KumiScript/interpreter/expression/ProcedureExpression.cs

42 lines
No EOL
1 KiB
C#

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;
}
public override Expression Apply(Expression args, Environment env)
{
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());
}
public override bool IsPrimitive()
{
return _proc.IsPrimitive();
}
}
}