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 3633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3644 method->has_const, | 3644 method->has_const, |
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 (method->has_native && library_.is_dart_scheme() && |
| 3655 library_.IsPrivate(*method->name)) { |
| 3656 func.set_is_visible(false); |
| 3657 } |
| 3658 if (method->IsFactoryOrConstructor() && library_.is_dart_scheme() && |
| 3659 library_.IsPrivate(*method->name)) { |
3655 func.set_is_visible(false); | 3660 func.set_is_visible(false); |
3656 } | 3661 } |
3657 if (method->metadata_pos > 0) { | 3662 if (method->metadata_pos > 0) { |
3658 library_.AddFunctionMetadata(func, method->metadata_pos); | 3663 library_.AddFunctionMetadata(func, method->metadata_pos); |
3659 } | 3664 } |
3660 | 3665 |
3661 // If this method is a redirecting factory, set the redirection information. | 3666 // If this method is a redirecting factory, set the redirection information. |
3662 if (!redirection_type.IsNull()) { | 3667 if (!redirection_type.IsNull()) { |
3663 ASSERT(func.IsFactory()); | 3668 ASSERT(func.IsFactory()); |
3664 func.SetRedirectionType(redirection_type); | 3669 func.SetRedirectionType(redirection_type); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3770 RawFunction::kImplicitStaticFinalGetter, | 3775 RawFunction::kImplicitStaticFinalGetter, |
3771 field->has_static, | 3776 field->has_static, |
3772 field->has_const, | 3777 field->has_const, |
3773 /* is_abstract = */ false, | 3778 /* is_abstract = */ false, |
3774 /* is_external = */ false, | 3779 /* is_external = */ false, |
3775 /* is_native = */ false, | 3780 /* is_native = */ false, |
3776 current_class(), | 3781 current_class(), |
3777 field->name_pos); | 3782 field->name_pos); |
3778 getter.set_result_type(*field->type); | 3783 getter.set_result_type(*field->type); |
3779 getter.set_is_debuggable(false); | 3784 getter.set_is_debuggable(false); |
3780 if (library_.is_dart_scheme() && library_.IsPrivate(*field->name)) { | |
3781 getter.set_is_visible(false); | |
3782 } | |
3783 members->AddFunction(getter); | 3785 members->AddFunction(getter); |
3784 } | 3786 } |
3785 } | 3787 } |
3786 | 3788 |
3787 // For instance fields, we create implicit getter and setter methods. | 3789 // For instance fields, we create implicit getter and setter methods. |
3788 if (!field->has_static) { | 3790 if (!field->has_static) { |
3789 String& getter_name = String::Handle(I, | 3791 String& getter_name = String::Handle(I, |
3790 Field::GetterSymbol(*field->name)); | 3792 Field::GetterSymbol(*field->name)); |
3791 getter = Function::New(getter_name, RawFunction::kImplicitGetter, | 3793 getter = Function::New(getter_name, RawFunction::kImplicitGetter, |
3792 field->has_static, | 3794 field->has_static, |
(...skipping 23 matching lines...) Expand all Loading... |
3816 current_class(), | 3818 current_class(), |
3817 field->name_pos); | 3819 field->name_pos); |
3818 ParamList params; | 3820 ParamList params; |
3819 ASSERT(current_class().raw() == setter.Owner()); | 3821 ASSERT(current_class().raw() == setter.Owner()); |
3820 params.AddReceiver(ReceiverType(current_class()), field->name_pos); | 3822 params.AddReceiver(ReceiverType(current_class()), field->name_pos); |
3821 params.AddFinalParameter(TokenPos(), | 3823 params.AddFinalParameter(TokenPos(), |
3822 &Symbols::Value(), | 3824 &Symbols::Value(), |
3823 field->type); | 3825 field->type); |
3824 setter.set_result_type(Type::Handle(I, Type::VoidType())); | 3826 setter.set_result_type(Type::Handle(I, Type::VoidType())); |
3825 setter.set_is_debuggable(false); | 3827 setter.set_is_debuggable(false); |
3826 if (library_.is_dart_scheme() && library_.IsPrivate(*field->name)) { | |
3827 setter.set_is_visible(false); | |
3828 } | |
3829 AddFormalParamsToFunction(¶ms, setter); | 3828 AddFormalParamsToFunction(¶ms, setter); |
3830 members->AddFunction(setter); | 3829 members->AddFunction(setter); |
3831 } | 3830 } |
3832 } | 3831 } |
3833 | 3832 |
3834 if (CurrentToken() != Token::kCOMMA) { | 3833 if (CurrentToken() != Token::kCOMMA) { |
3835 break; | 3834 break; |
3836 } | 3835 } |
3837 ConsumeToken(); | 3836 ConsumeToken(); |
3838 field->name_pos = this->TokenPos(); | 3837 field->name_pos = this->TokenPos(); |
(...skipping 1306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5145 RawFunction::kImplicitStaticFinalGetter, | 5144 RawFunction::kImplicitStaticFinalGetter, |
5146 is_static, | 5145 is_static, |
5147 is_const, | 5146 is_const, |
5148 /* is_abstract = */ false, | 5147 /* is_abstract = */ false, |
5149 /* is_external = */ false, | 5148 /* is_external = */ false, |
5150 /* is_native = */ false, | 5149 /* is_native = */ false, |
5151 current_class(), | 5150 current_class(), |
5152 name_pos); | 5151 name_pos); |
5153 getter.set_result_type(type); | 5152 getter.set_result_type(type); |
5154 getter.set_is_debuggable(false); | 5153 getter.set_is_debuggable(false); |
5155 if (library_.is_dart_scheme() && library_.IsPrivate(var_name)) { | |
5156 getter.set_is_visible(false); | |
5157 } | |
5158 top_level->functions.Add(getter); | 5154 top_level->functions.Add(getter); |
5159 } | 5155 } |
5160 } else if (is_final) { | 5156 } else if (is_final) { |
5161 ReportError(name_pos, "missing initializer for final or const variable"); | 5157 ReportError(name_pos, "missing initializer for final or const variable"); |
5162 } | 5158 } |
5163 | 5159 |
5164 if (CurrentToken() == Token::kCOMMA) { | 5160 if (CurrentToken() == Token::kCOMMA) { |
5165 ConsumeToken(); | 5161 ConsumeToken(); |
5166 } else if (CurrentToken() == Token::kSEMICOLON) { | 5162 } else if (CurrentToken() == Token::kSEMICOLON) { |
5167 ConsumeToken(); | 5163 ConsumeToken(); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5272 /* is_abstract = */ false, | 5268 /* is_abstract = */ false, |
5273 is_external, | 5269 is_external, |
5274 is_native, | 5270 is_native, |
5275 current_class(), | 5271 current_class(), |
5276 decl_begin_pos)); | 5272 decl_begin_pos)); |
5277 func.set_result_type(result_type); | 5273 func.set_result_type(result_type); |
5278 func.set_end_token_pos(function_end_pos); | 5274 func.set_end_token_pos(function_end_pos); |
5279 func.set_modifier(func_modifier); | 5275 func.set_modifier(func_modifier); |
5280 if (is_native) { | 5276 if (is_native) { |
5281 func.set_is_debuggable(false); | 5277 func.set_is_debuggable(false); |
5282 } | 5278 if (library_.is_dart_scheme() && library_.IsPrivate(func_name)) { |
5283 if (library_.is_dart_scheme() && library_.IsPrivate(func_name)) { | 5279 func.set_is_visible(false); |
5284 func.set_is_visible(false); | 5280 } |
5285 } | 5281 } |
5286 AddFormalParamsToFunction(¶ms, func); | 5282 AddFormalParamsToFunction(¶ms, func); |
5287 top_level->functions.Add(func); | 5283 top_level->functions.Add(func); |
5288 if (!is_patch) { | 5284 if (!is_patch) { |
5289 library_.AddObject(func, func_name); | 5285 library_.AddObject(func, func_name); |
5290 } else { | 5286 } else { |
5291 library_.ReplaceObject(func, func_name); | 5287 library_.ReplaceObject(func, func_name); |
5292 } | 5288 } |
5293 if (metadata_pos >= 0) { | 5289 if (metadata_pos >= 0) { |
5294 library_.AddFunctionMetadata(func, metadata_pos); | 5290 library_.AddFunctionMetadata(func, metadata_pos); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5415 /* is_abstract = */ false, | 5411 /* is_abstract = */ false, |
5416 is_external, | 5412 is_external, |
5417 is_native, | 5413 is_native, |
5418 current_class(), | 5414 current_class(), |
5419 decl_begin_pos)); | 5415 decl_begin_pos)); |
5420 func.set_result_type(result_type); | 5416 func.set_result_type(result_type); |
5421 func.set_end_token_pos(accessor_end_pos); | 5417 func.set_end_token_pos(accessor_end_pos); |
5422 func.set_modifier(func_modifier); | 5418 func.set_modifier(func_modifier); |
5423 if (is_native) { | 5419 if (is_native) { |
5424 func.set_is_debuggable(false); | 5420 func.set_is_debuggable(false); |
5425 } | 5421 if (library_.is_dart_scheme() && library_.IsPrivate(accessor_name)) { |
5426 if (library_.is_dart_scheme() && library_.IsPrivate(accessor_name)) { | 5422 func.set_is_visible(false); |
5427 func.set_is_visible(false); | 5423 } |
5428 } | 5424 } |
5429 AddFormalParamsToFunction(¶ms, func); | 5425 AddFormalParamsToFunction(¶ms, func); |
5430 top_level->functions.Add(func); | 5426 top_level->functions.Add(func); |
5431 if (!is_patch) { | 5427 if (!is_patch) { |
5432 library_.AddObject(func, accessor_name); | 5428 library_.AddObject(func, accessor_name); |
5433 } else { | 5429 } else { |
5434 library_.ReplaceObject(func, accessor_name); | 5430 library_.ReplaceObject(func, accessor_name); |
5435 } | 5431 } |
5436 if (metadata_pos >= 0) { | 5432 if (metadata_pos >= 0) { |
5437 library_.AddFunctionMetadata(func, metadata_pos); | 5433 library_.AddFunctionMetadata(func, metadata_pos); |
(...skipping 6786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12224 void Parser::SkipQualIdent() { | 12220 void Parser::SkipQualIdent() { |
12225 ASSERT(IsIdentifier()); | 12221 ASSERT(IsIdentifier()); |
12226 ConsumeToken(); | 12222 ConsumeToken(); |
12227 if (CurrentToken() == Token::kPERIOD) { | 12223 if (CurrentToken() == Token::kPERIOD) { |
12228 ConsumeToken(); // Consume the kPERIOD token. | 12224 ConsumeToken(); // Consume the kPERIOD token. |
12229 ExpectIdentifier("identifier expected after '.'"); | 12225 ExpectIdentifier("identifier expected after '.'"); |
12230 } | 12226 } |
12231 } | 12227 } |
12232 | 12228 |
12233 } // namespace dart | 12229 } // namespace dart |
OLD | NEW |