Exemplo n.º 1
0
        protected override Variable Evaluate(ParsingScript script)
        {
            List <Variable> args = script.GetFunctionArgs();
            string          item = Utils.GetSafeString(args, 0);

#if __ANDROID__ == false && __IOS__ == false
            switch (m_mode)
            {
            case EditMode.ADD_DEFINITION:
                Precompiler.AddDefinition(item);
                break;

            case EditMode.ADD_NAMESPACE:
                Precompiler.AddNamespace(item);
                break;

            case EditMode.CLEAR_DEFINITIONS:
                Precompiler.ClearDefinitions();
                break;

            case EditMode.CLEAR_NAMESPACES:
                Precompiler.ClearNamespaces();
                break;
            }
#endif

            return(Variable.EmptyInstance);
        }
Exemplo n.º 2
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();

            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));
        }
Exemplo n.º 3
0
 internal CustomCompiledFunction(string funcName,
                                 string body, string[] args,
                                 Precompiler precompiler,
                                 Dictionary <string, Variable> argsMap)
     : base(funcName, body, args)
 {
     m_precompiler = precompiler;
     m_argsMap     = argsMap;
 }