blob: e356a7af7734f4b05083841e1462722c7200b987 [file] [log] [blame]
oliver@apple.comb8d80ed2013-08-30 22:55:25 +00001/*
sbarati@apple.com21fc86e2016-09-06 23:22:01 +00002 * Copyright (C) 2013, 2016 Apple Inc. All rights reserved.
oliver@apple.comb8d80ed2013-08-30 22:55:25 +00003 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
ryanhaddad@apple.com22104f52016-09-28 17:08:17 +000026#pragma once
oliver@apple.comb8d80ed2013-08-30 22:55:25 +000027
28#include "JSObject.h"
sbarati@apple.com21fc86e2016-09-06 23:22:01 +000029#include "MapBase.h"
oliver@apple.comb8d80ed2013-08-30 22:55:25 +000030
31namespace JSC {
32
ggaren@apple.com2a514ce2015-03-25 00:19:05 +000033class JSSetIterator;
34
sbarati@apple.com21fc86e2016-09-06 23:22:01 +000035class JSSet : public MapBase<HashMapBucket<HashMapBucketDataKey>> {
36 typedef MapBase<HashMapBucket<HashMapBucketDataKey>> Base;
oliver@apple.comb8d80ed2013-08-30 22:55:25 +000037public:
utatane.tea@gmail.comca625002015-03-12 22:57:13 +000038
ggaren@apple.com2a514ce2015-03-25 00:19:05 +000039 friend class JSSetIterator;
40
oliver@apple.com901740c2013-09-03 23:21:10 +000041 DECLARE_EXPORT_INFO;
oliver@apple.comb8d80ed2013-08-30 22:55:25 +000042
43 static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
44 {
sbarati@apple.com21fc86e2016-09-06 23:22:01 +000045 return Structure::create(vm, globalObject, prototype, TypeInfo(JSSetType, StructureFlags), info());
oliver@apple.comb8d80ed2013-08-30 22:55:25 +000046 }
47
sbarati@apple.com21fc86e2016-09-06 23:22:01 +000048 static JSSet* create(ExecState* exec, VM& vm, Structure* structure)
oliver@apple.comb8d80ed2013-08-30 22:55:25 +000049 {
50 JSSet* instance = new (NotNull, allocateCell<JSSet>(vm.heap)) JSSet(vm, structure);
sbarati@apple.com21fc86e2016-09-06 23:22:01 +000051 instance->finishCreation(exec, vm);
oliver@apple.comb8d80ed2013-08-30 22:55:25 +000052 return instance;
53 }
54
sbarati@apple.com21fc86e2016-09-06 23:22:01 +000055 ALWAYS_INLINE void add(ExecState* exec, JSValue key)
oliver@apple.comb8d80ed2013-08-30 22:55:25 +000056 {
sbarati@apple.com21fc86e2016-09-06 23:22:01 +000057 m_map->add(exec, key);
oliver@apple.comb8d80ed2013-08-30 22:55:25 +000058 }
59
oliver@apple.comb8d80ed2013-08-30 22:55:25 +000060private:
oliver@apple.comb8d80ed2013-08-30 22:55:25 +000061 JSSet(VM& vm, Structure* structure)
62 : Base(vm, structure)
63 {
64 }
65
keith_miller@apple.com398a66a2016-08-29 18:50:44 +000066 static String toStringName(const JSObject*, ExecState*);
oliver@apple.comb8d80ed2013-08-30 22:55:25 +000067};
68
ryanhaddad@apple.com22104f52016-09-28 17:08:17 +000069} // namespace JSC