KumiScript/interpreter/expression/NumberExpression.cs

35 lines
725 B
C#
Raw Permalink Normal View History

2024-01-26 05:37:51 +00:00
namespace KumiScript.Interpreter
{
public class NumberExpression : Expression
2024-01-26 05:37:51 +00:00
{
decimal _value;
public NumberExpression(decimal value)
2024-01-26 05:37:51 +00:00
{
_value = value;
2024-01-26 05:37:51 +00:00
}
public override decimal GetValueAsFloat()
{
return _value;
}
public override string ToString()
{
return _value.ToString();
}
public override bool Equals(Expression expr)
{
try
{
decimal d = expr.GetValueAsFloat();
return d == _value;
}
catch (InterpreterTypingException)
{
return false;
}
}
2024-01-26 05:37:51 +00:00
}
}