| 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_RUNTIME | 8 #ifndef DART_PRECOMPILED_RUNTIME |
| 9 | 9 |
| 10 #include "lib/invocation_mirror.h" | 10 #include "lib/invocation_mirror.h" |
| (...skipping 2630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2641 | 2641 |
| 2642 if (found) continue; | 2642 if (found) continue; |
| 2643 | 2643 |
| 2644 field.RecordStore(Object::null_object()); | 2644 field.RecordStore(Object::null_object()); |
| 2645 } | 2645 } |
| 2646 } | 2646 } |
| 2647 | 2647 |
| 2648 | 2648 |
| 2649 AstNode* Parser::ParseExternalInitializedField(const Field& field) { | 2649 AstNode* Parser::ParseExternalInitializedField(const Field& field) { |
| 2650 // Only use this function if the initialized field originates | 2650 // Only use this function if the initialized field originates |
| 2651 // from a different class. We need to save and restore current | 2651 // from a different class. We need to save and restore the |
| 2652 // class, library, and token stream (script). | 2652 // library and token stream (script). |
| 2653 // The current_class remains unchanged, so that type arguments |
| 2654 // are resolved in the correct scope class. |
| 2653 ASSERT(current_class().raw() != field.Origin()); | 2655 ASSERT(current_class().raw() != field.Origin()); |
| 2654 const Class& saved_class = Class::Handle(Z, current_class().raw()); | |
| 2655 const Library& saved_library = Library::Handle(Z, library().raw()); | 2656 const Library& saved_library = Library::Handle(Z, library().raw()); |
| 2656 const Script& saved_script = Script::Handle(Z, script().raw()); | 2657 const Script& saved_script = Script::Handle(Z, script().raw()); |
| 2657 const TokenPosition saved_token_pos = TokenPos(); | 2658 const TokenPosition saved_token_pos = TokenPos(); |
| 2658 | 2659 |
| 2659 set_current_class(Class::Handle(Z, field.Origin())); | 2660 const Class& origin_class = Class::Handle(Z, field.Origin()); |
| 2660 set_library(Library::Handle(Z, current_class().library())); | 2661 set_library(Library::Handle(Z, origin_class.library())); |
| 2661 SetScript(Script::Handle(Z, current_class().script()), field.token_pos()); | 2662 SetScript(Script::Handle(Z, origin_class.script()), field.token_pos()); |
| 2662 | 2663 |
| 2663 ASSERT(IsIdentifier()); | 2664 ASSERT(IsIdentifier()); |
| 2664 ConsumeToken(); | 2665 ConsumeToken(); |
| 2665 ExpectToken(Token::kASSIGN); | 2666 ExpectToken(Token::kASSIGN); |
| 2666 AstNode* init_expr = NULL; | 2667 AstNode* init_expr = NULL; |
| 2667 TokenPosition expr_pos = TokenPos(); | 2668 TokenPosition expr_pos = TokenPos(); |
| 2668 if (field.is_const()) { | 2669 if (field.is_const()) { |
| 2669 init_expr = ParseConstExpr(); | 2670 init_expr = ParseConstExpr(); |
| 2670 } else { | 2671 } else { |
| 2671 init_expr = ParseExpr(kAllowConst, kConsumeCascades); | 2672 init_expr = ParseExpr(kAllowConst, kConsumeCascades); |
| 2672 if (init_expr->EvalConstExpr() != NULL) { | 2673 if (init_expr->EvalConstExpr() != NULL) { |
| 2673 Instance& expr_value = Instance::ZoneHandle(Z); | 2674 Instance& expr_value = Instance::ZoneHandle(Z); |
| 2674 if (!GetCachedConstant(expr_pos, &expr_value)) { | 2675 if (!GetCachedConstant(expr_pos, &expr_value)) { |
| 2675 expr_value = EvaluateConstExpr(expr_pos, init_expr).raw(); | 2676 expr_value = EvaluateConstExpr(expr_pos, init_expr).raw(); |
| 2676 CacheConstantValue(expr_pos, expr_value); | 2677 CacheConstantValue(expr_pos, expr_value); |
| 2677 } | 2678 } |
| 2678 init_expr = new(Z) LiteralNode(field.token_pos(), expr_value); | 2679 init_expr = new(Z) LiteralNode(field.token_pos(), expr_value); |
| 2679 } | 2680 } |
| 2680 } | 2681 } |
| 2681 set_current_class(saved_class); | |
| 2682 set_library(saved_library); | 2682 set_library(saved_library); |
| 2683 SetScript(saved_script, saved_token_pos); | 2683 SetScript(saved_script, saved_token_pos); |
| 2684 return init_expr; | 2684 return init_expr; |
| 2685 } | 2685 } |
| 2686 | 2686 |
| 2687 | 2687 |
| 2688 void Parser::ParseInitializedInstanceFields(const Class& cls, | 2688 void Parser::ParseInitializedInstanceFields(const Class& cls, |
| 2689 LocalVariable* receiver, | 2689 LocalVariable* receiver, |
| 2690 GrowableArray<Field*>* initialized_fields) { | 2690 GrowableArray<Field*>* initialized_fields) { |
| 2691 TRACE_PARSER("ParseInitializedInstanceFields"); | 2691 TRACE_PARSER("ParseInitializedInstanceFields"); |
| (...skipping 11924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14616 const ArgumentListNode& function_args, | 14616 const ArgumentListNode& function_args, |
| 14617 const LocalVariable* temp_for_last_arg, | 14617 const LocalVariable* temp_for_last_arg, |
| 14618 bool is_super_invocation) { | 14618 bool is_super_invocation) { |
| 14619 UNREACHABLE(); | 14619 UNREACHABLE(); |
| 14620 return NULL; | 14620 return NULL; |
| 14621 } | 14621 } |
| 14622 | 14622 |
| 14623 } // namespace dart | 14623 } // namespace dart |
| 14624 | 14624 |
| 14625 #endif // DART_PRECOMPILED_RUNTIME | 14625 #endif // DART_PRECOMPILED_RUNTIME |
| OLD | NEW |