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

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

Issue 23453024: Keep track of type parameter processing in mixin application classes. (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 2382 matching lines...) Expand 10 before | Expand all | Expand 10 after
2393 ParseInitializedInstanceFields( 2393 ParseInitializedInstanceFields(
2394 current_class(), receiver, &initialized_fields); 2394 current_class(), receiver, &initialized_fields);
2395 receiver->set_invisible(false); 2395 receiver->set_invisible(false);
2396 2396
2397 // If the class of this implicit constructor is a mixin application class, 2397 // If the class of this implicit constructor is a mixin application class,
2398 // it is a forwarding constructor of the mixin. The forwarding 2398 // it is a forwarding constructor of the mixin. The forwarding
2399 // constructor initializes the instance fields that have initializer 2399 // constructor initializes the instance fields that have initializer
2400 // expressions and then calls the respective super constructor with 2400 // expressions and then calls the respective super constructor with
2401 // the same name and number of parameters. 2401 // the same name and number of parameters.
2402 ArgumentListNode* forwarding_args = NULL; 2402 ArgumentListNode* forwarding_args = NULL;
2403 if (current_class().mixin() != Type::null()) { 2403 if (current_class().IsMixinApplication()) {
2404 // At this point we don't support forwarding constructors 2404 // At this point we don't support forwarding constructors
2405 // that have optional parameters because we don't know the default 2405 // that have optional parameters because we don't know the default
2406 // values of the optional parameters. We would have to compile the super 2406 // values of the optional parameters. We would have to compile the super
2407 // constructor to get the default values. Also, the spec is not clear 2407 // constructor to get the default values. Also, the spec is not clear
2408 // whether optional parameters are even allowed in this situation. 2408 // whether optional parameters are even allowed in this situation.
2409 // TODO(hausner): Remove this limitation if the language spec indeed 2409 // TODO(hausner): Remove this limitation if the language spec indeed
2410 // allows optional parameters. 2410 // allows optional parameters.
2411 if (func.HasOptionalParameters()) { 2411 if (func.HasOptionalParameters()) {
2412 ErrorMsg(ctor_pos, 2412 ErrorMsg(ctor_pos,
2413 "forwarding constructors must not have optional parameters"); 2413 "forwarding constructors must not have optional parameters");
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
2904 qual_ident->ident = CurrentLiteral(); 2904 qual_ident->ident = CurrentLiteral();
2905 qual_ident->lib_prefix = NULL; 2905 qual_ident->lib_prefix = NULL;
2906 ConsumeToken(); 2906 ConsumeToken();
2907 if (CurrentToken() == Token::kPERIOD) { 2907 if (CurrentToken() == Token::kPERIOD) {
2908 // An identifier cannot be resolved in a local scope when top level parsing. 2908 // An identifier cannot be resolved in a local scope when top level parsing.
2909 if (is_top_level_ || 2909 if (is_top_level_ ||
2910 !ResolveIdentInLocalScope(qual_ident->ident_pos, 2910 !ResolveIdentInLocalScope(qual_ident->ident_pos,
2911 *(qual_ident->ident), 2911 *(qual_ident->ident),
2912 NULL)) { 2912 NULL)) {
2913 LibraryPrefix& lib_prefix = LibraryPrefix::ZoneHandle(); 2913 LibraryPrefix& lib_prefix = LibraryPrefix::ZoneHandle();
2914 if (current_class().mixin() == Type::null()) { 2914 if (!current_class().IsMixinApplication()) {
2915 lib_prefix = current_class().LookupLibraryPrefix(*(qual_ident->ident)); 2915 lib_prefix = current_class().LookupLibraryPrefix(*(qual_ident->ident));
2916 } else { 2916 } else {
2917 // TODO(hausner): Should we resolve the prefix via the library scope 2917 // TODO(hausner): Should we resolve the prefix via the library scope
2918 // rather than via the class? 2918 // rather than via the class?
2919 Class& cls = Class::Handle(parsed_function()->function().origin()); 2919 Class& cls = Class::Handle(parsed_function()->function().origin());
2920 lib_prefix = cls.LookupLibraryPrefix(*(qual_ident->ident)); 2920 lib_prefix = cls.LookupLibraryPrefix(*(qual_ident->ident));
2921 } 2921 }
2922 if (!lib_prefix.IsNull()) { 2922 if (!lib_prefix.IsNull()) {
2923 // We have a library prefix qualified identifier, unless the prefix is 2923 // We have a library prefix qualified identifier, unless the prefix is
2924 // shadowed by a type parameter in scope. 2924 // shadowed by a type parameter in scope.
(...skipping 5782 matching lines...) Expand 10 before | Expand all | Expand 10 after
8707 *node = new LoadLocalNode(ident_pos, local); 8707 *node = new LoadLocalNode(ident_pos, local);
8708 } 8708 }
8709 } 8709 }
8710 return true; 8710 return true;
8711 } 8711 }
8712 8712
8713 // Try to find the identifier in the class scope of the current class. 8713 // Try to find the identifier in the class scope of the current class.
8714 // If the current class is the result of a mixin application, we must 8714 // If the current class is the result of a mixin application, we must
8715 // use the class scope of the class from which the function originates. 8715 // use the class scope of the class from which the function originates.
8716 Class& cls = Class::Handle(isolate()); 8716 Class& cls = Class::Handle(isolate());
8717 if (current_class().mixin() == Type::null()) { 8717 if (!current_class().IsMixinApplication()) {
8718 cls = current_class().raw(); 8718 cls = current_class().raw();
8719 } else { 8719 } else {
8720 cls = parsed_function()->function().origin(); 8720 cls = parsed_function()->function().origin();
8721 } 8721 }
8722 Function& func = Function::Handle(isolate(), Function::null()); 8722 Function& func = Function::Handle(isolate(), Function::null());
8723 Field& field = Field::Handle(isolate(), Field::null()); 8723 Field& field = Field::Handle(isolate(), Field::null());
8724 8724
8725 // First check if a field exists. 8725 // First check if a field exists.
8726 field = cls.LookupField(ident); 8726 field = cls.LookupField(ident);
8727 if (!field.IsNull()) { 8727 if (!field.IsNull()) {
(...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after
10130 CurrentToken() == Token::kLBRACE) { 10130 CurrentToken() == Token::kLBRACE) {
10131 primary = ParseCompoundLiteral(); 10131 primary = ParseCompoundLiteral();
10132 } else if (CurrentToken() == Token::kSUPER) { 10132 } else if (CurrentToken() == Token::kSUPER) {
10133 if (current_function().is_static()) { 10133 if (current_function().is_static()) {
10134 ErrorMsg("cannot access superclass from static method"); 10134 ErrorMsg("cannot access superclass from static method");
10135 } 10135 }
10136 if (current_class().SuperClass() == Class::null()) { 10136 if (current_class().SuperClass() == Class::null()) {
10137 ErrorMsg("class '%s' does not have a superclass", 10137 ErrorMsg("class '%s' does not have a superclass",
10138 String::Handle(current_class().Name()).ToCString()); 10138 String::Handle(current_class().Name()).ToCString());
10139 } 10139 }
10140 if (current_class().mixin() != Type::null()) { 10140 if (current_class().IsMixinApplication()) {
10141 const Type& mixin_type = Type::Handle(current_class().mixin()); 10141 const Type& mixin_type = Type::Handle(current_class().mixin());
10142 if (mixin_type.type_class() == current_function().origin()) { 10142 if (mixin_type.type_class() == current_function().origin()) {
10143 ErrorMsg("class '%s' may not use super " 10143 ErrorMsg("method of mixin class '%s' may not refer to 'super'",
10144 "because it is used as mixin class", 10144 String::Handle(Class::Handle(
10145 String::Handle(current_class().Name()).ToCString()); 10145 current_function().origin()).Name()).ToCString());
10146 } 10146 }
10147 } 10147 }
10148 ConsumeToken(); 10148 ConsumeToken();
10149 if (CurrentToken() == Token::kPERIOD) { 10149 if (CurrentToken() == Token::kPERIOD) {
10150 ConsumeToken(); 10150 ConsumeToken();
10151 const String& ident = *ExpectIdentifier("identifier expected"); 10151 const String& ident = *ExpectIdentifier("identifier expected");
10152 if (CurrentToken() == Token::kLPAREN) { 10152 if (CurrentToken() == Token::kLPAREN) {
10153 primary = ParseSuperCall(ident); 10153 primary = ParseSuperCall(ident);
10154 } else { 10154 } else {
10155 primary = ParseSuperFieldAccess(ident); 10155 primary = ParseSuperFieldAccess(ident);
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
10503 void Parser::SkipQualIdent() { 10503 void Parser::SkipQualIdent() {
10504 ASSERT(IsIdentifier()); 10504 ASSERT(IsIdentifier());
10505 ConsumeToken(); 10505 ConsumeToken();
10506 if (CurrentToken() == Token::kPERIOD) { 10506 if (CurrentToken() == Token::kPERIOD) {
10507 ConsumeToken(); // Consume the kPERIOD token. 10507 ConsumeToken(); // Consume the kPERIOD token.
10508 ExpectIdentifier("identifier expected after '.'"); 10508 ExpectIdentifier("identifier expected after '.'");
10509 } 10509 }
10510 } 10510 }
10511 10511
10512 } // namespace dart 10512 } // 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