• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2021-2022 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 ES2PANDA_COMPILER_CORE_PANDAGEN_H
17 #define ES2PANDA_COMPILER_CORE_PANDAGEN_H
18 
19 #include <compiler/base/optionalChain.h>
20 #include <compiler/core/envScope.h>
21 #include <compiler/core/inlineCache.h>
22 #include <compiler/core/regAllocator.h>
23 #include <compiler/core/regScope.h>
24 #include <ir/irnode.h>
25 #include <lexer/token/tokenType.h>
26 #include <libpandafile/file_items.h>
27 #include <macros.h>
28 
29 #include <regex>
30 
31 namespace panda::es2panda::binder {
32 class FunctionScope;
33 class ModuleVaribale;
34 class ScopeFindResult;
35 class Scope;
36 }  // namespace panda::es2panda::binder
37 
38 namespace panda::es2panda::ir {
39 class AstNode;
40 class ScriptFunction;
41 class Statement;
42 class Expression;
43 class Identifier;
44 }  // namespace panda::es2panda::ir
45 
46 namespace panda::es2panda::compiler {
47 
48 class FunctionBuilder;
49 class CompilerContext;
50 class LiteralBuffer;
51 class DynamicContext;
52 class CatchTable;
53 
54 enum class Constant {
55     JS_NAN,
56     JS_HOLE,
57     JS_INFINITY,
58     JS_UNDEFINED,
59     JS_NULL,
60     JS_TRUE,
61     JS_FALSE,
62     JS_SYMBOL,
63     JS_GLOBAL,
64 };
65 
66 class DebugInfo {
67 public:
DebugInfo(ArenaAllocator * allocator)68     explicit DebugInfo(ArenaAllocator *allocator) : variableDebugInfo(allocator->Adapter()) {};
69     DEFAULT_COPY_SEMANTIC(DebugInfo);
70     DEFAULT_MOVE_SEMANTIC(DebugInfo);
71     ~DebugInfo() = default;
72 
73     ArenaVector<const binder::Scope *> variableDebugInfo;
74     const ir::Statement *firstStmt {};
75 };
76 
77 class PandaGen {
78 public:
PandaGen(ArenaAllocator * allocator,CompilerContext * context,binder::FunctionScope * scope)79     explicit PandaGen(ArenaAllocator *allocator, CompilerContext *context, binder::FunctionScope *scope)
80         : allocator_(allocator),
81           context_(context),
82           builder_(nullptr),
83           debugInfo_(allocator_),
84           topScope_(scope),
85           scope_(topScope_),
86           rootNode_(scope->Node()),
87           insns_(allocator_->Adapter()),
88           typedInsns_(allocator_->Adapter()),
89           typedVars_(allocator_->Adapter()),
90           catchList_(allocator_->Adapter()),
91           strings_(allocator_->Adapter()),
92           buffStorage_(allocator_->Adapter()),
93           ra_(this)
94     {
95     }
96     ~PandaGen() = default;
97     NO_COPY_SEMANTIC(PandaGen);
98     NO_MOVE_SEMANTIC(PandaGen);
99 
Allocator()100     inline ArenaAllocator *Allocator() const
101     {
102         return allocator_;
103     }
104 
Context()105     inline CompilerContext *Context() const
106     {
107         return context_;
108     }
109 
Strings()110     const ArenaSet<util::StringView> &Strings() const
111     {
112         return strings_;
113     }
114 
CatchList()115     const ArenaVector<CatchTable *> &CatchList() const
116     {
117         return catchList_;
118     }
119 
TopScope()120     binder::FunctionScope *TopScope() const
121     {
122         return topScope_;
123     }
124 
Scope()125     binder::Scope *Scope() const
126     {
127         return scope_;
128     }
129 
RootNode()130     const ir::AstNode *RootNode() const
131     {
132         return rootNode_;
133     }
134 
Insns()135     ArenaList<IRNode *> &Insns()
136     {
137         return insns_;
138     }
139 
Insns()140     const ArenaList<IRNode *> &Insns() const
141     {
142         return insns_;
143     }
144 
SetInsns(ArenaList<IRNode * > & newInsns)145     void SetInsns(ArenaList<IRNode *> &newInsns)
146     {
147         insns_.assign(newInsns.begin(), newInsns.end());
148     }
149 
TypedInsns()150     ArenaMap<const IRNode *, int64_t> &TypedInsns()
151     {
152         return typedInsns_;
153     }
154 
TypedInsns()155     const ArenaMap<const IRNode *, int64_t> &TypedInsns() const
156     {
157         return typedInsns_;
158     }
159 
TypedVars()160     ArenaUnorderedSet<const binder::LocalVariable *> &TypedVars()
161     {
162         return typedVars_;
163     }
164 
TypedVars()165     const ArenaUnorderedSet<const binder::LocalVariable *> &TypedVars() const
166     {
167         return typedVars_;
168     }
169 
TypedFunc()170     std::pair<int64_t, int64_t> &TypedFunc()
171     {
172         return typedFunc_;
173     }
174 
TypedFunc()175     const std::pair<int64_t, int64_t> &TypedFunc() const
176     {
177         return typedFunc_;
178     }
179 
AllocReg()180     VReg AllocReg()
181     {
182         if (usedRegs_ > UINT16_MAX) {
183             throw Error(ErrorType::GENERIC, "Can't alloc new reg because all regs ran out");
184         }
185         return usedRegs_++;
186     }
187 
NextReg()188     VReg NextReg() const
189     {
190         return usedRegs_;
191     }
192 
TotalRegsNum()193     uint32_t TotalRegsNum() const
194     {
195         return totalRegs_;
196     }
197 
LabelCount()198     size_t LabelCount() const
199     {
200         return labelId_;
201     }
202 
Debuginfo()203     const DebugInfo &Debuginfo() const
204     {
205         return debugInfo_;
206     }
207 
FuncBuilder()208     FunctionBuilder *FuncBuilder() const
209     {
210         return builder_;
211     }
212 
GetEnvScope()213     EnvScope *GetEnvScope() const
214     {
215         return envScope_;
216     }
217 
BuffStorage()218     const ArenaVector<compiler::LiteralBuffer *> &BuffStorage() const
219     {
220         return buffStorage_;
221     }
222 
GetOptionalChain()223     OptionalChain *GetOptionalChain() const
224     {
225         return optionalChain_;
226     }
227 
IcSize()228     uint32_t IcSize() const
229     {
230         return ic_.Size();
231     }
232 
SetSourceLocationFlag(lexer::SourceLocationFlag flag)233     void SetSourceLocationFlag(lexer::SourceLocationFlag flag)
234     {
235         ra_.SetSourceLocationFlag(flag);
236     }
237 
AdjustSpillInsns()238     void AdjustSpillInsns()
239     {
240         ra_.AdjustInsRegWhenHasSpill();
241         totalRegs_ += ra_.GetSpillRegsCount();
242     }
243 
GetSpillRegsCount()244     uint16_t GetSpillRegsCount() const
245     {
246         if (ra_.HasSpill()) {
247             return ra_.GetSpillRegsCount();
248         }
249         return 0;
250     }
251 
GetFunctionKind()252     panda::panda_file::FunctionKind GetFunctionKind() const
253     {
254         return funcKind_;
255     }
256 
IsConcurrent()257     bool IsConcurrent() const
258     {
259         return funcKind_ == panda::panda_file::FunctionKind::CONCURRENT_FUNCTION;
260     }
261 
262     void SetFunctionKind();
263 
264     bool IsDebug() const;
265     bool IsDebuggerEvaluateExpressionMode() const;
266     std::string SourceFile() const;
267     uint32_t ParamCount() const;
268     uint32_t FormalParametersCount() const;
269     uint32_t InternalParamCount() const;
270     const util::StringView &InternalName() const;
271     const util::StringView &FunctionName() const;
272     binder::Binder *Binder() const;
273 
274     Label *AllocLabel();
275 
276     bool FunctionHasFinalizer() const;
277     bool IsAsyncFunction() const;
278     void FunctionInit(CatchTable* catchTable);
279     void FunctionEnter();
280     void FunctionExit();
281 
282     LiteralBuffer *NewLiteralBuffer();
283     int32_t AddLiteralBuffer(LiteralBuffer *buf);
284     int32_t AddLexicalVarNamesForDebugInfo(ArenaMap<uint32_t, std::pair<util::StringView, int>> &lexicalVars);
285 
286     void InitializeLexEnv(const ir::AstNode *node);
287     void CopyFunctionArguments(const ir::AstNode *node);
288     void GetFunctionObject(const ir::AstNode *node);
289     void GetNewTarget(const ir::AstNode *node);
290     void GetThis(const ir::AstNode *node);
291     void SetThis(const ir::AstNode *node);
292     void LoadVar(const ir::Identifier *node, const binder::ScopeFindResult &result);
293     void StoreVar(const ir::AstNode *node, const binder::ScopeFindResult &result, bool isDeclaration);
294 
295     void StLetOrClassToGlobalRecord(const ir::AstNode *node, const util::StringView &name);
296     void StConstToGlobalRecord(const ir::AstNode *node, const util::StringView &name);
297 
298     void StoreAccumulator(const ir::AstNode *node, VReg vreg);
299     void StoreAccumulatorWithType(const ir::AstNode *node, int64_t typeIndex, VReg vreg);
300     void LoadAccFromArgs(const ir::AstNode *node);
301     void LoadObjProperty(const ir::AstNode *node, VReg obj, const Operand &prop);
302 
303     void LoadObjByName(const ir::AstNode *node, VReg obj, const util::StringView &prop);
304 
305     void StoreObjProperty(const ir::AstNode *node, VReg obj, const Operand &prop);
306     void DefineClassField(const ir::AstNode *node, VReg obj, const Operand &prop);
307     void DefineClassPrivateField(const ir::AstNode *node, uint32_t level, uint32_t slot, VReg obj);
308     void StoreOwnProperty(const ir::AstNode *node, VReg obj, const Operand &prop, bool nameSetting = false);
309     void DeleteObjProperty(const ir::AstNode *node, VReg obj, const Operand &prop);
310     void LoadAccumulator(const ir::AstNode *node, VReg reg);
311     void LoadGlobalVar(const ir::AstNode *node, const util::StringView &name);
312     void StoreGlobalVar(const ir::AstNode *node, const util::StringView &name);
313 
314     void TryLoadGlobalByValue(const ir::AstNode *node, VReg key);
315     void TryStoreGlobalByValue(const ir::AstNode *node, VReg key);
316     void LoadObjByNameViaDebugger(const ir::AstNode *node, const util::StringView &name, bool throwUndefinedIfHole);
317     void TryLoadGlobalByName(const ir::AstNode *node, const util::StringView &name);
318     void StoreObjByNameViaDebugger(const ir::AstNode *node, const util::StringView &name);
319     void TryStoreGlobalByName(const ir::AstNode *node, const util::StringView &name);
320 
321     void LoadAccFromLexEnv(const ir::AstNode *node, const binder::ScopeFindResult &result);
322     void StoreAccToLexEnv(const ir::AstNode *node, const binder::ScopeFindResult &result, bool isDeclaration);
323 
324     void LoadAccumulatorString(const ir::AstNode *node, const util::StringView &str);
325     void LoadAccumulatorFloat(const ir::AstNode *node, double num);
326     void LoadAccumulatorInt(const ir::AstNode *node, int32_t num);
327     void LoadAccumulatorInt(const ir::AstNode *node, size_t num);
328     void LoadAccumulatorBigInt(const ir::AstNode *node, const util::StringView &num);
329 
330     void LoadConst(const ir::AstNode *node, Constant id);
331     void StoreConst(const ir::AstNode *node, VReg reg, Constant id);
332     void MoveVreg(const ir::AstNode *node, VReg vd, VReg vs);
333 
334     void SetLabel(const ir::AstNode *node, Label *label);
335     void Branch(const ir::AstNode *node, class Label *label);
336     bool CheckControlFlowChange() const;
337     Label *ControlFlowChangeBreak(const ir::Identifier *label = nullptr);
338     Label *ControlFlowChangeContinue(const ir::Identifier *label);
339     void ControlFlowChangeReturn();
340 
341     void Condition(const ir::AstNode *node, lexer::TokenType op, VReg lhs, class Label *ifFalse);
342     void Unary(const ir::AstNode *node, lexer::TokenType op, VReg operand);
343     void Binary(const ir::AstNode *node, lexer::TokenType op, VReg lhs);
344     void Equal(const ir::AstNode *node, VReg lhs);
345     void NotEqual(const ir::AstNode *node, VReg lhs);
346     void StrictEqual(const ir::AstNode *node, VReg lhs);
347     void StrictNotEqual(const ir::AstNode *node, VReg lhs);
348     void LessThan(const ir::AstNode *node, VReg lhs);
349     void LessEqual(const ir::AstNode *node, VReg lhs);
350     void GreaterThan(const ir::AstNode *node, VReg lhs);
351     void GreaterEqual(const ir::AstNode *node, VReg lhs);
352     void IsTrue(const ir::AstNode *node);
353 
354     void BranchIfUndefined(const ir::AstNode *node, class Label *target);
355     void BranchIfStrictUndefined(const ir::AstNode *node, class Label *target);
356     void BranchIfStrictNotUndefined(const ir::AstNode *node, class Label *target);
357     void BranchIfNotUndefined(const ir::AstNode *node, class Label *target);
358     void BranchIfHole(const ir::AstNode *node, class Label *target);
359     void BranchIfTrue(const ir::AstNode *node, class Label *target);
360     void BranchIfNotTrue(const ir::AstNode *node, class Label *target);
361     void BranchIfFalse(const ir::AstNode *node, class Label *target);
362     void BranchIfNotFalse(const ir::AstNode *node, class Label *target);
363     void BranchIfStrictNull(const ir::AstNode *node, class Label *target);
364 
365     void EmitThrow(const ir::AstNode *node);
366     void EmitRethrow(const ir::AstNode *node);
367     void EmitReturn(const ir::AstNode *node);
368     void EmitReturnUndefined(const ir::AstNode *node);
369     void ValidateClassDirectReturn(const ir::AstNode *node);
370     void DirectReturn(const ir::AstNode *node);
371     void ExplicitReturn(const ir::AstNode *node);
372     void ImplicitReturn(const ir::AstNode *node);
373     void EmitAwait(const ir::AstNode *node);
374 
375     void CallThis(const ir::AstNode *node, VReg startReg, size_t argCount);
376     void Call(const ir::AstNode *node, VReg startReg, size_t argCount);
377     void CallSpread(const ir::AstNode *node, VReg func, VReg thisReg, VReg args);
378     void SuperCall(const ir::AstNode *node, VReg startReg, size_t argCount);
379     void SuperCallSpread(const ir::AstNode *node, VReg vs);
380     void NotifyConcurrentResult(const ir::AstNode *node);
381     void CallInit(const ir::AstNode *node, VReg thisReg);
382 
383     void NewObject(const ir::AstNode *node, VReg startReg, size_t argCount);
384     void DefineFunction(const ir::AstNode *node, const ir::ScriptFunction *realNode, const util::StringView &name);
385 
386     void TypeOf(const ir::AstNode *node);
387     void NewObjSpread(const ir::AstNode *node, VReg obj);
388     void GetUnmappedArgs(const ir::AstNode *node);
389 
390     void Negate(const ir::AstNode *node);
391     void ToNumber(const ir::AstNode *node, VReg arg);
392     void ToNumeric(const ir::AstNode *node, VReg arg);
393 
394     void CreateGeneratorObj(const ir::AstNode *node, VReg funcObj);
395     void ResumeGenerator(const ir::AstNode *node, VReg genObj);
396     void GetResumeMode(const ir::AstNode *node, VReg genObj);
397 
398     void AsyncFunctionEnter(const ir::AstNode *node);
399     void AsyncFunctionAwait(const ir::AstNode *node, VReg asyncFuncObj);
400     void AsyncFunctionResolve(const ir::AstNode *node, VReg asyncFuncObj);
401     void AsyncFunctionReject(const ir::AstNode *node, VReg asyncFuncObj);
402 
403     void GeneratorYield(const ir::AstNode *node, VReg genObj);
404     void GeneratorComplete(const ir::AstNode *node, VReg genObj);
405     void CreateAsyncGeneratorObj(const ir::AstNode *node, VReg funcObj);
406     void CreateIterResultObject(const ir::AstNode *node, VReg value, VReg done);
407     void SuspendGenerator(const ir::AstNode *node, VReg genObj);
408     void SuspendAsyncGenerator(const ir::AstNode *node, VReg asyncGenObj);
409 
410     void AsyncGeneratorResolve(const ir::AstNode *node, VReg asyncGenObj, VReg value, VReg canSuspend);
411     void AsyncGeneratorReject(const ir::AstNode *node, VReg asyncGenObj);
412 
413     void GetTemplateObject(const ir::AstNode *node, VReg value);
414     void CopyRestArgs(const ir::AstNode *node, uint32_t index);
415 
416     void GetPropIterator(const ir::AstNode *node);
417     void GetNextPropName(const ir::AstNode *node, VReg iter);
418     void CreateEmptyObject(const ir::AstNode *node);
419     void CreateObjectWithBuffer(const ir::AstNode *node, uint32_t idx);
420     void SetObjectWithProto(const ir::AstNode *node, VReg proto, VReg obj);
421     void CopyDataProperties(const ir::AstNode *node, VReg dst);
422     void DefineGetterSetterByValue(const ir::AstNode *node, VReg obj, VReg name, VReg getter, VReg setter,
423                                    bool setName);
424     void CreateEmptyArray(const ir::AstNode *node);
425     void CreateArray(const ir::AstNode *node, const ArenaVector<ir::Expression *> &elements, VReg obj);
426     void CreateArrayWithBuffer(const ir::AstNode *node, uint32_t idx);
427     void StoreArraySpread(const ir::AstNode *node, VReg array, VReg index);
428 
429     void ThrowIfNotObject(const ir::AstNode *node, VReg obj);
430     void ThrowThrowNotExist(const ir::AstNode *node);
431     void GetIterator(const ir::AstNode *node);
432     void GetAsyncIterator(const ir::AstNode *node);
433 
434     void CreateObjectWithExcludedKeys(const ir::AstNode *node, VReg obj, VReg argStart, size_t argCount);
435     void ThrowObjectNonCoercible(const ir::AstNode *node);
436     void CloseIterator(const ir::AstNode *node, VReg iter);
437     void DefineClassWithBuffer(const ir::AstNode *node, const util::StringView &ctorId, int32_t litIdx, VReg base);
438     void DefineSendableClass(const ir::AstNode *node, const util::StringView &ctorId,
439                              int32_t litIdx, VReg base);
440     void LoadSendableClass(const ir::AstNode *node, int32_t level);
441 
442     void LoadLocalModuleVariable(const ir::AstNode *node, const binder::ModuleVariable *variable);
443     void LoadExternalModuleVariable(const ir::AstNode *node, const binder::ModuleVariable *variable);
444     void StoreModuleVariable(const ir::AstNode *node, const binder::ModuleVariable *variable);
445     void GetModuleNamespace(const ir::AstNode *node, uint32_t index);
446     void DynamicImportCall(const ir::AstNode *node);
447 
448     void StSuperByName(const ir::AstNode *node, VReg obj, const util::StringView &key);
449     void LdSuperByName(const ir::AstNode *node, VReg obj, const util::StringView &key);
450     void StSuperByValue(const ir::AstNode *node, VReg obj, VReg prop);
451     void LdSuperByValue(const ir::AstNode *node, VReg obj);
452     void StoreSuperProperty(const ir::AstNode *node, VReg obj, const Operand &prop);
453     void LoadSuperProperty(const ir::AstNode *node, VReg obj, const Operand &prop);
454 
455     void PopLexEnv(const ir::AstNode *node);
456     void GenDebugger(const ir::AstNode *node);
457     void CopyLexEnv(const ir::AstNode *node);
458     void NewLexicalEnv(const ir::AstNode *node, uint32_t num, binder::VariableScope *scope);
459     void NewLexEnv(const ir::AstNode *node, uint32_t num);
460     void NewLexEnvWithScopeInfo(const ir::AstNode *node, uint32_t num, int32_t scopeInfoIdx);
461     void LoadLexicalVar(const ir::AstNode *node, uint32_t level, uint32_t slot);
462     void LoadLexicalVar(const ir::AstNode *node, uint32_t level, uint32_t slot, const util::StringView &name);
463     void StoreLexicalVar(const ir::AstNode *node, uint32_t level, uint32_t slot);
464     void StoreLexicalVar(const ir::AstNode *node, uint32_t level, uint32_t slot, const binder::LocalVariable *local);
465     void StoreLexicalVar(const ir::AstNode *node, uint32_t level, uint32_t slot, VReg value);
466 
467     void ThrowIfSuperNotCorrectCall(const ir::AstNode *node, int64_t num);
468     void ThrowUndefinedIfHole(const ir::AstNode *node, const util::StringView &name);
469     void ThrowConstAssignment(const ir::AstNode *node, const util::StringView &name);
470 
471     uint32_t TryDepth() const;
472     CatchTable *CreateCatchTable();
473     void SortCatchTables();
474 
475     void LoadObjByIndex(const ir::AstNode *node, VReg obj, int64_t index);
476     void LoadObjByValue(const ir::AstNode *node, VReg obj);
477 
478     void StoreObjByName(const ir::AstNode *node, VReg obj, const util::StringView &prop);
479     void StoreObjByIndex(const ir::AstNode *node, VReg obj, int64_t index);
480     void StoreObjByValue(const ir::AstNode *node, VReg obj, VReg prop);
481 
482     void DefineFieldByName(const ir::AstNode *node, VReg obj, const util::StringView &prop);
483     void DefineFieldByIndex(const ir::AstNode *node, VReg obj, int64_t index);
484     void DefineFieldByValue(const ir::AstNode *node, VReg obj, VReg prop);
485 
486     void StOwnByName(const ir::AstNode *node, VReg obj, const util::StringView &prop, bool nameSetting = false);
487     void StOwnByValue(const ir::AstNode *node, VReg obj, VReg prop, bool nameSetting = false);
488     void StOwnByIndex(const ir::AstNode *node, VReg obj, int64_t index);
489 
490     Operand ToNamedPropertyKey(const ir::Expression *prop, bool isComputed);
491     Operand ToPropertyKey(const ir::Expression *prop, bool isComputed);
492     VReg LoadPropertyKey(const ir::Expression *prop, bool isComputed);
493     void ToComputedPropertyKey(const ir::AstNode *node);
494 
495     void ReArrangeIc();
496 
497     void CreatePrivateProperty(const ir::AstNode *node, uint32_t num, int32_t bufIdx);
498     void TestIn(const ir::AstNode *node, uint32_t level, uint32_t slot);
499     void LoadPrivateProperty(const ir::AstNode *node, uint32_t level, uint32_t slot);
500     void StorePrivateProperty(const ir::AstNode *node, uint32_t level, uint32_t slot, VReg obj);
501     void ThrowTypeErrorIfFalse(const ir::AstNode *node, util::StringView str);
502     void ThrowTypeError(const ir::AstNode *node, util::StringView str);
503 
504     /*
505      * Since the [Function] is not implemented yet, We compile the test262's framework code
506      * which obtains the [global] Object as following into [LoadConst.Global] directly.
507      * ```
508      *    var __globalObject = Function("return this;")();
509      *    var __globalObject = new Function("return this;")();
510      * ```
511      */
512     bool TryCompileFunctionCallOrNewExpression(const ir::Expression *expr);
513 
SetFirstStmt(const ir::Statement * stmt)514     void SetFirstStmt(const ir::Statement *stmt)
515     {
516         debugInfo_.firstStmt = stmt;
517     }
518 
Unimplemented()519     [[noreturn]] static void Unimplemented()
520     {
521         throw Error(ErrorType::GENERIC, "Unimplemented code path");
522     }
523 
GetCurrentSlot()524     IcSizeType GetCurrentSlot() const
525     {
526         return currentSlot_;
527     }
528 
IncreaseCurrentSlot(ICSlot inc)529     void IncreaseCurrentSlot(ICSlot inc)
530     {
531         currentSlot_ += inc;
532     }
533 
ResetCurrentSlot(IcSizeType slotSize)534     void ResetCurrentSlot(IcSizeType slotSize)
535     {
536         currentSlot_ = slotSize;
537     }
538 
SetIcOverFlow()539     void SetIcOverFlow()
540     {
541         icOverFlow_ = true;
542     }
543 
IsIcOverFlow()544     bool IsIcOverFlow() const
545     {
546         return icOverFlow_;
547     }
548 
549 private:
550     ArenaAllocator *allocator_;
551     CompilerContext *context_;
552     FunctionBuilder *builder_;
553     DebugInfo debugInfo_;
554     binder::FunctionScope *topScope_;
555     binder::Scope *scope_;
556     const ir::AstNode *rootNode_;
557     ArenaList<IRNode *> insns_;
558     ArenaMap<const IRNode *, int64_t> typedInsns_;
559     ArenaUnorderedSet<const binder::LocalVariable *> typedVars_;
560     std::pair<int64_t, int64_t> typedFunc_ {};
561     ArenaVector<CatchTable *> catchList_;
562     ArenaSet<util::StringView> strings_;
563     ArenaVector<LiteralBuffer *> buffStorage_;
564     EnvScope *envScope_ {};
565     DynamicContext *dynamicContext_ {};
566     OptionalChain *optionalChain_ {};
567     InlineCache ic_;
568     RegAllocator ra_;
569     IcSizeType currentSlot_ {0};
570 
571     uint32_t usedRegs_ {0};
572     uint32_t totalRegs_ {0};
573     friend class ScopeContext;
574     friend class RegScope;
575     friend class LocalRegScope;
576     friend class LoopRegScope;
577     friend class ParamRegScope;
578     friend class FunctionRegScope;
579     friend class EnvScope;
580     friend class LoopEnvScope;
581     friend class DynamicContext;
582     friend class OptionalChain;
583     size_t labelId_ {0};
584     panda::panda_file::FunctionKind funcKind_ {panda::panda_file::FunctionKind::NONE};
585     bool icOverFlow_ {false};
586 };
587 }  // namespace panda::es2panda::compiler
588 
589 #endif
590