• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef ECMASCRIPT_OBJECT_FACTORY_H
17 #define ECMASCRIPT_OBJECT_FACTORY_H
18 
19 #include "ecmascript/base/error_type.h"
20 #include "ecmascript/ecma_string.h"
21 #include "ecmascript/js_function_kind.h"
22 #include "ecmascript/js_handle.h"
23 #include "ecmascript/js_hclass.h"
24 #include "ecmascript/js_native_pointer.h"
25 #include "ecmascript/js_tagged_value.h"
26 #include "ecmascript/mem/heap_region_allocator.h"
27 #include "ecmascript/mem/machine_code.h"
28 #include "ecmascript/mem/native_area_allocator.h"
29 #include "ecmascript/tagged_array.h"
30 
31 namespace panda::ecmascript {
32 class JSObject;
33 class JSArray;
34 class JSSymbol;
35 class JSFunctionBase;
36 class JSFunction;
37 class JSBoundFunction;
38 class JSProxyRevocFunction;
39 class JSAsyncAwaitStatusFunction;
40 class JSPrimitiveRef;
41 class GlobalEnv;
42 class GlobalEnvConstants;
43 class AccessorData;
44 class JSGlobalObject;
45 class LexicalEnv;
46 class JSDate;
47 class JSProxy;
48 class JSRealm;
49 class JSArguments;
50 class TaggedQueue;
51 class JSForInIterator;
52 class JSSet;
53 class JSMap;
54 class JSRegExp;
55 class JSSetIterator;
56 class JSMapIterator;
57 class JSArrayIterator;
58 class JSStringIterator;
59 class JSGeneratorObject;
60 class CompletionRecord;
61 class GeneratorContext;
62 class JSArrayBuffer;
63 class JSDataView;
64 class JSPromise;
65 class JSPromiseReactionsFunction;
66 class JSPromiseExecutorFunction;
67 class JSPromiseAllResolveElementFunction;
68 class PromiseReaction;
69 class PromiseCapability;
70 class PromiseIteratorRecord;
71 class JSAsyncFuncObject;
72 class JSAsyncFunction;
73 class PromiseRecord;
74 class JSLocale;
75 class ResolvingFunctionsRecord;
76 class EcmaVM;
77 class Heap;
78 class ConstantPool;
79 class Program;
80 class EcmaModule;
81 class LayoutInfo;
82 class JSIntlBoundFunction;
83 class FreeObject;
84 class JSNativePointer;
85 class TSObjectType;
86 class TSClassType;
87 class TSUnionType;
88 class TSInterfaceType;
89 class TSTypeTable;
90 class TSClassInstanceType;
91 class TSImportType;
92 class TSObjLayoutInfo;
93 class TSModuleTable;
94 class JSAPIArrayList;
95 class JSAPIArrayListIterator;
96 class JSAPITreeSet;
97 class JSAPITreeMap;
98 class JSAPITreeSetIterator;
99 class JSAPITreeMapIterator;
100 class BigInt;
101 namespace job {
102 class MicroJobQueue;
103 class PendingJob;
104 }  // namespace job
105 class TransitionHandler;
106 class PrototypeHandler;
107 class PropertyBox;
108 class ProtoChangeMarker;
109 class ProtoChangeDetails;
110 class ProfileTypeInfo;
111 class MachineCode;
112 class ClassInfoExtractor;
113 
114 enum class CompletionRecordType : uint8_t;
115 enum class PrimitiveType : uint8_t;
116 enum class IterationKind : uint8_t;
117 
118 using ErrorType = base::ErrorType;
119 using base::ErrorType;
120 using DeleteEntryPoint = void (*)(void *, void *);
121 
122 enum class RemoveSlots { YES, NO };
123 class ObjectFactory {
124 public:
125     explicit ObjectFactory(JSThread *thread, Heap *heap);
126 
127     JSHandle<ProfileTypeInfo> NewProfileTypeInfo(uint32_t length);
128     JSHandle<ConstantPool> NewConstantPool(uint32_t capacity);
129     JSHandle<Program> NewProgram();
130     JSHandle<EcmaModule> NewEmptyEcmaModule();
131 
132     JSHandle<JSObject> GetJSError(const ErrorType &errorType, const char *data = nullptr);
133 
134     JSHandle<JSObject> NewJSError(const ErrorType &errorType, const JSHandle<EcmaString> &message);
135 
136     JSHandle<TransitionHandler> NewTransitionHandler();
137 
138     JSHandle<PrototypeHandler> NewPrototypeHandler();
139 
140     JSHandle<JSObject> NewEmptyJSObject();
141 
142     // use for others create, prototype is Function.prototype
143     // use for native function
144     JSHandle<JSFunction> NewJSFunction(const JSHandle<GlobalEnv> &env, const void *nativeFunc = nullptr,
145                                        FunctionKind kind = FunctionKind::NORMAL_FUNCTION);
146     // use for method
147     JSHandle<JSFunction> NewJSFunction(const JSHandle<GlobalEnv> &env, JSMethod *method,
148                                        FunctionKind kind = FunctionKind::NORMAL_FUNCTION);
149 
150     JSHandle<JSFunction> NewJSNativeErrorFunction(const JSHandle<GlobalEnv> &env, const void *nativeFunc = nullptr);
151 
152     JSHandle<JSFunction> NewSpecificTypedArrayFunction(const JSHandle<GlobalEnv> &env,
153                                                        const void *nativeFunc = nullptr);
154 
155     JSHandle<JSObject> OrdinaryNewJSObjectCreate(const JSHandle<JSTaggedValue> &proto);
156 
157     JSHandle<JSBoundFunction> NewJSBoundFunction(const JSHandle<JSFunctionBase> &target,
158                                                  const JSHandle<JSTaggedValue> &boundThis,
159                                                  const JSHandle<TaggedArray> &args);
160 
161     JSHandle<JSIntlBoundFunction> NewJSIntlBoundFunction(const void *nativeFunc = nullptr, int functionLength = 1);
162 
163     JSHandle<JSProxyRevocFunction> NewJSProxyRevocFunction(const JSHandle<JSProxy> &proxy,
164                                                            const void *nativeFunc = nullptr);
165 
166     JSHandle<JSAsyncAwaitStatusFunction> NewJSAsyncAwaitStatusFunction(const void *nativeFunc = nullptr);
167     JSHandle<JSFunction> NewJSGeneratorFunction(JSMethod *method);
168 
169     JSHandle<JSAsyncFunction> NewAsyncFunction(JSMethod *method);
170 
171     JSHandle<JSGeneratorObject> NewJSGeneratorObject(JSHandle<JSTaggedValue> generatorFunction);
172 
173     JSHandle<JSAsyncFuncObject> NewJSAsyncFuncObject();
174 
175     JSHandle<JSPrimitiveRef> NewJSPrimitiveRef(const JSHandle<JSFunction> &function,
176                                                const JSHandle<JSTaggedValue> &object);
177     JSHandle<JSPrimitiveRef> NewJSPrimitiveRef(PrimitiveType type, const JSHandle<JSTaggedValue> &object);
178 
179     // get JSHClass for Ecma ClassLinker
180     JSHandle<GlobalEnv> NewGlobalEnv(JSHClass *globalEnvClass);
181 
182     // get JSHClass for Ecma ClassLinker
183     JSHandle<LexicalEnv> NewLexicalEnv(int numSlots);
184 
185     inline LexicalEnv *InlineNewLexicalEnv(int numSlots);
186 
187     JSHandle<JSSymbol> NewJSSymbol();
188 
189     JSHandle<JSSymbol> NewPrivateSymbol();
190 
191     JSHandle<JSSymbol> NewPrivateNameSymbol(const JSHandle<JSTaggedValue> &name);
192 
193     JSHandle<JSSymbol> NewWellKnownSymbol(const JSHandle<JSTaggedValue> &name);
194 
195     JSHandle<JSSymbol> NewPublicSymbol(const JSHandle<JSTaggedValue> &name);
196 
197     JSHandle<JSSymbol> NewSymbolWithTable(const JSHandle<JSTaggedValue> &name);
198 
199     JSHandle<JSSymbol> NewPrivateNameSymbolWithChar(const char *description);
200 
201     JSHandle<JSSymbol> NewWellKnownSymbolWithChar(const char *description);
202 
203     JSHandle<JSSymbol> NewPublicSymbolWithChar(const char *description);
204 
205     JSHandle<JSSymbol> NewSymbolWithTableWithChar(const char *description);
206 
207     JSHandle<AccessorData> NewAccessorData();
208     JSHandle<AccessorData> NewInternalAccessor(void *setter, void *getter);
209 
210     JSHandle<PromiseCapability> NewPromiseCapability();
211 
212     JSHandle<PromiseReaction> NewPromiseReaction();
213 
214     JSHandle<PromiseRecord> NewPromiseRecord();
215 
216     JSHandle<ResolvingFunctionsRecord> NewResolvingFunctionsRecord();
217 
218     JSHandle<PromiseIteratorRecord> NewPromiseIteratorRecord(const JSHandle<JSTaggedValue> &itor, bool done);
219 
220     JSHandle<job::MicroJobQueue> NewMicroJobQueue();
221 
222     JSHandle<job::PendingJob> NewPendingJob(const JSHandle<JSFunction> &func, const JSHandle<TaggedArray> &argv);
223 
224     JSHandle<JSArray> NewJSArray();
225 
226     JSHandle<JSProxy> NewJSProxy(const JSHandle<JSTaggedValue> &target, const JSHandle<JSTaggedValue> &handler);
227     JSHandle<JSRealm> NewJSRealm();
228 
229     JSHandle<JSArguments> NewJSArguments();
230 
231     JSHandle<JSPrimitiveRef> NewJSString(const JSHandle<JSTaggedValue> &str);
232 
233     JSHandle<TaggedArray> NewTaggedArray(uint32_t length, JSTaggedValue initVal = JSTaggedValue::Hole());
234     JSHandle<TaggedArray> NewTaggedArray(uint32_t length, JSTaggedValue initVal, bool nonMovable);
235     JSHandle<TaggedArray> NewTaggedArray(uint32_t length, JSTaggedValue initVal, MemSpaceType spaceType);
236     JSHandle<TaggedArray> NewDictionaryArray(uint32_t length);
237     JSHandle<JSForInIterator> NewJSForinIterator(const JSHandle<JSTaggedValue> &obj);
238 
239     JSHandle<PropertyBox> NewPropertyBox(const JSHandle<JSTaggedValue> &name);
240 
241     JSHandle<ProtoChangeMarker> NewProtoChangeMarker();
242 
243     JSHandle<ProtoChangeDetails> NewProtoChangeDetails();
244     JSHandle<BigInt> NewBigInt();
245     // use for copy properties keys's array to another array
246     JSHandle<TaggedArray> ExtendArray(const JSHandle<TaggedArray> &old, uint32_t length,
247                                       JSTaggedValue initVal = JSTaggedValue::Hole());
248     JSHandle<TaggedArray> CopyPartArray(const JSHandle<TaggedArray> &old, uint32_t start, uint32_t end);
249     JSHandle<TaggedArray> CopyArray(const JSHandle<TaggedArray> &old, uint32_t oldLength, uint32_t newLength,
250                                     JSTaggedValue initVal = JSTaggedValue::Hole());
251     JSHandle<TaggedArray> CloneProperties(const JSHandle<TaggedArray> &old);
252     JSHandle<TaggedArray> CloneProperties(const JSHandle<TaggedArray> &old, const JSHandle<JSTaggedValue> &env,
253                                           const JSHandle<JSObject> &obj, const JSHandle<JSTaggedValue> &constpool);
254 
255     JSHandle<LayoutInfo> CreateLayoutInfo(int properties, JSTaggedValue initVal = JSTaggedValue::Hole());
256 
257     JSHandle<LayoutInfo> ExtendLayoutInfo(const JSHandle<LayoutInfo> &old, int properties,
258                                           JSTaggedValue initVal = JSTaggedValue::Hole());
259 
260     JSHandle<LayoutInfo> CopyLayoutInfo(const JSHandle<LayoutInfo> &old);
261 
262     JSHandle<LayoutInfo> CopyAndReSort(const JSHandle<LayoutInfo> &old, int end, int capacity);
263 
264     JSHandle<EcmaString> GetEmptyString() const;
265 
266     JSHandle<TaggedArray> EmptyArray() const;
267 
268     FreeObject *FillFreeObject(uintptr_t address, size_t size, RemoveSlots removeSlots = RemoveSlots::NO);
269 
270     TaggedObject *NewDynObject(const JSHandle<JSHClass> &dynclass);
271 
272     TaggedObject *NewNonMovableDynObject(const JSHandle<JSHClass> &dynclass, int inobjPropCount = 0);
273 
274     void InitializeExtraProperties(const JSHandle<JSHClass> &dynclass, TaggedObject *obj, int inobjPropCount);
275 
276     JSHandle<TaggedQueue> NewTaggedQueue(uint32_t length);
277 
278     JSHandle<TaggedQueue> GetEmptyTaggedQueue() const;
279 
280     JSHandle<JSSetIterator> NewJSSetIterator(const JSHandle<JSSet> &set, IterationKind kind);
281 
282     JSHandle<JSMapIterator> NewJSMapIterator(const JSHandle<JSMap> &map, IterationKind kind);
283 
284     JSHandle<JSArrayIterator> NewJSArrayIterator(const JSHandle<JSObject> &array, IterationKind kind);
285 
286     JSHandle<CompletionRecord> NewCompletionRecord(CompletionRecordType type, JSHandle<JSTaggedValue> value);
287 
288     JSHandle<GeneratorContext> NewGeneratorContext();
289 
290     JSHandle<JSPromiseReactionsFunction> CreateJSPromiseReactionsFunction(const void *nativeFunc);
291 
292     JSHandle<JSPromiseExecutorFunction> CreateJSPromiseExecutorFunction(const void *nativeFunc);
293 
294     JSHandle<JSPromiseAllResolveElementFunction> NewJSPromiseAllResolveElementFunction(const void *nativeFunc);
295 
296     JSHandle<JSObject> CloneObjectLiteral(JSHandle<JSObject> object, const JSHandle<JSTaggedValue> &env,
297                                           const JSHandle<JSTaggedValue> &constpool, bool canShareHClass = true);
298     JSHandle<JSObject> CloneObjectLiteral(JSHandle<JSObject> object);
299     JSHandle<JSArray> CloneArrayLiteral(JSHandle<JSArray> object);
300     JSHandle<JSFunction> CloneJSFuction(JSHandle<JSFunction> obj, FunctionKind kind);
301     JSHandle<JSFunction> CloneClassCtor(JSHandle<JSFunction> ctor, const JSHandle<JSTaggedValue> &lexenv,
302                                         bool canShareHClass);
303 
304     void NewJSArrayBufferData(const JSHandle<JSArrayBuffer> &array, int32_t length);
305 
306     JSHandle<JSArrayBuffer> NewJSArrayBuffer(int32_t length);
307 
308     JSHandle<JSArrayBuffer> NewJSArrayBuffer(void *buffer, int32_t length, const DeleteEntryPoint &deleter, void *data,
309                                              bool share = false);
310 
311     JSHandle<JSDataView> NewJSDataView(JSHandle<JSArrayBuffer> buffer, uint32_t offset, uint32_t length);
312 
313     void NewJSRegExpByteCodeData(const JSHandle<JSRegExp> &regexp, void *buffer, size_t size);
314 
315     template<typename T, typename S>
316     inline void NewJSIntlIcuData(const JSHandle<T> &obj, const S &icu, const DeleteEntryPoint &callback);
317 
318     EcmaString *InternString(const JSHandle<JSTaggedValue> &key);
319 
320     inline JSHandle<JSNativePointer> NewJSNativePointer(void *externalPointer,
321                                                         const DeleteEntryPoint &callBack = nullptr,
322                                                         void *data = nullptr,
323                                                         bool nonMovable = false);
324 
325     JSHandle<JSObject> NewJSObjectByClass(const JSHandle<TaggedArray> &properties, size_t length);
326 
327     // only use for creating Function.prototype and Function
328     JSHandle<JSFunction> NewJSFunctionByDynClass(JSMethod *method, const JSHandle<JSHClass> &clazz,
329                                                  FunctionKind kind = FunctionKind::NORMAL_FUNCTION);
330     EcmaString *ResolveString(uint32_t stringId);
331 
332     // used for creating jsobject by constructor
333     JSHandle<JSObject> NewJSObjectByConstructor(const JSHandle<JSFunction> &constructor,
334                                                 const JSHandle<JSTaggedValue> &newTarget);
335 
336     uintptr_t NewSpaceBySnapShotAllocator(size_t size);
337     JSHandle<MachineCode> NewMachineCodeObject(size_t length, const uint8_t *data);
338     JSHandle<ClassInfoExtractor> NewClassInfoExtractor(JSMethod *ctorMethod);
339 
340     // ----------------------------------- new TSType ----------------------------------------
341     JSHandle<TSObjLayoutInfo> CreateTSObjLayoutInfo(int propNum, JSTaggedValue initVal = JSTaggedValue::Hole());
342     JSHandle<TSObjectType> NewTSObjectType(uint32_t numOfKeys);
343     JSHandle<TSClassType> NewTSClassType();
344     JSHandle<TSUnionType> NewTSUnionType(uint32_t length);
345     JSHandle<TSInterfaceType> NewTSInterfaceType();
346     JSHandle<TSImportType> NewTSImportType();
347     JSHandle<TSClassInstanceType> NewTSClassInstanceType();
348     JSHandle<TSTypeTable> NewTSTypeTable(uint32_t length);
349     JSHandle<TSModuleTable> NewTSModuleTable(uint32_t length);
350 
351     ~ObjectFactory() = default;
352 
353     // ----------------------------------- new string ----------------------------------------
354     JSHandle<EcmaString> NewFromString(const CString &data);
355     JSHandle<EcmaString> NewFromCanBeCompressString(const CString &data);
356 
357     JSHandle<EcmaString> NewFromStdString(const std::string &data);
358     JSHandle<EcmaString> NewFromStdStringUnCheck(const std::string &data, bool canBeCompress);
359 
360     JSHandle<EcmaString> NewFromUtf8(const CString &data);
361     JSHandle<EcmaString> NewFromUtf8(const uint8_t *utf8Data, uint32_t utf8Len);
362     JSHandle<EcmaString> NewFromUtf8UnCheck(const uint8_t *utf8Data, uint32_t utf8Len, bool canBeCompress);
363 
364     JSHandle<EcmaString> NewFromUtf16(const uint16_t *utf16Data, uint32_t utf16Len);
365     JSHandle<EcmaString> NewFromUtf16UnCheck(const uint16_t *utf16Data, uint32_t utf16Len, bool canBeCompress);
366 
367     JSHandle<EcmaString> NewFromUtf8Literal(const uint8_t *utf8Data, uint32_t utf8Len);
368     JSHandle<EcmaString> NewFromUtf8LiteralUnCheck(const uint8_t *utf8Data, uint32_t utf8Len, bool canBeCompress);
369 
370     JSHandle<EcmaString> NewFromUtf16Literal(const uint16_t *utf16Data, uint32_t utf16Len);
371     JSHandle<EcmaString> NewFromUtf16LiteralUnCheck(const uint16_t *utf16Data, uint32_t utf16Len, bool canBeCompress);
372 
373     JSHandle<EcmaString> NewFromString(EcmaString *str);
374     JSHandle<EcmaString> ConcatFromString(const JSHandle<EcmaString> &firstString,
375                                           const JSHandle<EcmaString> &secondString);
376 
377     // used for creating Function
378     JSHandle<JSObject> NewJSObject(const JSHandle<JSHClass> &jshclass);
379 
380     // used for creating jshclass in Builtins, Function, Class_Linker
381     JSHandle<JSHClass> NewEcmaDynClass(uint32_t size, JSType type, const JSHandle<JSTaggedValue> &prototype);
382 
383     // It is used to provide iterators for non ECMA standard jsapi containers.
384     JSHandle<JSAPIArrayList> NewJSAPIArrayList(uint32_t capacity);
385     JSHandle<JSAPIArrayListIterator> NewJSAPIArrayListIterator(const JSHandle<JSAPIArrayList> &arrayList);
386     JSHandle<JSAPITreeMapIterator> NewJSAPITreeMapIterator(const JSHandle<JSAPITreeMap> &map, IterationKind kind);
387     JSHandle<JSAPITreeSetIterator> NewJSAPITreeSetIterator(const JSHandle<JSAPITreeSet> &set, IterationKind kind);
388 
389 private:
390     friend class GlobalEnv;
391     friend class GlobalEnvConstants;
392     friend class EcmaString;
393     JSHandle<JSFunction> NewJSFunctionImpl(JSMethod *method);
394 
395     void InitObjectFields(const TaggedObject *object);
396 
397     JSThread *thread_ {nullptr};
398     bool isTriggerGc_ {false};
399     bool triggerSemiGC_ {false};
400 
401     EcmaVM *vm_ {nullptr};
402     Heap *heap_ {nullptr};
403 
404     NO_COPY_SEMANTIC(ObjectFactory);
405     NO_MOVE_SEMANTIC(ObjectFactory);
406 
407     void NewObjectHook() const;
408 
409     // used for creating jshclass in Builtins, Function, Class_Linker
410     JSHandle<JSHClass> NewEcmaDynClass(uint32_t size, JSType type,
411                                        uint32_t inlinedProps = JSHClass::DEFAULT_CAPACITY_OF_IN_OBJECTS);
412     // used for creating jshclass in GlobalEnv, EcmaVM
413     JSHandle<JSHClass> NewEcmaDynClassClass(JSHClass *hclass, uint32_t size, JSType type);
414     JSHandle<JSHClass> NewEcmaDynClass(JSHClass *hclass, uint32_t size, JSType type,
415                                        uint32_t inlinedProps = JSHClass::DEFAULT_CAPACITY_OF_IN_OBJECTS);
416 
417     // used to create nonmovable js_object
418     JSHandle<JSObject> NewNonMovableJSObject(const JSHandle<JSHClass> &jshclass);
419 
420     // used for creating Function
421     JSHandle<JSFunction> NewJSFunction(const JSHandle<GlobalEnv> &env, const JSHandle<JSHClass> &dynKlass);
422     JSHandle<JSHClass> CreateObjectClass(const JSHandle<TaggedArray> &properties, size_t length);
423     JSHandle<JSHClass> CreateFunctionClass(FunctionKind kind, uint32_t size, JSType type,
424                                            const JSHandle<JSTaggedValue> &prototype);
425 
426     // used for creating ref.prototype in buildins, such as Number.prototype
427     JSHandle<JSPrimitiveRef> NewJSPrimitiveRef(const JSHandle<JSHClass> &dynKlass,
428                                                const JSHandle<JSTaggedValue> &object);
429 
430     JSHandle<EcmaString> GetStringFromStringTable(const uint8_t *utf8Data, uint32_t utf8Len, bool canBeCompress) const;
431     // For MUtf-8 string data
432     EcmaString *GetRawStringFromStringTable(const uint8_t *mutf8Data, uint32_t utf16Len, bool canBeCompressed) const;
433 
434     JSHandle<EcmaString> GetStringFromStringTable(const uint16_t *utf16Data, uint32_t utf16Len,
435                                                   bool canBeCompress) const;
436 
437     JSHandle<EcmaString> GetStringFromStringTable(EcmaString *string) const;
438 
439     JSHandle<EcmaString> GetStringFromStringTable(const JSHandle<EcmaString> &firstString,
440                                                   const JSHandle<EcmaString> &secondString);
441 
442     inline EcmaString *AllocStringObject(size_t size);
443     inline EcmaString *AllocNonMovableStringObject(size_t size);
444     JSHandle<TaggedArray> NewEmptyArray();  // only used for EcmaVM.
445 
446     JSHandle<JSHClass> CreateJSArguments();
447     JSHandle<JSHClass> CreateJSArrayInstanceClass(JSHandle<JSTaggedValue> proto);
448     JSHandle<JSHClass> CreateJSRegExpInstanceClass(JSHandle<JSTaggedValue> proto);
449 
450     friend class Builtins;    // create builtins object need dynclass
451     friend class JSFunction;  // create prototype_or_dynclass need dynclass
452     friend class JSHClass;    // HC transition need dynclass
453     friend class EcmaVM;      // hold the factory instance
454     friend class JsVerificationTest;
455     friend class PandaFileTranslator;
456     friend class LiteralDataExtractor;
457     friend class RuntimeTrampolines;
458     friend class ClassInfoExtractor;
459     friend class TSObjectType;
460     friend class TSClassType;
461     friend class TSUnionType;
462     friend class TSClassInstanceType;
463     friend class TSImportType;
464 };
465 
466 class ClassLinkerFactory {
467 private:
468     friend class GlobalEnv;  // root class in class_linker need dynclass
469     friend class EcmaVM;     // root class in class_linker need dynclass
470 };
471 }  // namespace panda::ecmascript
472 #endif  // ECMASCRIPT_OBJECT_FACTORY_H
473