Ejemplo n.º 1
0
 public IfValue Calculate(string op, IfValue v=null)
 {
     switch (op) {
         case "+": return new DecValue(this.GetFloat() + v.GetFloat());
         case "-": return new DecValue(this.GetFloat() - v.GetFloat());
         case "*": return new DecValue(this.GetFloat() * v.GetFloat());
         case "/": return new DecValue(this.GetFloat() / v.GetFloat());
         default:  return new DecValue(this.GetFloat());
     }
 }
Ejemplo n.º 2
0
 public IfValue Calculate(string op, IfValue v=null)
 {
     switch (op) {
         case "+": if (v != null) return new DecValue(this.Value + v.GetFloat());
                             else return new DecValue(this.Value);
         case "-": if (v != null) return new DecValue(this.Value - v.GetFloat());
                             else return new DecValue(-this.Value);
         case "*": if (v != null) return new DecValue(this.Value * v.GetFloat());
                             else throw new RuntimeError("right operand missing in expression");
         case "/": if (v != null) return new DecValue(this.Value / v.GetFloat());
                             else throw new RuntimeError("right operand missing in expression");
         default:  throw new RuntimeError("unknown operator " + op + " in expression");
     }
 }
Ejemplo n.º 3
0
        public IfValue Calculate(string op, IfValue v = null)
        {
            switch (op)
            {
            case "+": return(new DecValue(this.GetFloat() + v.GetFloat()));

            case "-": return(new DecValue(this.GetFloat() - v.GetFloat()));

            case "*": return(new DecValue(this.GetFloat() * v.GetFloat()));

            case "/": return(new DecValue(this.GetFloat() / v.GetFloat()));

            default:  return(new DecValue(this.GetFloat()));
            }
        }
Ejemplo n.º 4
0
        public IfValue Calculate(string op, IfValue v = null)
        {
            switch (op)
            {
            case "+": if (v != null)
                {
                    return(new DecValue(this.Value + v.GetFloat()));
                }
                else
                {
                    return(new DecValue(this.Value));
                }

            case "-": if (v != null)
                {
                    return(new DecValue(this.Value - v.GetFloat()));
                }
                else
                {
                    return(new DecValue(-this.Value));
                }

            case "*": if (v != null)
                {
                    return(new DecValue(this.Value * v.GetFloat()));
                }
                else
                {
                    throw new RuntimeError("right operand missing in expression");
                }

            case "/": if (v != null)
                {
                    return(new DecValue(this.Value / v.GetFloat()));
                }
                else
                {
                    throw new RuntimeError("right operand missing in expression");
                }

            default:  throw new RuntimeError("unknown operator " + op + " in expression");
            }
        }
Ejemplo n.º 5
0
 public void Set(IfValue v)
 {
     this.Value = v.GetFloat();
 }
Ejemplo n.º 6
0
 public void Set( IfValue v )
 {
     this.Value = v.GetFloat();
 }