Changeset 14834 in webkit for trunk/JavaScriptCore/kjs/interpreter.cpp
- Timestamp:
- Jun 12, 2006, 11:08:52 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/interpreter.cpp
r14799 r14834 26 26 #include "interpreter.h" 27 27 28 #include "SavedBuiltins.h" 29 #include "array_object.h" 30 #include "bool_object.h" 31 #include "collector.h" 32 #include "context.h" 33 #include "date_object.h" 34 #include "debugger.h" 35 #include "error_object.h" 36 #include "function_object.h" 37 #include "internal.h" 38 #include "math_object.h" 39 #include "nodes.h" 40 #include "number_object.h" 41 #include "object.h" 42 #include "object_object.h" 43 #include "operations.h" 44 #include "regexp_object.h" 45 #include "string_object.h" 46 #include "types.h" 47 #include "value.h" 48 49 #if PLATFORM(MAC) 50 #include "runtime.h" 51 #endif 52 28 53 #include <assert.h> 29 54 #include <math.h> 30 55 #include <stdio.h> 31 56 32 #include "collector.h" 33 #include "context.h" 34 #include "error_object.h" 35 #include "internal.h" 36 #include "nodes.h" 37 #include "object.h" 38 #include "operations.h" 39 #include "types.h" 40 #include "value.h" 41 42 #if PLATFORM(MAC) 43 #include "runtime.h" 57 namespace KJS { 58 59 Interpreter* Interpreter::s_hook = 0; 60 61 typedef HashMap<JSObject*, Interpreter*> InterpreterMap; 62 static inline InterpreterMap &interpreterMap() 63 { 64 static InterpreterMap* map = new InterpreterMap; 65 return* map; 66 } 67 68 Interpreter::Interpreter(JSObject* globalObject) 69 : m_globalExec(this, 0) 70 , m_globalObject(globalObject) 71 , m_argumentsPropertyName(&argumentsPropertyName) 72 , m_specialPrototypePropertyName(&specialPrototypePropertyName) 73 { 74 init(); 75 } 76 77 Interpreter::Interpreter() 78 : m_globalExec(this, 0) 79 , m_globalObject(new JSObject()) 80 , m_argumentsPropertyName(&argumentsPropertyName) 81 , m_specialPrototypePropertyName(&specialPrototypePropertyName) 82 { 83 init(); 84 } 85 86 void Interpreter::init() 87 { 88 JSLock lock; 89 90 m_recursion = 0; 91 m_debugger= 0; 92 m_context = 0; 93 m_compatMode = NativeMode; 94 95 interpreterMap().set(m_globalObject, this); 96 97 if (s_hook) { 98 prev = s_hook; 99 next = s_hook->next; 100 s_hook->next->prev = this; 101 s_hook->next = this; 102 } else { 103 // This is the first interpreter 104 s_hook = next = prev = this; 105 } 106 107 initGlobalObject(); 108 } 109 110 Interpreter::~Interpreter() 111 { 112 JSLock lock; 113 114 if (m_debugger) 115 m_debugger->detach(this); 116 117 next->prev = prev; 118 prev->next = next; 119 s_hook = next; 120 if (s_hook == this) 121 { 122 // This was the last interpreter 123 s_hook = 0; 124 } 125 126 interpreterMap().remove(m_globalObject); 127 } 128 129 JSObject* Interpreter::globalObject() const 130 { 131 return m_globalObject; 132 } 133 134 void Interpreter::initGlobalObject() 135 { 136 Identifier::init(); 137 138 FunctionPrototype *funcProto = new FunctionPrototype(&m_globalExec); 139 m_FunctionPrototype = funcProto; 140 ObjectPrototype *objProto = new ObjectPrototype(&m_globalExec, funcProto); 141 m_ObjectPrototype = objProto; 142 funcProto->setPrototype(m_ObjectPrototype); 143 144 ArrayPrototype *arrayProto = new ArrayPrototype(&m_globalExec, objProto); 145 m_ArrayPrototype = arrayProto; 146 StringPrototype *stringProto = new StringPrototype(&m_globalExec, objProto); 147 m_StringPrototype = stringProto; 148 BooleanPrototype *booleanProto = new BooleanPrototype(&m_globalExec, objProto, funcProto); 149 m_BooleanPrototype = booleanProto; 150 NumberPrototype *numberProto = new NumberPrototype(&m_globalExec, objProto, funcProto); 151 m_NumberPrototype = numberProto; 152 DatePrototype *dateProto = new DatePrototype(&m_globalExec, objProto); 153 m_DatePrototype = dateProto; 154 RegExpPrototype *regexpProto = new RegExpPrototype(&m_globalExec, objProto, funcProto); 155 m_RegExpPrototype = regexpProto; 156 ErrorPrototype *errorProto = new ErrorPrototype(&m_globalExec, objProto, funcProto); 157 m_ErrorPrototype = errorProto; 158 159 JSObject* o = m_globalObject; 160 while (o->prototype()->isObject()) 161 o = static_cast<JSObject*>(o->prototype()); 162 o->setPrototype(m_ObjectPrototype); 163 164 // Constructors (Object, Array, etc.) 165 m_Object = new ObjectObjectImp(&m_globalExec, objProto, funcProto); 166 m_Function = new FunctionObjectImp(&m_globalExec, funcProto); 167 m_Array = new ArrayObjectImp(&m_globalExec, funcProto, arrayProto); 168 m_String = new StringObjectImp(&m_globalExec, funcProto, stringProto); 169 m_Boolean = new BooleanObjectImp(&m_globalExec, funcProto, booleanProto); 170 m_Number = new NumberObjectImp(&m_globalExec, funcProto, numberProto); 171 m_Date = new DateObjectImp(&m_globalExec, funcProto, dateProto); 172 m_RegExp = new RegExpObjectImp(&m_globalExec, funcProto, regexpProto); 173 m_Error = new ErrorObjectImp(&m_globalExec, funcProto, errorProto); 174 175 // Error object prototypes 176 m_EvalErrorPrototype = new NativeErrorPrototype(&m_globalExec, errorProto, EvalError, "EvalError", "EvalError"); 177 m_RangeErrorPrototype = new NativeErrorPrototype(&m_globalExec, errorProto, RangeError, "RangeError", "RangeError"); 178 m_ReferenceErrorPrototype = new NativeErrorPrototype(&m_globalExec, errorProto, ReferenceError, "ReferenceError", "ReferenceError"); 179 m_SyntaxErrorPrototype = new NativeErrorPrototype(&m_globalExec, errorProto, SyntaxError, "SyntaxError", "SyntaxError"); 180 m_TypeErrorPrototype = new NativeErrorPrototype(&m_globalExec, errorProto, TypeError, "TypeError", "TypeError"); 181 m_UriErrorPrototype = new NativeErrorPrototype(&m_globalExec, errorProto, URIError, "URIError", "URIError"); 182 183 // Error objects 184 m_EvalError = new NativeErrorImp(&m_globalExec, funcProto, m_EvalErrorPrototype); 185 m_RangeError = new NativeErrorImp(&m_globalExec, funcProto, m_RangeErrorPrototype); 186 m_ReferenceError = new NativeErrorImp(&m_globalExec, funcProto, m_ReferenceErrorPrototype); 187 m_SyntaxError = new NativeErrorImp(&m_globalExec, funcProto, m_SyntaxErrorPrototype); 188 m_TypeError = new NativeErrorImp(&m_globalExec, funcProto, m_TypeErrorPrototype); 189 m_UriError = new NativeErrorImp(&m_globalExec, funcProto, m_UriErrorPrototype); 190 191 // ECMA 15.3.4.1 192 funcProto->put(&m_globalExec, constructorPropertyName, m_Function, DontEnum); 193 194 m_globalObject->put(&m_globalExec, "Object", m_Object, DontEnum); 195 m_globalObject->put(&m_globalExec, "Function", m_Function, DontEnum); 196 m_globalObject->put(&m_globalExec, "Array", m_Array, DontEnum); 197 m_globalObject->put(&m_globalExec, "Boolean", m_Boolean, DontEnum); 198 m_globalObject->put(&m_globalExec, "String", m_String, DontEnum); 199 m_globalObject->put(&m_globalExec, "Number", m_Number, DontEnum); 200 m_globalObject->put(&m_globalExec, "Date", m_Date, DontEnum); 201 m_globalObject->put(&m_globalExec, "RegExp", m_RegExp, DontEnum); 202 m_globalObject->put(&m_globalExec, "Error", m_Error, DontEnum); 203 // Using Internal for those to have something != 0 204 // (see kjs_window). Maybe DontEnum would be ok too ? 205 m_globalObject->put(&m_globalExec, "EvalError",m_EvalError, Internal); 206 m_globalObject->put(&m_globalExec, "RangeError",m_RangeError, Internal); 207 m_globalObject->put(&m_globalExec, "ReferenceError",m_ReferenceError, Internal); 208 m_globalObject->put(&m_globalExec, "SyntaxError",m_SyntaxError, Internal); 209 m_globalObject->put(&m_globalExec, "TypeError",m_TypeError, Internal); 210 m_globalObject->put(&m_globalExec, "URIError",m_UriError, Internal); 211 212 // Set the constructorPropertyName property of all builtin constructors 213 objProto->put(&m_globalExec, constructorPropertyName, m_Object, DontEnum | DontDelete | ReadOnly); 214 funcProto->put(&m_globalExec, constructorPropertyName, m_Function, DontEnum | DontDelete | ReadOnly); 215 arrayProto->put(&m_globalExec, constructorPropertyName, m_Array, DontEnum | DontDelete | ReadOnly); 216 booleanProto->put(&m_globalExec, constructorPropertyName, m_Boolean, DontEnum | DontDelete | ReadOnly); 217 stringProto->put(&m_globalExec, constructorPropertyName, m_String, DontEnum | DontDelete | ReadOnly); 218 numberProto->put(&m_globalExec, constructorPropertyName, m_Number, DontEnum | DontDelete | ReadOnly); 219 dateProto->put(&m_globalExec, constructorPropertyName, m_Date, DontEnum | DontDelete | ReadOnly); 220 regexpProto->put(&m_globalExec, constructorPropertyName, m_RegExp, DontEnum | DontDelete | ReadOnly); 221 errorProto->put(&m_globalExec, constructorPropertyName, m_Error, DontEnum | DontDelete | ReadOnly); 222 m_EvalErrorPrototype->put(&m_globalExec, constructorPropertyName, m_EvalError, DontEnum | DontDelete | ReadOnly); 223 m_RangeErrorPrototype->put(&m_globalExec, constructorPropertyName, m_RangeError, DontEnum | DontDelete | ReadOnly); 224 m_ReferenceErrorPrototype->put(&m_globalExec, constructorPropertyName, m_ReferenceError, DontEnum | DontDelete | ReadOnly); 225 m_SyntaxErrorPrototype->put(&m_globalExec, constructorPropertyName, m_SyntaxError, DontEnum | DontDelete | ReadOnly); 226 m_TypeErrorPrototype->put(&m_globalExec, constructorPropertyName, m_TypeError, DontEnum | DontDelete | ReadOnly); 227 m_UriErrorPrototype->put(&m_globalExec, constructorPropertyName, m_UriError, DontEnum | DontDelete | ReadOnly); 228 229 // built-in values 230 m_globalObject->put(&m_globalExec, "NaN", jsNaN(), DontEnum|DontDelete); 231 m_globalObject->put(&m_globalExec, "Infinity", jsNumber(Inf), DontEnum|DontDelete); 232 m_globalObject->put(&m_globalExec, "undefined", jsUndefined(), DontEnum|DontDelete); 233 234 // built-in functions 235 m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, funcProto, GlobalFuncImp::Eval, 1, "eval"), DontEnum); 236 m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, funcProto, GlobalFuncImp::ParseInt, 2, "parseInt"), DontEnum); 237 m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, funcProto, GlobalFuncImp::ParseFloat, 1, "parseFloat"), DontEnum); 238 m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, funcProto, GlobalFuncImp::IsNaN, 1, "isNaN"), DontEnum); 239 m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, funcProto, GlobalFuncImp::IsFinite, 1, "isFinite"), DontEnum); 240 m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, funcProto, GlobalFuncImp::Escape, 1, "escape"), DontEnum); 241 m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, funcProto, GlobalFuncImp::UnEscape, 1, "unescape"), DontEnum); 242 m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, funcProto, GlobalFuncImp::DecodeURI, 1, "decodeURI"), DontEnum); 243 m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, funcProto, GlobalFuncImp::DecodeURIComponent, 1, "decodeURIComponent"), DontEnum); 244 m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, funcProto, GlobalFuncImp::EncodeURI, 1, "encodeURI"), DontEnum); 245 m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, funcProto, GlobalFuncImp::EncodeURIComponent, 1, "encodeURIComponent"), DontEnum); 246 #ifndef NDEBUG 247 m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, funcProto, GlobalFuncImp::KJSPrint, 1, "kjsprint"), DontEnum); 44 248 #endif 45 46 namespace KJS { 47 48 // ------------------------------ Interpreter ---------------------------------- 49 50 Interpreter::Interpreter(JSObject *global) 51 : rep(0) 52 , m_argumentsPropertyName(&argumentsPropertyName) 53 , m_specialPrototypePropertyName(&specialPrototypePropertyName) 54 { 55 rep = new InterpreterImp(this, global); 56 } 57 58 Interpreter::Interpreter() 59 : rep(0) 60 , m_argumentsPropertyName(&argumentsPropertyName) 61 , m_specialPrototypePropertyName(&specialPrototypePropertyName) 62 { 63 rep = new InterpreterImp(this, new JSObject); 64 } 65 66 Interpreter::~Interpreter() 67 { 68 delete rep; 69 } 70 71 JSObject *Interpreter::globalObject() const 72 { 73 return rep->globalObject(); 74 } 75 76 void Interpreter::initGlobalObject() 77 { 78 rep->initGlobalObject(); 79 } 80 81 ExecState *Interpreter::globalExec() 82 { 83 return rep->globalExec(); 249 250 // built-in objects 251 m_globalObject->put(&m_globalExec, "Math", new MathObjectImp(&m_globalExec, objProto), DontEnum); 252 } 253 254 ExecState* Interpreter::globalExec() 255 { 256 return &m_globalExec; 84 257 } 85 258 86 259 bool Interpreter::checkSyntax(const UString &code) 87 260 { 88 return rep->checkSyntax(code); 261 JSLock lock; 262 263 // Parser::parse() returns 0 in a syntax error occurs 264 RefPtr<ProgramNode> progNode = Parser::parse(UString(), 0, code.data(), code.size(), 0, 0, 0); 265 return progNode; 89 266 } 90 267 … … 96 273 Completion Interpreter::evaluate(const UString& sourceURL, int startingLineNumber, const UChar* code, int codeLength, JSValue* thisV) 97 274 { 98 Completion comp = rep->evaluate(code, codeLength, thisV, sourceURL, startingLineNumber); 99 100 if (shouldPrintExceptions() && comp.complType() == Throw) { 275 JSLock lock; 276 277 // prevent against infinite recursion 278 if (m_recursion >= 20) 279 return Completion(Throw, Error::create(&m_globalExec, GeneralError, "Recursion too deep")); 280 281 // parse the source code 282 int sid; 283 int errLine; 284 UString errMsg; 285 RefPtr<ProgramNode> progNode = Parser::parse(sourceURL, startingLineNumber, code, codeLength, &sid, &errLine, &errMsg); 286 287 // notify debugger that source has been parsed 288 if (m_debugger) { 289 bool cont = m_debugger->sourceParsed(&m_globalExec, sid, sourceURL, UString(code, codeLength), errLine); 290 if (!cont) 291 return Completion(Break); 292 } 293 294 // no program node means a syntax error occurred 295 if (!progNode) 296 return Completion(Throw, Error::create(&m_globalExec, SyntaxError, errMsg, errLine, sid, &sourceURL)); 297 298 m_globalExec.clearException(); 299 300 m_recursion++; 301 302 JSObject* globalObj = m_globalObject; 303 JSObject* thisObj = globalObj; 304 305 // "this" must be an object... use same rules as Function.prototype.apply() 306 if (thisV && !thisV->isUndefinedOrNull()) 307 thisObj = thisV->toObject(&m_globalExec); 308 309 Completion res; 310 if (m_globalExec.hadException()) 311 // the thisV->toObject() conversion above might have thrown an exception - if so, propagate it 312 res = Completion(Throw, m_globalExec.exception()); 313 else { 314 // execute the code 315 Context ctx(globalObj, this, thisObj, progNode.get()); 316 ExecState newExec(this, &ctx); 317 progNode->processVarDecls(&newExec); 318 res = progNode->execute(&newExec); 319 } 320 321 m_recursion--; 322 323 if (shouldPrintExceptions() && res.complType() == Throw) { 101 324 JSLock lock; 102 ExecState *exec = rep->globalExec();325 ExecState* exec = globalExec(); 103 326 CString f = sourceURL.UTF8String(); 104 CString message = comp.value()->toObject(exec)->toString(exec).UTF8String();105 int line = comp.value()->toObject(exec)->get(exec, "line")->toUInt32(exec);327 CString message = res.value()->toObject(exec)->toString(exec).UTF8String(); 328 int line = res.value()->toObject(exec)->get(exec, "line")->toUInt32(exec); 106 329 #if PLATFORM(WIN_OS) 107 330 printf("%s line %d: %s\n", f.c_str(), line, message.c_str()); … … 111 334 } 112 335 113 return comp;336 return res; 114 337 } 115 338 116 339 JSObject *Interpreter::builtinObject() const 117 340 { 118 return rep->builtinObject();341 return m_Object; 119 342 } 120 343 121 344 JSObject *Interpreter::builtinFunction() const 122 345 { 123 return rep->builtinFunction();346 return m_Function; 124 347 } 125 348 126 349 JSObject *Interpreter::builtinArray() const 127 350 { 128 return rep->builtinArray();351 return m_Array; 129 352 } 130 353 131 354 JSObject *Interpreter::builtinBoolean() const 132 355 { 133 return rep->builtinBoolean();356 return m_Boolean; 134 357 } 135 358 136 359 JSObject *Interpreter::builtinString() const 137 360 { 138 return rep->builtinString();361 return m_String; 139 362 } 140 363 141 364 JSObject *Interpreter::builtinNumber() const 142 365 { 143 return rep->builtinNumber();366 return m_Number; 144 367 } 145 368 146 369 JSObject *Interpreter::builtinDate() const 147 370 { 148 return rep->builtinDate();371 return m_Date; 149 372 } 150 373 151 374 JSObject *Interpreter::builtinRegExp() const 152 375 { 153 return rep->builtinRegExp();376 return m_RegExp; 154 377 } 155 378 156 379 JSObject *Interpreter::builtinError() const 157 380 { 158 return rep->builtinError();381 return m_Error; 159 382 } 160 383 161 384 JSObject *Interpreter::builtinObjectPrototype() const 162 385 { 163 return rep->builtinObjectPrototype();386 return m_ObjectPrototype; 164 387 } 165 388 166 389 JSObject *Interpreter::builtinFunctionPrototype() const 167 390 { 168 return rep->builtinFunctionPrototype();391 return m_FunctionPrototype; 169 392 } 170 393 171 394 JSObject *Interpreter::builtinArrayPrototype() const 172 395 { 173 return rep->builtinArrayPrototype();396 return m_ArrayPrototype; 174 397 } 175 398 176 399 JSObject *Interpreter::builtinBooleanPrototype() const 177 400 { 178 return rep->builtinBooleanPrototype();401 return m_BooleanPrototype; 179 402 } 180 403 181 404 JSObject *Interpreter::builtinStringPrototype() const 182 405 { 183 return rep->builtinStringPrototype();406 return m_StringPrototype; 184 407 } 185 408 186 409 JSObject *Interpreter::builtinNumberPrototype() const 187 410 { 188 return rep->builtinNumberPrototype();411 return m_NumberPrototype; 189 412 } 190 413 191 414 JSObject *Interpreter::builtinDatePrototype() const 192 415 { 193 return rep->builtinDatePrototype();416 return m_DatePrototype; 194 417 } 195 418 196 419 JSObject *Interpreter::builtinRegExpPrototype() const 197 420 { 198 return rep->builtinRegExpPrototype();421 return m_RegExpPrototype; 199 422 } 200 423 201 424 JSObject *Interpreter::builtinErrorPrototype() const 202 425 { 203 return rep->builtinErrorPrototype();426 return m_ErrorPrototype; 204 427 } 205 428 206 429 JSObject *Interpreter::builtinEvalError() const 207 430 { 208 return rep->builtinEvalError();431 return m_EvalError; 209 432 } 210 433 211 434 JSObject *Interpreter::builtinRangeError() const 212 435 { 213 return rep->builtinRangeError();436 return m_RangeError; 214 437 } 215 438 216 439 JSObject *Interpreter::builtinReferenceError() const 217 440 { 218 return rep->builtinReferenceError();441 return m_ReferenceError; 219 442 } 220 443 221 444 JSObject *Interpreter::builtinSyntaxError() const 222 445 { 223 return rep->builtinSyntaxError();446 return m_SyntaxError; 224 447 } 225 448 226 449 JSObject *Interpreter::builtinTypeError() const 227 450 { 228 return rep->builtinTypeError();451 return m_TypeError; 229 452 } 230 453 231 454 JSObject *Interpreter::builtinURIError() const 232 455 { 233 return rep->builtinURIError();456 return m_UriError; 234 457 } 235 458 236 459 JSObject *Interpreter::builtinEvalErrorPrototype() const 237 460 { 238 return rep->builtinEvalErrorPrototype();461 return m_EvalErrorPrototype; 239 462 } 240 463 241 464 JSObject *Interpreter::builtinRangeErrorPrototype() const 242 465 { 243 return rep->builtinRangeErrorPrototype();466 return m_RangeErrorPrototype; 244 467 } 245 468 246 469 JSObject *Interpreter::builtinReferenceErrorPrototype() const 247 470 { 248 return rep->builtinReferenceErrorPrototype();471 return m_ReferenceErrorPrototype; 249 472 } 250 473 251 474 JSObject *Interpreter::builtinSyntaxErrorPrototype() const 252 475 { 253 return rep->builtinSyntaxErrorPrototype();476 return m_SyntaxErrorPrototype; 254 477 } 255 478 256 479 JSObject *Interpreter::builtinTypeErrorPrototype() const 257 480 { 258 return rep->builtinTypeErrorPrototype();481 return m_TypeErrorPrototype; 259 482 } 260 483 261 484 JSObject *Interpreter::builtinURIErrorPrototype() const 262 485 { 263 return rep->builtinURIErrorPrototype(); 264 } 265 266 void Interpreter::setCompatMode(CompatMode mode) 267 { 268 rep->setCompatMode(mode); 269 } 270 271 Interpreter::CompatMode Interpreter::compatMode() const 272 { 273 return rep->compatMode(); 486 return m_UriErrorPrototype; 274 487 } 275 488 … … 281 494 void Interpreter::mark(bool) 282 495 { 496 if (m_context) 497 m_context->mark(); 498 if (m_globalObject && !m_globalObject->marked()) 499 m_globalObject->mark(); 500 if (m_globalExec.exception() && !m_globalExec.exception()->marked()) 501 m_globalExec.exception()->mark(); 502 } 503 504 Interpreter* Interpreter::interpreterWithGlobalObject(JSObject* globalObject) 505 { 506 return interpreterMap().get(globalObject); 283 507 } 284 508 … … 317 541 #endif 318 542 319 void Interpreter::saveBuiltins (SavedBuiltins &builtins) const 320 { 321 rep->saveBuiltins(builtins); 322 } 323 324 void Interpreter::restoreBuiltins (const SavedBuiltins &builtins) 325 { 326 rep->restoreBuiltins(builtins); 543 void Interpreter::saveBuiltins (SavedBuiltins& builtins) const 544 { 545 if (!builtins._internal) 546 builtins._internal = new SavedBuiltinsInternal; 547 548 builtins._internal->m_Object = m_Object; 549 builtins._internal->m_Function = m_Function; 550 builtins._internal->m_Array = m_Array; 551 builtins._internal->m_Boolean = m_Boolean; 552 builtins._internal->m_String = m_String; 553 builtins._internal->m_Number = m_Number; 554 builtins._internal->m_Date = m_Date; 555 builtins._internal->m_RegExp = m_RegExp; 556 builtins._internal->m_Error = m_Error; 557 558 builtins._internal->m_ObjectPrototype = m_ObjectPrototype; 559 builtins._internal->m_FunctionPrototype = m_FunctionPrototype; 560 builtins._internal->m_ArrayPrototype = m_ArrayPrototype; 561 builtins._internal->m_BooleanPrototype = m_BooleanPrototype; 562 builtins._internal->m_StringPrototype = m_StringPrototype; 563 builtins._internal->m_NumberPrototype = m_NumberPrototype; 564 builtins._internal->m_DatePrototype = m_DatePrototype; 565 builtins._internal->m_RegExpPrototype = m_RegExpPrototype; 566 builtins._internal->m_ErrorPrototype = m_ErrorPrototype; 567 568 builtins._internal->m_EvalError = m_EvalError; 569 builtins._internal->m_RangeError = m_RangeError; 570 builtins._internal->m_ReferenceError = m_ReferenceError; 571 builtins._internal->m_SyntaxError = m_SyntaxError; 572 builtins._internal->m_TypeError = m_TypeError; 573 builtins._internal->m_UriError = m_UriError; 574 575 builtins._internal->m_EvalErrorPrototype = m_EvalErrorPrototype; 576 builtins._internal->m_RangeErrorPrototype = m_RangeErrorPrototype; 577 builtins._internal->m_ReferenceErrorPrototype = m_ReferenceErrorPrototype; 578 builtins._internal->m_SyntaxErrorPrototype = m_SyntaxErrorPrototype; 579 builtins._internal->m_TypeErrorPrototype = m_TypeErrorPrototype; 580 builtins._internal->m_UriErrorPrototype = m_UriErrorPrototype; 581 } 582 583 void Interpreter::restoreBuiltins (const SavedBuiltins& builtins) 584 { 585 if (!builtins._internal) 586 return; 587 588 m_Object = builtins._internal->m_Object; 589 m_Function = builtins._internal->m_Function; 590 m_Array = builtins._internal->m_Array; 591 m_Boolean = builtins._internal->m_Boolean; 592 m_String = builtins._internal->m_String; 593 m_Number = builtins._internal->m_Number; 594 m_Date = builtins._internal->m_Date; 595 m_RegExp = builtins._internal->m_RegExp; 596 m_Error = builtins._internal->m_Error; 597 598 m_ObjectPrototype = builtins._internal->m_ObjectPrototype; 599 m_FunctionPrototype = builtins._internal->m_FunctionPrototype; 600 m_ArrayPrototype = builtins._internal->m_ArrayPrototype; 601 m_BooleanPrototype = builtins._internal->m_BooleanPrototype; 602 m_StringPrototype = builtins._internal->m_StringPrototype; 603 m_NumberPrototype = builtins._internal->m_NumberPrototype; 604 m_DatePrototype = builtins._internal->m_DatePrototype; 605 m_RegExpPrototype = builtins._internal->m_RegExpPrototype; 606 m_ErrorPrototype = builtins._internal->m_ErrorPrototype; 607 608 m_EvalError = builtins._internal->m_EvalError; 609 m_RangeError = builtins._internal->m_RangeError; 610 m_ReferenceError = builtins._internal->m_ReferenceError; 611 m_SyntaxError = builtins._internal->m_SyntaxError; 612 m_TypeError = builtins._internal->m_TypeError; 613 m_UriError = builtins._internal->m_UriError; 614 615 m_EvalErrorPrototype = builtins._internal->m_EvalErrorPrototype; 616 m_RangeErrorPrototype = builtins._internal->m_RangeErrorPrototype; 617 m_ReferenceErrorPrototype = builtins._internal->m_ReferenceErrorPrototype; 618 m_SyntaxErrorPrototype = builtins._internal->m_SyntaxErrorPrototype; 619 m_TypeErrorPrototype = builtins._internal->m_TypeErrorPrototype; 620 m_UriErrorPrototype = builtins._internal->m_UriErrorPrototype; 327 621 } 328 622 … … 337 631 } 338 632 339 Interpreter *ExecState::lexicalInterpreter() const 340 { 341 if (!m_context) 342 return dynamicInterpreter(); 343 344 InterpreterImp *result = InterpreterImp::interpreterWithGlobalObject(m_context->scopeChain().bottom()); 345 346 if (!result) 347 return dynamicInterpreter(); 348 349 return result->interpreter(); 350 } 351 352 } 633 }
Note:
See TracChangeset
for help on using the changeset viewer.