Exemple #1
0
        public override Object Evaluate(Executer exec)
        {
            object[]      args     = new object[this.Arguments.Count];
            System.Type[] argTypes = new Type[this.Arguments.Count];
            for (int i = 0; i < this.Arguments.Count; i++)
            {
                Expression expr = (Expression)this.Arguments[i];
                //terms for functions *always* have an Expression and no Value.
                args[i]     = expr.Evaluate(exec).GetUnboxed(exec);
                argTypes[i] = args[i].GetType();
            }

            if (this.BelongsToObject == null)
            {
                this.BelongsToObject = MemberSearch.FindMethodObject(this.Name, argTypes);
            }

            if (this.BelongsToObject.GetType() == typeof(Nodes.ClassNode))
            {
                Nodes.MethodNode method = ((Nodes.ClassNode) this.BelongsToObject).GetMethod(this.Name);
                //TODO: arguments can't be set like this - another thread may call the same
                //method *while* this call is in execution, so arguments must be put on a stack!
                method.SetArguments(args);
                Executer exe = new Executer(method);
                object   o   = exe.Run();             //method.Execute();
                return(Object.CreateType(o));
            }
            return(Object.CreateType(Endogine.Serialization.Access.CallMethod(
                                         this.BelongsToObject, this.Name, args)));
        }
Exemple #2
0
        public override Object Evaluate(Executer exec)
        {
            object[] args = new object[this.Arguments.Count];
            System.Type[] argTypes = new Type[this.Arguments.Count];
            for (int i = 0; i < this.Arguments.Count; i++)
            {
                Expression expr = (Expression)this.Arguments[i];
                //terms for functions *always* have an Expression and no Value.
                args[i] = expr.Evaluate(exec).GetUnboxed(exec);
                argTypes[i] = args[i].GetType();
            }

            if (this.BelongsToObject == null)
                this.BelongsToObject = MemberSearch.FindMethodObject(this.Name, argTypes);

            if (this.BelongsToObject.GetType() == typeof(Nodes.ClassNode))
            {
                Nodes.MethodNode method = ((Nodes.ClassNode)this.BelongsToObject).GetMethod(this.Name);
                //TODO: arguments can't be set like this - another thread may call the same
                //method *while* this call is in execution, so arguments must be put on a stack!
                method.SetArguments(args);
                Executer exe = new Executer(method);
                object o = exe.Run(); //method.Execute();
                return Object.CreateType(o);
            }
            return Object.CreateType(Endogine.Serialization.Access.CallMethod(
                this.BelongsToObject, this.Name, args));
        }
Exemple #3
0
        public ActionResult runRecentTorrents()
        {
            var resp = executer.Run("/home/akash/Documents/script/scriptingEnv/bin/python", "/home/akash/Documents/script/scraping/1.PirateBay/RecentTorrents.py");

            return(Ok(resp));
        }