public ArithOP(VariableBlock leftBlock, VariableBlock rightBlock, string output, ArithOPTypes opType, string id, bool canBeScheduled) : base(false, null, new List <string>() { leftBlock?.OutputVariable, rightBlock?.OutputVariable }, output, id, canBeScheduled) { this.OPType = opType; this.LeftBlock = leftBlock; this.RightBlock = rightBlock; }
public string AddArithOPBlock(ArithOPTypes type, string leftBlock, string rightBlock) { string a = GetUniqueName(); AddBlock(a, ArithOP.XML_TYPE_NAME); SetField(a, ArithOP.OPTypeFieldName, ArithOP.ArithOpTypeToString(type)); AddConnection(a, ArithOP.LeftArithFieldName, leftBlock); AddConnection(a, ArithOP.RightArithFieldName, rightBlock); return(a); }
public static Block Parse(XmlNode node, DFG <Block> dfg, ParserInfo parserInfo, bool canBeScheduled) { string id = ParseTools.ParseID(node); ArithOPTypes opType = ArithOP.StringToArithOPType(id, ParseTools.ParseString(node, OPTypeFieldName)); VariableBlock leftArithBlock = ParseTools.ParseBlock <VariableBlock>(node, dfg, parserInfo, id, LeftArithFieldName, new MissingBlockException(id, "Left side of arithmetic operator is missing a block.")); VariableBlock rightArithBlock = ParseTools.ParseBlock <VariableBlock>(node, dfg, parserInfo, id, RightArithFieldName, new MissingBlockException(id, "Right side of Arithmetic operator is missing a block.")); dfg.AddNode(leftArithBlock); dfg.AddNode(rightArithBlock); return(new ArithOP(leftArithBlock, rightArithBlock, parserInfo.GetUniqueAnonymousName(), opType, id, canBeScheduled)); }
public static string ArithOpTypeToString(ArithOPTypes type) { switch (type) { case ArithOPTypes.ADD: return("ADD"); case ArithOPTypes.SUB: return("MINUS"); case ArithOPTypes.MUL: return("MULTIPLY"); case ArithOPTypes.DIV: return("DIVIDE"); case ArithOPTypes.POW: return("POWER"); default: throw new InternalParseException("Failed to parse the arithmetic operator type. Type: " + type.ToString()); } }