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

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

Issue 985203002: Allow direct access to type parameters from factory (issue 22700). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 9 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/language_analyzer.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 "platform/utils.h" 8 #include "platform/utils.h"
9 #include "vm/ast_transformer.h" 9 #include "vm/ast_transformer.h"
10 #include "vm/bootstrap.h" 10 #include "vm/bootstrap.h"
(...skipping 10692 matching lines...) Expand 10 before | Expand all | Expand 10 after
10703 while (true) { 10703 while (true) {
10704 AstNode* selector = NULL; 10704 AstNode* selector = NULL;
10705 if (CurrentToken() == Token::kPERIOD) { 10705 if (CurrentToken() == Token::kPERIOD) {
10706 ConsumeToken(); 10706 ConsumeToken();
10707 if (left->IsPrimaryNode()) { 10707 if (left->IsPrimaryNode()) {
10708 PrimaryNode* primary_node = left->AsPrimaryNode(); 10708 PrimaryNode* primary_node = left->AsPrimaryNode();
10709 const intptr_t primary_pos = primary_node->token_pos(); 10709 const intptr_t primary_pos = primary_node->token_pos();
10710 if (primary_node->primary().IsFunction()) { 10710 if (primary_node->primary().IsFunction()) {
10711 left = LoadClosure(primary_node); 10711 left = LoadClosure(primary_node);
10712 } else if (primary_node->primary().IsTypeParameter()) { 10712 } else if (primary_node->primary().IsTypeParameter()) {
10713 if (current_function().is_static()) { 10713 if (ParsingStaticMember()) {
10714 const String& name = String::ZoneHandle(Z, 10714 const String& name = String::ZoneHandle(Z,
10715 TypeParameter::Cast(primary_node->primary()).name()); 10715 TypeParameter::Cast(primary_node->primary()).name());
10716 ReportError(primary_pos, 10716 ReportError(primary_pos,
10717 "cannot access type parameter '%s' " 10717 "cannot access type parameter '%s' "
10718 "from static function", 10718 "from static function",
10719 name.ToCString()); 10719 name.ToCString());
10720 } 10720 }
10721 if (current_block_->scope->function_level() > 0) { 10721 if (current_block_->scope->function_level() > 0) {
10722 // Make sure that the instantiator is captured. 10722 // Make sure that the instantiator is captured.
10723 CaptureInstantiator(); 10723 CaptureInstantiator();
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
10789 const Class& type_class = Class::Cast(primary_node->primary()); 10789 const Class& type_class = Class::Cast(primary_node->primary());
10790 AbstractType& type = Type::ZoneHandle(Z, 10790 AbstractType& type = Type::ZoneHandle(Z,
10791 Type::New(type_class, TypeArguments::Handle(Z), 10791 Type::New(type_class, TypeArguments::Handle(Z),
10792 primary_pos, Heap::kOld)); 10792 primary_pos, Heap::kOld));
10793 type ^= ClassFinalizer::FinalizeType( 10793 type ^= ClassFinalizer::FinalizeType(
10794 current_class(), type, ClassFinalizer::kCanonicalize); 10794 current_class(), type, ClassFinalizer::kCanonicalize);
10795 // Type may be malbounded, but not malformed. 10795 // Type may be malbounded, but not malformed.
10796 ASSERT(!type.IsMalformed()); 10796 ASSERT(!type.IsMalformed());
10797 array = new(Z) TypeNode(primary_pos, type); 10797 array = new(Z) TypeNode(primary_pos, type);
10798 } else if (primary_node->primary().IsTypeParameter()) { 10798 } else if (primary_node->primary().IsTypeParameter()) {
10799 if (current_function().is_static()) { 10799 if (ParsingStaticMember()) {
10800 const String& name = String::ZoneHandle(Z, 10800 const String& name = String::ZoneHandle(Z,
10801 TypeParameter::Cast(primary_node->primary()).name()); 10801 TypeParameter::Cast(primary_node->primary()).name());
10802 ReportError(primary_pos, 10802 ReportError(primary_pos,
10803 "cannot access type parameter '%s' " 10803 "cannot access type parameter '%s' "
10804 "from static function", 10804 "from static function",
10805 name.ToCString()); 10805 name.ToCString());
10806 } 10806 }
10807 if (current_block_->scope->function_level() > 0) { 10807 if (current_block_->scope->function_level() > 0) {
10808 // Make sure that the instantiator is captured. 10808 // Make sure that the instantiator is captured.
10809 CaptureInstantiator(); 10809 CaptureInstantiator();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
10857 InvocationMirror::kStatic, 10857 InvocationMirror::kStatic,
10858 InvocationMirror::kMethod, 10858 InvocationMirror::kMethod,
10859 NULL); // No existing function. 10859 NULL); // No existing function.
10860 } else { 10860 } else {
10861 // Treat as call to unresolved (instance) method. 10861 // Treat as call to unresolved (instance) method.
10862 selector = ParseInstanceCall(LoadReceiver(primary_pos), name); 10862 selector = ParseInstanceCall(LoadReceiver(primary_pos), name);
10863 } 10863 }
10864 } else if (primary_node->primary().IsTypeParameter()) { 10864 } else if (primary_node->primary().IsTypeParameter()) {
10865 const String& name = String::ZoneHandle(Z, 10865 const String& name = String::ZoneHandle(Z,
10866 TypeParameter::Cast(primary_node->primary()).name()); 10866 TypeParameter::Cast(primary_node->primary()).name());
10867 if (current_function().is_static()) { 10867 if (ParsingStaticMember()) {
10868 // Treat as this.T(), because T is in scope. 10868 // Treat as this.T(), because T is in scope.
10869 ReportError(primary_pos, 10869 ReportError(primary_pos,
10870 "cannot access type parameter '%s' " 10870 "cannot access type parameter '%s' "
10871 "from static function", 10871 "from static function",
10872 name.ToCString()); 10872 name.ToCString());
10873 } else { 10873 } else {
10874 // Treat as call to unresolved (instance) method. 10874 // Treat as call to unresolved (instance) method.
10875 selector = ParseInstanceCall(LoadReceiver(primary_pos), name); 10875 selector = ParseInstanceCall(LoadReceiver(primary_pos), name);
10876 } 10876 }
10877 } else if (primary_node->primary().IsClass()) { 10877 } else if (primary_node->primary().IsClass()) {
(...skipping 25 matching lines...) Expand all
10903 } else if (primary_node->primary().IsClass()) { 10903 } else if (primary_node->primary().IsClass()) {
10904 const Class& type_class = Class::Cast(primary_node->primary()); 10904 const Class& type_class = Class::Cast(primary_node->primary());
10905 AbstractType& type = Type::ZoneHandle(Z, Type::New( 10905 AbstractType& type = Type::ZoneHandle(Z, Type::New(
10906 type_class, TypeArguments::Handle(Z), primary_pos)); 10906 type_class, TypeArguments::Handle(Z), primary_pos));
10907 type = ClassFinalizer::FinalizeType( 10907 type = ClassFinalizer::FinalizeType(
10908 current_class(), type, ClassFinalizer::kCanonicalize); 10908 current_class(), type, ClassFinalizer::kCanonicalize);
10909 // Type may be malbounded, but not malformed. 10909 // Type may be malbounded, but not malformed.
10910 ASSERT(!type.IsMalformed()); 10910 ASSERT(!type.IsMalformed());
10911 left = new(Z) TypeNode(primary_pos, type); 10911 left = new(Z) TypeNode(primary_pos, type);
10912 } else if (primary_node->primary().IsTypeParameter()) { 10912 } else if (primary_node->primary().IsTypeParameter()) {
10913 if (current_function().is_static()) { 10913 if (ParsingStaticMember()) {
10914 const String& name = String::ZoneHandle(Z, 10914 const String& name = String::ZoneHandle(Z,
10915 TypeParameter::Cast(primary_node->primary()).name()); 10915 TypeParameter::Cast(primary_node->primary()).name());
10916 ReportError(primary_pos, 10916 ReportError(primary_pos,
10917 "cannot access type parameter '%s' " 10917 "cannot access type parameter '%s' "
10918 "from static function", 10918 "from static function",
10919 name.ToCString()); 10919 name.ToCString());
10920 } 10920 }
10921 if (current_block_->scope->function_level() > 0) { 10921 if (current_block_->scope->function_level() > 0) {
10922 // Make sure that the instantiator is captured. 10922 // Make sure that the instantiator is captured.
10923 CaptureInstantiator(); 10923 CaptureInstantiator();
(...skipping 2278 matching lines...) Expand 10 before | Expand all | Expand 10 after
13202 void Parser::SkipQualIdent() { 13202 void Parser::SkipQualIdent() {
13203 ASSERT(IsIdentifier()); 13203 ASSERT(IsIdentifier());
13204 ConsumeToken(); 13204 ConsumeToken();
13205 if (CurrentToken() == Token::kPERIOD) { 13205 if (CurrentToken() == Token::kPERIOD) {
13206 ConsumeToken(); // Consume the kPERIOD token. 13206 ConsumeToken(); // Consume the kPERIOD token.
13207 ExpectIdentifier("identifier expected after '.'"); 13207 ExpectIdentifier("identifier expected after '.'");
13208 } 13208 }
13209 } 13209 }
13210 13210
13211 } // namespace dart 13211 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | tests/language/language_analyzer.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698