Changeset 11527 in webkit for trunk/JavaScriptCore/kjs/value.cpp
- Timestamp:
- Dec 10, 2005, 6:06:17 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/value.cpp
r11213 r11527 41 41 namespace KJS { 42 42 43 AllocatedValueImp*ConstantValues::undefined = NULL;44 AllocatedValueImp*ConstantValues::null = NULL;45 AllocatedValueImp*ConstantValues::jsTrue = NULL;46 AllocatedValueImp*ConstantValues::jsFalse = NULL;43 JSCell *ConstantValues::undefined = NULL; 44 JSCell *ConstantValues::null = NULL; 45 JSCell *ConstantValues::jsTrue = NULL; 46 JSCell *ConstantValues::jsFalse = NULL; 47 47 48 48 static const double D16 = 65536.0; 49 49 static const double D32 = 4294967296.0; 50 50 51 void * AllocatedValueImp::operator new(size_t size)51 void *JSCell::operator new(size_t size) 52 52 { 53 53 return Collector::allocate(size); 54 54 } 55 55 56 bool AllocatedValueImp::getUInt32(unsigned&) const56 bool JSCell::getUInt32(unsigned&) const 57 57 { 58 58 return false; … … 60 60 61 61 // ECMA 9.4 62 double ValueImp::toInteger(ExecState *exec) const63 { 64 uint32_t i; 65 if (getUInt32(i)) 66 return i; 67 return roundValue(exec, const_cast< ValueImp*>(this));68 } 69 70 int32_t ValueImp::toInt32(ExecState *exec) const71 { 72 uint32_t i; 73 if (getUInt32(i)) 74 return i; 75 76 double d = roundValue(exec, const_cast< ValueImp*>(this));62 double JSValue::toInteger(ExecState *exec) const 63 { 64 uint32_t i; 65 if (getUInt32(i)) 66 return i; 67 return roundValue(exec, const_cast<JSValue*>(this)); 68 } 69 70 int32_t JSValue::toInt32(ExecState *exec) const 71 { 72 uint32_t i; 73 if (getUInt32(i)) 74 return i; 75 76 double d = roundValue(exec, const_cast<JSValue*>(this)); 77 77 if (isNaN(d) || isInf(d)) 78 78 return 0; … … 87 87 } 88 88 89 uint32_t ValueImp::toUInt32(ExecState *exec) const90 { 91 uint32_t i; 92 if (getUInt32(i)) 93 return i; 94 95 double d = roundValue(exec, const_cast< ValueImp*>(this));89 uint32_t JSValue::toUInt32(ExecState *exec) const 90 { 91 uint32_t i; 92 if (getUInt32(i)) 93 return i; 94 95 double d = roundValue(exec, const_cast<JSValue*>(this)); 96 96 if (isNaN(d) || isInf(d)) 97 97 return 0; … … 104 104 } 105 105 106 uint16_t ValueImp::toUInt16(ExecState *exec) const107 { 108 uint32_t i; 109 if (getUInt32(i)) 110 return i; 111 112 double d = roundValue(exec, const_cast< ValueImp*>(this));106 uint16_t JSValue::toUInt16(ExecState *exec) const 107 { 108 uint32_t i; 109 if (getUInt32(i)) 110 return i; 111 112 double d = roundValue(exec, const_cast<JSValue*>(this)); 113 113 if (isNaN(d) || isInf(d)) 114 114 return 0; … … 121 121 } 122 122 123 ObjectImp *ValueImp::toObject(ExecState *exec) const123 JSObject *JSValue::toObject(ExecState *exec) const 124 124 { 125 125 if (SimpleNumber::is(this)) … … 128 128 } 129 129 130 bool AllocatedValueImp::getBoolean(bool &booleanValue) const130 bool JSCell::getBoolean(bool &booleanValue) const 131 131 { 132 132 if (!isBoolean()) … … 136 136 } 137 137 138 bool AllocatedValueImp::getNumber(double &numericValue) const138 bool JSCell::getNumber(double &numericValue) const 139 139 { 140 140 if (!isNumber()) … … 144 144 } 145 145 146 double AllocatedValueImp::getNumber() const146 double JSCell::getNumber() const 147 147 { 148 148 return isNumber() ? static_cast<const NumberImp *>(this)->value() : NaN; 149 149 } 150 150 151 bool AllocatedValueImp::getString(UString &stringValue) const151 bool JSCell::getString(UString &stringValue) const 152 152 { 153 153 if (!isString()) … … 157 157 } 158 158 159 UString AllocatedValueImp::getString() const159 UString JSCell::getString() const 160 160 { 161 161 return isString() ? static_cast<const StringImp *>(this)->value() : UString(); 162 162 } 163 163 164 ObjectImp *AllocatedValueImp::getObject()165 { 166 return isObject() ? static_cast< ObjectImp*>(this) : 0;167 } 168 169 const ObjectImp *AllocatedValueImp::getObject() const170 { 171 return isObject() ? static_cast<const ObjectImp*>(this) : 0;172 } 173 174 AllocatedValueImp*jsString(const char *s)164 JSObject *JSCell::getObject() 165 { 166 return isObject() ? static_cast<JSObject *>(this) : 0; 167 } 168 169 const JSObject *JSCell::getObject() const 170 { 171 return isObject() ? static_cast<const JSObject *>(this) : 0; 172 } 173 174 JSCell *jsString(const char *s) 175 175 { 176 176 return new StringImp(s ? s : ""); 177 177 } 178 178 179 AllocatedValueImp*jsString(const UString &s)179 JSCell *jsString(const UString &s) 180 180 { 181 181 return s.isNull() ? new StringImp("") : new StringImp(s); 182 182 } 183 183 184 ValueImp*jsNumber(double d)185 { 186 ValueImp*v = SimpleNumber::make(d);184 JSValue *jsNumber(double d) 185 { 186 JSValue *v = SimpleNumber::make(d); 187 187 return v ? v : new NumberImp(d); 188 188 } … … 201 201 void ConstantValues::mark() 202 202 { 203 if ( AllocatedValueImp*v = undefined)204 if (!v->marked()) 205 v->mark(); 206 if ( AllocatedValueImp*v = null)207 if (!v->marked()) 208 v->mark(); 209 if ( AllocatedValueImp*v = jsTrue)210 if (!v->marked()) 211 v->mark(); 212 if ( AllocatedValueImp*v = jsFalse)213 if (!v->marked()) 214 v->mark(); 215 } 216 217 } 203 if (JSCell *v = undefined) 204 if (!v->marked()) 205 v->mark(); 206 if (JSCell *v = null) 207 if (!v->marked()) 208 v->mark(); 209 if (JSCell *v = jsTrue) 210 if (!v->marked()) 211 v->mark(); 212 if (JSCell *v = jsFalse) 213 if (!v->marked()) 214 v->mark(); 215 } 216 217 }
Note:
See TracChangeset
for help on using the changeset viewer.