summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/runtime/WeakMapConstructor.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2015-05-20 09:56:07 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2015-05-20 09:56:07 +0000
commit41386e9cb918eed93b3f13648cbef387e371e451 (patch)
treea97f9d7bd1d9d091833286085f72da9d83fd0606 /Source/JavaScriptCore/runtime/WeakMapConstructor.cpp
parente15dd966d523731101f70ccf768bba12435a0208 (diff)
downloadWebKitGtk-tarball-41386e9cb918eed93b3f13648cbef387e371e451.tar.gz
webkitgtk-2.4.9webkitgtk-2.4.9
Diffstat (limited to 'Source/JavaScriptCore/runtime/WeakMapConstructor.cpp')
-rw-r--r--Source/JavaScriptCore/runtime/WeakMapConstructor.cpp90
1 files changed, 5 insertions, 85 deletions
diff --git a/Source/JavaScriptCore/runtime/WeakMapConstructor.cpp b/Source/JavaScriptCore/runtime/WeakMapConstructor.cpp
index 23c43330d..f3540faaa 100644
--- a/Source/JavaScriptCore/runtime/WeakMapConstructor.cpp
+++ b/Source/JavaScriptCore/runtime/WeakMapConstructor.cpp
@@ -26,18 +26,15 @@
#include "config.h"
#include "WeakMapConstructor.h"
-#include "Error.h"
-#include "IteratorOperations.h"
#include "JSCJSValueInlines.h"
#include "JSCellInlines.h"
#include "JSGlobalObject.h"
#include "JSWeakMap.h"
-#include "StructureInlines.h"
#include "WeakMapPrototype.h"
namespace JSC {
-const ClassInfo WeakMapConstructor::s_info = { "Function", &Base::s_info, 0, CREATE_METHOD_TABLE(WeakMapConstructor) };
+const ClassInfo WeakMapConstructor::s_info = { "Function", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(WeakMapConstructor) };
void WeakMapConstructor::finishCreation(VM& vm, WeakMapPrototype* prototype)
{
@@ -46,87 +43,11 @@ void WeakMapConstructor::finishCreation(VM& vm, WeakMapPrototype* prototype)
putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum | DontDelete);
}
-static EncodedJSValue JSC_HOST_CALL callWeakMap(ExecState* exec)
-{
- return JSValue::encode(throwTypeError(exec, ASCIILiteral("WeakMap cannot be called as a function")));
-}
-
static EncodedJSValue JSC_HOST_CALL constructWeakMap(ExecState* exec)
{
JSGlobalObject* globalObject = asInternalFunction(exec->callee())->globalObject();
- Structure* weakMapStructure = globalObject->weakMapStructure();
- JSWeakMap* weakMap = JSWeakMap::create(exec, weakMapStructure);
- JSValue iterable = exec->argument(0);
- if (iterable.isUndefinedOrNull())
- return JSValue::encode(weakMap);
-
- JSValue adderFunction = weakMap->JSObject::get(exec, exec->propertyNames().set);
- if (exec->hadException())
- return JSValue::encode(jsUndefined());
-
- CallData adderFunctionCallData;
- CallType adderFunctionCallType = getCallData(adderFunction, adderFunctionCallData);
- if (adderFunctionCallType == CallTypeNone)
- return JSValue::encode(throwTypeError(exec));
-
- JSValue iteratorFunction = iterable.get(exec, exec->propertyNames().iteratorSymbol);
- if (exec->hadException())
- return JSValue::encode(jsUndefined());
-
- CallData iteratorFunctionCallData;
- CallType iteratorFunctionCallType = getCallData(iteratorFunction, iteratorFunctionCallData);
- if (iteratorFunctionCallType == CallTypeNone)
- return JSValue::encode(throwTypeError(exec));
-
- ArgList iteratorFunctionArguments;
- JSValue iterator = call(exec, iteratorFunction, iteratorFunctionCallType, iteratorFunctionCallData, iterable, iteratorFunctionArguments);
- if (exec->hadException())
- return JSValue::encode(jsUndefined());
-
- if (!iterator.isObject())
- return JSValue::encode(throwTypeError(exec));
-
- while (true) {
- JSValue next = iteratorStep(exec, iterator);
- if (exec->hadException())
- return JSValue::encode(jsUndefined());
-
- if (next.isFalse())
- return JSValue::encode(weakMap);
-
- JSValue nextItem = iteratorValue(exec, next);
- if (exec->hadException())
- return JSValue::encode(jsUndefined());
-
- if (!nextItem.isObject()) {
- throwTypeError(exec);
- iteratorClose(exec, iterator);
- return JSValue::encode(jsUndefined());
- }
-
- JSValue key = nextItem.get(exec, 0);
- if (exec->hadException()) {
- iteratorClose(exec, iterator);
- return JSValue::encode(jsUndefined());
- }
-
- JSValue value = nextItem.get(exec, 1);
- if (exec->hadException()) {
- iteratorClose(exec, iterator);
- return JSValue::encode(jsUndefined());
- }
-
- MarkedArgumentBuffer arguments;
- arguments.append(key);
- arguments.append(value);
- call(exec, adderFunction, adderFunctionCallType, adderFunctionCallData, weakMap, arguments);
- if (exec->hadException()) {
- iteratorClose(exec, iterator);
- return JSValue::encode(jsUndefined());
- }
- }
- RELEASE_ASSERT_NOT_REACHED();
- return JSValue::encode(weakMap);
+ Structure* structure = globalObject->weakMapStructure();
+ return JSValue::encode(JSWeakMap::create(exec, structure));
}
ConstructType WeakMapConstructor::getConstructData(JSCell*, ConstructData& constructData)
@@ -135,10 +56,9 @@ ConstructType WeakMapConstructor::getConstructData(JSCell*, ConstructData& const
return ConstructTypeHost;
}
-CallType WeakMapConstructor::getCallData(JSCell*, CallData& callData)
+CallType WeakMapConstructor::getCallData(JSCell*, CallData&)
{
- callData.native.function = callWeakMap;
- return CallTypeHost;
+ return CallTypeNone;
}
}