Changeset 11614 in webkit for trunk/JavaScriptCore/kjs/internal.cpp
- Timestamp:
- Dec 16, 2005, 12:08:23 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/internal.cpp
r11566 r11614 633 633 634 634 // Parser::parse() returns 0 in a syntax error occurs, so we just check for that 635 RefPtr<ProgramNode> progNode = Parser::parse(UString(), 0, code.data(), code.size(),0,0,0);635 RefPtr<ProgramNode> progNode = Parser::parse(UString(), 0, code.data(), code.size(), 0, 0, 0); 636 636 return progNode; 637 637 } 638 638 639 Completion InterpreterImp::evaluate(const U String &code, JSValue *thisV, const UString &sourceURL, int startingLineNumber)639 Completion InterpreterImp::evaluate(const UChar* code, int codeLength, JSValue* thisV, const UString& sourceURL, int startingLineNumber) 640 640 { 641 641 JSLock lock; 642 642 643 643 // prevent against infinite recursion 644 if (recursion >= 20) { 645 #if APPLE_CHANGES 646 Completion result = Completion(Throw, Error::create(&globExec, GeneralError, "Recursion too deep")); 647 return result; 648 #else 649 return Completion(Throw,Error::create(&globExec, GeneralError, "Recursion too deep")); 650 #endif 651 } 644 if (recursion >= 20) 645 return Completion(Throw, Error::create(&globExec, GeneralError, "Recursion too deep")); 652 646 653 647 // parse the source code … … 655 649 int errLine; 656 650 UString errMsg; 657 RefPtr<ProgramNode> progNode = Parser::parse(sourceURL, startingLineNumber, code .data(),code.size(),&sid,&errLine,&errMsg);651 RefPtr<ProgramNode> progNode = Parser::parse(sourceURL, startingLineNumber, code, codeLength, &sid, &errLine, &errMsg); 658 652 659 653 // notify debugger that source has been parsed 660 654 if (dbg) { 661 bool cont = dbg->sourceParsed(&globExec, sid, sourceURL, code, errLine);655 bool cont = dbg->sourceParsed(&globExec, sid, sourceURL, UString(code, codeLength), errLine); 662 656 if (!cont) 663 657 return Completion(Break); … … 665 659 666 660 // no program node means a syntax error occurred 667 if (!progNode) { 668 JSObject *err = Error::create(&globExec, SyntaxError, errMsg, errLine, sid, &sourceURL); 669 return Completion(Throw,err); 670 } 661 if (!progNode) 662 return Completion(Throw, Error::create(&globExec, SyntaxError, errMsg, errLine, sid, &sourceURL)); 671 663 672 664 globExec.clearException(); … … 674 666 recursion++; 675 667 676 JSObject *globalObj = globalObject(); 677 JSObject *thisObj = globalObject(); 678 679 if (thisV) { 680 // "this" must be an object... use same rules as Function.prototype.apply() 681 if (thisV->isUndefinedOrNull()) 682 thisObj = globalObject(); 683 else { 668 JSObject* globalObj = globalObject(); 669 JSObject* thisObj = globalObj; 670 671 // "this" must be an object... use same rules as Function.prototype.apply() 672 if (thisV && !thisV->isUndefinedOrNull()) 684 673 thisObj = thisV->toObject(&globExec); 685 }686 }687 674 688 675 Completion res; 689 if (globExec.hadException()) { 690 // the thisArg->toObject() conversion above might have thrown an exception - if so, 691 // propagate it back 676 if (globExec.hadException()) 677 // the thisV->toObject() conversion above might have thrown an exception - if so, propagate it 692 678 res = Completion(Throw, globExec.exception()); 693 }694 679 else { 695 680 // execute the code
Note:
See TracChangeset
for help on using the changeset viewer.