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/class_finalizer.h" | 9 #include "vm/class_finalizer.h" |
10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
(...skipping 1585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1596 // Lookup class in the core lib which also contains various VM | 1596 // Lookup class in the core lib which also contains various VM |
1597 // helper methods and classes. Allow look up of private classes. | 1597 // helper methods and classes. Allow look up of private classes. |
1598 static RawClass* LookupCoreClass(const String& class_name) { | 1598 static RawClass* LookupCoreClass(const String& class_name) { |
1599 const Library& core_lib = Library::Handle(Library::CoreLibrary()); | 1599 const Library& core_lib = Library::Handle(Library::CoreLibrary()); |
1600 String& name = String::Handle(class_name.raw()); | 1600 String& name = String::Handle(class_name.raw()); |
1601 if (class_name.CharAt(0) == Scanner::kPrivateIdentifierStart) { | 1601 if (class_name.CharAt(0) == Scanner::kPrivateIdentifierStart) { |
1602 // Private identifiers are mangled on a per script basis. | 1602 // Private identifiers are mangled on a per script basis. |
1603 name = String::Concat(name, String::Handle(core_lib.private_key())); | 1603 name = String::Concat(name, String::Handle(core_lib.private_key())); |
1604 name = Symbols::New(name); | 1604 name = Symbols::New(name); |
1605 } | 1605 } |
1606 return core_lib.LookupClass(name); | 1606 return core_lib.LookupClass(name, NULL); // No ambiguity error expected. |
1607 } | 1607 } |
1608 | 1608 |
1609 | 1609 |
1610 static const String& PrivateCoreLibName(const String& str) { | 1610 static const String& PrivateCoreLibName(const String& str) { |
1611 const Library& core_lib = Library::Handle(Library::CoreLibrary()); | 1611 const Library& core_lib = Library::Handle(Library::CoreLibrary()); |
1612 const String& private_name = String::ZoneHandle(core_lib.PrivateName(str)); | 1612 const String& private_name = String::ZoneHandle(core_lib.PrivateName(str)); |
1613 return private_name; | 1613 return private_name; |
1614 } | 1614 } |
1615 | 1615 |
1616 | 1616 |
(...skipping 1226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2843 "static method '%s' cannot be abstract", | 2843 "static method '%s' cannot be abstract", |
2844 method->name->ToCString()); | 2844 method->name->ToCString()); |
2845 } | 2845 } |
2846 if (method->has_const && !method->IsFactoryOrConstructor()) { | 2846 if (method->has_const && !method->IsFactoryOrConstructor()) { |
2847 ErrorMsg(method->name_pos, "'const' not allowed for methods"); | 2847 ErrorMsg(method->name_pos, "'const' not allowed for methods"); |
2848 } | 2848 } |
2849 if (method->has_abstract && method->IsFactoryOrConstructor()) { | 2849 if (method->has_abstract && method->IsFactoryOrConstructor()) { |
2850 ErrorMsg(method->name_pos, "constructor cannot be abstract"); | 2850 ErrorMsg(method->name_pos, "constructor cannot be abstract"); |
2851 } | 2851 } |
2852 if (method->has_const && method->IsConstructor()) { | 2852 if (method->has_const && method->IsConstructor()) { |
2853 Class& cls = Class::Handle(library_.LookupClass(members->class_name())); | 2853 current_class().set_is_const(); |
2854 cls.set_is_const(); | |
2855 } | 2854 } |
2856 | 2855 |
2857 // Parse the formal parameters. | 2856 // Parse the formal parameters. |
2858 const bool are_implicitly_final = method->has_const; | 2857 const bool are_implicitly_final = method->has_const; |
2859 const bool allow_explicit_default_values = true; | 2858 const bool allow_explicit_default_values = true; |
2860 const intptr_t formal_param_pos = TokenPos(); | 2859 const intptr_t formal_param_pos = TokenPos(); |
2861 method->params.Clear(); | 2860 method->params.Clear(); |
2862 // Static functions do not have a receiver. | 2861 // Static functions do not have a receiver. |
2863 // The first parameter of a factory is the AbstractTypeArguments vector of | 2862 // The first parameter of a factory is the AbstractTypeArguments vector of |
2864 // the type of the instance to be allocated. | 2863 // the type of the instance to be allocated. |
(...skipping 5746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8611 } | 8610 } |
8612 accessor_name = Field::SetterName(name); | 8611 accessor_name = Field::SetterName(name); |
8613 obj = lib.LookupLocalObject(accessor_name); | 8612 obj = lib.LookupLocalObject(accessor_name); |
8614 return obj.raw(); | 8613 return obj.raw(); |
8615 } | 8614 } |
8616 | 8615 |
8617 | 8616 |
8618 static RawObject* LookupNameInImport(Isolate* isolate, | 8617 static RawObject* LookupNameInImport(Isolate* isolate, |
8619 const Namespace& ns, | 8618 const Namespace& ns, |
8620 const String& name) { | 8619 const String& name) { |
| 8620 // If the given name is filtered out by the import, don't look it up, nor its |
| 8621 // getter and setter names. |
| 8622 if (ns.HidesName(name)) { |
| 8623 return Object::null(); |
| 8624 } |
8621 Object& obj = Object::Handle(isolate); | 8625 Object& obj = Object::Handle(isolate); |
8622 obj = ns.Lookup(name); | 8626 obj = ns.Lookup(name); |
8623 if (!obj.IsNull()) { | 8627 if (!obj.IsNull()) { |
8624 return obj.raw(); | 8628 return obj.raw(); |
8625 } | 8629 } |
8626 // If the given name is filtered out by the import, don't look up the | |
8627 // getter and setter names. | |
8628 if (ns.HidesName(name)) { | |
8629 return Object::null(); | |
8630 } | |
8631 String& accessor_name = String::Handle(isolate, Field::GetterName(name)); | 8630 String& accessor_name = String::Handle(isolate, Field::GetterName(name)); |
8632 obj = ns.Lookup(accessor_name); | 8631 obj = ns.Lookup(accessor_name); |
8633 if (!obj.IsNull()) { | 8632 if (!obj.IsNull()) { |
8634 return obj.raw(); | 8633 return obj.raw(); |
8635 } | 8634 } |
8636 accessor_name = Field::SetterName(name); | 8635 accessor_name = Field::SetterName(name); |
8637 obj = ns.Lookup(accessor_name); | 8636 obj = ns.Lookup(accessor_name); |
8638 return obj.raw(); | 8637 return obj.raw(); |
8639 } | 8638 } |
8640 | 8639 |
(...skipping 1568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10209 void Parser::SkipQualIdent() { | 10208 void Parser::SkipQualIdent() { |
10210 ASSERT(IsIdentifier()); | 10209 ASSERT(IsIdentifier()); |
10211 ConsumeToken(); | 10210 ConsumeToken(); |
10212 if (CurrentToken() == Token::kPERIOD) { | 10211 if (CurrentToken() == Token::kPERIOD) { |
10213 ConsumeToken(); // Consume the kPERIOD token. | 10212 ConsumeToken(); // Consume the kPERIOD token. |
10214 ExpectIdentifier("identifier expected after '.'"); | 10213 ExpectIdentifier("identifier expected after '.'"); |
10215 } | 10214 } |
10216 } | 10215 } |
10217 | 10216 |
10218 } // namespace dart | 10217 } // namespace dart |
OLD | NEW |