/* public DependencyPass.DependencyTracker generateAST(ProtoCore.CodeBlock codeblock) { DependencyTracker tempTracker = new DependencyTracker(); foreach (Object obj in codeblock.Body) { Debug.Assert(obj is ProtoAssociative.DependencyPass.Node); Node node = obj as ProtoAssociative.DependencyPass.Node; tempTracker.AllNodes.Add(node); } return tempTracker; } * */ public DependencyPass.DependencyTracker GetDemoTracker() { IdentifierNode a = new IdentifierNode(); a.Value = "1..1000..+1"; FunctionCallNode b = new FunctionCallNode(); b.Function = new IdentifierNode() { Value = "SQRT" }; b.FormalArguments.Add(a); BinaryExpressionNode c = new BinaryExpressionNode(); c.LeftNode = a; c.Optr = ProtoCore.DSASM.Operator.mul; IdentifierNode _2Node = new IdentifierNode() { Value = "2" }; c.RightNode = _2Node; BinaryExpressionNode d = new BinaryExpressionNode(); d.LeftNode = c; d.RightNode = c; d.Optr = ProtoCore.DSASM.Operator.mul; FunctionCallNode e = new FunctionCallNode(); e.Function = new IdentifierNode() { Value = "LineFromPoint" }; e.FormalArguments.Add(a); e.FormalArguments.Add(b); e.FormalArguments.Add(d); Node f = new FunctionCallNode() { Function = new IdentifierNode() { Value = "Trim" } }; Node g = new FunctionCallNode() { Function = new IdentifierNode() { Value = "Rotate" } }; DependencyPass.DependencyTracker tracker = new DependencyPass.DependencyTracker(); tracker.AllNodes.Add(a); tracker.AllNodes.Add(b); tracker.AllNodes.Add(c); tracker.AllNodes.Add(_2Node); tracker.AllNodes.Add(d); tracker.AllNodes.Add(e); tracker.AllNodes.Add(f); tracker.AllNodes.Add(g); tracker.DirectContingents.Add(a, new List<Node>() { }); tracker.DirectContingents.Add(_2Node, new List<Node>() { }); tracker.DirectContingents.Add(b, new List<Node>() { a }); tracker.DirectContingents.Add(c, new List<Node>() { a, _2Node }); tracker.DirectContingents.Add(d, new List<Node>() { c }); tracker.DirectContingents.Add(e, new List<Node>() { a, b, d }); tracker.DirectContingents.Add(f, new List<Node>() { e }); tracker.DirectContingents.Add(g, new List<Node>() { f }); tracker.DirectDependents.Add(a, new List<Node>() {b, c, e}); tracker.DirectDependents.Add(b, new List<Node>() {e}); tracker.DirectDependents.Add(c, new List<Node>() {d}); tracker.DirectDependents.Add(d, new List<Node>() {e}); tracker.DirectDependents.Add(e, new List<Node>() {f}); tracker.DirectDependents.Add(f, new List<Node>() {g}); tracker.DirectDependents.Add(g, new List<Node>() {}); tracker.DirectDependents.Add(_2Node, new List<Node>() {c}); return tracker; }
void BaseConstructorCall(out Node bnode) { FunctionCallNode f = new FunctionCallNode(); NodeList args = null; Expect(37); if (la.kind == 1) { Ident(out bnode); f.Function = bnode; } Arguments(out args); f.FormalArguments = args; bnode = f; }
/* * public DependencyPass.DependencyTracker generateAST(ProtoCore.CodeBlock codeblock) * { * DependencyTracker tempTracker = new DependencyTracker(); * * foreach (Object obj in codeblock.Body) * { * Debug.Assert(obj is ProtoAssociative.DependencyPass.Node); * Node node = obj as ProtoAssociative.DependencyPass.Node; * tempTracker.AllNodes.Add(node); * } * return tempTracker; * } * */ public DependencyPass.DependencyTracker GetDemoTracker() { IdentifierNode a = new IdentifierNode(); a.Value = "1..1000..+1"; FunctionCallNode b = new FunctionCallNode(); b.Function = new IdentifierNode() { Value = "SQRT" }; b.FormalArguments.Add(a); BinaryExpressionNode c = new BinaryExpressionNode(); c.LeftNode = a; c.Optr = ProtoCore.DSASM.Operator.mul; IdentifierNode _2Node = new IdentifierNode() { Value = "2" }; c.RightNode = _2Node; BinaryExpressionNode d = new BinaryExpressionNode(); d.LeftNode = c; d.RightNode = c; d.Optr = ProtoCore.DSASM.Operator.mul; FunctionCallNode e = new FunctionCallNode(); e.Function = new IdentifierNode() { Value = "LineFromPoint" }; e.FormalArguments.Add(a); e.FormalArguments.Add(b); e.FormalArguments.Add(d); Node f = new FunctionCallNode() { Function = new IdentifierNode() { Value = "Trim" } }; Node g = new FunctionCallNode() { Function = new IdentifierNode() { Value = "Rotate" } }; DependencyPass.DependencyTracker tracker = new DependencyPass.DependencyTracker(); tracker.AllNodes.Add(a); tracker.AllNodes.Add(b); tracker.AllNodes.Add(c); tracker.AllNodes.Add(_2Node); tracker.AllNodes.Add(d); tracker.AllNodes.Add(e); tracker.AllNodes.Add(f); tracker.AllNodes.Add(g); tracker.DirectContingents.Add(a, new List <Node>() { }); tracker.DirectContingents.Add(_2Node, new List <Node>() { }); tracker.DirectContingents.Add(b, new List <Node>() { a }); tracker.DirectContingents.Add(c, new List <Node>() { a, _2Node }); tracker.DirectContingents.Add(d, new List <Node>() { c }); tracker.DirectContingents.Add(e, new List <Node>() { a, b, d }); tracker.DirectContingents.Add(f, new List <Node>() { e }); tracker.DirectContingents.Add(g, new List <Node>() { f }); tracker.DirectDependents.Add(a, new List <Node>() { b, c, e }); tracker.DirectDependents.Add(b, new List <Node>() { e }); tracker.DirectDependents.Add(c, new List <Node>() { d }); tracker.DirectDependents.Add(d, new List <Node>() { e }); tracker.DirectDependents.Add(e, new List <Node>() { f }); tracker.DirectDependents.Add(f, new List <Node>() { g }); tracker.DirectDependents.Add(g, new List <Node>() { }); tracker.DirectDependents.Add(_2Node, new List <Node>() { c }); return(tracker); }
void FunctionCall(out Node node) { Ident(out node); NodeList args = null; Arguments(out args); FunctionCallNode f = new FunctionCallNode(); f.FormalArguments = args; f.Function = node; node = f; }