Ignore:
Timestamp:
Jun 30, 2008, 1:52:03 PM (17 years ago)
Author:
[email protected]
Message:

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

Rubber-stamped by Darin Adler.

Remove internal.cpp and move its contents to there own .cpp files.

  • GNUmakefile.am:
  • JavaScriptCore.pri:
  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • JavaScriptCoreSources.bkl:
  • kjs/AllInOneFile.cpp:
  • kjs/GetterSetter.cpp: Copied from kjs/internal.cpp.
  • kjs/InternalFunction.cpp: Copied from kjs/internal.cpp.
  • kjs/JSNumberCell.cpp: Copied from kjs/internal.cpp.
  • kjs/JSString.cpp: Copied from kjs/internal.cpp.
  • kjs/JSString.h:
  • kjs/LabelStack.cpp: Copied from kjs/internal.cpp.
  • kjs/NumberConstructor.cpp:
  • kjs/NumberObject.cpp: (KJS::constructNumber): (KJS::constructNumberFromImmediateNumber):
  • kjs/internal.cpp: Removed.
File:
1 copied

Legend:

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

    r34892 r34893  
    2222
    2323#include "config.h"
    24 #include "JSString.h"
     24#include "JSFunction.h"
    2525
    26 #include "ExecState.h"
    2726#include "FunctionPrototype.h"
    28 #include "JSObject.h"
    29 #include "MathObject.h"
    30 #include "NumberObject.h"
    31 #include "StringPrototype.h"
    32 #include "collector.h"
    33 #include "debugger.h"
    34 #include "lexer.h"
    35 #include "nodes.h"
    36 #include "operations.h"
    37 #include <math.h>
    38 #include <stdio.h>
    39 #include <wtf/Assertions.h>
    40 #include <wtf/HashMap.h>
    41 #include <wtf/HashSet.h>
    42 #include <wtf/Vector.h>
    4327
    4428namespace KJS {
    45 
    46 // ------------------------------ JSString ------------------------------------
    47 
    48 JSValue* JSString::toPrimitive(ExecState*, JSType) const
    49 {
    50   return const_cast<JSString*>(this);
    51 }
    52 
    53 bool JSString::getPrimitiveNumber(ExecState*, double& number, JSValue*& value)
    54 {
    55     value = this;
    56     number = m_value.toDouble();
    57     return false;
    58 }
    59 
    60 bool JSString::toBoolean(ExecState*) const
    61 {
    62     return !m_value.isEmpty();
    63 }
    64 
    65 double JSString::toNumber(ExecState*) const
    66 {
    67     return m_value.toDouble();
    68 }
    69 
    70 UString JSString::toString(ExecState*) const
    71 {
    72     return m_value;
    73 }
    74 
    75 UString JSString::toThisString(ExecState*) const
    76 {
    77     return m_value;
    78 }
    79 
    80 JSString* JSString::toThisJSString(ExecState*)
    81 {
    82     return this;
    83 }
    84 
    85 inline StringObject* StringObject::create(ExecState* exec, JSString* string)
    86 {
    87     return new (exec) StringObject(exec->lexicalGlobalObject()->stringPrototype(), string);
    88 }
    89 
    90 JSObject* JSString::toObject(ExecState* exec) const
    91 {
    92     return StringObject::create(exec, const_cast<JSString*>(this));
    93 }
    94 
    95 JSObject* JSString::toThisObject(ExecState* exec) const
    96 {
    97     return StringObject::create(exec, const_cast<JSString*>(this));
    98 }
    99 
    100 JSValue* JSString::lengthGetter(ExecState* exec, const Identifier&, const PropertySlot& slot)
    101 {
    102     return jsNumber(exec, static_cast<JSString*>(slot.slotBase())->value().size());
    103 }
    104 
    105 JSValue* JSString::indexGetter(ExecState* exec, const Identifier&, const PropertySlot& slot)
    106 {
    107     return jsString(exec, static_cast<JSString*>(slot.slotBase())->value().substr(slot.index(), 1));
    108 }
    109 
    110 JSValue* JSString::indexNumericPropertyGetter(ExecState* exec, unsigned index, const PropertySlot& slot)
    111 {
    112     return jsString(exec, static_cast<JSString*>(slot.slotBase())->value().substr(index, 1));
    113 }
    114 
    115 bool JSString::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
    116 {
    117     // The semantics here are really getPropertySlot, not getOwnPropertySlot.
    118     // This function should only be called by JSValue::get.
    119     if (getStringPropertySlot(exec, propertyName, slot))
    120         return true;
    121     slot.setBase(this);
    122     JSObject* object;
    123     for (JSValue* prototype = exec->lexicalGlobalObject()->stringPrototype(); prototype != jsNull(); prototype = object->prototype()) {
    124         ASSERT(prototype->isObject());
    125         object = static_cast<JSObject*>(prototype);
    126         if (object->getOwnPropertySlot(exec, propertyName, slot))
    127             return true;
    128     }
    129     slot.setUndefined();
    130     return true;
    131 }
    132 
    133 bool JSString::getOwnPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot)
    134 {
    135     // The semantics here are really getPropertySlot, not getOwnPropertySlot.
    136     // This function should only be called by JSValue::get.
    137     if (getStringPropertySlot(propertyName, slot))
    138         return true;
    139     return JSString::getOwnPropertySlot(exec, Identifier::from(exec, propertyName), slot);
    140 }
    141 
    142 // ------------------------------ JSNumberCell ------------------------------------
    143 
    144 JSType JSNumberCell::type() const
    145 {
    146     return NumberType;
    147 }
    148 
    149 JSValue* JSNumberCell::toPrimitive(ExecState*, JSType) const
    150 {
    151     return const_cast<JSNumberCell*>(this);
    152 }
    153 
    154 bool JSNumberCell::getPrimitiveNumber(ExecState*, double& number, JSValue*& value)
    155 {
    156     number = val;
    157     value = this;
    158     return true;
    159 }
    160 
    161 bool JSNumberCell::toBoolean(ExecState *) const
    162 {
    163   return val < 0.0 || val > 0.0; // false for NaN
    164 }
    165 
    166 double JSNumberCell::toNumber(ExecState *) const
    167 {
    168   return val;
    169 }
    170 
    171 UString JSNumberCell::toString(ExecState*) const
    172 {
    173     if (val == 0.0) // +0.0 or -0.0
    174         return "0";
    175     return UString::from(val);
    176 }
    177 
    178 UString JSNumberCell::toThisString(ExecState*) const
    179 {
    180     if (val == 0.0) // +0.0 or -0.0
    181         return "0";
    182     return UString::from(val);
    183 }
    184 
    185 JSObject* JSNumberCell::toObject(ExecState* exec) const
    186 {
    187     return constructNumber(exec, const_cast<JSNumberCell*>(this));
    188 }
    189 
    190 JSObject* JSNumberCell::toThisObject(ExecState* exec) const
    191 {
    192     return constructNumber(exec, const_cast<JSNumberCell*>(this));
    193 }
    194 
    195 bool JSNumberCell::getUInt32(uint32_t& uint32) const
    196 {
    197     uint32 = static_cast<uint32_t>(val);
    198     return uint32 == val;
    199 }
    200 
    201 bool JSNumberCell::getTruncatedInt32(int32_t& int32) const
    202 {
    203     if (!(val >= -2147483648.0 && val < 2147483648.0))
    204         return false;
    205     int32 = static_cast<int32_t>(val);
    206     return true;
    207 }
    208 
    209 bool JSNumberCell::getTruncatedUInt32(uint32_t& uint32) const
    210 {
    211     if (!(val >= 0.0 && val < 4294967296.0))
    212         return false;
    213     uint32 = static_cast<uint32_t>(val);
    214     return true;
    215 }
    216 
    217 JSValue* JSNumberCell::getJSNumber()
    218 {
    219     return this;
    220 }
    221 
    222 // --------------------------- GetterSetter ---------------------------------
    223 
    224 void GetterSetter::mark()
    225 {
    226     JSCell::mark();
    227 
    228     if (m_getter && !m_getter->marked())
    229         m_getter->mark();
    230     if (m_setter && !m_setter->marked())
    231         m_setter->mark();
    232 }
    233 
    234 JSValue* GetterSetter::toPrimitive(ExecState*, JSType) const
    235 {
    236     ASSERT_NOT_REACHED();
    237     return jsNull();
    238 }
    239 
    240 bool GetterSetter::getPrimitiveNumber(ExecState*, double& number, JSValue*& value)
    241 {
    242     ASSERT_NOT_REACHED();
    243     number = 0;
    244     value = 0;
    245     return true;
    246 }
    247 
    248 bool GetterSetter::toBoolean(ExecState*) const
    249 {
    250     ASSERT_NOT_REACHED();
    251     return false;
    252 }
    253 
    254 double GetterSetter::toNumber(ExecState*) const
    255 {
    256     ASSERT_NOT_REACHED();
    257     return 0.0;
    258 }
    259 
    260 UString GetterSetter::toString(ExecState*) const
    261 {
    262     ASSERT_NOT_REACHED();
    263     return UString::null();
    264 }
    265 
    266 JSObject* GetterSetter::toObject(ExecState* exec) const
    267 {
    268     ASSERT_NOT_REACHED();
    269     return jsNull()->toObject(exec);
    270 }
    271 
    272 // ------------------------------ LabelStack -----------------------------------
    273 
    274 bool LabelStack::push(const Identifier &id)
    275 {
    276   if (contains(id))
    277     return false;
    278 
    279   StackElem *newtos = new StackElem;
    280   newtos->id = id;
    281   newtos->prev = tos;
    282   tos = newtos;
    283   return true;
    284 }
    285 
    286 bool LabelStack::contains(const Identifier &id) const
    287 {
    288   if (id.isEmpty())
    289     return true;
    290 
    291   for (StackElem *curr = tos; curr; curr = curr->prev)
    292     if (curr->id == id)
    293       return true;
    294 
    295   return false;
    296 }
    297 
    298 // ------------------------------ InternalFunction --------------------------
    29929
    30030const ClassInfo InternalFunction::info = { "Function", 0, 0, 0 };
     
    31545}
    31646
    317 }
     47} // namespace KJS
Note: See TracChangeset for help on using the changeset viewer.