Exemple #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());
     }
 }
Exemple #2
0
 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");
     }
 }
Exemple #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()));
            }
        }
Exemple #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");
            }
        }
Exemple #5
0
 public ExpressionLeaf( IfValue v )
 {
     this.Value = v;
 }
Exemple #6
0
 public void Set( IfValue v )
 {
     this.Text = v.GetString();
 }
Exemple #7
0
 public void Set(IfValue v)
 {
     this.Value = v.GetFloat();
 }
Exemple #8
0
 public void Set( IfValue v )
 {
     this.Value = v.GetInt();
 }
Exemple #9
0
 public ExpressionLeaf(IfValue v)
 {
     this.Value = v;
 }
Exemple #10
0
 public void Set(IfValue v)
 {
     this.Text = v.GetString();
 }
Exemple #11
0
 public void Set(IfValue v)
 {
     this.Value = v.GetInt();
 }
Exemple #12
0
 public void Set( IfValue v )
 {
     this.Value = v.GetFloat();
 }