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 #include "vm/flags.h" | 6 #include "vm/flags.h" |
7 | 7 |
8 #ifndef DART_PRECOMPILED | 8 #ifndef DART_PRECOMPILED |
9 | 9 |
10 #include "lib/invocation_mirror.h" | 10 #include "lib/invocation_mirror.h" |
(...skipping 3111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3122 } | 3122 } |
3123 } | 3123 } |
3124 | 3124 |
3125 if (is_redirecting_constructor) { | 3125 if (is_redirecting_constructor) { |
3126 ParseConstructorRedirection(cls, receiver); | 3126 ParseConstructorRedirection(cls, receiver); |
3127 } else { | 3127 } else { |
3128 ParseInitializers(cls, receiver, &initialized_fields); | 3128 ParseInitializers(cls, receiver, &initialized_fields); |
3129 } | 3129 } |
3130 | 3130 |
3131 SequenceNode* init_statements = CloseBlock(); | 3131 SequenceNode* init_statements = CloseBlock(); |
3132 if (is_redirecting_constructor) { | 3132 if (FLAG_move_super) { |
| 3133 // Ignore the phase parameter. |
| 3134 current_block_->statements->Add(init_statements); |
| 3135 } else if (is_redirecting_constructor) { |
3133 // A redirecting super constructor simply passes the phase parameter on to | 3136 // A redirecting super constructor simply passes the phase parameter on to |
3134 // the target which executes the corresponding phase. | 3137 // the target which executes the corresponding phase. |
3135 current_block_->statements->Add(init_statements); | 3138 current_block_->statements->Add(init_statements); |
3136 } else if (init_statements->length() > 0) { | 3139 } else if (init_statements->length() > 0) { |
3137 // Generate guard around the initializer code. | 3140 // Generate guard around the initializer code. |
3138 LocalVariable* phase_param = LookupPhaseParameter(); | 3141 LocalVariable* phase_param = LookupPhaseParameter(); |
3139 AstNode* phase_value = new | 3142 AstNode* phase_value = new |
3140 LoadLocalNode(Scanner::kNoSourcePos, phase_param); | 3143 LoadLocalNode(Scanner::kNoSourcePos, phase_param); |
3141 AstNode* phase_check = new BinaryOpNode( | 3144 AstNode* phase_check = new BinaryOpNode( |
3142 Scanner::kNoSourcePos, Token::kBIT_AND, phase_value, | 3145 Scanner::kNoSourcePos, Token::kBIT_AND, phase_value, |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3269 InvocationMirror::kStatic, | 3272 InvocationMirror::kStatic, |
3270 InvocationMirror::kMethod, | 3273 InvocationMirror::kMethod, |
3271 NULL)); // No existing function. | 3274 NULL)); // No existing function. |
3272 } | 3275 } |
3273 } else { | 3276 } else { |
3274 UnexpectedToken(); | 3277 UnexpectedToken(); |
3275 } | 3278 } |
3276 | 3279 |
3277 SequenceNode* ctor_block = CloseBlock(); | 3280 SequenceNode* ctor_block = CloseBlock(); |
3278 if (ctor_block->length() > 0) { | 3281 if (ctor_block->length() > 0) { |
3279 // Generate guard around the constructor body code. | 3282 if (FLAG_move_super) { |
3280 LocalVariable* phase_param = LookupPhaseParameter(); | 3283 // Ignore the phase parameter. |
3281 AstNode* phase_value = | 3284 current_block_->statements->Add(ctor_block); |
3282 new LoadLocalNode(Scanner::kNoSourcePos, phase_param); | 3285 } else { |
3283 AstNode* phase_check = | 3286 // Generate guard around the constructor body code. |
3284 new BinaryOpNode(Scanner::kNoSourcePos, Token::kBIT_AND, | 3287 LocalVariable* phase_param = LookupPhaseParameter(); |
3285 phase_value, | 3288 AstNode* phase_value = |
3286 new LiteralNode(Scanner::kNoSourcePos, | 3289 new LoadLocalNode(Scanner::kNoSourcePos, phase_param); |
3287 Smi::ZoneHandle(Smi::New(Function::kCtorPhaseBody)))); | 3290 AstNode* phase_check = |
3288 AstNode* comparison = | 3291 new BinaryOpNode(Scanner::kNoSourcePos, Token::kBIT_AND, |
3289 new ComparisonNode(Scanner::kNoSourcePos, | 3292 phase_value, |
3290 Token::kNE_STRICT, | 3293 new LiteralNode(Scanner::kNoSourcePos, |
3291 phase_check, | 3294 Smi::ZoneHandle(Smi::New(Function::kCtorPhaseBody)))); |
3292 new LiteralNode(body_pos, | 3295 AstNode* comparison = |
3293 Smi::ZoneHandle(Smi::New(0)))); | 3296 new ComparisonNode(Scanner::kNoSourcePos, |
3294 AstNode* guarded_block_statements = | 3297 Token::kNE_STRICT, |
3295 new IfNode(Scanner::kNoSourcePos, comparison, ctor_block, NULL); | 3298 phase_check, |
3296 current_block_->statements->Add(guarded_block_statements); | 3299 new LiteralNode(body_pos, |
| 3300 Smi::ZoneHandle(Smi::New(0)))); |
| 3301 AstNode* guarded_block_statements = |
| 3302 new IfNode(Scanner::kNoSourcePos, comparison, ctor_block, NULL); |
| 3303 current_block_->statements->Add(guarded_block_statements); |
| 3304 } |
3297 } | 3305 } |
3298 current_block_->statements->Add(new ReturnNode(func.end_token_pos())); | 3306 current_block_->statements->Add(new ReturnNode(func.end_token_pos())); |
3299 SequenceNode* statements = CloseBlock(); | 3307 SequenceNode* statements = CloseBlock(); |
3300 return statements; | 3308 return statements; |
3301 } | 3309 } |
3302 | 3310 |
3303 | 3311 |
3304 // Parser is at the opening parenthesis of the formal parameter | 3312 // Parser is at the opening parenthesis of the formal parameter |
3305 // declaration of the function or constructor. | 3313 // declaration of the function or constructor. |
3306 // Parse the formal parameters and code. | 3314 // Parse the formal parameters and code. |
(...skipping 11177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14484 const ArgumentListNode& function_args, | 14492 const ArgumentListNode& function_args, |
14485 const LocalVariable* temp_for_last_arg, | 14493 const LocalVariable* temp_for_last_arg, |
14486 bool is_super_invocation) { | 14494 bool is_super_invocation) { |
14487 UNREACHABLE(); | 14495 UNREACHABLE(); |
14488 return NULL; | 14496 return NULL; |
14489 } | 14497 } |
14490 | 14498 |
14491 } // namespace dart | 14499 } // namespace dart |
14492 | 14500 |
14493 #endif // DART_PRECOMPILED | 14501 #endif // DART_PRECOMPILED |
OLD | NEW |