mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-01-25 15:14:48 +00:00
parent
058da7c2bd
commit
70a58b6522
2 changed files with 12 additions and 3 deletions
|
@ -36,6 +36,8 @@ type MethodDebugInfo struct {
|
||||||
Name DebugMethodName `json:"name"`
|
Name DebugMethodName `json:"name"`
|
||||||
// IsExported defines whether method is exported.
|
// IsExported defines whether method is exported.
|
||||||
IsExported bool `json:"-"`
|
IsExported bool `json:"-"`
|
||||||
|
// IsFunction defines whether method has no receiver.
|
||||||
|
IsFunction bool `json:"-"`
|
||||||
// Range is the range of smart-contract's opcodes corresponding to the method.
|
// Range is the range of smart-contract's opcodes corresponding to the method.
|
||||||
Range DebugRange `json:"range"`
|
Range DebugRange `json:"range"`
|
||||||
// Parameters is a list of method's parameters.
|
// Parameters is a list of method's parameters.
|
||||||
|
@ -123,6 +125,7 @@ func (c *codegen) emitDebugInfo(contract []byte) *DebugInfo {
|
||||||
Namespace: c.mainPkg.Pkg.Name(),
|
Namespace: c.mainPkg.Pkg.Name(),
|
||||||
},
|
},
|
||||||
IsExported: true,
|
IsExported: true,
|
||||||
|
IsFunction: true,
|
||||||
Range: DebugRange{
|
Range: DebugRange{
|
||||||
Start: 0,
|
Start: 0,
|
||||||
End: uint16(c.initEndOffset),
|
End: uint16(c.initEndOffset),
|
||||||
|
@ -171,6 +174,7 @@ func (c *codegen) methodInfoFromScope(name string, scope *funcScope) *MethodDebu
|
||||||
Namespace: scope.pkg.Name(),
|
Namespace: scope.pkg.Name(),
|
||||||
},
|
},
|
||||||
IsExported: scope.decl.Name.IsExported(),
|
IsExported: scope.decl.Name.IsExported(),
|
||||||
|
IsFunction: scope.decl.Recv == nil,
|
||||||
Range: scope.rng,
|
Range: scope.rng,
|
||||||
Parameters: params,
|
Parameters: params,
|
||||||
ReturnType: c.scReturnTypeFromScope(scope),
|
ReturnType: c.scReturnTypeFromScope(scope),
|
||||||
|
@ -375,7 +379,7 @@ func (di *DebugInfo) ConvertToManifest(fs smartcontract.PropertyState, events []
|
||||||
}
|
}
|
||||||
methods := make([]manifest.Method, 0)
|
methods := make([]manifest.Method, 0)
|
||||||
for _, method := range di.Methods {
|
for _, method := range di.Methods {
|
||||||
if method.IsExported && method.Name.Namespace == di.MainPkg {
|
if method.IsExported && method.IsFunction && method.Name.Namespace == di.MainPkg {
|
||||||
mMethod, err := method.ToManifestMethod()
|
mMethod, err := method.ToManifestMethod()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -42,6 +42,9 @@ func MethodByteArray() []byte { return nil }
|
||||||
func MethodArray() []bool { return nil }
|
func MethodArray() []bool { return nil }
|
||||||
func MethodStruct() struct{} { return struct{}{} }
|
func MethodStruct() struct{} { return struct{}{} }
|
||||||
func unexportedMethod() int { return 1 }
|
func unexportedMethod() int { return 1 }
|
||||||
|
type MyStruct struct {}
|
||||||
|
func (ms MyStruct) MethodOnStruct() { }
|
||||||
|
func (ms *MyStruct) MethodOnPointerToStruct() { }
|
||||||
`
|
`
|
||||||
|
|
||||||
info, err := getBuildInfo("foo.go", src)
|
info, err := getBuildInfo("foo.go", src)
|
||||||
|
@ -67,6 +70,8 @@ func unexportedMethod() int { return 1 }
|
||||||
"MethodArray": "Array", "MethodStruct": "Struct",
|
"MethodArray": "Array", "MethodStruct": "Struct",
|
||||||
"Main": "Boolean",
|
"Main": "Boolean",
|
||||||
"unexportedMethod": "Integer",
|
"unexportedMethod": "Integer",
|
||||||
|
"MethodOnStruct": "Void",
|
||||||
|
"MethodOnPointerToStruct": "Void",
|
||||||
}
|
}
|
||||||
for i := range d.Methods {
|
for i := range d.Methods {
|
||||||
name := d.Methods[i].ID
|
name := d.Methods[i].ID
|
||||||
|
|
Loading…
Reference in a new issue