private static void BuildIdentToIdentStatement(Node node, Node nodeI, AST statementList) { Assignment a = new Assignment((IdentNode)node, (IdentNode)nodeI); if (statementList.nodeMap.ContainsKey(node.Guid)) { Node nodeToRemove = statementList.GetNode(a.Guid); int index = statementList.nodeList.IndexOf(nodeToRemove); statementList.RemoveNode(nodeToRemove); statementList.nodeList.Insert(index, a); statementList.nodeMap.Add(a.Guid, a); } else statementList.AddNode(a); }
private static void BuildIdentToOperatorStatement(Node node, AST statementList, Node nodeI) { Assignment a2 = (Assignment)statementList.GetNode(nodeI.Guid); Assignment a = new Assignment((IdentNode)node, (IdentNode)a2.left); if (statementList.nodeMap.ContainsKey(a.Guid)) { Node nodeToRemove = statementList.GetNode(a.Guid); int index = statementList.nodeList.IndexOf(nodeToRemove); statementList.RemoveNode(nodeToRemove); statementList.nodeList.Insert(index, a); statementList.nodeMap.Add(a.Guid, a); } else statementList.AddNode(a); }
private void BuildOperatorStatement(Node node, AST statementList) { Operator n = (Operator)node; Expr e1 = null; Expr e2 = null; tguid = GetTempGUID(n.Guid); BinExprNode b = new BinExprNode(e1, n, e2); Assignment a = new Assignment(new IdentNode(n.tempName, tguid), b); statementList.AddNode(a); }
private static int BuildIdentToCodeBlockIdentStatement(Node node, Node nodeI, List<Node> nodes, AST statementList, int j) { Block block = nodeI as Block; Validity.Assert(block != null); // Comment Jun: Check if the codeblock is a single ident string lhs = block.LHS; if (string.IsNullOrEmpty(lhs)) { lhs = block.TrimName(); } Assignment a = new Assignment((IdentNode)node, new IdentNode(lhs, block.Guid)); if (statementList.nodeMap.ContainsKey(a.Guid)) { int index = statementList.nodeList.IndexOf(statementList.GetNode(a.Guid)); statementList.RemoveNode(statementList.GetNode(a.Guid)); statementList.nodeList.Insert(index, a); statementList.nodeMap.Add(a.Guid, a); } else { statementList.AddNode(a); } return ++j; }
private void BuildFunctionCallStatement(Node node, AST statementList) { Func n = (Func)node; tguid = GetTempGUID(n.Guid); FunctionCall f = new FunctionCall(n); Assignment a = new Assignment(new IdentNode(n.tempName, tguid), f); statementList.AddNode(a); }
private void BuildArrayNodeStatement(Node node, AST statementList) { Expr e = (Expr)node; tguid = GetTempGUID(e.Guid); Assignment a = new Assignment(new IdentNode(GraphToDSCompiler.kw.tempPrefix + tguid, tguid), e); statementList.AddNode(a); }
private void BuildLiteralNodeStatement(Node node, AST statementList) { LiteralNode n = (LiteralNode)node; tguid = GetTempGUID(n.Guid); string name = GraphToDSCompiler.kw.tempPrefix + tguid; n.tempName = name; Node a = new Assignment(new IdentNode(name, tguid), n); statementList.AddNode(a); }
private void BuildBlockStatement(Node node, AST statementList) { if (node.children.Count > 1 || node.IsLeaf || node.IsIsland) { statementList.AddNode(node); } else { Block n = node as Block; Node a; // TODO Jun: why is this check needed? // This checks if the current node is a full expression // If a codeblock contains LHS then it is a full expression if (!string.IsNullOrEmpty(n.LHS)) { // This is a full expression // such as: [a = 2;] a = new Assignment(new IdentNode(n.LHS, node.Guid), new IdentNode(n.LHS, node.Guid)); } else { // This is a single identifier // such as: [a;] string s = n.Name; s = s.TrimEnd(';'); a = new Assignment(new IdentNode(s, node.Guid), new IdentNode(s, node.Guid)); } statementList.AddNode(a); } }
private void BuildIdentStatement(Node node, AST statementList) { IdentNode identNode = node as IdentNode; Assignment a = new Assignment(identNode, identNode); statementList.AddNode(a); }