public FunctionDefinition(string name, FnType type, Action <InterpreterRuntime, int> action, ParamType[] parameterTypes) { this.name = name; this.type = type; this.action = action; this.parameterTypes = parameterTypes; }
public readonly SideFx sideFx; // does this primitive cause side effects? if so, it should never be optimized away public Primitive(string name, int minargs, Function fn, FnType argsType = FnType.ConstArgs, SideFx sideFx = SideFx.None) { this.name = name; this.minargs = minargs; this.fn = fn; this.argsType = argsType; this.sideFx = sideFx; }
/// <summary> /// Registers a constructor. /// </summary> /// <param name="name"> Function name. </param> /// <param name="func"> The function. </param> public static void RegisterAction(string name, Action <InterpreterRuntime, int> func, FnType type, ParamType[] parameterTypes) { if (Actions.ContainsKey(name) == false) { Actions.Add(name, new FunctionDefinition(name, type, func, parameterTypes)); } else { Log.Warning($"Action already exists for {name}, will set to the one provided"); Actions[name] = new FunctionDefinition(name, type, func, parameterTypes); } }