internal override IEnumerable <AssociativeNode> BuildAst(List <AssociativeNode> inputAstNodes, AstBuilder.CompilationContext context) { //Do not build if the node is in error. if (State == ElementState.Error) { return(Enumerable.Empty <AssociativeNode>()); } var resultNodes = new List <AssociativeNode>(); // Define unbound variables if necessary if (inputIdentifiers != null && inputAstNodes != null && inputIdentifiers.Count == inputAstNodes.Count) { var initStatments = inputIdentifiers.Zip(inputAstNodes, (ident, rhs) => { var identNode = AstFactory.BuildIdentifier(ident); if (context != AstBuilder.CompilationContext.NodeToCode) { MapIdentifiers(identNode); } return(AstFactory.BuildAssignment(identNode, rhs)); }); resultNodes.AddRange(initStatments); } foreach (var astNode in codeStatements.Select(stmnt => NodeUtils.Clone(stmnt.AstNode))) { if (context != AstBuilder.CompilationContext.NodeToCode) { MapIdentifiers(astNode); } resultNodes.Add(astNode as AssociativeNode); } return(resultNodes); }
internal override IEnumerable <AssociativeNode> BuildAst(List <AssociativeNode> inputAstNodes, AstBuilder.CompilationContext context) { return(Controller.BuildAst(this, inputAstNodes)); }
internal override IEnumerable <AssociativeNode> BuildAst(List <AssociativeNode> inputAstNodes, AstBuilder.CompilationContext context) { var rhs = AstFactory.BuildStringNode(Value); var assignment = AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), rhs); return(new[] { assignment }); }
internal override IEnumerable <AssociativeNode> BuildAst(List <AssociativeNode> inputAstNodes, AstBuilder.CompilationContext context) { var paramDict = InPortData.Select(x => x.NickName) .Zip <string, AssociativeNode, Tuple <string, AssociativeNode> >(inputAstNodes, Tuple.Create) .ToDictionary(x => x.Item1, x => x.Item2); AssociativeNode rhs; if (null == _parsed) { rhs = AstFactory.BuildNullNode(); } else { List <AssociativeNode> newInputs = _parsed.Count == 1 ? new List <AssociativeNode> { _parsed[0].GetAstNode(paramDict) } : _parsed.Select(x => x.GetAstNode(paramDict)).ToList(); rhs = newInputs.Count == 1 ? newInputs[0] : AstFactory.BuildExprList(newInputs); } var assignment = AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), rhs); return(new[] { assignment }); }
internal override IEnumerable <AssociativeNode> BuildAst(List <AssociativeNode> inputAstNodes, AstBuilder.CompilationContext context) { AssociativeNode assignment; if (null == inputAstNodes || inputAstNodes.Count == 0) { assignment = AstFactory.BuildAssignment(AstIdentifierForPreview, AstFactory.BuildNullNode()); } else { assignment = AstFactory.BuildAssignment(AstIdentifierForPreview, inputAstNodes[0]); } return(new[] { assignment }); }
internal override IEnumerable <AssociativeNode> BuildAst(List <AssociativeNode> inputAstNodes, AstBuilder.CompilationContext context) { if (context == AstBuilder.CompilationContext.NodeToCode) { var rhs = AstFactory.BuildStringNode(Value.Replace(@"\", @"\\")); var assignment = AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), rhs); return(new[] { assignment }); } else { return(base.BuildAst(inputAstNodes, context)); } }