Changeset 37337 in webkit for trunk/JavaScriptCore/kjs


Ignore:
Timestamp:
Oct 6, 2008, 11:31:07 AM (17 years ago)
Author:
[email protected]
Message:

JavaScriptCore:

2008-10-06 Maciej Stachowiak <[email protected]>

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 <[email protected]>

Not reviewed. Build fix.

  • revert toBoolean changes (r37333 and r37335); need to make WebCore work with these
  • JSUtils.cpp: (KJSValueToCFTypeInternal):
Location:
trunk/JavaScriptCore/kjs
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/ArrayPrototype.cpp

    r37333 r37337  
    583583        JSValue* result = call(exec, function, callType, callData, applyThis, eachArguments);
    584584
    585         if (result->toBoolean())
     585        if (result->toBoolean(exec))
    586586            resultArray->put(exec, filterIndex++, v);
    587587    }
     
    657657        eachArguments.append(thisObj);
    658658
    659         bool predicateResult = call(exec, function, callType, callData, applyThis, eachArguments)->toBoolean();
     659        bool predicateResult = call(exec, function, callType, callData, applyThis, eachArguments)->toBoolean(exec);
    660660
    661661        if (!predicateResult) {
     
    721721        eachArguments.append(thisObj);
    722722
    723         bool predicateResult = call(exec, function, callType, callData, applyThis, eachArguments)->toBoolean();
     723        bool predicateResult = call(exec, function, callType, callData, applyThis, eachArguments)->toBoolean(exec);
    724724
    725725        if (predicateResult) {
  • trunk/JavaScriptCore/kjs/BooleanConstructor.cpp

    r37333 r37337  
    4242{
    4343    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)));
    4545    return obj;
    4646}
     
    6060static JSValue* callBooleanConstructor(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
    6161{
    62     return jsBoolean(args.at(exec, 0)->toBoolean());
     62    return jsBoolean(args.at(exec, 0)->toBoolean(exec));
    6363}
    6464
  • trunk/JavaScriptCore/kjs/GetterSetter.h

    r37333 r37337  
    5353        virtual JSValue* toPrimitive(ExecState*, PreferredPrimitiveType) const;
    5454        virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value);
    55         bool toBoolean(ExecState*) const;
     55        virtual bool toBoolean(ExecState*) const;
    5656        virtual double toNumber(ExecState*) const;
    5757        virtual UString toString(ExecState*) const;
  • trunk/JavaScriptCore/kjs/JSCell.h

    r37333 r37337  
    7373        virtual JSValue* toPrimitive(ExecState*, PreferredPrimitiveType) const = 0;
    7474        virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*&) = 0;
    75         bool toBoolean() const;
     75        virtual bool toBoolean(ExecState*) const = 0;
    7676        virtual double toNumber(ExecState*) const = 0;
    7777        virtual UString toString(ExecState*) const = 0;
     
    273273    }
    274274
    275     inline bool JSValue::toBoolean() const
    276     {
    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);
    278278    }
    279279
  • trunk/JavaScriptCore/kjs/JSNumberCell.cpp

    r37333 r37337  
    3939    value = this;
    4040    return true;
     41}
     42
     43bool JSNumberCell::toBoolean(ExecState*) const
     44{
     45    return m_value < 0.0 || m_value > 0.0; // false for NaN
    4146}
    4247
  • trunk/JavaScriptCore/kjs/JSNumberCell.h

    r37333 r37337  
    5353        virtual JSValue* toPrimitive(ExecState*, PreferredPrimitiveType) const;
    5454        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;
    5656        virtual double toNumber(ExecState*) const;
    5757        virtual UString toString(ExecState*) const;
  • trunk/JavaScriptCore/kjs/JSObject.cpp

    r37333 r37337  
    431431}
    432432
     433bool JSObject::toBoolean(ExecState*) const
     434{
     435    return true;
     436}
     437
    433438double JSObject::toNumber(ExecState* exec) const
    434439{
  • trunk/JavaScriptCore/kjs/JSObject.h

    r37333 r37337  
    2929#include "ExecState.h"
    3030#include "JSNumberCell.h"
    31 #include "JSString.h"
    3231#include "PropertyMap.h"
    3332#include "PropertySlot.h"
     
    111110        virtual JSValue* toPrimitive(ExecState*, PreferredPrimitiveType = NoPreference) const;
    112111        virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value);
    113         bool toBoolean() const { return true; }
     112        virtual bool toBoolean(ExecState*) const;
    114113        virtual double toNumber(ExecState*) const;
    115114        virtual UString toString(ExecState*) const;
     
    246245    }
    247246    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();
    259247}
    260248
  • trunk/JavaScriptCore/kjs/JSString.cpp

    r37333 r37337  
    4141    number = m_value.toDouble();
    4242    return false;
     43}
     44
     45bool JSString::toBoolean(ExecState*) const
     46{
     47    return !m_value.isEmpty();
    4348}
    4449
  • trunk/JavaScriptCore/kjs/JSString.h

    r37333 r37337  
    9393        static PassRefPtr<StructureID> createStructureID(JSValue* proto) { return StructureID::create(proto, TypeInfo(StringType, NeedsThisConversion)); }
    9494
    95         bool toBoolean() const { return !m_value.isEmpty(); }
    96 
    9795    private:
    9896        enum VPtrStealingHackType { VPtrStealingHack };
     
    104102        virtual JSValue* toPrimitive(ExecState*, PreferredPrimitiveType) const;
    105103        virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value);
     104        virtual bool toBoolean(ExecState*) const;
    106105        virtual double toNumber(ExecState*) const;
    107106        virtual JSObject* toObject(ExecState*) const;
  • trunk/JavaScriptCore/kjs/JSValue.h

    r37333 r37337  
    9797        bool getPrimitiveNumber(ExecState*, double& number, JSValue*&);
    9898
    99         bool toBoolean() const;
     99        bool toBoolean(ExecState*) const;
    100100
    101101        // toNumber conversion is expected to be side effect free if an exception has
  • trunk/JavaScriptCore/kjs/RegExpConstructor.cpp

    r37333 r37337  
    312312}
    313313
    314 void setRegExpConstructorMultiline(ExecState*, JSObject* baseObject, JSValue* value)
    315 {
    316     static_cast<RegExpConstructor*>(baseObject)->setMultiline(value->toBoolean());
     314void setRegExpConstructorMultiline(ExecState* exec, JSObject* baseObject, JSValue* value)
     315{
     316    static_cast<RegExpConstructor*>(baseObject)->setMultiline(value->toBoolean(exec));
    317317}
    318318 
  • trunk/JavaScriptCore/kjs/RegExpObject.cpp

    r37333 r37337  
    122122    }
    123123
    124     bool global = get(exec, exec->propertyNames().global)->toBoolean();
     124    bool global = get(exec, exec->propertyNames().global)->toBoolean(exec);
    125125    int lastIndex = 0;
    126126    if (global) {
  • trunk/JavaScriptCore/kjs/RegExpPrototype.cpp

    r37333 r37337  
    107107    UString result = "/" + static_cast<RegExpObject*>(thisValue)->get(exec, exec->propertyNames().source)->toString(exec);
    108108    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))
    110110        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))
    112112        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))
    114114        result.append('m');
    115115    return jsNontrivialString(exec, result);
Note: See TracChangeset for help on using the changeset viewer.