Changeset 60631 in webkit for trunk/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp
- Timestamp:
- Jun 3, 2010, 1:00:18 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp
r60392 r60631 273 273 } 274 274 275 JSValue JSC_HOST_CALL globalFuncEval(ExecState* exec)275 EncodedJSValue JSC_HOST_CALL globalFuncEval(ExecState* exec) 276 276 { 277 277 JSObject* thisObject = exec->hostThisValue().toThisObject(exec); 278 278 JSObject* unwrappedObject = thisObject->unwrappedObject(); 279 279 if (!unwrappedObject->isGlobalObject() || static_cast<JSGlobalObject*>(unwrappedObject)->evalFunction() != exec->callee()) 280 return throwError(exec, EvalError, "The \"this\" value passed to eval must be the global object from which eval originated");280 return JSValue::encode(throwError(exec, EvalError, "The \"this\" value passed to eval must be the global object from which eval originated")); 281 281 282 282 JSValue x = exec->argument(0); 283 283 if (!x.isString()) 284 return x;284 return JSValue::encode(x); 285 285 286 286 UString s = x.toString(exec); … … 288 288 LiteralParser preparser(exec, s, LiteralParser::NonStrictJSON); 289 289 if (JSValue parsedObject = preparser.tryLiteralParse()) 290 return parsedObject;290 return JSValue::encode(parsedObject); 291 291 292 292 RefPtr<EvalExecutable> eval = EvalExecutable::create(exec, makeSource(s)); 293 293 JSObject* error = eval->compile(exec, static_cast<JSGlobalObject*>(unwrappedObject)->globalScopeChain().node()); 294 294 if (error) 295 return throwError(exec, error);296 297 return exec->interpreter()->execute(eval.get(), exec, thisObject, static_cast<JSGlobalObject*>(unwrappedObject)->globalScopeChain().node(), exec->exceptionSlot());298 } 299 300 JSValue JSC_HOST_CALL globalFuncParseInt(ExecState* exec)295 return JSValue::encode(throwError(exec, error)); 296 297 return JSValue::encode(exec->interpreter()->execute(eval.get(), exec, thisObject, static_cast<JSGlobalObject*>(unwrappedObject)->globalScopeChain().node(), exec->exceptionSlot())); 298 } 299 300 EncodedJSValue JSC_HOST_CALL globalFuncParseInt(ExecState* exec) 301 301 { 302 302 JSValue value = exec->argument(0); … … 304 304 305 305 if (radix != 0 && radix != 10) 306 return jsNumber(exec, parseInt(value.toString(exec), radix));306 return JSValue::encode(jsNumber(exec, parseInt(value.toString(exec), radix))); 307 307 308 308 if (value.isInt32()) 309 return value;309 return JSValue::encode(value); 310 310 311 311 if (value.isDouble()) { 312 312 double d = value.asDouble(); 313 313 if (isfinite(d)) 314 return jsNumber(exec, (d > 0) ? floor(d) : ceil(d));314 return JSValue::encode(jsNumber(exec, (d > 0) ? floor(d) : ceil(d))); 315 315 if (isnan(d) || isinf(d)) 316 return jsNaN(exec);317 return jsNumber(exec, 0);318 } 319 320 return jsNumber(exec, parseInt(value.toString(exec), radix));321 } 322 323 JSValue JSC_HOST_CALL globalFuncParseFloat(ExecState* exec)324 { 325 return jsNumber(exec, parseFloat(exec->argument(0).toString(exec)));326 } 327 328 JSValue JSC_HOST_CALL globalFuncIsNaN(ExecState* exec)329 { 330 return jsBoolean(isnan(exec->argument(0).toNumber(exec)));331 } 332 333 JSValue JSC_HOST_CALL globalFuncIsFinite(ExecState* exec)316 return JSValue::encode(jsNaN(exec)); 317 return JSValue::encode(jsNumber(exec, 0)); 318 } 319 320 return JSValue::encode(jsNumber(exec, parseInt(value.toString(exec), radix))); 321 } 322 323 EncodedJSValue JSC_HOST_CALL globalFuncParseFloat(ExecState* exec) 324 { 325 return JSValue::encode(jsNumber(exec, parseFloat(exec->argument(0).toString(exec)))); 326 } 327 328 EncodedJSValue JSC_HOST_CALL globalFuncIsNaN(ExecState* exec) 329 { 330 return JSValue::encode(jsBoolean(isnan(exec->argument(0).toNumber(exec)))); 331 } 332 333 EncodedJSValue JSC_HOST_CALL globalFuncIsFinite(ExecState* exec) 334 334 { 335 335 double n = exec->argument(0).toNumber(exec); 336 return jsBoolean(!isnan(n) && !isinf(n));337 } 338 339 JSValue JSC_HOST_CALL globalFuncDecodeURI(ExecState* exec)336 return JSValue::encode(jsBoolean(!isnan(n) && !isinf(n))); 337 } 338 339 EncodedJSValue JSC_HOST_CALL globalFuncDecodeURI(ExecState* exec) 340 340 { 341 341 static const char do_not_unescape_when_decoding_URI[] = 342 342 "#$&+,/:;=?@"; 343 343 344 return decode(exec, do_not_unescape_when_decoding_URI, true);345 } 346 347 JSValue JSC_HOST_CALL globalFuncDecodeURIComponent(ExecState* exec)348 { 349 return decode(exec, "", true);350 } 351 352 JSValue JSC_HOST_CALL globalFuncEncodeURI(ExecState* exec)344 return JSValue::encode(decode(exec, do_not_unescape_when_decoding_URI, true)); 345 } 346 347 EncodedJSValue JSC_HOST_CALL globalFuncDecodeURIComponent(ExecState* exec) 348 { 349 return JSValue::encode(decode(exec, "", true)); 350 } 351 352 EncodedJSValue JSC_HOST_CALL globalFuncEncodeURI(ExecState* exec) 353 353 { 354 354 static const char do_not_escape_when_encoding_URI[] = … … 358 358 "!#$&'()*+,-./:;=?@_~"; 359 359 360 return encode(exec, do_not_escape_when_encoding_URI);361 } 362 363 JSValue JSC_HOST_CALL globalFuncEncodeURIComponent(ExecState* exec)360 return JSValue::encode(encode(exec, do_not_escape_when_encoding_URI)); 361 } 362 363 EncodedJSValue JSC_HOST_CALL globalFuncEncodeURIComponent(ExecState* exec) 364 364 { 365 365 static const char do_not_escape_when_encoding_URI_component[] = … … 369 369 "!'()*-._~"; 370 370 371 return encode(exec, do_not_escape_when_encoding_URI_component);372 } 373 374 JSValue JSC_HOST_CALL globalFuncEscape(ExecState* exec)371 return JSValue::encode(encode(exec, do_not_escape_when_encoding_URI_component)); 372 } 373 374 EncodedJSValue JSC_HOST_CALL globalFuncEscape(ExecState* exec) 375 375 { 376 376 static const char do_not_escape[] = … … 398 398 } 399 399 400 return builder.build(exec);401 } 402 403 JSValue JSC_HOST_CALL globalFuncUnescape(ExecState* exec)400 return JSValue::encode(builder.build(exec)); 401 } 402 403 EncodedJSValue JSC_HOST_CALL globalFuncUnescape(ExecState* exec) 404 404 { 405 405 StringBuilder builder; … … 425 425 } 426 426 427 return jsString(exec, builder.build());427 return JSValue::encode(jsString(exec, builder.build())); 428 428 } 429 429 430 430 #ifndef NDEBUG 431 JSValue JSC_HOST_CALL globalFuncJSCPrint(ExecState* exec)431 EncodedJSValue JSC_HOST_CALL globalFuncJSCPrint(ExecState* exec) 432 432 { 433 433 CString string = exec->argument(0).toString(exec).UTF8String(); 434 434 puts(string.data()); 435 return jsUndefined();435 return JSValue::encode(jsUndefined()); 436 436 } 437 437 #endif
Note:
See TracChangeset
for help on using the changeset viewer.