Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(603)

Unified Diff: runtime/vm/parser.cc

Issue 40863002: Handle metadata with type literals or qualified identifiers. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: impl Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/lib/lib.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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");
« no previous file with comments | « no previous file | tests/lib/lib.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698