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

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 + TODOs 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 4225 matching lines...) Expand 10 before | Expand all | Expand 10 after
4236 if (CurrentToken() == Token::kLT) { 4236 if (CurrentToken() == Token::kLT) {
4237 const GrowableObjectArray& type_parameters_array = 4237 const GrowableObjectArray& type_parameters_array =
4238 GrowableObjectArray::Handle(GrowableObjectArray::New()); 4238 GrowableObjectArray::Handle(GrowableObjectArray::New());
4239 intptr_t index = 0; 4239 intptr_t index = 0;
4240 TypeParameter& type_parameter = TypeParameter::Handle(); 4240 TypeParameter& type_parameter = TypeParameter::Handle();
4241 TypeParameter& existing_type_parameter = TypeParameter::Handle(); 4241 TypeParameter& existing_type_parameter = TypeParameter::Handle();
4242 String& existing_type_parameter_name = String::Handle(); 4242 String& existing_type_parameter_name = String::Handle();
4243 AbstractType& type_parameter_bound = Type::Handle(); 4243 AbstractType& type_parameter_bound = Type::Handle();
4244 do { 4244 do {
4245 ConsumeToken(); 4245 ConsumeToken();
4246 SkipMetadata(); 4246 const intptr_t metadata_pos = SkipMetadata();
4247 const intptr_t type_parameter_pos = TokenPos(); 4247 const intptr_t type_parameter_pos = TokenPos();
4248 String& type_parameter_name = 4248 String& type_parameter_name =
4249 *ExpectUserDefinedTypeIdentifier("type parameter expected"); 4249 *ExpectUserDefinedTypeIdentifier("type parameter expected");
4250 // Check for duplicate type parameters. 4250 // Check for duplicate type parameters.
4251 for (intptr_t i = 0; i < index; i++) { 4251 for (intptr_t i = 0; i < index; i++) {
4252 existing_type_parameter ^= type_parameters_array.At(i); 4252 existing_type_parameter ^= type_parameters_array.At(i);
4253 existing_type_parameter_name = existing_type_parameter.name(); 4253 existing_type_parameter_name = existing_type_parameter.name();
4254 if (existing_type_parameter_name.Equals(type_parameter_name)) { 4254 if (existing_type_parameter_name.Equals(type_parameter_name)) {
4255 ErrorMsg(type_parameter_pos, "duplicate type parameter '%s'", 4255 ErrorMsg(type_parameter_pos, "duplicate type parameter '%s'",
4256 type_parameter_name.ToCString()); 4256 type_parameter_name.ToCString());
4257 } 4257 }
4258 } 4258 }
4259 if (CurrentToken() == Token::kEXTENDS) { 4259 if (CurrentToken() == Token::kEXTENDS) {
4260 ConsumeToken(); 4260 ConsumeToken();
4261 // A bound may refer to the owner of the type parameter it applies to, 4261 // A bound may refer to the owner of the type parameter it applies to,
4262 // i.e. to the class or interface currently being parsed. 4262 // i.e. to the class or interface currently being parsed.
4263 // Postpone resolution in order to avoid resolving the class and its 4263 // Postpone resolution in order to avoid resolving the class and its
4264 // type parameters, as they are not fully parsed yet. 4264 // type parameters, as they are not fully parsed yet.
4265 type_parameter_bound = ParseType(ClassFinalizer::kDoNotResolve); 4265 type_parameter_bound = ParseType(ClassFinalizer::kDoNotResolve);
4266 } else { 4266 } else {
4267 type_parameter_bound = isolate()->object_store()->object_type(); 4267 type_parameter_bound = isolate()->object_store()->object_type();
4268 } 4268 }
4269 type_parameter = TypeParameter::New(cls, 4269 type_parameter = TypeParameter::New(cls,
4270 index, 4270 index,
4271 type_parameter_name, 4271 type_parameter_name,
4272 type_parameter_bound, 4272 type_parameter_bound,
4273 type_parameter_pos); 4273 type_parameter_pos);
4274 type_parameters_array.Add(type_parameter); 4274 type_parameters_array.Add(type_parameter);
4275 if (metadata_pos >= 0) {
4276 library_.AddTypeParameterMetadata(type_parameter, metadata_pos);
4277 }
4275 index++; 4278 index++;
4276 } while (CurrentToken() == Token::kCOMMA); 4279 } while (CurrentToken() == Token::kCOMMA);
4277 Token::Kind token = CurrentToken(); 4280 Token::Kind token = CurrentToken();
4278 if ((token == Token::kGT) || (token == Token::kSHR)) { 4281 if ((token == Token::kGT) || (token == Token::kSHR)) {
4279 ConsumeRightAngleBracket(); 4282 ConsumeRightAngleBracket();
4280 } else { 4283 } else {
4281 ErrorMsg("right angle bracket expected"); 4284 ErrorMsg("right angle bracket expected");
4282 } 4285 }
4283 const TypeArguments& type_parameters = 4286 const TypeArguments& type_parameters =
4284 TypeArguments::Handle(NewTypeArguments(type_parameters_array)); 4287 TypeArguments::Handle(NewTypeArguments(type_parameters_array));
(...skipping 6129 matching lines...) Expand 10 before | Expand all | Expand 10 after
10414 void Parser::SkipQualIdent() { 10417 void Parser::SkipQualIdent() {
10415 ASSERT(IsIdentifier()); 10418 ASSERT(IsIdentifier());
10416 ConsumeToken(); 10419 ConsumeToken();
10417 if (CurrentToken() == Token::kPERIOD) { 10420 if (CurrentToken() == Token::kPERIOD) {
10418 ConsumeToken(); // Consume the kPERIOD token. 10421 ConsumeToken(); // Consume the kPERIOD token.
10419 ExpectIdentifier("identifier expected after '.'"); 10422 ExpectIdentifier("identifier expected after '.'");
10420 } 10423 }
10421 } 10424 }
10422 10425
10423 } // namespace dart 10426 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698