public IfValue Calculate(string op, IfValue v=null) { switch (op) { case "+": if (v != null) return new IntValue(this.Value + v.GetInt()); else return new IntValue(this.Value); case "-": if (v != null) return new IntValue(this.Value - v.GetInt()); else return new IntValue(-this.Value); case "*": if (v != null) return new IntValue(this.Value * v.GetInt()); else throw new RuntimeError("right operand missing in expression"); case "/": if (v != null) return new IntValue(this.Value / v.GetInt()); else throw new RuntimeError("right operand missing in expression"); default: throw new RuntimeError("unknown operator " + op + " in expression"); } }
public IfValue Calculate(string op, IfValue v = null) { switch (op) { case "+": if (v != null) { return(new IntValue(this.Value + v.GetInt())); } else { return(new IntValue(this.Value)); } case "-": if (v != null) { return(new IntValue(this.Value - v.GetInt())); } else { return(new IntValue(-this.Value)); } case "*": if (v != null) { return(new IntValue(this.Value * v.GetInt())); } else { throw new RuntimeError("right operand missing in expression"); } case "/": if (v != null) { return(new IntValue(this.Value / v.GetInt())); } else { throw new RuntimeError("right operand missing in expression"); } default: throw new RuntimeError("unknown operator " + op + " in expression"); } }
public void Set( IfValue v ) { this.Value = v.GetInt(); }
public void Set(IfValue v) { this.Value = v.GetInt(); }