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

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

Issue 1307943008: Make default_parameter_values a ZoneGrowableArray instead of an array in new space (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Cleanup Created 5 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
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 "platform/utils.h" 8 #include "platform/utils.h"
9 #include "vm/ast_transformer.h" 9 #include "vm/ast_transformer.h"
10 #include "vm/bootstrap.h" 10 #include "vm/bootstrap.h"
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 INC_STAT(isolate, num_functions_compiled, 1); 883 INC_STAT(isolate, num_functions_compiled, 1);
884 VMTagScope tagScope(thread, VMTag::kCompileParseFunctionTagId, 884 VMTagScope tagScope(thread, VMTag::kCompileParseFunctionTagId,
885 FLAG_profile_vm); 885 FLAG_profile_vm);
886 886
887 ASSERT(thread->long_jump_base()->IsSafeToJump()); 887 ASSERT(thread->long_jump_base()->IsSafeToJump());
888 ASSERT(parsed_function != NULL); 888 ASSERT(parsed_function != NULL);
889 const Function& func = parsed_function->function(); 889 const Function& func = parsed_function->function();
890 const Script& script = Script::Handle(zone, func.script()); 890 const Script& script = Script::Handle(zone, func.script());
891 Parser parser(script, parsed_function, func.token_pos()); 891 Parser parser(script, parsed_function, func.token_pos());
892 SequenceNode* node_sequence = NULL; 892 SequenceNode* node_sequence = NULL;
893 Array& default_parameter_values = Array::ZoneHandle(zone, Array::null()); 893 ZoneGrowableArray<const Instance*>* default_parameter_values =
894 new ZoneGrowableArray<const Instance*>(zone, 2);
894 switch (func.kind()) { 895 switch (func.kind()) {
895 case RawFunction::kClosureFunction: 896 case RawFunction::kClosureFunction:
896 if (func.IsImplicitClosureFunction()) { 897 if (func.IsImplicitClosureFunction()) {
897 node_sequence = 898 node_sequence =
898 parser.ParseImplicitClosure(func, &default_parameter_values); 899 parser.ParseImplicitClosure(func, default_parameter_values);
899 break; 900 break;
900 } 901 }
901 if (func.IsConstructorClosureFunction()) { 902 if (func.IsConstructorClosureFunction()) {
902 node_sequence = 903 node_sequence =
903 parser.ParseConstructorClosure(func, &default_parameter_values); 904 parser.ParseConstructorClosure(func, default_parameter_values);
904 break; 905 break;
905 } 906 }
906 // Fall-through: Handle non-implicit closures. 907 // Fall-through: Handle non-implicit closures.
907 case RawFunction::kRegularFunction: 908 case RawFunction::kRegularFunction:
908 case RawFunction::kGetterFunction: 909 case RawFunction::kGetterFunction:
909 case RawFunction::kSetterFunction: 910 case RawFunction::kSetterFunction:
910 case RawFunction::kConstructor: 911 case RawFunction::kConstructor:
911 // The call to a redirecting factory is redirected. 912 // The call to a redirecting factory is redirected.
912 ASSERT(!func.IsRedirectingFactory()); 913 ASSERT(!func.IsRedirectingFactory());
913 if (!func.IsImplicitConstructor()) { 914 if (!func.IsImplicitConstructor()) {
914 parser.SkipFunctionPreamble(); 915 parser.SkipFunctionPreamble();
915 } 916 }
916 node_sequence = parser.ParseFunc(func, &default_parameter_values); 917 node_sequence = parser.ParseFunc(func, default_parameter_values);
917 break; 918 break;
918 case RawFunction::kImplicitGetter: 919 case RawFunction::kImplicitGetter:
919 ASSERT(!func.is_static()); 920 ASSERT(!func.is_static());
920 node_sequence = parser.ParseInstanceGetter(func); 921 node_sequence = parser.ParseInstanceGetter(func);
921 break; 922 break;
922 case RawFunction::kImplicitSetter: 923 case RawFunction::kImplicitSetter:
923 ASSERT(!func.is_static()); 924 ASSERT(!func.is_static());
924 node_sequence = parser.ParseInstanceSetter(func); 925 node_sequence = parser.ParseInstanceSetter(func);
925 break; 926 break;
926 case RawFunction::kImplicitStaticFinalGetter: 927 case RawFunction::kImplicitStaticFinalGetter:
927 node_sequence = parser.ParseStaticFinalGetter(func); 928 node_sequence = parser.ParseStaticFinalGetter(func);
928 INC_STAT(isolate, num_implicit_final_getters, 1); 929 INC_STAT(isolate, num_implicit_final_getters, 1);
929 break; 930 break;
930 case RawFunction::kMethodExtractor: 931 case RawFunction::kMethodExtractor:
931 node_sequence = parser.ParseMethodExtractor(func); 932 node_sequence = parser.ParseMethodExtractor(func);
932 break; 933 break;
933 case RawFunction::kNoSuchMethodDispatcher: 934 case RawFunction::kNoSuchMethodDispatcher:
934 node_sequence = 935 node_sequence =
935 parser.ParseNoSuchMethodDispatcher(func, &default_parameter_values); 936 parser.ParseNoSuchMethodDispatcher(func, default_parameter_values);
936 break; 937 break;
937 case RawFunction::kInvokeFieldDispatcher: 938 case RawFunction::kInvokeFieldDispatcher:
938 node_sequence = 939 node_sequence =
939 parser.ParseInvokeFieldDispatcher(func, &default_parameter_values); 940 parser.ParseInvokeFieldDispatcher(func, default_parameter_values);
940 break; 941 break;
941 case RawFunction::kIrregexpFunction: 942 case RawFunction::kIrregexpFunction:
942 UNREACHABLE(); // Irregexp functions have their own parser. 943 UNREACHABLE(); // Irregexp functions have their own parser.
943 default: 944 default:
944 UNREACHABLE(); 945 UNREACHABLE();
945 } 946 }
946 947
947 if (parsed_function->has_expression_temp_var()) { 948 if (parsed_function->has_expression_temp_var()) {
948 node_sequence->scope()->AddVariable(parsed_function->expression_temp_var()); 949 node_sequence->scope()->AddVariable(parsed_function->expression_temp_var());
949 } 950 }
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 initializer.set_is_reflectable(false); 1142 initializer.set_is_reflectable(false);
1142 initializer.set_is_debuggable(false); 1143 initializer.set_is_debuggable(false);
1143 initializer.SetIsOptimizable(false); 1144 initializer.SetIsOptimizable(false);
1144 initializer.set_is_inlinable(false); 1145 initializer.set_is_inlinable(false);
1145 1146
1146 ParsedFunction* parsed_function = new ParsedFunction(thread, initializer); 1147 ParsedFunction* parsed_function = new ParsedFunction(thread, initializer);
1147 Parser parser(script, parsed_function, field.token_pos()); 1148 Parser parser(script, parsed_function, field.token_pos());
1148 1149
1149 SequenceNode* body = parser.ParseStaticInitializer(); 1150 SequenceNode* body = parser.ParseStaticInitializer();
1150 parsed_function->SetNodeSequence(body); 1151 parsed_function->SetNodeSequence(body);
1151 parsed_function->set_default_parameter_values(Object::null_array());
1152 1152
1153 if (parsed_function->has_expression_temp_var()) { 1153 if (parsed_function->has_expression_temp_var()) {
1154 body->scope()->AddVariable(parsed_function->expression_temp_var()); 1154 body->scope()->AddVariable(parsed_function->expression_temp_var());
1155 } 1155 }
1156 body->scope()->AddVariable(parsed_function->current_context_var()); 1156 body->scope()->AddVariable(parsed_function->current_context_var());
1157 if (parsed_function->has_finally_return_temp_var()) { 1157 if (parsed_function->has_finally_return_temp_var()) {
1158 body->scope()->AddVariable(parsed_function->finally_return_temp_var()); 1158 body->scope()->AddVariable(parsed_function->finally_return_temp_var());
1159 } 1159 }
1160 // The instantiator is not required in a static expression. 1160 // The instantiator is not required in a static expression.
1161 ASSERT(!parser.IsInstantiatorRequired()); 1161 ASSERT(!parser.IsInstantiatorRequired());
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1327 1327
1328 EnsureExpressionTemp(); 1328 EnsureExpressionTemp();
1329 StoreInstanceFieldNode* store_field = 1329 StoreInstanceFieldNode* store_field =
1330 new StoreInstanceFieldNode(ident_pos, receiver, field, value); 1330 new StoreInstanceFieldNode(ident_pos, receiver, field, value);
1331 current_block_->statements->Add(store_field); 1331 current_block_->statements->Add(store_field);
1332 current_block_->statements->Add(new ReturnNode(Scanner::kNoSourcePos)); 1332 current_block_->statements->Add(new ReturnNode(Scanner::kNoSourcePos));
1333 return CloseBlock(); 1333 return CloseBlock();
1334 } 1334 }
1335 1335
1336 1336
1337 SequenceNode* Parser::ParseConstructorClosure(const Function& func, 1337 SequenceNode* Parser::ParseConstructorClosure(
1338 Array* default_values) { 1338 const Function& func,
1339 ZoneGrowableArray<const Instance*>* default_values) {
hausner 2015/08/24 23:32:39 I think the default_values parameter could be elim
srdjan 2015/08/25 00:06:31 ditto.
1339 TRACE_PARSER("ParseConstructorClosure"); 1340 TRACE_PARSER("ParseConstructorClosure");
1340 const intptr_t token_pos = func.token_pos(); 1341 const intptr_t token_pos = func.token_pos();
1341 1342
1342 Function& constructor = Function::ZoneHandle(Z); 1343 Function& constructor = Function::ZoneHandle(Z);
1343 TypeArguments& type_args = TypeArguments::ZoneHandle(Z); 1344 TypeArguments& type_args = TypeArguments::ZoneHandle(Z);
1344 ParseConstructorClosurization(&constructor, &type_args); 1345 ParseConstructorClosurization(&constructor, &type_args);
1345 ASSERT(!constructor.IsNull()); 1346 ASSERT(!constructor.IsNull());
1346 1347
1347 ParamList params; 1348 ParamList params;
1348 // The first parameter of the closure function is the implicit closure 1349 // The first parameter of the closure function is the implicit closure
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1382 } 1383 }
1383 1384
1384 AstNode* new_object = 1385 AstNode* new_object =
1385 CreateConstructorCallNode(token_pos, type_args, constructor, ctor_args); 1386 CreateConstructorCallNode(token_pos, type_args, constructor, ctor_args);
1386 ReturnNode* return_node = new ReturnNode(token_pos, new_object); 1387 ReturnNode* return_node = new ReturnNode(token_pos, new_object);
1387 current_block_->statements->Add(return_node); 1388 current_block_->statements->Add(return_node);
1388 return CloseBlock(); 1389 return CloseBlock();
1389 } 1390 }
1390 1391
1391 1392
1392 SequenceNode* Parser::ParseImplicitClosure(const Function& func, 1393 SequenceNode* Parser::ParseImplicitClosure(
1393 Array* default_values) { 1394 const Function& func, ZoneGrowableArray<const Instance*>* default_values) {
1394 TRACE_PARSER("ParseImplicitClosure"); 1395 TRACE_PARSER("ParseImplicitClosure");
1395 intptr_t token_pos = func.token_pos(); 1396 intptr_t token_pos = func.token_pos();
1396 1397
1397 OpenFunctionBlock(func); 1398 OpenFunctionBlock(func);
1398 1399
1399 ParamList params; 1400 ParamList params;
1400 params.AddFinalParameter( 1401 params.AddFinalParameter(
1401 token_pos, 1402 token_pos,
1402 &Symbols::ClosureParameter(), 1403 &Symbols::ClosureParameter(),
1403 &Type::ZoneHandle(Type::DynamicType())); 1404 &Type::ZoneHandle(Type::DynamicType()));
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1477 Function::ZoneHandle(Z, func.extracted_method_closure()), 1478 Function::ZoneHandle(Z, func.extracted_method_closure()),
1478 load_receiver, 1479 load_receiver,
1479 NULL); 1480 NULL);
1480 1481
1481 ReturnNode* return_node = new ReturnNode(Scanner::kNoSourcePos, closure); 1482 ReturnNode* return_node = new ReturnNode(Scanner::kNoSourcePos, closure);
1482 current_block_->statements->Add(return_node); 1483 current_block_->statements->Add(return_node);
1483 return CloseBlock(); 1484 return CloseBlock();
1484 } 1485 }
1485 1486
1486 1487
1487 void Parser::BuildDispatcherScope(const Function& func, 1488 void Parser::BuildDispatcherScope(
1488 const ArgumentsDescriptor& desc, 1489 const Function& func,
1489 Array* default_values) { 1490 const ArgumentsDescriptor& desc,
1491 ZoneGrowableArray<const Instance*>* default_values) {
1490 ParamList params; 1492 ParamList params;
1491 // Receiver first. 1493 // Receiver first.
1492 intptr_t token_pos = func.token_pos(); 1494 intptr_t token_pos = func.token_pos();
1493 params.AddReceiver(ReceiverType(current_class()), token_pos); 1495 params.AddReceiver(ReceiverType(current_class()), token_pos);
1494 // Remaining positional parameters. 1496 // Remaining positional parameters.
1495 intptr_t i = 1; 1497 intptr_t i = 1;
1496 for (; i < desc.PositionalCount(); ++i) { 1498 for (; i < desc.PositionalCount(); ++i) {
1497 ParamDesc p; 1499 ParamDesc p;
1498 char name[64]; 1500 char name[64];
1499 OS::SNPrint(name, 64, ":p%" Pd, i); 1501 OS::SNPrint(name, 64, ":p%" Pd, i);
(...skipping 17 matching lines...) Expand all
1517 } 1519 }
1518 ASSERT(desc.NamedCount() == params.num_optional_parameters); 1520 ASSERT(desc.NamedCount() == params.num_optional_parameters);
1519 1521
1520 SetupDefaultsForOptionalParams(params, default_values); 1522 SetupDefaultsForOptionalParams(params, default_values);
1521 1523
1522 // Build local scope for function and populate with the formal parameters. 1524 // Build local scope for function and populate with the formal parameters.
1523 OpenFunctionBlock(func); 1525 OpenFunctionBlock(func);
1524 AddFormalParamsToScope(&params, current_block_->scope); 1526 AddFormalParamsToScope(&params, current_block_->scope);
1525 } 1527 }
1526 1528
1527 SequenceNode* Parser::ParseNoSuchMethodDispatcher(const Function& func, 1529 SequenceNode* Parser::ParseNoSuchMethodDispatcher(
1528 Array* default_values) { 1530 const Function& func,
1531 ZoneGrowableArray<const Instance*>* default_values) {
1529 TRACE_PARSER("ParseNoSuchMethodDispatcher"); 1532 TRACE_PARSER("ParseNoSuchMethodDispatcher");
1530 ASSERT(FLAG_lazy_dispatchers); 1533 ASSERT(FLAG_lazy_dispatchers);
1531 1534
1532 ASSERT(func.IsNoSuchMethodDispatcher()); 1535 ASSERT(func.IsNoSuchMethodDispatcher());
1533 intptr_t token_pos = func.token_pos(); 1536 intptr_t token_pos = func.token_pos();
1534 ASSERT(func.token_pos() == 0); 1537 ASSERT(func.token_pos() == 0);
1535 ASSERT(current_class().raw() == func.Owner()); 1538 ASSERT(current_class().raw() == func.Owner());
1536 1539
1537 ArgumentsDescriptor desc(Array::Handle(Z, func.saved_args_desc())); 1540 ArgumentsDescriptor desc(Array::Handle(Z, func.saved_args_desc()));
1538 ASSERT(desc.Count() > 0); 1541 ASSERT(desc.Count() > 0);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1575 } 1578 }
1576 StaticCallNode* call = 1579 StaticCallNode* call =
1577 new StaticCallNode(token_pos, no_such_method, arguments); 1580 new StaticCallNode(token_pos, no_such_method, arguments);
1578 1581
1579 ReturnNode* return_node = new ReturnNode(token_pos, call); 1582 ReturnNode* return_node = new ReturnNode(token_pos, call);
1580 current_block_->statements->Add(return_node); 1583 current_block_->statements->Add(return_node);
1581 return CloseBlock(); 1584 return CloseBlock();
1582 } 1585 }
1583 1586
1584 1587
1585 SequenceNode* Parser::ParseInvokeFieldDispatcher(const Function& func, 1588 SequenceNode* Parser::ParseInvokeFieldDispatcher(
1586 Array* default_values) { 1589 const Function& func,
1590 ZoneGrowableArray<const Instance*>* default_values) {
1587 TRACE_PARSER("ParseInvokeFieldDispatcher"); 1591 TRACE_PARSER("ParseInvokeFieldDispatcher");
1588 ASSERT(FLAG_lazy_dispatchers); 1592 ASSERT(FLAG_lazy_dispatchers);
1589 1593
1590 ASSERT(func.IsInvokeFieldDispatcher()); 1594 ASSERT(func.IsInvokeFieldDispatcher());
1591 intptr_t token_pos = func.token_pos(); 1595 intptr_t token_pos = func.token_pos();
1592 ASSERT(func.token_pos() == 0); 1596 ASSERT(func.token_pos() == 0);
1593 ASSERT(current_class().raw() == func.Owner()); 1597 ASSERT(current_class().raw() == func.Owner());
1594 1598
1595 const Array& args_desc = Array::Handle(Z, func.saved_args_desc()); 1599 const Array& args_desc = Array::Handle(Z, func.saved_args_desc());
1596 ArgumentsDescriptor desc(args_desc); 1600 ArgumentsDescriptor desc(args_desc);
(...skipping 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after
2898 } 2902 }
2899 } 2903 }
2900 ASSERT(!unregister_pending_function_); 2904 ASSERT(!unregister_pending_function_);
2901 pending_functions.Add(current_function()); 2905 pending_functions.Add(current_function());
2902 unregister_pending_function_ = true; 2906 unregister_pending_function_ = true;
2903 } 2907 }
2904 2908
2905 2909
2906 // Parser is at the opening parenthesis of the formal parameter declaration 2910 // Parser is at the opening parenthesis of the formal parameter declaration
2907 // of function. Parse the formal parameters, initializers and code. 2911 // of function. Parse the formal parameters, initializers and code.
2908 SequenceNode* Parser::ParseConstructor(const Function& func, 2912 SequenceNode* Parser::ParseConstructor(
2909 Array* default_parameter_values) { 2913 const Function& func,
2914 ZoneGrowableArray<const Instance*>* default_parameter_values) {
2910 TRACE_PARSER("ParseConstructor"); 2915 TRACE_PARSER("ParseConstructor");
2911 ASSERT(func.IsGenerativeConstructor()); 2916 ASSERT(func.IsGenerativeConstructor());
2912 ASSERT(!func.IsFactory()); 2917 ASSERT(!func.IsFactory());
2913 ASSERT(!func.is_static()); 2918 ASSERT(!func.is_static());
2914 ASSERT(!func.IsLocalFunction()); 2919 ASSERT(!func.IsLocalFunction());
2915 const Class& cls = Class::Handle(Z, func.Owner()); 2920 const Class& cls = Class::Handle(Z, func.Owner());
2916 ASSERT(!cls.IsNull()); 2921 ASSERT(!cls.IsNull());
2917 2922
2918 CheckRecursiveInvocation(); 2923 CheckRecursiveInvocation();
2919 2924
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
3207 } 3212 }
3208 current_block_->statements->Add(new ReturnNode(func.end_token_pos())); 3213 current_block_->statements->Add(new ReturnNode(func.end_token_pos()));
3209 SequenceNode* statements = CloseBlock(); 3214 SequenceNode* statements = CloseBlock();
3210 return statements; 3215 return statements;
3211 } 3216 }
3212 3217
3213 3218
3214 // Parser is at the opening parenthesis of the formal parameter 3219 // Parser is at the opening parenthesis of the formal parameter
3215 // declaration of the function or constructor. 3220 // declaration of the function or constructor.
3216 // Parse the formal parameters and code. 3221 // Parse the formal parameters and code.
3217 SequenceNode* Parser::ParseFunc(const Function& func, 3222 SequenceNode* Parser::ParseFunc(
3218 Array* default_parameter_values) { 3223 const Function& func,
3224 ZoneGrowableArray<const Instance*>* default_parameter_values) {
3219 TRACE_PARSER("ParseFunc"); 3225 TRACE_PARSER("ParseFunc");
3220 Function& saved_innermost_function = 3226 Function& saved_innermost_function =
3221 Function::Handle(Z, innermost_function().raw()); 3227 Function::Handle(Z, innermost_function().raw());
3222 innermost_function_ = func.raw(); 3228 innermost_function_ = func.raw();
3223 3229
3224 // Save current try index. Try index starts at zero for each function. 3230 // Save current try index. Try index starts at zero for each function.
3225 intptr_t saved_try_index = last_used_try_index_; 3231 intptr_t saved_try_index = last_used_try_index_;
3226 last_used_try_index_ = 0; 3232 last_used_try_index_ = 0;
3227 3233
3228 // In case of nested async functions we also need to save the scope where 3234 // In case of nested async functions we also need to save the scope where
(...skipping 3987 matching lines...) Expand 10 before | Expand all | Expand 10 after
7216 ASSERT(new_body->scope() != NULL); 7222 ASSERT(new_body->scope() != NULL);
7217 new_body->scope()->LookupVariable(Symbols::AwaitJumpVar(), false); 7223 new_body->scope()->LookupVariable(Symbols::AwaitJumpVar(), false);
7218 new_body->scope()->LookupVariable(Symbols::AwaitContextVar(), false); 7224 new_body->scope()->LookupVariable(Symbols::AwaitContextVar(), false);
7219 new_body->scope()->LookupVariable(Symbols::AsyncCompleter(), false); 7225 new_body->scope()->LookupVariable(Symbols::AsyncCompleter(), false);
7220 new_body->scope()->RecursivelyCaptureAllVariables(); 7226 new_body->scope()->RecursivelyCaptureAllVariables();
7221 return new_body; 7227 return new_body;
7222 } 7228 }
7223 7229
7224 7230
7225 // Set up default values for all optional parameters to the function. 7231 // Set up default values for all optional parameters to the function.
7226 void Parser::SetupDefaultsForOptionalParams(const ParamList& params, 7232 void Parser::SetupDefaultsForOptionalParams(
7227 Array* default_values) { 7233 const ParamList& params,
7234 ZoneGrowableArray<const Instance*>* default_values) {
7228 if (params.num_optional_parameters > 0) { 7235 if (params.num_optional_parameters > 0) {
7229 // Build array of default parameter values. 7236 // Build array of default parameter values.
7230 *default_values = Array::New(params.num_optional_parameters);
hausner 2015/08/24 23:32:39 Instead of using a growable array, consider alloca
srdjan 2015/08/25 00:06:31 The change is turning up quite complicated, will d
7231 const ZoneGrowableArray<ParamDesc>& parameters = *params.parameters; 7237 const ZoneGrowableArray<ParamDesc>& parameters = *params.parameters;
7232 const int first_opt_param_offset = params.num_fixed_parameters; 7238 const int first_opt_param_offset = params.num_fixed_parameters;
7233 for (int i = 0; i < params.num_optional_parameters; i++) { 7239 for (int i = 0; i < params.num_optional_parameters; i++) {
7234 const Object* default_value = 7240 const Instance* default_value =
7235 parameters[i + first_opt_param_offset].default_value; 7241 parameters[i + first_opt_param_offset].default_value;
7236 default_values->SetAt(i, *default_value); 7242 default_values->Add(default_value);
7237 } 7243 }
7238 } 7244 }
7239 } 7245 }
7240 7246
7241 7247
7242 // Populate the parameter type array and parameter name array of the function 7248 // Populate the parameter type array and parameter name array of the function
7243 // with the formal parameter types and names. 7249 // with the formal parameter types and names.
7244 void Parser::AddFormalParamsToFunction(const ParamList* params, 7250 void Parser::AddFormalParamsToFunction(const ParamList* params,
7245 const Function& func) { 7251 const Function& func) {
7246 ASSERT((params != NULL) && (params->parameters != NULL)); 7252 ASSERT((params != NULL) && (params->parameters != NULL));
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
7663 } else { 7669 } else {
7664 ReportError(function_pos, 7670 ReportError(function_pos,
7665 "'%s' from outer scope has already been used, " 7671 "'%s' from outer scope has already been used, "
7666 "cannot redefine", 7672 "cannot redefine",
7667 function_variable->name().ToCString()); 7673 function_variable->name().ToCString());
7668 } 7674 }
7669 } 7675 }
7670 } 7676 }
7671 7677
7672 // Parse the local function. 7678 // Parse the local function.
7673 Array& default_parameter_values = Array::Handle(Z); 7679 ZoneGrowableArray<const Instance*>* default_parameter_values =
7680 new ZoneGrowableArray<const Instance*>(Z, 2);
7674 SequenceNode* statements = Parser::ParseFunc(function, 7681 SequenceNode* statements = Parser::ParseFunc(function,
7675 &default_parameter_values); 7682 default_parameter_values);
7676 7683
7677 // Now that the local function has formal parameters, lookup the signature 7684 // Now that the local function has formal parameters, lookup the signature
7678 // class in the current library (but not in its imports) and only create a new 7685 // class in the current library (but not in its imports) and only create a new
7679 // canonical signature class if it does not exist yet. 7686 // canonical signature class if it does not exist yet.
7680 const String& signature = String::Handle(Z, function.Signature()); 7687 const String& signature = String::Handle(Z, function.Signature());
7681 Class& signature_class = Class::ZoneHandle(Z); 7688 Class& signature_class = Class::ZoneHandle(Z);
7682 if (!is_new_closure) { 7689 if (!is_new_closure) {
7683 signature_class = function.signature_class(); 7690 signature_class = function.signature_class();
7684 } 7691 }
7685 if (signature_class.IsNull()) { 7692 if (signature_class.IsNull()) {
(...skipping 6503 matching lines...) Expand 10 before | Expand all | Expand 10 after
14189 void Parser::SkipQualIdent() { 14196 void Parser::SkipQualIdent() {
14190 ASSERT(IsIdentifier()); 14197 ASSERT(IsIdentifier());
14191 ConsumeToken(); 14198 ConsumeToken();
14192 if (CurrentToken() == Token::kPERIOD) { 14199 if (CurrentToken() == Token::kPERIOD) {
14193 ConsumeToken(); // Consume the kPERIOD token. 14200 ConsumeToken(); // Consume the kPERIOD token.
14194 ExpectIdentifier("identifier expected after '.'"); 14201 ExpectIdentifier("identifier expected after '.'");
14195 } 14202 }
14196 } 14203 }
14197 14204
14198 } // namespace dart 14205 } // namespace dart
OLDNEW
« runtime/vm/parser.h ('K') | « runtime/vm/parser.h ('k') | runtime/vm/unit_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698