Beispiel #1
0
        public Value calculate()
        {
            int size = args.Count;

            Value[] vals = new Value[size];
            for (int i = 0; i < size; i++)
            {
                vals[i] = args[i].calculate();
            }
            IFunction func = Functions.get(name);

            if (func is UserDefineFunction)
            {
                UserDefineFunction udef = (UserDefineFunction)func;
                if (size != udef.getArgsCount())
                {
                    throw new Exception("!");
                }

                Variables.push();
                for (int i = 0; i < size; i++)
                {
                    Variables.add(udef.getArgsName(i), vals[i]);
                }
                Value result = udef.execute(vals);
                Variables.pop();
                return(result);
            }
            //Function func = Functions.get(name);
            //if
            //var a = (Value)Functions.get(name).DynamicInvoke((object)vals);
            return(func.execute(vals));
        }
Beispiel #2
0
        public void execute()
        {
            UserDefineFunction u = new UserDefineFunction(arhNames, body);

            Functions.add(name, u);
        }