Lines Matching defs:pg
27 static void StoreModuleVarOrLocalVar(PandaGen *pg, binder::ScopeFindResult &result, const binder::Decl *decl)
30 ASSERT(pg->Scope()->IsModuleScope());
31 auto *var = pg->Scope()->FindLocal(decl->Name());
34 pg->StoreModuleVariable(decl->Node(), var->AsModuleVariable());
36 pg->StoreAccToLexEnv(decl->Node(), result, true);
40 static void HoistVar(PandaGen *pg, binder::Variable *var, const binder::VarDecl *decl)
46 auto *scope = pg->Scope();
48 pg->LoadConst(decl->Node(), Constant::JS_UNDEFINED);
49 pg->StoreGlobalVar(decl->Node(), decl->Name());
61 pg->LoadConst(decl->Node(), Constant::JS_UNDEFINED);
62 StoreModuleVarOrLocalVar(pg, result, decl);
65 static void HoistFunction(PandaGen *pg, binder::Variable *var, const binder::FunctionDecl *decl)
73 auto *scope = pg->Scope();
75 pg->DefineFunction(decl->Node(), scriptFunction, internalName);
76 pg->StoreGlobalVar(decl->Node(), var->Declaration()->Name());
85 pg->DefineFunction(decl->Node(), scriptFunction, internalName);
86 StoreModuleVarOrLocalVar(pg, result, decl);
89 static void HoistNameSpaceImports(PandaGen *pg)
91 if (pg->Scope()->IsModuleScope()) {
92 parser::SourceTextModuleRecord *moduleRecord = pg->Binder()->Program()->ModuleRecord();
95 auto *var = pg->TopScope()->FindLocal(nameSpaceEntry->localName_);
99 pg->GetModuleNamespace(node, nameSpaceEntry->moduleRequestIdx_);
100 pg->StoreVar(node, {nameSpaceEntry->localName_, pg->TopScope(), 0, var}, true);
105 void Hoisting::Hoist(PandaGen *pg)
107 const auto *scope = pg->Scope();
118 HoistVar(pg, var, decl->AsVarDecl());
121 HoistFunction(pg, var, decl->AsFunctionDecl());
125 HoistNameSpaceImports(pg);