Esempio n. 1
0
 override public IRTSDefine.Error onCompile(RTSList <IRTSLinker> compileList)
 {
     if (mBeConst)
     {
         return(0);
     }
     else if (mId == IRTSDefine.Linker.VARIABLE)
     {
         mConst = RTSConverter.getCompileValue(mSrc);
         if (mConst == null && !RTSUtil.isGoodName(mSrc))
         {
             return(IRTSDefine.Error.Compiling_DenyLinker);
         }
         return(0);
     }
     else if (mId == IRTSDefine.Linker.FUNCTION)
     {
         if (!RTSUtil.isGoodName(mSrc))
         {
             return(IRTSDefine.Error.Compiling_DenyLinker);
         }
         compileList.add(mArg);
         return(0);
     }
     else
     {
         return(IRTSDefine.Error.Compiling_DenyLinker);
     }
 }
Esempio n. 2
0
 override public IRTSDefine.Error onCompile(RTSList <IRTSLinker> compileList)
 {
     if (mId == IRTSDefine.Linker.TYPE)
     {
         if (mVarName == null)
         {
             return(0);
         }
         else
         {
             return(RTSUtil.isGoodName(mVarName) ? 0 : IRTSDefine.Error.Compiling_DenyLinker);
         }
     }
     else
     {
         if (mArg == null || mBody == null)
         {
             return(IRTSDefine.Error.Compiling_DenyLinker);
         }
         if (!((RTSBracketL)mArg).isVarList())
         {
             return(IRTSDefine.Error.Compiling_DenyLinker);
         }
         compileList.add(mArg);
         compileList.add(mBody);
         return(0);
     }
 }
Esempio n. 3
0
 public override IRTSDefine.Error onCompile(RTSList <IRTSLinker> compileList)
 {
     if (!RTSUtil.isGoodName(mSrc))
     {
         return(IRTSDefine.Error.Compiling_DenyLinker);
     }
     for (int i = 0; i < mArgs.length(); i++)
     {
         compileList.add(mArgs.get(i));
     }
     return(0);
 }
Esempio n. 4
0
 override public IRTSDefine.Error onCompile(RTSList <IRTSLinker> compileList)
 {
     if (!RTSUtil.isGoodName(mSrc))
     {
         return(IRTSDefine.Error.Compiling_DenyLinker);
     }
     if (mArg != null)
     {
         compileList.add(mArg);
     }
     return(0);
 }
 public bool isVarList()
 {
     if (mChild is RTSCommaL)
     {
         return(((RTSCommaL)mChild).isVarList());
     }
     else
     {
         return(mChild == null ||
                (mChild.getId() == IRTSDefine.Linker.VARIABLE && RTSUtil.isGoodName(mChild.getSrc())));
     }
 }
Esempio n. 6
0
 public object ExecuteFunction(string funcName, object[] args, bool immediate)
 {
     if (RTSUtil.isGoodName(funcName))
     {
         IRTSThread t = null;
         if (immediate)
         {
             t = mImmediateT;
         }
         else
         {
             int p = 0;
             for (int i = 1; i <= mThreads.Length; i++)
             {
                 p = i % mThreads.Length;
                 if (mThreads[p].isFinished())
                 {
                     t = mThreads[p];
                     break;
                 }
             }
         }
         if (t == null || !t.isFinished())
         {
             return(false);
         }
         IRTSFunction func = mEngine.getFunction(funcName, args == null ? 0 : args.Length);
         if (func == null)
         {
             return(false);
         }
         bool ret = t.loadRunner(func.createRunner(args));
         if (immediate)
         {
             while (!t.isFinished())
             {
                 t.run(mEngine);
             }
             return(t.getOutput());
         }
         else
         {
             mExecUpdate |= ret;
             return(ret);
         }
     }
     else
     {
         return(null);
     }
 }
 override public IRTSDefine.Error onCompile(util.RTSList <IRTSLinker> compileList)
 {
     if (mLeft == null || !RTSUtil.isGoodName(mDomain))
     {
         return(IRTSDefine.Error.Compiling_DenyLinker);
     }
     if (mArgs != null && mArgs.getId() != IRTSDefine.Linker.BRACKET)
     {
         return(IRTSDefine.Error.Compiling_DenyLinker);
     }
     compileList.add(mLeft);
     compileList.add(mArgs);
     return(0);
 }
Esempio n. 8
0
        public void LoadFunction(object target)
        {
#if UNITY_EDITOR
            if (target == null)
            {
                return;
            }
            System.Type tp = target.GetType();
            HashSet <RTSPluginAttribute> sets = new HashSet <RTSPluginAttribute>();
            mFunctions[tp] = sets;
            MethodInfo[] methods = tp.GetMethods(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static);
            //bool first = true;
            for (int i = 0; i < methods.Length; i++)
            {
                try
                {
                    object[] cmds = methods[i].GetCustomAttributes(typeof(RTSPluginAttribute), true);
                    if (cmds.Length > 0)
                    {
                        RTSPluginAttribute cmd = cmds[0] as RTSPluginAttribute;
                        if (!RTSUtil.isGoodName(cmd.Name))
                        {
                            continue;
                        }
                        RTSPluginDelegate func = (RTSPluginDelegate)System.Delegate.CreateDelegate(typeof(RTSPluginDelegate), target, methods[i].Name);
                        RTSPluginFunc     f    = new RTSPluginFunc(null, func, cmd.ArgCount);
                        if (cmd.IsCmd)
                        {
                            AddCommand(cmd.Name, f);
                        }
                        else
                        {
                            AddFunction(cmd.Name, f);
                        }
                        //Debug.LogFormat("Load Function: {0}" , desc(cmd));
                        if (!string.IsNullOrEmpty(cmd.Doc))
                        {
                            sets.Add(cmd);
                        }
                    }
                }
                catch (System.Exception e)
                {
                    PutLog(Level.error, e.ToString());
                    Debug.LogException(e);
                }
            }
#endif
        }
Esempio n. 9
0
 public bool isVarList()
 {
     for (int i = 0; i < mLins.length(); i++)
     {
         IRTSLinker l = mLins.get(i);
         if (l == null || l.getId() != IRTSDefine.Linker.VARIABLE)
         {
             return(false);
         }
         if (!RTSUtil.isGoodName(l.getSrc()))
         {
             return(false);
         }
     }
     return(true);
 }
Esempio n. 10
0
 override public IRTSLinker appendRightChild(IRTSLinker linker)
 {
     if (mVarName == null)
     {
         if (linker.getId() != IRTSDefine.Linker.VARIABLE || !RTSUtil.isGoodName(linker.getSrc()))
         {
             return(linker);
         }
         mVarName = linker.getSrc();
         return(this);
     }
     else if (mArg == null)
     {
         if (linker.getId() != IRTSDefine.Linker.BRACKET)
         {
             return(linker);
         }
         mId  = IRTSDefine.Linker.FUNCTION_DEFINE;
         mArg = linker;
         linker.setSuper(this);
         return(null);
     }
     else if (mBody == null)
     {
         if (linker.getId() != IRTSDefine.Linker.BRACKET_FLOWER)
         {
             return(linker);
         }
         mId   = IRTSDefine.Linker.FUNCTION_DEFINE;
         mBody = linker;
         linker.setSuper(this);
         return(null);
     }
     else
     {
         return(linker);
     }
 }