compiler: check correctness of emitted bytecode

The error here indicates a bug in compiler implementation.

Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgeniy Stratonikov 2021-10-25 13:54:18 +03:00
parent a885f84cad
commit 4fe188a60d

View file

@ -16,6 +16,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/io" "github.com/nspcc-dev/neo-go/pkg/io"
"github.com/nspcc-dev/neo-go/pkg/smartcontract" "github.com/nspcc-dev/neo-go/pkg/smartcontract"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neo-go/pkg/util/bitfield"
"github.com/nspcc-dev/neo-go/pkg/vm" "github.com/nspcc-dev/neo-go/pkg/vm"
"github.com/nspcc-dev/neo-go/pkg/vm/emit" "github.com/nspcc-dev/neo-go/pkg/vm/emit"
"github.com/nspcc-dev/neo-go/pkg/vm/opcode" "github.com/nspcc-dev/neo-go/pkg/vm/opcode"
@ -2073,7 +2074,13 @@ func CodeGen(info *buildInfo) ([]byte, *DebugInfo, error) {
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
return buf, c.emitDebugInfo(buf), nil
methods := bitfield.New(len(buf))
di := c.emitDebugInfo(buf)
for i := range di.Methods {
methods.Set(int(di.Methods[i].Range.Start))
}
return buf, di, vm.IsScriptCorrect(buf, methods)
} }
func (c *codegen) resolveFuncDecls(f *ast.File, pkg *types.Package) { func (c *codegen) resolveFuncDecls(f *ast.File, pkg *types.Package) {