| 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 "platform/utils.h" | 8 #include "platform/utils.h" |
| 9 #include "vm/ast_transformer.h" | 9 #include "vm/ast_transformer.h" |
| 10 #include "vm/bootstrap.h" | 10 #include "vm/bootstrap.h" |
| (...skipping 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1075 false, // !abstract | 1075 false, // !abstract |
| 1076 false, // !external | 1076 false, // !external |
| 1077 false, // !native | 1077 false, // !native |
| 1078 Class::Handle(field.owner()), | 1078 Class::Handle(field.owner()), |
| 1079 field.token_pos())); | 1079 field.token_pos())); |
| 1080 initializer.set_result_type(AbstractType::Handle(isolate, field.type())); | 1080 initializer.set_result_type(AbstractType::Handle(isolate, field.type())); |
| 1081 // Static initializer functions are hidden from the user. | 1081 // Static initializer functions are hidden from the user. |
| 1082 // Since they are only executed once, we avoid optimizing | 1082 // Since they are only executed once, we avoid optimizing |
| 1083 // and inlining them. After the field is initialized, the | 1083 // and inlining them. After the field is initialized, the |
| 1084 // compiler can eliminate the call to the static initializer. | 1084 // compiler can eliminate the call to the static initializer. |
| 1085 initializer.set_is_visible(false); | 1085 initializer.set_is_reflectable(false); |
| 1086 initializer.set_is_debuggable(false); | 1086 initializer.set_is_debuggable(false); |
| 1087 initializer.SetIsOptimizable(false); | 1087 initializer.SetIsOptimizable(false); |
| 1088 initializer.set_is_inlinable(false); | 1088 initializer.set_is_inlinable(false); |
| 1089 | 1089 |
| 1090 ParsedFunction* parsed_function = new ParsedFunction(isolate, initializer); | 1090 ParsedFunction* parsed_function = new ParsedFunction(isolate, initializer); |
| 1091 Parser parser(script, parsed_function, field.token_pos()); | 1091 Parser parser(script, parsed_function, field.token_pos()); |
| 1092 | 1092 |
| 1093 SequenceNode* body = parser.ParseStaticInitializer(); | 1093 SequenceNode* body = parser.ParseStaticInitializer(); |
| 1094 parsed_function->SetNodeSequence(body); | 1094 parsed_function->SetNodeSequence(body); |
| 1095 parsed_function->set_default_parameter_values(Object::null_array()); | 1095 parsed_function->set_default_parameter_values(Object::null_array()); |
| (...skipping 2549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3645 method->has_abstract, | 3645 method->has_abstract, |
| 3646 method->has_external, | 3646 method->has_external, |
| 3647 method->has_native, | 3647 method->has_native, |
| 3648 current_class(), | 3648 current_class(), |
| 3649 method->decl_begin_pos)); | 3649 method->decl_begin_pos)); |
| 3650 func.set_result_type(*method->type); | 3650 func.set_result_type(*method->type); |
| 3651 func.set_end_token_pos(method_end_pos); | 3651 func.set_end_token_pos(method_end_pos); |
| 3652 func.set_is_redirecting(is_redirecting); | 3652 func.set_is_redirecting(is_redirecting); |
| 3653 func.set_modifier(async_modifier); | 3653 func.set_modifier(async_modifier); |
| 3654 if (library_.is_dart_scheme() && library_.IsPrivate(*method->name)) { | 3654 if (library_.is_dart_scheme() && library_.IsPrivate(*method->name)) { |
| 3655 func.set_is_visible(false); | 3655 func.set_is_reflectable(false); |
| 3656 } | 3656 } |
| 3657 if (method->metadata_pos > 0) { | 3657 if (method->metadata_pos > 0) { |
| 3658 library_.AddFunctionMetadata(func, method->metadata_pos); | 3658 library_.AddFunctionMetadata(func, method->metadata_pos); |
| 3659 } | 3659 } |
| 3660 | 3660 |
| 3661 // If this method is a redirecting factory, set the redirection information. | 3661 // If this method is a redirecting factory, set the redirection information. |
| 3662 if (!redirection_type.IsNull()) { | 3662 if (!redirection_type.IsNull()) { |
| 3663 ASSERT(func.IsFactory()); | 3663 ASSERT(func.IsFactory()); |
| 3664 func.SetRedirectionType(redirection_type); | 3664 func.SetRedirectionType(redirection_type); |
| 3665 if (!redirection_identifier.IsNull()) { | 3665 if (!redirection_identifier.IsNull()) { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3771 field->has_static, | 3771 field->has_static, |
| 3772 field->has_const, | 3772 field->has_const, |
| 3773 /* is_abstract = */ false, | 3773 /* is_abstract = */ false, |
| 3774 /* is_external = */ false, | 3774 /* is_external = */ false, |
| 3775 /* is_native = */ false, | 3775 /* is_native = */ false, |
| 3776 current_class(), | 3776 current_class(), |
| 3777 field->name_pos); | 3777 field->name_pos); |
| 3778 getter.set_result_type(*field->type); | 3778 getter.set_result_type(*field->type); |
| 3779 getter.set_is_debuggable(false); | 3779 getter.set_is_debuggable(false); |
| 3780 if (library_.is_dart_scheme() && library_.IsPrivate(*field->name)) { | 3780 if (library_.is_dart_scheme() && library_.IsPrivate(*field->name)) { |
| 3781 getter.set_is_visible(false); | 3781 getter.set_is_reflectable(false); |
| 3782 } | 3782 } |
| 3783 members->AddFunction(getter); | 3783 members->AddFunction(getter); |
| 3784 } | 3784 } |
| 3785 } | 3785 } |
| 3786 | 3786 |
| 3787 // For instance fields, we create implicit getter and setter methods. | 3787 // For instance fields, we create implicit getter and setter methods. |
| 3788 if (!field->has_static) { | 3788 if (!field->has_static) { |
| 3789 String& getter_name = String::Handle(I, | 3789 String& getter_name = String::Handle(I, |
| 3790 Field::GetterSymbol(*field->name)); | 3790 Field::GetterSymbol(*field->name)); |
| 3791 getter = Function::New(getter_name, RawFunction::kImplicitGetter, | 3791 getter = Function::New(getter_name, RawFunction::kImplicitGetter, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 3817 field->name_pos); | 3817 field->name_pos); |
| 3818 ParamList params; | 3818 ParamList params; |
| 3819 ASSERT(current_class().raw() == setter.Owner()); | 3819 ASSERT(current_class().raw() == setter.Owner()); |
| 3820 params.AddReceiver(ReceiverType(current_class()), field->name_pos); | 3820 params.AddReceiver(ReceiverType(current_class()), field->name_pos); |
| 3821 params.AddFinalParameter(TokenPos(), | 3821 params.AddFinalParameter(TokenPos(), |
| 3822 &Symbols::Value(), | 3822 &Symbols::Value(), |
| 3823 field->type); | 3823 field->type); |
| 3824 setter.set_result_type(Type::Handle(I, Type::VoidType())); | 3824 setter.set_result_type(Type::Handle(I, Type::VoidType())); |
| 3825 setter.set_is_debuggable(false); | 3825 setter.set_is_debuggable(false); |
| 3826 if (library_.is_dart_scheme() && library_.IsPrivate(*field->name)) { | 3826 if (library_.is_dart_scheme() && library_.IsPrivate(*field->name)) { |
| 3827 setter.set_is_visible(false); | 3827 setter.set_is_reflectable(false); |
| 3828 } | 3828 } |
| 3829 AddFormalParamsToFunction(¶ms, setter); | 3829 AddFormalParamsToFunction(¶ms, setter); |
| 3830 members->AddFunction(setter); | 3830 members->AddFunction(setter); |
| 3831 } | 3831 } |
| 3832 } | 3832 } |
| 3833 | 3833 |
| 3834 if (CurrentToken() != Token::kCOMMA) { | 3834 if (CurrentToken() != Token::kCOMMA) { |
| 3835 break; | 3835 break; |
| 3836 } | 3836 } |
| 3837 ConsumeToken(); | 3837 ConsumeToken(); |
| (...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4567 /* is_static = */ false, | 4567 /* is_static = */ false, |
| 4568 /* is_const = */ false, | 4568 /* is_const = */ false, |
| 4569 /* is_abstract = */ false, | 4569 /* is_abstract = */ false, |
| 4570 /* is_external = */ false, | 4570 /* is_external = */ false, |
| 4571 /* is_native = */ false, | 4571 /* is_native = */ false, |
| 4572 cls, | 4572 cls, |
| 4573 cls.token_pos())); | 4573 cls.token_pos())); |
| 4574 ctor.set_end_token_pos(ctor.token_pos()); | 4574 ctor.set_end_token_pos(ctor.token_pos()); |
| 4575 ctor.set_is_debuggable(false); | 4575 ctor.set_is_debuggable(false); |
| 4576 if (library_.is_dart_scheme() && library_.IsPrivate(ctor_name)) { | 4576 if (library_.is_dart_scheme() && library_.IsPrivate(ctor_name)) { |
| 4577 ctor.set_is_visible(false); | 4577 ctor.set_is_reflectable(false); |
| 4578 } | 4578 } |
| 4579 | 4579 |
| 4580 ParamList params; | 4580 ParamList params; |
| 4581 // Add implicit 'this' parameter. | 4581 // Add implicit 'this' parameter. |
| 4582 const AbstractType* receiver_type = ReceiverType(cls); | 4582 const AbstractType* receiver_type = ReceiverType(cls); |
| 4583 params.AddReceiver(receiver_type, cls.token_pos()); | 4583 params.AddReceiver(receiver_type, cls.token_pos()); |
| 4584 // Add implicit parameter for construction phase. | 4584 // Add implicit parameter for construction phase. |
| 4585 params.AddFinalParameter(cls.token_pos(), | 4585 params.AddFinalParameter(cls.token_pos(), |
| 4586 &Symbols::PhaseParameter(), | 4586 &Symbols::PhaseParameter(), |
| 4587 &Type::ZoneHandle(I, Type::SmiType())); | 4587 &Type::ZoneHandle(I, Type::SmiType())); |
| (...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5146 is_static, | 5146 is_static, |
| 5147 is_const, | 5147 is_const, |
| 5148 /* is_abstract = */ false, | 5148 /* is_abstract = */ false, |
| 5149 /* is_external = */ false, | 5149 /* is_external = */ false, |
| 5150 /* is_native = */ false, | 5150 /* is_native = */ false, |
| 5151 current_class(), | 5151 current_class(), |
| 5152 name_pos); | 5152 name_pos); |
| 5153 getter.set_result_type(type); | 5153 getter.set_result_type(type); |
| 5154 getter.set_is_debuggable(false); | 5154 getter.set_is_debuggable(false); |
| 5155 if (library_.is_dart_scheme() && library_.IsPrivate(var_name)) { | 5155 if (library_.is_dart_scheme() && library_.IsPrivate(var_name)) { |
| 5156 getter.set_is_visible(false); | 5156 getter.set_is_reflectable(false); |
| 5157 } | 5157 } |
| 5158 top_level->functions.Add(getter); | 5158 top_level->functions.Add(getter); |
| 5159 } | 5159 } |
| 5160 } else if (is_final) { | 5160 } else if (is_final) { |
| 5161 ReportError(name_pos, "missing initializer for final or const variable"); | 5161 ReportError(name_pos, "missing initializer for final or const variable"); |
| 5162 } | 5162 } |
| 5163 | 5163 |
| 5164 if (CurrentToken() == Token::kCOMMA) { | 5164 if (CurrentToken() == Token::kCOMMA) { |
| 5165 ConsumeToken(); | 5165 ConsumeToken(); |
| 5166 } else if (CurrentToken() == Token::kSEMICOLON) { | 5166 } else if (CurrentToken() == Token::kSEMICOLON) { |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5270 is_static, | 5270 is_static, |
| 5271 /* is_const = */ false, | 5271 /* is_const = */ false, |
| 5272 /* is_abstract = */ false, | 5272 /* is_abstract = */ false, |
| 5273 is_external, | 5273 is_external, |
| 5274 is_native, | 5274 is_native, |
| 5275 current_class(), | 5275 current_class(), |
| 5276 decl_begin_pos)); | 5276 decl_begin_pos)); |
| 5277 func.set_result_type(result_type); | 5277 func.set_result_type(result_type); |
| 5278 func.set_end_token_pos(function_end_pos); | 5278 func.set_end_token_pos(function_end_pos); |
| 5279 func.set_modifier(func_modifier); | 5279 func.set_modifier(func_modifier); |
| 5280 if (is_native) { | |
| 5281 func.set_is_debuggable(false); | |
| 5282 } | |
| 5283 if (library_.is_dart_scheme() && library_.IsPrivate(func_name)) { | 5280 if (library_.is_dart_scheme() && library_.IsPrivate(func_name)) { |
| 5284 func.set_is_visible(false); | 5281 func.set_is_reflectable(false); |
| 5285 } | 5282 } |
| 5286 AddFormalParamsToFunction(¶ms, func); | 5283 AddFormalParamsToFunction(¶ms, func); |
| 5287 top_level->functions.Add(func); | 5284 top_level->functions.Add(func); |
| 5288 if (!is_patch) { | 5285 if (!is_patch) { |
| 5289 library_.AddObject(func, func_name); | 5286 library_.AddObject(func, func_name); |
| 5290 } else { | 5287 } else { |
| 5291 library_.ReplaceObject(func, func_name); | 5288 library_.ReplaceObject(func, func_name); |
| 5292 } | 5289 } |
| 5293 if (metadata_pos >= 0) { | 5290 if (metadata_pos >= 0) { |
| 5294 library_.AddFunctionMetadata(func, metadata_pos); | 5291 library_.AddFunctionMetadata(func, metadata_pos); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5417 is_native, | 5414 is_native, |
| 5418 current_class(), | 5415 current_class(), |
| 5419 decl_begin_pos)); | 5416 decl_begin_pos)); |
| 5420 func.set_result_type(result_type); | 5417 func.set_result_type(result_type); |
| 5421 func.set_end_token_pos(accessor_end_pos); | 5418 func.set_end_token_pos(accessor_end_pos); |
| 5422 func.set_modifier(func_modifier); | 5419 func.set_modifier(func_modifier); |
| 5423 if (is_native) { | 5420 if (is_native) { |
| 5424 func.set_is_debuggable(false); | 5421 func.set_is_debuggable(false); |
| 5425 } | 5422 } |
| 5426 if (library_.is_dart_scheme() && library_.IsPrivate(accessor_name)) { | 5423 if (library_.is_dart_scheme() && library_.IsPrivate(accessor_name)) { |
| 5427 func.set_is_visible(false); | 5424 func.set_is_reflectable(false); |
| 5428 } | 5425 } |
| 5429 AddFormalParamsToFunction(¶ms, func); | 5426 AddFormalParamsToFunction(¶ms, func); |
| 5430 top_level->functions.Add(func); | 5427 top_level->functions.Add(func); |
| 5431 if (!is_patch) { | 5428 if (!is_patch) { |
| 5432 library_.AddObject(func, accessor_name); | 5429 library_.AddObject(func, accessor_name); |
| 5433 } else { | 5430 } else { |
| 5434 library_.ReplaceObject(func, accessor_name); | 5431 library_.ReplaceObject(func, accessor_name); |
| 5435 } | 5432 } |
| 5436 if (metadata_pos >= 0) { | 5433 if (metadata_pos >= 0) { |
| 5437 library_.AddFunctionMetadata(func, metadata_pos); | 5434 library_.AddFunctionMetadata(func, metadata_pos); |
| (...skipping 6786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12224 void Parser::SkipQualIdent() { | 12221 void Parser::SkipQualIdent() { |
| 12225 ASSERT(IsIdentifier()); | 12222 ASSERT(IsIdentifier()); |
| 12226 ConsumeToken(); | 12223 ConsumeToken(); |
| 12227 if (CurrentToken() == Token::kPERIOD) { | 12224 if (CurrentToken() == Token::kPERIOD) { |
| 12228 ConsumeToken(); // Consume the kPERIOD token. | 12225 ConsumeToken(); // Consume the kPERIOD token. |
| 12229 ExpectIdentifier("identifier expected after '.'"); | 12226 ExpectIdentifier("identifier expected after '.'"); |
| 12230 } | 12227 } |
| 12231 } | 12228 } |
| 12232 | 12229 |
| 12233 } // namespace dart | 12230 } // namespace dart |
| OLD | NEW |