Exemplo n.º 1
0
 private void releaseToken(TclToken token)
 {
     if (interp != null && interp._parserTokensUsed > 0)
     {
         // if cache is not full put the object back in the cache
         interp._parserTokensUsed -= 1;
         interp._parserTokens[interp._parserTokensUsed] = token;
     }
 }
Exemplo n.º 2
0
        // Creating an interpreter will cause this init method to be called

        internal static void init(Interp interp)
        {
            TclToken[] TOKEN_CACHE = new TclToken[MAX_CACHED_TOKENS];
            for (int i = 0; i < MAX_CACHED_TOKENS; i++)
            {
                TOKEN_CACHE[i] = new TclToken();
            }

            interp._parserTokens     = TOKEN_CACHE;
            interp._parserTokensUsed = 0;
        }
Exemplo n.º 3
0
        /*
         * //uncommenting these methods will disable caching
         *
         * static void init(Interp interp) {}
         * private TclToken grabToken() {return new TclToken();}
         * private void releaseToken(TclToken token) {}
         */



        internal void expandTokenArray(int needed)
        {
            // Make sure there is at least enough room for needed tokens
            while (needed >= tokensAvailable)
            {
                tokensAvailable *= 2;
            }

            TclToken[] newList = new TclToken[tokensAvailable];
            Array.Copy((System.Array)tokenList, 0, (System.Array)newList, 0, tokenList.Length);
            tokenList = newList;
        }