| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/scopes.h" | 5 #include "vm/scopes.h" |
| 6 | 6 |
| 7 #include "vm/ast.h" | 7 #include "vm/ast.h" |
| 8 #include "vm/bit_vector.h" | 8 #include "vm/bit_vector.h" |
| 9 #include "vm/object.h" | 9 #include "vm/object.h" |
| 10 #include "vm/parser.h" | 10 #include "vm/parser.h" |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 context_scope.SetContextLevelAt(captured_idx, adjusted_context_level); | 470 context_scope.SetContextLevelAt(captured_idx, adjusted_context_level); |
| 471 captured_idx++; | 471 captured_idx++; |
| 472 } | 472 } |
| 473 } | 473 } |
| 474 ASSERT(context_scope.num_variables() == captured_idx); // Verify count. | 474 ASSERT(context_scope.num_variables() == captured_idx); // Verify count. |
| 475 return context_scope.raw(); | 475 return context_scope.raw(); |
| 476 } | 476 } |
| 477 | 477 |
| 478 | 478 |
| 479 LocalScope* LocalScope::RestoreOuterScope(const ContextScope& context_scope) { | 479 LocalScope* LocalScope::RestoreOuterScope(const ContextScope& context_scope) { |
| 480 LocalScope* outer_scope = new LocalScope(NULL, 0, 0); | 480 // The function level of the outer scope is one less than the function level |
| 481 // of the current function, which is 0. |
| 482 LocalScope* outer_scope = new LocalScope(NULL, -1, 0); |
| 481 // Add all variables as aliases to the outer scope. | 483 // Add all variables as aliases to the outer scope. |
| 482 for (int i = 0; i < context_scope.num_variables(); i++) { | 484 for (int i = 0; i < context_scope.num_variables(); i++) { |
| 483 LocalVariable* variable = | 485 LocalVariable* variable = |
| 484 new LocalVariable(context_scope.TokenIndexAt(i), | 486 new LocalVariable(context_scope.TokenIndexAt(i), |
| 485 String::ZoneHandle(context_scope.NameAt(i)), | 487 String::ZoneHandle(context_scope.NameAt(i)), |
| 486 AbstractType::ZoneHandle(context_scope.TypeAt(i))); | 488 AbstractType::ZoneHandle(context_scope.TypeAt(i))); |
| 487 variable->set_is_captured(); | 489 variable->set_is_captured(); |
| 488 variable->set_index(context_scope.ContextIndexAt(i)); | 490 variable->set_index(context_scope.ContextIndexAt(i)); |
| 489 if (context_scope.IsFinalAt(i)) { | 491 if (context_scope.IsFinalAt(i)) { |
| 490 variable->set_is_final(); | 492 variable->set_is_final(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 } else { | 551 } else { |
| 550 // Shift negative indexes so that the lowest one is 0 (they are still | 552 // Shift negative indexes so that the lowest one is 0 (they are still |
| 551 // non-positive). | 553 // non-positive). |
| 552 return fixed_parameter_count - | 554 return fixed_parameter_count - |
| 553 (index() - ParsedFunction::kFirstLocalSlotIndex); | 555 (index() - ParsedFunction::kFirstLocalSlotIndex); |
| 554 } | 556 } |
| 555 } | 557 } |
| 556 | 558 |
| 557 | 559 |
| 558 } // namespace dart | 560 } // namespace dart |
| OLD | NEW |