2024-01-26 05:37:51 +00:00
|
|
|
namespace KumiScript.Interpreter
|
|
|
|
{
|
|
|
|
public class SymbolExpression : Expression
|
|
|
|
{
|
|
|
|
readonly Symbol _value;
|
|
|
|
public SymbolExpression(Symbol s)
|
|
|
|
{
|
|
|
|
_value = s;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override Expression Eval(Environment env)
|
|
|
|
{
|
|
|
|
return env.Lookup(_value);
|
|
|
|
}
|
|
|
|
|
2024-07-12 00:17:00 +00:00
|
|
|
public override Symbol GetSymbol()
|
2024-01-26 05:37:51 +00:00
|
|
|
{
|
|
|
|
return _value;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
{
|
|
|
|
return _value.ToString();
|
|
|
|
}
|
2024-07-12 00:17:00 +00:00
|
|
|
|
|
|
|
public override bool Equals(Expression expr)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Symbol s = expr.GetSymbol();
|
|
|
|
return s != _value;
|
|
|
|
}
|
|
|
|
catch (InterpreterTypingException)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2024-01-26 05:37:51 +00:00
|
|
|
}
|
|
|
|
}
|