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 3794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3805 if (FLAG_trace_parser) { | 3805 if (FLAG_trace_parser) { |
| 3806 OS::Print("toplevel parsing typedef class '%s'\n", class_name.ToCString()); | 3806 OS::Print("toplevel parsing typedef class '%s'\n", class_name.ToCString()); |
| 3807 } | 3807 } |
| 3808 const Object& obj = Object::Handle(library_.LookupLocalObject(class_name)); | 3808 const Object& obj = Object::Handle(library_.LookupLocalObject(class_name)); |
| 3809 if (!obj.IsNull()) { | 3809 if (!obj.IsNull()) { |
| 3810 ErrorMsg(classname_pos, "'%s' is already defined", | 3810 ErrorMsg(classname_pos, "'%s' is already defined", |
| 3811 class_name.ToCString()); | 3811 class_name.ToCString()); |
| 3812 } | 3812 } |
| 3813 const Class& mixin_application = | 3813 const Class& mixin_application = |
| 3814 Class::Handle(Class::New(class_name, script_, classname_pos)); | 3814 Class::Handle(Class::New(class_name, script_, classname_pos)); |
| 3815 mixin_application.set_is_mixin_typedef(); | |
| 3815 library_.AddClass(mixin_application); | 3816 library_.AddClass(mixin_application); |
| 3816 set_current_class(mixin_application); | 3817 set_current_class(mixin_application); |
| 3817 ParseTypeParameters(mixin_application); | 3818 ParseTypeParameters(mixin_application); |
| 3818 | 3819 |
| 3819 ExpectToken(Token::kASSIGN); | 3820 ExpectToken(Token::kASSIGN); |
| 3820 | 3821 |
| 3821 if (CurrentToken() == Token::kABSTRACT) { | 3822 if (CurrentToken() == Token::kABSTRACT) { |
| 3822 mixin_application.set_is_abstract(); | 3823 mixin_application.set_is_abstract(); |
| 3823 ConsumeToken(); | 3824 ConsumeToken(); |
| 3824 } | 3825 } |
| 3825 | 3826 |
| 3826 const intptr_t type_pos = TokenPos(); | 3827 const intptr_t type_pos = TokenPos(); |
| 3827 AbstractType& type = | 3828 AbstractType& type = |
| 3828 AbstractType::Handle(ParseType(ClassFinalizer::kResolveTypeParameters)); | 3829 AbstractType::Handle(ParseType(ClassFinalizer::kResolveTypeParameters)); |
| 3829 if (type.IsTypeParameter()) { | 3830 if (type.IsTypeParameter()) { |
| 3830 ErrorMsg(type_pos, | 3831 ErrorMsg(type_pos, |
| 3831 "class '%s' may not extend type parameter '%s'", | 3832 "class '%s' may not extend type parameter '%s'", |
| 3832 class_name.ToCString(), | 3833 class_name.ToCString(), |
| 3833 String::Handle(type.UserVisibleName()).ToCString()); | 3834 String::Handle(type.UserVisibleName()).ToCString()); |
| 3834 } | 3835 } |
| 3835 | 3836 |
| 3836 if (CurrentToken() != Token::kWITH) { | 3837 if (CurrentToken() != Token::kWITH) { |
| 3837 ErrorMsg("mixin application 'with Type' expected"); | 3838 ErrorMsg("mixin application 'with Type' expected"); |
| 3838 } | 3839 } |
| 3839 type = ParseMixins(type); | 3840 type = ParseMixins(type); |
| 3840 | 3841 |
| 3841 // TODO(hausner): treat the mixin application as an alias, not as a base | 3842 // TODO(hausner): treat the mixin application as an alias, not as a base |
| 3842 // class whose super class is the mixin application! | 3843 // class whose super class is the mixin application! |
| 3844 // regis/rmacnak: This is difficult because of issues involving subsitution of | |
| 3845 // type parameters | |
|
siva
2013/08/26 04:30:27
Can an issue be opened for this and the TODO chang
rmacnak
2013/08/26 18:24:37
Done.
| |
| 3843 mixin_application.set_super_type(type); | 3846 mixin_application.set_super_type(type); |
| 3844 mixin_application.set_is_synthesized_class(); | 3847 mixin_application.set_is_synthesized_class(); |
| 3845 | 3848 |
| 3846 // This mixin application typedef needs an implicit constructor, but it is | 3849 // This mixin application typedef needs an implicit constructor, but it is |
| 3847 // too early to call 'AddImplicitConstructor(mixin_application)' here, | 3850 // too early to call 'AddImplicitConstructor(mixin_application)' here, |
| 3848 // because this class should be lazily compiled. | 3851 // because this class should be lazily compiled. |
| 3849 if (CurrentToken() == Token::kIMPLEMENTS) { | 3852 if (CurrentToken() == Token::kIMPLEMENTS) { |
| 3853 // At this point, the mixin_application alias already has an interface, but | |
| 3854 // ParseInterfaceList should be able to add to the list. | |
| 3850 ParseInterfaceList(mixin_application); | 3855 ParseInterfaceList(mixin_application); |
| 3851 } | 3856 } |
| 3852 ExpectSemicolon(); | 3857 ExpectSemicolon(); |
| 3853 pending_classes.Add(mixin_application, Heap::kOld); | 3858 pending_classes.Add(mixin_application, Heap::kOld); |
| 3854 } | 3859 } |
| 3855 | 3860 |
| 3856 | 3861 |
| 3857 // Look ahead to detect if we are seeing ident [ TypeParameters ] "(". | 3862 // Look ahead to detect if we are seeing ident [ TypeParameters ] "(". |
| 3858 // We need this lookahead to distinguish between the optional return type | 3863 // We need this lookahead to distinguish between the optional return type |
| 3859 // and the alias name of a function type alias. | 3864 // and the alias name of a function type alias. |
| (...skipping 6510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10370 void Parser::SkipQualIdent() { | 10375 void Parser::SkipQualIdent() { |
| 10371 ASSERT(IsIdentifier()); | 10376 ASSERT(IsIdentifier()); |
| 10372 ConsumeToken(); | 10377 ConsumeToken(); |
| 10373 if (CurrentToken() == Token::kPERIOD) { | 10378 if (CurrentToken() == Token::kPERIOD) { |
| 10374 ConsumeToken(); // Consume the kPERIOD token. | 10379 ConsumeToken(); // Consume the kPERIOD token. |
| 10375 ExpectIdentifier("identifier expected after '.'"); | 10380 ExpectIdentifier("identifier expected after '.'"); |
| 10376 } | 10381 } |
| 10377 } | 10382 } |
| 10378 | 10383 |
| 10379 } // namespace dart | 10384 } // namespace dart |
| OLD | NEW |