| 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 "vm/bigint_operations.h" | 8 #include "vm/bigint_operations.h" |
| 9 #include "vm/class_finalizer.h" | 9 #include "vm/class_finalizer.h" |
| 10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
| (...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 913 // Build local scope for function and populate with the formal parameters. | 913 // Build local scope for function and populate with the formal parameters. |
| 914 OpenFunctionBlock(func); | 914 OpenFunctionBlock(func); |
| 915 AddFormalParamsToScope(¶ms, current_block_->scope); | 915 AddFormalParamsToScope(¶ms, current_block_->scope); |
| 916 | 916 |
| 917 intptr_t ident_pos = TokenPos(); | 917 intptr_t ident_pos = TokenPos(); |
| 918 const String& field_name = *ExpectIdentifier("field name expected"); | 918 const String& field_name = *ExpectIdentifier("field name expected"); |
| 919 const Class& field_class = Class::Handle(func.Owner()); | 919 const Class& field_class = Class::Handle(func.Owner()); |
| 920 const Field& field = | 920 const Field& field = |
| 921 Field::ZoneHandle(field_class.LookupStaticField(field_name)); | 921 Field::ZoneHandle(field_class.LookupStaticField(field_name)); |
| 922 | 922 |
| 923 if (!field.is_const() && |
| 924 (field.value() != Object::transition_sentinel().raw()) && |
| 925 (field.value() != Object::sentinel().raw())) { |
| 926 // The field has already been initialized at compile time (this can |
| 927 // happen, e.g., if we are recompiling for optimization). There is no |
| 928 // need to check for initialization and compile the potentially very |
| 929 // large initialization code. By skipping this code, the deoptimization |
| 930 // ids will not line up with the original code, but this is safe because |
| 931 // LoadStaticField does not deoptimize. |
| 932 LoadStaticFieldNode* load_node = new LoadStaticFieldNode(ident_pos, field); |
| 933 ReturnNode* return_node = new ReturnNode(ident_pos, load_node); |
| 934 current_block_->statements->Add(return_node); |
| 935 return CloseBlock(); |
| 936 } |
| 937 |
| 923 // Static const fields must have an initializer. | 938 // Static const fields must have an initializer. |
| 924 ExpectToken(Token::kASSIGN); | 939 ExpectToken(Token::kASSIGN); |
| 925 | 940 |
| 926 // We don't want to use ParseConstExpr() here because we don't want | 941 // We don't want to use ParseConstExpr() here because we don't want |
| 927 // the constant folding code to create, compile and execute a code | 942 // the constant folding code to create, compile and execute a code |
| 928 // fragment to evaluate the expression. Instead, we just make sure | 943 // fragment to evaluate the expression. Instead, we just make sure |
| 929 // the static const field initializer is a constant expression and | 944 // the static const field initializer is a constant expression and |
| 930 // leave the evaluation to the getter function. | 945 // leave the evaluation to the getter function. |
| 931 const intptr_t expr_pos = TokenPos(); | 946 const intptr_t expr_pos = TokenPos(); |
| 932 AstNode* expr = ParseExpr(kAllowConst, kConsumeCascades); | 947 AstNode* expr = ParseExpr(kAllowConst, kConsumeCascades); |
| (...skipping 9157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10090 void Parser::SkipQualIdent() { | 10105 void Parser::SkipQualIdent() { |
| 10091 ASSERT(IsIdentifier()); | 10106 ASSERT(IsIdentifier()); |
| 10092 ConsumeToken(); | 10107 ConsumeToken(); |
| 10093 if (CurrentToken() == Token::kPERIOD) { | 10108 if (CurrentToken() == Token::kPERIOD) { |
| 10094 ConsumeToken(); // Consume the kPERIOD token. | 10109 ConsumeToken(); // Consume the kPERIOD token. |
| 10095 ExpectIdentifier("identifier expected after '.'"); | 10110 ExpectIdentifier("identifier expected after '.'"); |
| 10096 } | 10111 } |
| 10097 } | 10112 } |
| 10098 | 10113 |
| 10099 } // namespace dart | 10114 } // namespace dart |
| OLD | NEW |