KumiScript/interpreter/expression/IntegerExpression.cs

42 lines
907 B
C#
Raw Normal View History

2024-01-26 05:37:51 +00:00
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();
}
}
}