Beispiel #1
0
        //---------------------------------------------------------------------------
        private IValue ParseFromRPN()
        {
            IValue[] pStack = m_vStackBuffer;
            if (m_rpn.GetSize() == 0)
            {
                // Passiert bei leeren strings oder solchen, die nur Leerzeichen enthalten
                ErrorContext err = new ErrorContext();
                err.Expr = m_pTokenReader.GetExpr();
                err.Errc = EErrorCodes.ecUNEXPECTED_EOF;
                err.Pos  = 0;
                throw new ParserError(err);
            }

            IList <IToken> pRPN = m_rpn.GetData();

            int j      = 0;
            int sidx   = -1;
            int lenRPN = m_rpn.GetSize();

            for (int i = 0; i < lenRPN; ++i)
            {
                IToken   pTok  = pRPN[i];
                ECmdCode eCode = pTok.GetCode();

                switch (eCode)
                {
                case ECmdCode.cmSCRIPT_NEWLINE:
                    sidx = -1;
                    continue;

                case ECmdCode.cmVAL:
                {
                    IValue pVal = (IValue)pTok;
                    sidx++;
                    Global.MUP_VERIFY(sidx < pStack.Length);
                    pStack[sidx] = pVal;
                    //  m_vStackBuffer[sidx] = rVal;
                    //if (pVal.IsVariable())
                    //{
                    //    // m_vStackBuffer[sidx].Release();
                    //    pStack[sidx] = pVal;
                    //}
                    //else
                    //{
                    //    ref IValue val = ref pStack[sidx];
                    //    if (val.IsVariable())
                    //        m_cache.CreateFromCache(out val);

                    //    val = pVal;
                    //}
                }
                    continue;

                case ECmdCode.cmIC:
                {
                    j = 0;
                    ICallback pIdxOprt = (ICallback)pTok;
                    int       nArgs    = pIdxOprt.GetArgsPresent();
                    sidx -= nArgs - 1;
                    Global.MUP_VERIFY(sidx >= 0);
                    var        arr = new IValue[nArgs + 1];
                    ref IValue val = ref pStack[--sidx];
                    Array.Copy(pStack, sidx, arr, 0, nArgs + 1);
                    //int t = sidx + nArgs +1;
                    //arr = new IValue[nArgs+1];
                    //if (t == 1)
                    //    arr[0] = m_vStackBuffer[sidx];
                    //else if (t != 0)
                    //for (int k = sidx; k < t; k++)
                    //    arr[j++] = m_vStackBuffer[k];
                    pIdxOprt.Eval(ref val, arr);
                }
                    continue;