@@ -2451,9 +2451,8 @@ abstract class AstCodeGenerator
2451
2451
Lambda lambda = closures.lambdas[decl.function]! ;
2452
2452
_pushContext (decl.function);
2453
2453
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 );
2457
2456
b.comment ("Local call of ${decl .variable .name }" );
2458
2457
translator.callFunction (lambda.function, b);
2459
2458
return translator.outputOrVoid (lambda.function.type.outputs);
@@ -2545,33 +2544,39 @@ abstract class AstCodeGenerator
2545
2544
return nonNullOperandType;
2546
2545
}
2547
2546
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]);
2554
2552
}
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]);
2558
2559
}
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++ ) {
2561
2562
final w.ValueType type = signature.inputs[signatureOffset + i];
2562
2563
translator.constants
2563
2564
.instantiateConstant (b, paramInfo.positional[i]! , type);
2564
2565
}
2565
- // Named arguments
2566
+
2567
+ // Named arguments. Store evaluated arguments in locals to be able to
2568
+ // re-order them based on the `ParameterInfo`.
2566
2569
final Map <String , w.Local > namedLocals = {};
2567
- for (var namedArg in named) {
2570
+ for (var namedArg in node. named) {
2568
2571
final w.ValueType type = signature
2569
2572
.inputs[signatureOffset + paramInfo.nameIndex[namedArg.name]! ];
2570
2573
final w.Local namedLocal = addLocal (type);
2571
2574
namedLocals[namedArg.name] = namedLocal;
2572
2575
translateExpression (namedArg.value, namedLocal.type);
2573
2576
b.local_set (namedLocal);
2574
2577
}
2578
+ // Re-order named arguments and push default values for optional named
2579
+ // parameters.
2575
2580
for (String name in paramInfo.names) {
2576
2581
w.Local ? namedLocal = namedLocals[name];
2577
2582
final w.ValueType type =
@@ -2585,12 +2590,6 @@ abstract class AstCodeGenerator
2585
2590
}
2586
2591
}
2587
2592
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
-
2594
2593
@override
2595
2594
w.ValueType visitStringConcatenation (
2596
2595
StringConcatenation node, w.ValueType expectedType) {
0 commit comments