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); | |
|
siva
2012/09/24 18:28:51
From this code it appears that one can add private
hausner
2012/09/24 20:25:43
Private names are not contained in the export name
| |
| 4183 } else if (IsLiteral("hide")) { | |
| 4184 ConsumeToken(); | |
| 4185 ParseIdentList(&hide_list); | |
| 4186 } else { | |
| 4187 break; | |
| 4188 } | |
| 4189 } | |
|
siva
2012/09/24 18:28:51
Another question there is no check to ensure that
hausner
2012/09/24 20:25:43
I added a note to the spec asking for clarificatio
| |
| 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 library_.AddImportAll(core_lib); |
| 4230 } | 4267 } |
| 4231 return; | 4268 return; |
| 4232 } | 4269 } |
| 4233 | 4270 |
| 4234 // We may read metadata tokens that are part of the toplevel | 4271 // We may read metadata tokens that are part of the toplevel |
| 4235 // declaration that follows the library definitions. Therefore, we | 4272 // declaration that follows the library definitions. Therefore, we |
| 4236 // need to remember the position of the last token that was | 4273 // need to remember the position of the last token that was |
| 4237 // successfully consumed. | 4274 // successfully consumed. |
| 4238 intptr_t metadata_pos = TokenPos(); | 4275 intptr_t metadata_pos = TokenPos(); |
| 4239 SkipMetadata(); | 4276 SkipMetadata(); |
| 4240 if (IsLiteral("library")) { | 4277 if (IsLiteral("library")) { |
| 4241 ParseLibraryName(); | 4278 ParseLibraryName(); |
| 4242 metadata_pos = TokenPos(); | 4279 metadata_pos = TokenPos(); |
| 4243 SkipMetadata(); | 4280 SkipMetadata(); |
| 4244 } else if (script_.kind() == RawScript::kLibraryTag) { | 4281 } else if (script_.kind() == RawScript::kLibraryTag) { |
| 4245 ErrorMsg("library name definition expected"); | 4282 ErrorMsg("library name definition expected"); |
| 4246 } | 4283 } |
| 4247 while (IsLiteral("import") || IsLiteral("export")) { | 4284 while (IsLiteral("import") || IsLiteral("export")) { |
| 4248 ParseLibraryImportExport(); | 4285 ParseLibraryImportExport(); |
| 4249 metadata_pos = TokenPos(); | 4286 metadata_pos = TokenPos(); |
| 4250 SkipMetadata(); | 4287 SkipMetadata(); |
| 4251 } | 4288 } |
| 4252 // Core lib has not been explicitly imported, so we implicitly | 4289 // Core lib has not been explicitly imported, so we implicitly |
| 4253 // import it here. | 4290 // import it here. |
| 4254 if (!library_.ImportsCorelib()) { | 4291 if (!library_.ImportsCorelib()) { |
| 4255 Library& core_lib = Library::Handle(Library::CoreLibrary()); | 4292 Library& core_lib = Library::Handle(Library::CoreLibrary()); |
| 4256 ASSERT(!core_lib.IsNull()); | 4293 ASSERT(!core_lib.IsNull()); |
| 4257 library_.AddImport(core_lib); | 4294 library_.AddImportAll(core_lib); |
| 4258 } | 4295 } |
| 4259 while (IsLiteral("part")) { | 4296 while (IsLiteral("part")) { |
| 4260 ParseLibraryPart(); | 4297 ParseLibraryPart(); |
| 4261 metadata_pos = TokenPos(); | 4298 metadata_pos = TokenPos(); |
| 4262 SkipMetadata(); | 4299 SkipMetadata(); |
| 4263 } | 4300 } |
| 4264 if (IsLiteral("library") || IsLiteral("import") || IsLiteral("export")) { | 4301 if (IsLiteral("library") || IsLiteral("import") || IsLiteral("export")) { |
| 4265 ErrorMsg("unexpected token '%s'", CurrentLiteral()->ToCString()); | 4302 ErrorMsg("unexpected token '%s'", CurrentLiteral()->ToCString()); |
| 4266 } | 4303 } |
| 4267 SetPosition(metadata_pos); | 4304 SetPosition(metadata_pos); |
| (...skipping 3709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7977 obj = lib.LookupLocalObject(accessor_name); | 8014 obj = lib.LookupLocalObject(accessor_name); |
| 7978 if (!obj.IsNull()) { | 8015 if (!obj.IsNull()) { |
| 7979 return obj.raw(); | 8016 return obj.raw(); |
| 7980 } | 8017 } |
| 7981 accessor_name = Field::SetterName(name); | 8018 accessor_name = Field::SetterName(name); |
| 7982 obj = lib.LookupLocalObject(accessor_name); | 8019 obj = lib.LookupLocalObject(accessor_name); |
| 7983 return obj.raw(); | 8020 return obj.raw(); |
| 7984 } | 8021 } |
| 7985 | 8022 |
| 7986 | 8023 |
| 8024 static RawObject* LookupNameInImport(const Namespace& ns, const String& name) { | |
| 8025 Object& obj = Object::Handle(); | |
| 8026 obj = ns.Lookup(name); | |
| 8027 if (!obj.IsNull()) { | |
| 8028 return obj.raw(); | |
| 8029 } | |
| 8030 // If the given name is filtered out by the import, don't look up the | |
| 8031 // getter and setter names. | |
| 8032 if (ns.HidesName(name)) { | |
|
siva
2012/09/24 18:28:51
The name HidesName is not very readable here as it
hausner
2012/09/24 20:25:43
FiltersName does not say what the filter is doing.
| |
| 8033 return Object::null(); | |
| 8034 } | |
| 8035 String& accessor_name = String::Handle(Field::GetterName(name)); | |
| 8036 obj = ns.Lookup(accessor_name); | |
| 8037 if (!obj.IsNull()) { | |
| 8038 return obj.raw(); | |
| 8039 } | |
| 8040 accessor_name = Field::SetterName(name); | |
| 8041 obj = ns.Lookup(accessor_name); | |
| 8042 return obj.raw(); | |
| 8043 } | |
| 8044 | |
| 8045 | |
| 7987 // Resolve a name by checking the global scope of the current | 8046 // 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 | 8047 // library. If not found in the current library, then look in the scopes |
| 7989 // of all libraries that are imported without a library prefix. | 8048 // of all libraries that are imported without a library prefix. |
| 7990 // Issue an error if the name is not found in the global scope | 8049 // 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 | 8050 // of the current library, but is defined in more than one imported |
| 7992 // library, i.e. if the name cannot be resolved unambiguously. | 8051 // library, i.e. if the name cannot be resolved unambiguously. |
| 7993 RawObject* Parser::ResolveNameInCurrentLibraryScope(intptr_t ident_pos, | 8052 RawObject* Parser::ResolveNameInCurrentLibraryScope(intptr_t ident_pos, |
| 7994 const String& name) { | 8053 const String& name) { |
| 7995 TRACE_PARSER("ResolveNameInCurrentLibraryScope"); | 8054 TRACE_PARSER("ResolveNameInCurrentLibraryScope"); |
| 7996 Object& obj = Object::Handle(LookupNameInLibrary(library_, name)); | 8055 Object& obj = Object::Handle(LookupNameInLibrary(library_, name)); |
| 7997 if (obj.IsNull()) { | 8056 if (obj.IsNull()) { |
| 7998 // Name is not found in current library. Check scope of all | 8057 // Name is not found in current library. Check scope of all |
| 7999 // imported libraries. | 8058 // imported libraries. |
| 8000 String& first_lib_url = String::Handle(); | 8059 String& first_lib_url = String::Handle(); |
| 8001 Library& lib = Library::Handle(); | 8060 Namespace& import = Namespace::Handle(); |
| 8002 intptr_t num_imports = library_.num_imports(); | 8061 intptr_t num_imports = library_.num_imports(); |
| 8003 Object& resolved_obj = Object::Handle(); | 8062 Object& imported_obj = Object::Handle(); |
| 8004 for (int i = 0; i < num_imports; i++) { | 8063 for (int i = 0; i < num_imports; i++) { |
| 8005 lib ^= library_.ImportAt(i); | 8064 import ^= library_.ImportAt(i); |
| 8006 resolved_obj = LookupNameInLibrary(lib, name); | 8065 imported_obj = LookupNameInImport(import, name); |
| 8007 if (!resolved_obj.IsNull()) { | 8066 if (!imported_obj.IsNull()) { |
| 8067 const Library& lib = Library::Handle(import.library()); | |
| 8008 if (!first_lib_url.IsNull()) { | 8068 if (!first_lib_url.IsNull()) { |
| 8009 // Found duplicate definition. | 8069 // Found duplicate definition. |
| 8010 if (first_lib_url.raw() == lib.url()) { | 8070 if (first_lib_url.raw() == lib.url()) { |
| 8011 ErrorMsg(ident_pos, | 8071 ErrorMsg(ident_pos, |
| 8012 "ambiguous reference: " | 8072 "ambiguous reference: " |
| 8013 "'%s' as library '%s' is imported multiple times", | 8073 "'%s' as library '%s' is imported multiple times", |
| 8014 name.ToCString(), | 8074 name.ToCString(), |
| 8015 first_lib_url.ToCString()); | 8075 first_lib_url.ToCString()); |
| 8016 } else { | 8076 } else { |
| 8017 ErrorMsg(ident_pos, | 8077 ErrorMsg(ident_pos, |
| 8018 "ambiguous reference: " | 8078 "ambiguous reference: " |
| 8019 "'%s' is defined in library '%s' and also in '%s'", | 8079 "'%s' is defined in library '%s' and also in '%s'", |
| 8020 name.ToCString(), | 8080 name.ToCString(), |
| 8021 first_lib_url.ToCString(), | 8081 first_lib_url.ToCString(), |
| 8022 String::Handle(lib.url()).ToCString()); | 8082 String::Handle(lib.url()).ToCString()); |
| 8023 } | 8083 } |
| 8024 } else { | 8084 } else { |
| 8025 first_lib_url = lib.url(); | 8085 first_lib_url = lib.url(); |
| 8026 obj = resolved_obj.raw(); | 8086 obj = imported_obj.raw(); |
| 8027 } | 8087 } |
| 8028 } | 8088 } |
| 8029 } | 8089 } |
| 8030 } | 8090 } |
| 8031 return obj.raw(); | 8091 return obj.raw(); |
| 8032 } | 8092 } |
| 8033 | 8093 |
| 8034 | 8094 |
| 8035 RawClass* Parser::ResolveClassInCurrentLibraryScope(intptr_t ident_pos, | 8095 RawClass* Parser::ResolveClassInCurrentLibraryScope(intptr_t ident_pos, |
| 8036 const String& name) { | 8096 const String& name) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8079 } | 8139 } |
| 8080 // Lexically unresolved primary identifiers are referenced by their name. | 8140 // Lexically unresolved primary identifiers are referenced by their name. |
| 8081 return new PrimaryNode(ident_pos, ident); | 8141 return new PrimaryNode(ident_pos, ident); |
| 8082 } | 8142 } |
| 8083 | 8143 |
| 8084 | 8144 |
| 8085 RawObject* Parser::ResolveNameInPrefixScope(intptr_t ident_pos, | 8145 RawObject* Parser::ResolveNameInPrefixScope(intptr_t ident_pos, |
| 8086 const LibraryPrefix& prefix, | 8146 const LibraryPrefix& prefix, |
| 8087 const String& name) { | 8147 const String& name) { |
| 8088 TRACE_PARSER("ResolveNameInPrefixScope"); | 8148 TRACE_PARSER("ResolveNameInPrefixScope"); |
| 8089 Library& lib = Library::Handle(); | 8149 Namespace& import = Namespace::Handle(); |
| 8090 String& first_lib_url = String::Handle(); | 8150 String& first_lib_url = String::Handle(); |
| 8091 Object& obj = Object::Handle(); | 8151 Object& obj = Object::Handle(); |
| 8092 Object& resolved_obj = Object::Handle(); | 8152 Object& resolved_obj = Object::Handle(); |
| 8093 for (intptr_t i = 0; i < prefix.num_libs(); i++) { | 8153 const Array& imports = Array::Handle(prefix.imports()); |
| 8094 lib = prefix.GetLibrary(i); | 8154 for (intptr_t i = 0; i < prefix.num_imports(); i++) { |
| 8095 ASSERT(!lib.IsNull()); | 8155 import ^= imports.At(i); |
| 8096 resolved_obj = LookupNameInLibrary(lib, name); | 8156 resolved_obj = LookupNameInImport(import, name); |
| 8097 if (!resolved_obj.IsNull()) { | 8157 if (!resolved_obj.IsNull()) { |
| 8098 obj = resolved_obj.raw(); | 8158 obj = resolved_obj.raw(); |
| 8159 const Library& lib = Library::Handle(import.library()); | |
| 8099 if (first_lib_url.IsNull()) { | 8160 if (first_lib_url.IsNull()) { |
| 8100 first_lib_url = lib.url(); | 8161 first_lib_url = lib.url(); |
| 8101 } else { | 8162 } else { |
| 8102 ErrorMsg(ident_pos, | 8163 ErrorMsg(ident_pos, |
| 8103 "ambiguous reference: '%s.%s' is defined in '%s' and '%s'", | 8164 "ambiguous reference: '%s.%s' is defined in '%s' and '%s'", |
| 8104 String::Handle(prefix.name()).ToCString(), | 8165 String::Handle(prefix.name()).ToCString(), |
| 8105 name.ToCString(), | 8166 name.ToCString(), |
| 8106 first_lib_url.ToCString(), | 8167 first_lib_url.ToCString(), |
| 8107 String::Handle(lib.url()).ToCString()); | 8168 String::Handle(lib.url()).ToCString()); |
| 8108 } | 8169 } |
| (...skipping 1430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9539 void Parser::SkipQualIdent() { | 9600 void Parser::SkipQualIdent() { |
| 9540 ASSERT(IsIdentifier()); | 9601 ASSERT(IsIdentifier()); |
| 9541 ConsumeToken(); | 9602 ConsumeToken(); |
| 9542 if (CurrentToken() == Token::kPERIOD) { | 9603 if (CurrentToken() == Token::kPERIOD) { |
| 9543 ConsumeToken(); // Consume the kPERIOD token. | 9604 ConsumeToken(); // Consume the kPERIOD token. |
| 9544 ExpectIdentifier("identifier expected after '.'"); | 9605 ExpectIdentifier("identifier expected after '.'"); |
| 9545 } | 9606 } |
| 9546 } | 9607 } |
| 9547 | 9608 |
| 9548 } // namespace dart | 9609 } // namespace dart |
| OLD | NEW |