Changeset 46598 in webkit for trunk/JavaScriptCore/runtime/JSValue.cpp
- Timestamp:
- Jul 30, 2009, 1:57:44 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/JSValue.cpp
r43122 r46598 24 24 #include "JSValue.h" 25 25 26 #include "BooleanConstructor.h" 27 #include "BooleanPrototype.h" 28 #include "ExceptionHelpers.h" 29 #include "JSGlobalObject.h" 26 30 #include "JSFunction.h" 31 #include "JSNotAnObject.h" 32 #include "NumberObject.h" 27 33 #include <wtf/MathExtras.h> 34 #include <wtf/StringExtras.h> 28 35 29 36 namespace JSC { … … 34 41 double JSValue::toInteger(ExecState* exec) const 35 42 { 36 if (isInt32 Fast())37 return getInt32Fast();43 if (isInt32()) 44 return asInt32(); 38 45 double d = toNumber(exec); 39 46 return isnan(d) ? 0.0 : trunc(d); … … 42 49 double JSValue::toIntegerPreserveNaN(ExecState* exec) const 43 50 { 44 if (isInt32 Fast())45 return getInt32Fast();51 if (isInt32()) 52 return asInt32(); 46 53 return trunc(toNumber(exec)); 47 54 } 55 56 JSObject* JSValue::toObjectSlowCase(ExecState* exec) const 57 { 58 ASSERT(!isCell()); 59 60 if (isInt32() || isDouble()) 61 return constructNumber(exec, asValue()); 62 if (isTrue() || isFalse()) 63 return constructBooleanFromImmediateBoolean(exec, asValue()); 64 ASSERT(isUndefinedOrNull()); 65 JSNotAnObjectErrorStub* exception = createNotAnObjectErrorStub(exec, isNull()); 66 exec->setException(exception); 67 return new (exec) JSNotAnObject(exec, exception); 68 } 69 70 JSObject* JSValue::toThisObjectSlowCase(ExecState* exec) const 71 { 72 ASSERT(!isCell()); 73 74 if (isInt32() || isDouble()) 75 return constructNumber(exec, asValue()); 76 if (isTrue() || isFalse()) 77 return constructBooleanFromImmediateBoolean(exec, asValue()); 78 ASSERT(isUndefinedOrNull()); 79 return exec->globalThisValue(); 80 } 81 82 JSObject* JSValue::synthesizeObject(ExecState* exec) const 83 { 84 ASSERT(!isCell()); 85 if (isNumber()) 86 return constructNumber(exec, asValue()); 87 if (isBoolean()) 88 return constructBooleanFromImmediateBoolean(exec, asValue()); 89 90 JSNotAnObjectErrorStub* exception = createNotAnObjectErrorStub(exec, isNull()); 91 exec->setException(exception); 92 return new (exec) JSNotAnObject(exec, exception); 93 } 94 95 JSObject* JSValue::synthesizePrototype(ExecState* exec) const 96 { 97 ASSERT(!isCell()); 98 if (isNumber()) 99 return exec->lexicalGlobalObject()->numberPrototype(); 100 if (isBoolean()) 101 return exec->lexicalGlobalObject()->booleanPrototype(); 102 103 JSNotAnObjectErrorStub* exception = createNotAnObjectErrorStub(exec, isNull()); 104 exec->setException(exception); 105 return new (exec) JSNotAnObject(exec, exception); 106 } 107 108 #ifndef NDEBUG 109 char* JSValue::description() 110 { 111 static const size_t size = 32; 112 static char description[size]; 113 if (isInt32()) 114 snprintf(description, size, "Int32: %d", asInt32()); 115 else if (isDouble()) 116 snprintf(description, size, "Double: %lf", asDouble()); 117 else if (isCell()) 118 snprintf(description, size, "Cell: %p", asCell()); 119 else if (isTrue()) 120 snprintf(description, size, "True"); 121 else if (isFalse()) 122 snprintf(description, size, "False"); 123 else if (isNull()) 124 snprintf(description, size, "Null"); 125 else { 126 ASSERT(isUndefined()); 127 snprintf(description, size, "Undefined"); 128 } 129 130 return description; 131 } 132 #endif 48 133 49 134 int32_t toInt32SlowCase(double d, bool& ok) … … 85 170 } 86 171 172 NEVER_INLINE double nonInlineNaN() 173 { 174 return std::numeric_limits<double>::quiet_NaN(); 175 } 176 87 177 } // namespace JSC
Note:
See TracChangeset
for help on using the changeset viewer.