Ignore:
Timestamp:
May 21, 2008, 6:20:45 PM (17 years ago)
Author:
[email protected]
Message:

Merge squirrelfish branch into trunk.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/ExecState.h

    r33038 r33979  
    3333namespace KJS  {
    3434
    35     class ActivationImp;
    3635    class CommonIdentifiers;
    3736    class EvalNode;
     
    4342    class JSGlobalObject;
    4443    class JSVariableObject;
     44    class Machine;
    4545    class ProgramNode;
     46    class RegisterFile;
    4647    class ScopeNode;
     48
     49    struct Instruction;
    4750   
    48     enum CodeType { GlobalCode, EvalCode, FunctionCode };
    49 
    5051    struct PerThreadData {
    5152        const HashTable* arrayTable;
     
    6465    // Passed as the first argument to most functions.
    6566    class ExecState : Noncopyable {
    66         friend class JSGlobalObject;
     67        friend class Machine;
     68        friend class DebuggerCallFrame;
     69
    6770    public:
    68         // Global object that was in scope when the current script started executing.
     71        ExecState(JSGlobalObject*, JSObject* globalThisValue, ScopeChainNode* globalScopeChain);
     72
     73        // Global object in which execution began.
    6974        JSGlobalObject* dynamicGlobalObject() const { return m_globalObject; }
    7075       
    71         // Global object that was in scope when the current body of code was defined.
    72         JSGlobalObject* lexicalGlobalObject() const;
    73                
     76        // Global object in which the current script was defined. (Can differ
     77        // from dynamicGlobalObject() during function calls across frames.)
     78        JSGlobalObject* lexicalGlobalObject() const
     79        {
     80            return m_scopeChain->globalObject();
     81        }
     82       
     83        JSObject* globalThisValue() const { return m_globalThisValue; }
     84       
     85        Machine* machine() const { return m_machine; }
     86       
     87        // Exception propogation.
    7488        void setException(JSValue* exception) { m_exception = exception; }
    7589        void clearException() { m_exception = 0; }
     
    7791        JSValue** exceptionSlot() { return &m_exception; }
    7892        bool hadException() const { return !!m_exception; }
    79         JSValue* takeException() { JSValue* exception = m_exception; m_exception = 0; return exception; }
    80        
    81         const ScopeChain& scopeChain() const { return m_scopeChain; }
    82         void pushScope(JSObject* s) { m_scopeChain.push(s); }
    83         void popScope() { m_scopeChain.pop(); }
    84         void replaceScopeChainTop(JSObject* o) { m_scopeChain.replaceTop(o); }
    85        
    86         JSVariableObject* variableObject() const { return m_variableObject; }
    87         void setVariableObject(JSVariableObject* v) { m_variableObject = v; }
    88        
    89         JSObject* thisValue() const { return m_thisValue; }
    90         JSObject* globalThisValue() const { return m_globalThisValue; }
    91        
    92         ExecState* callingExecState() { return m_callingExec; }
    93        
    94         ActivationImp* activationObject() { return m_activation; }
    95         void setActivationObject(ActivationImp* a) { m_activation = a; }
    96         CodeType codeType() { return m_codeType; }
    97         ScopeNode* scopeNode() { return m_scopeNode; }
    98         FunctionImp* function() const { return m_function; }
    99         const List* arguments() const { return m_arguments; }
    100        
    101         LabelStack& seenLabels() { return m_labelStack; }
    102        
    103         void pushIteration() { m_iterationDepth++; }
    104         void popIteration() { m_iterationDepth--; }
    105         bool inIteration() const { return (m_iterationDepth > 0); }
    106        
    107         void pushSwitch() { m_switchDepth++; }
    108         void popSwitch() { m_switchDepth--; }
    109         bool inSwitch() const { return (m_switchDepth > 0); }
    11093
    11194        // These pointers are used to avoid accessing global variables for these,
     
    121104        static const HashTable* stringTable(ExecState* exec) { return exec->m_perThreadData->stringTable; }
    122105
    123         LocalStorage& localStorage() { return *m_localStorage; }
    124         void setLocalStorage(LocalStorage* s) { m_localStorage = s; }
     106    private:
     107        ExecState(ExecState*, Machine*, RegisterFile*, ScopeChainNode*, int callFrameOffset);
     108
     109        bool isGlobalObject(JSObject*) const;
     110
     111        JSGlobalObject* m_globalObject;
     112        JSObject* m_globalThisValue;
     113
     114        JSValue* m_exception;
     115
     116        const PerThreadData* m_perThreadData;
     117
     118        // These values are controlled by the machine.
     119        ExecState* m_prev;
     120        Machine* m_machine;
     121        RegisterFile* m_registerFile;
     122        ScopeChainNode* m_scopeChain;
     123        int m_callFrameOffset; // A negative offset indicates a non-function scope.
     124    };
     125
     126    // This code is now defunct:
     127
     128    enum CodeType { GlobalCode, EvalCode, FunctionCode };
     129    class OldInterpreterExecState : public ExecState {
     130    public:
     131        void pushSwitch() { m_switchDepth++; }
     132        void popSwitch() { m_switchDepth--; }
     133        bool inSwitch() const { return (m_switchDepth > 0); }
    125134
    126135        // These are only valid right after calling execute().
     
    185194            return 0;
    186195        }
    187 
    188     protected:
    189         ExecState(JSGlobalObject*, JSObject* thisObject);
    190         ExecState(JSGlobalObject*, JSObject* thisObject, ProgramNode*);
    191         ExecState(JSGlobalObject*, JSObject* thisObject, EvalNode*, ExecState* callingExecState, const ScopeChain&, JSVariableObject*);
    192         ExecState(JSGlobalObject*, JSObject* thisObject, JSObject* globalThisValue, FunctionBodyNode*, ExecState* callingExecState, FunctionImp*, const List& args);
    193         ~ExecState();
    194 
    195         // ExecStates are always stack-allocated, and the garbage collector
    196         // marks the stack, so we don't need to protect the objects below from GC.
    197 
    198         JSGlobalObject* m_globalObject;
    199         JSValue* m_exception;
    200 
    201         ExecState* m_callingExec;
    202 
    203         const PerThreadData* m_perThreadData;
    204 
    205         ScopeNode* m_scopeNode;
    206        
    207         FunctionImp* m_function;
    208         const List* m_arguments;
    209         ActivationImp* m_activation;
    210         LocalStorage* m_localStorage;
    211 
    212         ScopeChain m_scopeChain;
    213         ScopeChainNode m_inlineScopeChainNode;
    214         JSVariableObject* m_variableObject;
    215 
    216         JSObject* m_thisValue;
    217         JSObject* m_globalThisValue;
    218        
    219         LabelStack m_labelStack;
    220         int m_iterationDepth;
     196        CodeType codeType() { return m_codeType; }
     197        void pushIteration() { m_iterationDepth++; }
     198        void popIteration() { m_iterationDepth--; }
     199        bool inIteration() const { return (m_iterationDepth > 0); }
     200        LabelStack& seenLabels() { return m_labelStack; }
     201        void pushScope(JSObject* s) { m_scopeChain.push(s); }
     202        void popScope() { m_scopeChain.pop(); }
     203        JSVariableObject* variableObject() const { ASSERT_NOT_REACHED(); return m_variableObject; }
     204        void setVariableObject(JSVariableObject* v) { m_variableObject = v; }
     205        ExecState* callingExecState() { return m_callingExec; }
     206        ScopeNode* scopeNode() { return m_scopeNode; }
     207        const List* arguments() const { return m_arguments; }
     208        FunctionImp* function() const { return m_function; }
     209        LocalStorage& localStorage() { ASSERT_NOT_REACHED(); return *(LocalStorage*)0; }
     210        void setLocalStorage(LocalStorage*) { ASSERT_NOT_REACHED(); }
     211        ScopeChain& scopeChain() { return m_scopeChain; }
     212        JSObject* thisValue() const { return m_thisValue; }
     213       
     214        ComplType m_completionType;
     215        const Identifier* m_breakOrContinueTarget;
    221216        int m_switchDepth;
    222217        CodeType m_codeType;
    223 
    224         ComplType m_completionType;
    225         const Identifier* m_breakOrContinueTarget;
     218        int m_iterationDepth;
     219        LabelStack m_labelStack;
     220        ScopeChainNode m_inlineScopeChainNode;
     221        ScopeChain m_scopeChain;
     222        JSVariableObject* m_variableObject;
     223        ScopeNode* m_scopeNode;
     224        const List* m_arguments;
     225        FunctionImp* m_function;
     226        ExecState* m_callingExec;
     227        JSObject* m_thisValue;
    226228    };
    227229
    228     class GlobalExecState : public ExecState {
    229     public:
    230         GlobalExecState(JSGlobalObject*, JSObject* thisObject);
    231         ~GlobalExecState();
    232     };
    233 
    234     class InterpreterExecState : public ExecState {
    235     public:
    236         InterpreterExecState(JSGlobalObject*, JSObject* thisObject, ProgramNode*);
    237         ~InterpreterExecState();
    238     };
    239 
    240     class EvalExecState : public ExecState {
    241     public:
    242         EvalExecState(JSGlobalObject*, JSObject* thisObj, EvalNode*, ExecState* callingExec, const ScopeChain&, JSVariableObject*);
    243         ~EvalExecState();
    244     };
    245 
    246     class FunctionExecState : public ExecState {
    247     public:
    248         FunctionExecState(JSGlobalObject*, JSObject* thisObject, JSObject* globalThisValue, FunctionBodyNode*,
    249             ExecState* callingExecState, FunctionImp*, const List& args);
    250         ~FunctionExecState();
    251     };
    252 
    253230} // namespace KJS
    254231
Note: See TracChangeset for help on using the changeset viewer.