diff options
author | Ben Murdoch <benm@google.com> | 2010-06-15 19:36:43 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2010-06-16 14:52:28 +0100 |
commit | 545e470e52f0ac6a3a072bf559c796b42c6066b6 (patch) | |
tree | c0c14763654d84d37577dde512c3d3b4699a9e86 /JavaScriptCore/runtime/JSONObject.cpp | |
parent | 719298a66237d38ea5c05f1547123ad8aacbc237 (diff) | |
download | external_webkit-545e470e52f0ac6a3a072bf559c796b42c6066b6.zip external_webkit-545e470e52f0ac6a3a072bf559c796b42c6066b6.tar.gz external_webkit-545e470e52f0ac6a3a072bf559c796b42c6066b6.tar.bz2 |
Merge webkit.org at r61121: Initial merge by git.
Change-Id: Icd6db395c62285be384d137164d95d7466c98760
Diffstat (limited to 'JavaScriptCore/runtime/JSONObject.cpp')
-rw-r--r-- | JavaScriptCore/runtime/JSONObject.cpp | 60 |
1 files changed, 25 insertions, 35 deletions
diff --git a/JavaScriptCore/runtime/JSONObject.cpp b/JavaScriptCore/runtime/JSONObject.cpp index 86604d8..ccfd43a 100644 --- a/JavaScriptCore/runtime/JSONObject.cpp +++ b/JavaScriptCore/runtime/JSONObject.cpp @@ -41,8 +41,8 @@ namespace JSC { ASSERT_CLASS_FITS_IN_CELL(JSONObject); -static JSValue JSC_HOST_CALL JSONProtoFuncParse(ExecState*); -static JSValue JSC_HOST_CALL JSONProtoFuncStringify(ExecState*); +static EncodedJSValue JSC_HOST_CALL JSONProtoFuncParse(ExecState*); +static EncodedJSValue JSC_HOST_CALL JSONProtoFuncStringify(ExecState*); } @@ -425,7 +425,7 @@ Stringifier::StringifyResult Stringifier::appendStringifiedValue(StringBuilder& // Handle cycle detection, and put the holder on the stack. if (!m_holderCycleDetector.add(object).second) { - throwError(m_exec, TypeError, "JSON.stringify cannot serialize cyclic structures."); + throwError(m_exec, createTypeError(m_exec, "JSON.stringify cannot serialize cyclic structures.")); return StringifyFailed; } bool holderStackWasEmpty = m_holderStack.isEmpty(); @@ -443,7 +443,7 @@ Stringifier::StringifyResult Stringifier::appendStringifiedValue(StringBuilder& return StringifyFailed; if (!--tickCount) { if (localTimeoutChecker.didTimeOut(m_exec)) { - m_exec->setException(createInterruptedExecutionException(&m_exec->globalData())); + throwError(m_exec, createInterruptedExecutionException(&m_exec->globalData())); return StringifyFailed; } tickCount = localTimeoutChecker.ticksUntilNextCheck(); @@ -679,10 +679,8 @@ NEVER_INLINE JSValue Walker::walk(JSValue unfiltered) case ArrayStartState: { ASSERT(inValue.isObject()); ASSERT(isJSArray(&m_exec->globalData(), asObject(inValue)) || asObject(inValue)->inherits(&JSArray::info)); - if (objectStack.size() + arrayStack.size() > maximumFilterRecursion) { - m_exec->setException(createStackOverflowError(m_exec)); - return jsUndefined(); - } + if (objectStack.size() + arrayStack.size() > maximumFilterRecursion) + return throwError(m_exec, createStackOverflowError(m_exec)); JSArray* array = asArray(inValue); arrayStack.append(array); @@ -692,10 +690,8 @@ NEVER_INLINE JSValue Walker::walk(JSValue unfiltered) arrayStartVisitMember: case ArrayStartVisitMember: { if (!--tickCount) { - if (localTimeoutChecker.didTimeOut(m_exec)) { - m_exec->setException(createInterruptedExecutionException(&m_exec->globalData())); - return jsUndefined(); - } + if (localTimeoutChecker.didTimeOut(m_exec)) + return throwError(m_exec, createInterruptedExecutionException(&m_exec->globalData())); tickCount = localTimeoutChecker.ticksUntilNextCheck(); } @@ -744,10 +740,8 @@ NEVER_INLINE JSValue Walker::walk(JSValue unfiltered) case ObjectStartState: { ASSERT(inValue.isObject()); ASSERT(!isJSArray(&m_exec->globalData(), asObject(inValue)) && !asObject(inValue)->inherits(&JSArray::info)); - if (objectStack.size() + arrayStack.size() > maximumFilterRecursion) { - m_exec->setException(createStackOverflowError(m_exec)); - return jsUndefined(); - } + if (objectStack.size() + arrayStack.size() > maximumFilterRecursion) + return throwError(m_exec, createStackOverflowError(m_exec)); JSObject* object = asObject(inValue); objectStack.append(object); @@ -759,10 +753,8 @@ NEVER_INLINE JSValue Walker::walk(JSValue unfiltered) objectStartVisitMember: case ObjectStartVisitMember: { if (!--tickCount) { - if (localTimeoutChecker.didTimeOut(m_exec)) { - m_exec->setException(createInterruptedExecutionException(&m_exec->globalData())); - return jsUndefined(); - } + if (localTimeoutChecker.didTimeOut(m_exec)) + return throwError(m_exec, createInterruptedExecutionException(&m_exec->globalData())); tickCount = localTimeoutChecker.ticksUntilNextCheck(); } @@ -825,10 +817,8 @@ NEVER_INLINE JSValue Walker::walk(JSValue unfiltered) stateStack.removeLast(); if (!--tickCount) { - if (localTimeoutChecker.didTimeOut(m_exec)) { - m_exec->setException(createInterruptedExecutionException(&m_exec->globalData())); - return jsUndefined(); - } + if (localTimeoutChecker.didTimeOut(m_exec)) + return throwError(m_exec, createInterruptedExecutionException(&m_exec->globalData())); tickCount = localTimeoutChecker.ticksUntilNextCheck(); } } @@ -839,40 +829,40 @@ NEVER_INLINE JSValue Walker::walk(JSValue unfiltered) } // ECMA-262 v5 15.12.2 -JSValue JSC_HOST_CALL JSONProtoFuncParse(ExecState* exec) +EncodedJSValue JSC_HOST_CALL JSONProtoFuncParse(ExecState* exec) { if (!exec->argumentCount()) - return throwError(exec, GeneralError, "JSON.parse requires at least one parameter"); + return throwVMError(exec, createError(exec, "JSON.parse requires at least one parameter")); JSValue value = exec->argument(0); UString source = value.toString(exec); if (exec->hadException()) - return jsNull(); + return JSValue::encode(jsNull()); LiteralParser jsonParser(exec, source, LiteralParser::StrictJSON); JSValue unfiltered = jsonParser.tryLiteralParse(); if (!unfiltered) - return throwError(exec, SyntaxError, "Unable to parse JSON string"); + return throwVMError(exec, createSyntaxError(exec, "Unable to parse JSON string")); if (exec->argumentCount() < 2) - return unfiltered; + return JSValue::encode(unfiltered); JSValue function = exec->argument(1); CallData callData; - CallType callType = function.getCallData(callData); + CallType callType = getCallData(function, callData); if (callType == CallTypeNone) - return unfiltered; - return Walker(exec, asObject(function), callType, callData).walk(unfiltered); + return JSValue::encode(unfiltered); + return JSValue::encode(Walker(exec, asObject(function), callType, callData).walk(unfiltered)); } // ECMA-262 v5 15.12.3 -JSValue JSC_HOST_CALL JSONProtoFuncStringify(ExecState* exec) +EncodedJSValue JSC_HOST_CALL JSONProtoFuncStringify(ExecState* exec) { if (!exec->argumentCount()) - return throwError(exec, GeneralError, "No input to stringify"); + return throwVMError(exec, createError(exec, "No input to stringify")); JSValue value = exec->argument(0); JSValue replacer = exec->argument(1); JSValue space = exec->argument(2); - return Stringifier(exec, replacer, space).stringify(value); + return JSValue::encode(Stringifier(exec, replacer, space).stringify(value)); } UString JSONStringify(ExecState* exec, JSValue value, unsigned indent) |