| 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 "lib/invocation_mirror.h" | 7 #include "lib/invocation_mirror.h" |
| 8 #include "platform/utils.h" | 8 #include "platform/utils.h" |
| 9 #include "vm/bootstrap.h" | 9 #include "vm/bootstrap.h" |
| 10 #include "vm/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
| (...skipping 5277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5288 outer_scope->function_level(), | 5288 outer_scope->function_level(), |
| 5289 outer_scope->loop_level() + 1)); | 5289 outer_scope->loop_level() + 1)); |
| 5290 } | 5290 } |
| 5291 | 5291 |
| 5292 | 5292 |
| 5293 void Parser::OpenFunctionBlock(const Function& func) { | 5293 void Parser::OpenFunctionBlock(const Function& func) { |
| 5294 LocalScope* outer_scope; | 5294 LocalScope* outer_scope; |
| 5295 if (current_block_ == NULL) { | 5295 if (current_block_ == NULL) { |
| 5296 if (!func.IsLocalFunction()) { | 5296 if (!func.IsLocalFunction()) { |
| 5297 // We are compiling a non-nested function. | 5297 // We are compiling a non-nested function. |
| 5298 outer_scope = new LocalScope(NULL, 0, 0); | 5298 outer_scope = new(isolate()) LocalScope(NULL, 0, 0); |
| 5299 } else { | 5299 } else { |
| 5300 // We are compiling the function of an invoked closure. | 5300 // We are compiling the function of an invoked closure. |
| 5301 // Restore the outer scope containing all captured variables. | 5301 // Restore the outer scope containing all captured variables. |
| 5302 const ContextScope& context_scope = | 5302 const ContextScope& context_scope = |
| 5303 ContextScope::Handle(func.context_scope()); | 5303 ContextScope::Handle(isolate(), func.context_scope()); |
| 5304 ASSERT(!context_scope.IsNull()); | 5304 ASSERT(!context_scope.IsNull()); |
| 5305 outer_scope = | 5305 outer_scope = new(isolate()) LocalScope( |
| 5306 new LocalScope(LocalScope::RestoreOuterScope(context_scope), 0, 0); | 5306 LocalScope::RestoreOuterScope(context_scope), 0, 0); |
| 5307 } | 5307 } |
| 5308 } else { | 5308 } else { |
| 5309 // We are parsing a nested function while compiling the enclosing function. | 5309 // We are parsing a nested function while compiling the enclosing function. |
| 5310 outer_scope = new LocalScope(current_block_->scope, | 5310 outer_scope = |
| 5311 current_block_->scope->function_level() + 1, | 5311 new(isolate()) LocalScope(current_block_->scope, |
| 5312 0); | 5312 current_block_->scope->function_level() + 1, |
| 5313 0); |
| 5313 } | 5314 } |
| 5314 ChainNewBlock(outer_scope); | 5315 ChainNewBlock(outer_scope); |
| 5315 } | 5316 } |
| 5316 | 5317 |
| 5317 | 5318 |
| 5318 SequenceNode* Parser::CloseBlock() { | 5319 SequenceNode* Parser::CloseBlock() { |
| 5319 SequenceNode* statements = current_block_->statements; | 5320 SequenceNode* statements = current_block_->statements; |
| 5320 if (current_block_->scope != NULL) { | 5321 if (current_block_->scope != NULL) { |
| 5321 // Record the begin and end token index of the scope. | 5322 // Record the begin and end token index of the scope. |
| 5322 ASSERT(statements != NULL); | 5323 ASSERT(statements != NULL); |
| (...skipping 5633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10956 void Parser::SkipQualIdent() { | 10957 void Parser::SkipQualIdent() { |
| 10957 ASSERT(IsIdentifier()); | 10958 ASSERT(IsIdentifier()); |
| 10958 ConsumeToken(); | 10959 ConsumeToken(); |
| 10959 if (CurrentToken() == Token::kPERIOD) { | 10960 if (CurrentToken() == Token::kPERIOD) { |
| 10960 ConsumeToken(); // Consume the kPERIOD token. | 10961 ConsumeToken(); // Consume the kPERIOD token. |
| 10961 ExpectIdentifier("identifier expected after '.'"); | 10962 ExpectIdentifier("identifier expected after '.'"); |
| 10962 } | 10963 } |
| 10963 } | 10964 } |
| 10964 | 10965 |
| 10965 } // namespace dart | 10966 } // namespace dart |
| OLD | NEW |