#include "config.h"
#include "JSMap.h"
#include "JSCInlines.h"
#include "MapPrototype.h"
namespace JSC {
const ClassInfo JSMap::s_info = { "Map", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMap) };
String JSMap::toStringName(const JSObject*, JSGlobalObject*)
{
return "Object"_s;
}
JSMap* JSMap::clone(JSGlobalObject* globalObject, VM& vm, Structure* structure)
{
JSMap* instance = new (NotNull, allocateCell<JSMap>(vm.heap)) JSMap(vm, structure);
instance->finishCreation(globalObject, vm, this);
return instance;
}
bool JSMap::isIteratorProtocolFastAndNonObservable()
{
JSGlobalObject* globalObject = this->globalObject();
if (!globalObject->isMapPrototypeIteratorProtocolFastAndNonObservable())
return false;
VM& vm = globalObject->vm();
Structure* structure = this->structure(vm);
if (structure == globalObject->mapStructure())
return true;
if (getPrototypeDirect(vm) != globalObject->mapPrototype())
return false;
if (getDirectOffset(vm, vm.propertyNames->iteratorSymbol) != invalidOffset)
return false;
return true;
}
bool JSMap::canCloneFastAndNonObservable(Structure* structure)
{
auto setFastAndNonObservable = [&] (Structure* structure) {
JSGlobalObject* globalObject = structure->globalObject();
if (!globalObject->isMapPrototypeSetFastAndNonObservable())
return false;
if (structure->hasPolyProto())
return false;
if (structure->storedPrototype() != globalObject->mapPrototype())
return false;
return true;
};
return isIteratorProtocolFastAndNonObservable() && setFastAndNonObservable(structure);
}
}