| 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 | \ |
| 160 | macro(arrayHax) \ |
| 161 | macro(addr_of) \ |
| 162 | macro(read_offset) \ |
| 163 | macro(obj_at_addr) \ |
| 164 | \ |
| 165 | macro(parseInt) \ |
| 166 | macro(parseFloat) \ |
| 167 | macro(profiledBytecodes) \ |
| 168 | macro(propertyIsEnumerable) \ |
| 169 | macro(prototype) \ |
| 170 | macro(raw) \ |
| 171 | macro(replace) \ |
| 172 | macro(resolve) \ |
| 173 | macro(second) \ |
| 174 | macro(sensitivity) \ |
| 175 | macro(set) \ |
| 176 | macro(size) \ |
| 177 | macro(slice) \ |
| 178 | macro(source) \ |
| 179 | macro(sourceCode) \ |
| 180 | macro(sourceURL) \ |
| 181 | macro(stack) \ |
| 182 | macro(stackTraceLimit) \ |
| 183 | macro(sticky) \ |
| 184 | macro(subarray) \ |
| 185 | macro(summary) \ |
| 186 | macro(target) \ |
| 187 | macro(test) \ |
| 188 | macro(then) \ |
| 189 | macro(time) \ |
| 190 | macro(timeZone) \ |
| 191 | macro(timeZoneName) \ |
| 192 | macro(toExponential) \ |
| 193 | macro(toFixed) \ |
| 194 | macro(toISOString) \ |
| 195 | macro(toJSON) \ |
| 196 | macro(toLocaleString) \ |
| 197 | macro(toPrecision) \ |
| 198 | macro(toString) \ |
| 199 | macro(uid) \ |
| 200 | macro(unicode) \ |
| 201 | macro(usage) \ |
| 202 | macro(value) \ |
| 203 | macro(valueOf) \ |
| 204 | macro(weekday) \ |
| 205 | macro(writable) \ |
| 206 | macro(year) |
| 207 | |
| 208 | #define JSC_COMMON_IDENTIFIERS_EACH_KEYWORD(macro) \ |
| 209 | macro(await) \ |
| 210 | macro(break) \ |
| 211 | macro(case) \ |
| 212 | macro(catch) \ |
| 213 | macro(class) \ |
| 214 | macro(const) \ |
| 215 | macro(continue) \ |
| 216 | macro(debugger) \ |
| 217 | macro(default) \ |
| 218 | macro(delete) \ |
| 219 | macro(do) \ |
| 220 | macro(else) \ |
| 221 | macro(enum) \ |
| 222 | macro(export) \ |
| 223 | macro(extends) \ |
| 224 | macro(false) \ |
| 225 | macro(finally) \ |
| 226 | macro(for) \ |
| 227 | macro(function) \ |
| 228 | macro(if) \ |
| 229 | macro(implements) \ |
| 230 | macro(import) \ |
| 231 | macro(in) \ |
| 232 | macro(instanceof) \ |
| 233 | macro(interface) \ |
| 234 | macro(let) \ |
| 235 | macro(new) \ |
| 236 | macro(null) \ |
| 237 | macro(package) \ |
| 238 | macro(private) \ |
| 239 | macro(protected) \ |
| 240 | macro(public) \ |
| 241 | macro(return) \ |
| 242 | macro(static) \ |
| 243 | macro(super) \ |
| 244 | macro(switch) \ |
| 245 | macro(this) \ |
| 246 | macro(throw) \ |
| 247 | macro(true) \ |
| 248 | macro(try) \ |
| 249 | macro(typeof) \ |
| 250 | macro(undefined) \ |
| 251 | macro(var) \ |
| 252 | macro(void) \ |
| 253 | macro(while) \ |
| 254 | macro(with) \ |
| 255 | macro(yield) |
| 256 | |
| 257 | #define JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_WELL_KNOWN_SYMBOL(macro) \ |
| 258 | macro(hasInstance) \ |
| 259 | macro(isConcatSpreadable) \ |
| 260 | macro(asyncIterator) \ |
| 261 | macro(iterator) \ |
| 262 | macro(match) \ |
| 263 | macro(replace) \ |
| 264 | macro(search) \ |
| 265 | macro(species) \ |
| 266 | macro(split) \ |
| 267 | macro(toPrimitive) \ |
| 268 | macro(toStringTag) \ |
| 269 | macro(unscopables) |
| 270 | |
| 271 | #define JSC_PARSER_PRIVATE_NAMES(macro) \ |
| 272 | macro(generator) \ |
| 273 | macro(generatorState) \ |
| 274 | macro(generatorValue) \ |
| 275 | macro(generatorResumeMode) \ |
| 276 | macro(generatorFrame) \ |
| 277 | macro(meta) \ |
| 278 | macro(starDefault) \ |
| 279 | macro(undefined) \ |
| 280 | |
| 281 | namespace JSC { |
| 282 | |
| 283 | class BuiltinNames; |
| 284 | |
| 285 | class CommonIdentifiers { |
| 286 | WTF_MAKE_NONCOPYABLE(CommonIdentifiers); WTF_MAKE_FAST_ALLOCATED; |
| 287 | private: |
| 288 | CommonIdentifiers(VM*); |
| 289 | ~CommonIdentifiers(); |
| 290 | friend class VM; |
| 291 | |
| 292 | public: |
| 293 | const BuiltinNames& builtinNames() const { return *m_builtinNames; } |
| 294 | const Identifier nullIdentifier; |
| 295 | const Identifier emptyIdentifier; |
| 296 | const Identifier underscoreProto; |
| 297 | const Identifier thisIdentifier; |
| 298 | const Identifier useStrictIdentifier; |
| 299 | const Identifier timesIdentifier; |
| 300 | private: |
| 301 | std::unique_ptr<BuiltinNames> m_builtinNames; |
| 302 | |
| 303 | public: |
| 304 | |
| 305 | #define JSC_IDENTIFIER_DECLARE_PARSER_PRIVATE_NAME(name) const Identifier name##PrivateName; |
| 306 | JSC_PARSER_PRIVATE_NAMES(JSC_IDENTIFIER_DECLARE_PARSER_PRIVATE_NAME) |
| 307 | #undef JSC_IDENTIFIER_DECLARE_PARSER_PRIVATE_NAME |
| 308 | |
| 309 | #define JSC_IDENTIFIER_DECLARE_KEYWORD_NAME_GLOBAL(name) const Identifier name##Keyword; |
| 310 | JSC_COMMON_IDENTIFIERS_EACH_KEYWORD(JSC_IDENTIFIER_DECLARE_KEYWORD_NAME_GLOBAL) |
| 311 | #undef JSC_IDENTIFIER_DECLARE_KEYWORD_NAME_GLOBAL |
| 312 | |
| 313 | #define JSC_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL(name) const Identifier name; |
| 314 | JSC_COMMON_IDENTIFIERS_EACH_PROPERTY_NAME(JSC_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL) |
| 315 | #undef JSC_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL |
| 316 | |
| 317 | #define JSC_IDENTIFIER_DECLARE_PRIVATE_WELL_KNOWN_SYMBOL_GLOBAL(name) const Identifier name##Symbol; |
| 318 | JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_WELL_KNOWN_SYMBOL(JSC_IDENTIFIER_DECLARE_PRIVATE_WELL_KNOWN_SYMBOL_GLOBAL) |
| 319 | #undef JSC_IDENTIFIER_DECLARE_PRIVATE_WELL_KNOWN_SYMBOL_GLOBAL |
| 320 | |
| 321 | SymbolImpl* lookUpPrivateName(const Identifier&) const; |
| 322 | Identifier getPublicName(VM&, SymbolImpl*) const; |
| 323 | |
| 324 | // Callers of this method should make sure that identifiers given to this method |
| 325 | // survive the lifetime of CommonIdentifiers and related VM. |
| 326 | JS_EXPORT_PRIVATE void appendExternalName(const Identifier& publicName, const Identifier& privateName); |
| 327 | }; |
| 328 | |
| 329 | } // namespace JSC |
| 330 | |