/// <summary> /// Produces AST for a partial function application of a multi-output function. /// </summary> /// <param name="model">NodeModel to produce AST for.</param> /// <param name="rhs">AST representing the partial application. This will need to be used to assign all output port identifiers.</param> /// <param name="resultAst">Result accumulator: add all new output AST to this list.</param> protected virtual void BuildAstForPartialMultiOutput( NodeModel model, AssociativeNode rhs, List<AssociativeNode> resultAst) { var missingAmt = Enumerable.Range(0, model.InPortData.Count).Count(x => !model.HasInput(x)); var tmp = AstFactory.BuildIdentifier("__partial_" + model.GUID.ToString().Replace('-', '_')); resultAst.Add(AstFactory.BuildAssignment(tmp, rhs)); resultAst.AddRange( (Definition.ReturnKeys ?? Enumerable.Empty<string>()).Select( AstFactory.BuildStringNode) .Select( (rtnKey, index) => AstFactory.BuildAssignment( model.GetAstIdentifierForOutputIndex(index), AstFactory.BuildFunctionObject( "__ComposeBuffered", 3, new[] { 0, 1 }, new List<AssociativeNode> { AstFactory.BuildExprList( new List<AssociativeNode> { AstFactory.BuildFunctionObject( "__GetOutput", 2, new[] { 1 }, new List<AssociativeNode> { AstFactory.BuildNullNode(), rtnKey }), tmp }), AstFactory.BuildIntNode(missingAmt), AstFactory.BuildNullNode() })))); }