Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(255)

Side by Side Diff: runtime/vm/parser.cc

Issue 1528873002: VM: Use read-only handle Object::dynamic_type() where possible. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/parser.h ('k') | runtime/vm/regexp.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 8 #ifndef DART_PRECOMPILED
9 9
10 #include "lib/invocation_mirror.h" 10 #include "lib/invocation_mirror.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 // finalized yet. 131 // finalized yet.
132 return a.raw(); 132 return a.raw();
133 } 133 }
134 134
135 135
136 LocalVariable* ParsedFunction::EnsureExpressionTemp() { 136 LocalVariable* ParsedFunction::EnsureExpressionTemp() {
137 if (!has_expression_temp_var()) { 137 if (!has_expression_temp_var()) {
138 LocalVariable* temp = 138 LocalVariable* temp =
139 new (Z) LocalVariable(function_.token_pos(), 139 new (Z) LocalVariable(function_.token_pos(),
140 Symbols::ExprTemp(), 140 Symbols::ExprTemp(),
141 Type::ZoneHandle(Type::DynamicType())); 141 Object::dynamic_type());
142 ASSERT(temp != NULL); 142 ASSERT(temp != NULL);
143 set_expression_temp_var(temp); 143 set_expression_temp_var(temp);
144 } 144 }
145 ASSERT(has_expression_temp_var()); 145 ASSERT(has_expression_temp_var());
146 return expression_temp_var(); 146 return expression_temp_var();
147 } 147 }
148 148
149 149
150 void ParsedFunction::EnsureFinallyReturnTemp(bool is_async) { 150 void ParsedFunction::EnsureFinallyReturnTemp(bool is_async) {
151 if (!has_finally_return_temp_var()) { 151 if (!has_finally_return_temp_var()) {
152 LocalVariable* temp = new(Z) LocalVariable( 152 LocalVariable* temp = new(Z) LocalVariable(
153 function_.token_pos(), 153 function_.token_pos(),
154 String::ZoneHandle(Z, Symbols::New(":finally_ret_val")), 154 String::ZoneHandle(Z, Symbols::New(":finally_ret_val")),
155 Type::ZoneHandle(Z, Type::DynamicType())); 155 Object::dynamic_type());
156 ASSERT(temp != NULL); 156 ASSERT(temp != NULL);
157 temp->set_is_final(); 157 temp->set_is_final();
158 if (is_async) { 158 if (is_async) {
159 temp->set_is_captured(); 159 temp->set_is_captured();
160 } 160 }
161 set_finally_return_temp_var(temp); 161 set_finally_return_temp_var(temp);
162 } 162 }
163 ASSERT(has_finally_return_temp_var()); 163 ASSERT(has_finally_return_temp_var());
164 } 164 }
165 165
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 bool implicitly_final; 603 bool implicitly_final;
604 bool skipped; 604 bool skipped;
605 ZoneGrowableArray<ParamDesc>* parameters; 605 ZoneGrowableArray<ParamDesc>* parameters;
606 }; 606 };
607 607
608 608
609 struct MemberDesc { 609 struct MemberDesc {
610 MemberDesc() { 610 MemberDesc() {
611 Clear(); 611 Clear();
612 } 612 }
613
613 void Clear() { 614 void Clear() {
614 has_abstract = false; 615 has_abstract = false;
615 has_external = false; 616 has_external = false;
616 has_final = false; 617 has_final = false;
617 has_const = false; 618 has_const = false;
618 has_static = false; 619 has_static = false;
619 has_var = false; 620 has_var = false;
620 has_factory = false; 621 has_factory = false;
621 has_operator = false; 622 has_operator = false;
622 has_native = false; 623 has_native = false;
623 metadata_pos = -1; 624 metadata_pos = -1;
624 operator_token = Token::kILLEGAL; 625 operator_token = Token::kILLEGAL;
625 type = NULL; 626 type = NULL;
626 name_pos = 0; 627 name_pos = 0;
627 name = NULL; 628 name = NULL;
628 redirect_name = NULL; 629 redirect_name = NULL;
629 dict_name = NULL; 630 dict_name = NULL;
630 params.Clear(); 631 params.Clear();
631 kind = RawFunction::kRegularFunction; 632 kind = RawFunction::kRegularFunction;
632 field_ = NULL; 633 field_ = NULL;
633 } 634 }
635
634 bool IsConstructor() const { 636 bool IsConstructor() const {
635 return (kind == RawFunction::kConstructor) && !has_static; 637 return (kind == RawFunction::kConstructor) && !has_static;
636 } 638 }
637 bool IsFactory() const { 639 bool IsFactory() const {
638 return (kind == RawFunction::kConstructor) && has_static; 640 return (kind == RawFunction::kConstructor) && has_static;
639 } 641 }
640 bool IsFactoryOrConstructor() const { 642 bool IsFactoryOrConstructor() const {
641 return (kind == RawFunction::kConstructor); 643 return (kind == RawFunction::kConstructor);
642 } 644 }
643 bool IsGetter() const { 645 bool IsGetter() const {
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
1351 Function& constructor = Function::ZoneHandle(Z); 1353 Function& constructor = Function::ZoneHandle(Z);
1352 TypeArguments& type_args = TypeArguments::ZoneHandle(Z); 1354 TypeArguments& type_args = TypeArguments::ZoneHandle(Z);
1353 ParseConstructorClosurization(&constructor, &type_args); 1355 ParseConstructorClosurization(&constructor, &type_args);
1354 ASSERT(!constructor.IsNull()); 1356 ASSERT(!constructor.IsNull());
1355 1357
1356 ParamList params; 1358 ParamList params;
1357 // The first parameter of the closure function is the implicit closure 1359 // The first parameter of the closure function is the implicit closure
1358 // argument. 1360 // argument.
1359 params.AddFinalParameter(token_pos, 1361 params.AddFinalParameter(token_pos,
1360 &Symbols::ClosureParameter(), 1362 &Symbols::ClosureParameter(),
1361 &Type::ZoneHandle(Z, Type::DynamicType())); 1363 &Object::dynamic_type());
1362 bool params_ok = ParseFormalParameters(constructor, &params); 1364 bool params_ok = ParseFormalParameters(constructor, &params);
1363 USE(params_ok); 1365 USE(params_ok);
1364 ASSERT(params_ok); 1366 ASSERT(params_ok);
1365 // Per language spec, the type of the closure parameters is dynamic. 1367 // Per language spec, the type of the closure parameters is dynamic.
1366 // Replace the types parsed from the constructor. 1368 // Replace the types parsed from the constructor.
1367 params.EraseParameterTypes(); 1369 params.EraseParameterTypes();
1368 1370
1369 SetupDefaultsForOptionalParams(params); 1371 SetupDefaultsForOptionalParams(params);
1370 ASSERT(func.num_fixed_parameters() == params.num_fixed_parameters); 1372 ASSERT(func.num_fixed_parameters() == params.num_fixed_parameters);
1371 ASSERT(func.NumOptionalParameters() == params.num_optional_parameters); 1373 ASSERT(func.NumOptionalParameters() == params.num_optional_parameters);
(...skipping 29 matching lines...) Expand all
1401 SequenceNode* Parser::ParseImplicitClosure(const Function& func) { 1403 SequenceNode* Parser::ParseImplicitClosure(const Function& func) {
1402 TRACE_PARSER("ParseImplicitClosure"); 1404 TRACE_PARSER("ParseImplicitClosure");
1403 intptr_t token_pos = func.token_pos(); 1405 intptr_t token_pos = func.token_pos();
1404 1406
1405 OpenFunctionBlock(func); 1407 OpenFunctionBlock(func);
1406 1408
1407 ParamList params; 1409 ParamList params;
1408 params.AddFinalParameter( 1410 params.AddFinalParameter(
1409 token_pos, 1411 token_pos,
1410 &Symbols::ClosureParameter(), 1412 &Symbols::ClosureParameter(),
1411 &Type::ZoneHandle(Type::DynamicType())); 1413 &Object::dynamic_type());
1412 1414
1413 const Function& parent = Function::ZoneHandle(func.parent_function()); 1415 const Function& parent = Function::ZoneHandle(func.parent_function());
1414 if (parent.IsImplicitSetterFunction()) { 1416 if (parent.IsImplicitSetterFunction()) {
1415 const intptr_t ident_pos = func.token_pos(); 1417 const intptr_t ident_pos = func.token_pos();
1416 ASSERT(IsIdentifier()); 1418 ASSERT(IsIdentifier());
1417 const String& field_name = *CurrentLiteral(); 1419 const String& field_name = *CurrentLiteral();
1418 const Class& field_class = Class::ZoneHandle(Z, parent.Owner()); 1420 const Class& field_class = Class::ZoneHandle(Z, parent.Owner());
1419 const Field& field = 1421 const Field& field =
1420 Field::ZoneHandle(Z, field_class.LookupInstanceField(field_name)); 1422 Field::ZoneHandle(Z, field_class.LookupInstanceField(field_name));
1421 const AbstractType& field_type = AbstractType::ZoneHandle(Z, field.type()); 1423 const AbstractType& field_type = AbstractType::ZoneHandle(Z, field.type());
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1499 // Receiver first. 1501 // Receiver first.
1500 intptr_t token_pos = func.token_pos(); 1502 intptr_t token_pos = func.token_pos();
1501 params.AddReceiver(ReceiverType(current_class()), token_pos); 1503 params.AddReceiver(ReceiverType(current_class()), token_pos);
1502 // Remaining positional parameters. 1504 // Remaining positional parameters.
1503 intptr_t i = 1; 1505 intptr_t i = 1;
1504 for (; i < desc.PositionalCount(); ++i) { 1506 for (; i < desc.PositionalCount(); ++i) {
1505 ParamDesc p; 1507 ParamDesc p;
1506 char name[64]; 1508 char name[64];
1507 OS::SNPrint(name, 64, ":p%" Pd, i); 1509 OS::SNPrint(name, 64, ":p%" Pd, i);
1508 p.name = &String::ZoneHandle(Z, Symbols::New(name)); 1510 p.name = &String::ZoneHandle(Z, Symbols::New(name));
1509 p.type = &Type::ZoneHandle(Z, Type::DynamicType()); 1511 p.type = &Object::dynamic_type();
1510 params.parameters->Add(p); 1512 params.parameters->Add(p);
1511 params.num_fixed_parameters++; 1513 params.num_fixed_parameters++;
1512 } 1514 }
1513 ASSERT(desc.PositionalCount() == params.num_fixed_parameters); 1515 ASSERT(desc.PositionalCount() == params.num_fixed_parameters);
1514 1516
1515 // Named parameters. 1517 // Named parameters.
1516 for (; i < desc.Count(); ++i) { 1518 for (; i < desc.Count(); ++i) {
1517 ParamDesc p; 1519 ParamDesc p;
1518 intptr_t index = i - desc.PositionalCount(); 1520 intptr_t index = i - desc.PositionalCount();
1519 p.name = &String::ZoneHandle(Z, desc.NameAt(index)); 1521 p.name = &String::ZoneHandle(Z, desc.NameAt(index));
1520 p.type = &Type::ZoneHandle(Z, Type::DynamicType()); 1522 p.type = &Object::dynamic_type();
1521 p.default_value = &Object::null_instance(); 1523 p.default_value = &Object::null_instance();
1522 params.parameters->Add(p); 1524 params.parameters->Add(p);
1523 params.num_optional_parameters++; 1525 params.num_optional_parameters++;
1524 params.has_optional_named_parameters = true; 1526 params.has_optional_named_parameters = true;
1525 } 1527 }
1526 ASSERT(desc.NamedCount() == params.num_optional_parameters); 1528 ASSERT(desc.NamedCount() == params.num_optional_parameters);
1527 1529
1528 SetupDefaultsForOptionalParams(params); 1530 SetupDefaultsForOptionalParams(params);
1529 1531
1530 // Build local scope for function and populate with the formal parameters. 1532 // Build local scope for function and populate with the formal parameters.
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
1761 1763
1762 if (CurrentToken() == Token::kFINAL) { 1764 if (CurrentToken() == Token::kFINAL) {
1763 ConsumeToken(); 1765 ConsumeToken();
1764 parameter.is_final = true; 1766 parameter.is_final = true;
1765 } else if (CurrentToken() == Token::kVAR) { 1767 } else if (CurrentToken() == Token::kVAR) {
1766 ConsumeToken(); 1768 ConsumeToken();
1767 var_seen = true; 1769 var_seen = true;
1768 // The parameter type is the 'dynamic' type. 1770 // The parameter type is the 'dynamic' type.
1769 // If this is an initializing formal, its type will be set to the type of 1771 // If this is an initializing formal, its type will be set to the type of
1770 // the respective field when the constructor is fully parsed. 1772 // the respective field when the constructor is fully parsed.
1771 parameter.type = &Type::ZoneHandle(Z, Type::DynamicType()); 1773 parameter.type = &Object::dynamic_type();
1772 } 1774 }
1773 if (CurrentToken() == Token::kTHIS) { 1775 if (CurrentToken() == Token::kTHIS) {
1774 ConsumeToken(); 1776 ConsumeToken();
1775 ExpectToken(Token::kPERIOD); 1777 ExpectToken(Token::kPERIOD);
1776 this_seen = true; 1778 this_seen = true;
1777 parameter.is_field_initializer = true; 1779 parameter.is_field_initializer = true;
1778 } 1780 }
1779 if ((parameter.type == NULL) && (CurrentToken() == Token::kVOID)) { 1781 if ((parameter.type == NULL) && (CurrentToken() == Token::kVOID)) {
1780 ConsumeToken(); 1782 ConsumeToken();
1781 // This must later be changed to a closure type if we recognize 1783 // This must later be changed to a closure type if we recognize
1782 // a closure/function type parameter. We check this at the end 1784 // a closure/function type parameter. We check this at the end
1783 // of ParseFormalParameter. 1785 // of ParseFormalParameter.
1784 parameter.type = &Type::ZoneHandle(Z, Type::VoidType()); 1786 parameter.type = &Object::void_type();
1785 } 1787 }
1786 if (parameter.type == NULL) { 1788 if (parameter.type == NULL) {
1787 // At this point, we must see an identifier for the type or the 1789 // At this point, we must see an identifier for the type or the
1788 // function parameter. 1790 // function parameter.
1789 if (!IsIdentifier()) { 1791 if (!IsIdentifier()) {
1790 ReportError("parameter name or type expected"); 1792 ReportError("parameter name or type expected");
1791 } 1793 }
1792 // We have not seen a parameter type yet, so we check if the next 1794 // We have not seen a parameter type yet, so we check if the next
1793 // identifier could represent a type before parsing it. 1795 // identifier could represent a type before parsing it.
1794 Token::Kind follower = LookaheadToken(1); 1796 Token::Kind follower = LookaheadToken(1);
1795 // We have an identifier followed by a 'follower' token. 1797 // We have an identifier followed by a 'follower' token.
1796 // We either parse a type or assume that no type is specified. 1798 // We either parse a type or assume that no type is specified.
1797 if ((follower == Token::kLT) || // Parameterized type. 1799 if ((follower == Token::kLT) || // Parameterized type.
1798 (follower == Token::kPERIOD) || // Qualified class name of type. 1800 (follower == Token::kPERIOD) || // Qualified class name of type.
1799 Token::IsIdentifier(follower) || // Parameter name following a type. 1801 Token::IsIdentifier(follower) || // Parameter name following a type.
1800 (follower == Token::kTHIS)) { // Field parameter following a type. 1802 (follower == Token::kTHIS)) { // Field parameter following a type.
1801 // The types of formal parameters are never ignored, even in unchecked 1803 // The types of formal parameters are never ignored, even in unchecked
1802 // mode, because they are part of the function type of closurized 1804 // mode, because they are part of the function type of closurized
1803 // functions appearing in type tests with typedefs. 1805 // functions appearing in type tests with typedefs.
1804 parameter.has_explicit_type = true; 1806 parameter.has_explicit_type = true;
1805 parameter.type = &AbstractType::ZoneHandle(Z, 1807 parameter.type = &AbstractType::ZoneHandle(Z,
1806 ParseType(is_top_level_ ? ClassFinalizer::kResolveTypeParameters : 1808 ParseType(is_top_level_ ? ClassFinalizer::kResolveTypeParameters :
1807 ClassFinalizer::kCanonicalize)); 1809 ClassFinalizer::kCanonicalize));
1808 } else { 1810 } else {
1809 // If this is an initializing formal, its type will be set to the type of 1811 // If this is an initializing formal, its type will be set to the type of
1810 // the respective field when the constructor is fully parsed. 1812 // the respective field when the constructor is fully parsed.
1811 parameter.type = &Type::ZoneHandle(Z, Type::DynamicType()); 1813 parameter.type = &Object::dynamic_type();
1812 } 1814 }
1813 } 1815 }
1814 if (!this_seen && (CurrentToken() == Token::kTHIS)) { 1816 if (!this_seen && (CurrentToken() == Token::kTHIS)) {
1815 ConsumeToken(); 1817 ConsumeToken();
1816 ExpectToken(Token::kPERIOD); 1818 ExpectToken(Token::kPERIOD);
1817 this_seen = true; 1819 this_seen = true;
1818 parameter.is_field_initializer = true; 1820 parameter.is_field_initializer = true;
1819 } 1821 }
1820 1822
1821 // At this point, we must see an identifier for the parameter name. 1823 // At this point, we must see an identifier for the parameter name.
(...skipping 28 matching lines...) Expand all
1850 const AbstractType& result_type = 1852 const AbstractType& result_type =
1851 AbstractType::Handle(Z, parameter.type->raw()); 1853 AbstractType::Handle(Z, parameter.type->raw());
1852 1854
1853 // Finish parsing the function type parameter. 1855 // Finish parsing the function type parameter.
1854 ParamList func_params; 1856 ParamList func_params;
1855 1857
1856 // Add implicit closure object parameter. 1858 // Add implicit closure object parameter.
1857 func_params.AddFinalParameter( 1859 func_params.AddFinalParameter(
1858 TokenPos(), 1860 TokenPos(),
1859 &Symbols::ClosureParameter(), 1861 &Symbols::ClosureParameter(),
1860 &Type::ZoneHandle(Z, Type::DynamicType())); 1862 &Object::dynamic_type());
1861 1863
1862 const bool no_explicit_default_values = false; 1864 const bool no_explicit_default_values = false;
1863 ParseFormalParameterList(no_explicit_default_values, false, &func_params); 1865 ParseFormalParameterList(no_explicit_default_values, false, &func_params);
1864 1866
1865 // In top-level and mixin functions, the source may be in a different 1867 // In top-level and mixin functions, the source may be in a different
1866 // script than the script of the current class. 1868 // script than the script of the current class.
1867 Object& sig_func_owner = Object::Handle(Z, current_class().raw()); 1869 Object& sig_func_owner = Object::Handle(Z, current_class().raw());
1868 if (current_class().script() != script_.raw()) { 1870 if (current_class().script() != script_.raw()) {
1869 sig_func_owner = PatchClass::New(current_class(), script_); 1871 sig_func_owner = PatchClass::New(current_class(), script_);
1870 } 1872 }
(...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after
2923 String::Handle(Z, super_class.Name()).ToCString()); 2925 String::Handle(Z, super_class.Name()).ToCString());
2924 } 2926 }
2925 2927
2926 // Prepare user-defined arguments to be forwarded to super call. 2928 // Prepare user-defined arguments to be forwarded to super call.
2927 // The first user-defined argument is at position 2. 2929 // The first user-defined argument is at position 2.
2928 forwarding_args = new ArgumentListNode(Scanner::kNoSourcePos); 2930 forwarding_args = new ArgumentListNode(Scanner::kNoSourcePos);
2929 for (int i = 2; i < func.NumParameters(); i++) { 2931 for (int i = 2; i < func.NumParameters(); i++) {
2930 LocalVariable* param = new LocalVariable( 2932 LocalVariable* param = new LocalVariable(
2931 Scanner::kNoSourcePos, 2933 Scanner::kNoSourcePos,
2932 String::ZoneHandle(Z, func.ParameterNameAt(i)), 2934 String::ZoneHandle(Z, func.ParameterNameAt(i)),
2933 Type::ZoneHandle(Z, Type::DynamicType())); 2935 Object::dynamic_type());
2934 current_block_->scope->InsertParameterAt(i, param); 2936 current_block_->scope->InsertParameterAt(i, param);
2935 forwarding_args->Add(new LoadLocalNode(Scanner::kNoSourcePos, param)); 2937 forwarding_args->Add(new LoadLocalNode(Scanner::kNoSourcePos, param));
2936 } 2938 }
2937 } 2939 }
2938 2940
2939 AstNode* super_call = GenerateSuperConstructorCall( 2941 AstNode* super_call = GenerateSuperConstructorCall(
2940 current_class(), 2942 current_class(),
2941 Scanner::kNoSourcePos, 2943 Scanner::kNoSourcePos,
2942 receiver, 2944 receiver,
2943 new LoadLocalNode(Scanner::kNoSourcePos, phase_parameter), 2945 new LoadLocalNode(Scanner::kNoSourcePos, phase_parameter),
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
3308 3310
3309 ParamList params; 3311 ParamList params;
3310 // An instance closure function may capture and access the receiver, but via 3312 // An instance closure function may capture and access the receiver, but via
3311 // the context and not via the first formal parameter. 3313 // the context and not via the first formal parameter.
3312 if (func.IsClosureFunction()) { 3314 if (func.IsClosureFunction()) {
3313 // The first parameter of a closure function is the closure object. 3315 // The first parameter of a closure function is the closure object.
3314 ASSERT(!func.is_const()); // Closure functions cannot be const. 3316 ASSERT(!func.is_const()); // Closure functions cannot be const.
3315 params.AddFinalParameter( 3317 params.AddFinalParameter(
3316 TokenPos(), 3318 TokenPos(),
3317 &Symbols::ClosureParameter(), 3319 &Symbols::ClosureParameter(),
3318 &Type::ZoneHandle(Z, Type::DynamicType())); 3320 &Object::dynamic_type());
3319 } else if (!func.is_static()) { 3321 } else if (!func.is_static()) {
3320 // Static functions do not have a receiver. 3322 // Static functions do not have a receiver.
3321 ASSERT(current_class().raw() == func.Owner()); 3323 ASSERT(current_class().raw() == func.Owner());
3322 params.AddReceiver(ReceiverType(current_class()), func.token_pos()); 3324 params.AddReceiver(ReceiverType(current_class()), func.token_pos());
3323 } else if (func.IsFactory()) { 3325 } else if (func.IsFactory()) {
3324 // The first parameter of a factory is the TypeArguments vector of 3326 // The first parameter of a factory is the TypeArguments vector of
3325 // the type of the instance to be allocated. 3327 // the type of the instance to be allocated.
3326 params.AddFinalParameter( 3328 params.AddFinalParameter(
3327 TokenPos(), 3329 TokenPos(),
3328 &Symbols::TypeArgumentsParameter(), 3330 &Symbols::TypeArgumentsParameter(),
3329 &Type::ZoneHandle(Z, Type::DynamicType())); 3331 &Object::dynamic_type());
3330 } 3332 }
3331 // Expect the parameter list unless this is a getter function, or the 3333 // Expect the parameter list unless this is a getter function, or the
3332 // body closure of an async or generator getter function. 3334 // body closure of an async or generator getter function.
3333 ASSERT((CurrentToken() == Token::kLPAREN) || 3335 ASSERT((CurrentToken() == Token::kLPAREN) ||
3334 func.IsGetterFunction() || 3336 func.IsGetterFunction() ||
3335 (func.is_generated_body() && 3337 (func.is_generated_body() &&
3336 Function::Handle(func.parent_function()).IsGetterFunction())); 3338 Function::Handle(func.parent_function()).IsGetterFunction()));
3337 const bool allow_explicit_default_values = true; 3339 const bool allow_explicit_default_values = true;
3338 if (func.IsGetterFunction()) { 3340 if (func.IsGetterFunction()) {
3339 // Populate function scope with the formal parameters. Since in this case 3341 // Populate function scope with the formal parameters. Since in this case
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
3682 method->params.Clear(); 3684 method->params.Clear();
3683 // Static functions do not have a receiver. 3685 // Static functions do not have a receiver.
3684 // The first parameter of a factory is the TypeArguments vector of 3686 // The first parameter of a factory is the TypeArguments vector of
3685 // the type of the instance to be allocated. 3687 // the type of the instance to be allocated.
3686 if (!method->has_static || method->IsConstructor()) { 3688 if (!method->has_static || method->IsConstructor()) {
3687 method->params.AddReceiver(ReceiverType(current_class()), formal_param_pos); 3689 method->params.AddReceiver(ReceiverType(current_class()), formal_param_pos);
3688 } else if (method->IsFactory()) { 3690 } else if (method->IsFactory()) {
3689 method->params.AddFinalParameter( 3691 method->params.AddFinalParameter(
3690 formal_param_pos, 3692 formal_param_pos,
3691 &Symbols::TypeArgumentsParameter(), 3693 &Symbols::TypeArgumentsParameter(),
3692 &Type::ZoneHandle(Z, Type::DynamicType())); 3694 &Object::dynamic_type());
3693 } 3695 }
3694 // Constructors have an implicit parameter for the construction phase. 3696 // Constructors have an implicit parameter for the construction phase.
3695 if (method->IsConstructor()) { 3697 if (method->IsConstructor()) {
3696 method->params.AddFinalParameter( 3698 method->params.AddFinalParameter(
3697 TokenPos(), 3699 TokenPos(),
3698 &Symbols::PhaseParameter(), 3700 &Symbols::PhaseParameter(),
3699 &Type::ZoneHandle(Z, Type::SmiType())); 3701 &Type::ZoneHandle(Z, Type::SmiType()));
3700 } 3702 }
3701 if (are_implicitly_final) { 3703 if (are_implicitly_final) {
3702 method->params.SetImplicitlyFinal(); 3704 method->params.SetImplicitlyFinal();
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
4149 /* is_external = */ false, 4151 /* is_external = */ false,
4150 /* is_native = */ false, 4152 /* is_native = */ false,
4151 current_class(), 4153 current_class(),
4152 field->name_pos); 4154 field->name_pos);
4153 ParamList params; 4155 ParamList params;
4154 ASSERT(current_class().raw() == setter.Owner()); 4156 ASSERT(current_class().raw() == setter.Owner());
4155 params.AddReceiver(ReceiverType(current_class()), field->name_pos); 4157 params.AddReceiver(ReceiverType(current_class()), field->name_pos);
4156 params.AddFinalParameter(TokenPos(), 4158 params.AddFinalParameter(TokenPos(),
4157 &Symbols::Value(), 4159 &Symbols::Value(),
4158 field->type); 4160 field->type);
4159 setter.set_result_type(Type::Handle(Z, Type::VoidType())); 4161 setter.set_result_type(Object::void_type());
4160 setter.set_is_debuggable(false); 4162 setter.set_is_debuggable(false);
4161 if (library_.is_dart_scheme() && library_.IsPrivate(*field->name)) { 4163 if (library_.is_dart_scheme() && library_.IsPrivate(*field->name)) {
4162 setter.set_is_reflectable(false); 4164 setter.set_is_reflectable(false);
4163 } 4165 }
4164 AddFormalParamsToFunction(&params, setter); 4166 AddFormalParamsToFunction(&params, setter);
4165 members->AddFunction(setter); 4167 members->AddFunction(setter);
4166 } 4168 }
4167 } 4169 }
4168 4170
4169 if (CurrentToken() != Token::kCOMMA) { 4171 if (CurrentToken() != Token::kCOMMA) {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
4253 if (CurrentToken() == Token::kVAR) { 4255 if (CurrentToken() == Token::kVAR) {
4254 if (member.has_const) { 4256 if (member.has_const) {
4255 ReportError("identifier expected after 'const'"); 4257 ReportError("identifier expected after 'const'");
4256 } 4258 }
4257 if (member.has_final) { 4259 if (member.has_final) {
4258 ReportError("identifier expected after 'final'"); 4260 ReportError("identifier expected after 'final'");
4259 } 4261 }
4260 ConsumeToken(); 4262 ConsumeToken();
4261 member.has_var = true; 4263 member.has_var = true;
4262 // The member type is the 'dynamic' type. 4264 // The member type is the 'dynamic' type.
4263 member.type = &Type::ZoneHandle(Z, Type::DynamicType()); 4265 member.type = &Object::dynamic_type();
4264 } else if (CurrentToken() == Token::kFACTORY) { 4266 } else if (CurrentToken() == Token::kFACTORY) {
4265 ConsumeToken(); 4267 ConsumeToken();
4266 if (member.has_static) { 4268 if (member.has_static) {
4267 ReportError("factory method cannot be explicitly marked static"); 4269 ReportError("factory method cannot be explicitly marked static");
4268 } 4270 }
4269 member.has_factory = true; 4271 member.has_factory = true;
4270 member.has_static = true; 4272 member.has_static = true;
4271 // The result type depends on the name of the factory method. 4273 // The result type depends on the name of the factory method.
4272 } 4274 }
4273 // Optionally parse a type. 4275 // Optionally parse a type.
4274 if (CurrentToken() == Token::kVOID) { 4276 if (CurrentToken() == Token::kVOID) {
4275 if (member.has_var || member.has_factory) { 4277 if (member.has_var || member.has_factory) {
4276 ReportError("void not expected"); 4278 ReportError("void not expected");
4277 } 4279 }
4278 ConsumeToken(); 4280 ConsumeToken();
4279 ASSERT(member.type == NULL); 4281 ASSERT(member.type == NULL);
4280 member.type = &Type::ZoneHandle(Z, Type::VoidType()); 4282 member.type = &Object::void_type();
4281 } else if (CurrentToken() == Token::kIDENT) { 4283 } else if (CurrentToken() == Token::kIDENT) {
4282 // This is either a type name or the name of a method/constructor/field. 4284 // This is either a type name or the name of a method/constructor/field.
4283 if ((member.type == NULL) && !member.has_factory) { 4285 if ((member.type == NULL) && !member.has_factory) {
4284 // We have not seen a member type yet, so we check if the next 4286 // We have not seen a member type yet, so we check if the next
4285 // identifier could represent a type before parsing it. 4287 // identifier could represent a type before parsing it.
4286 Token::Kind follower = LookaheadToken(1); 4288 Token::Kind follower = LookaheadToken(1);
4287 // We have an identifier followed by a 'follower' token. 4289 // We have an identifier followed by a 'follower' token.
4288 // We either parse a type or assume that no type is specified. 4290 // We either parse a type or assume that no type is specified.
4289 if ((follower == Token::kLT) || // Parameterized type. 4291 if ((follower == Token::kLT) || // Parameterized type.
4290 (follower == Token::kGET) || // Getter following a type. 4292 (follower == Token::kGET) || // Getter following a type.
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
4365 (LookaheadToken(1) != Token::kCOMMA) && 4367 (LookaheadToken(1) != Token::kCOMMA) &&
4366 (LookaheadToken(1) != Token::kSEMICOLON)) { 4368 (LookaheadToken(1) != Token::kSEMICOLON)) {
4367 ConsumeToken(); 4369 ConsumeToken();
4368 member.kind = RawFunction::kSetterFunction; 4370 member.kind = RawFunction::kSetterFunction;
4369 member.name_pos = this->TokenPos(); 4371 member.name_pos = this->TokenPos();
4370 member.name = ExpectIdentifier("identifier expected"); 4372 member.name = ExpectIdentifier("identifier expected");
4371 CheckToken(Token::kLPAREN); 4373 CheckToken(Token::kLPAREN);
4372 // The grammar allows a return type, so member.type is not always NULL here. 4374 // The grammar allows a return type, so member.type is not always NULL here.
4373 // If no return type is specified, the return type of the setter is dynamic. 4375 // If no return type is specified, the return type of the setter is dynamic.
4374 if (member.type == NULL) { 4376 if (member.type == NULL) {
4375 member.type = &Type::ZoneHandle(Z, Type::DynamicType()); 4377 member.type = &Object::dynamic_type();
4376 } 4378 }
4377 } else if ((CurrentToken() == Token::kOPERATOR) && !member.has_var && 4379 } else if ((CurrentToken() == Token::kOPERATOR) && !member.has_var &&
4378 (LookaheadToken(1) != Token::kLPAREN) && 4380 (LookaheadToken(1) != Token::kLPAREN) &&
4379 (LookaheadToken(1) != Token::kASSIGN) && 4381 (LookaheadToken(1) != Token::kASSIGN) &&
4380 (LookaheadToken(1) != Token::kCOMMA) && 4382 (LookaheadToken(1) != Token::kCOMMA) &&
4381 (LookaheadToken(1) != Token::kSEMICOLON)) { 4383 (LookaheadToken(1) != Token::kSEMICOLON)) {
4382 ConsumeToken(); 4384 ConsumeToken();
4383 if (!Token::CanBeOverloaded(CurrentToken())) { 4385 if (!Token::CanBeOverloaded(CurrentToken())) {
4384 ReportError("invalid operator overloading"); 4386 ReportError("invalid operator overloading");
4385 } 4387 }
(...skipping 12 matching lines...) Expand all
4398 member.name_pos = TokenPos(); 4400 member.name_pos = TokenPos();
4399 ConsumeToken(); 4401 ConsumeToken();
4400 } else { 4402 } else {
4401 ReportError("identifier expected"); 4403 ReportError("identifier expected");
4402 } 4404 }
4403 4405
4404 ASSERT(member.name != NULL); 4406 ASSERT(member.name != NULL);
4405 if (CurrentToken() == Token::kLPAREN || member.IsGetter()) { 4407 if (CurrentToken() == Token::kLPAREN || member.IsGetter()) {
4406 // Constructor or method. 4408 // Constructor or method.
4407 if (member.type == NULL) { 4409 if (member.type == NULL) {
4408 member.type = &Type::ZoneHandle(Z, Type::DynamicType()); 4410 member.type = &Object::dynamic_type();
4409 } 4411 }
4410 ASSERT(member.IsFactory() == member.has_factory); 4412 ASSERT(member.IsFactory() == member.has_factory);
4411 ParseMethodOrConstructor(members, &member); 4413 ParseMethodOrConstructor(members, &member);
4412 } else if (CurrentToken() == Token::kSEMICOLON || 4414 } else if (CurrentToken() == Token::kSEMICOLON ||
4413 CurrentToken() == Token::kCOMMA || 4415 CurrentToken() == Token::kCOMMA ||
4414 CurrentToken() == Token::kASSIGN) { 4416 CurrentToken() == Token::kASSIGN) {
4415 // Field definition. 4417 // Field definition.
4416 if (member.has_const) { 4418 if (member.has_const) {
4417 // const fields are implicitly final. 4419 // const fields are implicitly final.
4418 member.has_final = true; 4420 member.has_final = true;
4419 } 4421 }
4420 if (member.type == NULL) { 4422 if (member.type == NULL) {
4421 if (member.has_final) { 4423 if (member.has_final) {
4422 member.type = &Type::ZoneHandle(Z, Type::DynamicType()); 4424 member.type = &Object::dynamic_type();
4423 } else { 4425 } else {
4424 ReportError("missing 'var', 'final', 'const' or type" 4426 ReportError("missing 'var', 'final', 'const' or type"
4425 " in field declaration"); 4427 " in field declaration");
4426 } 4428 }
4427 } 4429 }
4428 ParseFieldDefinition(members, &member); 4430 ParseFieldDefinition(members, &member);
4429 } else { 4431 } else {
4430 UnexpectedToken(); 4432 UnexpectedToken();
4431 } 4433 }
4432 current_member_ = NULL; 4434 current_member_ = NULL;
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after
5139 &result_type); 5141 &result_type);
5140 } 5142 }
5141 // Parse the formal parameters of the function type. 5143 // Parse the formal parameters of the function type.
5142 CheckToken(Token::kLPAREN, "formal parameter list expected"); 5144 CheckToken(Token::kLPAREN, "formal parameter list expected");
5143 ParamList func_params; 5145 ParamList func_params;
5144 5146
5145 // Add implicit closure object parameter. 5147 // Add implicit closure object parameter.
5146 func_params.AddFinalParameter( 5148 func_params.AddFinalParameter(
5147 TokenPos(), 5149 TokenPos(),
5148 &Symbols::ClosureParameter(), 5150 &Symbols::ClosureParameter(),
5149 &Type::ZoneHandle(Z, Type::DynamicType())); 5151 &Object::dynamic_type());
5150 5152
5151 const bool no_explicit_default_values = false; 5153 const bool no_explicit_default_values = false;
5152 ParseFormalParameterList(no_explicit_default_values, false, &func_params); 5154 ParseFormalParameterList(no_explicit_default_values, false, &func_params);
5153 ExpectSemicolon(); 5155 ExpectSemicolon();
5154 // The field 'is_static' has no meaning for signature functions. 5156 // The field 'is_static' has no meaning for signature functions.
5155 Function& signature_function = Function::Handle(Z, 5157 Function& signature_function = Function::Handle(Z,
5156 Function::New(*alias_name, 5158 Function::New(*alias_name,
5157 RawFunction::kSignatureFunction, 5159 RawFunction::kSignatureFunction,
5158 /* is_static = */ false, 5160 /* is_static = */ false,
5159 /* is_const = */ false, 5161 /* is_const = */ false,
(...skipping 1473 matching lines...) Expand 10 before | Expand all | Expand 10 after
6633 } else { 6635 } else {
6634 // Create the closure containing the body of this generator function. 6636 // Create the closure containing the body of this generator function.
6635 String& generator_name = String::Handle(Z, innermost_function().name()); 6637 String& generator_name = String::Handle(Z, innermost_function().name());
6636 body_closure_name = 6638 body_closure_name =
6637 Symbols::NewFormatted("<%s_sync_body>", generator_name.ToCString()); 6639 Symbols::NewFormatted("<%s_sync_body>", generator_name.ToCString());
6638 body_closure_name = Symbols::New(body_closure_name); 6640 body_closure_name = Symbols::New(body_closure_name);
6639 body = Function::NewClosureFunction(body_closure_name, 6641 body = Function::NewClosureFunction(body_closure_name,
6640 innermost_function(), 6642 innermost_function(),
6641 func_pos); 6643 func_pos);
6642 body.set_is_generated_body(true); 6644 body.set_is_generated_body(true);
6643 body.set_result_type(AbstractType::Handle(Type::DynamicType())); 6645 body.set_result_type(Object::dynamic_type());
6644 is_new_closure = true; 6646 is_new_closure = true;
6645 } 6647 }
6646 6648
6647 ParamList closure_params; 6649 ParamList closure_params;
6648 AddSyncGenClosureParameters(&closure_params); 6650 AddSyncGenClosureParameters(&closure_params);
6649 6651
6650 if (is_new_closure) { 6652 if (is_new_closure) {
6651 // Add the parameters to the newly created closure. 6653 // Add the parameters to the newly created closure.
6652 AddFormalParamsToFunction(&closure_params, body); 6654 AddFormalParamsToFunction(&closure_params, body);
6653 6655
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
6771 // Create the closure containing the body of this async function. 6773 // Create the closure containing the body of this async function.
6772 const String& async_func_name = 6774 const String& async_func_name =
6773 String::Handle(Z, innermost_function().name()); 6775 String::Handle(Z, innermost_function().name());
6774 String& closure_name = String::Handle(Z, 6776 String& closure_name = String::Handle(Z,
6775 Symbols::NewFormatted("<%s_async_body>", async_func_name.ToCString())); 6777 Symbols::NewFormatted("<%s_async_body>", async_func_name.ToCString()));
6776 closure = Function::NewClosureFunction( 6778 closure = Function::NewClosureFunction(
6777 closure_name, 6779 closure_name,
6778 innermost_function(), 6780 innermost_function(),
6779 async_func_pos); 6781 async_func_pos);
6780 closure.set_is_generated_body(true); 6782 closure.set_is_generated_body(true);
6781 closure.set_result_type(AbstractType::Handle(Type::DynamicType())); 6783 closure.set_result_type(Object::dynamic_type());
6782 is_new_closure = true; 6784 is_new_closure = true;
6783 } 6785 }
6784 // Create the parameter list for the async body closure. 6786 // Create the parameter list for the async body closure.
6785 ParamList closure_params; 6787 ParamList closure_params;
6786 AddAsyncClosureParameters(&closure_params); 6788 AddAsyncClosureParameters(&closure_params);
6787 if (is_new_closure) { 6789 if (is_new_closure) {
6788 // Add the parameters to the newly created closure. 6790 // Add the parameters to the newly created closure.
6789 AddFormalParamsToFunction(&closure_params, closure); 6791 AddFormalParamsToFunction(&closure_params, closure);
6790 6792
6791 // Create and set the signature class of the closure. 6793 // Create and set the signature class of the closure.
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
6905 const String& async_generator_name = 6907 const String& async_generator_name =
6906 String::Handle(Z, innermost_function().name()); 6908 String::Handle(Z, innermost_function().name());
6907 String& closure_name = String::Handle(Z, 6909 String& closure_name = String::Handle(Z,
6908 Symbols::NewFormatted("<%s_async_gen_body>", 6910 Symbols::NewFormatted("<%s_async_gen_body>",
6909 async_generator_name.ToCString())); 6911 async_generator_name.ToCString()));
6910 closure = Function::NewClosureFunction( 6912 closure = Function::NewClosureFunction(
6911 String::Handle(Z, Symbols::New(closure_name)), 6913 String::Handle(Z, Symbols::New(closure_name)),
6912 innermost_function(), 6914 innermost_function(),
6913 async_func_pos); 6915 async_func_pos);
6914 closure.set_is_generated_body(true); 6916 closure.set_is_generated_body(true);
6915 closure.set_result_type(AbstractType::Handle(Type::DynamicType())); 6917 closure.set_result_type(Object::dynamic_type());
6916 is_new_closure = true; 6918 is_new_closure = true;
6917 } 6919 }
6918 6920
6919 ParamList closure_params; 6921 ParamList closure_params;
6920 AddAsyncGenClosureParameters(&closure_params); 6922 AddAsyncGenClosureParameters(&closure_params);
6921 6923
6922 if (is_new_closure) { 6924 if (is_new_closure) {
6923 // Add the parameters to the newly created closure. 6925 // Add the parameters to the newly created closure.
6924 AddFormalParamsToFunction(&closure_params, closure); 6926 AddFormalParamsToFunction(&closure_params, closure);
6925 6927
(...skipping 1761 matching lines...) Expand 10 before | Expand all | Expand 10 after
8687 Function::ZoneHandle(Z, stream_iterator_cls.LookupFunction( 8689 Function::ZoneHandle(Z, stream_iterator_cls.LookupFunction(
8688 Symbols::StreamIteratorConstructor())); 8690 Symbols::StreamIteratorConstructor()));
8689 ASSERT(!iterator_ctor.IsNull()); 8691 ASSERT(!iterator_ctor.IsNull());
8690 ArgumentListNode* ctor_args = new (Z) ArgumentListNode(stream_expr_pos); 8692 ArgumentListNode* ctor_args = new (Z) ArgumentListNode(stream_expr_pos);
8691 ctor_args->Add(stream_expr); 8693 ctor_args->Add(stream_expr);
8692 ConstructorCallNode* ctor_call = 8694 ConstructorCallNode* ctor_call =
8693 new (Z) ConstructorCallNode(stream_expr_pos, 8695 new (Z) ConstructorCallNode(stream_expr_pos,
8694 TypeArguments::ZoneHandle(Z), 8696 TypeArguments::ZoneHandle(Z),
8695 iterator_ctor, 8697 iterator_ctor,
8696 ctor_args); 8698 ctor_args);
8697 const AbstractType& iterator_type = Type::ZoneHandle(Z, Type::DynamicType()); 8699 const AbstractType& iterator_type = Object::dynamic_type();
8698 LocalVariable* iterator_var = new(Z) LocalVariable( 8700 LocalVariable* iterator_var = new(Z) LocalVariable(
8699 stream_expr_pos, Symbols::ForInIter(), iterator_type); 8701 stream_expr_pos, Symbols::ForInIter(), iterator_type);
8700 current_block_->scope->AddVariable(iterator_var); 8702 current_block_->scope->AddVariable(iterator_var);
8701 AstNode* iterator_init = 8703 AstNode* iterator_init =
8702 new(Z) StoreLocalNode(stream_expr_pos, iterator_var, ctor_call); 8704 new(Z) StoreLocalNode(stream_expr_pos, iterator_var, ctor_call);
8703 current_block_->statements->Add(iterator_init); 8705 current_block_->statements->Add(iterator_init);
8704 8706
8705 // We need to ensure that the stream is cancelled after the loop. 8707 // We need to ensure that the stream is cancelled after the loop.
8706 // Thus, wrap the loop in a try-finally that calls :for-in-iter.close() 8708 // Thus, wrap the loop in a try-finally that calls :for-in-iter.close()
8707 // in the finally clause. It is harmless to call close() if the stream 8709 // in the finally clause. It is harmless to call close() if the stream
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
8952 ExpectToken(Token::kRPAREN); 8954 ExpectToken(Token::kRPAREN);
8953 8955
8954 OpenBlock(); // Implicit block around while loop. 8956 OpenBlock(); // Implicit block around while loop.
8955 8957
8956 // Generate implicit iterator variable and add to scope. 8958 // Generate implicit iterator variable and add to scope.
8957 // We could set the type of the implicit iterator variable to Iterator<T> 8959 // We could set the type of the implicit iterator variable to Iterator<T>
8958 // where T is the type of the for loop variable. However, the type error 8960 // where T is the type of the for loop variable. However, the type error
8959 // would refer to the compiler generated iterator and could confuse the user. 8961 // would refer to the compiler generated iterator and could confuse the user.
8960 // It is better to leave the iterator untyped and postpone the type error 8962 // It is better to leave the iterator untyped and postpone the type error
8961 // until the loop variable is assigned to. 8963 // until the loop variable is assigned to.
8962 const AbstractType& iterator_type = Type::ZoneHandle(Z, Type::DynamicType()); 8964 const AbstractType& iterator_type = Object::dynamic_type();
8963 LocalVariable* iterator_var = new(Z) LocalVariable( 8965 LocalVariable* iterator_var = new(Z) LocalVariable(
8964 collection_pos, Symbols::ForInIter(), iterator_type); 8966 collection_pos, Symbols::ForInIter(), iterator_type);
8965 current_block_->scope->AddVariable(iterator_var); 8967 current_block_->scope->AddVariable(iterator_var);
8966 8968
8967 // Generate initialization of iterator variable. 8969 // Generate initialization of iterator variable.
8968 ArgumentListNode* no_args = new(Z) ArgumentListNode(collection_pos); 8970 ArgumentListNode* no_args = new(Z) ArgumentListNode(collection_pos);
8969 AstNode* get_iterator = new(Z) InstanceGetterNode( 8971 AstNode* get_iterator = new(Z) InstanceGetterNode(
8970 collection_pos, collection_expr, Symbols::Iterator()); 8972 collection_pos, collection_expr, Symbols::Iterator());
8971 AstNode* iterator_init = 8973 AstNode* iterator_init =
8972 new(Z) StoreLocalNode(collection_pos, iterator_var, get_iterator); 8974 new(Z) StoreLocalNode(collection_pos, iterator_var, get_iterator);
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
9381 // closed in the loop that builds the if-then-else nest. 9383 // closed in the loop that builds the if-then-else nest.
9382 OpenBlock(); 9384 OpenBlock();
9383 const intptr_t catch_pos = TokenPos(); 9385 const intptr_t catch_pos = TokenPos();
9384 CatchParamDesc exception_param; 9386 CatchParamDesc exception_param;
9385 CatchParamDesc stack_trace_param; 9387 CatchParamDesc stack_trace_param;
9386 if (IsSymbol(Symbols::On())) { 9388 if (IsSymbol(Symbols::On())) {
9387 ConsumeToken(); 9389 ConsumeToken();
9388 exception_param.type = &AbstractType::ZoneHandle(Z, 9390 exception_param.type = &AbstractType::ZoneHandle(Z,
9389 ParseType(ClassFinalizer::kCanonicalize)); 9391 ParseType(ClassFinalizer::kCanonicalize));
9390 } else { 9392 } else {
9391 exception_param.type = &AbstractType::ZoneHandle(Z, Type::DynamicType()); 9393 exception_param.type = &Object::dynamic_type();
9392 } 9394 }
9393 if (CurrentToken() == Token::kCATCH) { 9395 if (CurrentToken() == Token::kCATCH) {
9394 ConsumeToken(); // Consume the 'catch'. 9396 ConsumeToken(); // Consume the 'catch'.
9395 ExpectToken(Token::kLPAREN); 9397 ExpectToken(Token::kLPAREN);
9396 exception_param.token_pos = TokenPos(); 9398 exception_param.token_pos = TokenPos();
9397 exception_param.name = ExpectIdentifier("identifier expected"); 9399 exception_param.name = ExpectIdentifier("identifier expected");
9398 if (CurrentToken() == Token::kCOMMA) { 9400 if (CurrentToken() == Token::kCOMMA) {
9399 ConsumeToken(); 9401 ConsumeToken();
9400 stack_trace_param.type = 9402 stack_trace_param.type = &Object::dynamic_type();
9401 &AbstractType::ZoneHandle(Z, Type::DynamicType());
9402 stack_trace_param.token_pos = TokenPos(); 9403 stack_trace_param.token_pos = TokenPos();
9403 stack_trace_param.name = ExpectIdentifier("identifier expected"); 9404 stack_trace_param.name = ExpectIdentifier("identifier expected");
9404 } 9405 }
9405 ExpectToken(Token::kRPAREN); 9406 ExpectToken(Token::kRPAREN);
9406 } 9407 }
9407 9408
9408 // Create a block containing the catch clause parameters and the 9409 // Create a block containing the catch clause parameters and the
9409 // following code: 9410 // following code:
9410 // 1) Store exception object and stack trace object into user-defined 9411 // 1) Store exception object and stack trace object into user-defined
9411 // variables (as needed). 9412 // variables (as needed).
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
9572 9573
9573 9574
9574 void Parser::SetupSavedTryContext(LocalVariable* saved_try_context) { 9575 void Parser::SetupSavedTryContext(LocalVariable* saved_try_context) {
9575 const String& async_saved_try_ctx_name = String::ZoneHandle(Z, 9576 const String& async_saved_try_ctx_name = String::ZoneHandle(Z,
9576 Symbols::NewFormatted("%s%d", 9577 Symbols::NewFormatted("%s%d",
9577 Symbols::AsyncSavedTryCtxVarPrefix().ToCString(), 9578 Symbols::AsyncSavedTryCtxVarPrefix().ToCString(),
9578 last_used_try_index_ - 1)); 9579 last_used_try_index_ - 1));
9579 LocalVariable* async_saved_try_ctx = new (Z) LocalVariable( 9580 LocalVariable* async_saved_try_ctx = new (Z) LocalVariable(
9580 Scanner::kNoSourcePos, 9581 Scanner::kNoSourcePos,
9581 async_saved_try_ctx_name, 9582 async_saved_try_ctx_name,
9582 Type::ZoneHandle(Z, Type::DynamicType())); 9583 Object::dynamic_type());
9583 ASSERT(async_temp_scope_ != NULL); 9584 ASSERT(async_temp_scope_ != NULL);
9584 async_temp_scope_->AddVariable(async_saved_try_ctx); 9585 async_temp_scope_->AddVariable(async_saved_try_ctx);
9585 ASSERT(saved_try_context != NULL); 9586 ASSERT(saved_try_context != NULL);
9586 current_block_->statements->Add(new(Z) StoreLocalNode( 9587 current_block_->statements->Add(new(Z) StoreLocalNode(
9587 Scanner::kNoSourcePos, 9588 Scanner::kNoSourcePos,
9588 async_saved_try_ctx, 9589 async_saved_try_ctx,
9589 new(Z) LoadLocalNode(Scanner::kNoSourcePos, saved_try_context))); 9590 new(Z) LoadLocalNode(Scanner::kNoSourcePos, saved_try_context)));
9590 } 9591 }
9591 9592
9592 9593
(...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after
10536 } 10537 }
10537 10538
10538 10539
10539 LocalVariable* Parser::CreateTempConstVariable(intptr_t token_pos, 10540 LocalVariable* Parser::CreateTempConstVariable(intptr_t token_pos,
10540 const char* s) { 10541 const char* s) {
10541 char name[64]; 10542 char name[64];
10542 OS::SNPrint(name, 64, ":%s%" Pd, s, token_pos); 10543 OS::SNPrint(name, 64, ":%s%" Pd, s, token_pos);
10543 LocalVariable* temp = new(Z) LocalVariable( 10544 LocalVariable* temp = new(Z) LocalVariable(
10544 token_pos, 10545 token_pos,
10545 String::ZoneHandle(Z, Symbols::New(name)), 10546 String::ZoneHandle(Z, Symbols::New(name)),
10546 Type::ZoneHandle(Z, Type::DynamicType())); 10547 Object::dynamic_type());
10547 temp->set_is_final(); 10548 temp->set_is_final();
10548 current_block_->scope->AddVariable(temp); 10549 current_block_->scope->AddVariable(temp);
10549 return temp; 10550 return temp;
10550 } 10551 }
10551 10552
10552 10553
10553 // TODO(srdjan): Implement other optimizations. 10554 // TODO(srdjan): Implement other optimizations.
10554 AstNode* Parser::OptimizeBinaryOpNode(intptr_t op_pos, 10555 AstNode* Parser::OptimizeBinaryOpNode(intptr_t op_pos,
10555 Token::Kind binary_op, 10556 Token::Kind binary_op,
10556 AstNode* lhs, 10557 AstNode* lhs,
(...skipping 2614 matching lines...) Expand 10 before | Expand all | Expand 10 after
13171 return closure.raw(); 13172 return closure.raw();
13172 } 13173 }
13173 13174
13174 String& closure_name = String::Handle(Z, ctr.name()); 13175 String& closure_name = String::Handle(Z, ctr.name());
13175 closure_name = Symbols::FromConcat(Symbols::ConstructorClosurePrefix(), 13176 closure_name = Symbols::FromConcat(Symbols::ConstructorClosurePrefix(),
13176 closure_name); 13177 closure_name);
13177 13178
13178 ParamList params; 13179 ParamList params;
13179 params.AddFinalParameter(token_pos, 13180 params.AddFinalParameter(token_pos,
13180 &Symbols::ClosureParameter(), 13181 &Symbols::ClosureParameter(),
13181 &Type::ZoneHandle(Z, Type::DynamicType())); 13182 &Object::dynamic_type());
13182 13183
13183 ParseFormalParameters(ctr, &params); 13184 ParseFormalParameters(ctr, &params);
13184 // Per language spec, the type of the closure parameters is dynamic. 13185 // Per language spec, the type of the closure parameters is dynamic.
13185 // Replace the types parsed from the constructor. 13186 // Replace the types parsed from the constructor.
13186 params.EraseParameterTypes(); 13187 params.EraseParameterTypes();
13187 13188
13188 closure = Function::NewClosureFunction(closure_name, 13189 closure = Function::NewClosureFunction(closure_name,
13189 innermost_function(), 13190 innermost_function(),
13190 token_pos); 13191 token_pos);
13191 closure.set_is_generated_body(true); 13192 closure.set_is_generated_body(true);
13192 closure.set_is_debuggable(false); 13193 closure.set_is_debuggable(false);
13193 closure.set_is_visible(false); 13194 closure.set_is_visible(false);
13194 closure.set_result_type(AbstractType::Handle(Type::DynamicType())); 13195 closure.set_result_type(Object::dynamic_type());
13195 AddFormalParamsToFunction(&params, closure); 13196 AddFormalParamsToFunction(&params, closure);
13196 13197
13197 // Create and set the signature class of the closure. 13198 // Create and set the signature class of the closure.
13198 const String& sig = String::Handle(Z, closure.Signature()); 13199 const String& sig = String::Handle(Z, closure.Signature());
13199 Class& sig_cls = Class::Handle(Z, library_.LookupLocalClass(sig)); 13200 Class& sig_cls = Class::Handle(Z, library_.LookupLocalClass(sig));
13200 if (sig_cls.IsNull()) { 13201 if (sig_cls.IsNull()) {
13201 sig_cls = Class::NewSignatureClass(sig, closure, script_, token_pos); 13202 sig_cls = Class::NewSignatureClass(sig, closure, script_, token_pos);
13202 library_.AddClass(sig_cls); 13203 library_.AddClass(sig_cls);
13203 } 13204 }
13204 closure.set_signature_class(sig_cls); 13205 closure.set_signature_class(sig_cls);
(...skipping 1258 matching lines...) Expand 10 before | Expand all | Expand 10 after
14463 const ArgumentListNode& function_args, 14464 const ArgumentListNode& function_args,
14464 const LocalVariable* temp_for_last_arg, 14465 const LocalVariable* temp_for_last_arg,
14465 bool is_super_invocation) { 14466 bool is_super_invocation) {
14466 UNREACHABLE(); 14467 UNREACHABLE();
14467 return NULL; 14468 return NULL;
14468 } 14469 }
14469 14470
14470 } // namespace dart 14471 } // namespace dart
14471 14472
14472 #endif // DART_PRECOMPILED 14473 #endif // DART_PRECOMPILED
OLDNEW
« no previous file with comments | « runtime/vm/parser.h ('k') | runtime/vm/regexp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698