Commit 6c3268ce authored by mjs@apple.com's avatar mjs@apple.com

JavaScriptCore:

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
parent d11bb12b
......@@ -188,9 +188,11 @@ JSValueRef JSValueMakeString(JSContextRef ctx, JSStringRef string)
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.
......
......@@ -335,6 +335,7 @@ __ZNK3JSC8JSObject8toNumberEPNS_9ExecStateE
__ZNK3JSC8JSObject8toObjectEPNS_9ExecStateE
__ZNK3JSC8JSObject8toStringEPNS_9ExecStateE
__ZNK3JSC8JSObject9classNameEv
__ZNK3JSC8JSObject9toBooleanEPNS_9ExecStateE
__ZNK3JSC9CodeBlock17derefStructureIDsEPNS_11InstructionE
__ZNK3JSC9HashTable11createTableEPNS_12JSGlobalDataE
__ZNK3WTF8Collator7collateEPKtmS2_m
......
......@@ -810,11 +810,13 @@ void CodeBlock::dump(ExecState* exec, const Vector<Instruction>::const_iterator&
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: {
......
......@@ -2127,7 +2127,8 @@ JSValue* Machine::privateExecute(ExecutionFlag flag, RegisterFile* registerFile,
*/
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;
......@@ -2985,7 +2986,7 @@ JSValue* Machine::privateExecute(ExecutionFlag flag, RegisterFile* registerFile,
*/
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;
......@@ -3002,7 +3003,7 @@ JSValue* Machine::privateExecute(ExecutionFlag flag, RegisterFile* registerFile,
*/
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;
}
......@@ -3018,7 +3019,7 @@ JSValue* Machine::privateExecute(ExecutionFlag flag, RegisterFile* registerFile,
*/
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;
}
......@@ -4987,7 +4988,11 @@ int Machine::cti_op_loop_if_true(CTI_ARGS)
{
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)
......@@ -5110,12 +5115,24 @@ int Machine::cti_op_jless(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)
......
......@@ -582,7 +582,7 @@ JSValue* arrayProtoFuncFilter(ExecState* exec, JSObject*, JSValue* thisValue, co
JSValue* result = call(exec, function, callType, callData, applyThis, eachArguments);
if (result->toBoolean())
if (result->toBoolean(exec))
resultArray->put(exec, filterIndex++, v);
}
return resultArray;
......@@ -656,7 +656,7 @@ JSValue* arrayProtoFuncEvery(ExecState* exec, JSObject*, JSValue* thisValue, con
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);
......@@ -720,7 +720,7 @@ JSValue* arrayProtoFuncSome(ExecState* exec, JSObject*, JSValue* thisValue, cons
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);
......
......@@ -41,7 +41,7 @@ BooleanConstructor::BooleanConstructor(ExecState* exec, PassRefPtr<StructureID>
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;
}
......@@ -59,7 +59,7 @@ ConstructType BooleanConstructor::getConstructData(ConstructData& constructData)
// 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)
......
......@@ -52,7 +52,7 @@ namespace JSC {
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;
......
......@@ -72,7 +72,7 @@ namespace JSC {
// 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;
......@@ -272,9 +272,9 @@ namespace JSC {
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
......
......@@ -40,6 +40,11 @@ bool JSNumberCell::getPrimitiveNumber(ExecState*, double& number, JSValue*& valu
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;
......
......@@ -52,7 +52,7 @@ namespace JSC {
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;
......
......@@ -430,6 +430,11 @@ void JSObject::getPropertyNames(ExecState* exec, PropertyNameArray& propertyName
m_structureID->getEnumerablePropertyNames(exec, propertyNames, this);
}
bool JSObject::toBoolean(ExecState*) const
{
return true;
}
double JSObject::toNumber(ExecState* exec) const
{
JSValue* primitive = toPrimitive(exec, PreferNumber);
......
......@@ -28,7 +28,6 @@
#include "CommonIdentifiers.h"
#include "ExecState.h"
#include "JSNumberCell.h"
#include "JSString.h"
#include "PropertyMap.h"
#include "PropertySlot.h"
#include "PutPropertySlot.h"
......@@ -110,7 +109,7 @@ namespace JSC {
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;
......@@ -247,17 +246,6 @@ inline bool JSCell::isObject(const ClassInfo* info) 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
{
......
......@@ -42,6 +42,11 @@ bool JSString::getPrimitiveNumber(ExecState*, double& number, JSValue*& value)
return false;
}
bool JSString::toBoolean(ExecState*) const
{
return !m_value.isEmpty();
}
double JSString::toNumber(ExecState*) const
{
return m_value.toDouble();
......
......@@ -92,8 +92,6 @@ namespace JSC {
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)
......@@ -103,6 +101,7 @@ namespace JSC {
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;
......
......@@ -96,7 +96,7 @@ namespace JSC {
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.
......
......@@ -311,9 +311,9 @@ void setRegExpConstructorInput(ExecState* exec, JSObject* baseObject, JSValue* v
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
......
......@@ -121,7 +121,7 @@ bool RegExpObject::match(ExecState* exec, const ArgList& args)
}
}
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()) {
......
......@@ -106,11 +106,11 @@ JSValue* regExpProtoFuncToString(ExecState* exec, JSObject*, JSValue* thisValue,
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.
......
......@@ -207,7 +207,7 @@ CFTypeRef KJSValueToCFTypeInternal(JSValue *inValue, ExecState *exec, ObjectImpL
if (inValue->isBoolean())
{
result = inValue->toBoolean() ? kCFBooleanTrue : kCFBooleanFalse;
result = inValue->toBoolean(exec) ? kCFBooleanTrue : kCFBooleanFalse;
RetainCFType(result);
return result;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment