diff options
Diffstat (limited to 'JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp')
| -rw-r--r-- | JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp | 100 |
1 files changed, 50 insertions, 50 deletions
diff --git a/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp b/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp index 5b6369a..04cb7cf 100644 --- a/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp +++ b/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp @@ -51,12 +51,12 @@ using namespace Unicode; namespace JSC { -static JSValue encode(ExecState* exec, const ArgList& args, const char* doNotEscape) +static JSValue encode(ExecState* exec, const char* doNotEscape) { - UString str = args.at(0).toString(exec); + UString str = exec->argument(0).toString(exec); CString cstr = str.UTF8String(true); if (!cstr.data()) - return throwError(exec, URIError, "String contained an illegal UTF-16 sequence."); + return throwError(exec, createURIError(exec, "String contained an illegal UTF-16 sequence.")); JSStringBuilder builder; const char* p = cstr.data(); @@ -73,10 +73,10 @@ static JSValue encode(ExecState* exec, const ArgList& args, const char* doNotEsc return builder.build(exec); } -static JSValue decode(ExecState* exec, const ArgList& args, const char* doNotUnescape, bool strict) +static JSValue decode(ExecState* exec, const char* doNotUnescape, bool strict) { JSStringBuilder builder; - UString str = args.at(0).toString(exec); + UString str = exec->argument(0).toString(exec); int k = 0; int len = str.size(); const UChar* d = str.data(); @@ -118,7 +118,7 @@ static JSValue decode(ExecState* exec, const ArgList& args, const char* doNotUne } if (charLen == 0) { if (strict) - return throwError(exec, URIError); + return throwError(exec, createURIError(exec, "URI error")); // The only case where we don't use "strict" mode is the "unescape" function. // For that, it's good to support the wonky "%u" syntax for compatibility with WinIE. if (k <= len - 6 && p[1] == 'u' @@ -242,9 +242,9 @@ static double parseInt(const UString& s, int radix) if (number >= mantissaOverflowLowerBound) { if (radix == 10) - number = WTF::strtod(s.substr(firstDigitPosition, p - firstDigitPosition).ascii(), 0); + number = WTF::strtod(s.substr(firstDigitPosition, p - firstDigitPosition).UTF8String().data(), 0); else if (radix == 2 || radix == 4 || radix == 8 || radix == 16 || radix == 32) - number = parseIntOverflow(s.substr(firstDigitPosition, p - firstDigitPosition).ascii(), p - firstDigitPosition, radix); + number = parseIntOverflow(s.substr(firstDigitPosition, p - firstDigitPosition).UTF8String().data(), p - firstDigitPosition, radix); } if (!sawDigit) @@ -272,84 +272,84 @@ static double parseFloat(const UString& s) return s.toDouble(true /*tolerant*/, false /* NaN for empty string */); } -JSValue JSC_HOST_CALL globalFuncEval(ExecState* exec, JSObject* function, JSValue thisValue, const ArgList& args) +EncodedJSValue JSC_HOST_CALL globalFuncEval(ExecState* exec) { - JSObject* thisObject = thisValue.toThisObject(exec); + JSObject* thisObject = exec->hostThisValue().toThisObject(exec); JSObject* unwrappedObject = thisObject->unwrappedObject(); - if (!unwrappedObject->isGlobalObject() || static_cast<JSGlobalObject*>(unwrappedObject)->evalFunction() != function) - return throwError(exec, EvalError, "The \"this\" value passed to eval must be the global object from which eval originated"); + if (!unwrappedObject->isGlobalObject() || static_cast<JSGlobalObject*>(unwrappedObject)->evalFunction() != exec->callee()) + return throwVMError(exec, createEvalError(exec, "The \"this\" value passed to eval must be the global object from which eval originated")); - JSValue x = args.at(0); + JSValue x = exec->argument(0); if (!x.isString()) - return x; + return JSValue::encode(x); UString s = x.toString(exec); LiteralParser preparser(exec, s, LiteralParser::NonStrictJSON); if (JSValue parsedObject = preparser.tryLiteralParse()) - return parsedObject; + return JSValue::encode(parsedObject); RefPtr<EvalExecutable> eval = EvalExecutable::create(exec, makeSource(s)); JSObject* error = eval->compile(exec, static_cast<JSGlobalObject*>(unwrappedObject)->globalScopeChain().node()); if (error) - return throwError(exec, error); + return throwVMError(exec, error); - return exec->interpreter()->execute(eval.get(), exec, thisObject, static_cast<JSGlobalObject*>(unwrappedObject)->globalScopeChain().node(), exec->exceptionSlot()); + return JSValue::encode(exec->interpreter()->execute(eval.get(), exec, thisObject, static_cast<JSGlobalObject*>(unwrappedObject)->globalScopeChain().node(), exec->exceptionSlot())); } -JSValue JSC_HOST_CALL globalFuncParseInt(ExecState* exec, JSObject*, JSValue, const ArgList& args) +EncodedJSValue JSC_HOST_CALL globalFuncParseInt(ExecState* exec) { - JSValue value = args.at(0); - int32_t radix = args.at(1).toInt32(exec); + JSValue value = exec->argument(0); + int32_t radix = exec->argument(1).toInt32(exec); if (radix != 0 && radix != 10) - return jsNumber(exec, parseInt(value.toString(exec), radix)); + return JSValue::encode(jsNumber(exec, parseInt(value.toString(exec), radix))); if (value.isInt32()) - return value; + return JSValue::encode(value); if (value.isDouble()) { double d = value.asDouble(); if (isfinite(d)) - return jsNumber(exec, (d > 0) ? floor(d) : ceil(d)); + return JSValue::encode(jsNumber(exec, (d > 0) ? floor(d) : ceil(d))); if (isnan(d) || isinf(d)) - return jsNaN(exec); - return jsNumber(exec, 0); + return JSValue::encode(jsNaN(exec)); + return JSValue::encode(jsNumber(exec, 0)); } - return jsNumber(exec, parseInt(value.toString(exec), radix)); + return JSValue::encode(jsNumber(exec, parseInt(value.toString(exec), radix))); } -JSValue JSC_HOST_CALL globalFuncParseFloat(ExecState* exec, JSObject*, JSValue, const ArgList& args) +EncodedJSValue JSC_HOST_CALL globalFuncParseFloat(ExecState* exec) { - return jsNumber(exec, parseFloat(args.at(0).toString(exec))); + return JSValue::encode(jsNumber(exec, parseFloat(exec->argument(0).toString(exec)))); } -JSValue JSC_HOST_CALL globalFuncIsNaN(ExecState* exec, JSObject*, JSValue, const ArgList& args) +EncodedJSValue JSC_HOST_CALL globalFuncIsNaN(ExecState* exec) { - return jsBoolean(isnan(args.at(0).toNumber(exec))); + return JSValue::encode(jsBoolean(isnan(exec->argument(0).toNumber(exec)))); } -JSValue JSC_HOST_CALL globalFuncIsFinite(ExecState* exec, JSObject*, JSValue, const ArgList& args) +EncodedJSValue JSC_HOST_CALL globalFuncIsFinite(ExecState* exec) { - double n = args.at(0).toNumber(exec); - return jsBoolean(!isnan(n) && !isinf(n)); + double n = exec->argument(0).toNumber(exec); + return JSValue::encode(jsBoolean(!isnan(n) && !isinf(n))); } -JSValue JSC_HOST_CALL globalFuncDecodeURI(ExecState* exec, JSObject*, JSValue, const ArgList& args) +EncodedJSValue JSC_HOST_CALL globalFuncDecodeURI(ExecState* exec) { static const char do_not_unescape_when_decoding_URI[] = "#$&+,/:;=?@"; - return decode(exec, args, do_not_unescape_when_decoding_URI, true); + return JSValue::encode(decode(exec, do_not_unescape_when_decoding_URI, true)); } -JSValue JSC_HOST_CALL globalFuncDecodeURIComponent(ExecState* exec, JSObject*, JSValue, const ArgList& args) +EncodedJSValue JSC_HOST_CALL globalFuncDecodeURIComponent(ExecState* exec) { - return decode(exec, args, "", true); + return JSValue::encode(decode(exec, "", true)); } -JSValue JSC_HOST_CALL globalFuncEncodeURI(ExecState* exec, JSObject*, JSValue, const ArgList& args) +EncodedJSValue JSC_HOST_CALL globalFuncEncodeURI(ExecState* exec) { static const char do_not_escape_when_encoding_URI[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" @@ -357,10 +357,10 @@ JSValue JSC_HOST_CALL globalFuncEncodeURI(ExecState* exec, JSObject*, JSValue, c "0123456789" "!#$&'()*+,-./:;=?@_~"; - return encode(exec, args, do_not_escape_when_encoding_URI); + return JSValue::encode(encode(exec, do_not_escape_when_encoding_URI)); } -JSValue JSC_HOST_CALL globalFuncEncodeURIComponent(ExecState* exec, JSObject*, JSValue, const ArgList& args) +EncodedJSValue JSC_HOST_CALL globalFuncEncodeURIComponent(ExecState* exec) { static const char do_not_escape_when_encoding_URI_component[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" @@ -368,10 +368,10 @@ JSValue JSC_HOST_CALL globalFuncEncodeURIComponent(ExecState* exec, JSObject*, J "0123456789" "!'()*-._~"; - return encode(exec, args, do_not_escape_when_encoding_URI_component); + return JSValue::encode(encode(exec, do_not_escape_when_encoding_URI_component)); } -JSValue JSC_HOST_CALL globalFuncEscape(ExecState* exec, JSObject*, JSValue, const ArgList& args) +EncodedJSValue JSC_HOST_CALL globalFuncEscape(ExecState* exec) { static const char do_not_escape[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" @@ -380,7 +380,7 @@ JSValue JSC_HOST_CALL globalFuncEscape(ExecState* exec, JSObject*, JSValue, cons "*+-./@_"; JSStringBuilder builder; - UString str = args.at(0).toString(exec); + UString str = exec->argument(0).toString(exec); const UChar* c = str.data(); for (unsigned k = 0; k < str.size(); k++, c++) { int u = c[0]; @@ -397,13 +397,13 @@ JSValue JSC_HOST_CALL globalFuncEscape(ExecState* exec, JSObject*, JSValue, cons } } - return builder.build(exec); + return JSValue::encode(builder.build(exec)); } -JSValue JSC_HOST_CALL globalFuncUnescape(ExecState* exec, JSObject*, JSValue, const ArgList& args) +EncodedJSValue JSC_HOST_CALL globalFuncUnescape(ExecState* exec) { StringBuilder builder; - UString str = args.at(0).toString(exec); + UString str = exec->argument(0).toString(exec); int k = 0; int len = str.size(); while (k < len) { @@ -424,15 +424,15 @@ JSValue JSC_HOST_CALL globalFuncUnescape(ExecState* exec, JSObject*, JSValue, co builder.append(*c); } - return jsString(exec, builder.build()); + return JSValue::encode(jsString(exec, builder.build())); } #ifndef NDEBUG -JSValue JSC_HOST_CALL globalFuncJSCPrint(ExecState* exec, JSObject*, JSValue, const ArgList& args) +EncodedJSValue JSC_HOST_CALL globalFuncJSCPrint(ExecState* exec) { - CString string = args.at(0).toString(exec).UTF8String(); + CString string = exec->argument(0).toString(exec).UTF8String(); puts(string.data()); - return jsUndefined(); + return JSValue::encode(jsUndefined()); } #endif |
