summaryrefslogtreecommitdiffstats
path: root/JavaScriptCore/runtime/ArrayConstructor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'JavaScriptCore/runtime/ArrayConstructor.cpp')
-rw-r--r--JavaScriptCore/runtime/ArrayConstructor.cpp29
1 files changed, 16 insertions, 13 deletions
diff --git a/JavaScriptCore/runtime/ArrayConstructor.cpp b/JavaScriptCore/runtime/ArrayConstructor.cpp
index fb44494..632d466 100644
--- a/JavaScriptCore/runtime/ArrayConstructor.cpp
+++ b/JavaScriptCore/runtime/ArrayConstructor.cpp
@@ -26,6 +26,7 @@
#include "ArrayPrototype.h"
#include "Error.h"
+#include "ExceptionHelpers.h"
#include "JSArray.h"
#include "JSFunction.h"
#include "Lookup.h"
@@ -35,19 +36,19 @@ namespace JSC {
ASSERT_CLASS_FITS_IN_CELL(ArrayConstructor);
-static JSValue JSC_HOST_CALL arrayConstructorIsArray(ExecState*, JSObject*, JSValue, const ArgList&);
+static EncodedJSValue JSC_HOST_CALL arrayConstructorIsArray(ExecState*);
-ArrayConstructor::ArrayConstructor(ExecState* exec, NonNullPassRefPtr<Structure> structure, ArrayPrototype* arrayPrototype, Structure* prototypeFunctionStructure)
- : InternalFunction(&exec->globalData(), structure, Identifier(exec, arrayPrototype->classInfo()->className))
+ArrayConstructor::ArrayConstructor(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, ArrayPrototype* arrayPrototype, Structure* prototypeFunctionStructure)
+ : InternalFunction(&exec->globalData(), globalObject, structure, Identifier(exec, arrayPrototype->classInfo()->className))
{
// ECMA 15.4.3.1 Array.prototype
putDirectWithoutTransition(exec->propertyNames().prototype, arrayPrototype, DontEnum | DontDelete | ReadOnly);
// no. of arguments for constructor
- putDirectWithoutTransition(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly | DontEnum | DontDelete);
+ putDirectWithoutTransition(exec->propertyNames().length, jsNumber(1), ReadOnly | DontEnum | DontDelete);
// ES5
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().isArray, arrayConstructorIsArray), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 1, exec->propertyNames().isArray, arrayConstructorIsArray), DontEnum);
}
static inline JSObject* constructArrayWithSizeQuirk(ExecState* exec, const ArgList& args)
@@ -56,17 +57,18 @@ static inline JSObject* constructArrayWithSizeQuirk(ExecState* exec, const ArgLi
if (args.size() == 1 && args.at(0).isNumber()) {
uint32_t n = args.at(0).toUInt32(exec);
if (n != args.at(0).toNumber(exec))
- return throwError(exec, RangeError, "Array size is not a small enough positive integer.");
- return new (exec) JSArray(exec->lexicalGlobalObject()->arrayStructure(), n);
+ return throwError(exec, createRangeError(exec, "Array size is not a small enough positive integer."));
+ return new (exec) JSArray(exec->lexicalGlobalObject()->arrayStructure(), n, CreateInitialized);
}
// otherwise the array is constructed with the arguments in it
return new (exec) JSArray(exec->lexicalGlobalObject()->arrayStructure(), args);
}
-static JSObject* constructWithArrayConstructor(ExecState* exec, JSObject*, const ArgList& args)
+static EncodedJSValue JSC_HOST_CALL constructWithArrayConstructor(ExecState* exec)
{
- return constructArrayWithSizeQuirk(exec, args);
+ ArgList args(exec);
+ return JSValue::encode(constructArrayWithSizeQuirk(exec, args));
}
// ECMA 15.4.2
@@ -76,9 +78,10 @@ ConstructType ArrayConstructor::getConstructData(ConstructData& constructData)
return ConstructTypeHost;
}
-static JSValue JSC_HOST_CALL callArrayConstructor(ExecState* exec, JSObject*, JSValue, const ArgList& args)
+static EncodedJSValue JSC_HOST_CALL callArrayConstructor(ExecState* exec)
{
- return constructArrayWithSizeQuirk(exec, args);
+ ArgList args(exec);
+ return JSValue::encode(constructArrayWithSizeQuirk(exec, args));
}
// ECMA 15.6.1
@@ -89,9 +92,9 @@ CallType ArrayConstructor::getCallData(CallData& callData)
return CallTypeHost;
}
-JSValue JSC_HOST_CALL arrayConstructorIsArray(ExecState*, JSObject*, JSValue, const ArgList& args)
+EncodedJSValue JSC_HOST_CALL arrayConstructorIsArray(ExecState* exec)
{
- return jsBoolean(args.at(0).inherits(&JSArray::info));
+ return JSValue::encode(jsBoolean(exec->argument(0).inherits(&JSArray::info)));
}
} // namespace JSC