compiler: allow to use init function

Process `init()` functions after global variables has been processed.
It's body is saved into the `_initialize` method where all
initialization is performed.
This commit is contained in:
Evgenii Stratonikov 2020-08-04 11:06:23 +03:00
parent ef53a45e7a
commit b771d2d024
3 changed files with 101 additions and 14 deletions

View file

@ -48,6 +48,7 @@ func (c *codegen) traverseGlobals() int {
}
emit.Instruction(c.prog.BinWriter, opcode.INITSSLOT, []byte{byte(n)})
c.ForEachFile(c.convertGlobals)
c.ForEachFile(c.convertInitFuncs)
}
return n
}