| 1 | /* |
| 2 | * Copyright (C) 2006-2018 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 | namespace JSC { |
| 24 | |
| 25 | enum JSType : uint8_t { |
| 26 | // The CellType value must come before any JSType that is a JSCell. |
| 27 | CellType, |
| 28 | StringType, |
| 29 | SymbolType, |
| 30 | BigIntType, |
| 31 | |
| 32 | CustomGetterSetterType, |
| 33 | APIValueWrapperType, |
| 34 | |
| 35 | NativeExecutableType, |
| 36 | |
| 37 | ProgramExecutableType, |
| 38 | ModuleProgramExecutableType, |
| 39 | EvalExecutableType, |
| 40 | FunctionExecutableType, |
| 41 | |
| 42 | UnlinkedFunctionExecutableType, |
| 43 | |
| 44 | UnlinkedProgramCodeBlockType, |
| 45 | UnlinkedModuleProgramCodeBlockType, |
| 46 | UnlinkedEvalCodeBlockType, |
| 47 | UnlinkedFunctionCodeBlockType, |
| 48 | |
| 49 | CodeBlockType, |
| 50 | |
| 51 | JSFixedArrayType, |
| 52 | JSImmutableButterflyType, |
| 53 | JSSourceCodeType, |
| 54 | JSScriptFetcherType, |
| 55 | JSScriptFetchParametersType, |
| 56 | |
| 57 | // The ObjectType value must come before any JSType that is a subclass of JSObject. |
| 58 | ObjectType, |
| 59 | FinalObjectType, |
| 60 | JSCalleeType, |
| 61 | JSFunctionType, |
| 62 | InternalFunctionType, |
| 63 | NumberObjectType, |
| 64 | ErrorInstanceType, |
| 65 | PureForwardingProxyType, |
| 66 | ImpureProxyType, |
| 67 | DirectArgumentsType, |
| 68 | ScopedArgumentsType, |
| 69 | ClonedArgumentsType, |
| 70 | |
| 71 | // Start JSArray types. |
| 72 | ArrayType, |
| 73 | DerivedArrayType, |
| 74 | // End JSArray types. |
| 75 | |
| 76 | ArrayBufferType, |
| 77 | |
| 78 | // Start JSArrayBufferView types. Keep in sync with the order of FOR_EACH_TYPED_ARRAY_TYPE_EXCLUDING_DATA_VIEW. |
| 79 | Int8ArrayType, |
| 80 | Uint8ArrayType, |
| 81 | Uint8ClampedArrayType, |
| 82 | Int16ArrayType, |
| 83 | Uint16ArrayType, |
| 84 | Int32ArrayType, |
| 85 | Uint32ArrayType, |
| 86 | Float32ArrayType, |
| 87 | Float64ArrayType, |
| 88 | DataViewType, |
| 89 | // End JSArrayBufferView types. |
| 90 | |
| 91 | GetterSetterType, |
| 92 | |
| 93 | // JSScope <- JSWithScope |
| 94 | // <- StrictEvalActivation |
| 95 | // <- JSSymbolTableObject <- JSLexicalEnvironment <- JSModuleEnvironment |
| 96 | // <- JSSegmentedVariableObject <- JSGlobalLexicalEnvironment |
| 97 | // <- JSGlobalObject |
| 98 | // Start JSScope types. |
| 99 | // Start environment record types. |
| 100 | GlobalObjectType, |
| 101 | GlobalLexicalEnvironmentType, |
| 102 | LexicalEnvironmentType, |
| 103 | ModuleEnvironmentType, |
| 104 | StrictEvalActivationType, |
| 105 | // End environment record types. |
| 106 | WithScopeType, |
| 107 | // End JSScope types. |
| 108 | |
| 109 | RegExpObjectType, |
| 110 | ProxyObjectType, |
| 111 | JSMapType, |
| 112 | JSSetType, |
| 113 | JSWeakMapType, |
| 114 | JSWeakSetType, |
| 115 | WebAssemblyToJSCalleeType, |
| 116 | StringObjectType, |
| 117 | |
| 118 | LastJSCObjectType = StringObjectType, // This is the last "JSC" Object type. After this, we have embedder's (e.g., WebCore) extended object types. |
| 119 | MaxJSType = 0b11111111, |
| 120 | }; |
| 121 | |
| 122 | static constexpr uint32_t FirstTypedArrayType = Int8ArrayType; |
| 123 | static constexpr uint32_t LastTypedArrayType = DataViewType; |
| 124 | |
| 125 | // LastObjectType should be MaxJSType (not LastJSCObjectType) since embedders can add their extended object types after the enums listed in JSType. |
| 126 | static constexpr uint32_t FirstObjectType = ObjectType; |
| 127 | static constexpr uint32_t LastObjectType = MaxJSType; |
| 128 | |
| 129 | static constexpr uint32_t NumberOfTypedArrayTypes = LastTypedArrayType - FirstTypedArrayType + 1; |
| 130 | static constexpr uint32_t NumberOfTypedArrayTypesExcludingDataView = NumberOfTypedArrayTypes - 1; |
| 131 | |
| 132 | static_assert(sizeof(JSType) == sizeof(uint8_t), "sizeof(JSType) is one byte." ); |
| 133 | static_assert(LastJSCObjectType < 128, "The highest bit is reserved for embedder's extension." ); |
| 134 | |
| 135 | inline constexpr bool isTypedArrayType(JSType type) |
| 136 | { |
| 137 | return (static_cast<uint32_t>(type) - FirstTypedArrayType) < NumberOfTypedArrayTypesExcludingDataView; |
| 138 | } |
| 139 | |
| 140 | } // namespace JSC |
| 141 | |
| 142 | namespace WTF { |
| 143 | |
| 144 | class PrintStream; |
| 145 | |
| 146 | void printInternal(PrintStream&, JSC::JSType); |
| 147 | |
| 148 | } // namespace WTF |
| 149 | |