2024-01-26 05:37:51 +00:00
|
|
|
namespace KumiScript.Interpreter
|
|
|
|
{
|
2024-07-12 00:17:00 +00:00
|
|
|
public class NumberExpression : Expression
|
2024-01-26 05:37:51 +00:00
|
|
|
{
|
2024-07-12 00:17:00 +00:00
|
|
|
decimal _value;
|
|
|
|
|
|
|
|
public NumberExpression(decimal value)
|
2024-01-26 05:37:51 +00:00
|
|
|
{
|
2024-07-12 00:17:00 +00:00
|
|
|
_value = value;
|
2024-01-26 05:37:51 +00:00
|
|
|
}
|
|
|
|
|
2024-07-12 00:17:00 +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
|
|
|
}
|
|
|
|
}
|