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

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

Issue 23619026: Simplify VM internal representation of a mixin application clause (MixinAppType (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: 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
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/raw_object.h » ('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 "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 4336 matching lines...) Expand 10 before | Expand all | Expand 10 after
4347 all_interfaces.Add(interface); 4347 all_interfaces.Add(interface);
4348 } while (CurrentToken() == Token::kCOMMA); 4348 } while (CurrentToken() == Token::kCOMMA);
4349 cls_interfaces = Array::MakeArray(all_interfaces); 4349 cls_interfaces = Array::MakeArray(all_interfaces);
4350 cls.set_interfaces(cls_interfaces); 4350 cls.set_interfaces(cls_interfaces);
4351 } 4351 }
4352 4352
4353 4353
4354 RawAbstractType* Parser::ParseMixins(const AbstractType& super_type) { 4354 RawAbstractType* Parser::ParseMixins(const AbstractType& super_type) {
4355 TRACE_PARSER("ParseMixins"); 4355 TRACE_PARSER("ParseMixins");
4356 ASSERT(CurrentToken() == Token::kWITH); 4356 ASSERT(CurrentToken() == Token::kWITH);
4357 ASSERT(super_type.IsType()); // TODO(regis): Could be a BoundedType.
4358 AbstractType& mixin_super_type = AbstractType::Handle(super_type.raw());
4357 4359
4358 const GrowableObjectArray& mixin_apps = 4360 const GrowableObjectArray& mixin_apps =
4359 GrowableObjectArray::Handle(GrowableObjectArray::New()); 4361 GrowableObjectArray::Handle(GrowableObjectArray::New());
4360 AbstractType& mixin_type = AbstractType::Handle(); 4362 AbstractType& mixin_type = AbstractType::Handle();
4361 AbstractTypeArguments& mixin_type_arguments = 4363 Class& mixin_app_class = Class::Handle();
4362 AbstractTypeArguments::Handle(); 4364 Array& mixin_app_interfaces = Array::Handle();
4363 Class& mixin_application = Class::Handle(); 4365 String& mixin_app_class_name = String::Handle();
4364 Type& mixin_application_type = Type::Handle(); 4366 String& mixin_type_class_name = String::Handle();
4365 Type& mixin_super_type = Type::Handle();
4366 ASSERT(super_type.IsType());
4367 mixin_super_type ^= super_type.raw();
4368 Array& mixin_application_interfaces = Array::Handle();
4369 do { 4367 do {
4370 ConsumeToken(); 4368 ConsumeToken();
4371 const intptr_t mixin_pos = TokenPos(); 4369 const intptr_t mixin_pos = TokenPos();
4372 mixin_type = ParseType(ClassFinalizer::kResolveTypeParameters); 4370 mixin_type = ParseType(ClassFinalizer::kResolveTypeParameters);
4373 if (mixin_type.IsTypeParameter()) { 4371 if (mixin_type.IsTypeParameter()) {
4374 ErrorMsg(mixin_pos, 4372 ErrorMsg(mixin_pos,
4375 "mixin type '%s' may not be a type parameter", 4373 "mixin type '%s' may not be a type parameter",
4376 String::Handle(mixin_type.UserVisibleName()).ToCString()); 4374 String::Handle(mixin_type.UserVisibleName()).ToCString());
4377 } 4375 }
4378 4376
4379 // The name of the mixin application class is a combination of 4377 // The name of the mixin application class is a combination of
4380 // the superclass and mixin class. 4378 // the super class name and mixin class name.
4381 String& mixin_app_name = String::Handle(); 4379 mixin_app_class_name = mixin_super_type.ClassName();
4382 mixin_app_name = mixin_super_type.ClassName(); 4380 mixin_app_class_name = String::Concat(mixin_app_class_name,
4383 mixin_app_name = String::Concat(mixin_app_name, Symbols::Ampersand()); 4381 Symbols::Ampersand());
4384 mixin_app_name = String::Concat(mixin_app_name, 4382 mixin_type_class_name = mixin_type.ClassName();
4385 String::Handle(mixin_type.ClassName())); 4383 mixin_app_class_name = String::Concat(mixin_app_class_name,
4386 mixin_app_name = Symbols::New(mixin_app_name); 4384 mixin_type_class_name);
4385 mixin_app_class_name = Symbols::New(mixin_app_class_name);
4387 4386
4388 mixin_application = Class::New(mixin_app_name, script_, mixin_pos); 4387 mixin_app_class = Class::New(mixin_app_class_name, script_, mixin_pos);
4389 mixin_application.set_super_type(mixin_super_type); 4388 mixin_app_class.set_super_type(mixin_super_type);
4390 mixin_application.set_mixin(Type::Cast(mixin_type)); 4389 mixin_app_class.set_mixin(Type::Cast(mixin_type));
4391 mixin_application.set_library(library_); 4390 mixin_app_class.set_library(library_);
4392 mixin_application.set_is_synthesized_class(); 4391 mixin_app_class.set_is_synthesized_class();
4393 4392
4394 // Add the mixin type to the interfaces that the mixin application 4393 // Add the mixin type to the interfaces that the mixin application
4395 // class implements. This is necessary so that type tests work. 4394 // class implements. This is necessary so that type tests work.
4396 mixin_application_interfaces = Array::New(1); 4395 mixin_app_interfaces = Array::New(1);
4397 mixin_application_interfaces.SetAt(0, mixin_type); 4396 mixin_app_interfaces.SetAt(0, mixin_type);
4398 mixin_application.set_interfaces(mixin_application_interfaces); 4397 mixin_app_class.set_interfaces(mixin_app_interfaces);
4399 4398
4400 // For the type arguments of the mixin application type, we need 4399 // Add the synthesized class to the list of mixin apps.
4401 // a copy of the type arguments to the mixin type. The simplest way 4400 mixin_apps.Add(mixin_app_class);
4402 // to get the copy is to rewind the parser, parse the mixin type
4403 // again and steal its type arguments.
4404 SetPosition(mixin_pos);
4405 mixin_type = ParseType(ClassFinalizer::kResolveTypeParameters);
4406 mixin_type_arguments = mixin_type.arguments();
4407 4401
4408 mixin_application_type = Type::New(mixin_application, 4402 // This mixin application class becomes the type class of the super type of
4409 mixin_type_arguments, 4403 // the next mixin application class. It is however too early to provide the
4410 mixin_pos); 4404 // correct super type arguments. We use the raw type for now.
4411 mixin_super_type = mixin_application_type.raw(); 4405 mixin_super_type = Type::New(mixin_app_class,
4412 mixin_apps.Add(mixin_application_type); 4406 Object::null_abstract_type_arguments(),
4407 mixin_pos);
4413 } while (CurrentToken() == Token::kCOMMA); 4408 } while (CurrentToken() == Token::kCOMMA);
4414 return MixinAppType::New(super_type, 4409 return MixinAppType::New(Array::Handle(Array::MakeArray(mixin_apps)));
4415 Array::Handle(Array::MakeArray(mixin_apps)));
4416 } 4410 }
4417 4411
4418 4412
4419 void Parser::ParseTopLevelVariable(TopLevel* top_level, 4413 void Parser::ParseTopLevelVariable(TopLevel* top_level,
4420 intptr_t metadata_pos) { 4414 intptr_t metadata_pos) {
4421 TRACE_PARSER("ParseTopLevelVariable"); 4415 TRACE_PARSER("ParseTopLevelVariable");
4422 const bool is_const = (CurrentToken() == Token::kCONST); 4416 const bool is_const = (CurrentToken() == Token::kCONST);
4423 // Const fields are implicitly final. 4417 // Const fields are implicitly final.
4424 const bool is_final = is_const || (CurrentToken() == Token::kFINAL); 4418 const bool is_final = is_const || (CurrentToken() == Token::kFINAL);
4425 const bool is_static = true; 4419 const bool is_static = true;
(...skipping 5968 matching lines...) Expand 10 before | Expand all | Expand 10 after
10394 void Parser::SkipQualIdent() { 10388 void Parser::SkipQualIdent() {
10395 ASSERT(IsIdentifier()); 10389 ASSERT(IsIdentifier());
10396 ConsumeToken(); 10390 ConsumeToken();
10397 if (CurrentToken() == Token::kPERIOD) { 10391 if (CurrentToken() == Token::kPERIOD) {
10398 ConsumeToken(); // Consume the kPERIOD token. 10392 ConsumeToken(); // Consume the kPERIOD token.
10399 ExpectIdentifier("identifier expected after '.'"); 10393 ExpectIdentifier("identifier expected after '.'");
10400 } 10394 }
10401 } 10395 }
10402 10396
10403 } // namespace dart 10397 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698