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 "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
| 8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/compiler_stats.h" | 10 #include "vm/compiler_stats.h" |
| (...skipping 4069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4080 CallLibraryTagHandler(kImportTag, import_pos, canon_url); | 4080 CallLibraryTagHandler(kImportTag, import_pos, canon_url); |
| 4081 // If the library tag handler succeded without registering the | 4081 // If the library tag handler succeded without registering the |
| 4082 // library we create an empty library to import. | 4082 // library we create an empty library to import. |
| 4083 library = Library::LookupLibrary(canon_url); | 4083 library = Library::LookupLibrary(canon_url); |
| 4084 if (library.IsNull()) { | 4084 if (library.IsNull()) { |
| 4085 library = Library::New(canon_url); | 4085 library = Library::New(canon_url); |
| 4086 library.Register(); | 4086 library.Register(); |
| 4087 } | 4087 } |
| 4088 } | 4088 } |
| 4089 // Add the import to the library. | 4089 // Add the import to the library. |
| 4090 const Namespace& import = Namespace::Handle( | |
| 4091 Namespace::New(library, Array::Handle(), Array::Handle())); | |
| 4090 if (prefix.IsNull() || (prefix.Length() == 0)) { | 4092 if (prefix.IsNull() || (prefix.Length() == 0)) { |
| 4091 library_.AddImport(library); | 4093 library_.AddImport(import); |
| 4092 } else { | 4094 } else { |
| 4093 LibraryPrefix& library_prefix = LibraryPrefix::Handle(); | 4095 LibraryPrefix& library_prefix = LibraryPrefix::Handle(); |
| 4094 library_prefix = library_.LookupLocalLibraryPrefix(prefix); | 4096 library_prefix = library_.LookupLocalLibraryPrefix(prefix); |
| 4095 if (!library_prefix.IsNull()) { | 4097 if (!library_prefix.IsNull()) { |
| 4096 library_prefix.AddLibrary(library); | 4098 library_prefix.AddImport(import); |
| 4097 } else { | 4099 } else { |
| 4098 library_prefix = LibraryPrefix::New(prefix, library); | 4100 library_prefix = LibraryPrefix::New(prefix, import); |
| 4099 library_.AddObject(library_prefix, prefix); | 4101 library_.AddObject(library_prefix, prefix); |
| 4100 } | 4102 } |
| 4101 } | 4103 } |
| 4102 } | 4104 } |
| 4103 } | 4105 } |
| 4104 | 4106 |
| 4105 | 4107 |
| 4106 // TODO(hausner): Remove support for old library definition syntax. | 4108 // TODO(hausner): Remove support for old library definition syntax. |
| 4107 void Parser::ParseLibraryIncludeObsoleteSyntax() { | 4109 void Parser::ParseLibraryIncludeObsoleteSyntax() { |
| 4108 while (CurrentToken() == Token::kSOURCE) { | 4110 while (CurrentToken() == Token::kSOURCE) { |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 4130 ConsumeToken(); | 4132 ConsumeToken(); |
| 4131 // TODO(hausner): Exact syntax of library name still unclear: identifier, | 4133 // TODO(hausner): Exact syntax of library name still unclear: identifier, |
| 4132 // qualified identifier or even multiple dots allowed? For now we just | 4134 // qualified identifier or even multiple dots allowed? For now we just |
| 4133 // accept simple identifiers. | 4135 // accept simple identifiers. |
| 4134 const String& lib_name = *ExpectIdentifier("library name expected"); | 4136 const String& lib_name = *ExpectIdentifier("library name expected"); |
| 4135 library_.SetName(lib_name); | 4137 library_.SetName(lib_name); |
| 4136 ExpectSemicolon(); | 4138 ExpectSemicolon(); |
| 4137 } | 4139 } |
| 4138 | 4140 |
| 4139 | 4141 |
| 4142 void Parser::ParseIdentList(GrowableObjectArray* names) { | |
| 4143 while (IsIdentifier()) { | |
| 4144 names->Add(*CurrentLiteral()); | |
| 4145 ConsumeToken(); // Identifier. | |
| 4146 if (CurrentToken() != Token::kCOMMA) { | |
| 4147 return; | |
| 4148 } | |
| 4149 ConsumeToken(); // Comma. | |
| 4150 } | |
| 4151 } | |
| 4152 | |
| 4153 | |
| 4140 void Parser::ParseLibraryImportExport() { | 4154 void Parser::ParseLibraryImportExport() { |
| 4141 if (IsLiteral("import")) { | 4155 if (IsLiteral("import")) { |
| 4142 const intptr_t import_pos = TokenPos(); | 4156 const intptr_t import_pos = TokenPos(); |
| 4143 ConsumeToken(); | 4157 ConsumeToken(); |
| 4144 if (CurrentToken() != Token::kSTRING) { | 4158 if (CurrentToken() != Token::kSTRING) { |
| 4145 ErrorMsg("library url expected"); | 4159 ErrorMsg("library url expected"); |
| 4146 } | 4160 } |
| 4147 const String& url = *CurrentLiteral(); | 4161 const String& url = *CurrentLiteral(); |
| 4148 if (url.Length() == 0) { | 4162 if (url.Length() == 0) { |
| 4149 ErrorMsg("library url expected"); | 4163 ErrorMsg("library url expected"); |
| 4150 } | 4164 } |
| 4151 ConsumeToken(); | 4165 ConsumeToken(); |
| 4152 String& prefix = String::Handle(); | 4166 String& prefix = String::Handle(); |
| 4153 if (IsLiteral("as")) { | 4167 if (IsLiteral("as")) { |
| 4154 ConsumeToken(); | 4168 ConsumeToken(); |
| 4155 prefix = ExpectIdentifier("prefix expected")->raw(); | 4169 prefix = ExpectIdentifier("prefix expected")->raw(); |
| 4156 } | 4170 } |
| 4157 if (IsLiteral("show")) { | 4171 |
| 4158 ErrorMsg("show combinator not yet supported"); | 4172 Array& show_names = Array::Handle(); |
| 4159 } else if (IsLiteral("hide")) { | 4173 Array& hide_names = Array::Handle(); |
| 4160 ErrorMsg("hide combinator not yet supported"); | 4174 if (IsLiteral("show") || IsLiteral("hide")) { |
| 4175 GrowableObjectArray& show_list = | |
| 4176 GrowableObjectArray::Handle(GrowableObjectArray::New()); | |
| 4177 GrowableObjectArray& hide_list = | |
| 4178 GrowableObjectArray::Handle(GrowableObjectArray::New()); | |
| 4179 for (;;) { | |
| 4180 if (IsLiteral("show")) { | |
| 4181 ConsumeToken(); | |
| 4182 ParseIdentList(&show_list); | |
| 4183 } else if (IsLiteral("hide")) { | |
| 4184 ConsumeToken(); | |
| 4185 ParseIdentList(&hide_list); | |
| 4186 } else { | |
| 4187 break; | |
| 4188 } | |
| 4189 } | |
| 4190 if (show_list.Length() > 0) { | |
| 4191 show_names = Array::MakeArray(show_list); | |
| 4192 } | |
| 4193 if (hide_list.Length() > 0) { | |
| 4194 hide_names = Array::MakeArray(hide_list); | |
| 4195 } | |
| 4161 } | 4196 } |
| 4162 ExpectSemicolon(); | 4197 ExpectSemicolon(); |
| 4163 | 4198 |
| 4164 // Canonicalize library URL. | 4199 // Canonicalize library URL. |
| 4165 Dart_Handle handle = | 4200 Dart_Handle handle = |
| 4166 CallLibraryTagHandler(kCanonicalizeUrl, import_pos, url); | 4201 CallLibraryTagHandler(kCanonicalizeUrl, import_pos, url); |
| 4167 const String& canon_url = String::CheckedHandle(Api::UnwrapHandle(handle)); | 4202 const String& canon_url = String::CheckedHandle(Api::UnwrapHandle(handle)); |
| 4168 // Lookup the library URL. | 4203 // Lookup the library URL. |
| 4169 Library& library = Library::Handle(Library::LookupLibrary(canon_url)); | 4204 Library& library = Library::Handle(Library::LookupLibrary(canon_url)); |
| 4170 if (library.IsNull()) { | 4205 if (library.IsNull()) { |
| 4171 // Call the library tag handler to load the library. | 4206 // Call the library tag handler to load the library. |
| 4172 CallLibraryTagHandler(kImportTag, import_pos, canon_url); | 4207 CallLibraryTagHandler(kImportTag, import_pos, canon_url); |
| 4173 // If the library tag handler succeded without registering the | 4208 // If the library tag handler succeded without registering the |
| 4174 // library we create an empty library to import. | 4209 // library we create an empty library to import. |
| 4175 library = Library::LookupLibrary(canon_url); | 4210 library = Library::LookupLibrary(canon_url); |
| 4176 if (library.IsNull()) { | 4211 if (library.IsNull()) { |
| 4177 library = Library::New(canon_url); | 4212 library = Library::New(canon_url); |
| 4178 library.Register(); | 4213 library.Register(); |
| 4179 } | 4214 } |
| 4180 } | 4215 } |
| 4181 // Add the import to the library. | 4216 // Add the import to the library. |
| 4217 const Namespace& import = | |
| 4218 Namespace::Handle(Namespace::New(library, show_names, hide_names)); | |
| 4182 if (prefix.IsNull() || (prefix.Length() == 0)) { | 4219 if (prefix.IsNull() || (prefix.Length() == 0)) { |
| 4183 library_.AddImport(library); | 4220 library_.AddImport(import); |
| 4184 } else { | 4221 } else { |
| 4185 LibraryPrefix& library_prefix = LibraryPrefix::Handle(); | 4222 LibraryPrefix& library_prefix = LibraryPrefix::Handle(); |
| 4186 library_prefix = library_.LookupLocalLibraryPrefix(prefix); | 4223 library_prefix = library_.LookupLocalLibraryPrefix(prefix); |
| 4187 if (!library_prefix.IsNull()) { | 4224 if (!library_prefix.IsNull()) { |
| 4188 library_prefix.AddLibrary(library); | 4225 library_prefix.AddImport(import); |
| 4189 } else { | 4226 } else { |
| 4190 library_prefix = LibraryPrefix::New(prefix, library); | 4227 library_prefix = LibraryPrefix::New(prefix, import); |
| 4191 library_.AddObject(library_prefix, prefix); | 4228 library_.AddObject(library_prefix, prefix); |
| 4192 } | 4229 } |
| 4193 } | 4230 } |
| 4194 } else if (IsLiteral("export")) { | 4231 } else if (IsLiteral("export")) { |
| 4195 ErrorMsg("export clause not yet supported"); | 4232 ErrorMsg("export clause not yet supported"); |
| 4196 } else { | 4233 } else { |
| 4197 ErrorMsg("unreachable"); | 4234 ErrorMsg("unreachable"); |
| 4198 UNREACHABLE(); | 4235 UNREACHABLE(); |
| 4199 } | 4236 } |
| 4200 } | 4237 } |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 4219 (CurrentToken() == Token::kIMPORT) || | 4256 (CurrentToken() == Token::kIMPORT) || |
| 4220 (CurrentToken() == Token::kSOURCE)) { | 4257 (CurrentToken() == Token::kSOURCE)) { |
| 4221 ParseLibraryNameObsoleteSyntax(); | 4258 ParseLibraryNameObsoleteSyntax(); |
| 4222 ParseLibraryImportObsoleteSyntax(); | 4259 ParseLibraryImportObsoleteSyntax(); |
| 4223 ParseLibraryIncludeObsoleteSyntax(); | 4260 ParseLibraryIncludeObsoleteSyntax(); |
| 4224 // Core lib has not been explicitly imported, so we implicitly | 4261 // Core lib has not been explicitly imported, so we implicitly |
| 4225 // import it here. | 4262 // import it here. |
| 4226 if (!library_.ImportsCorelib()) { | 4263 if (!library_.ImportsCorelib()) { |
| 4227 Library& core_lib = Library::Handle(Library::CoreLibrary()); | 4264 Library& core_lib = Library::Handle(Library::CoreLibrary()); |
| 4228 ASSERT(!core_lib.IsNull()); | 4265 ASSERT(!core_lib.IsNull()); |
| 4229 library_.AddImport(core_lib); | 4266 const Namespace& core_ns = Namespace::Handle( |
| 4267 Namespace::New(core_lib, Array::Handle(), Array::Handle())); | |
| 4268 library_.AddImport(core_ns); | |
| 4230 } | 4269 } |
| 4231 return; | 4270 return; |
| 4232 } | 4271 } |
| 4233 | 4272 |
| 4234 // We may read metadata tokens that are part of the toplevel | 4273 // We may read metadata tokens that are part of the toplevel |
| 4235 // declaration that follows the library definitions. Therefore, we | 4274 // declaration that follows the library definitions. Therefore, we |
| 4236 // need to remember the position of the last token that was | 4275 // need to remember the position of the last token that was |
| 4237 // successfully consumed. | 4276 // successfully consumed. |
| 4238 intptr_t metadata_pos = TokenPos(); | 4277 intptr_t metadata_pos = TokenPos(); |
| 4239 SkipMetadata(); | 4278 SkipMetadata(); |
| 4240 if (IsLiteral("library")) { | 4279 if (IsLiteral("library")) { |
| 4241 ParseLibraryName(); | 4280 ParseLibraryName(); |
| 4242 metadata_pos = TokenPos(); | 4281 metadata_pos = TokenPos(); |
| 4243 SkipMetadata(); | 4282 SkipMetadata(); |
| 4244 } else if (script_.kind() == RawScript::kLibraryTag) { | 4283 } else if (script_.kind() == RawScript::kLibraryTag) { |
| 4245 ErrorMsg("library name definition expected"); | 4284 ErrorMsg("library name definition expected"); |
| 4246 } | 4285 } |
| 4247 while (IsLiteral("import") || IsLiteral("export")) { | 4286 while (IsLiteral("import") || IsLiteral("export")) { |
| 4248 ParseLibraryImportExport(); | 4287 ParseLibraryImportExport(); |
| 4249 metadata_pos = TokenPos(); | 4288 metadata_pos = TokenPos(); |
| 4250 SkipMetadata(); | 4289 SkipMetadata(); |
| 4251 } | 4290 } |
| 4252 // Core lib has not been explicitly imported, so we implicitly | 4291 // Core lib has not been explicitly imported, so we implicitly |
| 4253 // import it here. | 4292 // import it here. |
| 4254 if (!library_.ImportsCorelib()) { | 4293 if (!library_.ImportsCorelib()) { |
| 4255 Library& core_lib = Library::Handle(Library::CoreLibrary()); | 4294 Library& core_lib = Library::Handle(Library::CoreLibrary()); |
| 4256 ASSERT(!core_lib.IsNull()); | 4295 ASSERT(!core_lib.IsNull()); |
| 4257 library_.AddImport(core_lib); | 4296 const Namespace& core_ns = Namespace::Handle( |
| 4297 Namespace::New(core_lib, Array::Handle(), Array::Handle())); | |
| 4298 library_.AddImport(core_ns); | |
| 4258 } | 4299 } |
| 4259 while (IsLiteral("part")) { | 4300 while (IsLiteral("part")) { |
| 4260 ParseLibraryPart(); | 4301 ParseLibraryPart(); |
| 4261 metadata_pos = TokenPos(); | 4302 metadata_pos = TokenPos(); |
| 4262 SkipMetadata(); | 4303 SkipMetadata(); |
| 4263 } | 4304 } |
| 4264 if (IsLiteral("library") || IsLiteral("import") || IsLiteral("export")) { | 4305 if (IsLiteral("library") || IsLiteral("import") || IsLiteral("export")) { |
| 4265 ErrorMsg("unexpected token '%s'", CurrentLiteral()->ToCString()); | 4306 ErrorMsg("unexpected token '%s'", CurrentLiteral()->ToCString()); |
| 4266 } | 4307 } |
| 4267 SetPosition(metadata_pos); | 4308 SetPosition(metadata_pos); |
| (...skipping 3709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7977 obj = lib.LookupLocalObject(accessor_name); | 8018 obj = lib.LookupLocalObject(accessor_name); |
| 7978 if (!obj.IsNull()) { | 8019 if (!obj.IsNull()) { |
| 7979 return obj.raw(); | 8020 return obj.raw(); |
| 7980 } | 8021 } |
| 7981 accessor_name = Field::SetterName(name); | 8022 accessor_name = Field::SetterName(name); |
| 7982 obj = lib.LookupLocalObject(accessor_name); | 8023 obj = lib.LookupLocalObject(accessor_name); |
| 7983 return obj.raw(); | 8024 return obj.raw(); |
| 7984 } | 8025 } |
| 7985 | 8026 |
| 7986 | 8027 |
| 8028 static RawObject* LookupNameInImport(const Namespace& ns, const String& name) { | |
| 8029 Object& obj = Object::Handle(); | |
| 8030 obj = ns.Lookup(name); | |
| 8031 if (!obj.IsNull()) { | |
| 8032 return obj.raw(); | |
| 8033 } | |
| 8034 // If the given name is filtered out by the import, don't look up the | |
| 8035 // getter and setter names. | |
| 8036 if (ns.HidesName(name)) { | |
| 8037 return Object::null(); | |
| 8038 } | |
| 8039 String& accessor_name = String::Handle(Field::GetterName(name)); | |
| 8040 obj = ns.Lookup(accessor_name); | |
| 8041 if (!obj.IsNull()) { | |
| 8042 return obj.raw(); | |
| 8043 } | |
| 8044 accessor_name = Field::SetterName(name); | |
| 8045 obj = ns.Lookup(accessor_name); | |
| 8046 return obj.raw(); | |
| 8047 } | |
| 8048 | |
| 8049 | |
| 7987 // Resolve a name by checking the global scope of the current | 8050 // Resolve a name by checking the global scope of the current |
| 7988 // library. If not found in the current library, then look in the scopes | 8051 // library. If not found in the current library, then look in the scopes |
| 7989 // of all libraries that are imported without a library prefix. | 8052 // of all libraries that are imported without a library prefix. |
| 7990 // Issue an error if the name is not found in the global scope | 8053 // Issue an error if the name is not found in the global scope |
| 7991 // of the current library, but is defined in more than one imported | 8054 // of the current library, but is defined in more than one imported |
| 7992 // library, i.e. if the name cannot be resolved unambiguously. | 8055 // library, i.e. if the name cannot be resolved unambiguously. |
| 7993 RawObject* Parser::ResolveNameInCurrentLibraryScope(intptr_t ident_pos, | 8056 RawObject* Parser::ResolveNameInCurrentLibraryScope(intptr_t ident_pos, |
| 7994 const String& name) { | 8057 const String& name) { |
| 7995 TRACE_PARSER("ResolveNameInCurrentLibraryScope"); | 8058 TRACE_PARSER("ResolveNameInCurrentLibraryScope"); |
| 7996 Object& obj = Object::Handle(LookupNameInLibrary(library_, name)); | 8059 Object& obj = Object::Handle(LookupNameInLibrary(library_, name)); |
| 7997 if (obj.IsNull()) { | 8060 if (obj.IsNull()) { |
| 7998 // Name is not found in current library. Check scope of all | 8061 // Name is not found in current library. Check scope of all |
| 7999 // imported libraries. | 8062 // imported libraries. |
| 8000 String& first_lib_url = String::Handle(); | 8063 String& first_lib_url = String::Handle(); |
| 8001 Library& lib = Library::Handle(); | 8064 Namespace& import = Namespace::Handle(); |
| 8002 intptr_t num_imports = library_.num_imports(); | 8065 intptr_t num_imports = library_.num_imports(); |
| 8003 Object& resolved_obj = Object::Handle(); | 8066 Object& imported_obj = Object::Handle(); |
| 8004 for (int i = 0; i < num_imports; i++) { | 8067 for (int i = 0; i < num_imports; i++) { |
| 8005 lib ^= library_.ImportAt(i); | 8068 import ^= library_.ImportAt(i); |
| 8006 resolved_obj = LookupNameInLibrary(lib, name); | 8069 imported_obj = LookupNameInImport(import, name); |
| 8007 if (!resolved_obj.IsNull()) { | 8070 if (!imported_obj.IsNull()) { |
| 8071 const Library& lib = Library::Handle(import.library()); | |
| 8008 if (!first_lib_url.IsNull()) { | 8072 if (!first_lib_url.IsNull()) { |
| 8009 // Found duplicate definition. | 8073 // Found duplicate definition. |
| 8010 if (first_lib_url.raw() == lib.url()) { | 8074 if (first_lib_url.raw() == lib.url()) { |
| 8011 ErrorMsg(ident_pos, | 8075 ErrorMsg(ident_pos, |
| 8012 "ambiguous reference: " | 8076 "ambiguous reference: " |
| 8013 "'%s' as library '%s' is imported multiple times", | 8077 "'%s' as library '%s' is imported multiple times", |
| 8014 name.ToCString(), | 8078 name.ToCString(), |
| 8015 first_lib_url.ToCString()); | 8079 first_lib_url.ToCString()); |
| 8016 } else { | 8080 } else { |
| 8017 ErrorMsg(ident_pos, | 8081 ErrorMsg(ident_pos, |
| 8018 "ambiguous reference: " | 8082 "ambiguous reference: " |
| 8019 "'%s' is defined in library '%s' and also in '%s'", | 8083 "'%s' is defined in library '%s' and also in '%s'", |
| 8020 name.ToCString(), | 8084 name.ToCString(), |
| 8021 first_lib_url.ToCString(), | 8085 first_lib_url.ToCString(), |
| 8022 String::Handle(lib.url()).ToCString()); | 8086 String::Handle(lib.url()).ToCString()); |
| 8023 } | 8087 } |
| 8024 } else { | 8088 } else { |
| 8025 first_lib_url = lib.url(); | 8089 first_lib_url = lib.url(); |
| 8026 obj = resolved_obj.raw(); | 8090 obj = imported_obj.raw(); |
| 8027 } | 8091 } |
| 8028 } | 8092 } |
| 8029 } | 8093 } |
| 8030 } | 8094 } |
| 8031 return obj.raw(); | 8095 return obj.raw(); |
| 8032 } | 8096 } |
| 8033 | 8097 |
| 8034 | 8098 |
| 8035 RawClass* Parser::ResolveClassInCurrentLibraryScope(intptr_t ident_pos, | 8099 RawClass* Parser::ResolveClassInCurrentLibraryScope(intptr_t ident_pos, |
| 8036 const String& name) { | 8100 const String& name) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8079 } | 8143 } |
| 8080 // Lexically unresolved primary identifiers are referenced by their name. | 8144 // Lexically unresolved primary identifiers are referenced by their name. |
| 8081 return new PrimaryNode(ident_pos, ident); | 8145 return new PrimaryNode(ident_pos, ident); |
| 8082 } | 8146 } |
| 8083 | 8147 |
| 8084 | 8148 |
| 8085 RawObject* Parser::ResolveNameInPrefixScope(intptr_t ident_pos, | 8149 RawObject* Parser::ResolveNameInPrefixScope(intptr_t ident_pos, |
| 8086 const LibraryPrefix& prefix, | 8150 const LibraryPrefix& prefix, |
| 8087 const String& name) { | 8151 const String& name) { |
| 8088 TRACE_PARSER("ResolveNameInPrefixScope"); | 8152 TRACE_PARSER("ResolveNameInPrefixScope"); |
| 8089 Library& lib = Library::Handle(); | 8153 Namespace& import = Namespace::Handle(); |
| 8090 String& first_lib_url = String::Handle(); | 8154 String& first_lib_url = String::Handle(); |
| 8091 Object& obj = Object::Handle(); | 8155 Object& obj = Object::Handle(); |
| 8092 Object& resolved_obj = Object::Handle(); | 8156 Object& resolved_obj = Object::Handle(); |
| 8093 for (intptr_t i = 0; i < prefix.num_libs(); i++) { | 8157 const Array& imports = Array::Handle(prefix.imports()); |
| 8094 lib = prefix.GetLibrary(i); | 8158 for (intptr_t i = 0; i < prefix.num_imports(); i++) { |
| 8095 ASSERT(!lib.IsNull()); | 8159 import ^= imports.At(i); |
| 8096 resolved_obj = LookupNameInLibrary(lib, name); | 8160 resolved_obj = LookupNameInImport(import, name); |
| 8097 if (!resolved_obj.IsNull()) { | 8161 if (!resolved_obj.IsNull()) { |
| 8098 obj = resolved_obj.raw(); | 8162 obj = resolved_obj.raw(); |
| 8163 const Library& lib = Library::Handle(import.library()); | |
| 8099 if (first_lib_url.IsNull()) { | 8164 if (first_lib_url.IsNull()) { |
| 8100 first_lib_url = lib.url(); | 8165 first_lib_url = lib.url(); |
| 8101 } else { | 8166 } else { |
| 8102 ErrorMsg(ident_pos, | 8167 ErrorMsg(ident_pos, |
| 8103 "ambiguous reference: '%s.%s' is defined in '%s' and '%s'", | 8168 "ambiguous reference: '%s.%s' is defined in '%s' and '%s'", |
| 8104 String::Handle(prefix.name()).ToCString(), | 8169 String::Handle(prefix.name()).ToCString(), |
| 8105 name.ToCString(), | 8170 name.ToCString(), |
| 8106 first_lib_url.ToCString(), | 8171 first_lib_url.ToCString(), |
| 8107 String::Handle(lib.url()).ToCString()); | 8172 String::Handle(lib.url()).ToCString()); |
|
siva
2012/09/24 21:12:37
We need a "if (first_lib_url.raw() == lib.url())"
hausner
2012/09/24 21:41:06
Done.
| |
| 8108 } | 8173 } |
| 8109 } | 8174 } |
| 8110 } | 8175 } |
| 8111 return obj.raw(); | 8176 return obj.raw(); |
| 8112 } | 8177 } |
| 8113 | 8178 |
| 8114 | 8179 |
| 8115 RawClass* Parser::ResolveClassInPrefixScope(intptr_t ident_pos, | 8180 RawClass* Parser::ResolveClassInPrefixScope(intptr_t ident_pos, |
| 8116 const LibraryPrefix& prefix, | 8181 const LibraryPrefix& prefix, |
| 8117 const String& name) { | 8182 const String& name) { |
| (...skipping 1421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9539 void Parser::SkipQualIdent() { | 9604 void Parser::SkipQualIdent() { |
| 9540 ASSERT(IsIdentifier()); | 9605 ASSERT(IsIdentifier()); |
| 9541 ConsumeToken(); | 9606 ConsumeToken(); |
| 9542 if (CurrentToken() == Token::kPERIOD) { | 9607 if (CurrentToken() == Token::kPERIOD) { |
| 9543 ConsumeToken(); // Consume the kPERIOD token. | 9608 ConsumeToken(); // Consume the kPERIOD token. |
| 9544 ExpectIdentifier("identifier expected after '.'"); | 9609 ExpectIdentifier("identifier expected after '.'"); |
| 9545 } | 9610 } |
| 9546 } | 9611 } |
| 9547 | 9612 |
| 9548 } // namespace dart | 9613 } // namespace dart |
| OLD | NEW |