Skip to content

Commit

Permalink
Use package_init in translation
Browse files Browse the repository at this point in the history
  • Loading branch information
upamanyus committed Dec 17, 2024
1 parent 00ce0e2 commit 349a583
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions goose.go
Original file line number Diff line number Diff line change
Expand Up @@ -2478,7 +2478,7 @@ func (ctx *Ctx) initFunctions() []glang.Decl {

ctx.dep.setCurrentName("initialize'")
initFunc := glang.FuncDecl{Name: "initialize'"}
ctx.dep.addDep("define'")

e = nil

// add all init() function bodies
Expand Down Expand Up @@ -2550,20 +2550,20 @@ func (ctx *Ctx) initFunctions() []glang.Decl {
}
}

ctx.dep.addDep("define'")
e = glang.NewDoSeq(glang.NewCallExpr(glang.GallinaIdent("define'"), glang.Tt), e)

for _, importName := range ctx.importNames {
e = glang.NewDoSeq(glang.GallinaIdent(importName+"."+"initialize'"), e)
}

e = glang.IfExpr{
Cond: glang.NewCallExpr(glang.GallinaIdent("globals.is_uninitialized"),
glang.GallinaIdent("pkg_name'")),
Then: e,
Else: glang.DoExpr{Expr: glang.Tt},
}
e = glang.NewCallExpr(glang.GallinaIdent("exception_do"), e)
e = glang.NewCallExpr(glang.GallinaIdent("globals.package_init"),
glang.GallinaIdent("pkg_name'"),
glang.FuncLit{Args: nil, Body: e},
)

initFunc.Body = glang.NewCallExpr(glang.GallinaIdent("exception_do"), e)
initFunc.Body = e

return []glang.Decl{packageIdDecl, defineFunc, initFunc}
}

0 comments on commit 349a583

Please sign in to comment.