mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-03 23:02:27 +00:00
compiler: exclude unexported methods from manifest
We should be able to invoke exported methods only.
This commit is contained in:
parent
1755ce10ac
commit
7d8a3a7065
2 changed files with 50 additions and 25 deletions
|
@ -18,27 +18,30 @@ func TestCodeGen_DebugInfo(t *testing.T) {
|
|||
func Main(op string) bool {
|
||||
var s string
|
||||
_ = s
|
||||
res := methodInt(op)
|
||||
_ = methodString()
|
||||
_ = methodByteArray()
|
||||
_ = methodArray()
|
||||
_ = methodStruct()
|
||||
res := MethodInt(op)
|
||||
_ = MethodString()
|
||||
_ = MethodByteArray()
|
||||
_ = MethodArray()
|
||||
_ = MethodStruct()
|
||||
_ = MethodConcat("a", "b", "c")
|
||||
_ = unexportedMethod()
|
||||
return res == 42
|
||||
}
|
||||
|
||||
func methodInt(a string) int {
|
||||
func MethodInt(a string) int {
|
||||
if a == "get42" {
|
||||
return 42
|
||||
}
|
||||
return 3
|
||||
}
|
||||
func methodConcat(a, b string, c string) string{
|
||||
func MethodConcat(a, b string, c string) string{
|
||||
return a + b + c
|
||||
}
|
||||
func methodString() string { return "" }
|
||||
func methodByteArray() []byte { return nil }
|
||||
func methodArray() []bool { return nil }
|
||||
func methodStruct() struct{} { return struct{}{} }
|
||||
func MethodString() string { return "" }
|
||||
func MethodByteArray() []byte { return nil }
|
||||
func MethodArray() []bool { return nil }
|
||||
func MethodStruct() struct{} { return struct{}{} }
|
||||
func unexportedMethod() int { return 1 }
|
||||
`
|
||||
|
||||
info, err := getBuildInfo(src)
|
||||
|
@ -58,11 +61,12 @@ func methodStruct() struct{} { return struct{}{} }
|
|||
|
||||
t.Run("return types", func(t *testing.T) {
|
||||
returnTypes := map[string]string{
|
||||
"methodInt": "Integer",
|
||||
"methodConcat": "String",
|
||||
"methodString": "String", "methodByteArray": "ByteArray",
|
||||
"methodArray": "Array", "methodStruct": "Struct",
|
||||
"Main": "Boolean",
|
||||
"MethodInt": "Integer",
|
||||
"MethodConcat": "String",
|
||||
"MethodString": "String", "MethodByteArray": "ByteArray",
|
||||
"MethodArray": "Array", "MethodStruct": "Struct",
|
||||
"Main": "Boolean",
|
||||
"unexportedMethod": "Integer",
|
||||
}
|
||||
for i := range d.Methods {
|
||||
name := d.Methods[i].Name.Name
|
||||
|
@ -84,11 +88,11 @@ func methodStruct() struct{} { return struct{}{} }
|
|||
|
||||
t.Run("param types", func(t *testing.T) {
|
||||
paramTypes := map[string][]DebugParam{
|
||||
"methodInt": {{
|
||||
"MethodInt": {{
|
||||
Name: "a",
|
||||
Type: "String",
|
||||
}},
|
||||
"methodConcat": {
|
||||
"MethodConcat": {
|
||||
{
|
||||
Name: "a",
|
||||
Type: "String",
|
||||
|
@ -140,7 +144,7 @@ func methodStruct() struct{} { return struct{}{} }
|
|||
},
|
||||
Methods: []manifest.Method{
|
||||
{
|
||||
Name: "methodInt",
|
||||
Name: "MethodInt",
|
||||
Parameters: []manifest.Parameter{
|
||||
{
|
||||
Name: "a",
|
||||
|
@ -150,25 +154,43 @@ func methodStruct() struct{} { return struct{}{} }
|
|||
ReturnType: smartcontract.IntegerType,
|
||||
},
|
||||
{
|
||||
Name: "methodString",
|
||||
Name: "MethodString",
|
||||
Parameters: []manifest.Parameter{},
|
||||
ReturnType: smartcontract.StringType,
|
||||
},
|
||||
{
|
||||
Name: "methodByteArray",
|
||||
Name: "MethodByteArray",
|
||||
Parameters: []manifest.Parameter{},
|
||||
ReturnType: smartcontract.ByteArrayType,
|
||||
},
|
||||
{
|
||||
Name: "methodArray",
|
||||
Name: "MethodArray",
|
||||
Parameters: []manifest.Parameter{},
|
||||
ReturnType: smartcontract.ArrayType,
|
||||
},
|
||||
{
|
||||
Name: "methodStruct",
|
||||
Name: "MethodStruct",
|
||||
Parameters: []manifest.Parameter{},
|
||||
ReturnType: smartcontract.ArrayType,
|
||||
},
|
||||
{
|
||||
Name: "MethodConcat",
|
||||
Parameters: []manifest.Parameter{
|
||||
{
|
||||
Name: "a",
|
||||
Type: smartcontract.StringType,
|
||||
},
|
||||
{
|
||||
Name: "b",
|
||||
Type: smartcontract.StringType,
|
||||
},
|
||||
{
|
||||
Name: "c",
|
||||
Type: smartcontract.StringType,
|
||||
},
|
||||
},
|
||||
ReturnType: smartcontract.StringType,
|
||||
},
|
||||
},
|
||||
Events: []manifest.Event{},
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue