private static Brep.Node BuildAssignment(Brep.LocationNode location, Brep.Node expr) { if (location == null) { throw new InvalidOperationException("Cannot assign something to a null location"); } return(new Brep.AssignmentNode(location, expr)); }
public Brep.Node Build(Vertex expVertex) { visitted[expVertex] = true; Brep.Node newNode = null; if (expVertex is ConditionalJumpVertex) { var condVertex = expVertex as ConditionalJumpVertex; var condNode = NodeBuilder.BuildNode(condVertex.Expression, funDef); Action <Brep.Node> trueAct = null; Action <Brep.Node> falseAct = null; newNode = new Brep.ConditionalJumpNode(condNode, out trueAct, out falseAct); HandleAction(trueAct, condVertex.TrueJump); HandleAction(falseAct, condVertex.FalseJump); } else if (expVertex is OneJumpVertex) { // I interpret it as a sequence of two actions, therefore: var jumpVertex = expVertex as OneJumpVertex; var first = NodeBuilder.BuildNode(jumpVertex.Expression, funDef); Action <Brep.Node> secondAct = null; newNode = new Brep.SequenceNode(new List <Brep.Node> { first }, out secondAct); HandleAction(secondAct, jumpVertex.Jump); } else { var retVertex = expVertex as ReturnVertex; newNode = NodeBuilder.BuildNode(retVertex.Expression, funDef); } if (expVertex == resNode) { funDef.BackendFunction.Result = newNode; } // finish build of dependent nodes if (awaiting.ContainsKey(expVertex)) { foreach (var act in awaiting[expVertex]) { act(newNode); } } built[expVertex] = newNode; return(newNode); }
public Brep.Node Build(FunctionCallNode funCallNode) { var args = new Brep.Node[funCallNode.Arguments.Count]; for (var i = 0; i < args.Length; ++i) { args[i] = Build(funCallNode.Arguments[i] as dynamic); } Action <Brep.Node> setter; return(funCallNode.Definition.BackendFunction.FunctionCall(funDef.BackendFunction, args, out setter)); }