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

Side by Side 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, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/lib/lib.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/bootstrap.h" 9 #include "vm/bootstrap.h"
10 #include "vm/class_finalizer.h" 10 #include "vm/class_finalizer.h"
(...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 } 871 }
872 AstNode* expr = NULL; 872 AstNode* expr = NULL;
873 if ((LookaheadToken(1) == Token::kLPAREN) || 873 if ((LookaheadToken(1) == Token::kLPAREN) ||
874 ((LookaheadToken(1) == Token::kPERIOD) && 874 ((LookaheadToken(1) == Token::kPERIOD) &&
875 (LookaheadToken(3) == Token::kLPAREN)) || 875 (LookaheadToken(3) == Token::kLPAREN)) ||
876 ((LookaheadToken(1) == Token::kPERIOD) && 876 ((LookaheadToken(1) == Token::kPERIOD) &&
877 (LookaheadToken(3) == Token::kPERIOD) && 877 (LookaheadToken(3) == Token::kPERIOD) &&
878 (LookaheadToken(5) == Token::kLPAREN))) { 878 (LookaheadToken(5) == Token::kLPAREN))) {
879 expr = ParseNewOperator(Token::kCONST); 879 expr = ParseNewOperator(Token::kCONST);
880 } else { 880 } else {
881 expr = ParsePrimary(); 881 // Can be x, C, L.C, C.x, or L.C.x.
882 expr = ParsePrimary(); // Consumes x, C or L.C.
883
hausner 2013/10/28 23:06:01 You could simplify the following code a bit if you
884 if (CurrentToken() == Token::kPERIOD) {
885 ConsumeToken();
886 const intptr_t ident_pos = TokenPos();
887 String* ident = ExpectIdentifier("identifier expected");
888
889 Class& cls = Class::Handle();
890 if (expr->IsPrimaryNode()) {
891 PrimaryNode* primary_node = expr->AsPrimaryNode();
892 if (primary_node->primary().IsClass()) {
893 // If the primary node referred to a class we are loading a
894 // qualified static field.
895 cls ^= primary_node->primary().raw();
896 }
897 }
898 if (cls.IsNull()) {
899 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
900 }
901 const Field& field = Field::Handle(cls.LookupStaticField(*ident));
902 if (field.IsNull()) {
903 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
904 }
905 expr = GenerateStaticFieldLookup(field, TokenPos());
906 }
907
908 // C or L.C.
909 if (expr->IsPrimaryNode()) {
910 PrimaryNode* primary_node = expr->AsPrimaryNode();
911 if (primary_node->primary().IsClass()) {
912 const Class& type_class = Class::Cast(primary_node->primary());
913 AbstractType& type = Type::ZoneHandle(
914 Type::New(type_class, TypeArguments::Handle(),
915 primary_node->token_pos(), Heap::kOld));
916 type = ClassFinalizer::FinalizeType(
917 current_class(), type, ClassFinalizer::kCanonicalize);
918 // Type may be malbounded, but not malformed.
919 ASSERT(!type.IsMalformed());
920 expr = new TypeNode(primary_node->token_pos(), type);
921 }
922 }
882 } 923 }
883 if (expr->EvalConstExpr() == NULL) { 924 if (expr->EvalConstExpr() == NULL) {
884 ErrorMsg(expr_pos, "expression must be a compile-time constant"); 925 ErrorMsg(expr_pos, "expression must be a compile-time constant");
885 } 926 }
886 const Instance& val = EvaluateConstExpr(expr_pos, expr); 927 const Instance& val = EvaluateConstExpr(expr_pos, expr);
887 meta_values.Add(val); 928 meta_values.Add(val);
888 } 929 }
889 return Array::MakeArray(meta_values); 930 return Array::MakeArray(meta_values);
890 } 931 }
891 932
(...skipping 9696 matching lines...) Expand 10 before | Expand all | Expand 10 after
10588 void Parser::SkipQualIdent() { 10629 void Parser::SkipQualIdent() {
10589 ASSERT(IsIdentifier()); 10630 ASSERT(IsIdentifier());
10590 ConsumeToken(); 10631 ConsumeToken();
10591 if (CurrentToken() == Token::kPERIOD) { 10632 if (CurrentToken() == Token::kPERIOD) {
10592 ConsumeToken(); // Consume the kPERIOD token. 10633 ConsumeToken(); // Consume the kPERIOD token.
10593 ExpectIdentifier("identifier expected after '.'"); 10634 ExpectIdentifier("identifier expected after '.'");
10594 } 10635 }
10595 } 10636 }
10596 10637
10597 } // namespace dart 10638 } // namespace dart
OLDNEW
« 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