Ignore:
Timestamp:
Jul 6, 2008, 7:49:29 PM (17 years ago)
Author:
[email protected]
Message:

JavaScriptCore:

2008-07-06 Sam Weinig <[email protected]>

Reviewed by Cameron Zwarich.

Second step in broad cleanup effort.

[ File list elided ]

WebCore:

2008-07-06 Sam Weinig <[email protected]>

Reviewed by Cameron Zwarich.

Add #include for kjs/protect.h.

  • xml/XMLHttpRequest.cpp: (WebCore::XMLHttpRequest::loadRequestAsynchronously):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/JSNumberCell.h

    r34921 r35027  
    3535namespace KJS {
    3636
    37 class ExecState;
    38 class Identifier;
    39 class JSCell;
    40 class JSObject;
    41 class JSString;
    42 class PropertySlot;
     37    class ExecState;
     38    class Identifier;
     39    class JSCell;
     40    class JSObject;
     41    class JSString;
     42    class PropertySlot;
    4343
    44 struct ClassInfo;
    45 struct Instruction;
     44    struct ClassInfo;
     45    struct Instruction;
    4646
    47 class JSNumberCell : public JSCell {
    48     friend JSValue* jsNumberCell(ExecState*, double);
    49 public:
    50     double value() const { return val; }
     47    class JSNumberCell : public JSCell {
     48        friend JSValue* jsNumberCell(ExecState*, double);
     49    public:
     50        double value() const { return m_value; }
    5151
    52     virtual JSType type() const;
     52        virtual JSType type() const;
    5353
    54     virtual JSValue* toPrimitive(ExecState*, JSType preferred = UnspecifiedType) const;
    55     virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value);
    56     virtual bool toBoolean(ExecState*) const;
    57     virtual double toNumber(ExecState*) const;
    58     virtual UString toString(ExecState*) const;
    59     virtual JSObject* toObject(ExecState*) const;
     54        virtual JSValue* toPrimitive(ExecState*, JSType preferred = UnspecifiedType) const;
     55        virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value);
     56        virtual bool toBoolean(ExecState*) const;
     57        virtual double toNumber(ExecState*) const;
     58        virtual UString toString(ExecState*) const;
     59        virtual JSObject* toObject(ExecState*) const;
    6060
    61     virtual UString toThisString(ExecState*) const;
    62     virtual JSObject* toThisObject(ExecState*) const;
    63     virtual JSValue* getJSNumber();
     61        virtual UString toThisString(ExecState*) const;
     62        virtual JSObject* toThisObject(ExecState*) const;
     63        virtual JSValue* getJSNumber();
    6464
    65     void* operator new(size_t size, ExecState* exec)
     65        void* operator new(size_t size, ExecState* exec)
     66        {
     67    #ifdef JAVASCRIPTCORE_BUILDING_ALL_IN_ONE_FILE
     68            return exec->heap()->inlineAllocateNumber(size);
     69    #else
     70            return exec->heap()->allocateNumber(size);
     71    #endif
     72        }
     73
     74    private:
     75        JSNumberCell(double value)
     76            : m_value(value)
     77        {
     78        }
     79
     80        virtual bool getUInt32(uint32_t&) const;
     81        virtual bool getTruncatedInt32(int32_t&) const;
     82        virtual bool getTruncatedUInt32(uint32_t&) const;
     83
     84        double m_value;
     85    };
     86
     87    extern const double NaN;
     88    extern const double Inf;
     89
     90    // Beware marking this function ALWAYS_INLINE: It takes a PIC branch, so
     91    // inlining it may not always be a win.
     92    inline JSValue* jsNumberCell(ExecState* exec, double d)
    6693    {
    67 #ifdef JAVASCRIPTCORE_BUILDING_ALL_IN_ONE_FILE
    68         return exec->heap()->inlineAllocateNumber(size);
    69 #else
    70         return exec->heap()->allocateNumber(size);
    71 #endif
     94        return new (exec) JSNumberCell(d);
    7295    }
    7396
    74 private:
    75     JSNumberCell(double v)
    76         : val(v)
     97    inline JSValue* jsNaN(ExecState* exec)
    7798    {
     99        return jsNumberCell(exec, NaN);
    78100    }
    79101
    80     virtual bool getUInt32(uint32_t&) const;
    81     virtual bool getTruncatedInt32(int32_t&) const;
    82     virtual bool getTruncatedUInt32(uint32_t&) const;
     102    ALWAYS_INLINE JSValue* jsNumber(ExecState* exec, double d)
     103    {
     104        JSValue* v = JSImmediate::from(d);
     105        return v ? v : jsNumberCell(exec, d);
     106    }
    83107
    84     double val;
    85 };
     108    ALWAYS_INLINE JSValue* jsNumber(ExecState* exec, int i)
     109    {
     110        JSValue* v = JSImmediate::from(i);
     111        return v ? v : jsNumberCell(exec, i);
     112    }
    86113
    87 extern const double NaN;
    88 extern const double Inf;
     114    ALWAYS_INLINE JSValue* jsNumber(ExecState* exec, unsigned i)
     115    {
     116        JSValue* v = JSImmediate::from(i);
     117        return v ? v : jsNumberCell(exec, i);
     118    }
    89119
    90 // Beware marking this function ALWAYS_INLINE: It takes a PIC branch, so
    91 // inlining it may not always be a win.
    92 inline JSValue* jsNumberCell(ExecState* exec, double d)
    93 {
    94     return new (exec) JSNumberCell(d);
    95 }
     120    ALWAYS_INLINE JSValue* jsNumber(ExecState* exec, long i)
     121    {
     122        JSValue* v = JSImmediate::from(i);
     123        return v ? v : jsNumberCell(exec, i);
     124    }
    96125
    97 inline JSValue* jsNaN(ExecState* exec)
    98 {
    99     return jsNumberCell(exec, NaN);
    100 }
     126    ALWAYS_INLINE JSValue* jsNumber(ExecState* exec, unsigned long i)
     127    {
     128        JSValue* v = JSImmediate::from(i);
     129        return v ? v : jsNumberCell(exec, i);
     130    }
    101131
    102 ALWAYS_INLINE JSValue* jsNumber(ExecState* exec, double d)
    103 {
    104     JSValue* v = JSImmediate::from(d);
    105     return v ? v : jsNumberCell(exec, d);
    106 }
     132    ALWAYS_INLINE JSValue* jsNumber(ExecState* exec, long long i)
     133    {
     134        JSValue* v = JSImmediate::from(i);
     135        return v ? v : jsNumberCell(exec, static_cast<double>(i));
     136    }
    107137
    108 ALWAYS_INLINE JSValue* jsNumber(ExecState* exec, int i)
    109 {
    110     JSValue* v = JSImmediate::from(i);
    111     return v ? v : jsNumberCell(exec, i);
    112 }
     138    ALWAYS_INLINE JSValue* jsNumber(ExecState* exec, unsigned long long i)
     139    {
     140        JSValue* v = JSImmediate::from(i);
     141        return v ? v : jsNumberCell(exec, static_cast<double>(i));
     142    }
    113143
    114 ALWAYS_INLINE JSValue* jsNumber(ExecState* exec, unsigned i)
    115 {
    116     JSValue* v = JSImmediate::from(i);
    117     return v ? v : jsNumberCell(exec, i);
    118 }
     144    // --- JSValue inlines ----------------------------
    119145
    120 ALWAYS_INLINE JSValue* jsNumber(ExecState* exec, long i)
    121 {
    122     JSValue* v = JSImmediate::from(i);
    123     return v ? v : jsNumberCell(exec, i);
    124 }
     146    inline double JSValue::uncheckedGetNumber() const
     147    {
     148        ASSERT(JSImmediate::isImmediate(this) || asCell()->isNumber());
     149        return JSImmediate::isImmediate(this) ? JSImmediate::toDouble(this) : static_cast<const JSNumberCell*>(this)->value();
     150    }
    125151
    126 ALWAYS_INLINE JSValue* jsNumber(ExecState* exec, unsigned long i)
    127 {
    128     JSValue* v = JSImmediate::from(i);
    129     return v ? v : jsNumberCell(exec, i);
    130 }
    131 
    132 ALWAYS_INLINE JSValue* jsNumber(ExecState* exec, long long i)
    133 {
    134     JSValue* v = JSImmediate::from(i);
    135     return v ? v : jsNumberCell(exec, static_cast<double>(i));
    136 }
    137 
    138 ALWAYS_INLINE JSValue* jsNumber(ExecState* exec, unsigned long long i)
    139 {
    140     JSValue* v = JSImmediate::from(i);
    141     return v ? v : jsNumberCell(exec, static_cast<double>(i));
    142 }
    143 
    144 // --- JSValue inlines ----------------------------
    145 
    146 inline double JSValue::uncheckedGetNumber() const
    147 {
    148     ASSERT(JSImmediate::isImmediate(this) || asCell()->isNumber());
    149     return JSImmediate::isImmediate(this) ? JSImmediate::toDouble(this) : static_cast<const JSNumberCell*>(this)->value();
    150 }
    151 
    152 ALWAYS_INLINE JSValue* JSValue::toJSNumber(ExecState* exec) const
    153 {
    154     return JSImmediate::isNumber(this) ? const_cast<JSValue*>(this) : jsNumber(exec, this->toNumber(exec));
    155 }
    156 
    157 // -------
     152    ALWAYS_INLINE JSValue* JSValue::toJSNumber(ExecState* exec) const
     153    {
     154        return JSImmediate::isNumber(this) ? const_cast<JSValue*>(this) : jsNumber(exec, this->toNumber(exec));
     155    }
    158156
    159157} // namespace KJS
Note: See TracChangeset for help on using the changeset viewer.