public bool evaluate(IRTSStack stack, object value)
        {
            object obj   = mVarR == null ? null : mVarR.getOutput();
            object index = mIndexR == null ? null : mIndexR.getOutput();

            if (obj == null)
            {
                return(false);
            }
            else if (index is int && obj is System.Collections.IList)
            {
                int n = RTSInteger.valueOf(index);
                ((System.Collections.IList)obj)[n] = value;
                mValue = value;
                return(true);
            }
            else if (index != null)
            {
                var eng  = stack.getThread().getEngine();
                var type = eng.getRTSType(obj.GetType());
                mValue = type.setProperty(eng, obj, RTSString.stringOf(index), value);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
 protected object dateTime(object[] args)
 {
     if (args != null && args.Length == 1)
     {
         return(System.DateTime.Now.ToString(RTSString.stringOf(args[0])));
     }
     else
     {
         return(System.DateTime.Now.ToString());
     }
 }
Esempio n. 3
0
        object sendMessage(object[] args)
        {
            if (args == null || args.Length < 1)
            {
                logError("Can't match parameters.");
            }
            List <string> funcs = mMsgHandler[RTSString.stringOf(args[0])];

            object[] argValues = args.Length > 1 ? new object[args.Length - 1] : null;
            if (argValues != null)
            {
                for (int i = 0; i < argValues.Length; i++)
                {
                    argValues[i] = args[i + 1];
                }
            }
            return(new RTSFuncListR(null, funcs.ToArray(), args.Length - 1, argValues));
        }
Esempio n. 4
0
        object unregistMessage(object[] args)
        {
            string msg  = RTSString.stringOf(args[0]);
            string func = RTSString.stringOf(args[1]);

            if (!string.IsNullOrEmpty(msg) && !string.IsNullOrEmpty(func))
            {
                List <string> funcs;
                if (mMsgHandler.TryGetValue(msg, out funcs))
                {
                    funcs.Remove(func);
                }
            }
            else
            {
                logWarning("Both msg name and function name are required.");
            }
            return(RTSVoid.VOID);
        }
Esempio n. 5
0
        object setValue(object[] args)
        {
            int pid = RTSInteger.valueOf(args[0]);

            if (mThreads != null && pid >= 0 && pid < mThreads.Length)
            {
                RTSThread t = mThreads[pid];
                if (t == null)
                {
                    return(false);
                }
                IRTSStack stack = t.getStack();
                if (stack == null)
                {
                    return(false);
                }
                stack.addVar(RTSString.stringOf(args[1]), args[2]);
                return(true);
            }
            return(false);
        }
Esempio n. 6
0
 protected object getButtonUp(object[] args)
 {
     return(Input.GetButtonUp(RTSString.stringOf(args[0])));
 }
Esempio n. 7
0
 protected object getkeyDown(object[] args)
 {
     return(Input.GetKeyDown((KeyCode)System.Enum.Parse(typeof(KeyCode), RTSString.stringOf(args[0]))));
 }
Esempio n. 8
0
 protected object axisValue(object[] args)
 {
     return(Input.GetAxis(RTSString.stringOf(args[0])));
 }
Esempio n. 9
0
 protected object rtsExist(object[] args)
 {
     return(mEngine.containsVar(RTSString.stringOf(args[0])));
 }
Esempio n. 10
0
 protected object inlineCompile(object[] args)
 {
     return(new RTSInlineCompileR(RTSString.stringOf(args[0])));
 }
Esempio n. 11
0
 public object aliasFunction(object[] args)
 {
     mEngine.aliasFunction(RTSString.stringOf(args[0]), RTSInteger.valueOf(args[1]), RTSString.stringOf(args[2]));
     return(RTSVoid.VOID);
 }
Esempio n. 12
0
 public object aliasOperator(object[] args)
 {
     mEngine.aliasLinker(RTSString.stringOf(args[0]), RTSString.stringOf(args[1]));
     return(RTSVoid.VOID);
 }
 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 if (mVarR == null)
     {
         mValue = new object[0];
     }
     else
     {
         object obj   = mVarR.getOutput();
         object index = mIndexR == null ? null : mIndexR.getOutput();
         if (obj == null)
         {
             mValue = null;
         }
         else if (index is string)
         {
             var      eng = stack.getThread().getEngine();
             IRTSType tp  = eng.getRTSType(obj.GetType());
             mValue = tp.getProperty(eng, obj, RTSString.stringOf(index));
         }
         else if (obj is System.Collections.IList)
         {
             int n = RTSInteger.valueOf(index);
             mValue = ((System.Collections.IList)obj)[n];
         }
         else
         {
             int n = RTSInteger.valueOf(index);
             mValue = n == 0 ? obj : null;
         }
         mOutput = mValue as IRTSRunner;
         if (stack.getThread().loadRunner(mOutput))
         {
             return(0);
         }
     }
     if (mOutput != null)
     {
         mValue  = mOutput.getOutput();
         mOutput = mValue as IRTSRunner;
         if (stack.getThread().loadRunner(mOutput))
         {
             return(0);
         }
     }
     return(0);
 }