Chromium Code Reviews| Index: runtime/vm/parser.cc |
| diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc |
| index 1801810032047e683073d49abaf6c00ad17ac70d..acbb501eb4050e92647479d0c22e3e39e96ed7a1 100644 |
| --- a/runtime/vm/parser.cc |
| +++ b/runtime/vm/parser.cc |
| @@ -878,7 +878,48 @@ RawArray* Parser::EvaluateMetadata() { |
| (LookaheadToken(5) == Token::kLPAREN))) { |
| expr = ParseNewOperator(Token::kCONST); |
| } else { |
| - expr = ParsePrimary(); |
| + // Can be x, C, L.C, C.x, or L.C.x. |
| + expr = ParsePrimary(); // Consumes x, C or L.C. |
| + |
|
hausner
2013/10/28 23:06:01
You could simplify the following code a bit if you
|
| + if (CurrentToken() == Token::kPERIOD) { |
| + ConsumeToken(); |
| + const intptr_t ident_pos = TokenPos(); |
| + String* ident = ExpectIdentifier("identifier expected"); |
| + |
| + Class& cls = Class::Handle(); |
| + if (expr->IsPrimaryNode()) { |
| + PrimaryNode* primary_node = expr->AsPrimaryNode(); |
| + if (primary_node->primary().IsClass()) { |
| + // If the primary node referred to a class we are loading a |
| + // qualified static field. |
| + cls ^= primary_node->primary().raw(); |
| + } |
| + } |
| + if (cls.IsNull()) { |
| + ErrorMsg(expr_pos, "class expected"); |
|
rmacnak
2013/10/28 22:06:35
Is this the appropriate position to point at?
hausner
2013/10/28 23:06:01
yes
|
| + } |
| + const Field& field = Field::Handle(cls.LookupStaticField(*ident)); |
| + if (field.IsNull()) { |
| + ErrorMsg(ident_pos, "field expected"); |
|
rmacnak
2013/10/28 22:06:35
Perhaps "<ident> is not a field of <class>"?
hausner
2013/10/28 23:06:01
I like this slightly better if you format the erro
|
| + } |
| + expr = GenerateStaticFieldLookup(field, TokenPos()); |
| + } |
| + |
| + // C or L.C. |
| + if (expr->IsPrimaryNode()) { |
| + PrimaryNode* primary_node = expr->AsPrimaryNode(); |
| + if (primary_node->primary().IsClass()) { |
| + const Class& type_class = Class::Cast(primary_node->primary()); |
| + AbstractType& type = Type::ZoneHandle( |
| + Type::New(type_class, TypeArguments::Handle(), |
| + primary_node->token_pos(), Heap::kOld)); |
| + type = ClassFinalizer::FinalizeType( |
| + current_class(), type, ClassFinalizer::kCanonicalize); |
| + // Type may be malbounded, but not malformed. |
| + ASSERT(!type.IsMalformed()); |
| + expr = new TypeNode(primary_node->token_pos(), type); |
| + } |
| + } |
| } |
| if (expr->EvalConstExpr() == NULL) { |
| ErrorMsg(expr_pos, "expression must be a compile-time constant"); |