1/*
2 * Copyright (C) 2003-2017 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(Set) \
53 macro(SharedArrayBuffer) \
54 macro(String) \
55 macro(Symbol) \
56 macro(__defineGetter__) \
57 macro(__defineSetter__) \
58 macro(__lookupGetter__) \
59 macro(__lookupSetter__) \
60 macro(add) \
61 macro(additionalJettisonReason) \
62 macro(anonymous) \
63 macro(arguments) \
64 macro(as) \
65 macro(async) \
66 macro(back) \
67 macro(bind) \
68 macro(byteLength) \
69 macro(byteOffset) \
70 macro(bytecode) \
71 macro(bytecodeIndex) \
72 macro(bytecodes) \
73 macro(bytecodesID) \
74 macro(calendar) \
75 macro(callee) \
76 macro(caller) \
77 macro(caseFirst) \
78 macro(clear) \
79 macro(collation) \
80 macro(column) \
81 macro(compilationKind) \
82 macro(compilationUID) \
83 macro(compilations) \
84 macro(compile) \
85 macro(configurable) \
86 macro(constructor) \
87 macro(count) \
88 macro(counters) \
89 macro(day) \
90 macro(defineProperty) \
91 macro(deref) \
92 macro(description) \
93 macro(descriptions) \
94 macro(detail) \
95 macro(displayName) \
96 macro(done) \
97 macro(dotAll) \
98 macro(enumerable) \
99 macro(era) \
100 macro(eval) \
101 macro(events) \
102 macro(exec) \
103 macro(executionCount) \
104 macro(exitKind) \
105 macro(flags) \
106 macro(forEach) \
107 macro(formatMatcher) \
108 macro(formatToParts) \
109 macro(forward) \
110 macro(from) \
111 macro(fromCharCode) \
112 macro(get) \
113 macro(global) \
114 macro(go) \
115 macro(groups) \
116 macro(has) \
117 macro(hasOwnProperty) \
118 macro(hash) \
119 macro(header) \
120 macro(hour) \
121 macro(hourCycle) \
122 macro(hour12) \
123 macro(id) \
124 macro(ignoreCase) \
125 macro(ignorePunctuation) \
126 macro(index) \
127 macro(inferredName) \
128 macro(input) \
129 macro(instructionCount) \
130 macro(isArray) \
131 macro(isEnabled) \
132 macro(isPrototypeOf) \
133 macro(isView) \
134 macro(isWatchpoint) \
135 macro(jettisonReason) \
136 macro(join) \
137 macro(lastIndex) \
138 macro(length) \
139 macro(line) \
140 macro(locale) \
141 macro(localeMatcher) \
142 macro(message) \
143 macro(minute) \
144 macro(month) \
145 macro(multiline) \
146 macro(name) \
147 macro(next) \
148 macro(now) \
149 macro(numInlinedCalls) \
150 macro(numInlinedGetByIds) \
151 macro(numInlinedPutByIds) \
152 macro(numberingSystem) \
153 macro(numeric) \
154 macro(of) \
155 macro(opcode) \
156 macro(origin) \
157 macro(osrExitSites) \
158 macro(osrExits) \
159 macro(parse) \
160 macro(parseInt) \
161 macro(parseFloat) \
162 macro(profiledBytecodes) \
163 macro(propertyIsEnumerable) \
164 macro(prototype) \
165 macro(raw) \
166 macro(replace) \
167 macro(resolve) \
168 macro(second) \
169 macro(sensitivity) \
170 macro(set) \
171 macro(size) \
172 macro(slice) \
173 macro(source) \
174 macro(sourceCode) \
175 macro(sourceURL) \
176 macro(stack) \
177 macro(stackTraceLimit) \
178 macro(sticky) \
179 macro(subarray) \
180 macro(summary) \
181 macro(target) \
182 macro(test) \
183 macro(then) \
184 macro(time) \
185 macro(timeZone) \
186 macro(timeZoneName) \
187 macro(toExponential) \
188 macro(toFixed) \
189 macro(toISOString) \
190 macro(toJSON) \
191 macro(toLocaleString) \
192 macro(toPrecision) \
193 macro(toString) \
194 macro(uid) \
195 macro(unicode) \
196 macro(usage) \
197 macro(value) \
198 macro(valueOf) \
199 macro(weekday) \
200 macro(writable) \
201 macro(year)
202
203#define JSC_COMMON_IDENTIFIERS_EACH_KEYWORD(macro) \
204 macro(await) \
205 macro(break) \
206 macro(case) \
207 macro(catch) \
208 macro(class) \
209 macro(const) \
210 macro(continue) \
211 macro(debugger) \
212 macro(default) \
213 macro(delete) \
214 macro(do) \
215 macro(else) \
216 macro(enum) \
217 macro(export) \
218 macro(extends) \
219 macro(false) \
220 macro(finally) \
221 macro(for) \
222 macro(function) \
223 macro(if) \
224 macro(implements) \
225 macro(import) \
226 macro(in) \
227 macro(instanceof) \
228 macro(interface) \
229 macro(let) \
230 macro(new) \
231 macro(null) \
232 macro(package) \
233 macro(private) \
234 macro(protected) \
235 macro(public) \
236 macro(return) \
237 macro(static) \
238 macro(super) \
239 macro(switch) \
240 macro(this) \
241 macro(throw) \
242 macro(true) \
243 macro(try) \
244 macro(typeof) \
245 macro(undefined) \
246 macro(var) \
247 macro(void) \
248 macro(while) \
249 macro(with) \
250 macro(yield)
251
252#define JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_WELL_KNOWN_SYMBOL(macro) \
253 macro(hasInstance) \
254 macro(isConcatSpreadable) \
255 macro(asyncIterator) \
256 macro(iterator) \
257 macro(match) \
258 macro(matchAll) \
259 macro(replace) \
260 macro(search) \
261 macro(species) \
262 macro(split) \
263 macro(toPrimitive) \
264 macro(toStringTag) \
265 macro(unscopables)
266
267#define JSC_PARSER_PRIVATE_NAMES(macro) \
268 macro(generator) \
269 macro(generatorState) \
270 macro(generatorValue) \
271 macro(generatorResumeMode) \
272 macro(generatorFrame) \
273 macro(meta) \
274 macro(starDefault) \
275 macro(undefined) \
276
277namespace JSC {
278
279 class BuiltinNames;
280
281 class CommonIdentifiers {
282 WTF_MAKE_NONCOPYABLE(CommonIdentifiers); WTF_MAKE_FAST_ALLOCATED;
283 private:
284 CommonIdentifiers(VM*);
285 ~CommonIdentifiers();
286 friend class VM;
287
288 public:
289 const BuiltinNames& builtinNames() const { return *m_builtinNames; }
290 const Identifier nullIdentifier;
291 const Identifier emptyIdentifier;
292 const Identifier underscoreProto;
293 const Identifier thisIdentifier;
294 const Identifier useStrictIdentifier;
295 const Identifier timesIdentifier;
296 private:
297 std::unique_ptr<BuiltinNames> m_builtinNames;
298
299 public:
300
301#define JSC_IDENTIFIER_DECLARE_PARSER_PRIVATE_NAME(name) const Identifier name##PrivateName;
302 JSC_PARSER_PRIVATE_NAMES(JSC_IDENTIFIER_DECLARE_PARSER_PRIVATE_NAME)
303#undef JSC_IDENTIFIER_DECLARE_PARSER_PRIVATE_NAME
304
305#define JSC_IDENTIFIER_DECLARE_KEYWORD_NAME_GLOBAL(name) const Identifier name##Keyword;
306 JSC_COMMON_IDENTIFIERS_EACH_KEYWORD(JSC_IDENTIFIER_DECLARE_KEYWORD_NAME_GLOBAL)
307#undef JSC_IDENTIFIER_DECLARE_KEYWORD_NAME_GLOBAL
308
309#define JSC_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL(name) const Identifier name;
310 JSC_COMMON_IDENTIFIERS_EACH_PROPERTY_NAME(JSC_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL)
311#undef JSC_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL
312
313#define JSC_IDENTIFIER_DECLARE_PRIVATE_WELL_KNOWN_SYMBOL_GLOBAL(name) const Identifier name##Symbol;
314 JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_WELL_KNOWN_SYMBOL(JSC_IDENTIFIER_DECLARE_PRIVATE_WELL_KNOWN_SYMBOL_GLOBAL)
315#undef JSC_IDENTIFIER_DECLARE_PRIVATE_WELL_KNOWN_SYMBOL_GLOBAL
316
317 SymbolImpl* lookUpPrivateName(const Identifier&) const;
318 Identifier getPublicName(VM&, SymbolImpl*) const;
319
320 // Callers of this method should make sure that identifiers given to this method
321 // survive the lifetime of CommonIdentifiers and related VM.
322 JS_EXPORT_PRIVATE void appendExternalName(const Identifier& publicName, const Identifier& privateName);
323 };
324
325} // namespace JSC
326