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

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

Issue 23224016: Implement ParameterMirror.metadata. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 months 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 | Annotate | Revision Log
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 6
7 #include "lib/invocation_mirror.h" 7 #include "lib/invocation_mirror.h"
8 #include "vm/bigint_operations.h" 8 #include "vm/bigint_operations.h"
9 #include "vm/bootstrap.h" 9 #include "vm/bootstrap.h"
10 #include "vm/class_finalizer.h" 10 #include "vm/class_finalizer.h"
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 String* ident; 425 String* ident;
426 }; 426 };
427 427
428 428
429 struct ParamDesc { 429 struct ParamDesc {
430 ParamDesc() 430 ParamDesc()
431 : type(NULL), 431 : type(NULL),
432 name_pos(0), 432 name_pos(0),
433 name(NULL), 433 name(NULL),
434 default_value(NULL), 434 default_value(NULL),
435 metadata(NULL),
435 is_final(false), 436 is_final(false),
436 is_field_initializer(false) { } 437 is_field_initializer(false) { }
437 const AbstractType* type; 438 const AbstractType* type;
438 intptr_t name_pos; 439 intptr_t name_pos;
439 const String* name; 440 const String* name;
440 const Object* default_value; // NULL if not an optional parameter. 441 const Object* default_value; // NULL if not an optional parameter.
442 const Object* metadata; // NULL if no metadata or metadata not evaluated.
441 bool is_final; 443 bool is_final;
442 bool is_field_initializer; 444 bool is_field_initializer;
443 }; 445 };
444 446
445 447
446 struct ParamList { 448 struct ParamList {
447 ParamList() { 449 ParamList() {
448 Clear(); 450 Clear();
449 } 451 }
450 452
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 isolate->set_long_jump_base(&jump); 786 isolate->set_long_jump_base(&jump);
785 if (setjmp(*jump.Set()) == 0) { 787 if (setjmp(*jump.Set()) == 0) {
786 const Script& script = Script::Handle(isolate, func.script()); 788 const Script& script = Script::Handle(isolate, func.script());
787 const Class& owner = Class::Handle(isolate, func.Owner()); 789 const Class& owner = Class::Handle(isolate, func.Owner());
788 ASSERT(!owner.IsNull()); 790 ASSERT(!owner.IsNull());
789 const Library& lib = Library::Handle(isolate, owner.library()); 791 const Library& lib = Library::Handle(isolate, owner.library());
790 Parser parser(script, lib, func.token_pos()); 792 Parser parser(script, lib, func.token_pos());
791 parser.set_current_class(owner); 793 parser.set_current_class(owner);
792 parser.SkipFunctionPreamble(); 794 parser.SkipFunctionPreamble();
793 ParamList params; 795 ParamList params;
794 parser.ParseFormalParameterList(true, &params); 796 parser.ParseFormalParameterList(true, true, &params);
795 ParamDesc* param = params.parameters->data(); 797 ParamDesc* param = params.parameters->data();
796 const int param_cnt = params.num_fixed_parameters + 798 const int param_cnt = params.num_fixed_parameters +
797 params.num_optional_parameters; 799 params.num_optional_parameters;
798 Array& param_descriptor = Array::Handle(isolate, Array::New(param_cnt * 2)); 800 Array& param_descriptor = Array::Handle(Array::New(param_cnt * 3));
799 for (int i = 0, j = 0; i < param_cnt; i++, j += 2) { 801 for (int i = 0, j = 0; i < param_cnt; i++, j += 3) {
800 param_descriptor.SetAt(j, param[i].is_final ? Bool::True() : 802 param_descriptor.SetAt(j, param[i].is_final ? Bool::True() :
siva 2013/08/28 23:26:48 Ditto comment about '3' here.
801 Bool::False()); 803 Bool::False());
802 param_descriptor.SetAt(j + 1, 804 param_descriptor.SetAt(j + 1,
803 (param[i].default_value == NULL) ? Object::null_instance() : 805 (param[i].default_value == NULL) ? Object::null_instance() :
804 *(param[i].default_value)); 806 *(param[i].default_value));
807 const Object* metadata = param[i].metadata;
808 if ((metadata != NULL) && (*metadata).IsError()) {
809 return (*metadata).raw(); // Error evaluating the metadata.
810 }
811 param_descriptor.SetAt(j + 2,
812 (param[i].metadata == NULL) ? Object::null_instance() :
813 *(param[i].metadata));
805 } 814 }
806 isolate->set_long_jump_base(base); 815 isolate->set_long_jump_base(base);
807 return param_descriptor.raw(); 816 return param_descriptor.raw();
808 } else { 817 } else {
809 Error& error = Error::Handle(); 818 Error& error = Error::Handle();
810 error = isolate->object_store()->sticky_error(); 819 error = isolate->object_store()->sticky_error();
811 isolate->object_store()->clear_sticky_error(); 820 isolate->object_store()->clear_sticky_error();
812 isolate->set_long_jump_base(base); 821 isolate->set_long_jump_base(base);
813 return error.raw(); 822 return error.raw();
814 } 823 }
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
1374 } while (!token_stack.is_empty() && is_match && !unexpected_token_found); 1383 } while (!token_stack.is_empty() && is_match && !unexpected_token_found);
1375 if (!is_match) { 1384 if (!is_match) {
1376 ErrorMsg(token_pos, "unbalanced '%s'", Token::Str(token)); 1385 ErrorMsg(token_pos, "unbalanced '%s'", Token::Str(token));
1377 } else if (unexpected_token_found) { 1386 } else if (unexpected_token_found) {
1378 ErrorMsg(block_start_pos, "unterminated block"); 1387 ErrorMsg(block_start_pos, "unterminated block");
1379 } 1388 }
1380 } 1389 }
1381 1390
1382 1391
1383 void Parser::ParseFormalParameter(bool allow_explicit_default_value, 1392 void Parser::ParseFormalParameter(bool allow_explicit_default_value,
1393 bool evaluate_metadata,
1384 ParamList* params) { 1394 ParamList* params) {
1385 TRACE_PARSER("ParseFormalParameter"); 1395 TRACE_PARSER("ParseFormalParameter");
1386 ParamDesc parameter; 1396 ParamDesc parameter;
1387 bool var_seen = false; 1397 bool var_seen = false;
1388 bool this_seen = false; 1398 bool this_seen = false;
1389 1399
1390 SkipMetadata(); 1400 if (evaluate_metadata && (CurrentToken() == Token::kAT)) {
1401 parameter.metadata = &Array::ZoneHandle(EvaluateMetadata());
1402 } else {
1403 SkipMetadata();
1404 }
1405
1391 if (CurrentToken() == Token::kFINAL) { 1406 if (CurrentToken() == Token::kFINAL) {
1392 ConsumeToken(); 1407 ConsumeToken();
1393 parameter.is_final = true; 1408 parameter.is_final = true;
1394 } else if (CurrentToken() == Token::kVAR) { 1409 } else if (CurrentToken() == Token::kVAR) {
1395 ConsumeToken(); 1410 ConsumeToken();
1396 var_seen = true; 1411 var_seen = true;
1397 // The parameter type is the 'dynamic' type. 1412 // The parameter type is the 'dynamic' type.
1398 parameter.type = &Type::ZoneHandle(Type::DynamicType()); 1413 parameter.type = &Type::ZoneHandle(Type::DynamicType());
1399 } 1414 }
1400 if (CurrentToken() == Token::kTHIS) { 1415 if (CurrentToken() == Token::kTHIS) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1480 // Finish parsing the function type parameter. 1495 // Finish parsing the function type parameter.
1481 ParamList func_params; 1496 ParamList func_params;
1482 1497
1483 // Add implicit closure object parameter. 1498 // Add implicit closure object parameter.
1484 func_params.AddFinalParameter( 1499 func_params.AddFinalParameter(
1485 TokenPos(), 1500 TokenPos(),
1486 &Symbols::ClosureParameter(), 1501 &Symbols::ClosureParameter(),
1487 &Type::ZoneHandle(Type::DynamicType())); 1502 &Type::ZoneHandle(Type::DynamicType()));
1488 1503
1489 const bool no_explicit_default_values = false; 1504 const bool no_explicit_default_values = false;
1490 ParseFormalParameterList(no_explicit_default_values, &func_params); 1505 ParseFormalParameterList(no_explicit_default_values, false, &func_params);
1491 1506
1492 // The field 'is_static' has no meaning for signature functions. 1507 // The field 'is_static' has no meaning for signature functions.
1493 const Function& signature_function = Function::Handle( 1508 const Function& signature_function = Function::Handle(
1494 Function::New(*parameter.name, 1509 Function::New(*parameter.name,
1495 RawFunction::kSignatureFunction, 1510 RawFunction::kSignatureFunction,
1496 /* is_static = */ false, 1511 /* is_static = */ false,
1497 /* is_const = */ false, 1512 /* is_const = */ false,
1498 /* is_abstract = */ false, 1513 /* is_abstract = */ false,
1499 /* is_external = */ false, 1514 /* is_external = */ false,
1500 current_class(), 1515 current_class(),
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1564 } 1579 }
1565 if (parameter.type->IsVoidType()) { 1580 if (parameter.type->IsVoidType()) {
1566 ErrorMsg("parameter '%s' may not be 'void'", parameter.name->ToCString()); 1581 ErrorMsg("parameter '%s' may not be 'void'", parameter.name->ToCString());
1567 } 1582 }
1568 params->parameters->Add(parameter); 1583 params->parameters->Add(parameter);
1569 } 1584 }
1570 1585
1571 1586
1572 // Parses a sequence of normal or optional formal parameters. 1587 // Parses a sequence of normal or optional formal parameters.
1573 void Parser::ParseFormalParameters(bool allow_explicit_default_values, 1588 void Parser::ParseFormalParameters(bool allow_explicit_default_values,
1589 bool evaluate_metadata,
1574 ParamList* params) { 1590 ParamList* params) {
1575 TRACE_PARSER("ParseFormalParameters"); 1591 TRACE_PARSER("ParseFormalParameters");
1576 do { 1592 do {
1577 ConsumeToken(); 1593 ConsumeToken();
1578 if (!params->has_optional_positional_parameters && 1594 if (!params->has_optional_positional_parameters &&
1579 !params->has_optional_named_parameters && 1595 !params->has_optional_named_parameters &&
1580 (CurrentToken() == Token::kLBRACK)) { 1596 (CurrentToken() == Token::kLBRACK)) {
1581 // End of normal parameters, start of optional positional parameters. 1597 // End of normal parameters, start of optional positional parameters.
1582 params->has_optional_positional_parameters = true; 1598 params->has_optional_positional_parameters = true;
1583 return; 1599 return;
1584 } 1600 }
1585 if (!params->has_optional_positional_parameters && 1601 if (!params->has_optional_positional_parameters &&
1586 !params->has_optional_named_parameters && 1602 !params->has_optional_named_parameters &&
1587 (CurrentToken() == Token::kLBRACE)) { 1603 (CurrentToken() == Token::kLBRACE)) {
1588 // End of normal parameters, start of optional named parameters. 1604 // End of normal parameters, start of optional named parameters.
1589 params->has_optional_named_parameters = true; 1605 params->has_optional_named_parameters = true;
1590 return; 1606 return;
1591 } 1607 }
1592 ParseFormalParameter(allow_explicit_default_values, params); 1608 ParseFormalParameter(allow_explicit_default_values,
1609 evaluate_metadata,
1610 params);
1593 } while (CurrentToken() == Token::kCOMMA); 1611 } while (CurrentToken() == Token::kCOMMA);
1594 } 1612 }
1595 1613
1596 1614
1597 void Parser::ParseFormalParameterList(bool allow_explicit_default_values, 1615 void Parser::ParseFormalParameterList(bool allow_explicit_default_values,
1616 bool evaluate_metadata,
1598 ParamList* params) { 1617 ParamList* params) {
1599 TRACE_PARSER("ParseFormalParameterList"); 1618 TRACE_PARSER("ParseFormalParameterList");
1600 ASSERT(CurrentToken() == Token::kLPAREN); 1619 ASSERT(CurrentToken() == Token::kLPAREN);
1601 1620
1602 if (LookaheadToken(1) != Token::kRPAREN) { 1621 if (LookaheadToken(1) != Token::kRPAREN) {
1603 // Parse fixed parameters. 1622 // Parse fixed parameters.
1604 ParseFormalParameters(allow_explicit_default_values, params); 1623 ParseFormalParameters(allow_explicit_default_values,
1624 evaluate_metadata,
1625 params);
1605 if (params->has_optional_positional_parameters || 1626 if (params->has_optional_positional_parameters ||
1606 params->has_optional_named_parameters) { 1627 params->has_optional_named_parameters) {
1607 // Parse optional parameters. 1628 // Parse optional parameters.
1608 ParseFormalParameters(allow_explicit_default_values, params); 1629 ParseFormalParameters(allow_explicit_default_values,
1630 evaluate_metadata,
1631 params);
1609 if (params->has_optional_positional_parameters) { 1632 if (params->has_optional_positional_parameters) {
1610 if (CurrentToken() != Token::kRBRACK) { 1633 if (CurrentToken() != Token::kRBRACK) {
1611 ErrorMsg("',' or ']' expected"); 1634 ErrorMsg("',' or ']' expected");
1612 } 1635 }
1613 } else { 1636 } else {
1614 if (CurrentToken() != Token::kRBRACE) { 1637 if (CurrentToken() != Token::kRBRACE) {
1615 ErrorMsg("',' or '}' expected"); 1638 ErrorMsg("',' or '}' expected");
1616 } 1639 }
1617 } 1640 }
1618 ConsumeToken(); // ']' or '}'. 1641 ConsumeToken(); // ']' or '}'.
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after
2489 2512
2490 // Add implicit parameter for construction phase. 2513 // Add implicit parameter for construction phase.
2491 params.AddFinalParameter( 2514 params.AddFinalParameter(
2492 TokenPos(), 2515 TokenPos(),
2493 &Symbols::PhaseParameter(), 2516 &Symbols::PhaseParameter(),
2494 &Type::ZoneHandle(Type::SmiType())); 2517 &Type::ZoneHandle(Type::SmiType()));
2495 2518
2496 if (func.is_const()) { 2519 if (func.is_const()) {
2497 params.SetImplicitlyFinal(); 2520 params.SetImplicitlyFinal();
2498 } 2521 }
2499 ParseFormalParameterList(allow_explicit_default_values, &params); 2522 ParseFormalParameterList(allow_explicit_default_values, false, &params);
2500 2523
2501 SetupDefaultsForOptionalParams(&params, default_parameter_values); 2524 SetupDefaultsForOptionalParams(&params, default_parameter_values);
2502 ASSERT(AbstractType::Handle(func.result_type()).IsResolved()); 2525 ASSERT(AbstractType::Handle(func.result_type()).IsResolved());
2503 ASSERT(func.NumParameters() == params.parameters->length()); 2526 ASSERT(func.NumParameters() == params.parameters->length());
2504 2527
2505 // Now populate function scope with the formal parameters. 2528 // Now populate function scope with the formal parameters.
2506 AddFormalParamsToScope(&params, current_block_->scope); 2529 AddFormalParamsToScope(&params, current_block_->scope);
2507 2530
2508 // Initialize instance fields that have an explicit initializer expression. 2531 // Initialize instance fields that have an explicit initializer expression.
2509 // The formal parameter names must not be visible to the instance 2532 // The formal parameter names must not be visible to the instance
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
2741 // The first parameter of a factory is the AbstractTypeArguments vector of 2764 // The first parameter of a factory is the AbstractTypeArguments vector of
2742 // the type of the instance to be allocated. 2765 // the type of the instance to be allocated.
2743 params.AddFinalParameter( 2766 params.AddFinalParameter(
2744 TokenPos(), 2767 TokenPos(),
2745 &Symbols::TypeArgumentsParameter(), 2768 &Symbols::TypeArgumentsParameter(),
2746 &Type::ZoneHandle(Type::DynamicType())); 2769 &Type::ZoneHandle(Type::DynamicType()));
2747 } 2770 }
2748 ASSERT((CurrentToken() == Token::kLPAREN) || func.IsGetterFunction()); 2771 ASSERT((CurrentToken() == Token::kLPAREN) || func.IsGetterFunction());
2749 const bool allow_explicit_default_values = true; 2772 const bool allow_explicit_default_values = true;
2750 if (!func.IsGetterFunction()) { 2773 if (!func.IsGetterFunction()) {
2751 ParseFormalParameterList(allow_explicit_default_values, &params); 2774 ParseFormalParameterList(allow_explicit_default_values, false, &params);
2752 } else { 2775 } else {
2753 // TODO(hausner): Remove this once we no longer support the old 2776 // TODO(hausner): Remove this once we no longer support the old
2754 // getter syntax with explicit empty parameter list. 2777 // getter syntax with explicit empty parameter list.
2755 if (CurrentToken() == Token::kLPAREN) { 2778 if (CurrentToken() == Token::kLPAREN) {
2756 ConsumeToken(); 2779 ConsumeToken();
2757 ExpectToken(Token::kRPAREN); 2780 ExpectToken(Token::kRPAREN);
2758 } 2781 }
2759 } 2782 }
2760 2783
2761 // The number of parameters and their type are not yet set in local functions, 2784 // The number of parameters and their type are not yet set in local functions,
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
2978 if (method->IsConstructor()) { 3001 if (method->IsConstructor()) {
2979 method->params.AddFinalParameter( 3002 method->params.AddFinalParameter(
2980 TokenPos(), 3003 TokenPos(),
2981 &Symbols::PhaseParameter(), 3004 &Symbols::PhaseParameter(),
2982 &Type::ZoneHandle(Type::SmiType())); 3005 &Type::ZoneHandle(Type::SmiType()));
2983 } 3006 }
2984 if (are_implicitly_final) { 3007 if (are_implicitly_final) {
2985 method->params.SetImplicitlyFinal(); 3008 method->params.SetImplicitlyFinal();
2986 } 3009 }
2987 if (!method->IsGetter()) { 3010 if (!method->IsGetter()) {
2988 ParseFormalParameterList(allow_explicit_default_values, &method->params); 3011 ParseFormalParameterList(allow_explicit_default_values,
3012 false,
3013 &method->params);
2989 } 3014 }
2990 3015
2991 // Now that we know the parameter list, we can distinguish between the 3016 // Now that we know the parameter list, we can distinguish between the
2992 // unary and binary operator -. 3017 // unary and binary operator -.
2993 if (method->has_operator) { 3018 if (method->has_operator) {
2994 if ((method->operator_token == Token::kSUB) && 3019 if ((method->operator_token == Token::kSUB) &&
2995 (method->params.num_fixed_parameters == 1)) { 3020 (method->params.num_fixed_parameters == 1)) {
2996 // Patch up name for unary operator - so it does not clash with the 3021 // Patch up name for unary operator - so it does not clash with the
2997 // name for binary operator -. 3022 // name for binary operator -.
2998 method->operator_token = Token::kNEGATE; 3023 method->operator_token = Token::kNEGATE;
(...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after
4030 } 4055 }
4031 ParamList func_params; 4056 ParamList func_params;
4032 4057
4033 // Add implicit closure object parameter. 4058 // Add implicit closure object parameter.
4034 func_params.AddFinalParameter( 4059 func_params.AddFinalParameter(
4035 TokenPos(), 4060 TokenPos(),
4036 &Symbols::ClosureParameter(), 4061 &Symbols::ClosureParameter(),
4037 &Type::ZoneHandle(Type::DynamicType())); 4062 &Type::ZoneHandle(Type::DynamicType()));
4038 4063
4039 const bool no_explicit_default_values = false; 4064 const bool no_explicit_default_values = false;
4040 ParseFormalParameterList(no_explicit_default_values, &func_params); 4065 ParseFormalParameterList(no_explicit_default_values, false, &func_params);
4041 ExpectSemicolon(); 4066 ExpectSemicolon();
4042 // The field 'is_static' has no meaning for signature functions. 4067 // The field 'is_static' has no meaning for signature functions.
4043 Function& signature_function = Function::Handle( 4068 Function& signature_function = Function::Handle(
4044 Function::New(*alias_name, 4069 Function::New(*alias_name,
4045 RawFunction::kSignatureFunction, 4070 RawFunction::kSignatureFunction,
4046 /* is_static = */ false, 4071 /* is_static = */ false,
4047 /* is_const = */ false, 4072 /* is_const = */ false,
4048 /* is_abstract = */ false, 4073 /* is_abstract = */ false,
4049 /* is_external = */ false, 4074 /* is_external = */ false,
4050 function_type_alias, 4075 function_type_alias,
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
4479 } 4504 }
4480 // A setter named x= may co-exist with a function named x, thus we do 4505 // A setter named x= may co-exist with a function named x, thus we do
4481 // not need to check setters. 4506 // not need to check setters.
4482 4507
4483 if (CurrentToken() != Token::kLPAREN) { 4508 if (CurrentToken() != Token::kLPAREN) {
4484 ErrorMsg("'(' expected"); 4509 ErrorMsg("'(' expected");
4485 } 4510 }
4486 const intptr_t function_pos = TokenPos(); 4511 const intptr_t function_pos = TokenPos();
4487 ParamList params; 4512 ParamList params;
4488 const bool allow_explicit_default_values = true; 4513 const bool allow_explicit_default_values = true;
4489 ParseFormalParameterList(allow_explicit_default_values, &params); 4514 ParseFormalParameterList(allow_explicit_default_values, false, &params);
4490 4515
4491 intptr_t function_end_pos = function_pos; 4516 intptr_t function_end_pos = function_pos;
4492 if (is_external) { 4517 if (is_external) {
4493 function_end_pos = TokenPos(); 4518 function_end_pos = TokenPos();
4494 ExpectSemicolon(); 4519 ExpectSemicolon();
4495 } else if (CurrentToken() == Token::kLBRACE) { 4520 } else if (CurrentToken() == Token::kLBRACE) {
4496 SkipBlock(); 4521 SkipBlock();
4497 function_end_pos = TokenPos() - 1; 4522 function_end_pos = TokenPos() - 1;
4498 } else if (CurrentToken() == Token::kARROW) { 4523 } else if (CurrentToken() == Token::kARROW) {
4499 ConsumeToken(); 4524 ConsumeToken();
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
4568 } 4593 }
4569 } 4594 }
4570 const intptr_t name_pos = TokenPos(); 4595 const intptr_t name_pos = TokenPos();
4571 const String* field_name = ExpectIdentifier("accessor name expected"); 4596 const String* field_name = ExpectIdentifier("accessor name expected");
4572 4597
4573 const intptr_t accessor_pos = TokenPos(); 4598 const intptr_t accessor_pos = TokenPos();
4574 ParamList params; 4599 ParamList params;
4575 4600
4576 if (!is_getter) { 4601 if (!is_getter) {
4577 const bool allow_explicit_default_values = true; 4602 const bool allow_explicit_default_values = true;
4578 ParseFormalParameterList(allow_explicit_default_values, &params); 4603 ParseFormalParameterList(allow_explicit_default_values, false, &params);
4579 } 4604 }
4580 String& accessor_name = String::ZoneHandle(); 4605 String& accessor_name = String::ZoneHandle();
4581 int expected_num_parameters = -1; 4606 int expected_num_parameters = -1;
4582 if (is_getter) { 4607 if (is_getter) {
4583 expected_num_parameters = 0; 4608 expected_num_parameters = 0;
4584 accessor_name = Field::GetterSymbol(*field_name); 4609 accessor_name = Field::GetterSymbol(*field_name);
4585 } else { 4610 } else {
4586 expected_num_parameters = 1; 4611 expected_num_parameters = 1;
4587 accessor_name = Field::SetterSymbol(*field_name); 4612 accessor_name = Field::SetterSymbol(*field_name);
4588 } 4613 }
(...skipping 5587 matching lines...) Expand 10 before | Expand all | Expand 10 after
10176 if (IsIdentifier()) { 10201 if (IsIdentifier()) {
10177 if (LookaheadToken(1) != Token::kLPAREN) { 10202 if (LookaheadToken(1) != Token::kLPAREN) {
10178 SkipType(true); 10203 SkipType(true);
10179 } 10204 }
10180 ExpectIdentifier("function name expected"); 10205 ExpectIdentifier("function name expected");
10181 } 10206 }
10182 if (CurrentToken() == Token::kLPAREN) { 10207 if (CurrentToken() == Token::kLPAREN) {
10183 const bool allow_explicit_default_values = true; 10208 const bool allow_explicit_default_values = true;
10184 ParamList params; 10209 ParamList params;
10185 params.skipped = true; 10210 params.skipped = true;
10186 ParseFormalParameterList(allow_explicit_default_values, &params); 10211 ParseFormalParameterList(allow_explicit_default_values, false, &params);
10187 } 10212 }
10188 if (CurrentToken() == Token::kLBRACE) { 10213 if (CurrentToken() == Token::kLBRACE) {
10189 SkipBlock(); 10214 SkipBlock();
10190 } else if (CurrentToken() == Token::kARROW) { 10215 } else if (CurrentToken() == Token::kARROW) {
10191 ConsumeToken(); 10216 ConsumeToken();
10192 SkipExpr(); 10217 SkipExpr();
10193 } 10218 }
10194 } 10219 }
10195 10220
10196 10221
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
10475 void Parser::SkipQualIdent() { 10500 void Parser::SkipQualIdent() {
10476 ASSERT(IsIdentifier()); 10501 ASSERT(IsIdentifier());
10477 ConsumeToken(); 10502 ConsumeToken();
10478 if (CurrentToken() == Token::kPERIOD) { 10503 if (CurrentToken() == Token::kPERIOD) {
10479 ConsumeToken(); // Consume the kPERIOD token. 10504 ConsumeToken(); // Consume the kPERIOD token.
10480 ExpectIdentifier("identifier expected after '.'"); 10505 ExpectIdentifier("identifier expected after '.'");
10481 } 10506 }
10482 } 10507 }
10483 10508
10484 } // namespace dart 10509 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698