resolveBinding()

in src/parser/WDL/entities/WDLWorkflow.js [297:327]


  resolveBinding(node, step, parentStep) {
    const nodeValue = node.attributes.value;
    const declaration = node.attributes.key.source_string;
    const expression = extractExpression(nodeValue);

    if (!step.i[declaration] && step instanceof Workflow && step.ownDeclarations[declaration]) {
      // remove declaration and add it as an input
      const declarationObj = step.removeDeclaration(declaration);
      const desc = {
        type: declarationObj.type,
      };
      if (expression.string
        && expression.type.toLowerCase() !== 'memberaccess' && expression.type.toLowerCase() !== 'identifier') {
        desc.expression = expression.string;
      }
      const port = new Port(declaration, step, desc);
      _.forEach(declarationObj.outputs, conn => conn.to.bind(port));
      step.i[declaration] = port;
    }

    if (step.i[declaration]) {
      const bindings = WDLWorkflow.getPortsForBinding(this.workflowStep, parentStep, expression);
      _.forEach(bindings, binding => step.i[declaration].bind(binding));
      if (expression.string
        && expression.type.toLowerCase() !== 'memberaccess' && expression.type.toLowerCase() !== 'identifier') {
        step.i[declaration].expression = expression;
      }
    } else {
      throw new WDLParserError(`Undeclared variable trying to be assigned: call '${step.name}' --> '${declaration}'`);
    }
  }