/*
 * The contents of this file are subject to the Netscape Public
 * License Version 1.1 (the "License"); you may not use this file
 * except in compliance with the License. You may obtain a copy of
 * the License at http://www.mozilla.org/NPL/

 * Software distributed under the License is distributed on an "AS
 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
 * implied. See the License for the specific language governing
 * rights and limitations under the License.

 * The Original Code is Rhino code, released
 * May 6, 1999.

 * The Initial Developer of the Original Code is Netscape
 * Communications Corporation.  Portions created by Netscape are
 * Copyright (C) 1997-1999 Netscape Communications Corporation. All
 * Rights Reserved.

 * Contributor(s): 

 * Alternatively, the contents of this file may be used under the
 * terms of the GNU Public License (the "GPL"), in which case the
 * provisions of the GPL are applicable instead of those above.
 * If you wish to allow use of your version of this file only
 * under the terms of the GPL and not to allow others to use your
 * version of this file under the NPL, indicate your decision by
 * deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL.  If you do not delete
 * the provisions above, a recipient may use your version of this
 * file under either the NPL or the GPL.
 */

#ifndef _JS_INTERPRETER_DATA_H_
#define _JS_INTERPRETER_DATA_H_

#include "js-types.h"
#include "js-gcnew.h"
#include "js-variabletable.h"

/* Classes */
class JSInterpretedFunction;
class JSInterpreterData: public JSGCNew { /* GC collectable */
    public:
#ifdef COMPACT_MEM
        static const int INITIAL_MAX_ICODE_LENGTH = 16;
        static const int INITIAL_STRINGTABLE_SIZE = 1;
        static const int INITIAL_NUMBERTABLE_SIZE = 1;
#else
        static const int INITIAL_MAX_ICODE_LENGTH = 1024;
        static const int INITIAL_STRINGTABLE_SIZE = 64;
        static const int INITIAL_NUMBERTABLE_SIZE = 64;
#endif

    public:
        JSVariableTable *itsVariableTable;

        jsString_t      itsName;
        jsString_t      itsSource;
        int             itsSourceLength;
        jsString_t      itsSourceFile;
        jsBool_t        itsNeedsActivation;
        jsBool_t        itsFromEvalCode;
        jsBool_t        itsUseDynamicScope;
        uint8_t         itsFunctionType;

        jsString_t      *itsStringTable;
        int             itsStringTableLength;
        int             itsStringTableIndex;

        double          *itsNumberTable;
        int             itsNumberTableLength;
        int             itsNumberTableIndex;

        JSInterpretedFunction
                        **itsNestedFunctions;
        int             itsNestedFunctionsLength;

        jsVal_t         *itsRegExpLiterals;
        int             itsRegExpLiteralsLength;
        int8_t          *itsICode;
        int             itsICodeLength;
        int             itsICodeTop;

#ifdef REUSE_LOCAL
        int             itsLocalTop;
#endif
        int             itsMaxLocals;
        int             itsMaxArgs;
        int             itsMaxStack;
        int             itsMaxTryDepth;
        int             itsMaxEnums;

    public:
        JSInterpreterData(JSContext *cx, int lastICodeTop,
                int lastStringTableIndex, int lastNumberTableIndex,
                jsBool_t useDynamicScope);

        /* gc methods */
        void    mark(JSContext *cx);
        void    finalize(JSContext *cx);
} ;

#endif /* _JS_INTERPRETER_DATA_H_ */

