| 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 scope->AllocateVariables(first_parameter_index_, | 170 scope->AllocateVariables(first_parameter_index_, |
| 171 parameter_count, | 171 parameter_count, |
| 172 first_stack_local_index_, | 172 first_stack_local_index_, |
| 173 scope, | 173 scope, |
| 174 &context_owner); | 174 &context_owner); |
| 175 | 175 |
| 176 // If this function is not a closure function and if it contains captured | 176 // If this function is not a closure function and if it contains captured |
| 177 // variables, the context needs to be saved on entry and restored on exit. | 177 // variables, the context needs to be saved on entry and restored on exit. |
| 178 // Add and allocate a local variable to this purpose. | 178 // Add and allocate a local variable to this purpose. |
| 179 if ((context_owner != NULL) && !function().IsClosureFunction()) { | 179 if ((context_owner != NULL) && !function().IsClosureFunction()) { |
| 180 const String& context_var_name = | 180 const String& context_var_name = String::ZoneHandle( |
| 181 String::ZoneHandle(String::NewSymbol(":saved_entry_context_var")); | 181 String::NewSymbol(LocalVariable::kSavedContextVarName)); |
| 182 LocalVariable* context_var = | 182 LocalVariable* context_var = |
| 183 new LocalVariable(function().token_index(), | 183 new LocalVariable(function().token_index(), |
| 184 context_var_name, | 184 context_var_name, |
| 185 Type::ZoneHandle(Type::DynamicType())); | 185 Type::ZoneHandle(Type::DynamicType())); |
| 186 context_var->set_index(next_free_frame_index--); | 186 context_var->set_index(next_free_frame_index--); |
| 187 scope->AddVariable(context_var); | 187 scope->AddVariable(context_var); |
| 188 set_saved_context_var(context_var); | 188 set_saved_context_var(context_var); |
| 189 } | 189 } |
| 190 | 190 |
| 191 // Frame indices are relative to the frame pointer and are decreasing. | 191 // Frame indices are relative to the frame pointer and are decreasing. |
| (...skipping 3685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3877 current_block_->scope->function_level() + 1, | 3877 current_block_->scope->function_level() + 1, |
| 3878 0); | 3878 0); |
| 3879 } | 3879 } |
| 3880 ChainNewBlock(outer_scope); | 3880 ChainNewBlock(outer_scope); |
| 3881 } | 3881 } |
| 3882 | 3882 |
| 3883 | 3883 |
| 3884 SequenceNode* Parser::CloseBlock() { | 3884 SequenceNode* Parser::CloseBlock() { |
| 3885 SequenceNode* statements = current_block_->statements; | 3885 SequenceNode* statements = current_block_->statements; |
| 3886 if (current_block_->scope != NULL) { | 3886 if (current_block_->scope != NULL) { |
| 3887 // Record the end token index of the scope. | 3887 // Record the begin and end token index of the scope. |
| 3888 ASSERT(statements != NULL); |
| 3889 current_block_->scope->set_begin_token_index(statements->token_index()); |
| 3888 current_block_->scope->set_end_token_index(token_index_); | 3890 current_block_->scope->set_end_token_index(token_index_); |
| 3889 } | 3891 } |
| 3890 current_block_ = current_block_->parent; | 3892 current_block_ = current_block_->parent; |
| 3891 return statements; | 3893 return statements; |
| 3892 } | 3894 } |
| 3893 | 3895 |
| 3894 | 3896 |
| 3895 // Set up default values for all optional parameters to the function. | 3897 // Set up default values for all optional parameters to the function. |
| 3896 void Parser::SetupDefaultsForOptionalParams(const ParamList* params, | 3898 void Parser::SetupDefaultsForOptionalParams(const ParamList* params, |
| 3897 Array& default_values) { | 3899 Array& default_values) { |
| (...skipping 4678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8576 void Parser::SkipQualIdent() { | 8578 void Parser::SkipQualIdent() { |
| 8577 ASSERT(IsIdentifier()); | 8579 ASSERT(IsIdentifier()); |
| 8578 ConsumeToken(); | 8580 ConsumeToken(); |
| 8579 if (CurrentToken() == Token::kPERIOD) { | 8581 if (CurrentToken() == Token::kPERIOD) { |
| 8580 ConsumeToken(); // Consume the kPERIOD token. | 8582 ConsumeToken(); // Consume the kPERIOD token. |
| 8581 ExpectIdentifier("identifier expected after '.'"); | 8583 ExpectIdentifier("identifier expected after '.'"); |
| 8582 } | 8584 } |
| 8583 } | 8585 } |
| 8584 | 8586 |
| 8585 } // namespace dart | 8587 } // namespace dart |
| OLD | NEW |