private Value Subtraction(SubtractionNode exp) { try { Constant left = Eval(exp.Left).GetRValue(); Constant right = Eval(exp.Right).GetRValue(); Constant.Type leftType = left.ConstantType; Constant.Type rightType = right.ConstantType; Constant.Type bt = Max(leftType, rightType); switch (bt) { case Constant.Type.Complex: { ComplexValue l = (ComplexValue)Convert(left, bt); ComplexValue r = (ComplexValue)Convert(right, bt); return(ComplexValue.OpSub(l, r)); } case Constant.Type.Int: { IntValue l = (IntValue)Convert(left, bt); IntValue r = (IntValue)Convert(right, bt); return(IntValue.OpSub(l, r)); } case Constant.Type.Float: { FloatValue l = (FloatValue)Convert(left, bt); FloatValue r = (FloatValue)Convert(right, bt); return(FloatValue.OpSub(l, r)); } } throw new ModelInterpreterException("Вычитание не определено для типа \"" + bt.ToString() + "\".") { Line = exp.Line, Position = exp.Position }; } catch (TypeConversionError exc) { throw new ModelInterpreterException($"Не удалось преобразование из \"{exc.Src}\" в \"{exc.Dst}\"") { Line = exp.Line, Position = exp.Position }; } catch (Exception exc) { throw new ModelInterpreterException(exc.Message) { Line = exp.Line, Position = exp.Position }; } }