compiler: disallow runtime.Notify in Verify function

Only direct invocations are considered. The check can be disabled
with '--no-events' compiler option.
This commit is contained in:
Evgeniy Stratonikov 2021-06-04 11:47:52 +03:00
parent ebff8be20a
commit 1578904da2
4 changed files with 53 additions and 2 deletions

View file

@ -337,6 +337,12 @@ func isInitFunc(decl *ast.FuncDecl) bool {
decl.Type.Results.NumFields() == 0
}
func (c *codegen) isVerifyFunc(decl *ast.FuncDecl) bool {
return decl.Name.Name == "Verify" && decl.Recv == nil &&
decl.Type.Results.NumFields() == 1 &&
isBool(c.typeOf(decl.Type.Results.List[0].Type))
}
func (c *codegen) clearSlots(n int) {
for i := 0; i < n; i++ {
emit.Opcodes(c.prog.BinWriter, opcode.PUSHNULL)