Forward.h 13 KB

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