2008-10-06 Maciej Stachowiak <mjs@apple.com>
Not reviewed. Build fix.
- revert toBoolean changes (r37333 and r37335); need to make WebCore work with these
* API/JSValueRef.cpp:
(JSValueToBoolean):
* ChangeLog:
* JavaScriptCore.exp:
* VM/CodeBlock.cpp:
(JSC::CodeBlock::dump):
* VM/Machine.cpp:
(JSC::Machine::privateExecute):
(JSC::Machine::cti_op_loop_if_true):
(JSC::Machine::cti_op_not):
(JSC::Machine::cti_op_jtrue):
* kjs/ArrayPrototype.cpp:
(JSC::arrayProtoFuncFilter):
(JSC::arrayProtoFuncEvery):
(JSC::arrayProtoFuncSome):
* kjs/BooleanConstructor.cpp:
(JSC::constructBoolean):
(JSC::callBooleanConstructor):
* kjs/GetterSetter.h:
* kjs/JSCell.h:
(JSC::JSValue::toBoolean):
* kjs/JSNumberCell.cpp:
(JSC::JSNumberCell::toBoolean):
* kjs/JSNumberCell.h:
* kjs/JSObject.cpp:
(JSC::JSObject::toBoolean):
* kjs/JSObject.h:
* kjs/JSString.cpp:
(JSC::JSString::toBoolean):
* kjs/JSString.h:
* kjs/JSValue.h:
* kjs/RegExpConstructor.cpp:
(JSC::setRegExpConstructorMultiline):
* kjs/RegExpObject.cpp:
(JSC::RegExpObject::match):
* kjs/RegExpPrototype.cpp:
(JSC::regExpProtoFuncToString):
JavaScriptGlue:
2008-10-06 Maciej Stachowiak <mjs@apple.com>
Not reviewed. Build fix.
- revert toBoolean changes (r37333 and r37335); need to make WebCore work with these
* JSUtils.cpp:
(KJSValueToCFTypeInternal):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@37337
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
return toRef(jsString(exec, string->ustring()));
}
-bool JSValueToBoolean(JSContextRef, JSValueRef value)
+bool JSValueToBoolean(JSContextRef ctx, JSValueRef value)
{
- return toJS(value)->toBoolean();
+ ExecState* exec = toJS(ctx);
+ JSValue* jsValue = toJS(value);
+ return jsValue->toBoolean(exec);
}
double JSValueToNumber(JSContextRef ctx, JSValueRef value, JSValueRef* exception)
+2008-10-06 Maciej Stachowiak <mjs@apple.com>
+
+ Not reviewed. Build fix.
+
+ - revert toBoolean changes (r37333 and r37335); need to make WebCore work with these
+
+ * API/JSValueRef.cpp:
+ (JSValueToBoolean):
+ * ChangeLog:
+ * JavaScriptCore.exp:
+ * VM/CodeBlock.cpp:
+ (JSC::CodeBlock::dump):
+ * VM/Machine.cpp:
+ (JSC::Machine::privateExecute):
+ (JSC::Machine::cti_op_loop_if_true):
+ (JSC::Machine::cti_op_not):
+ (JSC::Machine::cti_op_jtrue):
+ * kjs/ArrayPrototype.cpp:
+ (JSC::arrayProtoFuncFilter):
+ (JSC::arrayProtoFuncEvery):
+ (JSC::arrayProtoFuncSome):
+ * kjs/BooleanConstructor.cpp:
+ (JSC::constructBoolean):
+ (JSC::callBooleanConstructor):
+ * kjs/GetterSetter.h:
+ * kjs/JSCell.h:
+ (JSC::JSValue::toBoolean):
+ * kjs/JSNumberCell.cpp:
+ (JSC::JSNumberCell::toBoolean):
+ * kjs/JSNumberCell.h:
+ * kjs/JSObject.cpp:
+ (JSC::JSObject::toBoolean):
+ * kjs/JSObject.h:
+ * kjs/JSString.cpp:
+ (JSC::JSString::toBoolean):
+ * kjs/JSString.h:
+ * kjs/JSValue.h:
+ * kjs/RegExpConstructor.cpp:
+ (JSC::setRegExpConstructorMultiline):
+ * kjs/RegExpObject.cpp:
+ (JSC::RegExpObject::match):
+ * kjs/RegExpPrototype.cpp:
+ (JSC::regExpProtoFuncToString):
+
2008-10-06 Maciej Stachowiak <mjs@apple.com>
Reviewed by Sam Weinig.
__ZNK3JSC8JSObject8toObjectEPNS_9ExecStateE
__ZNK3JSC8JSObject8toStringEPNS_9ExecStateE
__ZNK3JSC8JSObject9classNameEv
+__ZNK3JSC8JSObject9toBooleanEPNS_9ExecStateE
__ZNK3JSC9CodeBlock17derefStructureIDsEPNS_11InstructionE
__ZNK3JSC9HashTable11createTableEPNS_12JSGlobalDataE
__ZNK3WTF8Collator7collateEPKtmS2_m
break;
}
case op_tear_off_activation: {
- printf("[%4d] tear_off_activation\n", location);
+ int r0 = (++it)->u.operand;
+ printf("[%4d] tear_off_activation\t %s\n", location, registerName(r0).c_str());
break;
}
case op_tear_off_arguments: {
- printf("[%4d] tear_off_arguments\n", location);
+ int r0 = (++it)->u.operand;
+ printf("[%4d] tear_off_arguments\t %s\n", location, registerName(r0).c_str());
break;
}
case op_ret: {
*/
int dst = (++vPC)->u.operand;
int src = (++vPC)->u.operand;
- JSValue* result = jsBoolean(!r[src].jsValue(exec)->toBoolean());
+ JSValue* result = jsBoolean(!r[src].jsValue(exec)->toBoolean(exec));
+ VM_CHECK_EXCEPTION();
r[dst] = result;
++vPC;
*/
int cond = (++vPC)->u.operand;
int target = (++vPC)->u.operand;
- if (r[cond].jsValue(exec)->toBoolean()) {
+ if (r[cond].jsValue(exec)->toBoolean(exec)) {
vPC += target;
CHECK_FOR_TIMEOUT();
NEXT_OPCODE;
*/
int cond = (++vPC)->u.operand;
int target = (++vPC)->u.operand;
- if (r[cond].jsValue(exec)->toBoolean()) {
+ if (r[cond].jsValue(exec)->toBoolean(exec)) {
vPC += target;
NEXT_OPCODE;
}
*/
int cond = (++vPC)->u.operand;
int target = (++vPC)->u.operand;
- if (!r[cond].jsValue(exec)->toBoolean()) {
+ if (!r[cond].jsValue(exec)->toBoolean(exec)) {
vPC += target;
NEXT_OPCODE;
}
{
JSValue* src1 = ARG_src1;
- return src1->toBoolean();
+ ExecState* exec = ARG_exec;
+
+ bool result = src1->toBoolean(exec);
+ VM_CHECK_EXCEPTION_AT_END();
+ return result;
}
JSValue* Machine::cti_op_negate(CTI_ARGS)
JSValue* Machine::cti_op_not(CTI_ARGS)
{
- return jsBoolean(!ARG_src1->toBoolean());
+ JSValue* src = ARG_src1;
+
+ ExecState* exec = ARG_exec;
+
+ JSValue* result = jsBoolean(!src->toBoolean(exec));
+ VM_CHECK_EXCEPTION_AT_END();
+ return result;
}
int SFX_CALL Machine::cti_op_jtrue(CTI_ARGS)
{
- return ARG_src1->toBoolean();
+ JSValue* src1 = ARG_src1;
+
+ ExecState* exec = ARG_exec;
+
+ bool result = src1->toBoolean(exec);
+ VM_CHECK_EXCEPTION_AT_END();
+ return result;
}
JSValue* Machine::cti_op_post_inc(CTI_ARGS)
JSValue* result = call(exec, function, callType, callData, applyThis, eachArguments);
- if (result->toBoolean())
+ if (result->toBoolean(exec))
resultArray->put(exec, filterIndex++, v);
}
return resultArray;
eachArguments.append(jsNumber(exec, k));
eachArguments.append(thisObj);
- bool predicateResult = call(exec, function, callType, callData, applyThis, eachArguments)->toBoolean();
+ bool predicateResult = call(exec, function, callType, callData, applyThis, eachArguments)->toBoolean(exec);
if (!predicateResult) {
result = jsBoolean(false);
eachArguments.append(jsNumber(exec, k));
eachArguments.append(thisObj);
- bool predicateResult = call(exec, function, callType, callData, applyThis, eachArguments)->toBoolean();
+ bool predicateResult = call(exec, function, callType, callData, applyThis, eachArguments)->toBoolean(exec);
if (predicateResult) {
result = jsBoolean(true);
JSObject* constructBoolean(ExecState* exec, const ArgList& args)
{
BooleanObject* obj = new (exec) BooleanObject(exec->lexicalGlobalObject()->booleanObjectStructure());
- obj->setInternalValue(jsBoolean(args.at(exec, 0)->toBoolean()));
+ obj->setInternalValue(jsBoolean(args.at(exec, 0)->toBoolean(exec)));
return obj;
}
// ECMA 15.6.1
static JSValue* callBooleanConstructor(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
- return jsBoolean(args.at(exec, 0)->toBoolean());
+ return jsBoolean(args.at(exec, 0)->toBoolean(exec));
}
CallType BooleanConstructor::getCallData(CallData& callData)
virtual JSValue* toPrimitive(ExecState*, PreferredPrimitiveType) const;
virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value);
- bool toBoolean(ExecState*) const;
+ virtual bool toBoolean(ExecState*) const;
virtual double toNumber(ExecState*) const;
virtual UString toString(ExecState*) const;
virtual JSObject* toObject(ExecState*) const;
// Basic conversions.
virtual JSValue* toPrimitive(ExecState*, PreferredPrimitiveType) const = 0;
virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*&) = 0;
- bool toBoolean() const;
+ virtual bool toBoolean(ExecState*) const = 0;
virtual double toNumber(ExecState*) const = 0;
virtual UString toString(ExecState*) const = 0;
virtual JSObject* toObject(ExecState*) const = 0;
return asCell()->getPrimitiveNumber(exec, number, value);
}
- inline bool JSValue::toBoolean() const
+ inline bool JSValue::toBoolean(ExecState* exec) const
{
- return JSImmediate::isImmediate(this) ? JSImmediate::toBoolean(this) : asCell()->toBoolean();
+ return JSImmediate::isImmediate(this) ? JSImmediate::toBoolean(this) : asCell()->toBoolean(exec);
}
ALWAYS_INLINE double JSValue::toNumber(ExecState* exec) const
return true;
}
+bool JSNumberCell::toBoolean(ExecState*) const
+{
+ return m_value < 0.0 || m_value > 0.0; // false for NaN
+}
+
double JSNumberCell::toNumber(ExecState*) const
{
return m_value;
virtual JSValue* toPrimitive(ExecState*, PreferredPrimitiveType) const;
virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value);
- bool toBoolean() const { return m_value < 0.0 || m_value > 0.0; /* false for NaN */ }
+ virtual bool toBoolean(ExecState*) const;
virtual double toNumber(ExecState*) const;
virtual UString toString(ExecState*) const;
virtual JSObject* toObject(ExecState*) const;
m_structureID->getEnumerablePropertyNames(exec, propertyNames, this);
}
+bool JSObject::toBoolean(ExecState*) const
+{
+ return true;
+}
+
double JSObject::toNumber(ExecState* exec) const
{
JSValue* primitive = toPrimitive(exec, PreferNumber);
#include "CommonIdentifiers.h"
#include "ExecState.h"
#include "JSNumberCell.h"
-#include "JSString.h"
#include "PropertyMap.h"
#include "PropertySlot.h"
#include "PutPropertySlot.h"
virtual JSValue* toPrimitive(ExecState*, PreferredPrimitiveType = NoPreference) const;
virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value);
- bool toBoolean() const { return true; }
+ virtual bool toBoolean(ExecState*) const;
virtual double toNumber(ExecState*) const;
virtual UString toString(ExecState*) const;
virtual JSObject* toObject(ExecState*) const;
return false;
}
-inline bool JSCell::toBoolean() const
-{
- JSType type = structureID()->typeInfo().type();
- if (type == NumberType)
- return static_cast<const JSNumberCell*>(this)->toBoolean();
- if (type == ObjectType)
- return static_cast<const JSObject*>(this)->toBoolean();
- ASSERT(type == StringType);
- return static_cast<const JSString*>(this)->toBoolean();
-}
-
// this method is here to be after the inline declaration of JSCell::isObject
inline bool JSValue::isObject(const ClassInfo* classInfo) const
{
return false;
}
+bool JSString::toBoolean(ExecState*) const
+{
+ return !m_value.isEmpty();
+}
+
double JSString::toNumber(ExecState*) const
{
return m_value.toDouble();
static PassRefPtr<StructureID> createStructureID(JSValue* proto) { return StructureID::create(proto, TypeInfo(StringType, NeedsThisConversion)); }
- bool toBoolean() const { return !m_value.isEmpty(); }
-
private:
enum VPtrStealingHackType { VPtrStealingHack };
JSString(VPtrStealingHackType)
virtual JSValue* toPrimitive(ExecState*, PreferredPrimitiveType) const;
virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value);
+ virtual bool toBoolean(ExecState*) const;
virtual double toNumber(ExecState*) const;
virtual JSObject* toObject(ExecState*) const;
virtual UString toString(ExecState*) const;
JSValue* toPrimitive(ExecState*, PreferredPrimitiveType = NoPreference) const;
bool getPrimitiveNumber(ExecState*, double& number, JSValue*&);
- bool toBoolean() const;
+ bool toBoolean(ExecState*) const;
// toNumber conversion is expected to be side effect free if an exception has
// been set in the ExecState already.
static_cast<RegExpConstructor*>(baseObject)->setInput(value->toString(exec));
}
-void setRegExpConstructorMultiline(ExecState*, JSObject* baseObject, JSValue* value)
+void setRegExpConstructorMultiline(ExecState* exec, JSObject* baseObject, JSValue* value)
{
- static_cast<RegExpConstructor*>(baseObject)->setMultiline(value->toBoolean());
+ static_cast<RegExpConstructor*>(baseObject)->setMultiline(value->toBoolean(exec));
}
// ECMA 15.10.4
}
}
- bool global = get(exec, exec->propertyNames().global)->toBoolean();
+ bool global = get(exec, exec->propertyNames().global)->toBoolean(exec);
int lastIndex = 0;
if (global) {
if (d->lastIndex < 0 || d->lastIndex > input.size()) {
UString result = "/" + static_cast<RegExpObject*>(thisValue)->get(exec, exec->propertyNames().source)->toString(exec);
result.append('/');
- if (static_cast<RegExpObject*>(thisValue)->get(exec, exec->propertyNames().global)->toBoolean())
+ if (static_cast<RegExpObject*>(thisValue)->get(exec, exec->propertyNames().global)->toBoolean(exec))
result.append('g');
- if (static_cast<RegExpObject*>(thisValue)->get(exec, exec->propertyNames().ignoreCase)->toBoolean())
+ if (static_cast<RegExpObject*>(thisValue)->get(exec, exec->propertyNames().ignoreCase)->toBoolean(exec))
result.append('i');
- if (static_cast<RegExpObject*>(thisValue)->get(exec, exec->propertyNames().multiline)->toBoolean())
+ if (static_cast<RegExpObject*>(thisValue)->get(exec, exec->propertyNames().multiline)->toBoolean(exec))
result.append('m');
return jsNontrivialString(exec, result);
}
+2008-10-06 Maciej Stachowiak <mjs@apple.com>
+
+ Not reviewed. Build fix.
+
+ - revert toBoolean changes (r37333 and r37335); need to make WebCore work with these
+
+ * JSUtils.cpp:
+ (KJSValueToCFTypeInternal):
+
2008-10-06 Maciej Stachowiak <mjs@apple.com>
Not reviewed.
if (inValue->isBoolean())
{
- result = inValue->toBoolean() ? kCFBooleanTrue : kCFBooleanFalse;
+ result = inValue->toBoolean(exec) ? kCFBooleanTrue : kCFBooleanFalse;
RetainCFType(result);
return result;
}