github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/gnovm/tests/files/zrealm_natbind0.gno (about) 1 // PKGPATH: gno.land/r/test 2 package test 3 4 import ( 5 "std" 6 ) 7 8 var node interface{} 9 10 func init() { 11 node = std.GetHeight 12 } 13 14 func main() { 15 // NOTE: this test uses GetHeight and CurrentRealmPath, which are "pure" 16 // natively bound functions (ie. not indirections through a wrapper fn, 17 // to convert the types to builtin go/gno identifiers). 18 f := node.(func() int64) 19 println(f()) 20 node = std.CurrentRealmPath 21 g := node.(func() string) 22 println(g()) 23 } 24 25 // Output: 26 // 123 27 // gno.land/r/test 28 29 // Realm: 30 // switchrealm["gno.land/r/test"] 31 // u[a8ada09dee16d791fd406d629fe29bb0ed084a30:2]={ 32 // "Blank": {}, 33 // "ObjectInfo": { 34 // "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:2", 35 // "IsEscaped": true, 36 // "ModTime": "3", 37 // "RefCount": "2" 38 // }, 39 // "Parent": null, 40 // "Source": { 41 // "@type": "/gno.RefNode", 42 // "BlockNode": null, 43 // "Location": { 44 // "File": "", 45 // "Line": "0", 46 // "Nonce": "0", 47 // "PkgPath": "gno.land/r/test" 48 // } 49 // }, 50 // "Values": [ 51 // { 52 // "T": { 53 // "@type": "/gno.FuncType", 54 // "Params": [], 55 // "Results": [] 56 // }, 57 // "V": { 58 // "@type": "/gno.FuncValue", 59 // "Closure": { 60 // "@type": "/gno.RefValue", 61 // "Escaped": true, 62 // "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:3" 63 // }, 64 // "FileName": "main.gno", 65 // "IsMethod": false, 66 // "Name": "init.0", 67 // "NativeName": "", 68 // "NativePkg": "", 69 // "PkgPath": "gno.land/r/test", 70 // "Source": { 71 // "@type": "/gno.RefNode", 72 // "BlockNode": null, 73 // "Location": { 74 // "File": "main.gno", 75 // "Line": "10", 76 // "Nonce": "0", 77 // "PkgPath": "gno.land/r/test" 78 // } 79 // }, 80 // "Type": { 81 // "@type": "/gno.FuncType", 82 // "Params": [], 83 // "Results": [] 84 // } 85 // } 86 // }, 87 // { 88 // "T": { 89 // "@type": "/gno.FuncType", 90 // "Params": [], 91 // "Results": [] 92 // }, 93 // "V": { 94 // "@type": "/gno.FuncValue", 95 // "Closure": { 96 // "@type": "/gno.RefValue", 97 // "Escaped": true, 98 // "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:3" 99 // }, 100 // "FileName": "main.gno", 101 // "IsMethod": false, 102 // "Name": "main", 103 // "NativeName": "", 104 // "NativePkg": "", 105 // "PkgPath": "gno.land/r/test", 106 // "Source": { 107 // "@type": "/gno.RefNode", 108 // "BlockNode": null, 109 // "Location": { 110 // "File": "main.gno", 111 // "Line": "14", 112 // "Nonce": "0", 113 // "PkgPath": "gno.land/r/test" 114 // } 115 // }, 116 // "Type": { 117 // "@type": "/gno.FuncType", 118 // "Params": [], 119 // "Results": [] 120 // } 121 // } 122 // }, 123 // { 124 // "T": { 125 // "@type": "/gno.FuncType", 126 // "Params": [], 127 // "Results": [ 128 // { 129 // "Embedded": false, 130 // "Name": "", 131 // "Tag": "", 132 // "Type": { 133 // "@type": "/gno.PrimitiveType", 134 // "value": "16" 135 // } 136 // } 137 // ] 138 // }, 139 // "V": { 140 // "@type": "/gno.FuncValue", 141 // "Closure": { 142 // "@type": "/gno.RefValue", 143 // "Escaped": true, 144 // "ObjectID": "a7f5397443359ea76c50be82c77f1f893a060925:7" 145 // }, 146 // "FileName": "native.gno", 147 // "IsMethod": false, 148 // "Name": "CurrentRealmPath", 149 // "NativeName": "CurrentRealmPath", 150 // "NativePkg": "std", 151 // "PkgPath": "std", 152 // "Source": { 153 // "@type": "/gno.RefNode", 154 // "BlockNode": null, 155 // "Location": { 156 // "File": "native.gno", 157 // "Line": "5", 158 // "Nonce": "0", 159 // "PkgPath": "std" 160 // } 161 // }, 162 // "Type": { 163 // "@type": "/gno.FuncType", 164 // "Params": [], 165 // "Results": [ 166 // { 167 // "Embedded": false, 168 // "Name": "", 169 // "Tag": "", 170 // "Type": { 171 // "@type": "/gno.PrimitiveType", 172 // "value": "16" 173 // } 174 // } 175 // ] 176 // } 177 // } 178 // } 179 // ] 180 // }