Esempio n. 1
0
        protected override Variable Evaluate(ParsingScript script)
        {
            string funcReturn, funcName;

            Utils.GetCompiledArgs(script, out funcReturn, out funcName);

#if __ANDROID__ == false && __IOS__ == false
            Precompiler.RegisterReturnType(funcName, funcReturn);

            Dictionary <string, Variable> argsMap;
            string[] args = Utils.GetCompiledFunctionSignature(script, out argsMap);

            script.MoveForwardIf(Constants.START_GROUP, Constants.SPACE);
            int parentOffset = script.Pointer;

            string body = Utils.GetBodyBetween(script, Constants.START_GROUP, Constants.END_GROUP);

            Precompiler precompiler = new Precompiler(funcName, args, argsMap, body, script);
            precompiler.Compile(m_scriptInCSharp);

            CustomCompiledFunction customFunc = new CustomCompiledFunction(funcName, body, args, precompiler, argsMap, script);
            customFunc.ParentScript = script;
            customFunc.ParentOffset = parentOffset;

            ParserFunction.RegisterFunction(funcName, customFunc, false /* not native */);
#endif
            return(new Variable(funcName));
        }
Esempio n. 2
0
        public static Variable RunCompiled(string functionName, string argsString)
        {
            string          adjArgs   = PrepareArgs(argsString, true);
            ParsingScript   argScript = new ParsingScript(adjArgs);
            List <Variable> args      = argScript.GetFunctionArgs();

            ParserFunction function = ParserFunction.GetFunction(functionName, null);

            if (function is CustomCompiledFunction)
            {
                CustomCompiledFunction customFunction = function as CustomCompiledFunction;
                Variable result = customFunction.Run(args);
                if (result != null)
                {
                    return(result);
                }
            }
            return(Calculate(functionName, argsString));
        }