| 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 1769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1780 const Class& cls = Class::Handle(func.Owner()); | 1780 const Class& cls = Class::Handle(func.Owner()); |
| 1781 LocalVariable* receiver = new LocalVariable( | 1781 LocalVariable* receiver = new LocalVariable( |
| 1782 ctor_pos, | 1782 ctor_pos, |
| 1783 String::ZoneHandle(Symbols::This()), | 1783 String::ZoneHandle(Symbols::This()), |
| 1784 Type::ZoneHandle(Type::DynamicType())); | 1784 Type::ZoneHandle(Type::DynamicType())); |
| 1785 current_block_->scope->AddVariable(receiver); | 1785 current_block_->scope->AddVariable(receiver); |
| 1786 | 1786 |
| 1787 LocalVariable* phase_parameter = new LocalVariable( | 1787 LocalVariable* phase_parameter = new LocalVariable( |
| 1788 ctor_pos, | 1788 ctor_pos, |
| 1789 String::ZoneHandle(Symbols::PhaseParameter()), | 1789 String::ZoneHandle(Symbols::PhaseParameter()), |
| 1790 Type::ZoneHandle(Type::IntInterface())); | 1790 Type::ZoneHandle(Type::SmiType())); |
| 1791 current_block_->scope->AddVariable(phase_parameter); | 1791 current_block_->scope->AddVariable(phase_parameter); |
| 1792 | 1792 |
| 1793 // Parse expressions of instance fields that have an explicit | 1793 // Parse expressions of instance fields that have an explicit |
| 1794 // initializer expression. | 1794 // initializer expression. |
| 1795 // The receiver must not be visible to field initializer expressions. | 1795 // The receiver must not be visible to field initializer expressions. |
| 1796 receiver->set_invisible(true); | 1796 receiver->set_invisible(true); |
| 1797 GrowableArray<Field*> initialized_fields; | 1797 GrowableArray<Field*> initialized_fields; |
| 1798 ParseInitializedInstanceFields(cls, receiver, &initialized_fields); | 1798 ParseInitializedInstanceFields(cls, receiver, &initialized_fields); |
| 1799 receiver->set_invisible(false); | 1799 receiver->set_invisible(false); |
| 1800 | 1800 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1848 | 1848 |
| 1849 // Add implicit receiver parameter which is passed the allocated | 1849 // Add implicit receiver parameter which is passed the allocated |
| 1850 // but uninitialized instance to construct. | 1850 // but uninitialized instance to construct. |
| 1851 ASSERT(current_class().raw() == func.Owner()); | 1851 ASSERT(current_class().raw() == func.Owner()); |
| 1852 params.AddReceiver(ReceiverType(TokenPos())); | 1852 params.AddReceiver(ReceiverType(TokenPos())); |
| 1853 | 1853 |
| 1854 // Add implicit parameter for construction phase. | 1854 // Add implicit parameter for construction phase. |
| 1855 params.AddFinalParameter( | 1855 params.AddFinalParameter( |
| 1856 TokenPos(), | 1856 TokenPos(), |
| 1857 &String::ZoneHandle(Symbols::PhaseParameter()), | 1857 &String::ZoneHandle(Symbols::PhaseParameter()), |
| 1858 &Type::ZoneHandle(Type::IntInterface())); | 1858 &Type::ZoneHandle(Type::SmiType())); |
| 1859 | 1859 |
| 1860 if (func.is_const()) { | 1860 if (func.is_const()) { |
| 1861 params.SetImplicitlyFinal(); | 1861 params.SetImplicitlyFinal(); |
| 1862 } | 1862 } |
| 1863 ParseFormalParameterList(allow_explicit_default_values, ¶ms); | 1863 ParseFormalParameterList(allow_explicit_default_values, ¶ms); |
| 1864 | 1864 |
| 1865 SetupDefaultsForOptionalParams(¶ms, default_parameter_values); | 1865 SetupDefaultsForOptionalParams(¶ms, default_parameter_values); |
| 1866 ASSERT(AbstractType::Handle(func.result_type()).IsResolved()); | 1866 ASSERT(AbstractType::Handle(func.result_type()).IsResolved()); |
| 1867 ASSERT(func.NumberOfParameters() == params.parameters->length()); | 1867 ASSERT(func.NumberOfParameters() == params.parameters->length()); |
| 1868 | 1868 |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2325 method->params.AddFinalParameter( | 2325 method->params.AddFinalParameter( |
| 2326 formal_param_pos, | 2326 formal_param_pos, |
| 2327 &String::ZoneHandle(Symbols::TypeArgumentsParameter()), | 2327 &String::ZoneHandle(Symbols::TypeArgumentsParameter()), |
| 2328 &Type::ZoneHandle(Type::DynamicType())); | 2328 &Type::ZoneHandle(Type::DynamicType())); |
| 2329 } | 2329 } |
| 2330 // Constructors have an implicit parameter for the construction phase. | 2330 // Constructors have an implicit parameter for the construction phase. |
| 2331 if (method->IsConstructor()) { | 2331 if (method->IsConstructor()) { |
| 2332 method->params.AddFinalParameter( | 2332 method->params.AddFinalParameter( |
| 2333 TokenPos(), | 2333 TokenPos(), |
| 2334 &String::ZoneHandle(Symbols::PhaseParameter()), | 2334 &String::ZoneHandle(Symbols::PhaseParameter()), |
| 2335 &Type::ZoneHandle(Type::IntInterface())); | 2335 &Type::ZoneHandle(Type::SmiType())); |
| 2336 } | 2336 } |
| 2337 if (are_implicitly_final) { | 2337 if (are_implicitly_final) { |
| 2338 method->params.SetImplicitlyFinal(); | 2338 method->params.SetImplicitlyFinal(); |
| 2339 } | 2339 } |
| 2340 if (!method->IsGetter()) { | 2340 if (!method->IsGetter()) { |
| 2341 ParseFormalParameterList(allow_explicit_default_values, &method->params); | 2341 ParseFormalParameterList(allow_explicit_default_values, &method->params); |
| 2342 } else { | 2342 } else { |
| 2343 // TODO(hausner): Remove this once the old getter syntax with | 2343 // TODO(hausner): Remove this once the old getter syntax with |
| 2344 // empty parameter list is no longer supported. | 2344 // empty parameter list is no longer supported. |
| 2345 if (CurrentToken() == Token::kLPAREN) { | 2345 if (CurrentToken() == Token::kLPAREN) { |
| (...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3070 /* is_external = */ false, | 3070 /* is_external = */ false, |
| 3071 current_class(), | 3071 current_class(), |
| 3072 class_desc->token_pos())); | 3072 class_desc->token_pos())); |
| 3073 ParamList params; | 3073 ParamList params; |
| 3074 // Add implicit 'this' parameter. | 3074 // Add implicit 'this' parameter. |
| 3075 ASSERT(current_class().raw() == ctor.Owner()); | 3075 ASSERT(current_class().raw() == ctor.Owner()); |
| 3076 params.AddReceiver(ReceiverType(TokenPos())); | 3076 params.AddReceiver(ReceiverType(TokenPos())); |
| 3077 // Add implicit parameter for construction phase. | 3077 // Add implicit parameter for construction phase. |
| 3078 params.AddFinalParameter(TokenPos(), | 3078 params.AddFinalParameter(TokenPos(), |
| 3079 &String::ZoneHandle(Symbols::PhaseParameter()), | 3079 &String::ZoneHandle(Symbols::PhaseParameter()), |
| 3080 &Type::ZoneHandle(Type::IntInterface())); | 3080 &Type::ZoneHandle(Type::SmiType())); |
| 3081 | 3081 |
| 3082 AddFormalParamsToFunction(¶ms, ctor); | 3082 AddFormalParamsToFunction(¶ms, ctor); |
| 3083 // The body of the constructor cannot modify the type of the constructed | 3083 // The body of the constructor cannot modify the type of the constructed |
| 3084 // instance, which is passed in as the receiver. | 3084 // instance, which is passed in as the receiver. |
| 3085 ctor.set_result_type(*((*params.parameters)[0].type)); | 3085 ctor.set_result_type(*((*params.parameters)[0].type)); |
| 3086 class_desc->AddFunction(ctor); | 3086 class_desc->AddFunction(ctor); |
| 3087 } | 3087 } |
| 3088 | 3088 |
| 3089 | 3089 |
| 3090 // Check for cycles in constructor redirection. | 3090 // Check for cycles in constructor redirection. |
| (...skipping 6135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9226 void Parser::SkipQualIdent() { | 9226 void Parser::SkipQualIdent() { |
| 9227 ASSERT(IsIdentifier()); | 9227 ASSERT(IsIdentifier()); |
| 9228 ConsumeToken(); | 9228 ConsumeToken(); |
| 9229 if (CurrentToken() == Token::kPERIOD) { | 9229 if (CurrentToken() == Token::kPERIOD) { |
| 9230 ConsumeToken(); // Consume the kPERIOD token. | 9230 ConsumeToken(); // Consume the kPERIOD token. |
| 9231 ExpectIdentifier("identifier expected after '.'"); | 9231 ExpectIdentifier("identifier expected after '.'"); |
| 9232 } | 9232 } |
| 9233 } | 9233 } |
| 9234 | 9234 |
| 9235 } // namespace dart | 9235 } // namespace dart |
| OLD | NEW |