source: webkit/trunk/JavaScriptCore/kjs/ExecState.h@ 35900

Last change on this file since 35900 was 35898, checked in by [email protected], 17 years ago

2008-08-22 Cameron Zwarich <[email protected]>

Reviewed by Oliver.

Some cleanup to match our coding style.

  • VM/CodeGenerator.h:
  • VM/Machine.cpp: (KJS::Machine::privateExecute):
  • kjs/ExecState.cpp:
  • kjs/ExecState.h:
  • kjs/completion.h:
  • kjs/identifier.cpp: (KJS::Identifier::equal): (KJS::CStringTranslator::hash): (KJS::CStringTranslator::equal): (KJS::CStringTranslator::translate): (KJS::UCharBufferTranslator::equal): (KJS::UCharBufferTranslator::translate): (KJS::Identifier::remove):
  • kjs/operations.h:
  • Property svn:eol-style set to native
File size: 4.5 KB
Line 
1/*
2 * Copyright (C) 1999-2001 Harri Porten ([email protected])
3 * Copyright (C) 2001 Peter Kelly ([email protected])
4 * Copyright (C) 2003, 2007, 2008 Apple Inc. All rights reserved.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 *
21 */
22
23#ifndef ExecState_h
24#define ExecState_h
25
26#include "JSGlobalData.h"
27#include "ScopeChain.h"
28
29namespace KJS {
30
31 class EvalNode;
32 class FunctionBodyNode;
33 class JSFunction;
34 class JSValue;
35 class GlobalFuncImp;
36 class Interpreter;
37 class JSGlobalObject;
38 class JSVariableObject;
39 class Machine;
40 class ProgramNode;
41 class Register;
42 class RegisterFile;
43 class ScopeNode;
44
45 struct Instruction;
46
47 // Represents the current state of script execution.
48 // Passed as the first argument to most functions.
49 class ExecState : Noncopyable {
50 friend class Machine;
51 friend class DebuggerCallFrame;
52
53 public:
54 ExecState(JSGlobalObject*, JSObject* globalThisValue, ScopeChainNode* globalScopeChain);
55
56 // Global object in which execution began.
57 JSGlobalObject* dynamicGlobalObject() const { return m_globalObject; }
58
59 // Global object in which the current script was defined. (Can differ
60 // from dynamicGlobalObject() during function calls across frames.)
61 JSGlobalObject* lexicalGlobalObject() const
62 {
63 return m_scopeChain->globalObject();
64 }
65
66 JSObject* globalThisValue() const { return m_scopeChain->globalThisObject(); }
67
68 // Exception propogation.
69 void setException(JSValue* exception) { m_exception = exception; }
70 void clearException() { m_exception = 0; }
71 JSValue* exception() const { return m_exception; }
72 JSValue** exceptionSlot() { return &m_exception; }
73 bool hadException() const { return !!m_exception; }
74
75 JSGlobalData& globalData() { return *m_globalData; }
76
77 IdentifierTable* identifierTable() { return m_globalData->identifierTable; }
78 const CommonIdentifiers& propertyNames() const { return *m_globalData->propertyNames; }
79 const ArgList& emptyList() const { return *m_globalData->emptyList; }
80 Lexer* lexer() { return m_globalData->lexer; }
81 Parser* parser() { return m_globalData->parser; }
82 Machine* machine() const { return m_globalData->machine; }
83 static const HashTable* arrayTable(ExecState* exec) { return exec->m_globalData->arrayTable; }
84 static const HashTable* dateTable(ExecState* exec) { return exec->m_globalData->dateTable; }
85 static const HashTable* mathTable(ExecState* exec) { return exec->m_globalData->mathTable; }
86 static const HashTable* numberTable(ExecState* exec) { return exec->m_globalData->numberTable; }
87 static const HashTable* regExpTable(ExecState* exec) { return exec->m_globalData->regExpTable; }
88 static const HashTable* regExpConstructorTable(ExecState* exec) { return exec->m_globalData->regExpConstructorTable; }
89 static const HashTable* stringTable(ExecState* exec) { return exec->m_globalData->stringTable; }
90
91 Heap* heap() const { return m_globalData->heap; }
92
93 private:
94 // Default constructor required for gcc 3.
95 ExecState() { }
96
97 ExecState(ExecState*, RegisterFile*, ScopeChainNode*, Register* callFrame);
98
99 bool isGlobalObject(JSObject*) const;
100
101 JSGlobalObject* m_globalObject;
102 JSObject* m_globalThisValue;
103
104 JSValue* m_exception;
105
106 JSGlobalData* m_globalData;
107
108 // These values are controlled by the machine.
109 ExecState* m_prev;
110 RegisterFile* m_registerFile;
111 ScopeChainNode* m_scopeChain;
112 Register* m_callFrame; // The most recent call frame.
113 };
114
115 enum CodeType { GlobalCode, EvalCode, FunctionCode };
116
117} // namespace KJS
118
119#endif // ExecState_h
Note: See TracBrowser for help on using the repository browser.