Skip to content

Commit ad49e19

Browse files
committed
Fixed deadlocks when expressions with dependencies are used in simplified mapper declarations.
1 parent bcdca7f commit ad49e19

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/org/griphyn/vdl/engine/Karajan.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -520,11 +520,13 @@ public void variable(VariableDeclaration var, IStatementContainer container, boo
520520
iMapping.setLine(var.getExpression().getLine());
521521
if (exprType.equals(Types.STRING)) {
522522
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));
524525
}
525526
else if (exprType.isArray() && (exprType.itemType().equals(Types.STRING) || exprType.itemType().isMapped())) {
526527
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));
528530
}
529531
else {
530532
throw new CompilationException(getLocation(var) + "cannot use expression of type " +
@@ -541,7 +543,7 @@ else if (exprType.isArray() && (exprType.itemType().equals(Types.STRING) || expr
541543

542544
checkMapperParams(mapperType, mapping);
543545
for (MappingParameter param : mapping.getParameters()) {
544-
iMapping.addParameter(mappingParameter(param, container));
546+
iMapping.addParameter(mappingParameter(param, null, container));
545547
}
546548
iVar.setMapping(iMapping);
547549
}
@@ -585,23 +587,24 @@ private void checkMapperParams(String mapperType, MappingDeclaration mapping) th
585587
}
586588
}
587589

588-
private IMappingParameter mappingParameter(MappingParameter param, IStatementContainer container) throws CompilationException {
590+
private IMappingParameter mappingParameter(MappingParameter param, IExpression iParamValue, IStatementContainer container) throws CompilationException {
589591
IMappingParameter iParam = new IMappingParameter();
590592
iParam.setName(param.getName());
591593
Expression.Type type = param.getValue().getExpressionType();
594+
if (iParamValue == null) {
595+
iParamValue = expressionToKarajan(param.getValue(), container);
596+
}
592597
if (type == Expression.Type.VARIABLE_REFERENCE) {
593-
iParam.setValue(expressionToKarajan(param.getValue(), container));
594-
}
598+
iParam.setValue(iParamValue);
599+
}
595600
else {
596601
/*
597602
* The declarations are not processed in parallel. In order to avoid issues when
598603
* parameters depend on other variables, declarations happen first, instantiating
599604
* futures as placeholders. Then the actual processing happens.
600605
*/
601606
String parameterVariableName = "swift.mapper." + (internedIDCounter++);
602-
603-
IExpression iParamValue = expressionToKarajan(param.getValue(), container);
604-
607+
605608
// use the abstract syntax tree rather than the intermediate tree
606609
VariableDeclaration decl = new VariableDeclaration();
607610
decl.setName(parameterVariableName);

0 commit comments

Comments
 (0)