2024-01-26 05:37:51 +00:00
|
|
|
namespace KumiScript.Interpreter
|
|
|
|
{
|
|
|
|
public class PrimitiveProcedure : Procedure
|
|
|
|
{
|
2024-07-12 00:17:00 +00:00
|
|
|
public delegate Expression PrimitiveDelegate(Expression args, Environment env);
|
2024-01-26 05:37:51 +00:00
|
|
|
readonly PrimitiveDelegate _function;
|
|
|
|
public PrimitiveProcedure(PrimitiveDelegate function)
|
|
|
|
{
|
|
|
|
_function = function;
|
|
|
|
}
|
|
|
|
|
2024-07-12 00:17:00 +00:00
|
|
|
public override Expression ApplyWithArgs(Expression args, Environment env)
|
2024-01-26 05:37:51 +00:00
|
|
|
{
|
|
|
|
return _function(args, env);
|
|
|
|
}
|
|
|
|
|
|
|
|
public override bool IsPrimitive()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
{
|
|
|
|
return _function.ToString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|