Changeset 32807 in webkit for trunk/JavaScriptCore/kjs/number_object.cpp
- Timestamp:
- May 2, 2008, 3:07:53 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/number_object.cpp
r32652 r32807 56 56 : NumberInstance(objectPrototype) 57 57 { 58 setInternalValue(jsNumber( 0));58 setInternalValue(jsNumber(exec, 0)); 59 59 60 60 // The constructor will be added later, after NumberObjectImp has been constructed 61 61 62 putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().toString, numberProtoFuncToString), DontEnum);63 putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toLocaleString, numberProtoFuncToLocaleString), DontEnum);64 putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().valueOf, numberProtoFuncValueOf), DontEnum);65 putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().toFixed, numberProtoFuncToFixed), DontEnum);66 putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().toExponential, numberProtoFuncToExponential), DontEnum);67 putDirectFunction(new PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().toPrecision, numberProtoFuncToPrecision), DontEnum);62 putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().toString, numberProtoFuncToString), DontEnum); 63 putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toLocaleString, numberProtoFuncToLocaleString), DontEnum); 64 putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().valueOf, numberProtoFuncValueOf), DontEnum); 65 putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().toFixed, numberProtoFuncToFixed), DontEnum); 66 putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().toExponential, numberProtoFuncToExponential), DontEnum); 67 putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().toPrecision, numberProtoFuncToPrecision), DontEnum); 68 68 } 69 69 … … 152 152 double radixAsDouble = args[0]->toInteger(exec); // nan -> 0 153 153 if (radixAsDouble == 10 || args[0]->isUndefined()) 154 return jsString( v->toString(exec));154 return jsString(exec, v->toString(exec)); 155 155 156 156 if (radixAsDouble < 2 || radixAsDouble > 36) … … 166 166 double x = v->toNumber(exec); 167 167 if (isnan(x) || isinf(x)) 168 return jsString( UString::from(x));168 return jsString(exec, UString::from(x)); 169 169 170 170 bool isNegative = x < 0.0; … … 205 205 ASSERT(p < s + sizeof(s)); 206 206 207 return jsString( startOfResultString);207 return jsString(exec, startOfResultString); 208 208 } 209 209 … … 214 214 215 215 // TODO 216 return jsString( static_cast<NumberInstance*>(thisObj)->internalValue()->toString(exec));216 return jsString(exec, static_cast<NumberInstance*>(thisObj)->internalValue()->toString(exec)); 217 217 } 218 218 … … 240 240 double x = v->toNumber(exec); 241 241 if (isnan(x)) 242 return jsString( "NaN");242 return jsString(exec, "NaN"); 243 243 244 244 UString s; … … 250 250 251 251 if (x >= pow(10.0, 21.0)) 252 return jsString( s + UString::from(x));252 return jsString(exec, s + UString::from(x)); 253 253 254 254 const double tenToTheF = pow(10.0, f); … … 270 270 int kMinusf = k - f; 271 271 if (kMinusf < m.size()) 272 return jsString( s + m.substr(0, kMinusf) + "." + m.substr(kMinusf));273 return jsString( s + m.substr(0, kMinusf));272 return jsString(exec, s + m.substr(0, kMinusf) + "." + m.substr(kMinusf)); 273 return jsString(exec, s + m.substr(0, kMinusf)); 274 274 } 275 275 … … 321 321 322 322 if (isnan(x) || isinf(x)) 323 return jsString( UString::from(x));323 return jsString(exec, UString::from(x)); 324 324 325 325 JSValue* fractionalDigitsValue = args[0]; … … 347 347 348 348 if (isnan(x)) 349 return jsString( "NaN");349 return jsString(exec, "NaN"); 350 350 351 351 if (x == -0.0) // (-0.0).toExponential() should print as 0 instead of -0 … … 379 379 freedtoa(result); 380 380 381 return jsString( buf);381 return jsString(exec, buf); 382 382 } 383 383 … … 392 392 double x = v->toNumber(exec); 393 393 if (args[0]->isUndefined() || isnan(x) || isinf(x)) 394 return jsString( v->toString(exec));394 return jsString(exec, v->toString(exec)); 395 395 396 396 UString s; … … 431 431 m = m.substr(0, 1) + "." + m.substr(1); 432 432 if (e >= 0) 433 return jsString( s + m + "e+" + UString::from(e));434 return jsString( s + m + "e-" + UString::from(-e));433 return jsString(exec, s + m + "e+" + UString::from(e)); 434 return jsString(exec, s + m + "e-" + UString::from(-e)); 435 435 } 436 436 } else { … … 440 440 441 441 if (e == precision - 1) 442 return jsString( s + m);442 return jsString(exec, s + m); 443 443 if (e >= 0) { 444 444 if (e + 1 < m.size()) 445 return jsString( s + m.substr(0, e + 1) + "." + m.substr(e + 1));446 return jsString( s + m);447 } 448 return jsString( s + "0." + char_sequence('0', -(e + 1)) + m);445 return jsString(exec, s + m.substr(0, e + 1) + "." + m.substr(e + 1)); 446 return jsString(exec, s + m); 447 } 448 return jsString(exec, s + "0." + char_sequence('0', -(e + 1)) + m); 449 449 } 450 450 … … 469 469 470 470 // no. of arguments for constructor 471 putDirect(exec->propertyNames().length, jsNumber( 1), ReadOnly|DontDelete|DontEnum);471 putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly|DontDelete|DontEnum); 472 472 } 473 473 … … 477 477 } 478 478 479 JSValue* NumberObjectImp::getValueProperty(ExecState* , int token) const479 JSValue* NumberObjectImp::getValueProperty(ExecState* exec, int token) const 480 480 { 481 481 // ECMA 15.7.3 482 482 switch (token) { 483 483 case NaNValue: 484 return jsNaN( );484 return jsNaN(exec); 485 485 case NegInfinity: 486 return jsNumberCell( -Inf);486 return jsNumberCell(exec, -Inf); 487 487 case PosInfinity: 488 return jsNumberCell( Inf);488 return jsNumberCell(exec, Inf); 489 489 case MaxValue: 490 return jsNumberCell( 1.7976931348623157E+308);490 return jsNumberCell(exec, 1.7976931348623157E+308); 491 491 case MinValue: 492 return jsNumberCell( 5E-324);492 return jsNumberCell(exec, 5E-324); 493 493 } 494 494 ASSERT_NOT_REACHED(); … … 505 505 { 506 506 JSObject* proto = exec->lexicalGlobalObject()->numberPrototype(); 507 NumberInstance* obj = new NumberInstance(proto);507 NumberInstance* obj = new (exec) NumberInstance(proto); 508 508 509 509 // FIXME: Check args[0]->isUndefined() instead of args.isEmpty()? 510 510 double n = args.isEmpty() ? 0 : args[0]->toNumber(exec); 511 obj->setInternalValue(jsNumber( n));511 obj->setInternalValue(jsNumber(exec, n)); 512 512 return obj; 513 513 } … … 517 517 { 518 518 // FIXME: Check args[0]->isUndefined() instead of args.isEmpty()? 519 return jsNumber( args.isEmpty() ? 0 : args[0]->toNumber(exec));519 return jsNumber(exec, args.isEmpty() ? 0 : args[0]->toNumber(exec)); 520 520 } 521 521
Note:
See TracChangeset
for help on using the changeset viewer.