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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 250 intptr_t token_position) | 250 intptr_t token_position) |
| 251 : script_(script), | 251 : script_(script), |
| 252 tokens_iterator_(TokenStream::Handle(script.tokens()), token_position), | 252 tokens_iterator_(TokenStream::Handle(script.tokens()), token_position), |
| 253 token_kind_(Token::kILLEGAL), | 253 token_kind_(Token::kILLEGAL), |
| 254 current_block_(NULL), | 254 current_block_(NULL), |
| 255 is_top_level_(false), | 255 is_top_level_(false), |
| 256 current_member_(NULL), | 256 current_member_(NULL), |
| 257 allow_function_literals_(true), | 257 allow_function_literals_(true), |
| 258 current_function_(function), | 258 current_function_(function), |
| 259 innermost_function_(Function::Handle(function.raw())), | 259 innermost_function_(Function::Handle(function.raw())), |
| 260 current_class_(Class::Handle(current_function_.owner())), | 260 current_class_(Class::Handle(current_function_.Owner())), |
| 261 library_(Library::Handle(current_class_.library())), | 261 library_(Library::Handle(current_class_.library())), |
| 262 try_blocks_list_(NULL), | 262 try_blocks_list_(NULL), |
| 263 expression_temp_(NULL) { | 263 expression_temp_(NULL) { |
| 264 ASSERT(tokens_iterator_.IsValid()); | 264 ASSERT(tokens_iterator_.IsValid()); |
| 265 ASSERT(!function.IsNull()); | 265 ASSERT(!function.IsNull()); |
| 266 if (FLAG_enable_type_checks) { | 266 if (FLAG_enable_type_checks) { |
| 267 EnsureExpressionTemp(); | 267 EnsureExpressionTemp(); |
| 268 } | 268 } |
| 269 } | 269 } |
| 270 | 270 |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 649 } | 649 } |
| 650 } | 650 } |
| 651 | 651 |
| 652 | 652 |
| 653 void Parser::ParseFunction(ParsedFunction* parsed_function) { | 653 void Parser::ParseFunction(ParsedFunction* parsed_function) { |
| 654 TimerScope timer(FLAG_compiler_stats, &CompilerStats::parser_timer); | 654 TimerScope timer(FLAG_compiler_stats, &CompilerStats::parser_timer); |
| 655 Isolate* isolate = Isolate::Current(); | 655 Isolate* isolate = Isolate::Current(); |
| 656 ASSERT(isolate->long_jump_base()->IsSafeToJump()); | 656 ASSERT(isolate->long_jump_base()->IsSafeToJump()); |
| 657 ASSERT(parsed_function != NULL); | 657 ASSERT(parsed_function != NULL); |
| 658 const Function& func = parsed_function->function(); | 658 const Function& func = parsed_function->function(); |
| 659 const Class& cls = Class::Handle(isolate, func.owner()); | 659 const Script& script = Script::Handle(isolate, func.script()); |
| 660 const Script& script = Script::Handle(isolate, cls.script()); | |
| 661 Parser parser(script, func, func.token_pos()); | 660 Parser parser(script, func, func.token_pos()); |
| 662 SequenceNode* node_sequence = NULL; | 661 SequenceNode* node_sequence = NULL; |
| 663 Array& default_parameter_values = Array::Handle(isolate, Array::null()); | 662 Array& default_parameter_values = Array::Handle(isolate, Array::null()); |
| 664 switch (func.kind()) { | 663 switch (func.kind()) { |
| 665 case RawFunction::kRegularFunction: | 664 case RawFunction::kRegularFunction: |
| 666 case RawFunction::kClosureFunction: | 665 case RawFunction::kClosureFunction: |
| 667 case RawFunction::kGetterFunction: | 666 case RawFunction::kGetterFunction: |
| 668 case RawFunction::kSetterFunction: | 667 case RawFunction::kSetterFunction: |
| 669 case RawFunction::kConstructor: | 668 case RawFunction::kConstructor: |
| 670 node_sequence = parser.ParseFunc(func, default_parameter_values); | 669 node_sequence = parser.ParseFunc(func, default_parameter_values); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 730 ParamList params; | 729 ParamList params; |
| 731 ASSERT(func.num_fixed_parameters() == 0); // static. | 730 ASSERT(func.num_fixed_parameters() == 0); // static. |
| 732 ASSERT(func.num_optional_parameters() == 0); | 731 ASSERT(func.num_optional_parameters() == 0); |
| 733 ASSERT(AbstractType::Handle(func.result_type()).IsResolved()); | 732 ASSERT(AbstractType::Handle(func.result_type()).IsResolved()); |
| 734 | 733 |
| 735 // Build local scope for function and populate with the formal parameters. | 734 // Build local scope for function and populate with the formal parameters. |
| 736 OpenFunctionBlock(func); | 735 OpenFunctionBlock(func); |
| 737 AddFormalParamsToScope(¶ms, current_block_->scope); | 736 AddFormalParamsToScope(¶ms, current_block_->scope); |
| 738 | 737 |
| 739 const String& field_name = *ExpectIdentifier("field name expected"); | 738 const String& field_name = *ExpectIdentifier("field name expected"); |
| 740 const Class& field_class = Class::Handle(func.owner()); | 739 const Class& field_class = Class::Handle(func.Owner()); |
| 741 const Field& field = | 740 const Field& field = |
| 742 Field::ZoneHandle(field_class.LookupStaticField(field_name)); | 741 Field::ZoneHandle(field_class.LookupStaticField(field_name)); |
| 743 | 742 |
| 744 // Static const fields must have an initializer. | 743 // Static const fields must have an initializer. |
| 745 ExpectToken(Token::kASSIGN); | 744 ExpectToken(Token::kASSIGN); |
| 746 | 745 |
| 747 // We don't want to use ParseConstExpr() here because we don't want | 746 // We don't want to use ParseConstExpr() here because we don't want |
| 748 // the constant folding code to create, compile and execute a code | 747 // the constant folding code to create, compile and execute a code |
| 749 // fragment to evaluate the expression. Instead, we just make sure | 748 // fragment to evaluate the expression. Instead, we just make sure |
| 750 // the static const field initializer is a constant expression and | 749 // the static const field initializer is a constant expression and |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 835 } | 834 } |
| 836 | 835 |
| 837 | 836 |
| 838 // Create AstNodes for an implicit instance getter method: | 837 // Create AstNodes for an implicit instance getter method: |
| 839 // LoadLocalNode 0 ('this'); | 838 // LoadLocalNode 0 ('this'); |
| 840 // LoadInstanceFieldNode (field_name); | 839 // LoadInstanceFieldNode (field_name); |
| 841 // ReturnNode (field's value); | 840 // ReturnNode (field's value); |
| 842 SequenceNode* Parser::ParseInstanceGetter(const Function& func) { | 841 SequenceNode* Parser::ParseInstanceGetter(const Function& func) { |
| 843 TRACE_PARSER("ParseInstanceGetter"); | 842 TRACE_PARSER("ParseInstanceGetter"); |
| 844 ParamList params; | 843 ParamList params; |
| 845 ASSERT(current_class().raw() == func.owner()); | 844 ASSERT(current_class().raw() == func.Owner()); |
| 846 params.AddReceiver(ReceiverType(TokenPos())); | 845 params.AddReceiver(ReceiverType(TokenPos())); |
| 847 ASSERT(func.num_fixed_parameters() == 1); // receiver. | 846 ASSERT(func.num_fixed_parameters() == 1); // receiver. |
| 848 ASSERT(func.num_optional_parameters() == 0); | 847 ASSERT(func.num_optional_parameters() == 0); |
| 849 ASSERT(AbstractType::Handle(func.result_type()).IsResolved()); | 848 ASSERT(AbstractType::Handle(func.result_type()).IsResolved()); |
| 850 | 849 |
| 851 // Build local scope for function and populate with the formal parameters. | 850 // Build local scope for function and populate with the formal parameters. |
| 852 OpenFunctionBlock(func); | 851 OpenFunctionBlock(func); |
| 853 AddFormalParamsToScope(¶ms, current_block_->scope); | 852 AddFormalParamsToScope(¶ms, current_block_->scope); |
| 854 | 853 |
| 855 // Receiver is local 0. | 854 // Receiver is local 0. |
| 856 LocalVariable* receiver = current_block_->scope->VariableAt(0); | 855 LocalVariable* receiver = current_block_->scope->VariableAt(0); |
| 857 LoadLocalNode* load_receiver = new LoadLocalNode(TokenPos(), receiver); | 856 LoadLocalNode* load_receiver = new LoadLocalNode(TokenPos(), receiver); |
| 858 // TokenPos() returns the function's token position which points to the | 857 // TokenPos() returns the function's token position which points to the |
| 859 // name of the field; | 858 // name of the field; |
| 860 ASSERT(IsIdentifier()); | 859 ASSERT(IsIdentifier()); |
| 861 const String& field_name = *CurrentLiteral(); | 860 const String& field_name = *CurrentLiteral(); |
| 862 const Class& field_class = Class::Handle(func.owner()); | 861 const Class& field_class = Class::Handle(func.Owner()); |
| 863 const Field& field = | 862 const Field& field = |
| 864 Field::ZoneHandle(field_class.LookupInstanceField(field_name)); | 863 Field::ZoneHandle(field_class.LookupInstanceField(field_name)); |
| 865 | 864 |
| 866 LoadInstanceFieldNode* load_field = | 865 LoadInstanceFieldNode* load_field = |
| 867 new LoadInstanceFieldNode(TokenPos(), load_receiver, field); | 866 new LoadInstanceFieldNode(TokenPos(), load_receiver, field); |
| 868 | 867 |
| 869 ReturnNode* return_node = new ReturnNode(TokenPos(), load_field); | 868 ReturnNode* return_node = new ReturnNode(TokenPos(), load_field); |
| 870 current_block_->statements->Add(return_node); | 869 current_block_->statements->Add(return_node); |
| 871 return CloseBlock(); | 870 return CloseBlock(); |
| 872 } | 871 } |
| 873 | 872 |
| 874 | 873 |
| 875 // Create AstNodes for an implicit instance setter method: | 874 // Create AstNodes for an implicit instance setter method: |
| 876 // LoadLocalNode 0 ('this') | 875 // LoadLocalNode 0 ('this') |
| 877 // LoadLocalNode 1 ('value') | 876 // LoadLocalNode 1 ('value') |
| 878 // SetInstanceField (field_name); | 877 // SetInstanceField (field_name); |
| 879 // ReturnNode (void); | 878 // ReturnNode (void); |
| 880 SequenceNode* Parser::ParseInstanceSetter(const Function& func) { | 879 SequenceNode* Parser::ParseInstanceSetter(const Function& func) { |
| 881 TRACE_PARSER("ParseInstanceSetter"); | 880 TRACE_PARSER("ParseInstanceSetter"); |
| 882 // TokenPos() returns the function's token position which points to | 881 // TokenPos() returns the function's token position which points to |
| 883 // the name of the field; we can use it to form the field_name. | 882 // the name of the field; we can use it to form the field_name. |
| 884 const String& field_name = *CurrentLiteral(); | 883 const String& field_name = *CurrentLiteral(); |
| 885 const Class& field_class = Class::ZoneHandle(func.owner()); | 884 const Class& field_class = Class::ZoneHandle(func.Owner()); |
| 886 const Field& field = | 885 const Field& field = |
| 887 Field::ZoneHandle(field_class.LookupInstanceField(field_name)); | 886 Field::ZoneHandle(field_class.LookupInstanceField(field_name)); |
| 888 const AbstractType& field_type = AbstractType::ZoneHandle(field.type()); | 887 const AbstractType& field_type = AbstractType::ZoneHandle(field.type()); |
| 889 | 888 |
| 890 ParamList params; | 889 ParamList params; |
| 891 ASSERT(current_class().raw() == func.owner()); | 890 ASSERT(current_class().raw() == func.Owner()); |
| 892 params.AddReceiver(ReceiverType(TokenPos())); | 891 params.AddReceiver(ReceiverType(TokenPos())); |
| 893 params.AddFinalParameter(TokenPos(), | 892 params.AddFinalParameter(TokenPos(), |
| 894 &String::ZoneHandle(Symbols::Value()), | 893 &String::ZoneHandle(Symbols::Value()), |
| 895 &field_type); | 894 &field_type); |
| 896 ASSERT(func.num_fixed_parameters() == 2); // receiver, value. | 895 ASSERT(func.num_fixed_parameters() == 2); // receiver, value. |
| 897 ASSERT(func.num_optional_parameters() == 0); | 896 ASSERT(func.num_optional_parameters() == 0); |
| 898 ASSERT(AbstractType::Handle(func.result_type()).IsVoidType()); | 897 ASSERT(AbstractType::Handle(func.result_type()).IsVoidType()); |
| 899 | 898 |
| 900 // Build local scope for function and populate with the formal parameters. | 899 // Build local scope for function and populate with the formal parameters. |
| 901 OpenFunctionBlock(func); | 900 OpenFunctionBlock(func); |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1181 } | 1180 } |
| 1182 String& native_name = *CurrentLiteral(); | 1181 String& native_name = *CurrentLiteral(); |
| 1183 ConsumeToken(); | 1182 ConsumeToken(); |
| 1184 ExpectSemicolon(); | 1183 ExpectSemicolon(); |
| 1185 return native_name; | 1184 return native_name; |
| 1186 } | 1185 } |
| 1187 | 1186 |
| 1188 | 1187 |
| 1189 void Parser::CheckFunctionIsCallable(intptr_t token_pos, | 1188 void Parser::CheckFunctionIsCallable(intptr_t token_pos, |
| 1190 const Function& function) { | 1189 const Function& function) { |
| 1191 if (Class::Handle(function.owner()).is_interface()) { | 1190 if (Class::Handle(function.Owner()).is_interface()) { |
| 1192 ErrorMsg(token_pos, "cannot call function of interface '%s'", | 1191 ErrorMsg(token_pos, "cannot call function of interface '%s'", |
| 1193 function.ToFullyQualifiedCString()); | 1192 function.ToFullyQualifiedCString()); |
| 1194 } | 1193 } |
| 1195 } | 1194 } |
| 1196 | 1195 |
| 1197 | 1196 |
| 1198 // Resolve and return the dynamic function of the given name in the superclass. | 1197 // Resolve and return the dynamic function of the given name in the superclass. |
| 1199 // If it is not found, return noSuchMethod and set is_no_such_method to true. | 1198 // If it is not found, return noSuchMethod and set is_no_such_method to true. |
| 1200 RawFunction* Parser::GetSuperFunction(intptr_t token_pos, | 1199 RawFunction* Parser::GetSuperFunction(intptr_t token_pos, |
| 1201 const String& name, | 1200 const String& name, |
| (...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1772 ASSERT(func.IsConstructor()); | 1771 ASSERT(func.IsConstructor()); |
| 1773 const intptr_t ctor_pos = TokenPos(); | 1772 const intptr_t ctor_pos = TokenPos(); |
| 1774 | 1773 |
| 1775 // Implicit 'this' is the only parameter/local variable. | 1774 // Implicit 'this' is the only parameter/local variable. |
| 1776 OpenFunctionBlock(func); | 1775 OpenFunctionBlock(func); |
| 1777 | 1776 |
| 1778 // Parse expressions of instance fields that have an explicit | 1777 // Parse expressions of instance fields that have an explicit |
| 1779 // initializers. | 1778 // initializers. |
| 1780 GrowableArray<FieldInitExpression> initializers; | 1779 GrowableArray<FieldInitExpression> initializers; |
| 1781 GrowableArray<Field*> initialized_fields; | 1780 GrowableArray<Field*> initialized_fields; |
| 1782 Class& cls = Class::Handle(func.owner()); | 1781 Class& cls = Class::Handle(func.Owner()); |
| 1783 ParseInitializedInstanceFields(cls, &initializers, &initialized_fields); | 1782 ParseInitializedInstanceFields(cls, &initializers, &initialized_fields); |
| 1784 | 1783 |
| 1785 LocalVariable* receiver = new LocalVariable( | 1784 LocalVariable* receiver = new LocalVariable( |
| 1786 ctor_pos, | 1785 ctor_pos, |
| 1787 String::ZoneHandle(Symbols::This()), | 1786 String::ZoneHandle(Symbols::This()), |
| 1788 Type::ZoneHandle(Type::DynamicType())); | 1787 Type::ZoneHandle(Type::DynamicType())); |
| 1789 current_block_->scope->AddVariable(receiver); | 1788 current_block_->scope->AddVariable(receiver); |
| 1790 | 1789 |
| 1791 LocalVariable* phase_parameter = new LocalVariable( | 1790 LocalVariable* phase_parameter = new LocalVariable( |
| 1792 ctor_pos, | 1791 ctor_pos, |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 1818 | 1817 |
| 1819 // Parser is at the opening parenthesis of the formal parameter declaration | 1818 // Parser is at the opening parenthesis of the formal parameter declaration |
| 1820 // of function. Parse the formal parameters, initializers and code. | 1819 // of function. Parse the formal parameters, initializers and code. |
| 1821 SequenceNode* Parser::ParseConstructor(const Function& func, | 1820 SequenceNode* Parser::ParseConstructor(const Function& func, |
| 1822 Array& default_parameter_values) { | 1821 Array& default_parameter_values) { |
| 1823 TRACE_PARSER("ParseConstructor"); | 1822 TRACE_PARSER("ParseConstructor"); |
| 1824 ASSERT(func.IsConstructor()); | 1823 ASSERT(func.IsConstructor()); |
| 1825 ASSERT(!func.IsFactory()); | 1824 ASSERT(!func.IsFactory()); |
| 1826 ASSERT(!func.is_static()); | 1825 ASSERT(!func.is_static()); |
| 1827 ASSERT(!func.IsLocalFunction()); | 1826 ASSERT(!func.IsLocalFunction()); |
| 1828 const Class& cls = Class::Handle(func.owner()); | 1827 const Class& cls = Class::Handle(func.Owner()); |
| 1829 ASSERT(!cls.IsNull()); | 1828 ASSERT(!cls.IsNull()); |
| 1830 | 1829 |
| 1831 if (CurrentToken() == Token::kCLASS) { | 1830 if (CurrentToken() == Token::kCLASS) { |
| 1832 // Special case: implicit constructor. | 1831 // Special case: implicit constructor. |
| 1833 // The parser adds an implicit default constructor when a class | 1832 // The parser adds an implicit default constructor when a class |
| 1834 // does not have any explicit constructor or factory (see | 1833 // does not have any explicit constructor or factory (see |
| 1835 // Parser::CheckConstructors). The token position of this implicit | 1834 // Parser::CheckConstructors). The token position of this implicit |
| 1836 // constructor points to the 'class' keyword, which is followed | 1835 // constructor points to the 'class' keyword, which is followed |
| 1837 // by the name of the class (which is also the constructor name). | 1836 // by the name of the class (which is also the constructor name). |
| 1838 // There is no source text to parse. We just build the | 1837 // There is no source text to parse. We just build the |
| 1839 // sequence node by hand. | 1838 // sequence node by hand. |
| 1840 return MakeImplicitConstructor(func); | 1839 return MakeImplicitConstructor(func); |
| 1841 } | 1840 } |
| 1842 | 1841 |
| 1843 OpenFunctionBlock(func); | 1842 OpenFunctionBlock(func); |
| 1844 ParamList params; | 1843 ParamList params; |
| 1845 const bool allow_explicit_default_values = true; | 1844 const bool allow_explicit_default_values = true; |
| 1846 ASSERT(CurrentToken() == Token::kLPAREN); | 1845 ASSERT(CurrentToken() == Token::kLPAREN); |
| 1847 | 1846 |
| 1848 // Add implicit receiver parameter which is passed the allocated | 1847 // Add implicit receiver parameter which is passed the allocated |
| 1849 // but uninitialized instance to construct. | 1848 // but uninitialized instance to construct. |
| 1850 ASSERT(current_class().raw() == func.owner()); | 1849 ASSERT(current_class().raw() == func.Owner()); |
| 1851 params.AddReceiver(ReceiverType(TokenPos())); | 1850 params.AddReceiver(ReceiverType(TokenPos())); |
| 1852 | 1851 |
| 1853 // Add implicit parameter for construction phase. | 1852 // Add implicit parameter for construction phase. |
| 1854 params.AddFinalParameter( | 1853 params.AddFinalParameter( |
| 1855 TokenPos(), | 1854 TokenPos(), |
| 1856 &String::ZoneHandle(Symbols::PhaseParameter()), | 1855 &String::ZoneHandle(Symbols::PhaseParameter()), |
| 1857 &Type::ZoneHandle(Type::IntInterface())); | 1856 &Type::ZoneHandle(Type::IntInterface())); |
| 1858 | 1857 |
| 1859 if (func.is_const()) { | 1858 if (func.is_const()) { |
| 1860 params.SetImplicitlyFinal(); | 1859 params.SetImplicitlyFinal(); |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2089 ASSERT(!func.IsConstructor()); | 2088 ASSERT(!func.IsConstructor()); |
| 2090 OpenFunctionBlock(func); // Build local scope for function. | 2089 OpenFunctionBlock(func); // Build local scope for function. |
| 2091 | 2090 |
| 2092 ParamList params; | 2091 ParamList params; |
| 2093 // Static functions do not have a receiver. | 2092 // Static functions do not have a receiver. |
| 2094 // An instance closure may capture and access the receiver, but via the | 2093 // An instance closure may capture and access the receiver, but via the |
| 2095 // context and not via the first formal parameter. | 2094 // context and not via the first formal parameter. |
| 2096 // The first parameter of a factory is the AbstractTypeArguments vector of | 2095 // The first parameter of a factory is the AbstractTypeArguments vector of |
| 2097 // the type of the instance to be allocated. | 2096 // the type of the instance to be allocated. |
| 2098 if (!func.is_static() && !func.IsClosureFunction()) { | 2097 if (!func.is_static() && !func.IsClosureFunction()) { |
| 2099 ASSERT(current_class().raw() == func.owner()); | 2098 ASSERT(current_class().raw() == func.Owner()); |
| 2100 params.AddReceiver(ReceiverType(TokenPos())); | 2099 params.AddReceiver(ReceiverType(TokenPos())); |
| 2101 } else if (func.IsFactory()) { | 2100 } else if (func.IsFactory()) { |
| 2102 params.AddFinalParameter( | 2101 params.AddFinalParameter( |
| 2103 TokenPos(), | 2102 TokenPos(), |
| 2104 &String::ZoneHandle(Symbols::TypeArgumentsParameter()), | 2103 &String::ZoneHandle(Symbols::TypeArgumentsParameter()), |
| 2105 &Type::ZoneHandle(Type::DynamicType())); | 2104 &Type::ZoneHandle(Type::DynamicType())); |
| 2106 } | 2105 } |
| 2107 ASSERT((CurrentToken() == Token::kLPAREN) || func.IsGetterFunction()); | 2106 ASSERT((CurrentToken() == Token::kLPAREN) || func.IsGetterFunction()); |
| 2108 const bool allow_explicit_default_values = true; | 2107 const bool allow_explicit_default_values = true; |
| 2109 if (!func.IsGetterFunction()) { | 2108 if (!func.IsGetterFunction()) { |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2619 if (!field->has_static) { | 2618 if (!field->has_static) { |
| 2620 String& getter_name = String::Handle(Field::GetterSymbol(*field->name)); | 2619 String& getter_name = String::Handle(Field::GetterSymbol(*field->name)); |
| 2621 getter = Function::New(getter_name, RawFunction::kImplicitGetter, | 2620 getter = Function::New(getter_name, RawFunction::kImplicitGetter, |
| 2622 field->has_static, | 2621 field->has_static, |
| 2623 field->has_final, | 2622 field->has_final, |
| 2624 /* is_abstract = */ false, | 2623 /* is_abstract = */ false, |
| 2625 /* is_external = */ false, | 2624 /* is_external = */ false, |
| 2626 current_class(), | 2625 current_class(), |
| 2627 field->name_pos); | 2626 field->name_pos); |
| 2628 ParamList params; | 2627 ParamList params; |
| 2629 ASSERT(current_class().raw() == getter.owner()); | 2628 ASSERT(current_class().raw() == getter.Owner()); |
| 2630 params.AddReceiver(ReceiverType(TokenPos())); | 2629 params.AddReceiver(ReceiverType(TokenPos())); |
| 2631 getter.set_result_type(*field->type); | 2630 getter.set_result_type(*field->type); |
| 2632 AddFormalParamsToFunction(¶ms, getter); | 2631 AddFormalParamsToFunction(¶ms, getter); |
| 2633 members->AddFunction(getter); | 2632 members->AddFunction(getter); |
| 2634 if (!field->has_final) { | 2633 if (!field->has_final) { |
| 2635 // Build a setter accessor for non-const fields. | 2634 // Build a setter accessor for non-const fields. |
| 2636 String& setter_name = String::Handle(Field::SetterSymbol(*field->name)); | 2635 String& setter_name = String::Handle(Field::SetterSymbol(*field->name)); |
| 2637 setter = Function::New(setter_name, RawFunction::kImplicitSetter, | 2636 setter = Function::New(setter_name, RawFunction::kImplicitSetter, |
| 2638 field->has_static, | 2637 field->has_static, |
| 2639 field->has_final, | 2638 field->has_final, |
| 2640 /* is_abstract = */ false, | 2639 /* is_abstract = */ false, |
| 2641 /* is_external = */ false, | 2640 /* is_external = */ false, |
| 2642 current_class(), | 2641 current_class(), |
| 2643 field->name_pos); | 2642 field->name_pos); |
| 2644 ParamList params; | 2643 ParamList params; |
| 2645 ASSERT(current_class().raw() == setter.owner()); | 2644 ASSERT(current_class().raw() == setter.Owner()); |
| 2646 params.AddReceiver(ReceiverType(TokenPos())); | 2645 params.AddReceiver(ReceiverType(TokenPos())); |
| 2647 params.AddFinalParameter(TokenPos(), | 2646 params.AddFinalParameter(TokenPos(), |
| 2648 &String::ZoneHandle(Symbols::Value()), | 2647 &String::ZoneHandle(Symbols::Value()), |
| 2649 field->type); | 2648 field->type); |
| 2650 setter.set_result_type(Type::Handle(Type::VoidType())); | 2649 setter.set_result_type(Type::Handle(Type::VoidType())); |
| 2651 AddFormalParamsToFunction(¶ms, setter); | 2650 AddFormalParamsToFunction(¶ms, setter); |
| 2652 members->AddFunction(setter); | 2651 members->AddFunction(setter); |
| 2653 } | 2652 } |
| 2654 } | 2653 } |
| 2655 | 2654 |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2918 UnexpectedToken(); | 2917 UnexpectedToken(); |
| 2919 } | 2918 } |
| 2920 current_member_ = NULL; | 2919 current_member_ = NULL; |
| 2921 members->AddMember(member); | 2920 members->AddMember(member); |
| 2922 } | 2921 } |
| 2923 | 2922 |
| 2924 | 2923 |
| 2925 void Parser::ParseClassDefinition(const GrowableObjectArray& pending_classes) { | 2924 void Parser::ParseClassDefinition(const GrowableObjectArray& pending_classes) { |
| 2926 TRACE_PARSER("ParseClassDefinition"); | 2925 TRACE_PARSER("ParseClassDefinition"); |
| 2927 const intptr_t class_pos = TokenPos(); | 2926 const intptr_t class_pos = TokenPos(); |
| 2927 bool is_patch = false; | |
| 2928 if (is_patch_source() && | |
| 2929 (CurrentToken() == Token::kIDENT) && | |
| 2930 CurrentLiteral()->Equals("patch")) { | |
| 2931 ConsumeToken(); | |
| 2932 is_patch = true; | |
| 2933 } | |
| 2928 ExpectToken(Token::kCLASS); | 2934 ExpectToken(Token::kCLASS); |
| 2929 const intptr_t classname_pos = TokenPos(); | 2935 const intptr_t classname_pos = TokenPos(); |
| 2930 String& class_name = *ExpectTypeIdentifier("class name expected"); | 2936 String& class_name = *ExpectTypeIdentifier("class name expected"); |
| 2931 if (FLAG_trace_parser) { | 2937 if (FLAG_trace_parser) { |
| 2932 OS::Print("TopLevel parsing class '%s'\n", class_name.ToCString()); | 2938 OS::Print("TopLevel parsing class '%s'\n", class_name.ToCString()); |
| 2933 } | 2939 } |
| 2934 Class& cls = Class::Handle(); | 2940 Class& cls = Class::Handle(); |
| 2935 Object& obj = Object::Handle(library_.LookupObject(class_name)); | 2941 Object& obj = Object::Handle(library_.LookupObject(class_name)); |
| 2936 if (obj.IsNull()) { | 2942 if (obj.IsNull()) { |
| 2943 if (is_patch) { | |
| 2944 ErrorMsg(classname_pos, "missing class '%s' cannot be patched", | |
| 2945 class_name.ToCString()); | |
| 2946 } | |
| 2937 cls = Class::New(class_name, script_, classname_pos); | 2947 cls = Class::New(class_name, script_, classname_pos); |
| 2938 library_.AddClass(cls); | 2948 library_.AddClass(cls); |
| 2939 } else { | 2949 } else { |
| 2940 if (!obj.IsClass()) { | 2950 if (!obj.IsClass()) { |
| 2941 ErrorMsg(classname_pos, "'%s' is already defined", | 2951 ErrorMsg(classname_pos, "'%s' is already defined", |
| 2942 class_name.ToCString()); | 2952 class_name.ToCString()); |
| 2943 } | 2953 } |
| 2944 cls ^= obj.raw(); | 2954 cls ^= obj.raw(); |
| 2945 if (cls.is_interface()) { | 2955 if (cls.is_interface()) { |
| 2946 ErrorMsg(classname_pos, "'%s' is already defined as interface", | 2956 ErrorMsg(classname_pos, "'%s' %s", |
| 2947 class_name.ToCString()); | 2957 class_name.ToCString(), |
| 2948 } else if (cls.functions() != Object::empty_array()) { | 2958 is_patch ? |
| 2959 "is already defined as interface" : | |
| 2960 "interface cannot be patched"); | |
| 2961 } else if (!is_patch && (cls.functions() != Object::empty_array())) { | |
| 2949 ErrorMsg(classname_pos, "class '%s' is already defined", | 2962 ErrorMsg(classname_pos, "class '%s' is already defined", |
| 2950 class_name.ToCString()); | 2963 class_name.ToCString()); |
|
siva
2012/08/15 00:16:04
I suppose it is an error to have multiple patch cl
Ivan Posva
2012/08/15 06:50:39
Currently this error cannot be identified as I am
| |
| 2964 } else if (is_patch) { | |
| 2965 String& patch = String::Handle(Symbols::New("patch ")); | |
| 2966 patch = String::Concat(patch, class_name); | |
| 2967 patch = Symbols::New(patch); | |
| 2968 cls = Class::New(patch, script_, classname_pos); | |
| 2969 } else { | |
| 2970 // Not patching a class, but it has been found. This must be one of the | |
| 2971 // pre-registered classes from object.cc or a duplicate definition. | |
| 2972 if (cls.functions() != Object::empty_array()) { | |
| 2973 ErrorMsg(classname_pos, "class '%s' is already defined", | |
| 2974 class_name.ToCString()); | |
| 2975 } | |
|
siva
2012/08/15 00:16:04
There seems to be a duplication of this is already
Ivan Posva
2012/08/15 06:50:40
Merge-conflict resolution error. Thanks for notici
| |
| 2976 // Pre-registered classes need their scripts connected at this time. | |
| 2977 cls.set_script(script_); | |
| 2951 } | 2978 } |
| 2952 // Pre-registered classes need their scripts connected at this time. | |
| 2953 cls.set_script(script_); | |
| 2954 } | 2979 } |
| 2955 ASSERT(!cls.IsNull()); | 2980 ASSERT(!cls.IsNull()); |
| 2956 ASSERT(cls.functions() == Object::empty_array()); | 2981 ASSERT(cls.functions() == Object::empty_array()); |
| 2957 set_current_class(cls); | 2982 set_current_class(cls); |
| 2958 ParseTypeParameters(cls); | 2983 ParseTypeParameters(cls); |
| 2959 Type& super_type = Type::Handle(); | 2984 Type& super_type = Type::Handle(); |
| 2960 if (CurrentToken() == Token::kEXTENDS) { | 2985 if (CurrentToken() == Token::kEXTENDS) { |
| 2961 ConsumeToken(); | 2986 ConsumeToken(); |
| 2962 const intptr_t type_pos = TokenPos(); | 2987 const intptr_t type_pos = TokenPos(); |
| 2963 const AbstractType& type = AbstractType::Handle( | 2988 const AbstractType& type = AbstractType::Handle( |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 2989 AddInterfaces(interfaces_pos, cls, interfaces); | 3014 AddInterfaces(interfaces_pos, cls, interfaces); |
| 2990 } | 3015 } |
| 2991 | 3016 |
| 2992 ExpectToken(Token::kLBRACE); | 3017 ExpectToken(Token::kLBRACE); |
| 2993 ClassDesc members(cls, class_name, false, class_pos); | 3018 ClassDesc members(cls, class_name, false, class_pos); |
| 2994 while (CurrentToken() != Token::kRBRACE) { | 3019 while (CurrentToken() != Token::kRBRACE) { |
| 2995 ParseClassMemberDefinition(&members); | 3020 ParseClassMemberDefinition(&members); |
| 2996 } | 3021 } |
| 2997 ExpectToken(Token::kRBRACE); | 3022 ExpectToken(Token::kRBRACE); |
| 2998 | 3023 |
| 2999 CheckConstructors(&members); | 3024 if (!is_patch) { |
| 3025 // Do not install implicit constructors. | |
|
hausner
2012/08/14 18:25:06
Why?
Ivan Posva
2012/08/15 06:50:40
If a patch class does not patch a constructor, it
| |
| 3026 CheckConstructors(&members); | |
| 3027 } | |
| 3000 | 3028 |
| 3001 Array& array = Array::Handle(); | 3029 Array& array = Array::Handle(); |
| 3002 array = Array::MakeArray(members.fields()); | 3030 array = Array::MakeArray(members.fields()); |
| 3003 cls.SetFields(array); | 3031 cls.SetFields(array); |
| 3004 | 3032 |
| 3005 // Creating a new array for functions marks the class as parsed. | 3033 // Creating a new array for functions marks the class as parsed. |
| 3006 array = Array::MakeArray(members.functions()); | 3034 array = Array::MakeArray(members.functions()); |
| 3007 cls.SetFunctions(array); | 3035 cls.SetFunctions(array); |
| 3008 | 3036 |
| 3009 pending_classes.Add(cls, Heap::kOld); | 3037 if (!is_patch) { |
| 3038 pending_classes.Add(cls, Heap::kOld); | |
| 3039 } else { | |
| 3040 // Lookup the patched class and apply the changes. | |
| 3041 obj = library_.LookupObject(class_name); | |
| 3042 Class::Cast(obj).ApplyPatch(cls); | |
| 3043 } | |
| 3010 } | 3044 } |
| 3011 | 3045 |
| 3012 | 3046 |
| 3013 // 1. Add an implicit constructor if no explicit constructor is present. | 3047 // 1. Add an implicit constructor if no explicit constructor is present. |
| 3014 // 2. Check for cycles in constructor redirection. | 3048 // 2. Check for cycles in constructor redirection. |
| 3015 void Parser::CheckConstructors(ClassDesc* class_desc) { | 3049 void Parser::CheckConstructors(ClassDesc* class_desc) { |
| 3016 // Add an implicit constructor if no explicit constructor is present. | 3050 // Add an implicit constructor if no explicit constructor is present. |
| 3017 if (!class_desc->has_constructor()) { | 3051 if (!class_desc->has_constructor()) { |
| 3018 // The implicit constructor is unnamed, has no explicit parameter, | 3052 // The implicit constructor is unnamed, has no explicit parameter, |
| 3019 // and contains a supercall in the initializer list. | 3053 // and contains a supercall in the initializer list. |
| 3020 String& ctor_name = String::ZoneHandle( | 3054 String& ctor_name = String::ZoneHandle( |
| 3021 String::Concat(class_desc->class_name(), | 3055 String::Concat(class_desc->class_name(), |
| 3022 String::Handle(Symbols::Dot()))); | 3056 String::Handle(Symbols::Dot()))); |
| 3023 ctor_name = Symbols::New(ctor_name); | 3057 ctor_name = Symbols::New(ctor_name); |
| 3024 // The token position for the implicit constructor is the 'class' | 3058 // The token position for the implicit constructor is the 'class' |
| 3025 // keyword of the constructor's class. | 3059 // keyword of the constructor's class. |
| 3026 Function& ctor = Function::Handle( | 3060 Function& ctor = Function::Handle( |
| 3027 Function::New(ctor_name, | 3061 Function::New(ctor_name, |
| 3028 RawFunction::kConstructor, | 3062 RawFunction::kConstructor, |
| 3029 /* is_static = */ false, | 3063 /* is_static = */ false, |
| 3030 /* is_const = */ false, | 3064 /* is_const = */ false, |
| 3031 /* is_abstract = */ false, | 3065 /* is_abstract = */ false, |
| 3032 /* is_external = */ false, | 3066 /* is_external = */ false, |
| 3033 current_class(), | 3067 current_class(), |
| 3034 class_desc->token_pos())); | 3068 class_desc->token_pos())); |
| 3035 ParamList params; | 3069 ParamList params; |
| 3036 // Add implicit 'this' parameter. | 3070 // Add implicit 'this' parameter. |
| 3037 ASSERT(current_class().raw() == ctor.owner()); | 3071 ASSERT(current_class().raw() == ctor.Owner()); |
| 3038 params.AddReceiver(ReceiverType(TokenPos())); | 3072 params.AddReceiver(ReceiverType(TokenPos())); |
| 3039 // Add implicit parameter for construction phase. | 3073 // Add implicit parameter for construction phase. |
| 3040 params.AddFinalParameter( | 3074 params.AddFinalParameter( |
| 3041 TokenPos(), | 3075 TokenPos(), |
| 3042 &String::ZoneHandle(Symbols::PhaseParameter()), | 3076 &String::ZoneHandle(Symbols::PhaseParameter()), |
| 3043 &Type::ZoneHandle(Type::IntInterface())); | 3077 &Type::ZoneHandle(Type::IntInterface())); |
| 3044 | 3078 |
| 3045 AddFormalParamsToFunction(¶ms, ctor); | 3079 AddFormalParamsToFunction(¶ms, ctor); |
| 3046 // The body of the constructor cannot modify the type of the constructed | 3080 // The body of the constructor cannot modify the type of the constructed |
| 3047 // instance, which is passed in as the receiver. | 3081 // instance, which is passed in as the receiver. |
| (...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3707 | 3741 |
| 3708 | 3742 |
| 3709 void Parser::ParseTopLevelAccessor(TopLevel* top_level) { | 3743 void Parser::ParseTopLevelAccessor(TopLevel* top_level) { |
| 3710 TRACE_PARSER("ParseTopLevelAccessor"); | 3744 TRACE_PARSER("ParseTopLevelAccessor"); |
| 3711 const bool is_static = true; | 3745 const bool is_static = true; |
| 3712 bool is_external = false; | 3746 bool is_external = false; |
| 3713 bool is_patch = false; | 3747 bool is_patch = false; |
| 3714 AbstractType& result_type = AbstractType::Handle(); | 3748 AbstractType& result_type = AbstractType::Handle(); |
| 3715 if (is_patch_source() && | 3749 if (is_patch_source() && |
| 3716 (CurrentToken() == Token::kIDENT) && | 3750 (CurrentToken() == Token::kIDENT) && |
| 3717 (CurrentLiteral()->Equals("patch"))) { | 3751 CurrentLiteral()->Equals("patch")) { |
| 3718 ConsumeToken(); | 3752 ConsumeToken(); |
| 3719 is_patch = true; | 3753 is_patch = true; |
| 3720 } else if (CurrentToken() == Token::kEXTERNAL) { | 3754 } else if (CurrentToken() == Token::kEXTERNAL) { |
| 3721 ConsumeToken(); | 3755 ConsumeToken(); |
| 3722 is_external = true; | 3756 is_external = true; |
| 3723 } | 3757 } |
| 3724 bool is_getter = (CurrentToken() == Token::kGET); | 3758 bool is_getter = (CurrentToken() == Token::kGET); |
| 3725 if (CurrentToken() == Token::kGET || | 3759 if (CurrentToken() == Token::kGET || |
| 3726 CurrentToken() == Token::kSET) { | 3760 CurrentToken() == Token::kSET) { |
| 3727 ConsumeToken(); | 3761 ConsumeToken(); |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3999 ParseClassDefinition(pending_classes); | 4033 ParseClassDefinition(pending_classes); |
| 4000 } else if ((CurrentToken() == Token::kTYPEDEF) && | 4034 } else if ((CurrentToken() == Token::kTYPEDEF) && |
| 4001 (LookaheadToken(1) != Token::kLPAREN)) { | 4035 (LookaheadToken(1) != Token::kLPAREN)) { |
| 4002 ParseFunctionTypeAlias(pending_classes); | 4036 ParseFunctionTypeAlias(pending_classes); |
| 4003 } else if (CurrentToken() == Token::kINTERFACE) { | 4037 } else if (CurrentToken() == Token::kINTERFACE) { |
| 4004 ParseInterfaceDefinition(pending_classes); | 4038 ParseInterfaceDefinition(pending_classes); |
| 4005 } else if ((CurrentToken() == Token::kABSTRACT) && | 4039 } else if ((CurrentToken() == Token::kABSTRACT) && |
| 4006 (LookaheadToken(1) == Token::kCLASS)) { | 4040 (LookaheadToken(1) == Token::kCLASS)) { |
| 4007 ConsumeToken(); // Consume and ignore 'abstract'. | 4041 ConsumeToken(); // Consume and ignore 'abstract'. |
| 4008 ParseClassDefinition(pending_classes); | 4042 ParseClassDefinition(pending_classes); |
| 4043 } else if (is_patch_source() && | |
| 4044 (CurrentToken() == Token::kIDENT) && | |
| 4045 CurrentLiteral()->Equals("patch") && | |
| 4046 (LookaheadToken(1) == Token::kCLASS)) { | |
| 4047 ParseClassDefinition(pending_classes); | |
| 4009 } else { | 4048 } else { |
| 4010 set_current_class(toplevel_class); | 4049 set_current_class(toplevel_class); |
| 4011 if (IsVariableDeclaration()) { | 4050 if (IsVariableDeclaration()) { |
| 4012 ParseTopLevelVariable(&top_level); | 4051 ParseTopLevelVariable(&top_level); |
| 4013 } else if (IsFunctionDeclaration()) { | 4052 } else if (IsFunctionDeclaration()) { |
| 4014 ParseTopLevelFunction(&top_level); | 4053 ParseTopLevelFunction(&top_level); |
| 4015 } else if (IsTopLevelAccessor()) { | 4054 } else if (IsTopLevelAccessor()) { |
| 4016 ParseTopLevelAccessor(&top_level); | 4055 ParseTopLevelAccessor(&top_level); |
| 4017 } else if (CurrentToken() == Token::kEOS) { | 4056 } else if (CurrentToken() == Token::kEOS) { |
| 4018 break; | 4057 break; |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4161 } | 4200 } |
| 4162 } | 4201 } |
| 4163 } | 4202 } |
| 4164 | 4203 |
| 4165 | 4204 |
| 4166 // Builds ReturnNode/NativeBodyNode for a native function. | 4205 // Builds ReturnNode/NativeBodyNode for a native function. |
| 4167 void Parser::ParseNativeFunctionBlock(const ParamList* params, | 4206 void Parser::ParseNativeFunctionBlock(const ParamList* params, |
| 4168 const Function& func) { | 4207 const Function& func) { |
| 4169 func.set_is_native(true); | 4208 func.set_is_native(true); |
| 4170 TRACE_PARSER("ParseNativeFunctionBlock"); | 4209 TRACE_PARSER("ParseNativeFunctionBlock"); |
| 4171 const Class& cls = Class::Handle(func.owner()); | 4210 const Class& cls = Class::Handle(func.Owner()); |
| 4172 const int num_parameters = params->parameters->length(); | 4211 const int num_parameters = params->parameters->length(); |
| 4173 const bool is_instance_closure = func.IsImplicitInstanceClosureFunction(); | 4212 const bool is_instance_closure = func.IsImplicitInstanceClosureFunction(); |
| 4174 int num_params_for_resolution = num_parameters; | 4213 int num_params_for_resolution = num_parameters; |
| 4175 | 4214 |
| 4176 // Parse the function name out. | 4215 // Parse the function name out. |
| 4177 const intptr_t native_pos = TokenPos(); | 4216 const intptr_t native_pos = TokenPos(); |
| 4178 const String& native_name = ParseNativeDeclaration(); | 4217 const String& native_name = ParseNativeDeclaration(); |
| 4179 | 4218 |
| 4180 if (is_instance_closure) { | 4219 if (is_instance_closure) { |
| 4181 num_params_for_resolution += 1; // account for 'this' when resolving. | 4220 num_params_for_resolution += 1; // account for 'this' when resolving. |
| (...skipping 2903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7085 selector = new LoadIndexedNode(bracket_pos, array, index); | 7124 selector = new LoadIndexedNode(bracket_pos, array, index); |
| 7086 } else if (CurrentToken() == Token::kLPAREN) { | 7125 } else if (CurrentToken() == Token::kLPAREN) { |
| 7087 if (left->IsPrimaryNode()) { | 7126 if (left->IsPrimaryNode()) { |
| 7088 PrimaryNode* primary = left->AsPrimaryNode(); | 7127 PrimaryNode* primary = left->AsPrimaryNode(); |
| 7089 const intptr_t primary_pos = primary->token_pos(); | 7128 const intptr_t primary_pos = primary->token_pos(); |
| 7090 if (primary->primary().IsFunction()) { | 7129 if (primary->primary().IsFunction()) { |
| 7091 Function& func = Function::CheckedHandle(primary->primary().raw()); | 7130 Function& func = Function::CheckedHandle(primary->primary().raw()); |
| 7092 String& func_name = String::ZoneHandle(func.name()); | 7131 String& func_name = String::ZoneHandle(func.name()); |
| 7093 if (func.is_static()) { | 7132 if (func.is_static()) { |
| 7094 // Parse static function call. | 7133 // Parse static function call. |
| 7095 Class& cls = Class::Handle(func.owner()); | 7134 Class& cls = Class::Handle(func.Owner()); |
| 7096 selector = ParseStaticCall(cls, func_name, primary_pos); | 7135 selector = ParseStaticCall(cls, func_name, primary_pos); |
| 7097 } else { | 7136 } else { |
| 7098 // Dynamic function call on implicit "this" parameter. | 7137 // Dynamic function call on implicit "this" parameter. |
| 7099 if (current_function().is_static()) { | 7138 if (current_function().is_static()) { |
| 7100 ErrorMsg(primary_pos, | 7139 ErrorMsg(primary_pos, |
| 7101 "cannot access instance method '%s' " | 7140 "cannot access instance method '%s' " |
| 7102 "from static function", | 7141 "from static function", |
| 7103 func_name.ToCString()); | 7142 func_name.ToCString()); |
| 7104 } | 7143 } |
| 7105 selector = ParseInstanceCall(LoadReceiver(primary_pos), func_name); | 7144 selector = ParseInstanceCall(LoadReceiver(primary_pos), func_name); |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7641 } | 7680 } |
| 7642 } | 7681 } |
| 7643 if (!obj.IsNull()) { | 7682 if (!obj.IsNull()) { |
| 7644 ASSERT(obj.IsFunction()); | 7683 ASSERT(obj.IsFunction()); |
| 7645 const Function& func = Function::Cast(obj); | 7684 const Function& func = Function::Cast(obj); |
| 7646 ASSERT(func.is_static()); | 7685 ASSERT(func.is_static()); |
| 7647 ASSERT(AbstractType::Handle(func.result_type()).IsResolved()); | 7686 ASSERT(AbstractType::Handle(func.result_type()).IsResolved()); |
| 7648 return new StaticGetterNode(qual_ident.ident_pos, | 7687 return new StaticGetterNode(qual_ident.ident_pos, |
| 7649 NULL, | 7688 NULL, |
| 7650 false, | 7689 false, |
| 7651 Class::ZoneHandle(func.owner()), | 7690 Class::ZoneHandle(func.Owner()), |
| 7652 *qual_ident.ident); | 7691 *qual_ident.ident); |
| 7653 } | 7692 } |
| 7654 if (qual_ident.lib_prefix != NULL) { | 7693 if (qual_ident.lib_prefix != NULL) { |
| 7655 return NULL; | 7694 return NULL; |
| 7656 } | 7695 } |
| 7657 // Lexically unresolved primary identifiers are referenced by their name. | 7696 // Lexically unresolved primary identifiers are referenced by their name. |
| 7658 return new PrimaryNode(qual_ident.ident_pos, *qual_ident.ident); | 7697 return new PrimaryNode(qual_ident.ident_pos, *qual_ident.ident); |
| 7659 } | 7698 } |
| 7660 | 7699 |
| 7661 | 7700 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7837 } | 7876 } |
| 7838 } | 7877 } |
| 7839 return type.raw(); | 7878 return type.raw(); |
| 7840 } | 7879 } |
| 7841 | 7880 |
| 7842 | 7881 |
| 7843 void Parser::CheckConstructorCallTypeArguments( | 7882 void Parser::CheckConstructorCallTypeArguments( |
| 7844 intptr_t pos, Function& constructor, | 7883 intptr_t pos, Function& constructor, |
| 7845 const AbstractTypeArguments& type_arguments) { | 7884 const AbstractTypeArguments& type_arguments) { |
| 7846 if (!type_arguments.IsNull()) { | 7885 if (!type_arguments.IsNull()) { |
| 7847 const Class& constructor_class = Class::Handle(constructor.owner()); | 7886 const Class& constructor_class = Class::Handle(constructor.Owner()); |
| 7848 ASSERT(!constructor_class.IsNull()); | 7887 ASSERT(!constructor_class.IsNull()); |
| 7849 ASSERT(constructor_class.is_finalized()); | 7888 ASSERT(constructor_class.is_finalized()); |
| 7850 // Do not report the expected vs. actual number of type arguments, because | 7889 // Do not report the expected vs. actual number of type arguments, because |
| 7851 // the type argument vector is flattened and raw types are allowed. | 7890 // the type argument vector is flattened and raw types are allowed. |
| 7852 if (type_arguments.Length() != constructor_class.NumTypeArguments()) { | 7891 if (type_arguments.Length() != constructor_class.NumTypeArguments()) { |
| 7853 ErrorMsg(pos, "wrong number of type arguments passed to constructor"); | 7892 ErrorMsg(pos, "wrong number of type arguments passed to constructor"); |
| 7854 } | 7893 } |
| 7855 } | 7894 } |
| 7856 } | 7895 } |
| 7857 | 7896 |
| (...skipping 1196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9054 void Parser::SkipQualIdent() { | 9093 void Parser::SkipQualIdent() { |
| 9055 ASSERT(IsIdentifier()); | 9094 ASSERT(IsIdentifier()); |
| 9056 ConsumeToken(); | 9095 ConsumeToken(); |
| 9057 if (CurrentToken() == Token::kPERIOD) { | 9096 if (CurrentToken() == Token::kPERIOD) { |
| 9058 ConsumeToken(); // Consume the kPERIOD token. | 9097 ConsumeToken(); // Consume the kPERIOD token. |
| 9059 ExpectIdentifier("identifier expected after '.'"); | 9098 ExpectIdentifier("identifier expected after '.'"); |
| 9060 } | 9099 } |
| 9061 } | 9100 } |
| 9062 | 9101 |
| 9063 } // namespace dart | 9102 } // namespace dart |
| OLD | NEW |