public void Run(ExecFunc exec) { foreach (var func in Functions) { List <Param> refParams = new List <Param>(); foreach (var refParam in func.ParamRefs) { var paramVal = ScriptContext.GetRaw(refParam.Key); refParams.Add(new Param { Name = refParam.Target, Value = paramVal }); } func.Context.AddParams(refParams.ToArray()); exec(func.Name, func.Context); if (func.OutputKey == "$out") { OutputContext.AddParams(func.Context.GetResults()); } if (func.OutputKey != null) { ScriptContext.AddParams(func.Context.GetResults(func.OutputKey + ".")); } } }
public void ExecuteFunctionTopLevel(string functionName) { LLVMValueRef funcValue = _globalModule.GetNamedFunction(functionName); funcValue.ThrowIfNull(); IntPtr pointerToFunc = LLVMSharp.LLVM.GetPointerToGlobal(_engine, funcValue); ExecFunc func = Marshal.GetDelegateForFunctionPointer <ExecFunc>(pointerToFunc); func(); }
public override double Evaluate(ExecFunc function, string data, ref int from) { double num; if (!double.TryParse(_item, out num)) { throw new ArgumentException("Could not parse token [" + _item + "]"); } return(num); }
static protected void ExecMenuAction(object sender, EventArgs e) { System.Windows.Forms.ToolStripMenuItem mi = sender as System.Windows.Forms.ToolStripMenuItem; //MessageBox.Show(mi.Tag.ToString()); ExecFunc exf = (ExecFunc)Delegate.CreateDelegate( // Динамическое создание делегата из MethodInfo typeof(ExecFunc), // Тип создаваемого делегата sender, // У кого вызывать метод mi.Tag.ToString()); // Какой метод вызывать exf(sender, e); }
public Commands() { ExecDelegate = new ExecFunc((name, context) => { name = name.Split('.').Aggregate((s, e) => s + " " + e); Command command = Find(c => c.Name == name); if (command == null) { Console.WriteLine("Command {0} not found!", name); return; } command.Run(context); }); StartupScripts = new Scripting(ExecDelegate, true); RuntimeScripts = new Scripting(ExecDelegate); Command.SetCommandsReference(this); }
public override double Evaluate(ExecFunc function, string data, ref int from) { return(function(data, ref from, Parser.EndArg)); }
public Executor(ExecFunc exec) { Exec = exec; }
public Scripting(ExecFunc executor, bool noReload = false) { ExecDelegate = executor; NoReload = noReload; }
public override double Evaluate(ExecFunc function, string data, ref int from) { double arg = function(data, ref from, Parser.EndArg); return(Math.Abs(arg)); }
public abstract double Evaluate(ExecFunc function, string data, ref int from);