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

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

Issue 8804019: Support qualified factory names (fix issue 514). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years 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/language.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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/compiler_stats.h" 10 #include "vm/compiler_stats.h"
(...skipping 2308 matching lines...) Expand 10 before | Expand all | Expand 10 after
2319 // Optionally parse a (possibly named) constructor name or factory. 2319 // Optionally parse a (possibly named) constructor name or factory.
2320 if ((CurrentToken() == Token::kIDENT) && 2320 if ((CurrentToken() == Token::kIDENT) &&
2321 (CurrentLiteral()->Equals(members->class_name()) || member.has_factory)) { 2321 (CurrentLiteral()->Equals(members->class_name()) || member.has_factory)) {
2322 member.name = CurrentLiteral(); 2322 member.name = CurrentLiteral();
2323 member.name_pos = this->token_index_; 2323 member.name_pos = this->token_index_;
2324 ConsumeToken(); 2324 ConsumeToken();
2325 // Resolution of the factory result type is always postponed until class 2325 // Resolution of the factory result type is always postponed until class
2326 // finalization, so that the list of type parameters in the factory 2326 // finalization, so that the list of type parameters in the factory
2327 // signature can be checked at the same time. 2327 // signature can be checked at the same time.
2328 if (member.has_factory) { 2328 if (member.has_factory) {
2329 String& qualifier = String::Handle();
2330 if (CurrentToken() == Token::kPERIOD) {
2331 LibraryPrefix& lib_prefix = LibraryPrefix::ZoneHandle();
2332 lib_prefix = current_class().LookupLibraryPrefix(*member.name);
2333 if (!lib_prefix.IsNull()) {
2334 // We have a library prefix qualified identifier.
2335 ConsumeToken(); // Consume the kPERIOD token.
2336 qualifier ^= member.name->raw();
2337 member.name = ExpectIdentifier("identifier expected");
2338 }
2339 }
2329 const UnresolvedClass& unresolved_factory_class = 2340 const UnresolvedClass& unresolved_factory_class =
2330 UnresolvedClass::Handle(UnresolvedClass::New(member.name_pos, 2341 UnresolvedClass::Handle(UnresolvedClass::New(member.name_pos,
2331 String::Handle(), 2342 qualifier,
2332 *(member.name))); 2343 *(member.name)));
2333 const Class& signature_class = Class::Handle( 2344 const Class& signature_class = Class::Handle(
2334 Class::New(String::Handle(String::NewSymbol(":factory_signature")), 2345 Class::New(String::Handle(String::NewSymbol(":factory_signature")),
2335 Script::Handle())); 2346 Script::Handle()));
2336 signature_class.set_is_finalized(); 2347 signature_class.set_is_finalized();
2337 unresolved_factory_class.set_factory_signature_class(signature_class); 2348 unresolved_factory_class.set_factory_signature_class(signature_class);
2338 // The type arguments of the result type are set during finalization. 2349 // The type arguments of the result type are set during finalization.
2339 const TypeArguments& args = TypeArguments::Handle(); 2350 const TypeArguments& args = TypeArguments::Handle();
2340 member.type = &Type::ZoneHandle( 2351 member.type = &Type::ZoneHandle(
2341 Type::NewParameterizedType(unresolved_factory_class, args)); 2352 Type::NewParameterizedType(unresolved_factory_class, args));
(...skipping 5254 matching lines...) Expand 10 before | Expand all | Expand 10 after
7596 } 7607 }
7597 7608
7598 7609
7599 void Parser::SkipNestedExpr() { 7610 void Parser::SkipNestedExpr() {
7600 const bool saved_mode = SetAllowFunctionLiterals(true); 7611 const bool saved_mode = SetAllowFunctionLiterals(true);
7601 SkipExpr(); 7612 SkipExpr();
7602 SetAllowFunctionLiterals(saved_mode); 7613 SetAllowFunctionLiterals(saved_mode);
7603 } 7614 }
7604 7615
7605 } // namespace dart 7616 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698