| 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 #include "vm/flags.h" | 6 #include "vm/flags.h" |
| 7 | 7 |
| 8 #ifndef DART_PRECOMPILED_RUNTIME | 8 #ifndef DART_PRECOMPILED_RUNTIME |
| 9 | 9 |
| 10 #include "lib/invocation_mirror.h" | 10 #include "lib/invocation_mirror.h" |
| (...skipping 4220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4231 func.set_modifier(async_modifier); | 4231 func.set_modifier(async_modifier); |
| 4232 if (library_.is_dart_scheme() && library_.IsPrivate(*method->name)) { | 4232 if (library_.is_dart_scheme() && library_.IsPrivate(*method->name)) { |
| 4233 func.set_is_reflectable(false); | 4233 func.set_is_reflectable(false); |
| 4234 } | 4234 } |
| 4235 if (is_patch_source() && IsPatchAnnotation(method->metadata_pos)) { | 4235 if (is_patch_source() && IsPatchAnnotation(method->metadata_pos)) { |
| 4236 // Currently, we just ignore the patch annotation. If the function | 4236 // Currently, we just ignore the patch annotation. If the function |
| 4237 // name already exists in the patched class, this function will replace | 4237 // name already exists in the patched class, this function will replace |
| 4238 // the one in the patched class. | 4238 // the one in the patched class. |
| 4239 method->metadata_pos = TokenPosition::kNoSource; | 4239 method->metadata_pos = TokenPosition::kNoSource; |
| 4240 } | 4240 } |
| 4241 if (FLAG_enable_mirrors && (method->metadata_pos.IsReal())) { | 4241 if (method->metadata_pos.IsReal()) { |
| 4242 library_.AddFunctionMetadata(func, method->metadata_pos); | 4242 library_.AddFunctionMetadata(func, method->metadata_pos); |
| 4243 } | 4243 } |
| 4244 if (method->has_native) { | 4244 if (method->has_native) { |
| 4245 func.set_native_name(*native_name); | 4245 func.set_native_name(*native_name); |
| 4246 } | 4246 } |
| 4247 | 4247 |
| 4248 // If this method is a redirecting factory, set the redirection information. | 4248 // If this method is a redirecting factory, set the redirection information. |
| 4249 if (!redirection_type.IsNull()) { | 4249 if (!redirection_type.IsNull()) { |
| 4250 ASSERT(func.IsFactory()); | 4250 ASSERT(func.IsFactory()); |
| 4251 func.SetRedirectionType(redirection_type); | 4251 func.SetRedirectionType(redirection_type); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4338 field->has_const, is_reflectable, current_class(), | 4338 field->has_const, is_reflectable, current_class(), |
| 4339 *field->type, field->name_pos); | 4339 *field->type, field->name_pos); |
| 4340 class_field.set_has_initializer(has_initializer); | 4340 class_field.set_has_initializer(has_initializer); |
| 4341 members->AddField(class_field); | 4341 members->AddField(class_field); |
| 4342 field->field_ = &class_field; | 4342 field->field_ = &class_field; |
| 4343 if (is_patch_source() && IsPatchAnnotation(field->metadata_pos)) { | 4343 if (is_patch_source() && IsPatchAnnotation(field->metadata_pos)) { |
| 4344 // Currently, we just ignore the patch annotation on fields. | 4344 // Currently, we just ignore the patch annotation on fields. |
| 4345 // All fields in the patch class are added to the patched class. | 4345 // All fields in the patch class are added to the patched class. |
| 4346 field->metadata_pos = TokenPosition::kNoSource; | 4346 field->metadata_pos = TokenPosition::kNoSource; |
| 4347 } | 4347 } |
| 4348 if (FLAG_enable_mirrors && (field->metadata_pos.IsReal())) { | 4348 if ((field->metadata_pos.IsReal())) { |
| 4349 library_.AddFieldMetadata(class_field, field->metadata_pos); | 4349 library_.AddFieldMetadata(class_field, field->metadata_pos); |
| 4350 } | 4350 } |
| 4351 | 4351 |
| 4352 // Start tracking types for fields with simple initializers in their | 4352 // Start tracking types for fields with simple initializers in their |
| 4353 // definition. This avoids some of the overhead to track this at runtime | 4353 // definition. This avoids some of the overhead to track this at runtime |
| 4354 // and rules out many fields from being unnecessary unboxing candidates. | 4354 // and rules out many fields from being unnecessary unboxing candidates. |
| 4355 if (!field->has_static && has_initializer && has_simple_literal) { | 4355 if (!field->has_static && has_initializer && has_simple_literal) { |
| 4356 class_field.RecordStore(init_value); | 4356 class_field.RecordStore(init_value); |
| 4357 if (!init_value.IsNull() && init_value.IsDouble()) { | 4357 if (!init_value.IsNull() && init_value.IsDouble()) { |
| 4358 class_field.set_is_double_initialized(true); | 4358 class_field.set_is_double_initialized(true); |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4723 | 4723 |
| 4724 Object& obj = Object::Handle(Z, library_.LookupLocalObject(*enum_name)); | 4724 Object& obj = Object::Handle(Z, library_.LookupLocalObject(*enum_name)); |
| 4725 if (!obj.IsNull()) { | 4725 if (!obj.IsNull()) { |
| 4726 ReportError(name_pos, "'%s' is already defined", enum_name->ToCString()); | 4726 ReportError(name_pos, "'%s' is already defined", enum_name->ToCString()); |
| 4727 } | 4727 } |
| 4728 Class& cls = Class::Handle(Z); | 4728 Class& cls = Class::Handle(Z); |
| 4729 cls = Class::New(library_, *enum_name, script_, declaration_pos); | 4729 cls = Class::New(library_, *enum_name, script_, declaration_pos); |
| 4730 library_.AddClass(cls); | 4730 library_.AddClass(cls); |
| 4731 cls.set_is_synthesized_class(); | 4731 cls.set_is_synthesized_class(); |
| 4732 cls.set_is_enum_class(); | 4732 cls.set_is_enum_class(); |
| 4733 if (FLAG_enable_mirrors && (metadata_pos.IsReal())) { | 4733 if (metadata_pos.IsReal()) { |
| 4734 library_.AddClassMetadata(cls, tl_owner, metadata_pos); | 4734 library_.AddClassMetadata(cls, tl_owner, metadata_pos); |
| 4735 } | 4735 } |
| 4736 cls.set_super_type(Type::Handle(Z, Type::ObjectType())); | 4736 cls.set_super_type(Type::Handle(Z, Type::ObjectType())); |
| 4737 pending_classes.Add(cls, Heap::kOld); | 4737 pending_classes.Add(cls, Heap::kOld); |
| 4738 } | 4738 } |
| 4739 | 4739 |
| 4740 void Parser::ParseClassDeclaration(const GrowableObjectArray& pending_classes, | 4740 void Parser::ParseClassDeclaration(const GrowableObjectArray& pending_classes, |
| 4741 const Object& tl_owner, | 4741 const Object& tl_owner, |
| 4742 TokenPosition metadata_pos) { | 4742 TokenPosition metadata_pos) { |
| 4743 TRACE_PARSER("ParseClassDeclaration"); | 4743 TRACE_PARSER("ParseClassDeclaration"); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4840 String::Handle(orig_bound.UserVisibleName()).ToCString()); | 4840 String::Handle(orig_bound.UserVisibleName()).ToCString()); |
| 4841 } | 4841 } |
| 4842 } | 4842 } |
| 4843 } | 4843 } |
| 4844 cls.set_type_parameters(orig_type_parameters); | 4844 cls.set_type_parameters(orig_type_parameters); |
| 4845 } | 4845 } |
| 4846 | 4846 |
| 4847 if (is_abstract) { | 4847 if (is_abstract) { |
| 4848 cls.set_is_abstract(); | 4848 cls.set_is_abstract(); |
| 4849 } | 4849 } |
| 4850 if (FLAG_enable_mirrors && metadata_pos.IsReal()) { | 4850 if (metadata_pos.IsReal()) { |
| 4851 library_.AddClassMetadata(cls, tl_owner, metadata_pos); | 4851 library_.AddClassMetadata(cls, tl_owner, metadata_pos); |
| 4852 } | 4852 } |
| 4853 | 4853 |
| 4854 const bool is_mixin_declaration = (CurrentToken() == Token::kASSIGN); | 4854 const bool is_mixin_declaration = (CurrentToken() == Token::kASSIGN); |
| 4855 if (is_mixin_declaration && is_patch) { | 4855 if (is_mixin_declaration && is_patch) { |
| 4856 ReportError(classname_pos, | 4856 ReportError(classname_pos, |
| 4857 "mixin application '%s' may not be a patch class", | 4857 "mixin application '%s' may not be a patch class", |
| 4858 class_name.ToCString()); | 4858 class_name.ToCString()); |
| 4859 } | 4859 } |
| 4860 | 4860 |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5328 mixin_application.set_is_synthesized_class(); | 5328 mixin_application.set_is_synthesized_class(); |
| 5329 | 5329 |
| 5330 // This mixin application alias needs an implicit constructor, but it is | 5330 // This mixin application alias needs an implicit constructor, but it is |
| 5331 // too early to call 'AddImplicitConstructor(mixin_application)' here, | 5331 // too early to call 'AddImplicitConstructor(mixin_application)' here, |
| 5332 // because this class should be lazily compiled. | 5332 // because this class should be lazily compiled. |
| 5333 if (CurrentToken() == Token::kIMPLEMENTS) { | 5333 if (CurrentToken() == Token::kIMPLEMENTS) { |
| 5334 ParseInterfaceList(mixin_application); | 5334 ParseInterfaceList(mixin_application); |
| 5335 } | 5335 } |
| 5336 ExpectSemicolon(); | 5336 ExpectSemicolon(); |
| 5337 pending_classes.Add(mixin_application, Heap::kOld); | 5337 pending_classes.Add(mixin_application, Heap::kOld); |
| 5338 if (FLAG_enable_mirrors && metadata_pos.IsReal()) { | 5338 if (metadata_pos.IsReal()) { |
| 5339 library_.AddClassMetadata(mixin_application, tl_owner, metadata_pos); | 5339 library_.AddClassMetadata(mixin_application, tl_owner, metadata_pos); |
| 5340 } | 5340 } |
| 5341 } | 5341 } |
| 5342 | 5342 |
| 5343 // Look ahead to detect if we are seeing ident [ TypeParameters ] ("(" | "="). | 5343 // Look ahead to detect if we are seeing ident [ TypeParameters ] ("(" | "="). |
| 5344 // We need this lookahead to distinguish between the optional return type | 5344 // We need this lookahead to distinguish between the optional return type |
| 5345 // and the alias name of a function type alias. | 5345 // and the alias name of a function type alias. |
| 5346 // Token position remains unchanged. | 5346 // Token position remains unchanged. |
| 5347 bool Parser::IsFunctionTypeAliasName(bool* use_function_type_syntax) { | 5347 bool Parser::IsFunctionTypeAliasName(bool* use_function_type_syntax) { |
| 5348 if (IsIdentifier()) { | 5348 if (IsIdentifier()) { |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5476 Type::Cast(function_type).signature()); | 5476 Type::Cast(function_type).signature()); |
| 5477 | 5477 |
| 5478 if (FLAG_trace_parser) { | 5478 if (FLAG_trace_parser) { |
| 5479 OS::Print("TopLevel parsing function type alias '%s'\n", | 5479 OS::Print("TopLevel parsing function type alias '%s'\n", |
| 5480 String::Handle(Z, signature_function.Signature()).ToCString()); | 5480 String::Handle(Z, signature_function.Signature()).ToCString()); |
| 5481 } | 5481 } |
| 5482 // The alias should not be marked as finalized yet, since it needs to be | 5482 // The alias should not be marked as finalized yet, since it needs to be |
| 5483 // checked in the class finalizer for illegal self references. | 5483 // checked in the class finalizer for illegal self references. |
| 5484 ASSERT(!function_type_alias.is_finalized()); | 5484 ASSERT(!function_type_alias.is_finalized()); |
| 5485 pending_classes.Add(function_type_alias, Heap::kOld); | 5485 pending_classes.Add(function_type_alias, Heap::kOld); |
| 5486 if (FLAG_enable_mirrors && metadata_pos.IsReal()) { | 5486 if (metadata_pos.IsReal()) { |
| 5487 library_.AddClassMetadata(function_type_alias, tl_owner, metadata_pos); | 5487 library_.AddClassMetadata(function_type_alias, tl_owner, metadata_pos); |
| 5488 } | 5488 } |
| 5489 } | 5489 } |
| 5490 | 5490 |
| 5491 // Consumes exactly one right angle bracket. If the current token is | 5491 // Consumes exactly one right angle bracket. If the current token is |
| 5492 // a single bracket token, it is consumed normally. However, if it is | 5492 // a single bracket token, it is consumed normally. However, if it is |
| 5493 // a double bracket, it is replaced by a single bracket token without | 5493 // a double bracket, it is replaced by a single bracket token without |
| 5494 // incrementing the token index. | 5494 // incrementing the token index. |
| 5495 void Parser::ConsumeRightAngleBracket() { | 5495 void Parser::ConsumeRightAngleBracket() { |
| 5496 if (token_kind_ == Token::kGT) { | 5496 if (token_kind_ == Token::kGT) { |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5645 type_parameter_bound = I->object_store()->object_type(); | 5645 type_parameter_bound = I->object_store()->object_type(); |
| 5646 } | 5646 } |
| 5647 // Note that we cannot yet calculate the final index of a function type | 5647 // Note that we cannot yet calculate the final index of a function type |
| 5648 // parameter, because we may not have parsed the parent function yet. | 5648 // parameter, because we may not have parsed the parent function yet. |
| 5649 type_parameter = TypeParameter::New( | 5649 type_parameter = TypeParameter::New( |
| 5650 parameterizing_class ? current_class() : Class::Handle(Z), | 5650 parameterizing_class ? current_class() : Class::Handle(Z), |
| 5651 parameterizing_class ? Function::Handle(Z) : innermost_function(), | 5651 parameterizing_class ? Function::Handle(Z) : innermost_function(), |
| 5652 index, type_parameter_name, type_parameter_bound, declaration_pos); | 5652 index, type_parameter_name, type_parameter_bound, declaration_pos); |
| 5653 type_parameters_array.Add( | 5653 type_parameters_array.Add( |
| 5654 &AbstractType::ZoneHandle(Z, type_parameter.raw())); | 5654 &AbstractType::ZoneHandle(Z, type_parameter.raw())); |
| 5655 if (FLAG_enable_mirrors && metadata_pos.IsReal()) { | 5655 if (metadata_pos.IsReal()) { |
| 5656 library_.AddTypeParameterMetadata(type_parameter, metadata_pos); | 5656 library_.AddTypeParameterMetadata(type_parameter, metadata_pos); |
| 5657 } | 5657 } |
| 5658 index++; | 5658 index++; |
| 5659 } while (CurrentToken() == Token::kCOMMA); | 5659 } while (CurrentToken() == Token::kCOMMA); |
| 5660 Token::Kind token = CurrentToken(); | 5660 Token::Kind token = CurrentToken(); |
| 5661 if ((token == Token::kGT) || (token == Token::kSHR)) { | 5661 if ((token == Token::kGT) || (token == Token::kSHR)) { |
| 5662 ConsumeRightAngleBracket(); | 5662 ConsumeRightAngleBracket(); |
| 5663 } else { | 5663 } else { |
| 5664 ReportError("right angle bracket expected"); | 5664 ReportError("right angle bracket expected"); |
| 5665 } | 5665 } |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5807 | 5807 |
| 5808 const bool is_reflectable = | 5808 const bool is_reflectable = |
| 5809 !(library_.is_dart_scheme() && library_.IsPrivate(var_name)); | 5809 !(library_.is_dart_scheme() && library_.IsPrivate(var_name)); |
| 5810 | 5810 |
| 5811 field = Field::NewTopLevel(var_name, is_final, is_const, owner, name_pos); | 5811 field = Field::NewTopLevel(var_name, is_final, is_const, owner, name_pos); |
| 5812 field.SetFieldType(type); | 5812 field.SetFieldType(type); |
| 5813 field.set_is_reflectable(is_reflectable); | 5813 field.set_is_reflectable(is_reflectable); |
| 5814 field.SetStaticValue(Object::null_instance(), true); | 5814 field.SetStaticValue(Object::null_instance(), true); |
| 5815 top_level->AddField(field); | 5815 top_level->AddField(field); |
| 5816 library_.AddObject(field, var_name); | 5816 library_.AddObject(field, var_name); |
| 5817 if (FLAG_enable_mirrors && metadata_pos.IsReal()) { | 5817 if (metadata_pos.IsReal()) { |
| 5818 library_.AddFieldMetadata(field, metadata_pos); | 5818 library_.AddFieldMetadata(field, metadata_pos); |
| 5819 } | 5819 } |
| 5820 if (CurrentToken() == Token::kASSIGN) { | 5820 if (CurrentToken() == Token::kASSIGN) { |
| 5821 ConsumeToken(); | 5821 ConsumeToken(); |
| 5822 Instance& field_value = Instance::Handle(Z, Object::sentinel().raw()); | 5822 Instance& field_value = Instance::Handle(Z, Object::sentinel().raw()); |
| 5823 bool has_simple_literal = false; | 5823 bool has_simple_literal = false; |
| 5824 if (LookaheadToken(1) == Token::kSEMICOLON) { | 5824 if (LookaheadToken(1) == Token::kSEMICOLON) { |
| 5825 has_simple_literal = IsSimpleLiteral(type, &field_value); | 5825 has_simple_literal = IsSimpleLiteral(type, &field_value); |
| 5826 } | 5826 } |
| 5827 SkipExpr(); | 5827 SkipExpr(); |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6005 library_.AddObject(func, func_name); | 6005 library_.AddObject(func, func_name); |
| 6006 } else { | 6006 } else { |
| 6007 // Need to remove the previously added function that is being patched. | 6007 // Need to remove the previously added function that is being patched. |
| 6008 const Class& toplevel_cls = Class::Handle(Z, library_.toplevel_class()); | 6008 const Class& toplevel_cls = Class::Handle(Z, library_.toplevel_class()); |
| 6009 const Function& replaced_func = | 6009 const Function& replaced_func = |
| 6010 Function::Handle(Z, toplevel_cls.LookupStaticFunction(func_name)); | 6010 Function::Handle(Z, toplevel_cls.LookupStaticFunction(func_name)); |
| 6011 ASSERT(!replaced_func.IsNull()); | 6011 ASSERT(!replaced_func.IsNull()); |
| 6012 toplevel_cls.RemoveFunction(replaced_func); | 6012 toplevel_cls.RemoveFunction(replaced_func); |
| 6013 library_.ReplaceObject(func, func_name); | 6013 library_.ReplaceObject(func, func_name); |
| 6014 } | 6014 } |
| 6015 if (FLAG_enable_mirrors && metadata_pos.IsReal()) { | 6015 if (metadata_pos.IsReal()) { |
| 6016 library_.AddFunctionMetadata(func, metadata_pos); | 6016 library_.AddFunctionMetadata(func, metadata_pos); |
| 6017 } | 6017 } |
| 6018 } | 6018 } |
| 6019 | 6019 |
| 6020 void Parser::ParseTopLevelAccessor(TopLevel* top_level, | 6020 void Parser::ParseTopLevelAccessor(TopLevel* top_level, |
| 6021 const Object& owner, | 6021 const Object& owner, |
| 6022 TokenPosition metadata_pos) { | 6022 TokenPosition metadata_pos) { |
| 6023 TRACE_PARSER("ParseTopLevelAccessor"); | 6023 TRACE_PARSER("ParseTopLevelAccessor"); |
| 6024 const TokenPosition decl_begin_pos = TokenPos(); | 6024 const TokenPosition decl_begin_pos = TokenPos(); |
| 6025 const bool is_static = true; | 6025 const bool is_static = true; |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6165 // Need to remove the previously added accessor that is being patched. | 6165 // Need to remove the previously added accessor that is being patched. |
| 6166 const Class& toplevel_cls = Class::Handle( | 6166 const Class& toplevel_cls = Class::Handle( |
| 6167 Z, owner.IsClass() ? Class::Cast(owner).raw() | 6167 Z, owner.IsClass() ? Class::Cast(owner).raw() |
| 6168 : PatchClass::Cast(owner).patched_class()); | 6168 : PatchClass::Cast(owner).patched_class()); |
| 6169 const Function& replaced_func = | 6169 const Function& replaced_func = |
| 6170 Function::Handle(Z, toplevel_cls.LookupFunction(accessor_name)); | 6170 Function::Handle(Z, toplevel_cls.LookupFunction(accessor_name)); |
| 6171 ASSERT(!replaced_func.IsNull()); | 6171 ASSERT(!replaced_func.IsNull()); |
| 6172 toplevel_cls.RemoveFunction(replaced_func); | 6172 toplevel_cls.RemoveFunction(replaced_func); |
| 6173 library_.ReplaceObject(func, accessor_name); | 6173 library_.ReplaceObject(func, accessor_name); |
| 6174 } | 6174 } |
| 6175 if (FLAG_enable_mirrors && metadata_pos.IsReal()) { | 6175 if (metadata_pos.IsReal()) { |
| 6176 library_.AddFunctionMetadata(func, metadata_pos); | 6176 library_.AddFunctionMetadata(func, metadata_pos); |
| 6177 } | 6177 } |
| 6178 } | 6178 } |
| 6179 | 6179 |
| 6180 RawObject* Parser::CallLibraryTagHandler(Dart_LibraryTag tag, | 6180 RawObject* Parser::CallLibraryTagHandler(Dart_LibraryTag tag, |
| 6181 TokenPosition token_pos, | 6181 TokenPosition token_pos, |
| 6182 const String& url) { | 6182 const String& url) { |
| 6183 Dart_LibraryTagHandler handler = I->library_tag_handler(); | 6183 Dart_LibraryTagHandler handler = I->library_tag_handler(); |
| 6184 if (handler == NULL) { | 6184 if (handler == NULL) { |
| 6185 if (url.StartsWith(Symbols::DartScheme())) { | 6185 if (url.StartsWith(Symbols::DartScheme())) { |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6374 // library import, call the library tag handler to request loading | 6374 // library import, call the library tag handler to request loading |
| 6375 // the library. | 6375 // the library. |
| 6376 if (library.LoadNotStarted() && | 6376 if (library.LoadNotStarted() && |
| 6377 (!is_deferred_import || FLAG_load_deferred_eagerly)) { | 6377 (!is_deferred_import || FLAG_load_deferred_eagerly)) { |
| 6378 library.SetLoadRequested(); | 6378 library.SetLoadRequested(); |
| 6379 CallLibraryTagHandler(Dart_kImportTag, import_pos, canon_url); | 6379 CallLibraryTagHandler(Dart_kImportTag, import_pos, canon_url); |
| 6380 } | 6380 } |
| 6381 | 6381 |
| 6382 Namespace& ns = | 6382 Namespace& ns = |
| 6383 Namespace::Handle(Z, Namespace::New(library, show_names, hide_names)); | 6383 Namespace::Handle(Z, Namespace::New(library, show_names, hide_names)); |
| 6384 if (FLAG_enable_mirrors && metadata_pos.IsReal()) { | 6384 if (metadata_pos.IsReal()) { |
| 6385 ns.AddMetadata(tl_owner, metadata_pos); | 6385 ns.AddMetadata(tl_owner, metadata_pos); |
| 6386 } | 6386 } |
| 6387 | 6387 |
| 6388 // Ensure that private dart:_ libraries are only imported into dart: | 6388 // Ensure that private dart:_ libraries are only imported into dart: |
| 6389 // libraries, including indirectly through exports. | 6389 // libraries, including indirectly through exports. |
| 6390 const String& lib_url = String::Handle(Z, library_.url()); | 6390 const String& lib_url = String::Handle(Z, library_.url()); |
| 6391 if (canon_url.StartsWith(Symbols::DartSchemePrivate()) && | 6391 if (canon_url.StartsWith(Symbols::DartSchemePrivate()) && |
| 6392 !lib_url.StartsWith(Symbols::DartScheme())) { | 6392 !lib_url.StartsWith(Symbols::DartScheme())) { |
| 6393 ReportError(import_pos, "private library is not accessible"); | 6393 ReportError(import_pos, "private library is not accessible"); |
| 6394 } | 6394 } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6461 // declaration that follows the library definitions. Therefore, we | 6461 // declaration that follows the library definitions. Therefore, we |
| 6462 // need to remember the position of the last token that was | 6462 // need to remember the position of the last token that was |
| 6463 // successfully consumed. | 6463 // successfully consumed. |
| 6464 TokenPosition rewind_pos = TokenPos(); | 6464 TokenPosition rewind_pos = TokenPos(); |
| 6465 TokenPosition metadata_pos = SkipMetadata(); | 6465 TokenPosition metadata_pos = SkipMetadata(); |
| 6466 if (CurrentToken() == Token::kLIBRARY) { | 6466 if (CurrentToken() == Token::kLIBRARY) { |
| 6467 if (is_patch_source()) { | 6467 if (is_patch_source()) { |
| 6468 ReportError("patch cannot override library name"); | 6468 ReportError("patch cannot override library name"); |
| 6469 } | 6469 } |
| 6470 ParseLibraryName(); | 6470 ParseLibraryName(); |
| 6471 if (FLAG_enable_mirrors && metadata_pos.IsReal()) { | 6471 if (metadata_pos.IsReal()) { |
| 6472 library_.AddLibraryMetadata(tl_owner, metadata_pos); | 6472 library_.AddLibraryMetadata(tl_owner, metadata_pos); |
| 6473 } | 6473 } |
| 6474 rewind_pos = TokenPos(); | 6474 rewind_pos = TokenPos(); |
| 6475 metadata_pos = SkipMetadata(); | 6475 metadata_pos = SkipMetadata(); |
| 6476 } | 6476 } |
| 6477 while ((CurrentToken() == Token::kIMPORT) || | 6477 while ((CurrentToken() == Token::kIMPORT) || |
| 6478 (CurrentToken() == Token::kEXPORT)) { | 6478 (CurrentToken() == Token::kEXPORT)) { |
| 6479 ParseLibraryImportExport(tl_owner, metadata_pos); | 6479 ParseLibraryImportExport(tl_owner, metadata_pos); |
| 6480 rewind_pos = TokenPos(); | 6480 rewind_pos = TokenPos(); |
| 6481 metadata_pos = SkipMetadata(); | 6481 metadata_pos = SkipMetadata(); |
| (...skipping 1561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8043 // The function will be registered in the lookup table by the | 8043 // The function will be registered in the lookup table by the |
| 8044 // EffectGraphVisitor::VisitClosureNode when the newly allocated closure | 8044 // EffectGraphVisitor::VisitClosureNode when the newly allocated closure |
| 8045 // function has been properly setup. | 8045 // function has been properly setup. |
| 8046 found_func = false; | 8046 found_func = false; |
| 8047 function = Function::NewClosureFunction(*function_name, | 8047 function = Function::NewClosureFunction(*function_name, |
| 8048 innermost_function(), function_pos); | 8048 innermost_function(), function_pos); |
| 8049 function.set_result_type(result_type); | 8049 function.set_result_type(result_type); |
| 8050 // The result type may refer to the function's type parameters, | 8050 // The result type may refer to the function's type parameters, |
| 8051 // but was not parsed in the scope of the function. Adjust. | 8051 // but was not parsed in the scope of the function. Adjust. |
| 8052 result_type.SetScopeFunction(function); | 8052 result_type.SetScopeFunction(function); |
| 8053 if (FLAG_enable_mirrors && metadata_pos.IsReal()) { | 8053 if (metadata_pos.IsReal()) { |
| 8054 library_.AddFunctionMetadata(function, metadata_pos); | 8054 library_.AddFunctionMetadata(function, metadata_pos); |
| 8055 } | 8055 } |
| 8056 } | 8056 } |
| 8057 | 8057 |
| 8058 ASSERT(function.parent_function() == innermost_function_.raw()); | 8058 ASSERT(function.parent_function() == innermost_function_.raw()); |
| 8059 innermost_function_ = function.raw(); | 8059 innermost_function_ = function.raw(); |
| 8060 | 8060 |
| 8061 if (CurrentToken() == Token::kLT) { | 8061 if (CurrentToken() == Token::kLT) { |
| 8062 if (!FLAG_generic_method_syntax) { | 8062 if (!FLAG_generic_method_syntax) { |
| 8063 ReportError("generic functions not supported"); | 8063 ReportError("generic functions not supported"); |
| (...skipping 7038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15102 bool Parser::FieldHasFunctionLiteralInitializer(const Field& field, | 15102 bool Parser::FieldHasFunctionLiteralInitializer(const Field& field, |
| 15103 TokenPosition* start, | 15103 TokenPosition* start, |
| 15104 TokenPosition* end) { | 15104 TokenPosition* end) { |
| 15105 UNREACHABLE(); | 15105 UNREACHABLE(); |
| 15106 return false; | 15106 return false; |
| 15107 } | 15107 } |
| 15108 | 15108 |
| 15109 } // namespace dart | 15109 } // namespace dart |
| 15110 | 15110 |
| 15111 #endif // DART_PRECOMPILED_RUNTIME | 15111 #endif // DART_PRECOMPILED_RUNTIME |
| OLD | NEW |