Changeset 10076 in webkit for trunk/JavaScriptCore/kjs/internal.cpp
- Timestamp:
- Aug 6, 2005, 11:17:49 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/internal.cpp
r9929 r10076 498 498 499 499 InterpreterImp::InterpreterImp(Interpreter *interp, const Object &glob) 500 : _context(0) 500 : globExec(interp, 0) 501 , _context(0) 501 502 { 502 503 // add this interpreter to the global chain … … 518 519 519 520 global = glob; 520 globExec = new ExecState(m_interpreter,0);521 521 dbg = 0; 522 522 m_compatMode = Interpreter::NativeMode; … … 550 550 // Contructor prototype objects (Object.prototype, Array.prototype etc) 551 551 552 FunctionPrototypeImp *funcProto = new FunctionPrototypeImp( globExec);552 FunctionPrototypeImp *funcProto = new FunctionPrototypeImp(&globExec); 553 553 b_FunctionPrototype = Object(funcProto); 554 ObjectPrototypeImp *objProto = new ObjectPrototypeImp( globExec,funcProto);554 ObjectPrototypeImp *objProto = new ObjectPrototypeImp(&globExec, funcProto); 555 555 b_ObjectPrototype = Object(objProto); 556 556 funcProto->setPrototype(b_ObjectPrototype); 557 557 558 ArrayPrototypeImp *arrayProto = new ArrayPrototypeImp( globExec,objProto);558 ArrayPrototypeImp *arrayProto = new ArrayPrototypeImp(&globExec, objProto); 559 559 b_ArrayPrototype = Object(arrayProto); 560 StringPrototypeImp *stringProto = new StringPrototypeImp( globExec,objProto);560 StringPrototypeImp *stringProto = new StringPrototypeImp(&globExec, objProto); 561 561 b_StringPrototype = Object(stringProto); 562 BooleanPrototypeImp *booleanProto = new BooleanPrototypeImp( globExec,objProto,funcProto);562 BooleanPrototypeImp *booleanProto = new BooleanPrototypeImp(&globExec, objProto, funcProto); 563 563 b_BooleanPrototype = Object(booleanProto); 564 NumberPrototypeImp *numberProto = new NumberPrototypeImp( globExec,objProto,funcProto);564 NumberPrototypeImp *numberProto = new NumberPrototypeImp(&globExec, objProto, funcProto); 565 565 b_NumberPrototype = Object(numberProto); 566 DatePrototypeImp *dateProto = new DatePrototypeImp( globExec,objProto);566 DatePrototypeImp *dateProto = new DatePrototypeImp(&globExec, objProto); 567 567 b_DatePrototype = Object(dateProto); 568 RegExpPrototypeImp *regexpProto = new RegExpPrototypeImp( globExec,objProto,funcProto);568 RegExpPrototypeImp *regexpProto = new RegExpPrototypeImp(&globExec, objProto, funcProto); 569 569 b_RegExpPrototype = Object(regexpProto); 570 ErrorPrototypeImp *errorProto = new ErrorPrototypeImp( globExec,objProto,funcProto);570 ErrorPrototypeImp *errorProto = new ErrorPrototypeImp(&globExec, objProto, funcProto); 571 571 b_ErrorPrototype = Object(errorProto); 572 572 … … 574 574 575 575 // Constructors (Object, Array, etc.) 576 b_Object = Object(new ObjectObjectImp( globExec, objProto, funcProto));577 b_Function = Object(new FunctionObjectImp( globExec, funcProto));578 b_Array = Object(new ArrayObjectImp( globExec, funcProto, arrayProto));579 b_String = Object(new StringObjectImp( globExec, funcProto, stringProto));580 b_Boolean = Object(new BooleanObjectImp( globExec, funcProto, booleanProto));581 b_Number = Object(new NumberObjectImp( globExec, funcProto, numberProto));582 b_Date = Object(new DateObjectImp( globExec, funcProto, dateProto));583 b_RegExp = Object(new RegExpObjectImp( globExec, funcProto, regexpProto));584 b_Error = Object(new ErrorObjectImp( globExec, funcProto, errorProto));576 b_Object = Object(new ObjectObjectImp(&globExec, objProto, funcProto)); 577 b_Function = Object(new FunctionObjectImp(&globExec, funcProto)); 578 b_Array = Object(new ArrayObjectImp(&globExec, funcProto, arrayProto)); 579 b_String = Object(new StringObjectImp(&globExec, funcProto, stringProto)); 580 b_Boolean = Object(new BooleanObjectImp(&globExec, funcProto, booleanProto)); 581 b_Number = Object(new NumberObjectImp(&globExec, funcProto, numberProto)); 582 b_Date = Object(new DateObjectImp(&globExec, funcProto, dateProto)); 583 b_RegExp = Object(new RegExpObjectImp(&globExec, funcProto, regexpProto)); 584 b_Error = Object(new ErrorObjectImp(&globExec, funcProto, errorProto)); 585 585 586 586 // Error object prototypes 587 b_evalErrorPrototype = Object(new NativeErrorPrototypeImp( globExec,errorProto,EvalError,588 "EvalError", "EvalError"));589 b_rangeErrorPrototype = Object(new NativeErrorPrototypeImp( globExec,errorProto,RangeError,590 "RangeError", "RangeError"));591 b_referenceErrorPrototype = Object(new NativeErrorPrototypeImp( globExec,errorProto,ReferenceError,592 "ReferenceError", "ReferenceError"));593 b_syntaxErrorPrototype = Object(new NativeErrorPrototypeImp( globExec,errorProto,SyntaxError,594 "SyntaxError", "SyntaxError"));595 b_typeErrorPrototype = Object(new NativeErrorPrototypeImp( globExec,errorProto,TypeError,596 "TypeError", "TypeError"));597 b_uriErrorPrototype = Object(new NativeErrorPrototypeImp( globExec,errorProto,URIError,598 "URIError", "URIError"));587 b_evalErrorPrototype = Object(new NativeErrorPrototypeImp(&globExec, errorProto, EvalError, 588 "EvalError", "EvalError")); 589 b_rangeErrorPrototype = Object(new NativeErrorPrototypeImp(&globExec, errorProto, RangeError, 590 "RangeError", "RangeError")); 591 b_referenceErrorPrototype = Object(new NativeErrorPrototypeImp(&globExec, errorProto, ReferenceError, 592 "ReferenceError", "ReferenceError")); 593 b_syntaxErrorPrototype = Object(new NativeErrorPrototypeImp(&globExec, errorProto, SyntaxError, 594 "SyntaxError", "SyntaxError")); 595 b_typeErrorPrototype = Object(new NativeErrorPrototypeImp(&globExec, errorProto, TypeError, 596 "TypeError", "TypeError")); 597 b_uriErrorPrototype = Object(new NativeErrorPrototypeImp(&globExec, errorProto, URIError, 598 "URIError", "URIError")); 599 599 600 600 // Error objects 601 b_evalError = Object(new NativeErrorImp( globExec,funcProto,b_evalErrorPrototype));602 b_rangeError = Object(new NativeErrorImp( globExec,funcProto,b_rangeErrorPrototype));603 b_referenceError = Object(new NativeErrorImp( globExec,funcProto,b_referenceErrorPrototype));604 b_syntaxError = Object(new NativeErrorImp( globExec,funcProto,b_syntaxErrorPrototype));605 b_typeError = Object(new NativeErrorImp( globExec,funcProto,b_typeErrorPrototype));606 b_uriError = Object(new NativeErrorImp( globExec,funcProto,b_uriErrorPrototype));601 b_evalError = Object(new NativeErrorImp(&globExec, funcProto, b_evalErrorPrototype)); 602 b_rangeError = Object(new NativeErrorImp(&globExec, funcProto, b_rangeErrorPrototype)); 603 b_referenceError = Object(new NativeErrorImp(&globExec, funcProto, b_referenceErrorPrototype)); 604 b_syntaxError = Object(new NativeErrorImp(&globExec, funcProto, b_syntaxErrorPrototype)); 605 b_typeError = Object(new NativeErrorImp(&globExec, funcProto, b_typeErrorPrototype)); 606 b_uriError = Object(new NativeErrorImp(&globExec, funcProto, b_uriErrorPrototype)); 607 607 608 608 // ECMA 15.3.4.1 609 funcProto->put( globExec,"constructor", b_Function, DontEnum);610 611 global.put( globExec,"Object", b_Object, DontEnum);612 global.put( globExec,"Function", b_Function, DontEnum);613 global.put( globExec,"Array", b_Array, DontEnum);614 global.put( globExec,"Boolean", b_Boolean, DontEnum);615 global.put( globExec,"String", b_String, DontEnum);616 global.put( globExec,"Number", b_Number, DontEnum);617 global.put( globExec,"Date", b_Date, DontEnum);618 global.put( globExec,"RegExp", b_RegExp, DontEnum);619 global.put( globExec,"Error", b_Error, DontEnum);609 funcProto->put(&globExec, "constructor", b_Function, DontEnum); 610 611 global.put(&globExec, "Object", b_Object, DontEnum); 612 global.put(&globExec, "Function", b_Function, DontEnum); 613 global.put(&globExec, "Array", b_Array, DontEnum); 614 global.put(&globExec, "Boolean", b_Boolean, DontEnum); 615 global.put(&globExec, "String", b_String, DontEnum); 616 global.put(&globExec, "Number", b_Number, DontEnum); 617 global.put(&globExec, "Date", b_Date, DontEnum); 618 global.put(&globExec, "RegExp", b_RegExp, DontEnum); 619 global.put(&globExec, "Error", b_Error, DontEnum); 620 620 // Using Internal for those to have something != 0 621 621 // (see kjs_window). Maybe DontEnum would be ok too ? 622 global.put( globExec,"EvalError",b_evalError, Internal);623 global.put( globExec,"RangeError",b_rangeError, Internal);624 global.put( globExec,"ReferenceError",b_referenceError, Internal);625 global.put( globExec,"SyntaxError",b_syntaxError, Internal);626 global.put( globExec,"TypeError",b_typeError, Internal);627 global.put( globExec,"URIError",b_uriError, Internal);622 global.put(&globExec, "EvalError",b_evalError, Internal); 623 global.put(&globExec, "RangeError",b_rangeError, Internal); 624 global.put(&globExec, "ReferenceError",b_referenceError, Internal); 625 global.put(&globExec, "SyntaxError",b_syntaxError, Internal); 626 global.put(&globExec, "TypeError",b_typeError, Internal); 627 global.put(&globExec, "URIError",b_uriError, Internal); 628 628 629 629 // Set the "constructor" property of all builtin constructors 630 objProto->put( globExec, "constructor", b_Object, DontEnum | DontDelete | ReadOnly);631 funcProto->put( globExec, "constructor", b_Function, DontEnum | DontDelete | ReadOnly);632 arrayProto->put( globExec, "constructor", b_Array, DontEnum | DontDelete | ReadOnly);633 booleanProto->put( globExec, "constructor", b_Boolean, DontEnum | DontDelete | ReadOnly);634 stringProto->put( globExec, "constructor", b_String, DontEnum | DontDelete | ReadOnly);635 numberProto->put( globExec, "constructor", b_Number, DontEnum | DontDelete | ReadOnly);636 dateProto->put( globExec, "constructor", b_Date, DontEnum | DontDelete | ReadOnly);637 regexpProto->put( globExec, "constructor", b_RegExp, DontEnum | DontDelete | ReadOnly);638 errorProto->put( globExec, "constructor", b_Error, DontEnum | DontDelete | ReadOnly);639 b_evalErrorPrototype.put( globExec, "constructor", b_evalError, DontEnum | DontDelete | ReadOnly);640 b_rangeErrorPrototype.put( globExec, "constructor", b_rangeError, DontEnum | DontDelete | ReadOnly);641 b_referenceErrorPrototype.put( globExec, "constructor", b_referenceError, DontEnum | DontDelete | ReadOnly);642 b_syntaxErrorPrototype.put( globExec, "constructor", b_syntaxError, DontEnum | DontDelete | ReadOnly);643 b_typeErrorPrototype.put( globExec, "constructor", b_typeError, DontEnum | DontDelete | ReadOnly);644 b_uriErrorPrototype.put( globExec, "constructor", b_uriError, DontEnum | DontDelete | ReadOnly);630 objProto->put(&globExec, "constructor", b_Object, DontEnum | DontDelete | ReadOnly); 631 funcProto->put(&globExec, "constructor", b_Function, DontEnum | DontDelete | ReadOnly); 632 arrayProto->put(&globExec, "constructor", b_Array, DontEnum | DontDelete | ReadOnly); 633 booleanProto->put(&globExec, "constructor", b_Boolean, DontEnum | DontDelete | ReadOnly); 634 stringProto->put(&globExec, "constructor", b_String, DontEnum | DontDelete | ReadOnly); 635 numberProto->put(&globExec, "constructor", b_Number, DontEnum | DontDelete | ReadOnly); 636 dateProto->put(&globExec, "constructor", b_Date, DontEnum | DontDelete | ReadOnly); 637 regexpProto->put(&globExec, "constructor", b_RegExp, DontEnum | DontDelete | ReadOnly); 638 errorProto->put(&globExec, "constructor", b_Error, DontEnum | DontDelete | ReadOnly); 639 b_evalErrorPrototype.put(&globExec, "constructor", b_evalError, DontEnum | DontDelete | ReadOnly); 640 b_rangeErrorPrototype.put(&globExec, "constructor", b_rangeError, DontEnum | DontDelete | ReadOnly); 641 b_referenceErrorPrototype.put(&globExec, "constructor", b_referenceError, DontEnum | DontDelete | ReadOnly); 642 b_syntaxErrorPrototype.put(&globExec, "constructor", b_syntaxError, DontEnum | DontDelete | ReadOnly); 643 b_typeErrorPrototype.put(&globExec, "constructor", b_typeError, DontEnum | DontDelete | ReadOnly); 644 b_uriErrorPrototype.put(&globExec, "constructor", b_uriError, DontEnum | DontDelete | ReadOnly); 645 645 646 646 // built-in values 647 global.put( globExec, "NaN", Number(NaN), DontEnum|DontDelete);648 global.put( globExec, "Infinity", Number(Inf), DontEnum|DontDelete);649 global.put( globExec, "undefined", Undefined(), DontEnum|DontDelete);647 global.put(&globExec, "NaN", Number(NaN), DontEnum|DontDelete); 648 global.put(&globExec, "Infinity", Number(Inf), DontEnum|DontDelete); 649 global.put(&globExec, "undefined", Undefined(), DontEnum|DontDelete); 650 650 651 651 // built-in functions 652 global.put( globExec,"eval", Object(new GlobalFuncImp(globExec,funcProto,GlobalFuncImp::Eval,1)), DontEnum);653 global.put( globExec,"parseInt", Object(new GlobalFuncImp(globExec,funcProto,GlobalFuncImp::ParseInt,2)), DontEnum);654 global.put( globExec,"parseFloat", Object(new GlobalFuncImp(globExec,funcProto,GlobalFuncImp::ParseFloat, 1)), DontEnum);655 global.put( globExec,"isNaN", Object(new GlobalFuncImp(globExec,funcProto,GlobalFuncImp::IsNaN,1)), DontEnum);656 global.put( globExec,"isFinite", Object(new GlobalFuncImp(globExec,funcProto,GlobalFuncImp::IsFinite,1)), DontEnum);657 global.put( globExec,"escape", Object(new GlobalFuncImp(globExec,funcProto,GlobalFuncImp::Escape,1)), DontEnum);658 global.put( globExec,"unescape", Object(new GlobalFuncImp(globExec,funcProto,GlobalFuncImp::UnEscape,1)), DontEnum);659 global.put( globExec,"decodeURI", Object(new GlobalFuncImp(globExec,funcProto,GlobalFuncImp::DecodeURI,1)), DontEnum);660 global.put( globExec,"decodeURIComponent", Object(new GlobalFuncImp(globExec,funcProto,GlobalFuncImp::DecodeURIComponent, 1)), DontEnum);661 global.put( globExec,"encodeURI", Object(new GlobalFuncImp(globExec,funcProto,GlobalFuncImp::EncodeURI,1)), DontEnum);662 global.put( globExec,"encodeURIComponent", Object(new GlobalFuncImp(globExec,funcProto,GlobalFuncImp::EncodeURIComponent, 1)), DontEnum);652 global.put(&globExec, "eval", Object(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::Eval, 1)), DontEnum); 653 global.put(&globExec, "parseInt", Object(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::ParseInt, 2)), DontEnum); 654 global.put(&globExec, "parseFloat", Object(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::ParseFloat, 1)), DontEnum); 655 global.put(&globExec, "isNaN", Object(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::IsNaN, 1)), DontEnum); 656 global.put(&globExec, "isFinite", Object(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::IsFinite, 1)), DontEnum); 657 global.put(&globExec, "escape", Object(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::Escape, 1)), DontEnum); 658 global.put(&globExec, "unescape", Object(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::UnEscape, 1)), DontEnum); 659 global.put(&globExec, "decodeURI", Object(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::DecodeURI, 1)), DontEnum); 660 global.put(&globExec, "decodeURIComponent", Object(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::DecodeURIComponent, 1)), DontEnum); 661 global.put(&globExec, "encodeURI", Object(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::EncodeURI, 1)), DontEnum); 662 global.put(&globExec, "encodeURIComponent", Object(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::EncodeURIComponent, 1)), DontEnum); 663 663 #ifndef NDEBUG 664 global.put( globExec,"kjsprint", Object(new GlobalFuncImp(globExec,funcProto,GlobalFuncImp::KJSPrint,1)), DontEnum);664 global.put(&globExec, "kjsprint", Object(new GlobalFuncImp(&globExec, funcProto, GlobalFuncImp::KJSPrint, 1)), DontEnum); 665 665 #endif 666 666 667 667 // built-in objects 668 global.put( globExec,"Math", Object(new MathObjectImp(globExec,objProto)), DontEnum);668 global.put(&globExec, "Math", Object(new MathObjectImp(&globExec, objProto)), DontEnum); 669 669 } 670 670 … … 673 673 if (dbg) 674 674 dbg->detach(m_interpreter); 675 delete globExec;676 globExec = 0L;677 675 clear(); 678 676 } … … 746 744 if (recursion >= 20) { 747 745 #if APPLE_CHANGES 748 Completion result = Completion(Throw, Error::create(globExec,GeneralError,"Recursion too deep"));746 Completion result = Completion(Throw, Error::create(&globExec, GeneralError, "Recursion too deep")); 749 747 unlockInterpreter(); 750 748 return result; 751 749 #else 752 return Completion(Throw,Error::create( globExec,GeneralError,"Recursion too deep"));750 return Completion(Throw,Error::create(&globExec, GeneralError, "Recursion too deep")); 753 751 #endif 754 752 } … … 762 760 // notify debugger that source has been parsed 763 761 if (dbg) { 764 bool cont = dbg->sourceParsed( globExec,sid,sourceURL,code,errLine);762 bool cont = dbg->sourceParsed(&globExec, sid, sourceURL, code, errLine); 765 763 if (!cont) 766 764 #if APPLE_CHANGES … … 776 774 // no program node means a syntax error occurred 777 775 if (!progNode) { 778 Object err = Error::create( globExec,SyntaxError,errMsg.ascii(),errLine, -1, &sourceURL);779 err.put( globExec,"sid",Number(sid));776 Object err = Error::create(&globExec, SyntaxError, errMsg.ascii(), errLine, -1, &sourceURL); 777 err.put(&globExec, "sid", Number(sid)); 780 778 #if APPLE_CHANGES 781 779 unlockInterpreter(); … … 784 782 } 785 783 786 globExec ->clearException();784 globExec.clearException(); 787 785 788 786 recursion++; … … 797 795 thisObj = globalObject(); 798 796 else { 799 thisObj = thisV.toObject( globExec);797 thisObj = thisV.toObject(&globExec); 800 798 } 801 799 } 802 800 803 801 Completion res; 804 if (globExec ->hadException()) {802 if (globExec.hadException()) { 805 803 // the thisArg.toObject() conversion above might have thrown an exception - if so, 806 804 // propagate it back 807 res = Completion(Throw, globExec->exception());805 res = Completion(Throw, globExec.exception()); 808 806 } 809 807 else {
Note:
See TracChangeset
for help on using the changeset viewer.