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

Side by Side Diff: runtime/vm/parser.cc

Issue 219473007: Deferred prefix support in metadata (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/language/deferred_constraints_constants_test.dart » ('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 "platform/utils.h" 8 #include "platform/utils.h"
9 #include "vm/bootstrap.h" 9 #include "vm/bootstrap.h"
10 #include "vm/class_finalizer.h" 10 #include "vm/class_finalizer.h"
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 RawArray* Parser::EvaluateMetadata() { 899 RawArray* Parser::EvaluateMetadata() {
900 CheckToken(Token::kAT, "Metadata character '@' expected"); 900 CheckToken(Token::kAT, "Metadata character '@' expected");
901 GrowableObjectArray& meta_values = 901 GrowableObjectArray& meta_values =
902 GrowableObjectArray::Handle(GrowableObjectArray::New()); 902 GrowableObjectArray::Handle(GrowableObjectArray::New());
903 while (CurrentToken() == Token::kAT) { 903 while (CurrentToken() == Token::kAT) {
904 ConsumeToken(); 904 ConsumeToken();
905 intptr_t expr_pos = TokenPos(); 905 intptr_t expr_pos = TokenPos();
906 if (!IsIdentifier()) { 906 if (!IsIdentifier()) {
907 ExpectIdentifier("identifier expected"); 907 ExpectIdentifier("identifier expected");
908 } 908 }
909 // Reject expressions with deferred library prefix eagerly.
910 Object& obj = Object::Handle(library_.LookupLocalObject(*CurrentLiteral()));
911 if (!obj.IsNull() && obj.IsLibraryPrefix()) {
912 if (LibraryPrefix::Cast(obj).is_deferred_load()) {
913 ErrorMsg("Metadata must be compile-time constant");
914 }
915 }
909 AstNode* expr = NULL; 916 AstNode* expr = NULL;
910 if ((LookaheadToken(1) == Token::kLPAREN) || 917 if ((LookaheadToken(1) == Token::kLPAREN) ||
911 ((LookaheadToken(1) == Token::kPERIOD) && 918 ((LookaheadToken(1) == Token::kPERIOD) &&
912 (LookaheadToken(3) == Token::kLPAREN)) || 919 (LookaheadToken(3) == Token::kLPAREN)) ||
913 ((LookaheadToken(1) == Token::kPERIOD) && 920 ((LookaheadToken(1) == Token::kPERIOD) &&
914 (LookaheadToken(3) == Token::kPERIOD) && 921 (LookaheadToken(3) == Token::kPERIOD) &&
915 (LookaheadToken(5) == Token::kLPAREN))) { 922 (LookaheadToken(5) == Token::kLPAREN))) {
916 expr = ParseNewOperator(Token::kCONST); 923 expr = ParseNewOperator(Token::kCONST);
917 } else { 924 } else {
918 // Can be x, C.x, or L.C.x. 925 // Can be x, C.x, or L.C.x.
(...skipping 8321 matching lines...) Expand 10 before | Expand all | Expand 10 after
9240 AstNode* Parser::ResolveIdentInPrefixScope(intptr_t ident_pos, 9247 AstNode* Parser::ResolveIdentInPrefixScope(intptr_t ident_pos,
9241 const LibraryPrefix& prefix, 9248 const LibraryPrefix& prefix,
9242 const String& ident) { 9249 const String& ident) {
9243 TRACE_PARSER("ResolveIdentInPrefixScope"); 9250 TRACE_PARSER("ResolveIdentInPrefixScope");
9244 HANDLESCOPE(isolate()); 9251 HANDLESCOPE(isolate());
9245 Object& obj = Object::Handle(); 9252 Object& obj = Object::Handle();
9246 if (prefix.is_loaded()) { 9253 if (prefix.is_loaded()) {
9247 obj = prefix.LookupObject(ident); 9254 obj = prefix.LookupObject(ident);
9248 } else { 9255 } else {
9249 // Remember that this function depends on an import prefix of an 9256 // Remember that this function depends on an import prefix of an
9250 // unloaded deferred library. 9257 // unloaded deferred library. Note that parsed_function() can be
9251 parsed_function()->AddDeferredPrefix(prefix); 9258 // NULL when parsing expressions outside the scope of a function.
9259 if (parsed_function() != NULL) {
9260 parsed_function()->AddDeferredPrefix(prefix);
9261 }
9252 } 9262 }
9253 if (obj.IsNull()) { 9263 if (obj.IsNull()) {
9254 // Unresolved prefixed primary identifier. 9264 // Unresolved prefixed primary identifier.
9255 return NULL; 9265 return NULL;
9256 } else if (obj.IsClass()) { 9266 } else if (obj.IsClass()) {
9257 const Class& cls = Class::Cast(obj); 9267 const Class& cls = Class::Cast(obj);
9258 return new PrimaryNode(ident_pos, Class::ZoneHandle(cls.raw())); 9268 return new PrimaryNode(ident_pos, Class::ZoneHandle(cls.raw()));
9259 } else if (obj.IsField()) { 9269 } else if (obj.IsField()) {
9260 const Field& field = Field::Cast(obj); 9270 const Field& field = Field::Cast(obj);
9261 ASSERT(field.is_static()); 9271 ASSERT(field.is_static());
(...skipping 1608 matching lines...) Expand 10 before | Expand all | Expand 10 after
10870 void Parser::SkipQualIdent() { 10880 void Parser::SkipQualIdent() {
10871 ASSERT(IsIdentifier()); 10881 ASSERT(IsIdentifier());
10872 ConsumeToken(); 10882 ConsumeToken();
10873 if (CurrentToken() == Token::kPERIOD) { 10883 if (CurrentToken() == Token::kPERIOD) {
10874 ConsumeToken(); // Consume the kPERIOD token. 10884 ConsumeToken(); // Consume the kPERIOD token.
10875 ExpectIdentifier("identifier expected after '.'"); 10885 ExpectIdentifier("identifier expected after '.'");
10876 } 10886 }
10877 } 10887 }
10878 10888
10879 } // namespace dart 10889 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | tests/language/deferred_constraints_constants_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698