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

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

Issue 23872010: Add metadata for type parameters (TypeVariableMirror). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebase Created 7 years, 3 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
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 4218 matching lines...) Expand 10 before | Expand all | Expand 10 after
4229 if (CurrentToken() == Token::kLT) { 4229 if (CurrentToken() == Token::kLT) {
4230 const GrowableObjectArray& type_parameters_array = 4230 const GrowableObjectArray& type_parameters_array =
4231 GrowableObjectArray::Handle(GrowableObjectArray::New()); 4231 GrowableObjectArray::Handle(GrowableObjectArray::New());
4232 intptr_t index = 0; 4232 intptr_t index = 0;
4233 TypeParameter& type_parameter = TypeParameter::Handle(); 4233 TypeParameter& type_parameter = TypeParameter::Handle();
4234 TypeParameter& existing_type_parameter = TypeParameter::Handle(); 4234 TypeParameter& existing_type_parameter = TypeParameter::Handle();
4235 String& existing_type_parameter_name = String::Handle(); 4235 String& existing_type_parameter_name = String::Handle();
4236 AbstractType& type_parameter_bound = Type::Handle(); 4236 AbstractType& type_parameter_bound = Type::Handle();
4237 do { 4237 do {
4238 ConsumeToken(); 4238 ConsumeToken();
4239 SkipMetadata(); 4239 const intptr_t metadata_pos = SkipMetadata();
4240 const intptr_t type_parameter_pos = TokenPos(); 4240 const intptr_t type_parameter_pos = TokenPos();
4241 String& type_parameter_name = 4241 String& type_parameter_name =
4242 *ExpectUserDefinedTypeIdentifier("type parameter expected"); 4242 *ExpectUserDefinedTypeIdentifier("type parameter expected");
4243 // Check for duplicate type parameters. 4243 // Check for duplicate type parameters.
4244 for (intptr_t i = 0; i < index; i++) { 4244 for (intptr_t i = 0; i < index; i++) {
4245 existing_type_parameter ^= type_parameters_array.At(i); 4245 existing_type_parameter ^= type_parameters_array.At(i);
4246 existing_type_parameter_name = existing_type_parameter.name(); 4246 existing_type_parameter_name = existing_type_parameter.name();
4247 if (existing_type_parameter_name.Equals(type_parameter_name)) { 4247 if (existing_type_parameter_name.Equals(type_parameter_name)) {
4248 ErrorMsg(type_parameter_pos, "duplicate type parameter '%s'", 4248 ErrorMsg(type_parameter_pos, "duplicate type parameter '%s'",
4249 type_parameter_name.ToCString()); 4249 type_parameter_name.ToCString());
4250 } 4250 }
4251 } 4251 }
4252 if (CurrentToken() == Token::kEXTENDS) { 4252 if (CurrentToken() == Token::kEXTENDS) {
4253 ConsumeToken(); 4253 ConsumeToken();
4254 // A bound may refer to the owner of the type parameter it applies to, 4254 // A bound may refer to the owner of the type parameter it applies to,
4255 // i.e. to the class or interface currently being parsed. 4255 // i.e. to the class or interface currently being parsed.
4256 // Postpone resolution in order to avoid resolving the class and its 4256 // Postpone resolution in order to avoid resolving the class and its
4257 // type parameters, as they are not fully parsed yet. 4257 // type parameters, as they are not fully parsed yet.
4258 type_parameter_bound = ParseType(ClassFinalizer::kDoNotResolve); 4258 type_parameter_bound = ParseType(ClassFinalizer::kDoNotResolve);
4259 } else { 4259 } else {
4260 type_parameter_bound = isolate()->object_store()->object_type(); 4260 type_parameter_bound = isolate()->object_store()->object_type();
4261 } 4261 }
4262 type_parameter = TypeParameter::New(cls, 4262 type_parameter = TypeParameter::New(cls,
4263 index, 4263 index,
4264 type_parameter_name, 4264 type_parameter_name,
4265 type_parameter_bound, 4265 type_parameter_bound,
4266 type_parameter_pos); 4266 type_parameter_pos);
4267 type_parameters_array.Add(type_parameter); 4267 type_parameters_array.Add(type_parameter);
4268 if (metadata_pos >= 0) {
4269 library_.AddTypeParameterMetadata(type_parameter, metadata_pos);
4270 }
4268 index++; 4271 index++;
4269 } while (CurrentToken() == Token::kCOMMA); 4272 } while (CurrentToken() == Token::kCOMMA);
4270 Token::Kind token = CurrentToken(); 4273 Token::Kind token = CurrentToken();
4271 if ((token == Token::kGT) || (token == Token::kSHR)) { 4274 if ((token == Token::kGT) || (token == Token::kSHR)) {
4272 ConsumeRightAngleBracket(); 4275 ConsumeRightAngleBracket();
4273 } else { 4276 } else {
4274 ErrorMsg("right angle bracket expected"); 4277 ErrorMsg("right angle bracket expected");
4275 } 4278 }
4276 const TypeArguments& type_parameters = 4279 const TypeArguments& type_parameters =
4277 TypeArguments::Handle(NewTypeArguments(type_parameters_array)); 4280 TypeArguments::Handle(NewTypeArguments(type_parameters_array));
(...skipping 6132 matching lines...) Expand 10 before | Expand all | Expand 10 after
10410 void Parser::SkipQualIdent() { 10413 void Parser::SkipQualIdent() {
10411 ASSERT(IsIdentifier()); 10414 ASSERT(IsIdentifier());
10412 ConsumeToken(); 10415 ConsumeToken();
10413 if (CurrentToken() == Token::kPERIOD) { 10416 if (CurrentToken() == Token::kPERIOD) {
10414 ConsumeToken(); // Consume the kPERIOD token. 10417 ConsumeToken(); // Consume the kPERIOD token.
10415 ExpectIdentifier("identifier expected after '.'"); 10418 ExpectIdentifier("identifier expected after '.'");
10416 } 10419 }
10417 } 10420 }
10418 10421
10419 } // namespace dart 10422 } // namespace dart
OLDNEW
« runtime/vm/object.cc ('K') | « runtime/vm/object.cc ('k') | tests/lib/lib.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698