Esempio n. 1
0
        override public IRTSRunner createRunner()
        {
            IRTSRunner           r   = null;
            RTSList <IRTSRunner> lrs = null;

            if (mArg != null)
            {
                RTSList <IRTSLinker> lins = ((RTSBracketL)mArg).getChildAsList();
                if (lins != null)
                {
                    lrs = new RTSList <IRTSRunner>(lins.length());
                    for (int i = 0; i < lins.length(); i++)
                    {
                        IRTSLinker l = lins.get(i);
                        if (l == null)
                        {
                            lrs.add(null);
                        }
                        else
                        {
                            lrs.add(l.createRunner());
                        }
                    }
                }
            }
            r = new RTSFuncR(mCastType, mSrc, lrs);
            return(r);
        }
 override public bool appendLeftChild(IRTSLinker oper)
 {
     mVar = oper;
     oper.setSuper(this);
     mVarAtLeft = true;
     return(true);
 }
Esempio n. 3
0
 public void reset()
 {
     mCompiling = false;
     mReader.Reset();
     mExeLinker  = null;
     mTempLinker = null;
 }
Esempio n. 4
0
 public RTSInnerFunction(IRTSType returnType, RTSList <IRTSLinker> arg, IRTSLinker body)
 {
     mLimitArg   = true;
     mArg        = arg;
     mBody       = body;
     mReturnType = returnType;
 }
