1/*
2 * Copyright (C) 2003-2019 Apple Inc. All rights reserved.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 *
19 */
20
21#pragma once
22
23#include "Identifier.h"
24#include <wtf/Noncopyable.h>
25
26// MarkedArgumentBuffer of property names, passed to a macro so we can do set them up various
27// ways without repeating the list.
28#define JSC_COMMON_IDENTIFIERS_EACH_PROPERTY_NAME(macro) \
29 macro(Array) \
30 macro(ArrayBuffer) \
31 macro(BYTES_PER_ELEMENT) \
32 macro(BigInt) \
33 macro(Boolean) \
34 macro(Collator) \
35 macro(Date) \
36 macro(DateTimeFormat) \
37 macro(Error) \
38 macro(EvalError) \
39 macro(Function) \
40 macro(Infinity) \
41 macro(Intl) \
42 macro(Loader) \
43 macro(Map) \
44 macro(NaN) \
45 macro(Number) \
46 macro(NumberFormat) \
47 macro(Object) \
48 macro(PluralRules) \
49 macro(Promise) \
50 macro(Reflect) \
51 macro(RegExp) \
52 macro(RemotePlayback) \
53 macro(Set) \
54 macro(SharedArrayBuffer) \
55 macro(String) \
56 macro(Symbol) \
57 macro(WeakRef) \
58 macro(__defineGetter__) \
59 macro(__defineSetter__) \
60 macro(__lookupGetter__) \
61 macro(__lookupSetter__) \
62 macro(add) \
63 macro(additionalJettisonReason) \
64 macro(anonymous) \
65 macro(arguments) \
66 macro(as) \
67 macro(async) \
68 macro(back) \
69 macro(bind) \
70 macro(byteLength) \
71 macro(byteOffset) \
72 macro(bytecode) \
73 macro(bytecodeIndex) \
74 macro(bytecodes) \
75 macro(bytecodesID) \
76 macro(calendar) \
77 macro(callee) \
78 macro(caller) \
79 macro(caseFirst) \
80 macro(clear) \
81 macro(collation) \
82 macro(column) \
83 macro(compilationKind) \
84 macro(compilationUID) \
85 macro(compilations) \
86 macro(compile) \
87 macro(configurable) \
88 macro(constructor) \
89 macro(count) \
90 macro(counters) \
91 macro(day) \
92 macro(defineProperty) \
93 macro(deref) \
94 macro(description) \
95 macro(descriptions) \
96 macro(detail) \
97 macro(displayName) \
98 macro(done) \
99 macro(dotAll) \
100 macro(enumerable) \
101 macro(era) \
102 macro(eval) \
103 macro(events) \
104 macro(exec) \
105 macro(executionCount) \
106 macro(exitKind) \
107 macro(flags) \
108 macro(forEach) \
109 macro(formatMatcher) \
110 macro(formatToParts) \
111 macro(forward) \
112 macro(from) \
113 macro(fromCharCode) \
114 macro(get) \
115 macro(global) \
116 macro(go) \
117 macro(groups) \
118 macro(has) \
119 macro(hasOwnProperty) \
120 macro(hash) \
121 macro(header) \
122 macro(hour) \
123 macro(hourCycle) \
124 macro(hour12) \
125 macro(id) \
126 macro(ignoreCase) \
127 macro(ignorePunctuation) \
128 macro(index) \
129 macro(inferredName) \
130 macro(input) \
131 macro(instructionCount) \
132 macro(isArray) \
133 macro(isEnabled) \
134 macro(isPrototypeOf) \
135 macro(isView) \
136 macro(isWatchpoint) \
137 macro(jettisonReason) \
138 macro(join) \
139 macro(lastIndex) \
140 macro(length) \
141 macro(line) \
142 macro(locale) \
143 macro(localeMatcher) \
144 macro(message) \
145 macro(minute) \
146 macro(month) \
147 macro(multiline) \
148 macro(name) \
149 macro(next) \
150 macro(now) \
151 macro(numInlinedCalls) \
152 macro(numInlinedGetByIds) \
153 macro(numInlinedPutByIds) \
154 macro(numberingSystem) \
155 macro(numeric) \
156 macro(of) \
157 macro(opcode) \
158 macro(origin) \
159 macro(osrExitSites) \
160 macro(osrExits) \
161 macro(parse) \
162 macro(parseInt) \
163 macro(parseFloat) \
164 macro(profiledBytecodes) \
165 macro(propertyIsEnumerable) \
166 macro(prototype) \
167 macro(raw) \
168 macro(replace) \
169 macro(resolve) \
170 macro(second) \
171 macro(sensitivity) \
172 macro(set) \
173 macro(size) \
174 macro(slice) \
175 macro(source) \
176 macro(sourceCode) \
177 macro(sourceURL) \
178 macro(stack) \
179 macro(stackTraceLimit) \
180 macro(sticky) \
181 macro(subarray) \
182 macro(summary) \
183 macro(target) \
184 macro(test) \
185 macro(then) \
186 macro(time) \
187 macro(timeZone) \
188 macro(timeZoneName) \
189 macro(toExponential) \
190 macro(toFixed) \
191 macro(toISOString) \
192 macro(toJSON) \
193 macro(toLocaleString) \
194 macro(toPrecision) \
195 macro(toString) \
196 macro(uid) \
197 macro(unicode) \
198 macro(usage) \
199 macro(value) \
200 macro(valueOf) \
201 macro(weekday) \
202 macro(writable) \
203 macro(year)
204
205#define JSC_COMMON_IDENTIFIERS_EACH_KEYWORD(macro) \
206 macro(await) \
207 macro(break) \
208 macro(case) \
209 macro(catch) \
210 macro(class) \
211 macro(const) \
212 macro(continue) \
213 macro(debugger) \
214 macro(default) \
215 macro(delete) \
216 macro(do) \
217 macro(else) \
218 macro(enum) \
219 macro(export) \
220 macro(extends) \
221 macro(false) \
222 macro(finally) \
223 macro(for) \
224 macro(function) \
225 macro(if) \
226 macro(implements) \
227 macro(import) \
228 macro(in) \
229 macro(instanceof) \
230 macro(interface) \
231 macro(let) \
232 macro(new) \
233 macro(null) \
234 macro(package) \
235 macro(private) \
236 macro(protected) \
237 macro(public) \
238 macro(return) \
239 macro(static) \
240 macro(super) \
241 macro(switch) \
242 macro(this) \
243 macro(throw) \
244 macro(true) \
245 macro(try) \
246 macro(typeof) \
247 macro(undefined) \
248 macro(var) \
249 macro(void) \
250 macro(while) \
251 macro(with) \
252 macro(yield)
253
254#define JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_WELL_KNOWN_SYMBOL(macro) \
255 macro(hasInstance) \
256 macro(isConcatSpreadable) \
257 macro(asyncIterator) \
258 macro(iterator) \
259 macro(match) \
260 macro(matchAll) \
261 macro(replace) \
262 macro(search) \
263 macro(species) \
264 macro(split) \
265 macro(toPrimitive) \
266 macro(toStringTag) \
267 macro(unscopables)
268
269#define JSC_PARSER_PRIVATE_NAMES(macro) \
270 macro(generator) \
271 macro(generatorState) \
272 macro(generatorValue) \
273 macro(generatorResumeMode) \
274 macro(generatorFrame) \
275 macro(meta) \
276 macro(starDefault) \
277 macro(undefined) \
278
279namespace JSC {
280
281 class BuiltinNames;
282
283 class CommonIdentifiers {
284 WTF_MAKE_NONCOPYABLE(CommonIdentifiers); WTF_MAKE_FAST_ALLOCATED;
285 private:
286 CommonIdentifiers(VM&);
287 ~CommonIdentifiers();
288 friend class VM;
289
290 public:
291 const BuiltinNames& builtinNames() const { return *m_builtinNames; }
292 const Identifier nullIdentifier;
293 const Identifier emptyIdentifier;
294 const Identifier underscoreProto;
295 const Identifier thisIdentifier;
296 const Identifier useStrictIdentifier;
297 const Identifier timesIdentifier;
298 private:
299 std::unique_ptr<BuiltinNames> m_builtinNames;
300
301 public:
302
303#define JSC_IDENTIFIER_DECLARE_PARSER_PRIVATE_NAME(name) const Identifier name##PrivateName;
304 JSC_PARSER_PRIVATE_NAMES(JSC_IDENTIFIER_DECLARE_PARSER_PRIVATE_NAME)
305#undef JSC_IDENTIFIER_DECLARE_PARSER_PRIVATE_NAME
306
307#define JSC_IDENTIFIER_DECLARE_KEYWORD_NAME_GLOBAL(name) const Identifier name##Keyword;
308 JSC_COMMON_IDENTIFIERS_EACH_KEYWORD(JSC_IDENTIFIER_DECLARE_KEYWORD_NAME_GLOBAL)
309#undef JSC_IDENTIFIER_DECLARE_KEYWORD_NAME_GLOBAL
310
311#define JSC_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL(name) const Identifier name;
312 JSC_COMMON_IDENTIFIERS_EACH_PROPERTY_NAME(JSC_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL)
313#undef JSC_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL
314
315#define JSC_IDENTIFIER_DECLARE_PRIVATE_WELL_KNOWN_SYMBOL_GLOBAL(name) const Identifier name##Symbol;
316 JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_WELL_KNOWN_SYMBOL(JSC_IDENTIFIER_DECLARE_PRIVATE_WELL_KNOWN_SYMBOL_GLOBAL)
317#undef JSC_IDENTIFIER_DECLARE_PRIVATE_WELL_KNOWN_SYMBOL_GLOBAL
318
319 SymbolImpl* lookUpPrivateName(const Identifier&) const;
320 Identifier getPublicName(VM&, SymbolImpl*) const;
321
322 // Callers of this method should make sure that identifiers given to this method
323 // survive the lifetime of CommonIdentifiers and related VM.
324 JS_EXPORT_PRIVATE void appendExternalName(const Identifier& publicName, const Identifier& privateName);
325 };
326
327} // namespace JSC
328