compiler: refactor syscall handling

Close #941.
This commit is contained in:
Evgeniy Stratonikov 2021-02-05 19:02:09 +03:00
parent f7b9861c11
commit df5314f286
12 changed files with 157 additions and 128 deletions

View file

@ -277,8 +277,7 @@ func isSyscall(fun *funcScope) bool {
if fun.selector == nil || fun.pkg == nil || !isInteropPath(fun.pkg.Path()) {
return false
}
_, ok := syscalls[fun.pkg.Name()][fun.name]
return ok
return fun.pkg.Name() == "neogointernal" && strings.HasPrefix(fun.name, "Syscall")
}
const interopPrefix = "github.com/nspcc-dev/neo-go/pkg/interop"
@ -309,6 +308,13 @@ func canConvert(s string) bool {
// Currently there is a static list of function which are inlined,
// this may change in future.
func canInline(s string) bool {
return isNativeHelpersPath(s) ||
strings.HasPrefix(s, "github.com/nspcc-dev/neo-go/pkg/compiler/testdata/inline")
if strings.HasPrefix(s, "github.com/nspcc-dev/neo-go/pkg/compiler/testdata/inline") {
return true
}
if !isInteropPath(s) {
return false
}
return !strings.HasPrefix(s[len(interopPrefix):], "/neogointernal") &&
!strings.HasPrefix(s[len(interopPrefix):], "/util") &&
!strings.HasPrefix(s[len(interopPrefix):], "/convert")
}