compiler: compile init
even if there are no globals
`init` can be useful even if no globals are present, e.g. we can use some syscall inside.
This commit is contained in:
parent
439d9ff94d
commit
4488f61777
3 changed files with 51 additions and 14 deletions
|
@ -1495,8 +1495,8 @@ func (c *codegen) compile(info *buildInfo, pkg *loader.PackageInfo) error {
|
|||
// Bring all imported functions into scope.
|
||||
c.ForEachFile(c.resolveFuncDecls)
|
||||
|
||||
n := c.traverseGlobals()
|
||||
if n > 0 {
|
||||
n, hasInit := c.traverseGlobals()
|
||||
if n > 0 || hasInit {
|
||||
emit.Opcode(c.prog.BinWriter, opcode.RET)
|
||||
c.initEndOffset = c.prog.Len()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue