Commit 282b0a4e authored by weinig@apple.com's avatar weinig@apple.com

2008-06-27 Sam Weinig <sam@webkit.org>

        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:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@34843 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent c8f3a755
2008-06-27 Sam Weinig <sam@webkit.org>
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:
2008-06-27 Oliver Hunt <oliver@apple.com>
Reviewed by Sam.
......
......@@ -85,8 +85,11 @@ javascriptcore_sources += \
JavaScriptCore/kjs/Parser.cpp \
JavaScriptCore/kjs/PropertyNameArray.cpp \
JavaScriptCore/kjs/JSArray.cpp \
JavaScriptCore/kjs/ArrayConstructor.cpp \
JavaScriptCore/kjs/ArrayPrototype.cpp \
JavaScriptCore/kjs/BooleanConstructor.cpp \
JavaScriptCore/kjs/BooleanObject.cpp \
JavaScriptCore/kjs/BooleanPrototype.cpp \
JavaScriptCore/kjs/collector.cpp \
JavaScriptCore/kjs/date_object.cpp \
JavaScriptCore/kjs/debugger.cpp \
......
......@@ -67,8 +67,11 @@ SOURCES += \
kjs/JSFunction.cpp \
kjs/debugger.cpp \
kjs/JSArray.cpp \
kjs/ArrayConstructor.cpp \
kjs/ArrayPrototype.cpp \
kjs/BooleanConstructor.cpp \
kjs/BooleanObject.cpp \
kjs/BooleanPrototype.cpp \
kjs/collector.cpp \
kjs/CommonIdentifiers.cpp \
kjs/date_object.cpp \
......
......@@ -272,6 +272,14 @@
RelativePath="..\..\kjs\Activation.h"
>
</File>
<File
RelativePath="..\..\kjs\ArrayConstructor.cpp"
>
</File>
<File
RelativePath="..\..\kjs\ArrayConstructor.h"
>
</File>
<File
RelativePath="..\..\kjs\ArrayPrototype.cpp"
>
......@@ -280,6 +288,14 @@
RelativePath="..\..\kjs\ArrayPrototype.h"
>
</File>
<File
RelativePath="..\..\kjs\BooleanConstructor.cpp"
>
</File>
<File
RelativePath="..\..\kjs\BooleanConstructor.h"
>
</File>
<File
RelativePath="..\..\kjs\BooleanObject.cpp"
>
......@@ -288,6 +304,14 @@
RelativePath="..\..\kjs\BooleanObject.h"
>
</File>
<File
RelativePath="..\..\kjs\BooleanPrototype.cpp"
>
</File>
<File
RelativePath="..\..\kjs\BooleanPrototype.h"
>
</File>
<File
RelativePath="..\..\kjs\collector.cpp"
>
......
......@@ -224,6 +224,7 @@
A7C31DAA0DBEBA4300FDF8EB /* SegmentedVector.h in Headers */ = {isa = PBXBuildFile; fileRef = A7C31DA80DBEBA4300FDF8EB /* SegmentedVector.h */; };
A8E894320CD0602400367179 /* JSCallbackObjectFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = A8E894310CD0602400367179 /* JSCallbackObjectFunctions.h */; };
A8E894340CD0603F00367179 /* JSGlobalObject.h in Headers */ = {isa = PBXBuildFile; fileRef = A8E894330CD0603F00367179 /* JSGlobalObject.h */; settings = {ATTRIBUTES = (Private, ); }; };
BC7952090E15E8A800A898AB /* ArrayConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = BC7952070E15E8A800A898AB /* ArrayConstructor.h */; };
BC8F3CED0DAF1A8000577A80 /* ConstructData.h in Headers */ = {isa = PBXBuildFile; fileRef = BC8F3CCF0DAF17BA00577A80 /* ConstructData.h */; settings = {ATTRIBUTES = (Private, ); }; };
BCF655590A2049710038A194 /* MathExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = BCF6553B0A2048DE0038A194 /* MathExtras.h */; settings = {ATTRIBUTES = (Private, ); }; };
D212022B0AD4310D00ED79B6 /* DateMath.h in Headers */ = {isa = PBXBuildFile; fileRef = D21202290AD4310C00ED79B6 /* DateMath.h */; };
......@@ -583,6 +584,12 @@
A7C31DA80DBEBA4300FDF8EB /* SegmentedVector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SegmentedVector.h; path = VM/SegmentedVector.h; sourceTree = "<group>"; };
A8E894310CD0602400367179 /* JSCallbackObjectFunctions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCallbackObjectFunctions.h; sourceTree = "<group>"; };
A8E894330CD0603F00367179 /* JSGlobalObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSGlobalObject.h; sourceTree = "<group>"; };
BC7952060E15E8A800A898AB /* ArrayConstructor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ArrayConstructor.cpp; sourceTree = "<group>"; };
BC7952070E15E8A800A898AB /* ArrayConstructor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ArrayConstructor.h; sourceTree = "<group>"; };
BC7952320E15EB5600A898AB /* BooleanConstructor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BooleanConstructor.cpp; sourceTree = "<group>"; };
BC7952330E15EB5600A898AB /* BooleanConstructor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BooleanConstructor.h; sourceTree = "<group>"; };
BC7952340E15EB5600A898AB /* BooleanPrototype.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BooleanPrototype.cpp; sourceTree = "<group>"; };
BC7952350E15EB5600A898AB /* BooleanPrototype.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BooleanPrototype.h; sourceTree = "<group>"; };
BC8F3CCF0DAF17BA00577A80 /* ConstructData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConstructData.h; sourceTree = "<group>"; };
BCF6553B0A2048DE0038A194 /* MathExtras.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = MathExtras.h; sourceTree = "<group>"; };
D21202280AD4310C00ED79B6 /* DateMath.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = DateMath.cpp; sourceTree = "<group>"; };
......@@ -977,15 +984,17 @@
65417200039E01BA0058BFEB /* kjs */ = {
isa = PBXGroup;
children = (
65E866ED0DD59AFA00A2B2A1 /* SourceProvider.h */,
65E866EE0DD59AFA00A2B2A1 /* SourceRange.h */,
659126BC0BDD1728001921FB /* AllInOneFile.cpp */,
93ADFCE60CCBD7AC00D30B08 /* JSArray.cpp */,
938772E5038BFE19008635CE /* JSArray.h */,
BC7952060E15E8A800A898AB /* ArrayConstructor.cpp */,
BC7952070E15E8A800A898AB /* ArrayConstructor.h */,
F692A84D0255597D01FF60F7 /* ArrayPrototype.cpp */,
F692A84E0255597D01FF60F7 /* ArrayPrototype.h */,
BC7952320E15EB5600A898AB /* BooleanConstructor.cpp */,
BC7952330E15EB5600A898AB /* BooleanConstructor.h */,
F692A8500255597D01FF60F7 /* BooleanObject.cpp */,
704FD35305697E6D003DBED9 /* BooleanObject.h */,
BC7952340E15EB5600A898AB /* BooleanPrototype.cpp */,
BC7952350E15EB5600A898AB /* BooleanPrototype.h */,
145C507F0D9DF63B0088F6B9 /* CallData.h */,
F692A8520255597D01FF60F7 /* collector.cpp */,
F692A8530255597D01FF60F7 /* collector.h */,
......@@ -1007,8 +1016,6 @@
F692A85B0255597D01FF60F7 /* error_object.h */,
14BD53F40A3E12D800BAF59C /* ExecState.cpp */,
14BD53F30A3E12D800BAF59C /* ExecState.h */,
F692A85E0255597D01FF60F7 /* JSFunction.cpp */,
F692A85F0255597D01FF60F7 /* JSFunction.h */,
F692A85C0255597D01FF60F7 /* FunctionPrototype.cpp */,
F692A85D0255597D01FF60F7 /* FunctionPrototype.h */,
933A3499038AE7C6008635CE /* grammar.y */,
......@@ -1017,21 +1024,30 @@
E178636C0D9BEEC300D74E75 /* InitializeThreading.cpp */,
E178633F0D9BEC0000D74E75 /* InitializeThreading.h */,
F692A8610255597D01FF60F7 /* internal.cpp */,
F692A8620255597D01FF60F7 /* JSString.h */,
F692A8630255597D01FF60F7 /* interpreter.cpp */,
F692A8640255597D01FF60F7 /* interpreter.h */,
14DA818F0D99FD2000B0A4FB /* JSActivation.cpp */,
14DA818E0D99FD2000B0A4FB /* JSActivation.h */,
E18E3A560DF9278C00D90B34 /* JSGlobalData.h */,
93ADFCE60CCBD7AC00D30B08 /* JSArray.cpp */,
938772E5038BFE19008635CE /* JSArray.h */,
F692A85E0255597D01FF60F7 /* JSFunction.cpp */,
F692A85F0255597D01FF60F7 /* JSFunction.h */,
E18E3A570DF9278C00D90B34 /* JSGlobalData.cpp */,
E18E3A560DF9278C00D90B34 /* JSGlobalData.h */,
14DE0D680D02431400AACCA2 /* JSGlobalObject.cpp */,
A8E894330CD0603F00367179 /* JSGlobalObject.h */,
14760863099C633800437128 /* JSImmediate.cpp */,
1483B589099BC1950016E4F0 /* JSImmediate.h */,
65EA4C99092AF9E20093D800 /* JSLock.cpp */,
65EA4C9A092AF9E20093D800 /* JSLock.h */,
A72700780DAC605600E548D7 /* JSNotAnObject.cpp */,
A72700770DAC605600E548D7 /* JSNotAnObject.h */,
F692A8750255597D01FF60F7 /* JSObject.cpp */,
F692A8760255597D01FF60F7 /* JSObject.h */,
F692A8620255597D01FF60F7 /* JSString.h */,
14ABB454099C2A0F00E2A24F /* JSType.h */,
14F252600D08DF2F004ECFFF /* JSVariableObject.cpp */,
F692A8870255597D01FF60F7 /* JSValue.cpp */,
14ABB36E099C076400E2A24F /* JSValue.h */,
14F252600D08DF2F004ECFFF /* JSVariableObject.cpp */,
14F252560D08DD8D004ECFFF /* JSVariableObject.h */,
65C7A1710A8EAACB00FA37EA /* JSWrapperObject.cpp */,
......@@ -1066,15 +1082,14 @@
9374D3A8038D9D74008635CE /* ScopeChain.cpp */,
9374D3A7038D9D74008635CE /* ScopeChain.h */,
7E2C6C980D31C6B6002D44E2 /* ScopeChainMark.h */,
65E866ED0DD59AFA00A2B2A1 /* SourceProvider.h */,
65E866EE0DD59AFA00A2B2A1 /* SourceRange.h */,
F692A87F0255597D01FF60F7 /* string_object.cpp */,
F692A8800255597D01FF60F7 /* string_object.h */,
14A396A60CD2933100B5B4FF /* SymbolTable.h */,
F692A8850255597D01FF60F7 /* ustring.cpp */,
F692A8860255597D01FF60F7 /* ustring.h */,
F692A8870255597D01FF60F7 /* JSValue.cpp */,
14ABB36E099C076400E2A24F /* JSValue.h */,
A72700770DAC605600E548D7 /* JSNotAnObject.h */,
A72700780DAC605600E548D7 /* JSNotAnObject.cpp */,
14F252600D08DF2F004ECFFF /* JSVariableObject.cpp */,
);
path = kjs;
sourceTree = "<group>";
......@@ -1307,6 +1322,7 @@
A7C31DA90DBEBA4300FDF8EB /* SegmentedVector.h in Headers */,
1480DB9D0DDC227F003CFDF2 /* DebuggerCallFrame.h in Headers */,
E18E3A580DF9278C00D90B34 /* JSGlobalData.h in Headers */,
BC7952090E15E8A800A898AB /* ArrayConstructor.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
......@@ -44,8 +44,11 @@ Source files for JSCore.
<set append="1" var="JSCORE_SOURCES_KJS">
DerivedSources/JavaScriptCore/grammar.cpp
kjs/JSArray.cpp
kjs/ArrayConstructor.cpp
kjs/ArrayPrototype.cpp
kjs/BooleanConstructor.cpp
kjs/BooleanObject.cpp
kjs/BooleanPrototype.cpp
kjs/collector.cpp
kjs/CommonIdentifiers.cpp
kjs/date_object.cpp
......
......@@ -40,13 +40,12 @@
#include "Parser.h"
#include "Profiler.h"
#include "Register.h"
#include "ArrayPrototype.h"
#include "JSArray.h"
#include "debugger.h"
#include "JSFunction.h"
#include "JSString.h"
#include "object_object.h"
#include "operations.h"
#include "operations.h"
#include "RegExpObject.h"
#if HAVE(SYS_TIME_H)
......
......@@ -29,8 +29,11 @@
#include "JSFunction.cpp"
#include "debugger.cpp"
#include "JSArray.cpp"
#include "ArrayConstructor.cpp"
#include "ArrayPrototype.cpp"
#include "BooleanConstructor.cpp"
#include "BooleanObject.cpp"
#include "BooleanPrototype.cpp"
#include "collector.cpp"
#if PLATFORM(DARWIN)
#include "CollectorHeapIntrospector.cpp"
......
/*
* Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
* Copyright (C) 2003, 2007, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2003 Peter Kelly (pmk@post.com)
* Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*
*/
#include "config.h"
#include "ArrayConstructor.h"
#include "ArrayPrototype.h"
#include "JSArray.h"
#include "error_object.h"
#include "lookup.h"
namespace KJS {
ArrayConstructor::ArrayConstructor(ExecState* exec, FunctionPrototype* funcProto, ArrayPrototype* arrayProto)
: InternalFunction(funcProto, Identifier(exec, arrayProto->classInfo()->className))
{
// ECMA 15.4.3.1 Array.prototype
putDirect(exec->propertyNames().prototype, arrayProto, DontEnum|DontDelete|ReadOnly);
// no. of arguments for constructor
putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly | DontEnum | DontDelete);
}
static JSObject* constructArrayWithSizeQuirk(ExecState* exec, const ArgList& args)
{
// a single numeric argument denotes the array size (!)
if (args.size() == 1 && args[0]->isNumber()) {
uint32_t n = args[0]->toUInt32(exec);
if (n != args[0]->toNumber(exec))
return throwError(exec, RangeError, "Array size is not a small enough positive integer.");
return new (exec) JSArray(exec->lexicalGlobalObject()->arrayPrototype(), n);
}
// otherwise the array is constructed with the arguments in it
return new (exec) JSArray(exec->lexicalGlobalObject()->arrayPrototype(), args);
}
static JSObject* constructWithArrayConstructor(ExecState* exec, JSObject*, const ArgList& args)
{
return constructArrayWithSizeQuirk(exec, args);
}
// ECMA 15.4.2
ConstructType ArrayConstructor::getConstructData(ConstructData& constructData)
{
constructData.native.function = constructWithArrayConstructor;
return ConstructTypeNative;
}
static JSValue* callArrayConstructor(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
return constructArrayWithSizeQuirk(exec, args);
}
// ECMA 15.6.1
CallType ArrayConstructor::getCallData(CallData& callData)
{
// equivalent to 'new Array(....)'
callData.native.function = callArrayConstructor;
return CallTypeNative;
}
}
/*
* Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
* Copyright (C) 2007 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef ArrayConstructor_h
#define ArrayConstructor_h
#include "FunctionPrototype.h"
namespace KJS {
class ArrayPrototype;
class ArrayConstructor : public InternalFunction {
public:
ArrayConstructor(ExecState*, FunctionPrototype*, ArrayPrototype*);
virtual ConstructType getConstructData(ConstructData&);
virtual CallType getCallData(CallData&);
};
} // namespace KJS
#endif // ArrayConstructor_h
......@@ -28,7 +28,6 @@
#include "error_object.h"
#include "lookup.h"
#include "operations.h"
#include <stdio.h>
#include <wtf/Assertions.h>
#include <wtf/HashSet.h>
......@@ -776,55 +775,4 @@ JSValue* arrayProtoFuncLastIndexOf(ExecState* exec, JSObject*, JSValue* thisValu
return jsNumber(exec, -1);
}
// ------------------------------ ArrayConstructor -------------------------------
ArrayConstructor::ArrayConstructor(ExecState* exec, FunctionPrototype* funcProto, ArrayPrototype* arrayProto)
: InternalFunction(funcProto, Identifier(exec, arrayProto->classInfo()->className))
{
// ECMA 15.4.3.1 Array.prototype
putDirect(exec->propertyNames().prototype, arrayProto, DontEnum|DontDelete|ReadOnly);
// no. of arguments for constructor
putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly | DontEnum | DontDelete);
}
static JSObject* constructArrayWithSizeQuirk(ExecState* exec, const ArgList& args)
{
// a single numeric argument denotes the array size (!)
if (args.size() == 1 && args[0]->isNumber()) {
uint32_t n = args[0]->toUInt32(exec);
if (n != args[0]->toNumber(exec))
return throwError(exec, RangeError, "Array size is not a small enough positive integer.");
return new (exec) JSArray(exec->lexicalGlobalObject()->arrayPrototype(), n);
}
// otherwise the array is constructed with the arguments in it
return new (exec) JSArray(exec->lexicalGlobalObject()->arrayPrototype(), args);
}
static JSObject* constructWithArrayConstructor(ExecState* exec, JSObject*, const ArgList& args)
{
return constructArrayWithSizeQuirk(exec, args);
}
// ECMA 15.4.2
ConstructType ArrayConstructor::getConstructData(ConstructData& constructData)
{
constructData.native.function = constructWithArrayConstructor;
return ConstructTypeNative;
}
static JSValue* callArrayConstructor(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
return constructArrayWithSizeQuirk(exec, args);
}
// ECMA 15.6.1
CallType ArrayConstructor::getCallData(CallData& callData)
{
// equivalent to 'new Array(....)'
callData.native.function = callArrayConstructor;
return CallTypeNative;
}
}
......@@ -22,7 +22,6 @@
#define ArrayPrototype_h
#include "JSArray.h"
#include "FunctionPrototype.h"
#include "lookup.h"
namespace KJS {
......@@ -36,13 +35,6 @@ namespace KJS {
static const ClassInfo info;
};
class ArrayConstructor : public InternalFunction {
public:
ArrayConstructor(ExecState*, FunctionPrototype*, ArrayPrototype*);
virtual ConstructType getConstructData(ConstructData&);
virtual CallType getCallData(CallData&);
};
} // namespace KJS
#endif // ArrayPrototype_h
/*
* Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
* Copyright (C) 2003, 2008 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "config.h"
#include "BooleanConstructor.h"
#include "BooleanPrototype.h"
#include "JSGlobalObject.h"
namespace KJS {
BooleanConstructor::BooleanConstructor(ExecState* exec, FunctionPrototype* functionPrototype, BooleanPrototype* booleanPrototype)
: InternalFunction(functionPrototype, Identifier(exec, booleanPrototype->classInfo()->className))
{
putDirect(exec->propertyNames().prototype, booleanPrototype, DontEnum | DontDelete | ReadOnly);
// no. of arguments for constructor
putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly | DontDelete | DontEnum);
}
// ECMA 15.6.2
JSObject* constructBoolean(ExecState* exec, const ArgList& args)
{
BooleanObject* obj = new (exec) BooleanObject(exec->lexicalGlobalObject()->booleanPrototype());
obj->setInternalValue(jsBoolean(args[0]->toBoolean(exec)));
return obj;
}
static JSObject* constructWithBooleanConstructor(ExecState* exec, JSObject*, const ArgList& args)
{
return constructBoolean(exec, args);
}
ConstructType BooleanConstructor::getConstructData(ConstructData& constructData)
{
constructData.native.function = constructWithBooleanConstructor;
return ConstructTypeNative;
}
// ECMA 15.6.1
static JSValue* callBooleanConstructor(ExecState* exec, JSObject*, JSValue*, const ArgList& args)
{
return jsBoolean(args[0]->toBoolean(exec));
}
CallType BooleanConstructor::getCallData(CallData& callData)
{
callData.native.function = callBooleanConstructor;
return CallTypeNative;
}
JSObject* constructBooleanFromImmediateBoolean(ExecState* exec, JSValue* immediateBooleanValue)
{
BooleanObject* obj = new (exec) BooleanObject(exec->lexicalGlobalObject()->booleanPrototype());
obj->setInternalValue(immediateBooleanValue);
return obj;
}
} // namespace KJS
/*
* Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
* Copyright (C) 2008 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef BooleanConstructor_h
#define BooleanConstructor_h
#include "FunctionPrototype.h"
namespace KJS {
/**
* @internal
*
* The initial value of the the global variable's "Boolean" property
*/
class BooleanConstructor : public InternalFunction {
public:
BooleanConstructor(ExecState*, FunctionPrototype*, BooleanPrototype*);
private:
virtual ConstructType getConstructData(ConstructData&);
virtual CallType getCallData(CallData&);
};
JSObject* constructBooleanFromImmediateBoolean(ExecState*, JSValue*);
JSObject* constructBoolean(ExecState*, const ArgList&);
} // namespace KJS
#endif // BooleanConstructor_h
......@@ -21,15 +21,8 @@
#include "config.h"
#include "BooleanObject.h"
#include "JSGlobalObject.h"
#include "error_object.h"
#include "operations.h"
#include <wtf/Assertions.h>
namespace KJS {
// ------------------------------ BooleanObject ---------------------------
const ClassInfo BooleanObject::info = { "Boolean", 0, 0, 0 };
BooleanObject::BooleanObject(JSObject* proto)
......@@ -37,105 +30,4 @@ BooleanObject::BooleanObject(JSObject* proto)
{
}
// ------------------------------ BooleanPrototype --------------------------
// Functions
static JSValue* booleanProtoFuncToString(ExecState*, JSObject*, JSValue*, const ArgList&);
static JSValue* booleanProtoFuncValueOf(ExecState*, JSObject*, JSValue*, const ArgList&);
// ECMA 15.6.4
BooleanPrototype::BooleanPrototype(ExecState* exec, ObjectPrototype* objectPrototype, FunctionPrototype* functionPrototype)
: BooleanObject(objectPrototype)
{
setInternalValue(jsBoolean(false));
putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, booleanProtoFuncToString), DontEnum);
putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().valueOf, booleanProtoFuncValueOf), DontEnum);
}
// ------------------------------ Functions --------------------------
// ECMA 15.6.4.2 + 15.6.4.3
JSValue* booleanProtoFuncToString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
if (thisValue == jsBoolean(false))
return jsString(exec, "false");
if (thisValue == jsBoolean(true))
return jsString(exec, "true");
if (!thisValue->isObject(&BooleanObject::info))
return throwError(exec, TypeError);
if (static_cast<BooleanObject*>(thisValue)->internalValue() == jsBoolean(false))
return jsString(exec, "false");
ASSERT(static_cast<BooleanObject*>(thisValue)->internalValue() == jsBoolean(true));
return jsString(exec, "true");
}
JSValue* booleanProtoFuncValueOf(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
{
if (JSImmediate::isBoolean(thisValue))