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