Changeset 58964 in webkit for trunk/JavaScriptCore/runtime
- Timestamp:
- May 7, 2010, 12:30:31 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/NumberPrototype.cpp
r54789 r58964 144 144 return throwError(exec, TypeError); 145 145 146 double radixAsDouble = args.at(0).toInteger(exec); // nan -> 0 147 if (radixAsDouble == 10 || args.at(0).isUndefined()) 146 JSValue radixValue = args.at(0); 147 int radix; 148 if (radixValue.isInt32()) 149 radix = radixValue.asInt32(); 150 else if (radixValue.isUndefined()) 151 radix = 10; 152 else 153 radix = static_cast<int>(radixValue.toInteger(exec)); // nan -> 0 154 155 if (radix == 10) 148 156 return jsString(exec, v.toString(exec)); 149 157 150 if (radixAsDouble < 2 || radixAsDouble > 36) 158 static const char digits[] = "0123456789abcdefghijklmnopqrstuvwxyz"; 159 160 // Fast path for number to character conversion. 161 if (radix == 36) { 162 if (v.isInt32()) { 163 int x = v.asInt32(); 164 if (x < 36) { 165 JSGlobalData* globalData = &exec->globalData(); 166 return globalData->smallStrings.singleCharacterString(globalData, digits[x]); 167 } 168 } 169 } 170 171 if (radix < 2 || radix > 36) 151 172 return throwError(exec, RangeError, "toString() radix argument must be between 2 and 36"); 152 173 153 int radix = static_cast<int>(radixAsDouble);154 const char digits[] = "0123456789abcdefghijklmnopqrstuvwxyz";155 174 // INT_MAX results in 1024 characters left of the dot with radix 2 156 175 // give the same space on the right side. safety checks are in place
Note:
See TracChangeset
for help on using the changeset viewer.