in src/parser/WDL/entities/WDLWorkflow.js [538:612]
static getPortsForBinding(workflow, parent, expression, isWfOutput = false) {
const accessesTypes = [
'ArrayOrMapLookup',
'MemberAccess',
'FunctionCall',
'ArrayLiteral',
'ObjectLiteral',
'MapLiteral',
'TupleLiteral',
'LogicalNot',
'UnaryPlus',
'UnaryNegation',
'Add',
'Subtract',
'Multiply',
'Divide',
'Remainder',
'LogicalOr',
'LogicalAnd',
'Equals',
'NotEquals',
'LessThan',
'LessThanOrEqual',
'GreaterThan',
'GreaterThanOrEqual',
'TernaryIf',
'MapLiteralKv',
'ObjectKV',
];
const errorMessAdd = isWfOutput ? `in ${workflow.name} output block ` : '';
let binder = [expression.string];
if (accessesTypes.indexOf(expression.type) >= 0 && expression.accesses.length) {
binder = [];
_.forEach(expression.accesses, (accesses) => {
if (_.isObject(accesses)) {
const outputStep = WDLWorkflow.findStepInStructureRecursively(workflow, accesses.lhs);
if (outputStep && outputStep instanceof Step) {
if (outputStep.o[accesses.rhs]) {
binder.push(outputStep.o[accesses.rhs]);
} else {
throw new WDLParserError(`Undeclared variable ${errorMessAdd}is referenced: '${accesses.lhs}.${accesses.rhs}'`);
}
} else if (outputStep && outputStep instanceof Port) {
binder.push(outputStep);
} else {
throw new WDLParserError(`Undeclared call ${errorMessAdd}is referenced: '${accesses.lhs}'`);
}
} else if (_.isString(accesses)) {
const desiredStep = WDLWorkflow.groupNameResolver(parent, accesses);
if (desiredStep) {
if (desiredStep.i[accesses]) {
binder.push(desiredStep.i[accesses]);
} else {
binder.push(desiredStep.declarations[accesses]);
}
} else {
throw new WDLParserError(`Undeclared variable ${errorMessAdd}is referenced: '${expression.string}'`);
}
}
});
} else if (expression.type === 'identifier') {
const desiredStep = WDLWorkflow.groupNameResolver(parent, expression.string);
if (desiredStep) {
if (desiredStep.i[expression.string]) {
binder = [desiredStep.i[expression.string]];
} else {
binder = [desiredStep.declarations[expression.string]];
}
} else {
throw new WDLParserError(`Undeclared variable ${errorMessAdd}is referenced: '${expression.string}'`);
}
}
return binder;
}