Esempio n. 5
0
 override public bool appendLeftChild(IRTSLinker linker)
 {
     if (linker.getId() == IRTSDefine.Linker.BRACKET)
     {
         IRTSType ctp = ((RTSBracketL)linker).getCastType();
         mCastType = ctp;
         return(ctp != null);
     }
     else if (linker.getId() == IRTSDefine.Linker.PROPERTY)
     {
         mProperty |= ((RTSPropertyL)linker).getProperty();
         return(true);
     }
     else if (linker.getId() == IRTSDefine.Linker.TYPE)
     {
         mProperty |= IRTSDefine.Property.DECALRE;
         mCastType  = ((RTSTypeL)linker).getRTSType();
         linker.setSuper(this);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 6
0
 override public string ToString()
 {
     System.Text.StringBuilder buf = new System.Text.StringBuilder();
     buf.Append('{');
     if (mChildrenL != null && mChildrenL.length() > 0)
     {
         buf.Append('\n');
         for (int i = 0; i < mChildrenL.length(); i++)
         {
             IRTSLinker lin = mChildrenL.get(i);
             if (lin != null)
             {
                 string s   = lin.ToString();
                 int    off = 0;
                 for (int j = 0; j < s.Length; j++)
                 {
                     if (s[j] == '\n')
                     {
                         buf.Append('\t').Append(s.Substring(off, j - off))
                         .Append('\n');
                         off = j + 1;
                     }
                     else if (j == s.Length - 1)
                     {
                         buf.Append('\t').Append(s.Substring(off))
                         .Append(';').Append('\n');
                     }
                 }
             }
         }
     }
     buf.Append('}');
     return(buf.ToString());
 }
 public IRTSDefine.Stack run(IRTSStack stack)
 {
     if (mCur == 0)
     {
         mCur++;
         mConditionR = mConditionL == null ? null : mConditionL.createRunner();
         if (stack.getThread().loadRunner(mConditionR))
         {
             return(0);
         }
     }
     if (mCur == 1)
     {
         mCur++;
         object     o = mConditionR == null ? null : mConditionR.getOutput();
         bool       c = org.vr.rts.modify.RTSBool.valueOf(o);
         IRTSLinker l = c ? mTrueL : mFalseL;
         mResultR = l == null ? null : l.createRunner();
         if (stack.getThread().loadRunner(mResultR))
         {
             return(0);
         }
     }
     return(0);
 }
 public RTSForR(IRTSLinker initL, IRTSLinker condition, IRTSLinker endL, IRTSLinker bodyL)
 {
     mLins    = new IRTSRunner[3];
     mLins[0] = condition == null ? null : condition.createRunner();
     mLins[1] = bodyL == null ? null : bodyL.createRunner();
     mLins[2] = endL == null ? null : endL.createRunner();
     if (initL == null)
     {
         mInit = null;
     }
     else if (initL.getId() == IRTSDefine.Linker.COMMA)
     {
         org.vr.rts.util.RTSList <IRTSLinker> lst = ((org.vr.rts.linker.RTSCommaL)initL).getChildren();
         if (lst == null || lst.length() == 0)
         {
             mInit = null;
         }
         else
         {
             mInit = new IRTSRunner[lst.length()];
             for (int i = 0; i < mInit.Length; i++)
             {
                 IRTSLinker l = lst.get(i);
                 mInit[i] = l == null ? null : l.createRunner();
             }
         }
     }
     else
     {
         mInit    = new IRTSRunner[1];
         mInit[0] = initL.createRunner();
     }
 }
Esempio n. 9
0
 public bool Execute(string cmd, int threadId)
 {
     if (!string.IsNullOrEmpty(cmd))
     {
         int        tid = FindFreeThread(threadId);
         IRTSThread t   = tid == -1 ? null : mThreads[tid];
         if (t == null)
         {
             return(false);
         }
         mCompiler.reset();
         mCompiler.loadSource(cmd);
         while (mCompiler.isCompiling())
         {
             IRTSDefine.Error error = mCompiler.onCompile(mEngine);
             if (error != 0)
             {
                 logError("rts compile error:" + RTSUtil.getEnumDescript(typeof(IRTSDefine.Error), (int)error) + "-" + mCompiler.getCompilingLinker());
                 return(false);
             }
         }
         IRTSLinker root = mCompiler.getRootLinker();
         if (root != null)
         {
             bool ret = t.loadRunner(root.createRunner());
             mExecUpdate |= ret;
             return(ret);
         }
         return(false);
     }
     return(false);
 }
Esempio n. 10
0
 /**
  * 在运行线程(RTSThread)中计算,返回值为表示return的类型,有return,break,continue
  *
  * @param thread
  * @return returnType
  */
 public IRTSDefine.Stack run(IRTSStack stack)
 {
     if (doCompile)
     {
         doCompile = false;
         compiler.loadSource(source);
         while (compiler.isCompiling())
         {
             IRTSDefine.Error err = compiler.onCompile(stack.getThread().getEngine());
             if (err != 0)
             {
                 IRTSLog log = stack.getThread().getEngine().getLogger();
                 if (log != null)
                 {
                     log.logError("无法解析内容 \"" + source + "\"");
                 }
                 return(0);
             }
         }
         IRTSLinker l = compiler.getRootLinker();
         child = l.createRunner();
         if (stack.getThread().loadRunner(child))
         {
             return(0);
         }
     }
     return(0);
 }
 override public IRTSLinker appendRightChild(IRTSLinker linker)
 {
     if (linker.getId() == IRTSDefine.Linker.COLON)
     {
         if (mOnFalse)
         {
             return(linker);
         }
         mOnFalse = true;
         return(this);
     }
     else if (mOnFalse)
     {
         IRTSLinker ret = mFalseL;
         if (ret != null)
         {
             ret.setSuper(null);
         }
         mFalseL = linker;
         linker.setSuper(this);
         return(ret);
     }
     else
     {
         IRTSLinker ret = mTrueL;
         if (ret != null)
         {
             ret.setSuper(null);
         }
         mTrueL = linker;
         linker.setSuper(this);
         return(ret);
     }
 }
Esempio n. 12
0
 override public IRTSLinker appendRightChild(IRTSLinker linker)
 {
     IRTSDefine.Linker id = linker.getId();
     if (id == IRTSDefine.Linker.SEMICOLON)
     {
         if (mBodyL == null)
         {
             return(linker);
         }
         mOver = true;
         return(this);
     }
     else
     {
         if (mOver)
         {
             return(linker);
         }
         IRTSLinker ret = mBodyL;
         if (ret != null)
         {
             ret.setSuper(null);
         }
         mBodyL = linker;
         linker.setSuper(this);
         if (linker.isStructure())
         {
             mOver = true;
         }
         return(ret);
     }
 }
Esempio n. 13
0
 override public IRTSLinker appendRightChild(IRTSLinker oper)
 {
     IRTSDefine.Linker id = oper.getId();
     if (mCArg)
     {
         if (id == IRTSDefine.Linker.BRACKET2)
         {
             mCArg = false;
             mCur++;
             return(this);
         }
         else if (id == IRTSDefine.Linker.SEMICOLON)
         {
             if (mCur < 2)
             {
                 mCur++;
                 return(this);
             }
             else
             {
                 return(oper);
             }
         }
         else
         {
             IRTSLinker ret = mChildren[mCur];
             if (ret != null)
             {
                 ret.setSuper(null);
             }
             mChildren[mCur] = oper;
             oper.setSuper(this);
             return(ret);
         }
     }
     else if (mCur == 0)
     {
         if (id != IRTSDefine.Linker.BRACKET)
         {
             return(oper);
         }
         mCArg = true;
         return(this);
     }
     else
     {
         if (mCur != 3)
         {
             return(oper);
         }
         IRTSLinker ret = mChildren[mCur];
         if (ret != null)
         {
             ret.setSuper(null);
         }
         mChildren[mCur] = oper;
         oper.setSuper(this);
         return(ret);
     }
 }
 public RTSDomainR(IRTSLinker left, string name)
 {
     mDomain     = name;
     mLeftL      = left;
     mArgNum     = 0;
     mAsFunction = false;
 }
Esempio n. 15
0
 override public IRTSDefine.Error onCompile(org.vr.rts.util.RTSList <IRTSLinker> compileList)
 {
     if (!mClosed && mId != 0)
     {
         return(IRTSDefine.Error.Compiling_DenyLinker);
     }
     if (mTempL != null)
     {
         if (mChildrenL == null)
         {
             mChildrenL = new org.vr.rts.util.RTSList <IRTSLinker>(1);
         }
         mChildrenL.add(mTempL);
         mTempL = null;
     }
     if (mChildrenL != null)
     {
         for (int i = 0; i < mChildrenL.length(); i++)
         {
             IRTSLinker l = mChildrenL.get(i);
             if (l != null)
             {
                 compileList.add(l);
             }
         }
     }
     return(0);
 }
Esempio n. 16
0
 public RTSInnerFunction(IRTSLinker body)
 {
     mLimitArg   = false;
     mReturnType = null;
     mArg        = null;
     mBody       = body;
 }
Esempio n. 17
0
 public IRTSDefine.Stack run(IRTSStack stack)
 {
     if (!mVarLoaded)
     {
         mVarLoaded = true;
         mVarR      = mVar == null ? null : mVar.createRunner();
         if (stack.getThread().loadRunner(mVarR))
         {
             return(0);
         }
     }
     if (!mIndexLoaded)
     {
         mIndexLoaded = true;
         mIndexR      = mIndex == null ? null : mIndex.createRunner();
         if (stack.getThread().loadRunner(mIndexR))
         {
             return(0);
         }
     }
     while (mArray != null && mListCur < mArray.length())
     {
         IRTSLinker l = mArray.get(mListCur);
         mArrayR[mListCur] = l == null ? null : l.createRunner();
         if (stack.getThread().loadRunner(mArrayR[mListCur++]))
         {
             return(0);
         }
     }
     if (mArrayR != null)
     {
         //org.vr.rts.typedef.RTSarray arr = new org.vr.rts.typedef.RTSarray(mArrayR.Length);
         object[] arr = new object[mArrayR.Length];
         for (int i = 0; i < mArrayR.Length; i++)
         {
             object v = mArrayR[i] == null ? null : mArrayR[i].getOutput();
             //arr.set(i, v);
             arr[i] = v;
         }
         mValue = arr;
     }
     else
     {
         object obj   = mVarR == null ? null : mVarR.getOutput();
         object index = mIndexR == null ? null : mIndexR.getOutput();
         int    n     = org.vr.rts.modify.RTSInteger.valueOf(index);
         if (obj != null && obj is System.Collections.IList)
         {
             mValue = ((System.Collections.IList)obj)[n];
         }
         else
         {
             mValue = n == 0 ? obj : null;
         }
     }
     return(0);
 }
Esempio n. 18
0
 private IRTSDefine.Error onBuild(IRTSEngine lib)
 {
     mReader.fixCharsOffset();
     if (mReader.hasNext())
     {
         string     src       = mReader.nextWord(lib);
         IRTSLinker newLinker = lib.newLinker(src);
         IRTSLinker right     = newLinker;
         IRTSLinker left      = getPriorityRoot(mTempLinker, right);
         if (left.isPriority(right))
         {
             if (!right.appendLeftChild(left))
             {
                 mTempLinker = left;
                 return(IRTSDefine.Error.Compiling_InvalidLinkerL);
             }
             mTempLinker = right;
         }
         else
         {
             IRTSLinker replace = left.appendRightChild(right);
             if (replace == null)
             {
                 mTempLinker = right;
             }
             else if (replace == left)
             {
                 mTempLinker = left;
             }
             else if (replace == right)
             {
                 mTempLinker = right;
                 return(IRTSDefine.Error.Compiling_InvalidLinkerR);
             }
             else
             {
                 mTempLinker = right;
                 if (!right.appendLeftChild(replace))
                 {
                     mTempLinker = replace;
                     return(IRTSDefine.Error.Compiling_InvalidLinkerL_rep);
                 }
             }
         }
         return(0);
     }
     else
     {
         mBuild     = false;
         mExeLinker = getDeepRoot(mTempLinker);
         if (mExeLinker != null)
         {
             mCompileList.add(mExeLinker);
         }
         return(0);
     }
 }
Esempio n. 19
0
        public RTSInnerFuncR(object[] args, IRTSFunction func)
        {
            mArgs       = args;
            mReturnType = func.returnType();
            mFunc       = func;
            IRTSLinker body = func.getBody();

            mBody = body == null ? null : body.createRunner();
        }
Esempio n. 20
0
 public override bool appendLeftChild(IRTSLinker linker)
 {
     if (linker.getId() == IRTSDefine.Linker.BRACKET)
     {
         IRTSType ctp = ((RTSBracketL)linker).getCastType();
         mCastType = ctp;
         return(ctp != null);
     }
     return(false);
 }
Esempio n. 21
0
 override public IRTSDefine.Error onCompile(RTSList <IRTSLinker> compileList)
 {
     if (mCur != null)
     {
         mLins.add(mCur);
         mCur = null;
     }
     compileList.addList(mLins);
     return(0);
 }
Esempio n. 22
0
 override public bool isPriority(IRTSLinker linker)
 {
     if (linker.getId() == mId)
     {
         return(false);
     }
     else
     {
         return(base.isPriority(linker));
     }
 }
 override public bool isPriority(IRTSLinker linker)
 {
     if (mFalseL == null)
     {
         return(false);
     }
     else
     {
         return(base.isPriority(linker));
     }
 }
Esempio n. 24
0
 override public bool isPriority(IRTSLinker linker)
 {
     if (mId == IRTSDefine.Linker.FUNCTION_DEFINE && mBody == null)
     {
         return(false);
     }
     else
     {
         return(base.isPriority(linker));
     }
 }
Esempio n. 25
0
 override public bool isPriority(IRTSLinker linker)
 {
     if (mOver)
     {
         return(linker.getId() != IRTSDefine.Linker.ELSE);
     }
     else
     {
         return(false);
     }
 }
 public override bool isPriority(IRTSLinker linker)
 {
     if (mRight == null && !linker.isStructure())
     {
         return(false);
     }
     else
     {
         return(base.isPriority(linker));
     }
 }
Esempio n. 27
0
 override public bool isPriority(IRTSLinker linker)
 {
     if (!mClosed)
     {
         return(false);
     }
     else
     {
         return(base.isPriority(linker));
     }
 }
 override public IRTSLinker appendRightChild(IRTSLinker linker)
 {
     if (linker.getId() == IRTSDefine.Linker.PROPERTY)
     {
         mAllProperty |= ((RTSPropertyL)linker).getProperty();
         return(this);
     }
     else
     {
         return(linker);
     }
 }
 override public bool appendLeftChild(IRTSLinker linker)
 {
     if (linker.getId() == IRTSDefine.Linker.PROPERTY)
     {
         mAllProperty |= ((RTSPropertyL)linker).getProperty();
         return(true);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 30
0
        override public IRTSLinker appendRightChild(IRTSLinker linker)
        {
            IRTSLinker ret = mChildL;

            if (ret != null)
            {
                ret.setSuper(null);
            }
            mChildL = linker;
            linker.setSuper(this);
            return(ret);
        }