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

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: rebase 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
« no previous file with comments | « runtime/vm/parser.h ('k') | tests/lib/mirrors/parameter_metadata_test.dart » ('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 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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 isolate->set_long_jump_base(&jump); 773 isolate->set_long_jump_base(&jump);
772 if (setjmp(*jump.Set()) == 0) { 774 if (setjmp(*jump.Set()) == 0) {
773 const Script& script = Script::Handle(isolate, func.script()); 775 const Script& script = Script::Handle(isolate, func.script());
774 const Class& owner = Class::Handle(isolate, func.Owner()); 776 const Class& owner = Class::Handle(isolate, func.Owner());
775 ASSERT(!owner.IsNull()); 777 ASSERT(!owner.IsNull());
776 const Library& lib = Library::Handle(isolate, owner.library()); 778 const Library& lib = Library::Handle(isolate, owner.library());
777 Parser parser(script, lib, func.token_pos()); 779 Parser parser(script, lib, func.token_pos());
778 parser.set_current_class(owner); 780 parser.set_current_class(owner);
779 parser.SkipFunctionPreamble(); 781 parser.SkipFunctionPreamble();
780 ParamList params; 782 ParamList params;
781 parser.ParseFormalParameterList(true, &params); 783 parser.ParseFormalParameterList(true, true, &params);
782 ParamDesc* param = params.parameters->data(); 784 ParamDesc* param = params.parameters->data();
783 const int param_cnt = params.num_fixed_parameters + 785 const int param_cnt = params.num_fixed_parameters +
784 params.num_optional_parameters; 786 params.num_optional_parameters;
785 Array& param_descriptor = Array::Handle(isolate, Array::New(param_cnt * 2)); 787 const Array& param_descriptor =
786 for (int i = 0, j = 0; i < param_cnt; i++, j += 2) { 788 Array::Handle(Array::New(param_cnt * kParameterEntrySize));
787 param_descriptor.SetAt(j, param[i].is_final ? Bool::True() : 789 for (int i = 0, j = 0; i < param_cnt; i++, j += kParameterEntrySize) {
788 Bool::False()); 790 param_descriptor.SetAt(j + kParameterIsFinalOffset,
789 param_descriptor.SetAt(j + 1, 791 param[i].is_final ? Bool::True() : Bool::False());
792 param_descriptor.SetAt(j + kParameterDefaultValueOffset,
790 (param[i].default_value == NULL) ? Object::null_instance() : 793 (param[i].default_value == NULL) ? Object::null_instance() :
791 *(param[i].default_value)); 794 *(param[i].default_value));
795 const Object* metadata = param[i].metadata;
796 if ((metadata != NULL) && (*metadata).IsError()) {
797 return (*metadata).raw(); // Error evaluating the metadata.
798 }
799 param_descriptor.SetAt(j + kParameterMetadataOffset,
800 (param[i].metadata == NULL) ? Object::null_instance() :
801 *(param[i].metadata));
792 } 802 }
793 isolate->set_long_jump_base(base); 803 isolate->set_long_jump_base(base);
794 return param_descriptor.raw(); 804 return param_descriptor.raw();
795 } else { 805 } else {
796 Error& error = Error::Handle(); 806 Error& error = Error::Handle();
797 error = isolate->object_store()->sticky_error(); 807 error = isolate->object_store()->sticky_error();
798 isolate->object_store()->clear_sticky_error(); 808 isolate->object_store()->clear_sticky_error();
799 isolate->set_long_jump_base(base); 809 isolate->set_long_jump_base(base);
800 return error.raw(); 810 return error.raw();
801 } 811 }
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
1359 } while (!token_stack.is_empty() && is_match && !unexpected_token_found); 1369 } while (!token_stack.is_empty() && is_match && !unexpected_token_found);
1360 if (!is_match) { 1370 if (!is_match) {
1361 ErrorMsg(token_pos, "unbalanced '%s'", Token::Str(token)); 1371 ErrorMsg(token_pos, "unbalanced '%s'", Token::Str(token));
1362 } else if (unexpected_token_found) { 1372 } else if (unexpected_token_found) {
1363 ErrorMsg(block_start_pos, "unterminated block"); 1373 ErrorMsg(block_start_pos, "unterminated block");
1364 } 1374 }
1365 } 1375 }
1366 1376
1367 1377
1368 void Parser::ParseFormalParameter(bool allow_explicit_default_value, 1378 void Parser::ParseFormalParameter(bool allow_explicit_default_value,
1379 bool evaluate_metadata,
1369 ParamList* params) { 1380 ParamList* params) {
1370 TRACE_PARSER("ParseFormalParameter"); 1381 TRACE_PARSER("ParseFormalParameter");
1371 ParamDesc parameter; 1382 ParamDesc parameter;
1372 bool var_seen = false; 1383 bool var_seen = false;
1373 bool this_seen = false; 1384 bool this_seen = false;
1374 1385
1375 SkipMetadata(); 1386 if (evaluate_metadata && (CurrentToken() == Token::kAT)) {
1387 parameter.metadata = &Array::ZoneHandle(EvaluateMetadata());
1388 } else {
1389 SkipMetadata();
1390 }
1391
1376 if (CurrentToken() == Token::kFINAL) { 1392 if (CurrentToken() == Token::kFINAL) {
1377 ConsumeToken(); 1393 ConsumeToken();
1378 parameter.is_final = true; 1394 parameter.is_final = true;
1379 } else if (CurrentToken() == Token::kVAR) { 1395 } else if (CurrentToken() == Token::kVAR) {
1380 ConsumeToken(); 1396 ConsumeToken();
1381 var_seen = true; 1397 var_seen = true;
1382 // The parameter type is the 'dynamic' type. 1398 // The parameter type is the 'dynamic' type.
1383 parameter.type = &Type::ZoneHandle(Type::DynamicType()); 1399 parameter.type = &Type::ZoneHandle(Type::DynamicType());
1384 } 1400 }
1385 if (CurrentToken() == Token::kTHIS) { 1401 if (CurrentToken() == Token::kTHIS) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1465 // Finish parsing the function type parameter. 1481 // Finish parsing the function type parameter.
1466 ParamList func_params; 1482 ParamList func_params;
1467 1483
1468 // Add implicit closure object parameter. 1484 // Add implicit closure object parameter.
1469 func_params.AddFinalParameter( 1485 func_params.AddFinalParameter(
1470 TokenPos(), 1486 TokenPos(),
1471 &Symbols::ClosureParameter(), 1487 &Symbols::ClosureParameter(),
1472 &Type::ZoneHandle(Type::DynamicType())); 1488 &Type::ZoneHandle(Type::DynamicType()));
1473 1489
1474 const bool no_explicit_default_values = false; 1490 const bool no_explicit_default_values = false;
1475 ParseFormalParameterList(no_explicit_default_values, &func_params); 1491 ParseFormalParameterList(no_explicit_default_values, false, &func_params);
1476 1492
1477 // The field 'is_static' has no meaning for signature functions. 1493 // The field 'is_static' has no meaning for signature functions.
1478 const Function& signature_function = Function::Handle( 1494 const Function& signature_function = Function::Handle(
1479 Function::New(*parameter.name, 1495 Function::New(*parameter.name,
1480 RawFunction::kSignatureFunction, 1496 RawFunction::kSignatureFunction,
1481 /* is_static = */ false, 1497 /* is_static = */ false,
1482 /* is_const = */ false, 1498 /* is_const = */ false,
1483 /* is_abstract = */ false, 1499 /* is_abstract = */ false,
1484 /* is_external = */ false, 1500 /* is_external = */ false,
1485 current_class(), 1501 current_class(),
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1549 } 1565 }
1550 if (parameter.type->IsVoidType()) { 1566 if (parameter.type->IsVoidType()) {
1551 ErrorMsg("parameter '%s' may not be 'void'", parameter.name->ToCString()); 1567 ErrorMsg("parameter '%s' may not be 'void'", parameter.name->ToCString());
1552 } 1568 }
1553 params->parameters->Add(parameter); 1569 params->parameters->Add(parameter);
1554 } 1570 }
1555 1571
1556 1572
1557 // Parses a sequence of normal or optional formal parameters. 1573 // Parses a sequence of normal or optional formal parameters.
1558 void Parser::ParseFormalParameters(bool allow_explicit_default_values, 1574 void Parser::ParseFormalParameters(bool allow_explicit_default_values,
1575 bool evaluate_metadata,
1559 ParamList* params) { 1576 ParamList* params) {
1560 TRACE_PARSER("ParseFormalParameters"); 1577 TRACE_PARSER("ParseFormalParameters");
1561 do { 1578 do {
1562 ConsumeToken(); 1579 ConsumeToken();
1563 if (!params->has_optional_positional_parameters && 1580 if (!params->has_optional_positional_parameters &&
1564 !params->has_optional_named_parameters && 1581 !params->has_optional_named_parameters &&
1565 (CurrentToken() == Token::kLBRACK)) { 1582 (CurrentToken() == Token::kLBRACK)) {
1566 // End of normal parameters, start of optional positional parameters. 1583 // End of normal parameters, start of optional positional parameters.
1567 params->has_optional_positional_parameters = true; 1584 params->has_optional_positional_parameters = true;
1568 return; 1585 return;
1569 } 1586 }
1570 if (!params->has_optional_positional_parameters && 1587 if (!params->has_optional_positional_parameters &&
1571 !params->has_optional_named_parameters && 1588 !params->has_optional_named_parameters &&
1572 (CurrentToken() == Token::kLBRACE)) { 1589 (CurrentToken() == Token::kLBRACE)) {
1573 // End of normal parameters, start of optional named parameters. 1590 // End of normal parameters, start of optional named parameters.
1574 params->has_optional_named_parameters = true; 1591 params->has_optional_named_parameters = true;
1575 return; 1592 return;
1576 } 1593 }
1577 ParseFormalParameter(allow_explicit_default_values, params); 1594 ParseFormalParameter(allow_explicit_default_values,
1595 evaluate_metadata,
1596 params);
1578 } while (CurrentToken() == Token::kCOMMA); 1597 } while (CurrentToken() == Token::kCOMMA);
1579 } 1598 }
1580 1599
1581 1600
1582 void Parser::ParseFormalParameterList(bool allow_explicit_default_values, 1601 void Parser::ParseFormalParameterList(bool allow_explicit_default_values,
1602 bool evaluate_metadata,
1583 ParamList* params) { 1603 ParamList* params) {
1584 TRACE_PARSER("ParseFormalParameterList"); 1604 TRACE_PARSER("ParseFormalParameterList");
1585 ASSERT(CurrentToken() == Token::kLPAREN); 1605 ASSERT(CurrentToken() == Token::kLPAREN);
1586 1606
1587 if (LookaheadToken(1) != Token::kRPAREN) { 1607 if (LookaheadToken(1) != Token::kRPAREN) {
1588 // Parse fixed parameters. 1608 // Parse fixed parameters.
1589 ParseFormalParameters(allow_explicit_default_values, params); 1609 ParseFormalParameters(allow_explicit_default_values,
1610 evaluate_metadata,
1611 params);
1590 if (params->has_optional_positional_parameters || 1612 if (params->has_optional_positional_parameters ||
1591 params->has_optional_named_parameters) { 1613 params->has_optional_named_parameters) {
1592 // Parse optional parameters. 1614 // Parse optional parameters.
1593 ParseFormalParameters(allow_explicit_default_values, params); 1615 ParseFormalParameters(allow_explicit_default_values,
1616 evaluate_metadata,
1617 params);
1594 if (params->has_optional_positional_parameters) { 1618 if (params->has_optional_positional_parameters) {
1595 if (CurrentToken() != Token::kRBRACK) { 1619 if (CurrentToken() != Token::kRBRACK) {
1596 ErrorMsg("',' or ']' expected"); 1620 ErrorMsg("',' or ']' expected");
1597 } 1621 }
1598 } else { 1622 } else {
1599 if (CurrentToken() != Token::kRBRACE) { 1623 if (CurrentToken() != Token::kRBRACE) {
1600 ErrorMsg("',' or '}' expected"); 1624 ErrorMsg("',' or '}' expected");
1601 } 1625 }
1602 } 1626 }
1603 ConsumeToken(); // ']' or '}'. 1627 ConsumeToken(); // ']' or '}'.
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after
2474 2498
2475 // Add implicit parameter for construction phase. 2499 // Add implicit parameter for construction phase.
2476 params.AddFinalParameter( 2500 params.AddFinalParameter(
2477 TokenPos(), 2501 TokenPos(),
2478 &Symbols::PhaseParameter(), 2502 &Symbols::PhaseParameter(),
2479 &Type::ZoneHandle(Type::SmiType())); 2503 &Type::ZoneHandle(Type::SmiType()));
2480 2504
2481 if (func.is_const()) { 2505 if (func.is_const()) {
2482 params.SetImplicitlyFinal(); 2506 params.SetImplicitlyFinal();
2483 } 2507 }
2484 ParseFormalParameterList(allow_explicit_default_values, &params); 2508 ParseFormalParameterList(allow_explicit_default_values, false, &params);
2485 2509
2486 SetupDefaultsForOptionalParams(&params, default_parameter_values); 2510 SetupDefaultsForOptionalParams(&params, default_parameter_values);
2487 ASSERT(AbstractType::Handle(func.result_type()).IsResolved()); 2511 ASSERT(AbstractType::Handle(func.result_type()).IsResolved());
2488 ASSERT(func.NumParameters() == params.parameters->length()); 2512 ASSERT(func.NumParameters() == params.parameters->length());
2489 2513
2490 // Now populate function scope with the formal parameters. 2514 // Now populate function scope with the formal parameters.
2491 AddFormalParamsToScope(&params, current_block_->scope); 2515 AddFormalParamsToScope(&params, current_block_->scope);
2492 2516
2493 // Initialize instance fields that have an explicit initializer expression. 2517 // Initialize instance fields that have an explicit initializer expression.
2494 // The formal parameter names must not be visible to the instance 2518 // The formal parameter names must not be visible to the instance
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
2730 &Symbols::TypeArgumentsParameter(), 2754 &Symbols::TypeArgumentsParameter(),
2731 &Type::ZoneHandle(Type::DynamicType())); 2755 &Type::ZoneHandle(Type::DynamicType()));
2732 } 2756 }
2733 ASSERT((CurrentToken() == Token::kLPAREN) || func.IsGetterFunction()); 2757 ASSERT((CurrentToken() == Token::kLPAREN) || func.IsGetterFunction());
2734 const bool allow_explicit_default_values = true; 2758 const bool allow_explicit_default_values = true;
2735 if (func.IsGetterFunction()) { 2759 if (func.IsGetterFunction()) {
2736 // Populate function scope with the formal parameters. Since in this case 2760 // Populate function scope with the formal parameters. Since in this case
2737 // we are compiling a getter this will at most populate the receiver. 2761 // we are compiling a getter this will at most populate the receiver.
2738 AddFormalParamsToScope(&params, current_block_->scope); 2762 AddFormalParamsToScope(&params, current_block_->scope);
2739 } else { 2763 } else {
2740 ParseFormalParameterList(allow_explicit_default_values, &params); 2764 ParseFormalParameterList(allow_explicit_default_values, false, &params);
2741 2765
2742 // The number of parameters and their type are not yet set in local 2766 // The number of parameters and their type are not yet set in local
2743 // functions, since they are not 'top-level' parsed. 2767 // functions, since they are not 'top-level' parsed.
2744 if (func.IsLocalFunction()) { 2768 if (func.IsLocalFunction()) {
2745 AddFormalParamsToFunction(&params, func); 2769 AddFormalParamsToFunction(&params, func);
2746 } 2770 }
2747 SetupDefaultsForOptionalParams(&params, default_parameter_values); 2771 SetupDefaultsForOptionalParams(&params, default_parameter_values);
2748 ASSERT(AbstractType::Handle(func.result_type()).IsResolved()); 2772 ASSERT(AbstractType::Handle(func.result_type()).IsResolved());
2749 ASSERT(func.NumParameters() == params.parameters->length()); 2773 ASSERT(func.NumParameters() == params.parameters->length());
2750 2774
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
2961 if (method->IsConstructor()) { 2985 if (method->IsConstructor()) {
2962 method->params.AddFinalParameter( 2986 method->params.AddFinalParameter(
2963 TokenPos(), 2987 TokenPos(),
2964 &Symbols::PhaseParameter(), 2988 &Symbols::PhaseParameter(),
2965 &Type::ZoneHandle(Type::SmiType())); 2989 &Type::ZoneHandle(Type::SmiType()));
2966 } 2990 }
2967 if (are_implicitly_final) { 2991 if (are_implicitly_final) {
2968 method->params.SetImplicitlyFinal(); 2992 method->params.SetImplicitlyFinal();
2969 } 2993 }
2970 if (!method->IsGetter()) { 2994 if (!method->IsGetter()) {
2971 ParseFormalParameterList(allow_explicit_default_values, &method->params); 2995 ParseFormalParameterList(allow_explicit_default_values,
2996 false,
2997 &method->params);
2972 } 2998 }
2973 2999
2974 // Now that we know the parameter list, we can distinguish between the 3000 // Now that we know the parameter list, we can distinguish between the
2975 // unary and binary operator -. 3001 // unary and binary operator -.
2976 if (method->has_operator) { 3002 if (method->has_operator) {
2977 if ((method->operator_token == Token::kSUB) && 3003 if ((method->operator_token == Token::kSUB) &&
2978 (method->params.num_fixed_parameters == 1)) { 3004 (method->params.num_fixed_parameters == 1)) {
2979 // Patch up name for unary operator - so it does not clash with the 3005 // Patch up name for unary operator - so it does not clash with the
2980 // name for binary operator -. 3006 // name for binary operator -.
2981 method->operator_token = Token::kNEGATE; 3007 method->operator_token = Token::kNEGATE;
(...skipping 1036 matching lines...) Expand 10 before | Expand all | Expand 10 after
4018 } 4044 }
4019 ParamList func_params; 4045 ParamList func_params;
4020 4046
4021 // Add implicit closure object parameter. 4047 // Add implicit closure object parameter.
4022 func_params.AddFinalParameter( 4048 func_params.AddFinalParameter(
4023 TokenPos(), 4049 TokenPos(),
4024 &Symbols::ClosureParameter(), 4050 &Symbols::ClosureParameter(),
4025 &Type::ZoneHandle(Type::DynamicType())); 4051 &Type::ZoneHandle(Type::DynamicType()));
4026 4052
4027 const bool no_explicit_default_values = false; 4053 const bool no_explicit_default_values = false;
4028 ParseFormalParameterList(no_explicit_default_values, &func_params); 4054 ParseFormalParameterList(no_explicit_default_values, false, &func_params);
4029 ExpectSemicolon(); 4055 ExpectSemicolon();
4030 // The field 'is_static' has no meaning for signature functions. 4056 // The field 'is_static' has no meaning for signature functions.
4031 Function& signature_function = Function::Handle( 4057 Function& signature_function = Function::Handle(
4032 Function::New(*alias_name, 4058 Function::New(*alias_name,
4033 RawFunction::kSignatureFunction, 4059 RawFunction::kSignatureFunction,
4034 /* is_static = */ false, 4060 /* is_static = */ false,
4035 /* is_const = */ false, 4061 /* is_const = */ false,
4036 /* is_abstract = */ false, 4062 /* is_abstract = */ false,
4037 /* is_external = */ false, 4063 /* is_external = */ false,
4038 function_type_alias, 4064 function_type_alias,
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
4467 } 4493 }
4468 // A setter named x= may co-exist with a function named x, thus we do 4494 // A setter named x= may co-exist with a function named x, thus we do
4469 // not need to check setters. 4495 // not need to check setters.
4470 4496
4471 if (CurrentToken() != Token::kLPAREN) { 4497 if (CurrentToken() != Token::kLPAREN) {
4472 ErrorMsg("'(' expected"); 4498 ErrorMsg("'(' expected");
4473 } 4499 }
4474 const intptr_t function_pos = TokenPos(); 4500 const intptr_t function_pos = TokenPos();
4475 ParamList params; 4501 ParamList params;
4476 const bool allow_explicit_default_values = true; 4502 const bool allow_explicit_default_values = true;
4477 ParseFormalParameterList(allow_explicit_default_values, &params); 4503 ParseFormalParameterList(allow_explicit_default_values, false, &params);
4478 4504
4479 intptr_t function_end_pos = function_pos; 4505 intptr_t function_end_pos = function_pos;
4480 if (is_external) { 4506 if (is_external) {
4481 function_end_pos = TokenPos(); 4507 function_end_pos = TokenPos();
4482 ExpectSemicolon(); 4508 ExpectSemicolon();
4483 } else if (CurrentToken() == Token::kLBRACE) { 4509 } else if (CurrentToken() == Token::kLBRACE) {
4484 SkipBlock(); 4510 SkipBlock();
4485 function_end_pos = TokenPos() - 1; 4511 function_end_pos = TokenPos() - 1;
4486 } else if (CurrentToken() == Token::kARROW) { 4512 } else if (CurrentToken() == Token::kARROW) {
4487 ConsumeToken(); 4513 ConsumeToken();
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
4556 } 4582 }
4557 } 4583 }
4558 const intptr_t name_pos = TokenPos(); 4584 const intptr_t name_pos = TokenPos();
4559 const String* field_name = ExpectIdentifier("accessor name expected"); 4585 const String* field_name = ExpectIdentifier("accessor name expected");
4560 4586
4561 const intptr_t accessor_pos = TokenPos(); 4587 const intptr_t accessor_pos = TokenPos();
4562 ParamList params; 4588 ParamList params;
4563 4589
4564 if (!is_getter) { 4590 if (!is_getter) {
4565 const bool allow_explicit_default_values = true; 4591 const bool allow_explicit_default_values = true;
4566 ParseFormalParameterList(allow_explicit_default_values, &params); 4592 ParseFormalParameterList(allow_explicit_default_values, false, &params);
4567 } 4593 }
4568 String& accessor_name = String::ZoneHandle(); 4594 String& accessor_name = String::ZoneHandle();
4569 int expected_num_parameters = -1; 4595 int expected_num_parameters = -1;
4570 if (is_getter) { 4596 if (is_getter) {
4571 expected_num_parameters = 0; 4597 expected_num_parameters = 0;
4572 accessor_name = Field::GetterSymbol(*field_name); 4598 accessor_name = Field::GetterSymbol(*field_name);
4573 } else { 4599 } else {
4574 expected_num_parameters = 1; 4600 expected_num_parameters = 1;
4575 accessor_name = Field::SetterSymbol(*field_name); 4601 accessor_name = Field::SetterSymbol(*field_name);
4576 } 4602 }
(...skipping 5601 matching lines...) Expand 10 before | Expand all | Expand 10 after
10178 if (IsIdentifier()) { 10204 if (IsIdentifier()) {
10179 if (LookaheadToken(1) != Token::kLPAREN) { 10205 if (LookaheadToken(1) != Token::kLPAREN) {
10180 SkipType(true); 10206 SkipType(true);
10181 } 10207 }
10182 ExpectIdentifier("function name expected"); 10208 ExpectIdentifier("function name expected");
10183 } 10209 }
10184 if (CurrentToken() == Token::kLPAREN) { 10210 if (CurrentToken() == Token::kLPAREN) {
10185 const bool allow_explicit_default_values = true; 10211 const bool allow_explicit_default_values = true;
10186 ParamList params; 10212 ParamList params;
10187 params.skipped = true; 10213 params.skipped = true;
10188 ParseFormalParameterList(allow_explicit_default_values, &params); 10214 ParseFormalParameterList(allow_explicit_default_values, false, &params);
10189 } 10215 }
10190 if (CurrentToken() == Token::kLBRACE) { 10216 if (CurrentToken() == Token::kLBRACE) {
10191 SkipBlock(); 10217 SkipBlock();
10192 } else if (CurrentToken() == Token::kARROW) { 10218 } else if (CurrentToken() == Token::kARROW) {
10193 ConsumeToken(); 10219 ConsumeToken();
10194 SkipExpr(); 10220 SkipExpr();
10195 } 10221 }
10196 } 10222 }
10197 10223
10198 10224
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
10477 void Parser::SkipQualIdent() { 10503 void Parser::SkipQualIdent() {
10478 ASSERT(IsIdentifier()); 10504 ASSERT(IsIdentifier());
10479 ConsumeToken(); 10505 ConsumeToken();
10480 if (CurrentToken() == Token::kPERIOD) { 10506 if (CurrentToken() == Token::kPERIOD) {
10481 ConsumeToken(); // Consume the kPERIOD token. 10507 ConsumeToken(); // Consume the kPERIOD token.
10482 ExpectIdentifier("identifier expected after '.'"); 10508 ExpectIdentifier("identifier expected after '.'");
10483 } 10509 }
10484 } 10510 }
10485 10511
10486 } // namespace dart 10512 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/parser.h ('k') | tests/lib/mirrors/parameter_metadata_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698