Ignore:
Timestamp:
Jun 27, 2008, 9:29:48 PM (17 years ago)
Author:
[email protected]
Message:

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

Rubber-stamped by Oliver Hunt.

Splits ArrayConstructor out of ArrayPrototype.h/cpp
Splits BooleanConstructor and BooleanPrototype out of BooleanObject.h/cpp

  • GNUmakefile.am:
  • JavaScriptCore.pri:
  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • JavaScriptCoreSources.bkl:
  • VM/Machine.cpp:
  • kjs/AllInOneFile.cpp:
  • kjs/ArrayConstructor.cpp: Copied from kjs/ArrayPrototype.cpp.
  • kjs/ArrayConstructor.h: Copied from kjs/ArrayPrototype.h.
  • kjs/ArrayPrototype.cpp:
  • kjs/ArrayPrototype.h:
  • kjs/BooleanConstructor.cpp: Copied from kjs/BooleanObject.cpp.
  • kjs/BooleanConstructor.h: Copied from kjs/BooleanObject.h.
  • kjs/BooleanObject.cpp:
  • kjs/BooleanObject.h:
  • kjs/BooleanPrototype.cpp: Copied from kjs/BooleanObject.cpp.
  • kjs/BooleanPrototype.h: Copied from kjs/BooleanObject.h.
  • kjs/CommonIdentifiers.h:
  • kjs/FunctionPrototype.cpp:
  • kjs/JSArray.cpp:
  • kjs/JSGlobalObject.cpp:
  • kjs/JSImmediate.cpp:
  • kjs/Shell.cpp:
  • kjs/internal.cpp:
  • kjs/nodes.cpp:
  • kjs/string_object.cpp:
File:
1 edited

Legend:

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

    r34821 r34843  
    2222#include "BooleanObject.h"
    2323
    24 #include "JSGlobalObject.h"
    25 #include "error_object.h"
    26 #include "operations.h"
    27 #include <wtf/Assertions.h>
    28 
    2924namespace KJS {
    30 
    31 // ------------------------------ BooleanObject ---------------------------
    3225
    3326const ClassInfo BooleanObject::info = { "Boolean", 0, 0, 0 };
     
    3831}
    3932
    40 // ------------------------------ BooleanPrototype --------------------------
    41 
    42 // Functions
    43 static JSValue* booleanProtoFuncToString(ExecState*, JSObject*, JSValue*, const ArgList&);
    44 static JSValue* booleanProtoFuncValueOf(ExecState*, JSObject*, JSValue*, const ArgList&);
    45 
    46 // ECMA 15.6.4
    47 
    48 BooleanPrototype::BooleanPrototype(ExecState* exec, ObjectPrototype* objectPrototype, FunctionPrototype* functionPrototype)
    49     : BooleanObject(objectPrototype)
    50 {
    51     setInternalValue(jsBoolean(false));
    52 
    53     putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, booleanProtoFuncToString), DontEnum);
    54     putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().valueOf, booleanProtoFuncValueOf), DontEnum);
    55 }
    56 
    57 
    58 // ------------------------------ Functions --------------------------
    59 
    60 // ECMA 15.6.4.2 + 15.6.4.3
    61 
    62 JSValue* booleanProtoFuncToString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
    63 {
    64     if (thisValue == jsBoolean(false))
    65         return jsString(exec, "false");
    66 
    67     if (thisValue == jsBoolean(true))
    68         return jsString(exec, "true");
    69 
    70     if (!thisValue->isObject(&BooleanObject::info))
    71         return throwError(exec, TypeError);
    72 
    73     if (static_cast<BooleanObject*>(thisValue)->internalValue() == jsBoolean(false))
    74         return jsString(exec, "false");
    75 
    76     ASSERT(static_cast<BooleanObject*>(thisValue)->internalValue() == jsBoolean(true));
    77     return jsString(exec, "true");
    78 }
    79 
    80 JSValue* booleanProtoFuncValueOf(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
    81 {
    82     if (JSImmediate::isBoolean(thisValue))
    83         return thisValue;
    84 
    85     if (!thisValue->isObject(&BooleanObject::info))
    86         return throwError(exec, TypeError);
    87 
    88     return static_cast<BooleanObject*>(thisValue)->internalValue();
    89 }
    90 
    91 // ------------------------------ BooleanConstructor -----------------------------
    92 
    93 
    94 BooleanConstructor::BooleanConstructor(ExecState* exec, FunctionPrototype* functionPrototype, BooleanPrototype* booleanPrototype)
    95     : InternalFunction(functionPrototype, Identifier(exec, booleanPrototype->classInfo()->className))
    96 {
    97     putDirect(exec->propertyNames().prototype, booleanPrototype, DontEnum | DontDelete | ReadOnly);
    98 
    99     // no. of arguments for constructor
    100     putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly | DontDelete | DontEnum);
    101 }
    102 
    103 // ECMA 15.6.2
    104 JSObject* constructBoolean(ExecState* exec, const ArgList& args)
    105 {
    106     BooleanObject* obj = new (exec) BooleanObject(exec->lexicalGlobalObject()->booleanPrototype());
    107     obj->setInternalValue(jsBoolean(args[0]->toBoolean(exec)));
    108     return obj;
    109 }
    110 
    111 static JSObject* constructWithBooleanConstructor(ExecState* exec, JSObject*, const ArgList& args)
    112 {
    113     return constructBoolean(exec, args);
    114 }
    115 
    116 ConstructType BooleanConstructor::getConstructData(ConstructData& constructData)
    117 {
    118     constructData.native.function = constructWithBooleanConstructor;
    119     return ConstructTypeNative;
    120 }
    121 
    122 // ECMA 15.6.1
    123 static JSValue* callBooleanConstructor(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
    124 {
    125     return jsBoolean(args[0]->toBoolean(exec));
    126 }
    127 
    128 CallType BooleanConstructor::getCallData(CallData& callData)
    129 {
    130     callData.native.function = callBooleanConstructor;
    131     return CallTypeNative;
    132 }
    133 
    134 JSObject* constructBooleanFromImmediateBoolean(ExecState* exec, JSValue* immediateBooleanValue)
    135 {
    136     BooleanObject* obj = new (exec) BooleanObject(exec->lexicalGlobalObject()->booleanPrototype());
    137     obj->setInternalValue(immediateBooleanValue);
    138     return obj;
    139 }
    140 
    14133} // namespace KJS
Note: See TracChangeset for help on using the changeset viewer.