Changeset 37337 in webkit for trunk/JavaScriptCore/kjs
- Timestamp:
- Oct 6, 2008, 11:31:07 AM (17 years ago)
- Location:
- trunk/JavaScriptCore/kjs
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/ArrayPrototype.cpp
r37333 r37337 583 583 JSValue* result = call(exec, function, callType, callData, applyThis, eachArguments); 584 584 585 if (result->toBoolean( ))585 if (result->toBoolean(exec)) 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( );659 bool predicateResult = call(exec, function, callType, callData, applyThis, eachArguments)->toBoolean(exec); 660 660 661 661 if (!predicateResult) { … … 721 721 eachArguments.append(thisObj); 722 722 723 bool predicateResult = call(exec, function, callType, callData, applyThis, eachArguments)->toBoolean( );723 bool predicateResult = call(exec, function, callType, callData, applyThis, eachArguments)->toBoolean(exec); 724 724 725 725 if (predicateResult) { -
trunk/JavaScriptCore/kjs/BooleanConstructor.cpp
r37333 r37337 42 42 { 43 43 BooleanObject* obj = new (exec) BooleanObject(exec->lexicalGlobalObject()->booleanObjectStructure()); 44 obj->setInternalValue(jsBoolean(args.at(exec, 0)->toBoolean( )));44 obj->setInternalValue(jsBoolean(args.at(exec, 0)->toBoolean(exec))); 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( ));62 return jsBoolean(args.at(exec, 0)->toBoolean(exec)); 63 63 } 64 64 -
trunk/JavaScriptCore/kjs/GetterSetter.h
r37333 r37337 53 53 virtual JSValue* toPrimitive(ExecState*, PreferredPrimitiveType) const; 54 54 virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value); 55 bool toBoolean(ExecState*) const;55 virtual bool toBoolean(ExecState*) const; 56 56 virtual double toNumber(ExecState*) const; 57 57 virtual UString toString(ExecState*) const; -
trunk/JavaScriptCore/kjs/JSCell.h
r37333 r37337 73 73 virtual JSValue* toPrimitive(ExecState*, PreferredPrimitiveType) const = 0; 74 74 virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*&) = 0; 75 bool toBoolean() const;75 virtual bool toBoolean(ExecState*) const = 0; 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( ) const276 { 277 return JSImmediate::isImmediate(this) ? JSImmediate::toBoolean(this) : asCell()->toBoolean( );275 inline bool JSValue::toBoolean(ExecState* exec) const 276 { 277 return JSImmediate::isImmediate(this) ? JSImmediate::toBoolean(this) : asCell()->toBoolean(exec); 278 278 } 279 279 -
trunk/JavaScriptCore/kjs/JSNumberCell.cpp
r37333 r37337 39 39 value = this; 40 40 return true; 41 } 42 43 bool JSNumberCell::toBoolean(ExecState*) const 44 { 45 return m_value < 0.0 || m_value > 0.0; // false for NaN 41 46 } 42 47 -
trunk/JavaScriptCore/kjs/JSNumberCell.h
r37333 r37337 53 53 virtual JSValue* toPrimitive(ExecState*, PreferredPrimitiveType) const; 54 54 virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value); 55 bool toBoolean() const { return m_value < 0.0 || m_value > 0.0; /* false for NaN */ }55 virtual bool toBoolean(ExecState*) const; 56 56 virtual double toNumber(ExecState*) const; 57 57 virtual UString toString(ExecState*) const; -
trunk/JavaScriptCore/kjs/JSObject.cpp
r37333 r37337 431 431 } 432 432 433 bool JSObject::toBoolean(ExecState*) const 434 { 435 return true; 436 } 437 433 438 double JSObject::toNumber(ExecState* exec) const 434 439 { -
trunk/JavaScriptCore/kjs/JSObject.h
r37333 r37337 29 29 #include "ExecState.h" 30 30 #include "JSNumberCell.h" 31 #include "JSString.h"32 31 #include "PropertyMap.h" 33 32 #include "PropertySlot.h" … … 111 110 virtual JSValue* toPrimitive(ExecState*, PreferredPrimitiveType = NoPreference) const; 112 111 virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value); 113 bool toBoolean() const { return true; }112 virtual bool toBoolean(ExecState*) const; 114 113 virtual double toNumber(ExecState*) const; 115 114 virtual UString toString(ExecState*) const; … … 246 245 } 247 246 return false; 248 }249 250 inline bool JSCell::toBoolean() const251 {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();259 247 } 260 248 -
trunk/JavaScriptCore/kjs/JSString.cpp
r37333 r37337 41 41 number = m_value.toDouble(); 42 42 return false; 43 } 44 45 bool JSString::toBoolean(ExecState*) const 46 { 47 return !m_value.isEmpty(); 43 48 } 44 49 -
trunk/JavaScriptCore/kjs/JSString.h
r37333 r37337 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 97 95 private: 98 96 enum VPtrStealingHackType { VPtrStealingHack }; … … 104 102 virtual JSValue* toPrimitive(ExecState*, PreferredPrimitiveType) const; 105 103 virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value); 104 virtual bool toBoolean(ExecState*) const; 106 105 virtual double toNumber(ExecState*) const; 107 106 virtual JSObject* toObject(ExecState*) const; -
trunk/JavaScriptCore/kjs/JSValue.h
r37333 r37337 97 97 bool getPrimitiveNumber(ExecState*, double& number, JSValue*&); 98 98 99 bool toBoolean( ) const;99 bool toBoolean(ExecState*) const; 100 100 101 101 // toNumber conversion is expected to be side effect free if an exception has -
trunk/JavaScriptCore/kjs/RegExpConstructor.cpp
r37333 r37337 312 312 } 313 313 314 void setRegExpConstructorMultiline(ExecState* , JSObject* baseObject, JSValue* value)315 { 316 static_cast<RegExpConstructor*>(baseObject)->setMultiline(value->toBoolean( ));314 void setRegExpConstructorMultiline(ExecState* exec, JSObject* baseObject, JSValue* value) 315 { 316 static_cast<RegExpConstructor*>(baseObject)->setMultiline(value->toBoolean(exec)); 317 317 } 318 318 -
trunk/JavaScriptCore/kjs/RegExpObject.cpp
r37333 r37337 122 122 } 123 123 124 bool global = get(exec, exec->propertyNames().global)->toBoolean( );124 bool global = get(exec, exec->propertyNames().global)->toBoolean(exec); 125 125 int lastIndex = 0; 126 126 if (global) { -
trunk/JavaScriptCore/kjs/RegExpPrototype.cpp
r37333 r37337 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( ))109 if (static_cast<RegExpObject*>(thisValue)->get(exec, exec->propertyNames().global)->toBoolean(exec)) 110 110 result.append('g'); 111 if (static_cast<RegExpObject*>(thisValue)->get(exec, exec->propertyNames().ignoreCase)->toBoolean( ))111 if (static_cast<RegExpObject*>(thisValue)->get(exec, exec->propertyNames().ignoreCase)->toBoolean(exec)) 112 112 result.append('i'); 113 if (static_cast<RegExpObject*>(thisValue)->get(exec, exec->propertyNames().multiline)->toBoolean( ))113 if (static_cast<RegExpObject*>(thisValue)->get(exec, exec->propertyNames().multiline)->toBoolean(exec)) 114 114 result.append('m'); 115 115 return jsNontrivialString(exec, result);
Note:
See TracChangeset
for help on using the changeset viewer.