diff --git a/pkg/compiler/debug.go b/pkg/compiler/debug.go index e4ef96e3d..4fd9a2b59 100644 --- a/pkg/compiler/debug.go +++ b/pkg/compiler/debug.go @@ -201,6 +201,21 @@ func (c *codegen) scTypeFromExpr(typ ast.Expr) string { if c.typeOf(typ) == nil { return "Any" } + if named, ok := t.(*types.Named); ok { + if isInteropPath(named.String()) { + name := named.Obj().Name() + pkg := named.Obj().Pkg().Name() + switch pkg { + case "blockchain", "contract": + return "Array" // Block, Transaction, Contract + case "interop": + if name != "Interface" { + return name + } + } + return "InteropInterface" + } + } switch t := t.Underlying().(type) { case *types.Basic: info := t.Info() diff --git a/pkg/compiler/debug_test.go b/pkg/compiler/debug_test.go index 6223e59e4..d795a05e8 100644 --- a/pkg/compiler/debug_test.go +++ b/pkg/compiler/debug_test.go @@ -15,6 +15,10 @@ import ( func TestCodeGen_DebugInfo(t *testing.T) { src := `package foo + import "github.com/nspcc-dev/neo-go/pkg/interop" + import "github.com/nspcc-dev/neo-go/pkg/interop/storage" + import "github.com/nspcc-dev/neo-go/pkg/interop/blockchain" + import "github.com/nspcc-dev/neo-go/pkg/interop/contract" func Main(op string) bool { var s string _ = s @@ -42,6 +46,12 @@ func MethodByteArray() []byte { return nil } func MethodArray() []bool { return nil } func MethodStruct() struct{} { return struct{}{} } func unexportedMethod() int { return 1 } +func MethodParams(addr interop.Hash160, h interop.Hash256, + sig interop.Signature, pub interop.PublicKey, + inter interop.Interface, ctr contract.Contract, + ctx storage.Context, tx blockchain.Transaction) bool { + return true +} type MyStruct struct {} func (ms MyStruct) MethodOnStruct() { } func (ms *MyStruct) MethodOnPointerToStruct() { } @@ -72,6 +82,7 @@ func (ms *MyStruct) MethodOnPointerToStruct() { } "unexportedMethod": "Integer", "MethodOnStruct": "Void", "MethodOnPointerToStruct": "Void", + "MethodParams": "Boolean", } for i := range d.Methods { name := d.Methods[i].ID @@ -201,6 +212,21 @@ func (ms *MyStruct) MethodOnPointerToStruct() { } }, ReturnType: smartcontract.StringType, }, + { + Name: "methodParams", + Offset: 125, + Parameters: []manifest.Parameter{ + manifest.NewParameter("addr", smartcontract.Hash160Type), + manifest.NewParameter("h", smartcontract.Hash256Type), + manifest.NewParameter("sig", smartcontract.SignatureType), + manifest.NewParameter("pub", smartcontract.PublicKeyType), + manifest.NewParameter("inter", smartcontract.InteropInterfaceType), + manifest.NewParameter("ctr", smartcontract.ArrayType), + manifest.NewParameter("ctx", smartcontract.InteropInterfaceType), + manifest.NewParameter("tx", smartcontract.ArrayType), + }, + ReturnType: smartcontract.BoolType, + }, }, Events: []manifest.Event{}, },