@@ -520,11 +520,13 @@ public void variable(VariableDeclaration var, IStatementContainer container, boo
520
520
iMapping .setLine (var .getExpression ().getLine ());
521
521
if (exprType .equals (Types .STRING )) {
522
522
iMapping .setName ("SingleFileMapper" );
523
- iMapping .addParameter (new IMappingParameter ("file" , expr ));
523
+ //iMapping.addParameter(new IMappingParameter("file", expr));
524
+ iMapping .addParameter (mappingParameter (new MappingParameter ("file" , var .getExpression ()), expr , container ));
524
525
}
525
526
else if (exprType .isArray () && (exprType .itemType ().equals (Types .STRING ) || exprType .itemType ().isMapped ())) {
526
527
iMapping .setName ("FixedArrayMapper" );
527
- iMapping .addParameter (new IMappingParameter ("files" , expr ));
528
+ //iMapping.addParameter(new IMappingParameter("files", expr));
529
+ iMapping .addParameter (mappingParameter (new MappingParameter ("files" , var .getExpression ()), expr , container ));
528
530
}
529
531
else {
530
532
throw new CompilationException (getLocation (var ) + "cannot use expression of type " +
@@ -541,7 +543,7 @@ else if (exprType.isArray() && (exprType.itemType().equals(Types.STRING) || expr
541
543
542
544
checkMapperParams (mapperType , mapping );
543
545
for (MappingParameter param : mapping .getParameters ()) {
544
- iMapping .addParameter (mappingParameter (param , container ));
546
+ iMapping .addParameter (mappingParameter (param , null , container ));
545
547
}
546
548
iVar .setMapping (iMapping );
547
549
}
@@ -585,23 +587,24 @@ private void checkMapperParams(String mapperType, MappingDeclaration mapping) th
585
587
}
586
588
}
587
589
588
- private IMappingParameter mappingParameter (MappingParameter param , IStatementContainer container ) throws CompilationException {
590
+ private IMappingParameter mappingParameter (MappingParameter param , IExpression iParamValue , IStatementContainer container ) throws CompilationException {
589
591
IMappingParameter iParam = new IMappingParameter ();
590
592
iParam .setName (param .getName ());
591
593
Expression .Type type = param .getValue ().getExpressionType ();
594
+ if (iParamValue == null ) {
595
+ iParamValue = expressionToKarajan (param .getValue (), container );
596
+ }
592
597
if (type == Expression .Type .VARIABLE_REFERENCE ) {
593
- iParam .setValue (expressionToKarajan ( param . getValue (), container ) );
594
- }
598
+ iParam .setValue (iParamValue );
599
+ }
595
600
else {
596
601
/*
597
602
* The declarations are not processed in parallel. In order to avoid issues when
598
603
* parameters depend on other variables, declarations happen first, instantiating
599
604
* futures as placeholders. Then the actual processing happens.
600
605
*/
601
606
String parameterVariableName = "swift.mapper." + (internedIDCounter ++);
602
-
603
- IExpression iParamValue = expressionToKarajan (param .getValue (), container );
604
-
607
+
605
608
// use the abstract syntax tree rather than the intermediate tree
606
609
VariableDeclaration decl = new VariableDeclaration ();
607
610
decl .setName (parameterVariableName );
0 commit comments