41 lines
No EOL
908 B
C#
41 lines
No EOL
908 B
C#
using System.Numerics;
|
|
|
|
namespace KumiScript.Interpreter
|
|
{
|
|
public class FloatExpression : NumberExpression
|
|
{
|
|
readonly decimal _value;
|
|
public FloatExpression(decimal f)
|
|
{
|
|
_value = f;
|
|
}
|
|
|
|
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 (int) _value;
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return _value.ToString();
|
|
}
|
|
}
|
|
} |