Esempio n. 1
0
 public FunctionDefinition(string name, FnType type, Action <InterpreterRuntime, int> action, ParamType[] parameterTypes)
 {
     this.name           = name;
     this.type           = type;
     this.action         = action;
     this.parameterTypes = parameterTypes;
 }
Esempio n. 2
0
        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;
        }
Esempio n. 3
0
 /// <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);
     }
 }