Changeset 34578 in webkit for trunk/JavaScriptCore/kjs/internal.cpp
- Timestamp:
- Jun 15, 2008, 7:19:08 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/internal.cpp
r34518 r34578 50 50 namespace KJS { 51 51 52 // ------------------------------ StringImp------------------------------------53 54 JSValue* StringImp::toPrimitive(ExecState*, JSType) const55 { 56 return const_cast< StringImp*>(this);57 } 58 59 bool StringImp::getPrimitiveNumber(ExecState*, double& number, JSValue*& value)52 // ------------------------------ JSString ------------------------------------ 53 54 JSValue* JSString::toPrimitive(ExecState*, JSType) const 55 { 56 return const_cast<JSString*>(this); 57 } 58 59 bool JSString::getPrimitiveNumber(ExecState*, double& number, JSValue*& value) 60 60 { 61 61 value = this; … … 64 64 } 65 65 66 bool StringImp::toBoolean(ExecState*) const66 bool JSString::toBoolean(ExecState*) const 67 67 { 68 68 return !m_value.isEmpty(); 69 69 } 70 70 71 double StringImp::toNumber(ExecState*) const71 double JSString::toNumber(ExecState*) const 72 72 { 73 73 return m_value.toDouble(); 74 74 } 75 75 76 UString StringImp::toString(ExecState*) const76 UString JSString::toString(ExecState*) const 77 77 { 78 78 return m_value; 79 79 } 80 80 81 inline StringInstance* StringInstance::create(ExecState* exec, StringImp* string)81 inline StringInstance* StringInstance::create(ExecState* exec, JSString* string) 82 82 { 83 83 return new StringInstance(exec->lexicalGlobalObject()->stringPrototype(), string); 84 84 } 85 85 86 JSObject* StringImp::toObject(ExecState* exec) const87 { 88 return StringInstance::create(exec, const_cast< StringImp*>(this));89 } 90 91 JSObject* StringImp::toThisObject(ExecState* exec) const92 { 93 return StringInstance::create(exec, const_cast< StringImp*>(this));94 } 95 96 JSValue* StringImp::lengthGetter(ExecState*, const Identifier&, const PropertySlot& slot)97 { 98 return jsNumber(static_cast< StringImp*>(slot.slotBase())->value().size());99 } 100 101 JSValue* StringImp::indexGetter(ExecState*, const Identifier&, const PropertySlot& slot)102 { 103 return jsString(static_cast< StringImp*>(slot.slotBase())->value().substr(slot.index(), 1));104 } 105 106 JSValue* StringImp::indexNumericPropertyGetter(ExecState*, unsigned index, const PropertySlot& slot)107 { 108 return jsString(static_cast< StringImp*>(slot.slotBase())->value().substr(index, 1));109 } 110 111 bool StringImp::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)86 JSObject* JSString::toObject(ExecState* exec) const 87 { 88 return StringInstance::create(exec, const_cast<JSString*>(this)); 89 } 90 91 JSObject* JSString::toThisObject(ExecState* exec) const 92 { 93 return StringInstance::create(exec, const_cast<JSString*>(this)); 94 } 95 96 JSValue* JSString::lengthGetter(ExecState*, const Identifier&, const PropertySlot& slot) 97 { 98 return jsNumber(static_cast<JSString*>(slot.slotBase())->value().size()); 99 } 100 101 JSValue* JSString::indexGetter(ExecState*, const Identifier&, const PropertySlot& slot) 102 { 103 return jsString(static_cast<JSString*>(slot.slotBase())->value().substr(slot.index(), 1)); 104 } 105 106 JSValue* JSString::indexNumericPropertyGetter(ExecState*, unsigned index, const PropertySlot& slot) 107 { 108 return jsString(static_cast<JSString*>(slot.slotBase())->value().substr(index, 1)); 109 } 110 111 bool JSString::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) 112 112 { 113 113 // The semantics here are really getPropertySlot, not getOwnPropertySlot. … … 131 131 } 132 132 133 bool StringImp::getOwnPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot)133 bool JSString::getOwnPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot) 134 134 { 135 135 // The semantics here are really getPropertySlot, not getOwnPropertySlot. … … 137 137 if (getStringPropertySlot(propertyName, slot)) 138 138 return true; 139 return StringImp::getOwnPropertySlot(exec, Identifier::from(propertyName), slot);140 } 141 142 // ------------------------------ NumberImp------------------------------------143 144 JSType NumberImp::type() const139 return JSString::getOwnPropertySlot(exec, Identifier::from(propertyName), slot); 140 } 141 142 // ------------------------------ JSNumberCell ------------------------------------ 143 144 JSType JSNumberCell::type() const 145 145 { 146 146 return NumberType; 147 147 } 148 148 149 JSValue* NumberImp::toPrimitive(ExecState*, JSType) const150 { 151 return const_cast< NumberImp*>(this);152 } 153 154 bool NumberImp::getPrimitiveNumber(ExecState*, double& number, JSValue*& value)149 JSValue* JSNumberCell::toPrimitive(ExecState*, JSType) const 150 { 151 return const_cast<JSNumberCell*>(this); 152 } 153 154 bool JSNumberCell::getPrimitiveNumber(ExecState*, double& number, JSValue*& value) 155 155 { 156 156 number = val; … … 159 159 } 160 160 161 bool NumberImp::toBoolean(ExecState *) const161 bool JSNumberCell::toBoolean(ExecState *) const 162 162 { 163 163 return val < 0.0 || val > 0.0; // false for NaN 164 164 } 165 165 166 double NumberImp::toNumber(ExecState *) const166 double JSNumberCell::toNumber(ExecState *) const 167 167 { 168 168 return val; 169 169 } 170 170 171 UString NumberImp::toString(ExecState *) const171 UString JSNumberCell::toString(ExecState *) const 172 172 { 173 173 if (val == 0.0) // +0.0 or -0.0 … … 176 176 } 177 177 178 JSObject * NumberImp::toObject(ExecState *exec) const178 JSObject *JSNumberCell::toObject(ExecState *exec) const 179 179 { 180 180 List args; 181 args.append(const_cast< NumberImp*>(this));181 args.append(const_cast<JSNumberCell*>(this)); 182 182 return static_cast<JSObject *>(exec->lexicalGlobalObject()->numberConstructor()->construct(exec,args)); 183 183 } 184 184 185 JSObject* NumberImp::toThisObject(ExecState* exec) const185 JSObject* JSNumberCell::toThisObject(ExecState* exec) const 186 186 { 187 187 List args; 188 args.append(const_cast< NumberImp*>(this));188 args.append(const_cast<JSNumberCell*>(this)); 189 189 return static_cast<JSObject*>(exec->lexicalGlobalObject()->numberConstructor()->construct(exec, args)); 190 190 } 191 191 192 bool NumberImp::getUInt32(uint32_t& uint32) const192 bool JSNumberCell::getUInt32(uint32_t& uint32) const 193 193 { 194 194 uint32 = static_cast<uint32_t>(val); … … 196 196 } 197 197 198 bool NumberImp::getTruncatedInt32(int32_t& int32) const198 bool JSNumberCell::getTruncatedInt32(int32_t& int32) const 199 199 { 200 200 if (!(val >= -2147483648.0 && val < 2147483648.0)) … … 204 204 } 205 205 206 bool NumberImp::getTruncatedUInt32(uint32_t& uint32) const206 bool JSNumberCell::getTruncatedUInt32(uint32_t& uint32) const 207 207 { 208 208 if (!(val >= 0.0 && val < 4294967296.0)) … … 212 212 } 213 213 214 // --------------------------- GetterSetter Imp---------------------------------215 void GetterSetter Imp::mark()214 // --------------------------- GetterSetter --------------------------------- 215 void GetterSetter::mark() 216 216 { 217 217 JSCell::mark(); … … 223 223 } 224 224 225 JSValue* GetterSetter Imp::toPrimitive(ExecState*, JSType) const225 JSValue* GetterSetter::toPrimitive(ExecState*, JSType) const 226 226 { 227 227 ASSERT(false); … … 229 229 } 230 230 231 bool GetterSetter Imp::getPrimitiveNumber(ExecState*, double& number, JSValue*& value)231 bool GetterSetter::getPrimitiveNumber(ExecState*, double& number, JSValue*& value) 232 232 { 233 233 ASSERT_NOT_REACHED(); … … 237 237 } 238 238 239 bool GetterSetter Imp::toBoolean(ExecState*) const240 { 241 ASSERT(false); 242 return false; 243 } 244 245 double GetterSetter Imp::toNumber(ExecState *) const239 bool GetterSetter::toBoolean(ExecState*) const 240 { 241 ASSERT(false); 242 return false; 243 } 244 245 double GetterSetter::toNumber(ExecState *) const 246 246 { 247 247 ASSERT(false); … … 249 249 } 250 250 251 UString GetterSetter Imp::toString(ExecState *) const251 UString GetterSetter::toString(ExecState *) const 252 252 { 253 253 ASSERT(false); … … 255 255 } 256 256 257 JSObject *GetterSetter Imp::toObject(ExecState *exec) const257 JSObject *GetterSetter::toObject(ExecState *exec) const 258 258 { 259 259 ASSERT(false); … … 261 261 } 262 262 263 bool GetterSetter Imp::getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&)264 { 265 ASSERT_NOT_REACHED(); 266 return false; 267 } 268 269 bool GetterSetter Imp::getOwnPropertySlot(ExecState*, unsigned, PropertySlot&)270 { 271 ASSERT_NOT_REACHED(); 272 return false; 273 } 274 275 void GetterSetter Imp::put(ExecState*, const Identifier&, JSValue*)276 { 277 ASSERT_NOT_REACHED(); 278 } 279 280 void GetterSetter Imp::put(ExecState*, unsigned, JSValue*)281 { 282 ASSERT_NOT_REACHED(); 283 } 284 285 JSObject* GetterSetter Imp::toThisObject(ExecState*) const263 bool GetterSetter::getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&) 264 { 265 ASSERT_NOT_REACHED(); 266 return false; 267 } 268 269 bool GetterSetter::getOwnPropertySlot(ExecState*, unsigned, PropertySlot&) 270 { 271 ASSERT_NOT_REACHED(); 272 return false; 273 } 274 275 void GetterSetter::put(ExecState*, const Identifier&, JSValue*) 276 { 277 ASSERT_NOT_REACHED(); 278 } 279 280 void GetterSetter::put(ExecState*, unsigned, JSValue*) 281 { 282 ASSERT_NOT_REACHED(); 283 } 284 285 JSObject* GetterSetter::toThisObject(ExecState*) const 286 286 { 287 287 ASSERT_NOT_REACHED();
Note:
See TracChangeset
for help on using the changeset viewer.