@@ -2451,9 +2451,8 @@ abstract class AstCodeGenerator
24512451 Lambda lambda = closures.lambdas[decl.function]! ;
24522452 _pushContext (decl.function);
24532453 Arguments arguments = node.arguments;
2454- visitArgumentsLists (arguments.positional, lambda.function.type,
2455- ParameterInfo .fromLocalFunction (decl.function), 1 ,
2456- typeArguments: arguments.types, named: arguments.named);
2454+ _visitArguments (arguments, lambda.function.type,
2455+ ParameterInfo .fromLocalFunction (decl.function), 1 );
24572456 b.comment ("Local call of ${decl .variable .name }" );
24582457 translator.callFunction (lambda.function, b);
24592458 return translator.outputOrVoid (lambda.function.type.outputs);
@@ -2545,33 +2544,39 @@ abstract class AstCodeGenerator
25452544 return nonNullOperandType;
25462545 }
25472546
2548- void visitArgumentsLists (List <Expression > positional,
2549- w.FunctionType signature, ParameterInfo paramInfo, int signatureOffset,
2550- {List <DartType > typeArguments = const [],
2551- List <NamedExpression > named = const []}) {
2552- for (int i = 0 ; i < typeArguments.length; i++ ) {
2553- types.makeType (this , typeArguments[i]);
2547+ void _visitArguments (Arguments node, w.FunctionType signature,
2548+ ParameterInfo paramInfo, int signatureOffset) {
2549+ // Type arguments
2550+ for (int i = 0 ; i < node.types.length; i++ ) {
2551+ types.makeType (this , node.types[i]);
25542552 }
2555- signatureOffset += typeArguments.length;
2556- for (int i = 0 ; i < positional.length; i++ ) {
2557- translateExpression (positional[i], signature.inputs[signatureOffset + i]);
2553+ signatureOffset += node.types.length;
2554+
2555+ // Positional arguments
2556+ for (int i = 0 ; i < node.positional.length; i++ ) {
2557+ translateExpression (
2558+ node.positional[i], signature.inputs[signatureOffset + i]);
25582559 }
2559- // Default values for positional parameters
2560- for (int i = positional.length; i < paramInfo.positional.length; i++ ) {
2560+ // Push default values for optional positional parameters.
2561+ for (int i = node. positional.length; i < paramInfo.positional.length; i++ ) {
25612562 final w.ValueType type = signature.inputs[signatureOffset + i];
25622563 translator.constants
25632564 .instantiateConstant (b, paramInfo.positional[i]! , type);
25642565 }
2565- // Named arguments
2566+
2567+ // Named arguments. Store evaluated arguments in locals to be able to
2568+ // re-order them based on the `ParameterInfo`.
25662569 final Map <String , w.Local > namedLocals = {};
2567- for (var namedArg in named) {
2570+ for (var namedArg in node. named) {
25682571 final w.ValueType type = signature
25692572 .inputs[signatureOffset + paramInfo.nameIndex[namedArg.name]! ];
25702573 final w.Local namedLocal = addLocal (type);
25712574 namedLocals[namedArg.name] = namedLocal;
25722575 translateExpression (namedArg.value, namedLocal.type);
25732576 b.local_set (namedLocal);
25742577 }
2578+ // Re-order named arguments and push default values for optional named
2579+ // parameters.
25752580 for (String name in paramInfo.names) {
25762581 w.Local ? namedLocal = namedLocals[name];
25772582 final w.ValueType type =
@@ -2585,12 +2590,6 @@ abstract class AstCodeGenerator
25852590 }
25862591 }
25872592
2588- void _visitArguments (Arguments node, w.FunctionType signature,
2589- ParameterInfo paramInfo, int signatureOffset) {
2590- visitArgumentsLists (node.positional, signature, paramInfo, signatureOffset,
2591- typeArguments: node.types, named: node.named);
2592- }
2593-
25942593 @override
25952594 w.ValueType visitStringConcatenation (
25962595 StringConcatenation node, w.ValueType expectedType) {
0 commit comments