#pragma once
#include "HashMapImpl.h"
#include "JSObject.h"
namespace JSC {
class JSMapIterator;
class JSMap final : public HashMapImpl<HashMapBucket<HashMapBucketDataKeyValue>> {
using Base = HashMapImpl<HashMapBucket<HashMapBucketDataKeyValue>>;
public:
friend class JSMapIterator;
DECLARE_EXPORT_INFO;
static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
{
return Structure::create(vm, globalObject, prototype, TypeInfo(JSMapType, StructureFlags), info());
}
static JSMap* create(ExecState* exec, VM& vm, Structure* structure)
{
JSMap* instance = new (NotNull, allocateCell<JSMap>(vm.heap)) JSMap(vm, structure);
instance->finishCreation(exec, vm);
return instance;
}
ALWAYS_INLINE void set(ExecState* exec, JSValue key, JSValue value)
{
add(exec, key, value);
}
bool isIteratorProtocolFastAndNonObservable();
bool canCloneFastAndNonObservable(Structure*);
JSMap* clone(ExecState*, VM&, Structure*);
private:
JSMap(VM& vm, Structure* structure)
: Base(vm, structure)
{
}
static String toStringName(const JSObject*, ExecState*);
};
inline bool isJSMap(JSCell* from)
{
static_assert(std::is_final<JSMap>::value, "");
return from->type() == JSMapType;
}
inline bool isJSMap(JSValue from)
{
static_assert(std::is_final<JSMap>::value, "");
return from.isCell() && from.asCell()->type() == JSMapType;
}
}