Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 3754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3765 if (FLAG_trace_parser) { | 3765 if (FLAG_trace_parser) { |
| 3766 OS::Print("toplevel parsing typedef class '%s'\n", class_name.ToCString()); | 3766 OS::Print("toplevel parsing typedef class '%s'\n", class_name.ToCString()); |
| 3767 } | 3767 } |
| 3768 const Object& obj = Object::Handle(library_.LookupLocalObject(class_name)); | 3768 const Object& obj = Object::Handle(library_.LookupLocalObject(class_name)); |
| 3769 if (!obj.IsNull()) { | 3769 if (!obj.IsNull()) { |
| 3770 ErrorMsg(classname_pos, "'%s' is already defined", | 3770 ErrorMsg(classname_pos, "'%s' is already defined", |
| 3771 class_name.ToCString()); | 3771 class_name.ToCString()); |
| 3772 } | 3772 } |
| 3773 const Class& mixin_application = | 3773 const Class& mixin_application = |
| 3774 Class::Handle(Class::New(class_name, script_, classname_pos)); | 3774 Class::Handle(Class::New(class_name, script_, classname_pos)); |
| 3775 mixin_application.set_is_mixin_typedef(); | |
| 3775 library_.AddClass(mixin_application); | 3776 library_.AddClass(mixin_application); |
| 3776 set_current_class(mixin_application); | 3777 set_current_class(mixin_application); |
| 3777 ParseTypeParameters(mixin_application); | 3778 ParseTypeParameters(mixin_application); |
| 3778 | 3779 |
| 3779 ExpectToken(Token::kASSIGN); | 3780 ExpectToken(Token::kASSIGN); |
| 3780 | 3781 |
| 3781 if (CurrentToken() == Token::kABSTRACT) { | 3782 if (CurrentToken() == Token::kABSTRACT) { |
| 3782 mixin_application.set_is_abstract(); | 3783 mixin_application.set_is_abstract(); |
| 3783 ConsumeToken(); | 3784 ConsumeToken(); |
| 3784 } | 3785 } |
| 3785 | 3786 |
| 3786 const intptr_t type_pos = TokenPos(); | 3787 const intptr_t type_pos = TokenPos(); |
| 3787 AbstractType& type = | 3788 AbstractType& type = |
| 3788 AbstractType::Handle(ParseType(ClassFinalizer::kResolveTypeParameters)); | 3789 AbstractType::Handle(ParseType(ClassFinalizer::kResolveTypeParameters)); |
| 3789 if (type.IsTypeParameter()) { | 3790 if (type.IsTypeParameter()) { |
| 3790 ErrorMsg(type_pos, | 3791 ErrorMsg(type_pos, |
| 3791 "class '%s' may not extend type parameter '%s'", | 3792 "class '%s' may not extend type parameter '%s'", |
| 3792 class_name.ToCString(), | 3793 class_name.ToCString(), |
| 3793 String::Handle(type.UserVisibleName()).ToCString()); | 3794 String::Handle(type.UserVisibleName()).ToCString()); |
| 3794 } | 3795 } |
| 3795 | 3796 |
| 3796 if (CurrentToken() != Token::kWITH) { | 3797 if (CurrentToken() != Token::kWITH) { |
| 3797 ErrorMsg("mixin application 'with Type' expected"); | 3798 ErrorMsg("mixin application 'with Type' expected"); |
| 3798 } | 3799 } |
| 3799 type = ParseMixins(type); | 3800 type = ParseMixins(type); |
| 3800 | 3801 |
| 3801 // TODO(hausner): treat the mixin application as an alias, not as a base | 3802 // TODO(hausner): treat the mixin application as an alias, not as a base |
| 3802 // class whose super class is the mixin application! | 3803 // class whose super class is the mixin application! |
| 3804 // regis/rmacnak: This is difficult because of issues involving subsitution of | |
| 3805 // type parameters | |
| 3803 mixin_application.set_super_type(type); | 3806 mixin_application.set_super_type(type); |
| 3804 mixin_application.set_is_synthesized_class(); | 3807 mixin_application.set_is_synthesized_class(); |
| 3805 | 3808 |
| 3806 // This mixin application typedef needs an implicit constructor, but it is | 3809 // This mixin application typedef needs an implicit constructor, but it is |
| 3807 // too early to call 'AddImplicitConstructor(mixin_application)' here, | 3810 // too early to call 'AddImplicitConstructor(mixin_application)' here, |
| 3808 // because this class should be lazily compiled. | 3811 // because this class should be lazily compiled. |
| 3809 if (CurrentToken() == Token::kIMPLEMENTS) { | 3812 if (CurrentToken() == Token::kIMPLEMENTS) { |
| 3813 // At this point, the mixin_application alias already has an interface, but | |
|
rmacnak
2013/08/21 23:24:17
Is this still true with the extra class?
| |
| 3814 // ParseInterfaceList should be able to add to the list. | |
| 3810 ParseInterfaceList(mixin_application); | 3815 ParseInterfaceList(mixin_application); |
| 3811 } | 3816 } |
| 3812 ExpectSemicolon(); | 3817 ExpectSemicolon(); |
| 3813 pending_classes.Add(mixin_application, Heap::kOld); | 3818 pending_classes.Add(mixin_application, Heap::kOld); |
| 3814 } | 3819 } |
| 3815 | 3820 |
| 3816 | 3821 |
| 3817 // Look ahead to detect if we are seeing ident [ TypeParameters ] "(". | 3822 // Look ahead to detect if we are seeing ident [ TypeParameters ] "(". |
| 3818 // We need this lookahead to distinguish between the optional return type | 3823 // We need this lookahead to distinguish between the optional return type |
| 3819 // and the alias name of a function type alias. | 3824 // and the alias name of a function type alias. |
| (...skipping 6509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10329 void Parser::SkipQualIdent() { | 10334 void Parser::SkipQualIdent() { |
| 10330 ASSERT(IsIdentifier()); | 10335 ASSERT(IsIdentifier()); |
| 10331 ConsumeToken(); | 10336 ConsumeToken(); |
| 10332 if (CurrentToken() == Token::kPERIOD) { | 10337 if (CurrentToken() == Token::kPERIOD) { |
| 10333 ConsumeToken(); // Consume the kPERIOD token. | 10338 ConsumeToken(); // Consume the kPERIOD token. |
| 10334 ExpectIdentifier("identifier expected after '.'"); | 10339 ExpectIdentifier("identifier expected after '.'"); |
| 10335 } | 10340 } |
| 10336 } | 10341 } |
| 10337 | 10342 |
| 10338 } // namespace dart | 10343 } // namespace dart |
| OLD | NEW |