| 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/parser.h" | 5 #include "vm/parser.h" |
| 6 | 6 |
| 7 #include "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
| 8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/compiler_stats.h" | 10 #include "vm/compiler_stats.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 | 135 |
| 136 // Allocate parameters and local variables, either in the local frame or | 136 // Allocate parameters and local variables, either in the local frame or |
| 137 // in the context(s). | 137 // in the context(s). |
| 138 LocalScope* context_owner = NULL; // No context needed yet. | 138 LocalScope* context_owner = NULL; // No context needed yet. |
| 139 int next_free_frame_index = | 139 int next_free_frame_index = |
| 140 scope->AllocateVariables(first_parameter_index_, | 140 scope->AllocateVariables(first_parameter_index_, |
| 141 parameter_count, | 141 parameter_count, |
| 142 first_stack_local_index_, | 142 first_stack_local_index_, |
| 143 scope, | 143 scope, |
| 144 &context_owner); | 144 &context_owner); |
| 145 |
| 146 // If this function is not a closure function and if it contains captured |
| 147 // variables, the context needs to be saved on entry and restored on exit. |
| 148 // Add and allocate a local variable to this purpose. |
| 149 if ((context_owner != NULL) && !function().IsClosureFunction()) { |
| 150 const String& context_var_name = |
| 151 String::ZoneHandle(String::NewSymbol(":saved_entry_context_var")); |
| 152 LocalVariable* context_var = |
| 153 new LocalVariable(function().token_index(), |
| 154 context_var_name, |
| 155 Type::ZoneHandle(Type::DynamicType())); |
| 156 context_var->set_index(next_free_frame_index--); |
| 157 scope->AddVariable(context_var); |
| 158 set_saved_context_var(context_var); |
| 159 } |
| 160 |
| 145 // Frame indices are relative to the frame pointer and are decreasing. | 161 // Frame indices are relative to the frame pointer and are decreasing. |
| 146 ASSERT(next_free_frame_index <= first_stack_local_index_); | 162 ASSERT(next_free_frame_index <= first_stack_local_index_); |
| 147 stack_local_count_ = first_stack_local_index_ - next_free_frame_index; | 163 stack_local_count_ = first_stack_local_index_ - next_free_frame_index; |
| 148 } | 164 } |
| 149 | 165 |
| 150 | 166 |
| 151 struct Parser::Block : public ZoneAllocated { | 167 struct Parser::Block : public ZoneAllocated { |
| 152 Block(Block* outer_block, LocalScope* local_scope, SequenceNode* seq) | 168 Block(Block* outer_block, LocalScope* local_scope, SequenceNode* seq) |
| 153 : parent(outer_block), scope(local_scope), statements(seq) { | 169 : parent(outer_block), scope(local_scope), statements(seq) { |
| 154 ASSERT(scope != NULL); | 170 ASSERT(scope != NULL); |
| (...skipping 8070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8225 void Parser::SkipQualIdent() { | 8241 void Parser::SkipQualIdent() { |
| 8226 ASSERT(IsIdentifier()); | 8242 ASSERT(IsIdentifier()); |
| 8227 ConsumeToken(); | 8243 ConsumeToken(); |
| 8228 if (CurrentToken() == Token::kPERIOD) { | 8244 if (CurrentToken() == Token::kPERIOD) { |
| 8229 ConsumeToken(); // Consume the kPERIOD token. | 8245 ConsumeToken(); // Consume the kPERIOD token. |
| 8230 ExpectIdentifier("identifier expected after '.'"); | 8246 ExpectIdentifier("identifier expected after '.'"); |
| 8231 } | 8247 } |
| 8232 } | 8248 } |
| 8233 | 8249 |
| 8234 } // namespace dart | 8250 } // namespace dart |
| OLD | NEW |