+ if (m_reentryDepth >= MaxSmallThreadReentryDepth && m_reentryDepth >= callFrame->globalData().maxReentryDepth)
+ return checkedReturn(throwStackOverflowError(callFrame));
+
+ DynamicGlobalObjectScope globalObjectScope(*scopeChain->globalData, scopeChain->globalObject.get());
+ LiteralParser literalParser(callFrame, program->source().data(), program->source().length(), LiteralParser::JSONP);
+ Vector<LiteralParser::JSONPData> JSONPData;
+ if (literalParser.tryJSONPParse(JSONPData, scopeChain->globalObject->supportsRichSourceInfo())) {
+ JSGlobalObject* globalObject = scopeChain->globalObject.get();
+ JSValue result;
+ for (unsigned entry = 0; entry < JSONPData.size(); entry++) {
+ Vector<LiteralParser::JSONPPathEntry> JSONPPath;
+ JSONPPath.swap(JSONPData[entry].m_path);
+ JSValue JSONPValue = JSONPData[entry].m_value.get();
+ if (JSONPPath.size() == 1 && JSONPPath[0].m_type == LiteralParser::JSONPPathEntryTypeDeclare) {
+ if (globalObject->hasProperty(callFrame, JSONPPath[0].m_pathEntryName)) {
+ PutPropertySlot slot;
+ globalObject->put(callFrame, JSONPPath[0].m_pathEntryName, JSONPValue, slot);
+ } else
+ globalObject->putWithAttributes(callFrame, JSONPPath[0].m_pathEntryName, JSONPValue, DontEnum | DontDelete);
+ // var declarations return undefined
+ result = jsUndefined();
+ continue;
+ }
+ JSValue baseObject(globalObject);
+ for (unsigned i = 0; i < JSONPPath.size() - 1; i++) {
+ ASSERT(JSONPPath[i].m_type != LiteralParser::JSONPPathEntryTypeDeclare);
+ switch (JSONPPath[i].m_type) {
+ case LiteralParser::JSONPPathEntryTypeDot: {
+ if (i == 0) {
+ PropertySlot slot(globalObject);
+ if (!globalObject->getPropertySlot(callFrame, JSONPPath[i].m_pathEntryName, slot)) {
+ if (entry)
+ return throwError(callFrame, createUndefinedVariableError(globalObject->globalExec(), JSONPPath[i].m_pathEntryName));
+ goto failedJSONP;
+ }
+ baseObject = slot.getValue(callFrame, JSONPPath[i].m_pathEntryName);
+ } else
+ baseObject = baseObject.get(callFrame, JSONPPath[i].m_pathEntryName);
+ if (callFrame->hadException())
+ return jsUndefined();
+ continue;
+ }
+ case LiteralParser::JSONPPathEntryTypeLookup: {
+ baseObject = baseObject.get(callFrame, JSONPPath[i].m_pathIndex);
+ if (callFrame->hadException())
+ return jsUndefined();
+ continue;
+ }
+ default:
+ ASSERT_NOT_REACHED();
+ return jsUndefined();
+ }
+ }
+ PutPropertySlot slot;
+ switch (JSONPPath.last().m_type) {
+ case LiteralParser::JSONPPathEntryTypeCall: {
+ JSValue function = baseObject.get(callFrame, JSONPPath.last().m_pathEntryName);
+ if (callFrame->hadException())
+ return jsUndefined();
+ CallData callData;
+ CallType callType = getCallData(function, callData);
+ if (callType == CallTypeNone)
+ return throwError(callFrame, createNotAFunctionError(callFrame, function));
+ MarkedArgumentBuffer jsonArg;
+ jsonArg.append(JSONPValue);
+ JSValue thisValue = JSONPPath.size() == 1 ? jsUndefined(): baseObject;
+ JSONPValue = JSC::call(callFrame, function, callType, callData, thisValue, jsonArg);
+ if (callFrame->hadException())
+ return jsUndefined();
+ break;
+ }
+ case LiteralParser::JSONPPathEntryTypeDot: {
+ baseObject.put(callFrame, JSONPPath.last().m_pathEntryName, JSONPValue, slot);
+ if (callFrame->hadException())
+ return jsUndefined();
+ break;
+ }
+ case LiteralParser::JSONPPathEntryTypeLookup: {
+ baseObject.put(callFrame, JSONPPath.last().m_pathIndex, JSONPValue);
+ if (callFrame->hadException())
+ return jsUndefined();
+ break;
+ }
+ default:
+ ASSERT_NOT_REACHED();
+ return jsUndefined();
+ }
+ result = JSONPValue;