1/*
2 * Copyright (C) 2003, 2007, 2009 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#ifndef CommonIdentifiers_h
22#define CommonIdentifiers_h
23
24#include "BytecodeIntrinsicRegistry.h"
25#include "Identifier.h"
26#include <wtf/Noncopyable.h>
27
28// MarkedArgumentBuffer of property names, passed to a macro so we can do set them up various
29// ways without repeating the list.
30#define JSC_COMMON_IDENTIFIERS_EACH_PROPERTY_NAME(macro) \
31 macro(AnimationTimeline) \
32 macro(Array) \
33 macro(ArrayBuffer) \
34 macro(ArrayIterator) \
35 macro(Audio) \
36 macro(BYTES_PER_ELEMENT) \
37 macro(Boolean) \
38 macro(Collator) \
39 macro(Date) \
40 macro(DateTimeFormat) \
41 macro(DocumentTimeline) \
42 macro(Error) \
43 macro(EvalError) \
44 macro(Function) \
45 macro(Gamepad) \
46 macro(GamepadButton) \
47 macro(GamepadEvent) \
48 macro(GeneratorFunction) \
49 macro(HTMLAudioElement) \
50 macro(HTMLSlotElement) \
51 macro(IDBCursor) \
52 macro(IDBCursorWithValue) \
53 macro(IDBDatabase) \
54 macro(IDBFactory) \
55 macro(IDBIndex) \
56 macro(IDBKeyRange) \
57 macro(IDBObjectStore) \
58 macro(IDBOpenDBRequest) \
59 macro(IDBRequest) \
60 macro(IDBTransaction) \
61 macro(IDBVersionChangeEvent) \
62 macro(Infinity) \
63 macro(Intl) \
64 macro(JSON) \
65 macro(Loader) \
66 macro(Map)\
67 macro(MapIterator)\
68 macro(Math) \
69 macro(NaN) \
70 macro(Number) \
71 macro(NumberFormat) \
72 macro(Object) \
73 macro(Promise) \
74 macro(Proxy) \
75 macro(RangeError) \
76 macro(ReferenceError) \
77 macro(Reflect) \
78 macro(RegExp) \
79 macro(Set)\
80 macro(SetIterator)\
81 macro(ShadowRoot) \
82 macro(String) \
83 macro(Symbol) \
84 macro(SyntaxError) \
85 macro(TypeError) \
86 macro(URIError) \
87 macro(UTC) \
88 macro(WeakMap)\
89 macro(WeakSet)\
90 macro(WebSocket) \
91 macro(__defineGetter__) \
92 macro(__defineSetter__) \
93 macro(__lookupGetter__) \
94 macro(__lookupSetter__) \
95 macro(add) \
96 macro(additionalJettisonReason) \
97 macro(anonymous) \
98 macro(arguments) \
99 macro(as) \
100 macro(assign) \
101 macro(back) \
102 macro(bind) \
103 macro(blur) \
104 macro(buffer) \
105 macro(byteLength) \
106 macro(byteOffset) \
107 macro(bytecode) \
108 macro(bytecodeIndex) \
109 macro(bytecodes) \
110 macro(bytecodesID) \
111 macro(calendar) \
112 macro(callee) \
113 macro(caller) \
114 macro(caseFirst) \
115 macro(clear) \
116 macro(close) \
117 macro(closed) \
118 macro(collation) \
119 macro(column) \
120 macro(compilationKind) \
121 macro(compilations) \
122 macro(compile) \
123 macro(configurable) \
124 macro(constructor) \
125 macro(count) \
126 macro(counters) \
127 macro(day) \
128 macro(defineProperty) \
129 macro(description) \
130 macro(descriptions) \
131 macro(displayName) \
132 macro(document) \
133 macro(done) \
134 macro(entries) \
135 macro(enumerable) \
136 macro(era) \
137 macro(eval) \
138 macro(exec) \
139 macro(executionCount) \
140 macro(exitKind) \
141 macro(flags) \
142 macro(focus) \
143 macro(forEach) \
144 macro(formatMatcher) \
145 macro(forward) \
146 macro(frames) \
147 macro(from) \
148 macro(fromCharCode) \
149 macro(get) \
150 macro(global) \
151 macro(go) \
152 macro(has) \
153 macro(hasOwnProperty) \
154 macro(hash) \
155 macro(header) \
156 macro(hour) \
157 macro(hour12) \
158 macro(href) \
159 macro(id) \
160 macro(ignoreCase) \
161 macro(ignorePunctuation) \
162 macro(index) \
163 macro(indexedDB) \
164 macro(inferredName) \
165 macro(input) \
166 macro(instructionCount) \
167 macro(isArray) \
168 macro(isEnabled) \
169 macro(isPrototypeOf) \
170 macro(isView) \
171 macro(isWatchpoint) \
172 macro(jettisonReason) \
173 macro(join) \
174 macro(keys) \
175 macro(lastIndex) \
176 macro(length) \
177 macro(line) \
178 macro(locale) \
179 macro(localeMatcher) \
180 macro(location) \
181 macro(message) \
182 macro(minute) \
183 macro(month) \
184 macro(multiline) \
185 macro(name) \
186 macro(next) \
187 macro(now) \
188 macro(numInlinedCalls) \
189 macro(numInlinedGetByIds) \
190 macro(numInlinedPutByIds) \
191 macro(numberingSystem) \
192 macro(numeric) \
193 macro(of) \
194 macro(opcode) \
195 macro(opener) \
196 macro(origin) \
197 macro(osrExitSites) \
198 macro(osrExits) \
199 macro(parent) \
200 macro(parse) \
201 macro(parseInt) \
202 macro(postMessage) \
203 macro(profiledBytecodes) \
204 macro(propertyIsEnumerable) \
205 macro(prototype) \
206 macro(raw) \
207 macro(reload) \
208 macro(replace) \
209 macro(resolve) \
210 macro(second) \
211 macro(self) \
212 macro(sensitivity) \
213 macro(set) \
214 macro(showModalDialog) \
215 macro(size) \
216 macro(slice) \
217 macro(source) \
218 macro(sourceCode) \
219 macro(sourceURL) \
220 macro(stack) \
221 macro(subarray) \
222 macro(target) \
223 macro(test) \
224 macro(then) \
225 macro(timeZone) \
226 macro(timeZoneName) \
227 macro(toExponential) \
228 macro(toFixed) \
229 macro(toISOString) \
230 macro(toJSON) \
231 macro(toLocaleString) \
232 macro(toPrecision) \
233 macro(toString) \
234 macro(top) \
235 macro(usage) \
236 macro(value) \
237 macro(valueOf) \
238 macro(values) \
239 macro(webkit) \
240 macro(webkitIDBCursor) \
241 macro(webkitIDBDatabase) \
242 macro(webkitIDBFactory) \
243 macro(webkitIDBIndex) \
244 macro(webkitIDBKeyRange) \
245 macro(webkitIDBObjectStore) \
246 macro(webkitIDBRequest) \
247 macro(webkitIDBTransaction) \
248 macro(webkitIndexedDB) \
249 macro(weekday) \
250 macro(window) \
251 macro(writable) \
252 macro(year)
253
254#define JSC_COMMON_IDENTIFIERS_EACH_KEYWORD(macro) \
255 macro(break) \
256 macro(case) \
257 macro(catch) \
258 macro(class) \
259 macro(const) \
260 macro(continue) \
261 macro(debugger) \
262 macro(default) \
263 macro(delete) \
264 macro(do) \
265 macro(else) \
266 macro(enum) \
267 macro(export) \
268 macro(extends) \
269 macro(false) \
270 macro(finally) \
271 macro(for) \
272 macro(function) \
273 macro(if) \
274 macro(implements) \
275 macro(import) \
276 macro(in) \
277 macro(instanceof) \
278 macro(interface) \
279 macro(let) \
280 macro(new) \
281 macro(null) \
282 macro(package) \
283 macro(private) \
284 macro(protected) \
285 macro(public) \
286 macro(return) \
287 macro(static) \
288 macro(super) \
289 macro(switch) \
290 macro(this) \
291 macro(throw) \
292 macro(true) \
293 macro(try) \
294 macro(typeof) \
295 macro(undefined) \
296 macro(var) \
297 macro(void) \
298 macro(while) \
299 macro(with) \
300 macro(yield)
301
302#define JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_WELL_KNOWN_SYMBOL_NOT_IMPLEMENTED_YET(macro)\
303 macro(isConcatSpreadable) \
304 macro(match) \
305 macro(replace) \
306 macro(split) \
307 macro(toPrimitive)
308
309#define JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_WELL_KNOWN_SYMBOL(macro) \
310 macro(hasInstance) \
311 macro(iterator) \
312 macro(search) \
313 macro(species) \
314 macro(toStringTag) \
315 macro(unscopables)
316
317#define JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_PROPERTY_NAME(macro) \
318 JSC_COMMON_BYTECODE_INTRINSIC_FUNCTIONS_EACH_NAME(macro) \
319 JSC_COMMON_BYTECODE_INTRINSIC_CONSTANTS_EACH_NAME(macro) \
320 macro(iteratedObject) \
321 macro(arrayIteratorNextIndex) \
322 macro(arrayIterationKind) \
323 macro(charCodeAt) \
324 macro(iteratedString) \
325 macro(stringIteratorNextIndex) \
326 macro(promise) \
327 macro(fulfillmentHandler) \
328 macro(rejectionHandler) \
329 macro(index) \
330 macro(values) \
331 macro(deferred) \
332 macro(countdownHolder) \
333 macro(Object) \
334 macro(ownEnumerablePropertyKeys) \
335 macro(Number) \
336 macro(Array) \
337 macro(String) \
338 macro(RegExp) \
339 macro(Map) \
340 macro(Promise) \
341 macro(InternalPromise) \
342 macro(abs) \
343 macro(floor) \
344 macro(isFinite) \
345 macro(isNaN) \
346 macro(getPrototypeOf) \
347 macro(getOwnPropertyNames) \
348 macro(RangeError) \
349 macro(TypeError) \
350 macro(typedArrayLength) \
351 macro(typedArraySort) \
352 macro(BuiltinLog) \
353 macro(homeObject) \
354 macro(getTemplateObject) \
355 macro(enqueueJob) \
356 macro(handler) \
357 macro(promiseState) \
358 macro(promiseFulfillReactions) \
359 macro(promiseRejectReactions) \
360 macro(promiseResult) \
361 macro(push) \
362 macro(capabilities) \
363 macro(starDefault) \
364 macro(InspectorInstrumentation) \
365 macro(get) \
366 macro(set) \
367 macro(shift) \
368 macro(allocateTypedArray) \
369 macro(Int8Array) \
370 macro(Int16Array) \
371 macro(Int32Array) \
372 macro(Uint8Array) \
373 macro(Uint8ClampedArray) \
374 macro(Uint16Array) \
375 macro(Uint32Array) \
376 macro(Float32Array) \
377 macro(Float64Array) \
378 macro(generator) \
379 macro(generatorNext) \
380 macro(generatorState) \
381 macro(generatorFrame) \
382 macro(generatorValue) \
383 macro(generatorThis) \
384 macro(generatorResumeMode) \
385 macro(Collator) \
386 macro(DateTimeFormat) \
387 macro(NumberFormat) \
388 macro(thisTimeValue) \
389 macro(newTargetLocal) \
390 macro(derivedConstructor) \
391 macro(isBoundFunction) \
392 macro(hasInstanceBoundFunction) \
393 macro(instanceOf) \
394 macro(isSet) \
395 macro(isMap) \
396 macro(SetIterator) \
397 macro(setIteratorNext) \
398 macro(MapIterator) \
399 macro(mapIteratorNext) \
400
401
402namespace JSC {
403
404 class BuiltinNames;
405
406 class CommonIdentifiers {
407 WTF_MAKE_NONCOPYABLE(CommonIdentifiers); WTF_MAKE_FAST_ALLOCATED;
408 private:
409 CommonIdentifiers(VM*);
410 ~CommonIdentifiers();
411 friend class VM;
412
413 public:
414 const BuiltinNames& builtinNames() const { return *m_builtinNames; }
415 const Identifier nullIdentifier;
416 const Identifier emptyIdentifier;
417 const Identifier underscoreProto;
418 const Identifier thisIdentifier;
419 const Identifier useStrictIdentifier;
420 const Identifier timesIdentifier;
421 private:
422 std::unique_ptr<BuiltinNames> m_builtinNames;
423
424 public:
425
426#define JSC_IDENTIFIER_DECLARE_KEYWORD_NAME_GLOBAL(name) const Identifier name##Keyword;
427 JSC_COMMON_IDENTIFIERS_EACH_KEYWORD(JSC_IDENTIFIER_DECLARE_KEYWORD_NAME_GLOBAL)
428#undef JSC_IDENTIFIER_DECLARE_KEYWORD_NAME_GLOBAL
429
430#define JSC_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL(name) const Identifier name;
431 JSC_COMMON_IDENTIFIERS_EACH_PROPERTY_NAME(JSC_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL)
432#undef JSC_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL
433
434#define JSC_IDENTIFIER_DECLARE_PRIVATE_PROPERTY_NAME_GLOBAL(name) const Identifier name##PrivateName;
435 JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_PROPERTY_NAME(JSC_IDENTIFIER_DECLARE_PRIVATE_PROPERTY_NAME_GLOBAL)
436#undef JSC_IDENTIFIER_DECLARE_PRIVATE_PROPERTY_NAME_GLOBAL
437
438#define JSC_IDENTIFIER_DECLARE_PRIVATE_WELL_KNOWN_SYMBOL_GLOBAL(name) const Identifier name##Symbol;
439 JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_WELL_KNOWN_SYMBOL(JSC_IDENTIFIER_DECLARE_PRIVATE_WELL_KNOWN_SYMBOL_GLOBAL)
440#undef JSC_IDENTIFIER_DECLARE_PRIVATE_WELL_KNOWN_SYMBOL_GLOBAL
441
442 bool isPrivateName(SymbolImpl& uid) const;
443 bool isPrivateName(UniquedStringImpl& uid) const;
444 bool isPrivateName(const Identifier&) const;
445
446 const Identifier* lookUpPrivateName(const Identifier&) const;
447 Identifier lookUpPublicName(const Identifier&) const;
448
449 // Callers of this method should make sure that identifiers given to this method
450 // survive the lifetime of CommonIdentifiers and related VM.
451 JS_EXPORT_PRIVATE void appendExternalName(const Identifier& publicName, const Identifier& privateName);
452 };
453
454} // namespace JSC
455
456#endif // CommonIdentifiers_h
457