Forward.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. /*
  2. * Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #define JS_DECLARE_OLD_NATIVE_FUNCTION(name) \
  8. static JS::Value name(JS::VM&, JS::GlobalObject&)
  9. #define JS_DEFINE_OLD_NATIVE_FUNCTION(name) \
  10. JS::Value name([[maybe_unused]] JS::VM& vm, [[maybe_unused]] JS::GlobalObject& global_object)
  11. #define JS_DECLARE_NATIVE_FUNCTION(name) \
  12. static JS::ThrowCompletionOr<JS::Value> name(JS::VM&, JS::GlobalObject&)
  13. #define JS_DEFINE_NATIVE_FUNCTION(name) \
  14. JS::ThrowCompletionOr<JS::Value> name([[maybe_unused]] JS::VM& vm, [[maybe_unused]] JS::GlobalObject& global_object)
  15. // NOTE: Proxy is not included here as it doesn't have a prototype - m_proxy_constructor is initialized separately.
  16. #define JS_ENUMERATE_NATIVE_OBJECTS_EXCLUDING_TEMPLATES \
  17. __JS_ENUMERATE(AggregateError, aggregate_error, AggregateErrorPrototype, AggregateErrorConstructor, void) \
  18. __JS_ENUMERATE(Array, array, ArrayPrototype, ArrayConstructor, void) \
  19. __JS_ENUMERATE(ArrayBuffer, array_buffer, ArrayBufferPrototype, ArrayBufferConstructor, void) \
  20. __JS_ENUMERATE(BigIntObject, bigint, BigIntPrototype, BigIntConstructor, void) \
  21. __JS_ENUMERATE(BooleanObject, boolean, BooleanPrototype, BooleanConstructor, void) \
  22. __JS_ENUMERATE(DataView, data_view, DataViewPrototype, DataViewConstructor, void) \
  23. __JS_ENUMERATE(Date, date, DatePrototype, DateConstructor, void) \
  24. __JS_ENUMERATE(Error, error, ErrorPrototype, ErrorConstructor, void) \
  25. __JS_ENUMERATE(FinalizationRegistry, finalization_registry, FinalizationRegistryPrototype, FinalizationRegistryConstructor, void) \
  26. __JS_ENUMERATE(FunctionObject, function, FunctionPrototype, FunctionConstructor, void) \
  27. __JS_ENUMERATE(GeneratorFunction, generator_function, GeneratorFunctionPrototype, GeneratorFunctionConstructor, void) \
  28. __JS_ENUMERATE(Map, map, MapPrototype, MapConstructor, void) \
  29. __JS_ENUMERATE(NumberObject, number, NumberPrototype, NumberConstructor, void) \
  30. __JS_ENUMERATE(Object, object, ObjectPrototype, ObjectConstructor, void) \
  31. __JS_ENUMERATE(Promise, promise, PromisePrototype, PromiseConstructor, void) \
  32. __JS_ENUMERATE(RegExpObject, regexp, RegExpPrototype, RegExpConstructor, void) \
  33. __JS_ENUMERATE(Set, set, SetPrototype, SetConstructor, void) \
  34. __JS_ENUMERATE(ShadowRealm, shadow_realm, ShadowRealmPrototype, ShadowRealmConstructor, void) \
  35. __JS_ENUMERATE(StringObject, string, StringPrototype, StringConstructor, void) \
  36. __JS_ENUMERATE(SymbolObject, symbol, SymbolPrototype, SymbolConstructor, void) \
  37. __JS_ENUMERATE(WeakMap, weak_map, WeakMapPrototype, WeakMapConstructor, void) \
  38. __JS_ENUMERATE(WeakRef, weak_ref, WeakRefPrototype, WeakRefConstructor, void) \
  39. __JS_ENUMERATE(WeakSet, weak_set, WeakSetPrototype, WeakSetConstructor, void)
  40. #define JS_ENUMERATE_NATIVE_OBJECTS \
  41. JS_ENUMERATE_NATIVE_OBJECTS_EXCLUDING_TEMPLATES \
  42. __JS_ENUMERATE(TypedArray, typed_array, TypedArrayPrototype, TypedArrayConstructor, void)
  43. #define JS_ENUMERATE_NATIVE_ERRORS \
  44. __JS_ENUMERATE(EvalError, eval_error, EvalErrorPrototype, EvalErrorConstructor, void) \
  45. __JS_ENUMERATE(InternalError, internal_error, InternalErrorPrototype, InternalErrorConstructor, void) \
  46. __JS_ENUMERATE(InvalidCharacterError, invalid_character_error, InvalidCharacterErrorPrototype, InvalidCharacterErrorConstructor, void) \
  47. __JS_ENUMERATE(RangeError, range_error, RangeErrorPrototype, RangeErrorConstructor, void) \
  48. __JS_ENUMERATE(ReferenceError, reference_error, ReferenceErrorPrototype, ReferenceErrorConstructor, void) \
  49. __JS_ENUMERATE(SyntaxError, syntax_error, SyntaxErrorPrototype, SyntaxErrorConstructor, void) \
  50. __JS_ENUMERATE(TypeError, type_error, TypeErrorPrototype, TypeErrorConstructor, void) \
  51. __JS_ENUMERATE(URIError, uri_error, URIErrorPrototype, URIErrorConstructor, void)
  52. #define JS_ENUMERATE_TYPED_ARRAYS \
  53. __JS_ENUMERATE(Uint8Array, uint8_array, Uint8ArrayPrototype, Uint8ArrayConstructor, u8) \
  54. __JS_ENUMERATE(Uint8ClampedArray, uint8_clamped_array, Uint8ClampedArrayPrototype, Uint8ClampedArrayConstructor, ClampedU8) \
  55. __JS_ENUMERATE(Uint16Array, uint16_array, Uint16ArrayPrototype, Uint16ArrayConstructor, u16) \
  56. __JS_ENUMERATE(Uint32Array, uint32_array, Uint32ArrayPrototype, Uint32ArrayConstructor, u32) \
  57. __JS_ENUMERATE(BigUint64Array, big_uint64_array, BigUint64ArrayPrototype, BigUint64ArrayConstructor, u64) \
  58. __JS_ENUMERATE(Int8Array, int8_array, Int8ArrayPrototype, Int8ArrayConstructor, i8) \
  59. __JS_ENUMERATE(Int16Array, int16_array, Int16ArrayPrototype, Int16ArrayConstructor, i16) \
  60. __JS_ENUMERATE(Int32Array, int32_array, Int32ArrayPrototype, Int32ArrayConstructor, i32) \
  61. __JS_ENUMERATE(BigInt64Array, big_int64_array, BigInt64ArrayPrototype, BigInt64ArrayConstructor, i64) \
  62. __JS_ENUMERATE(Float32Array, float32_array, Float32ArrayPrototype, Float32ArrayConstructor, float) \
  63. __JS_ENUMERATE(Float64Array, float64_array, Float64ArrayPrototype, Float64ArrayConstructor, double)
  64. #define JS_ENUMERATE_INTL_OBJECTS \
  65. __JS_ENUMERATE(DisplayNames, display_names, DisplayNamesPrototype, DisplayNamesConstructor) \
  66. __JS_ENUMERATE(ListFormat, list_format, ListFormatPrototype, ListFormatConstructor) \
  67. __JS_ENUMERATE(Locale, locale, LocalePrototype, LocaleConstructor) \
  68. __JS_ENUMERATE(NumberFormat, number_format, NumberFormatPrototype, NumberFormatConstructor)
  69. #define JS_ENUMERATE_TEMPORAL_OBJECTS \
  70. __JS_ENUMERATE(Calendar, calendar, CalendarPrototype, CalendarConstructor) \
  71. __JS_ENUMERATE(Duration, duration, DurationPrototype, DurationConstructor) \
  72. __JS_ENUMERATE(Instant, instant, InstantPrototype, InstantConstructor) \
  73. __JS_ENUMERATE(PlainDate, plain_date, PlainDatePrototype, PlainDateConstructor) \
  74. __JS_ENUMERATE(PlainDateTime, plain_date_time, PlainDateTimePrototype, PlainDateTimeConstructor) \
  75. __JS_ENUMERATE(PlainMonthDay, plain_month_day, PlainMonthDayPrototype, PlainMonthDayConstructor) \
  76. __JS_ENUMERATE(PlainTime, plain_time, PlainTimePrototype, PlainTimeConstructor) \
  77. __JS_ENUMERATE(PlainYearMonth, plain_year_month, PlainYearMonthPrototype, PlainYearMonthConstructor) \
  78. __JS_ENUMERATE(TimeZone, time_zone, TimeZonePrototype, TimeZoneConstructor) \
  79. __JS_ENUMERATE(ZonedDateTime, zoned_date_time, ZonedDateTimePrototype, ZonedDateTimeConstructor)
  80. #define JS_ENUMERATE_ITERATOR_PROTOTYPES \
  81. __JS_ENUMERATE(Iterator, iterator) \
  82. __JS_ENUMERATE(ArrayIterator, array_iterator) \
  83. __JS_ENUMERATE(MapIterator, map_iterator) \
  84. __JS_ENUMERATE(RegExpStringIterator, regexp_string_iterator) \
  85. __JS_ENUMERATE(SetIterator, set_iterator) \
  86. __JS_ENUMERATE(StringIterator, string_iterator)
  87. #define JS_ENUMERATE_BUILTIN_TYPES \
  88. JS_ENUMERATE_NATIVE_OBJECTS \
  89. JS_ENUMERATE_NATIVE_ERRORS \
  90. JS_ENUMERATE_TYPED_ARRAYS
  91. #define JS_ENUMERATE_WELL_KNOWN_SYMBOLS \
  92. __JS_ENUMERATE(iterator, iterator) \
  93. __JS_ENUMERATE(asyncIterator, async_iterator) \
  94. __JS_ENUMERATE(match, match) \
  95. __JS_ENUMERATE(matchAll, match_all) \
  96. __JS_ENUMERATE(replace, replace) \
  97. __JS_ENUMERATE(replaceAll, replace_all) \
  98. __JS_ENUMERATE(search, search) \
  99. __JS_ENUMERATE(split, split) \
  100. __JS_ENUMERATE(hasInstance, has_instance) \
  101. __JS_ENUMERATE(isConcatSpreadable, is_concat_spreadable) \
  102. __JS_ENUMERATE(unscopables, unscopables) \
  103. __JS_ENUMERATE(species, species) \
  104. __JS_ENUMERATE(toPrimitive, to_primitive) \
  105. __JS_ENUMERATE(toStringTag, to_string_tag)
  106. #define JS_ENUMERATE_REGEXP_FLAGS \
  107. __JS_ENUMERATE(hasIndices, has_indices, d) \
  108. __JS_ENUMERATE(global, global, g) \
  109. __JS_ENUMERATE(ignoreCase, ignore_case, i) \
  110. __JS_ENUMERATE(multiline, multiline, m) \
  111. __JS_ENUMERATE(dotAll, dot_all, s) \
  112. __JS_ENUMERATE(unicode, unicode, u) \
  113. __JS_ENUMERATE(sticky, sticky, y)
  114. namespace JS {
  115. class ASTNode;
  116. class Accessor;
  117. class BigInt;
  118. class BoundFunction;
  119. class Cell;
  120. class CellAllocator;
  121. class ClassExpression;
  122. class Completion;
  123. class Console;
  124. class DeclarativeEnvironment;
  125. class DeferGC;
  126. class ECMAScriptFunctionObject;
  127. class Environment;
  128. class Error;
  129. class ErrorType;
  130. class Exception;
  131. class Expression;
  132. class FunctionEnvironment;
  133. class FunctionNode;
  134. class GlobalEnvironment;
  135. class GlobalObject;
  136. class HandleImpl;
  137. class Heap;
  138. class HeapBlock;
  139. class Interpreter;
  140. class MarkedValueList;
  141. class NativeFunction;
  142. class ObjectEnvironment;
  143. class PrimitiveString;
  144. class PromiseReaction;
  145. class PromiseReactionJob;
  146. class PromiseResolveThenableJob;
  147. class PropertyAttributes;
  148. class PropertyDescriptor;
  149. class PropertyName;
  150. class Realm;
  151. class Reference;
  152. class ScopeNode;
  153. class Shape;
  154. class Statement;
  155. class StringOrSymbol;
  156. class Symbol;
  157. class Token;
  158. class Utf16String;
  159. class VM;
  160. class Value;
  161. class WeakContainer;
  162. class WrappedFunction;
  163. enum class DeclarationKind;
  164. struct AlreadyResolved;
  165. struct JobCallback;
  166. struct PromiseCapability;
  167. // Not included in JS_ENUMERATE_NATIVE_OBJECTS due to missing distinct prototype
  168. class ProxyObject;
  169. class ProxyConstructor;
  170. // Not included in JS_ENUMERATE_NATIVE_OBJECTS due to missing distinct constructor
  171. class GeneratorObjectPrototype;
  172. class TypedArrayConstructor;
  173. class TypedArrayPrototype;
  174. // Tag type used to differentiate between u8 as used by Uint8Array and u8 as used by Uint8ClampedArray.
  175. struct ClampedU8;
  176. #define __JS_ENUMERATE(ClassName, snake_name, ConstructorName, PrototypeName, ArrayType) \
  177. class ClassName; \
  178. class ConstructorName; \
  179. class PrototypeName;
  180. JS_ENUMERATE_NATIVE_OBJECTS_EXCLUDING_TEMPLATES
  181. JS_ENUMERATE_NATIVE_ERRORS
  182. JS_ENUMERATE_TYPED_ARRAYS
  183. #undef __JS_ENUMERATE
  184. namespace Intl {
  185. #define __JS_ENUMERATE(ClassName, snake_name, ConstructorName, PrototypeName) \
  186. class ClassName; \
  187. class ConstructorName; \
  188. class PrototypeName;
  189. JS_ENUMERATE_INTL_OBJECTS
  190. #undef __JS_ENUMERATE
  191. };
  192. namespace Temporal {
  193. #define __JS_ENUMERATE(ClassName, snake_name, ConstructorName, PrototypeName) \
  194. class ClassName; \
  195. class ConstructorName; \
  196. class PrototypeName;
  197. JS_ENUMERATE_TEMPORAL_OBJECTS
  198. #undef __JS_ENUMERATE
  199. struct TemporalDuration;
  200. };
  201. template<typename T>
  202. class ThrowCompletionOr;
  203. template<class T>
  204. class Handle;
  205. namespace Bytecode {
  206. class BasicBlock;
  207. struct Executable;
  208. class Generator;
  209. class Instruction;
  210. class Interpreter;
  211. class Register;
  212. }
  213. }