2024-01-26 05:37:51 +00:00
|
|
|
namespace KumiScript.Interpreter
|
|
|
|
{
|
|
|
|
public class ProcedureExpression : Expression
|
|
|
|
{
|
|
|
|
readonly Procedure _proc;
|
|
|
|
readonly bool _branching;
|
|
|
|
public ProcedureExpression(Procedure p)
|
|
|
|
{
|
|
|
|
_proc = p;
|
|
|
|
_branching = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public ProcedureExpression(Procedure p, bool branching)
|
|
|
|
{
|
|
|
|
_proc = p;
|
|
|
|
_branching = branching;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override Expression Eval(Environment env)
|
|
|
|
{
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2024-07-12 00:17:00 +00:00
|
|
|
public override Expression Apply(Expression args, Environment env)
|
2024-01-26 05:37:51 +00:00
|
|
|
{
|
|
|
|
return _proc.ApplyWithArgs(args, env);
|
|
|
|
}
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
{
|
|
|
|
if (_proc.IsPrimitive())
|
|
|
|
return string.Format("#Primitive<{0}>", _proc.ToString());
|
|
|
|
|
|
|
|
return string.Format("#Procedure<{0}>", _proc.ToString());
|
|
|
|
}
|
|
|
|
|
2024-07-12 00:17:00 +00:00
|
|
|
public override bool IsPrimitive()
|
2024-01-26 05:37:51 +00:00
|
|
|
{
|
2024-07-12 00:17:00 +00:00
|
|
|
return _proc.IsPrimitive();
|
2024-01-26 05:37:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|