public Value Eval() { var value1 = Expression1.Eval(); var value2 = Expression2.Eval(); switch (value1) { case IntegerValue: { var number1 = value1.AsInteger(); var number2 = value2.AsInteger(); var result = Conditional(number1, number2); return(new BooleanValue(result)); } case RealValue: { var number1 = value1.AsReal(); var number2 = value2.AsReal(); var result = Conditional(number1, number2); return(new BooleanValue(result)); } default: return(new BooleanValue(false)); } }
public Value Eval() { var value1 = Expression1.Eval(); var value2 = Expression2.Eval(); return(value1 switch { IntegerValue => Operation switch { Operations.Plus => new IntegerValue(value1.AsInteger() + value2.AsInteger()), Operations.Minus => new IntegerValue(value1.AsInteger() - value2.AsInteger()), Operations.Multiply => new IntegerValue(value1.AsInteger() * value2.AsInteger()), Operations.Divide => new IntegerValue(value1.AsInteger() / value2.AsInteger()), _ => throw new ArgumentOutOfRangeException() },
public override int Eval() { return(Expression1.Eval() + Expression2.Eval()); }