public Variable BinaryOperation(Variable variable, Variable another, VariableOperationType op) { Debug.Assert(variable.Type == this); if ((this.BinaryOperationFuncs?.ContainsKey(op)).GetValueOrDefault()) { var retVariable = this.BinaryOperationFuncs[op](variable, another); // add connection var newCon = new VariableConnection() { OperationType = op }; newCon.InVariables.Add(variable); newCon.InVariables.Add(another); newCon.OutVariables.Add(retVariable); retVariable.ParentConnections.Add(newCon); // note: retVariable might be unused. The calculation of unused variables MUST be done, but the result will be cleared out later return(retVariable); } else { throw new Exception($"Type \"{this.TypeCodeName}\" doesn't support \"{op.ToString()}\" operation."); } }
public PinocchioSubOutput OperationNodeToPinocchio(VariableOperationType operationType, List <PinocchioVariableWires> inVars, RawVariable outputRawVariable, PinocchioCommonArg commonArg) { // currently, assume there is at least one in-variable Debug.Assert(inVars[0].RawVariable.Type == this); return(this.OperationNodeToPinocchioFunc(operationType, inVars, outputRawVariable, commonArg)); }