github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/gnovm/tests/stdlibs/native.go (about)

     1  // This file is autogenerated from the genstd tool (@/misc/genstd); do not edit.
     2  // To regenerate it, run `go generate` from this directory.
     3  
     4  package stdlibs
     5  
     6  import (
     7  	"reflect"
     8  
     9  	gno "github.com/gnolang/gno/gnovm/pkg/gnolang"
    10  	testlibs_std "github.com/gnolang/gno/gnovm/tests/stdlibs/std"
    11  	testlibs_testing "github.com/gnolang/gno/gnovm/tests/stdlibs/testing"
    12  )
    13  
    14  type nativeFunc struct {
    15  	gnoPkg  string
    16  	gnoFunc gno.Name
    17  	params  []gno.FieldTypeExpr
    18  	results []gno.FieldTypeExpr
    19  	f       func(m *gno.Machine)
    20  }
    21  
    22  var nativeFuncs = [...]nativeFunc{
    23  	{
    24  		"std",
    25  		"AssertOriginCall",
    26  		[]gno.FieldTypeExpr{},
    27  		[]gno.FieldTypeExpr{},
    28  		func(m *gno.Machine) {
    29  			testlibs_std.AssertOriginCall(
    30  				m,
    31  			)
    32  		},
    33  	},
    34  	{
    35  		"std",
    36  		"IsOriginCall",
    37  		[]gno.FieldTypeExpr{},
    38  		[]gno.FieldTypeExpr{
    39  			{Name: gno.N("r0"), Type: gno.X("bool")},
    40  		},
    41  		func(m *gno.Machine) {
    42  			r0 := testlibs_std.IsOriginCall(
    43  				m,
    44  			)
    45  
    46  			m.PushValue(gno.Go2GnoValue(
    47  				m.Alloc,
    48  				m.Store,
    49  				reflect.ValueOf(&r0).Elem(),
    50  			))
    51  		},
    52  	},
    53  	{
    54  		"std",
    55  		"TestCurrentRealm",
    56  		[]gno.FieldTypeExpr{},
    57  		[]gno.FieldTypeExpr{
    58  			{Name: gno.N("r0"), Type: gno.X("string")},
    59  		},
    60  		func(m *gno.Machine) {
    61  			r0 := testlibs_std.TestCurrentRealm(
    62  				m,
    63  			)
    64  
    65  			m.PushValue(gno.Go2GnoValue(
    66  				m.Alloc,
    67  				m.Store,
    68  				reflect.ValueOf(&r0).Elem(),
    69  			))
    70  		},
    71  	},
    72  	{
    73  		"std",
    74  		"TestSkipHeights",
    75  		[]gno.FieldTypeExpr{
    76  			{Name: gno.N("p0"), Type: gno.X("int64")},
    77  		},
    78  		[]gno.FieldTypeExpr{},
    79  		func(m *gno.Machine) {
    80  			b := m.LastBlock()
    81  			var (
    82  				p0  int64
    83  				rp0 = reflect.ValueOf(&p0).Elem()
    84  			)
    85  
    86  			gno.Gno2GoValue(b.GetPointerTo(nil, gno.NewValuePathBlock(1, 0, "")).TV, rp0)
    87  
    88  			testlibs_std.TestSkipHeights(
    89  				m,
    90  				p0)
    91  		},
    92  	},
    93  	{
    94  		"std",
    95  		"ClearStoreCache",
    96  		[]gno.FieldTypeExpr{},
    97  		[]gno.FieldTypeExpr{},
    98  		func(m *gno.Machine) {
    99  			testlibs_std.ClearStoreCache(
   100  				m,
   101  			)
   102  		},
   103  	},
   104  	{
   105  		"std",
   106  		"callerAt",
   107  		[]gno.FieldTypeExpr{
   108  			{Name: gno.N("p0"), Type: gno.X("int")},
   109  		},
   110  		[]gno.FieldTypeExpr{
   111  			{Name: gno.N("r0"), Type: gno.X("string")},
   112  		},
   113  		func(m *gno.Machine) {
   114  			b := m.LastBlock()
   115  			var (
   116  				p0  int
   117  				rp0 = reflect.ValueOf(&p0).Elem()
   118  			)
   119  
   120  			gno.Gno2GoValue(b.GetPointerTo(nil, gno.NewValuePathBlock(1, 0, "")).TV, rp0)
   121  
   122  			r0 := testlibs_std.X_callerAt(
   123  				m,
   124  				p0)
   125  
   126  			m.PushValue(gno.Go2GnoValue(
   127  				m.Alloc,
   128  				m.Store,
   129  				reflect.ValueOf(&r0).Elem(),
   130  			))
   131  		},
   132  	},
   133  	{
   134  		"std",
   135  		"testSetOrigCaller",
   136  		[]gno.FieldTypeExpr{
   137  			{Name: gno.N("p0"), Type: gno.X("string")},
   138  		},
   139  		[]gno.FieldTypeExpr{},
   140  		func(m *gno.Machine) {
   141  			b := m.LastBlock()
   142  			var (
   143  				p0  string
   144  				rp0 = reflect.ValueOf(&p0).Elem()
   145  			)
   146  
   147  			gno.Gno2GoValue(b.GetPointerTo(nil, gno.NewValuePathBlock(1, 0, "")).TV, rp0)
   148  
   149  			testlibs_std.X_testSetOrigCaller(
   150  				m,
   151  				p0)
   152  		},
   153  	},
   154  	{
   155  		"std",
   156  		"testSetOrigPkgAddr",
   157  		[]gno.FieldTypeExpr{
   158  			{Name: gno.N("p0"), Type: gno.X("string")},
   159  		},
   160  		[]gno.FieldTypeExpr{},
   161  		func(m *gno.Machine) {
   162  			b := m.LastBlock()
   163  			var (
   164  				p0  string
   165  				rp0 = reflect.ValueOf(&p0).Elem()
   166  			)
   167  
   168  			gno.Gno2GoValue(b.GetPointerTo(nil, gno.NewValuePathBlock(1, 0, "")).TV, rp0)
   169  
   170  			testlibs_std.X_testSetOrigPkgAddr(
   171  				m,
   172  				p0)
   173  		},
   174  	},
   175  	{
   176  		"std",
   177  		"testSetPrevRealm",
   178  		[]gno.FieldTypeExpr{
   179  			{Name: gno.N("p0"), Type: gno.X("string")},
   180  		},
   181  		[]gno.FieldTypeExpr{},
   182  		func(m *gno.Machine) {
   183  			b := m.LastBlock()
   184  			var (
   185  				p0  string
   186  				rp0 = reflect.ValueOf(&p0).Elem()
   187  			)
   188  
   189  			gno.Gno2GoValue(b.GetPointerTo(nil, gno.NewValuePathBlock(1, 0, "")).TV, rp0)
   190  
   191  			testlibs_std.X_testSetPrevRealm(
   192  				m,
   193  				p0)
   194  		},
   195  	},
   196  	{
   197  		"std",
   198  		"testSetPrevAddr",
   199  		[]gno.FieldTypeExpr{
   200  			{Name: gno.N("p0"), Type: gno.X("string")},
   201  		},
   202  		[]gno.FieldTypeExpr{},
   203  		func(m *gno.Machine) {
   204  			b := m.LastBlock()
   205  			var (
   206  				p0  string
   207  				rp0 = reflect.ValueOf(&p0).Elem()
   208  			)
   209  
   210  			gno.Gno2GoValue(b.GetPointerTo(nil, gno.NewValuePathBlock(1, 0, "")).TV, rp0)
   211  
   212  			testlibs_std.X_testSetPrevAddr(
   213  				m,
   214  				p0)
   215  		},
   216  	},
   217  	{
   218  		"std",
   219  		"testSetOrigSend",
   220  		[]gno.FieldTypeExpr{
   221  			{Name: gno.N("p0"), Type: gno.X("[]string")},
   222  			{Name: gno.N("p1"), Type: gno.X("[]int64")},
   223  			{Name: gno.N("p2"), Type: gno.X("[]string")},
   224  			{Name: gno.N("p3"), Type: gno.X("[]int64")},
   225  		},
   226  		[]gno.FieldTypeExpr{},
   227  		func(m *gno.Machine) {
   228  			b := m.LastBlock()
   229  			var (
   230  				p0  []string
   231  				rp0 = reflect.ValueOf(&p0).Elem()
   232  				p1  []int64
   233  				rp1 = reflect.ValueOf(&p1).Elem()
   234  				p2  []string
   235  				rp2 = reflect.ValueOf(&p2).Elem()
   236  				p3  []int64
   237  				rp3 = reflect.ValueOf(&p3).Elem()
   238  			)
   239  
   240  			gno.Gno2GoValue(b.GetPointerTo(nil, gno.NewValuePathBlock(1, 0, "")).TV, rp0)
   241  			gno.Gno2GoValue(b.GetPointerTo(nil, gno.NewValuePathBlock(1, 1, "")).TV, rp1)
   242  			gno.Gno2GoValue(b.GetPointerTo(nil, gno.NewValuePathBlock(1, 2, "")).TV, rp2)
   243  			gno.Gno2GoValue(b.GetPointerTo(nil, gno.NewValuePathBlock(1, 3, "")).TV, rp3)
   244  
   245  			testlibs_std.X_testSetOrigSend(
   246  				m,
   247  				p0, p1, p2, p3)
   248  		},
   249  	},
   250  	{
   251  		"std",
   252  		"testIssueCoins",
   253  		[]gno.FieldTypeExpr{
   254  			{Name: gno.N("p0"), Type: gno.X("string")},
   255  			{Name: gno.N("p1"), Type: gno.X("[]string")},
   256  			{Name: gno.N("p2"), Type: gno.X("[]int64")},
   257  		},
   258  		[]gno.FieldTypeExpr{},
   259  		func(m *gno.Machine) {
   260  			b := m.LastBlock()
   261  			var (
   262  				p0  string
   263  				rp0 = reflect.ValueOf(&p0).Elem()
   264  				p1  []string
   265  				rp1 = reflect.ValueOf(&p1).Elem()
   266  				p2  []int64
   267  				rp2 = reflect.ValueOf(&p2).Elem()
   268  			)
   269  
   270  			gno.Gno2GoValue(b.GetPointerTo(nil, gno.NewValuePathBlock(1, 0, "")).TV, rp0)
   271  			gno.Gno2GoValue(b.GetPointerTo(nil, gno.NewValuePathBlock(1, 1, "")).TV, rp1)
   272  			gno.Gno2GoValue(b.GetPointerTo(nil, gno.NewValuePathBlock(1, 2, "")).TV, rp2)
   273  
   274  			testlibs_std.X_testIssueCoins(
   275  				m,
   276  				p0, p1, p2)
   277  		},
   278  	},
   279  	{
   280  		"testing",
   281  		"unixNano",
   282  		[]gno.FieldTypeExpr{},
   283  		[]gno.FieldTypeExpr{
   284  			{Name: gno.N("r0"), Type: gno.X("int64")},
   285  		},
   286  		func(m *gno.Machine) {
   287  			r0 := testlibs_testing.X_unixNano()
   288  
   289  			m.PushValue(gno.Go2GnoValue(
   290  				m.Alloc,
   291  				m.Store,
   292  				reflect.ValueOf(&r0).Elem(),
   293  			))
   294  		},
   295  	},
   296  }