Changeset 89192 in webkit for trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp
- Timestamp:
- Jun 18, 2011, 1:47:10 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp
r89184 r89192 397 397 // FIXME: We can use the preparser in strict mode, we just need additional logic 398 398 // to prevent duplicates. 399 LiteralParser preparser(callFrame, programSource .characters(), programSource.length(), LiteralParser::NonStrictJSON);399 LiteralParser preparser(callFrame, programSource, LiteralParser::NonStrictJSON); 400 400 if (JSValue parsedObject = preparser.tryLiteralParse()) 401 401 return parsedObject; … … 745 745 746 746 DynamicGlobalObjectScope globalObjectScope(*scopeChain->globalData, scopeChain->globalObject.get()); 747 LiteralParser literalParser(callFrame, program->source().data(), program->source().length(), LiteralParser::JSONP);748 Vector<LiteralParser::JSONPData> JSONPData;749 if (literalParser.tryJSONPParse(JSONPData)) {750 JSGlobalObject* globalObject = scopeChain->globalObject.get();751 JSValue result;752 for (unsigned entry = 0; entry < JSONPData.size(); entry++) {753 Vector<LiteralParser::JSONPPathEntry> JSONPPath;754 JSONPPath.swap(JSONPData[entry].m_path);755 JSValue JSONPValue = JSONPData[entry].m_value.get();756 if (JSONPPath.size() == 1 && JSONPPath[0].m_type == LiteralParser::JSONPPathEntryTypeDeclare) {757 if (globalObject->hasProperty(callFrame, JSONPPath[0].m_pathEntryName)) {758 PutPropertySlot slot;759 globalObject->put(callFrame, JSONPPath[0].m_pathEntryName, JSONPValue, slot);760 } else761 globalObject->putWithAttributes(callFrame, JSONPPath[0].m_pathEntryName, JSONPValue, DontEnum | DontDelete);762 // var declarations return undefined763 result = jsUndefined();764 continue;765 }766 JSValue baseObject(globalObject);767 for (unsigned i = 0; i < JSONPPath.size() - 1; i++) {768 ASSERT(JSONPPath[i].m_type != LiteralParser::JSONPPathEntryTypeDeclare);769 switch (JSONPPath[i].m_type) {770 case LiteralParser::JSONPPathEntryTypeDot: {771 if (i == 0) {772 PropertySlot slot(globalObject);773 if (!globalObject->getPropertySlot(callFrame, JSONPPath[i].m_pathEntryName, slot))774 return throwError(callFrame, createUndefinedVariableError(globalObject->globalExec(), JSONPPath[i].m_pathEntryName));775 776 } else777 baseObject = baseObject.get(callFrame, JSONPPath[i].m_pathEntryName);778 if (callFrame->hadException())779 return jsUndefined();780 continue;781 }782 case LiteralParser::JSONPPathEntryTypeLookup: {783 baseObject = baseObject.get(callFrame, JSONPPath[i].m_pathIndex);784 if (callFrame->hadException())785 return jsUndefined();786 continue;787 }788 default:789 ASSERT_NOT_REACHED();790 return jsUndefined();791 }792 }793 PutPropertySlot slot;794 switch (JSONPPath.last().m_type) {795 case LiteralParser::JSONPPathEntryTypeDot: {796 baseObject.put(callFrame, JSONPPath.last().m_pathEntryName, JSONPValue, slot);797 if (callFrame->hadException())798 return jsUndefined();799 break;800 }801 case LiteralParser::JSONPPathEntryTypeLookup: {802 baseObject.put(callFrame, JSONPPath.last().m_pathIndex, JSONPValue);803 if (callFrame->hadException())804 return jsUndefined();805 break;806 }807 default:808 ASSERT_NOT_REACHED();809 return jsUndefined();810 }811 result = JSONPValue;812 }813 return result;814 }815 747 816 748 JSObject* error = program->compile(callFrame, scopeChain);
Note:
See TracChangeset
for help on using the changeset viewer.