KumiScript/interpreter/expression/IntegerExpression.cs
2024-01-25 23:37:51 -06:00

42 lines
907 B
C#

using System.Numerics;
namespace KumiScript.Interpreter
{
public class IntegerExpression : NumberExpression
{
readonly int _value;
public IntegerExpression(int n)
{
_value = n;
}
public override bool Equals(Expression expr)
{
NumberExpression? nexpr = expr as NumberExpression;
if (nexpr is null)
return false;
return nexpr.GetValueAsFloat() == _value;
}
public override Expression Eval(Environment env)
{
return this;
}
public override decimal GetValueAsFloat()
{
return _value;
}
public override int GetValueAsInt()
{
return _value;
}
public override string ToString()
{
return _value.ToString();
}
}
}