-
Notifications
You must be signed in to change notification settings - Fork 389
/
Copy pathstdlibs.go
36 lines (30 loc) · 952 Bytes
/
stdlibs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package stdlibs
//go:generate go run github.com/gnolang/gno/misc/genstd
import (
gno "github.com/gnolang/gno/gnovm/pkg/gnolang"
libsstd "github.com/gnolang/gno/gnovm/stdlibs/std"
)
type ExecContext = libsstd.ExecContext
func GetContext(m *gno.Machine) ExecContext {
return libsstd.GetContext(m)
}
// FindNative returns the NativeFunc associated with the given pkgPath+name
// combination. If there is none, FindNative returns nil.
func FindNative(pkgPath string, name gno.Name) *NativeFunc {
for i, nf := range nativeFuncs {
if nf.gnoPkg == pkgPath && name == nf.gnoFunc {
return &nativeFuncs[i]
}
}
return nil
}
// NativeResolver is used by the GnoVM to determine if the given function,
// specified by its pkgPath and name, has a native implementation; and if so
// retrieve it.
func NativeResolver(pkgPath string, name gno.Name) func(*gno.Machine) {
nt := FindNative(pkgPath, name)
if nt == nil {
return nil
}
return nt.f
}