Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
ltzmaxwell committed Nov 28, 2024
1 parent 0d2c203 commit e0a040e
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 0 deletions.
4 changes: 4 additions & 0 deletions gnovm/pkg/gnolang/op_assign.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package gnolang

import "fmt"

func (m *Machine) doOpDefine() {
s := m.PopStmt().(*AssignStmt)
fmt.Println("---doOpDefine, s: ", s)
// Define each value evaluated for Lhs.
// NOTE: PopValues() returns a slice in
// forward order, not the usual reverse.
Expand All @@ -26,6 +29,7 @@ func (m *Machine) doOpDefine() {

func (m *Machine) doOpAssign() {
s := m.PopStmt().(*AssignStmt)
fmt.Println("---doOpAssign, s: ", s)
// Assign each value evaluated for Lhs.
// NOTE: PopValues() returns a slice in
// forward order, not the usual reverse.
Expand Down
2 changes: 2 additions & 0 deletions gnovm/pkg/gnolang/op_decl.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

func (m *Machine) doOpValueDecl() {
s := m.PopStmt().(*ValueDecl)
fmt.Println("---doOpValueDecl, s: ", s)
lb := m.LastBlock()
nt := Type(nil)
if s.Type != nil {
Expand All @@ -18,6 +19,7 @@ func (m *Machine) doOpValueDecl() {
for i := 0; i < len(s.NameExprs); i++ {
var tv TypedValue
if rvs == nil {
println("---rvs is nil, using default value")
// NOTE: Go/Gno wart.
// implicit interface casting could
// requiring the consideration of the typed-nil case.
Expand Down
2 changes: 2 additions & 0 deletions gnovm/pkg/gnolang/op_eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func (m *Machine) doOpEval() {
debug.Printf("EVAL: (%T) %v\n", x, x)
fmt.Println(m.String())
}
fmt.Printf("EVAL: (%T) %v\n", x, x)
// This case moved out of switch for performance.
// TODO: understand this better.
if nx, ok := x.(*NameExpr); ok {
Expand All @@ -37,6 +38,7 @@ func (m *Machine) doOpEval() {
lb := m.LastBlock()
// Push value, done.
ptr := lb.GetPointerTo(m.Store, nx.Path)
fmt.Println("---ptr.Deref(): ", ptr.Deref())
m.PushValue(ptr.Deref())
return
}
Expand Down
20 changes: 20 additions & 0 deletions gnovm/tests/files/zrealm_crossrealm41.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// PKGPATH: gno.land/r/crossrealm_test
package crossrealm_test

type local struct {
name string
}

var ll local // this is attached as a zero value

// XXX, consider more about this.
// var sll []crossrealm.bar
// var pll *crossrealm.bar

func main() {
l := local{name: "a"}
println(l)
}

// Output:
// (struct{("a" string)} gno.land/r/crossrealm_test.local)
12 changes: 12 additions & 0 deletions gnovm/tests/files/zrealm_crossrealm42.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// PKGPATH: gno.land/r/crossrealm_test
package crossrealm_test

import crossrealm "gno.land/r/demo/tests/crossrealm"

type LocalBar crossrealm.Bar

var lb LocalBar

func main() {
println(lb)
}

0 comments on commit e0a040e

Please sign in to comment.