Changeset 37333 in webkit for trunk/JavaScriptCore/kjs
- Timestamp:
- Oct 6, 2008, 10:50:08 AM (17 years ago)
- Location:
- trunk/JavaScriptCore/kjs
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/ArrayPrototype.cpp
r37175 r37333 583 583 JSValue* result = call(exec, function, callType, callData, applyThis, eachArguments); 584 584 585 if (result->toBoolean( exec))585 if (result->toBoolean()) 586 586 resultArray->put(exec, filterIndex++, v); 587 587 } … … 657 657 eachArguments.append(thisObj); 658 658 659 bool predicateResult = call(exec, function, callType, callData, applyThis, eachArguments)->toBoolean( exec);659 bool predicateResult = call(exec, function, callType, callData, applyThis, eachArguments)->toBoolean(); 660 660 661 661 if (!predicateResult) { … … 721 721 eachArguments.append(thisObj); 722 722 723 bool predicateResult = call(exec, function, callType, callData, applyThis, eachArguments)->toBoolean( exec);723 bool predicateResult = call(exec, function, callType, callData, applyThis, eachArguments)->toBoolean(); 724 724 725 725 if (predicateResult) { -
trunk/JavaScriptCore/kjs/BooleanConstructor.cpp
r37257 r37333 42 42 { 43 43 BooleanObject* obj = new (exec) BooleanObject(exec->lexicalGlobalObject()->booleanObjectStructure()); 44 obj->setInternalValue(jsBoolean(args.at(exec, 0)->toBoolean( exec)));44 obj->setInternalValue(jsBoolean(args.at(exec, 0)->toBoolean())); 45 45 return obj; 46 46 } … … 60 60 static JSValue* callBooleanConstructor(ExecState* exec, JSObject*, JSValue*, const ArgList& args) 61 61 { 62 return jsBoolean(args.at(exec, 0)->toBoolean( exec));62 return jsBoolean(args.at(exec, 0)->toBoolean()); 63 63 } 64 64 -
trunk/JavaScriptCore/kjs/GetterSetter.h
r36316 r37333 53 53 virtual JSValue* toPrimitive(ExecState*, PreferredPrimitiveType) const; 54 54 virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value); 55 virtualbool toBoolean(ExecState*) const;55 bool toBoolean(ExecState*) const; 56 56 virtual double toNumber(ExecState*) const; 57 57 virtual UString toString(ExecState*) const; -
trunk/JavaScriptCore/kjs/JSCell.h
r37285 r37333 73 73 virtual JSValue* toPrimitive(ExecState*, PreferredPrimitiveType) const = 0; 74 74 virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*&) = 0; 75 virtual bool toBoolean(ExecState*) const = 0;75 bool toBoolean() const; 76 76 virtual double toNumber(ExecState*) const = 0; 77 77 virtual UString toString(ExecState*) const = 0; … … 273 273 } 274 274 275 inline bool JSValue::toBoolean( ExecState* exec) const276 { 277 return JSImmediate::isImmediate(this) ? JSImmediate::toBoolean(this) : asCell()->toBoolean( exec);275 inline bool JSValue::toBoolean() const 276 { 277 return JSImmediate::isImmediate(this) ? JSImmediate::toBoolean(this) : asCell()->toBoolean(); 278 278 } 279 279 -
trunk/JavaScriptCore/kjs/JSNumberCell.cpp
r37257 r37333 39 39 value = this; 40 40 return true; 41 }42 43 bool JSNumberCell::toBoolean(ExecState*) const44 {45 return m_value < 0.0 || m_value > 0.0; // false for NaN46 41 } 47 42 -
trunk/JavaScriptCore/kjs/JSNumberCell.h
r37285 r37333 53 53 virtual JSValue* toPrimitive(ExecState*, PreferredPrimitiveType) const; 54 54 virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value); 55 virtual bool toBoolean(ExecState*) const;55 bool toBoolean() const { return m_value < 0.0 || m_value > 0.0; /* false for NaN */ } 56 56 virtual double toNumber(ExecState*) const; 57 57 virtual UString toString(ExecState*) const; -
trunk/JavaScriptCore/kjs/JSObject.cpp
r37297 r37333 431 431 } 432 432 433 bool JSObject::toBoolean(ExecState*) const434 {435 return true;436 }437 438 433 double JSObject::toNumber(ExecState* exec) const 439 434 { -
trunk/JavaScriptCore/kjs/JSObject.h
r37068 r37333 29 29 #include "ExecState.h" 30 30 #include "JSNumberCell.h" 31 #include "JSString.h" 31 32 #include "PropertyMap.h" 32 33 #include "PropertySlot.h" … … 110 111 virtual JSValue* toPrimitive(ExecState*, PreferredPrimitiveType = NoPreference) const; 111 112 virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value); 112 virtual bool toBoolean(ExecState*) const;113 bool toBoolean() const { return true; } 113 114 virtual double toNumber(ExecState*) const; 114 115 virtual UString toString(ExecState*) const; … … 245 246 } 246 247 return false; 248 } 249 250 inline bool JSCell::toBoolean() const 251 { 252 JSType type = structureID()->typeInfo().type(); 253 if (type == NumberType) 254 return static_cast<const JSNumberCell*>(this)->toBoolean(); 255 if (type == ObjectType) 256 return static_cast<const JSObject*>(this)->toBoolean(); 257 ASSERT(type == StringType); 258 return static_cast<const JSString*>(this)->toBoolean(); 247 259 } 248 260 -
trunk/JavaScriptCore/kjs/JSString.cpp
r37257 r37333 41 41 number = m_value.toDouble(); 42 42 return false; 43 }44 45 bool JSString::toBoolean(ExecState*) const46 {47 return !m_value.isEmpty();48 43 } 49 44 -
trunk/JavaScriptCore/kjs/JSString.h
r37285 r37333 93 93 static PassRefPtr<StructureID> createStructureID(JSValue* proto) { return StructureID::create(proto, TypeInfo(StringType, NeedsThisConversion)); } 94 94 95 bool toBoolean() const { return !m_value.isEmpty(); } 96 95 97 private: 96 98 enum VPtrStealingHackType { VPtrStealingHack }; … … 102 104 virtual JSValue* toPrimitive(ExecState*, PreferredPrimitiveType) const; 103 105 virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value); 104 virtual bool toBoolean(ExecState*) const;105 106 virtual double toNumber(ExecState*) const; 106 107 virtual JSObject* toObject(ExecState*) const; -
trunk/JavaScriptCore/kjs/JSValue.h
r37285 r37333 97 97 bool getPrimitiveNumber(ExecState*, double& number, JSValue*&); 98 98 99 bool toBoolean( ExecState*) const;99 bool toBoolean() const; 100 100 101 101 // toNumber conversion is expected to be side effect free if an exception has -
trunk/JavaScriptCore/kjs/RegExpConstructor.cpp
r37257 r37333 312 312 } 313 313 314 void setRegExpConstructorMultiline(ExecState* exec, JSObject* baseObject, JSValue* value)315 { 316 static_cast<RegExpConstructor*>(baseObject)->setMultiline(value->toBoolean( exec));314 void setRegExpConstructorMultiline(ExecState*, JSObject* baseObject, JSValue* value) 315 { 316 static_cast<RegExpConstructor*>(baseObject)->setMultiline(value->toBoolean()); 317 317 } 318 318 -
trunk/JavaScriptCore/kjs/RegExpObject.cpp
r36977 r37333 122 122 } 123 123 124 bool global = get(exec, exec->propertyNames().global)->toBoolean( exec);124 bool global = get(exec, exec->propertyNames().global)->toBoolean(); 125 125 int lastIndex = 0; 126 126 if (global) { -
trunk/JavaScriptCore/kjs/RegExpPrototype.cpp
r36726 r37333 107 107 UString result = "/" + static_cast<RegExpObject*>(thisValue)->get(exec, exec->propertyNames().source)->toString(exec); 108 108 result.append('/'); 109 if (static_cast<RegExpObject*>(thisValue)->get(exec, exec->propertyNames().global)->toBoolean( exec))109 if (static_cast<RegExpObject*>(thisValue)->get(exec, exec->propertyNames().global)->toBoolean()) 110 110 result.append('g'); 111 if (static_cast<RegExpObject*>(thisValue)->get(exec, exec->propertyNames().ignoreCase)->toBoolean( exec))111 if (static_cast<RegExpObject*>(thisValue)->get(exec, exec->propertyNames().ignoreCase)->toBoolean()) 112 112 result.append('i'); 113 if (static_cast<RegExpObject*>(thisValue)->get(exec, exec->propertyNames().multiline)->toBoolean( exec))113 if (static_cast<RegExpObject*>(thisValue)->get(exec, exec->propertyNames().multiline)->toBoolean()) 114 114 result.append('m'); 115 115 return jsNontrivialString(exec, result);
Note:
See TracChangeset
for help on using the changeset viewer.