Exemple #1
0
        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 + "."));
                }
            }
        }
Exemple #2
0
        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();
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        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);
        }
Exemple #5
0
        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);
        }
Exemple #6
0
 public override double Evaluate(ExecFunc function, string data, ref int from)
 {
     return(function(data, ref from, Parser.EndArg));
 }
Exemple #7
0
 public Executor(ExecFunc exec)
 {
     Exec = exec;
 }
Exemple #8
0
 public Scripting(ExecFunc executor, bool noReload = false)
 {
     ExecDelegate = executor;
     NoReload     = noReload;
 }
Exemple #9
0
        public override double Evaluate(ExecFunc function, string data, ref int from)
        {
            double arg = function(data, ref from, Parser.EndArg);

            return(Math.Abs(arg));
        }
Exemple #10
0
 public abstract double Evaluate(ExecFunc function, string data, ref int from);