| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 1105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1116 } | 1116 } |
| 1117 return super_op; | 1117 return super_op; |
| 1118 } | 1118 } |
| 1119 | 1119 |
| 1120 | 1120 |
| 1121 AstNode* Parser::CreateImplicitClosureNode(const Function& func, | 1121 AstNode* Parser::CreateImplicitClosureNode(const Function& func, |
| 1122 intptr_t token_pos, | 1122 intptr_t token_pos, |
| 1123 AstNode* receiver) { | 1123 AstNode* receiver) { |
| 1124 Function& implicit_closure_function = | 1124 Function& implicit_closure_function = |
| 1125 Function::ZoneHandle(func.ImplicitClosureFunction()); | 1125 Function::ZoneHandle(func.ImplicitClosureFunction()); |
| 1126 if (receiver == NULL) { | 1126 if (receiver != NULL) { |
| 1127 return new ImplicitStaticClosureNode(token_pos, implicit_closure_function); | |
| 1128 } else { | |
| 1129 // If we create an implicit instance closure from inside a closure of a | 1127 // If we create an implicit instance closure from inside a closure of a |
| 1130 // parameterized class, make sure that the receiver is captured as | 1128 // parameterized class, make sure that the receiver is captured as |
| 1131 // instantiator. | 1129 // instantiator. |
| 1132 if (current_block_->scope->function_level() > 0) { | 1130 if (current_block_->scope->function_level() > 0) { |
| 1133 const Class& signature_class = Class::Handle(func.signature_class()); | 1131 const Class& signature_class = Class::Handle(func.signature_class()); |
| 1134 if (signature_class.IsParameterized()) { | 1132 if (signature_class.IsParameterized()) { |
| 1135 CaptureReceiver(); | 1133 CaptureReceiver(); |
| 1136 } | 1134 } |
| 1137 } | 1135 } |
| 1138 return new ImplicitInstanceClosureNode(token_pos, | |
| 1139 implicit_closure_function, | |
| 1140 receiver); | |
| 1141 } | 1136 } |
| 1137 return new ClosureNode(token_pos, implicit_closure_function, receiver, NULL); |
| 1142 } | 1138 } |
| 1143 | 1139 |
| 1144 | 1140 |
| 1145 AstNode* Parser::ParseSuperFieldAccess(const String& field_name) { | 1141 AstNode* Parser::ParseSuperFieldAccess(const String& field_name) { |
| 1146 const intptr_t field_pos = token_index_; | 1142 const intptr_t field_pos = token_index_; |
| 1147 const Class& super_class = Class::Handle(current_class().SuperClass()); | 1143 const Class& super_class = Class::Handle(current_class().SuperClass()); |
| 1148 if (super_class.IsNull()) { | 1144 if (super_class.IsNull()) { |
| 1149 ErrorMsg("class '%s' does not have a superclass", | 1145 ErrorMsg("class '%s' does not have a superclass", |
| 1150 String::Handle(current_class().Name()).ToCString()); | 1146 String::Handle(current_class().Name()).ToCString()); |
| 1151 } | 1147 } |
| (...skipping 2349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3501 // captured. The captured variables will be recorded along with their | 3497 // captured. The captured variables will be recorded along with their |
| 3502 // allocation information in a Scope object stored in the function object. | 3498 // allocation information in a Scope object stored in the function object. |
| 3503 // This Scope object is then provided to the compiler when compiling the local | 3499 // This Scope object is then provided to the compiler when compiling the local |
| 3504 // function. It would be too early to record the captured variables here, | 3500 // function. It would be too early to record the captured variables here, |
| 3505 // since further closure functions may capture more variables. | 3501 // since further closure functions may capture more variables. |
| 3506 // This Scope object is constructed after all variables have been allocated. | 3502 // This Scope object is constructed after all variables have been allocated. |
| 3507 // The local scope of the parsed function can be pruned, since contained | 3503 // The local scope of the parsed function can be pruned, since contained |
| 3508 // variables are not relevant for the compilation of the enclosing function. | 3504 // variables are not relevant for the compilation of the enclosing function. |
| 3509 // This pruning is done by omitting to hook the local scope in its parent | 3505 // This pruning is done by omitting to hook the local scope in its parent |
| 3510 // scope in the constructor of LocalScope. | 3506 // scope in the constructor of LocalScope. |
| 3511 AstNode* closure = new ClosureNode(ident_pos, function, statements->scope()); | 3507 AstNode* closure = |
| 3508 new ClosureNode(ident_pos, function, NULL, statements->scope()); |
| 3512 | 3509 |
| 3513 if (function_variable == NULL) { | 3510 if (function_variable == NULL) { |
| 3514 ASSERT(is_literal); | 3511 ASSERT(is_literal); |
| 3515 return closure; | 3512 return closure; |
| 3516 } else { | 3513 } else { |
| 3517 AstNode* initialization = | 3514 AstNode* initialization = |
| 3518 new StoreLocalNode(ident_pos, *function_variable, closure); | 3515 new StoreLocalNode(ident_pos, *function_variable, closure); |
| 3519 return initialization; | 3516 return initialization; |
| 3520 } | 3517 } |
| 3521 } | 3518 } |
| (...skipping 3525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7047 } | 7044 } |
| 7048 | 7045 |
| 7049 | 7046 |
| 7050 void Parser::SkipNestedExpr() { | 7047 void Parser::SkipNestedExpr() { |
| 7051 const bool saved_mode = SetAllowFunctionLiterals(true); | 7048 const bool saved_mode = SetAllowFunctionLiterals(true); |
| 7052 SkipExpr(); | 7049 SkipExpr(); |
| 7053 SetAllowFunctionLiterals(saved_mode); | 7050 SetAllowFunctionLiterals(saved_mode); |
| 7054 } | 7051 } |
| 7055 | 7052 |
| 7056 } // namespace dart | 7053 } // namespace dart |
| OLD | NEW |