Changeset 28468 in webkit for trunk/JavaScriptCore/kjs/JSGlobalObject.h
- Timestamp:
- Dec 5, 2007, 6:31:41 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/JSGlobalObject.h
r28415 r28468 2 2 /* 3 3 * Copyright (C) 2007 Eric Seidel <[email protected]> 4 * Copyright (C) 2007 Apple Inc e. All rights reserved.4 * Copyright (C) 2007 Apple Inc. All rights reserved. 5 5 * 6 6 * This library is free software; you can redistribute it and/or … … 28 28 namespace KJS { 29 29 30 class Interpreter; 30 class ArrayObjectImp; 31 class ArrayPrototype; 32 class BooleanObjectImp; 33 class BooleanPrototype; 34 class DateObjectImp; 35 class DatePrototype; 36 class Debugger; 37 class ErrorObjectImp; 38 class ErrorPrototype; 39 class EvalError; 40 class EvalErrorPrototype; 41 class FunctionObjectImp; 42 class FunctionPrototype; 43 class JSGlobalObject; 44 class NativeErrorImp; 45 class NativeErrorPrototype; 46 class NumberObjectImp; 47 class NumberPrototype; 48 class ObjectObjectImp; 49 class ObjectPrototype; 50 class RangeError; 51 class RangeErrorPrototype; 52 class ReferenceError; 53 class ReferenceError; 54 class ReferenceErrorPrototype; 55 class RegExpObjectImp; 56 class RegExpPrototype; 57 class RuntimeMethod; 58 class SavedBuiltins; 59 class ScopeChain; 60 class StringObjectImp; 61 class StringPrototype; 62 class SyntaxErrorPrototype; 63 class TypeError; 64 class TypeErrorPrototype; 65 class UriError; 66 class UriErrorPrototype; 67 68 enum CompatMode { NativeMode, IECompat, NetscapeCompat }; 31 69 32 70 class JSGlobalObject : public JSObject { 71 protected: 72 struct JSGlobalObjectData { 73 JSGlobalObjectData(JSGlobalObject* globalObject) 74 : globalExec(globalObject, globalObject, 0) 75 { 76 } 77 78 JSGlobalObject* next; 79 JSGlobalObject* prev; 80 81 Debugger* debugger; 82 CompatMode compatMode; 83 84 ExecState globalExec; 85 ExecState* currentExec; 86 int recursion; 87 88 unsigned timeoutTime; 89 unsigned timeAtLastCheckTimeout; 90 unsigned timeExecuting; 91 unsigned timeoutCheckCount; 92 unsigned tickCount; 93 unsigned ticksUntilNextTimeoutCheck; 94 95 ObjectObjectImp* objectConstructor; 96 FunctionObjectImp* functionConstructor; 97 ArrayObjectImp* arrayConstructor; 98 BooleanObjectImp* booleanConstructor; 99 StringObjectImp* stringConstructor; 100 NumberObjectImp* numberConstructor; 101 DateObjectImp* dateConstructor; 102 RegExpObjectImp* regExpConstructor; 103 ErrorObjectImp* errorConstructor; 104 NativeErrorImp* evalErrorConstructor; 105 NativeErrorImp* rangeErrorConstructor; 106 NativeErrorImp* referenceErrorConstructor; 107 NativeErrorImp* syntaxErrorConstructor; 108 NativeErrorImp* typeErrorConstructor; 109 NativeErrorImp* URIErrorConstructor; 110 111 ObjectPrototype* objectPrototype; 112 FunctionPrototype* functionPrototype; 113 ArrayPrototype* arrayPrototype; 114 BooleanPrototype* booleanPrototype; 115 StringPrototype* stringPrototype; 116 NumberPrototype* numberPrototype; 117 DatePrototype* datePrototype; 118 RegExpPrototype* regExpPrototype; 119 ErrorPrototype* errorPrototype; 120 NativeErrorPrototype* evalErrorPrototype; 121 NativeErrorPrototype* rangeErrorPrototype; 122 NativeErrorPrototype* referenceErrorPrototype; 123 NativeErrorPrototype* syntaxErrorPrototype; 124 NativeErrorPrototype* typeErrorPrototype; 125 NativeErrorPrototype* URIErrorPrototype; 126 }; 127 33 128 public: 34 JSGlobalObject() { } 35 JSGlobalObject(JSValue* proto) : JSObject(proto) { } 36 37 Interpreter* interpreter() const { return m_interpreter.get(); } 38 void setInterpreter(std::auto_ptr<Interpreter> i) { m_interpreter = i; } 129 JSGlobalObject() 130 { 131 init(); 132 } 133 134 protected: 135 JSGlobalObject(JSValue* proto) 136 : JSObject(proto) 137 { 138 init(); 139 } 140 141 public: 142 virtual ~JSGlobalObject(); 143 144 // Linked list of all global objects. 145 static JSGlobalObject* head() { return s_head; } 146 JSGlobalObject* next() { return d->next; } 147 148 // Resets the global object to contain only built-in properties, sets 149 // the global object's prototype to "prototype," then adds the 150 // default object prototype to the tail of the global object's 151 // prototype chain. 152 void reset(JSValue* prototype); 153 154 // The following accessors return pristine values, even if a script 155 // replaces the global object's associated property. 156 157 ObjectObjectImp* objectConstructor() const { return d->objectConstructor; } 158 FunctionObjectImp* functionConstructor() const { return d->functionConstructor; } 159 ArrayObjectImp* arrayConstructor() const { return d->arrayConstructor; } 160 BooleanObjectImp* booleanConstructor() const { return d->booleanConstructor; } 161 StringObjectImp* stringConstructor() const{ return d->stringConstructor; } 162 NumberObjectImp* numberConstructor() const{ return d->numberConstructor; } 163 DateObjectImp* dateConstructor() const{ return d->dateConstructor; } 164 RegExpObjectImp* regExpConstructor() const { return d->regExpConstructor; } 165 ErrorObjectImp* errorConstructor() const { return d->errorConstructor; } 166 NativeErrorImp* evalErrorConstructor() const { return d->evalErrorConstructor; } 167 NativeErrorImp* rangeErrorConstructor() const { return d->rangeErrorConstructor; } 168 NativeErrorImp* referenceErrorConstructor() const { return d->referenceErrorConstructor; } 169 NativeErrorImp* syntaxErrorConstructor() const { return d->syntaxErrorConstructor; } 170 NativeErrorImp* typeErrorConstructor() const { return d->typeErrorConstructor; } 171 NativeErrorImp* URIErrorConstructor() const { return d->URIErrorConstructor; } 172 173 ObjectPrototype* objectPrototype() const { return d->objectPrototype; } 174 FunctionPrototype* functionPrototype() const { return d->functionPrototype; } 175 ArrayPrototype* arrayPrototype() const { return d->arrayPrototype; } 176 BooleanPrototype* booleanPrototype() const { return d->booleanPrototype; } 177 StringPrototype* stringPrototype() const { return d->stringPrototype; } 178 NumberPrototype* numberPrototype() const { return d->numberPrototype; } 179 DatePrototype* datePrototype() const { return d->datePrototype; } 180 RegExpPrototype* regExpPrototype() const { return d->regExpPrototype; } 181 ErrorPrototype* errorPrototype() const { return d->errorPrototype; } 182 NativeErrorPrototype* evalErrorPrototype() const { return d->evalErrorPrototype; } 183 NativeErrorPrototype* rangeErrorPrototype() const { return d->rangeErrorPrototype; } 184 NativeErrorPrototype* referenceErrorPrototype() const { return d->referenceErrorPrototype; } 185 NativeErrorPrototype* syntaxErrorPrototype() const { return d->syntaxErrorPrototype; } 186 NativeErrorPrototype* typeErrorPrototype() const { return d->typeErrorPrototype; } 187 NativeErrorPrototype* URIErrorPrototype() const { return d->URIErrorPrototype; } 188 189 void saveBuiltins(SavedBuiltins&) const; 190 void restoreBuiltins(const SavedBuiltins&); 191 192 void setTimeoutTime(unsigned timeoutTime) { d->timeoutTime = timeoutTime; } 193 void startTimeoutCheck(); 194 void stopTimeoutCheck(); 195 bool timedOut(); 196 197 Debugger* debugger() const { return d->debugger; } 198 void setDebugger(Debugger* debugger) { d->debugger = debugger; } 199 200 void setCurrentExec(ExecState* exec) { d->currentExec = exec; } 201 ExecState* currentExec() const { return d->currentExec; } 202 203 // FIXME: Let's just pick one compatible behavior and go with it. 204 void setCompatMode(CompatMode mode) { d->compatMode = mode; } 205 CompatMode compatMode() const { return d->compatMode; } 206 207 int recursion() { return d->recursion; } 208 void incRecursion() { ++d->recursion; } 209 void decRecursion() { --d->recursion; } 39 210 40 211 virtual void mark(); … … 48 219 virtual bool isSafeScript(const JSGlobalObject*) const { return true; } 49 220 221 protected: 222 std::auto_ptr<JSGlobalObjectData> d; 223 50 224 private: 51 std::auto_ptr<Interpreter> m_interpreter; 225 void init(); 226 227 bool checkTimeout(); 228 void resetTimeoutCheck(); 229 230 static JSGlobalObject* s_head; 52 231 }; 53 232 233 inline bool JSGlobalObject::timedOut() 234 { 235 d->tickCount++; 236 237 if (d->tickCount != d->ticksUntilNextTimeoutCheck) 238 return false; 239 240 return checkTimeout(); 241 } 242 54 243 } // namespace KJS 55 244
Note:
See TracChangeset
for help on using the changeset viewer.