Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP fix(gnovm): PoC of inter-realm spec #2958

Draft
wants to merge 33 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
2dcdfd5
naive fix
ltzmaxwell Jun 24, 2024
3056bcd
Merge branch 'master' of https://github.com/gnolang/gno
ltzmaxwell Jul 26, 2024
e69dfc0
Merge branch 'master' of github.com:gnolang/gno
ltzmaxwell Aug 13, 2024
9d05216
Merge branch 'master' of https://github.com/gnolang/gno
ltzmaxwell Aug 22, 2024
fb2f408
fix untyped bool
ltzmaxwell Aug 22, 2024
22f973f
revert un-intentional change
ltzmaxwell Aug 27, 2024
2926b3d
test files
ltzmaxwell Sep 22, 2024
c3e3bdd
debug
ltzmaxwell Sep 23, 2024
72b28d7
debug
ltzmaxwell Sep 27, 2024
00a59e7
save
ltzmaxwell Oct 7, 2024
71c6fed
external type
ltzmaxwell Oct 8, 2024
07d9029
save
ltzmaxwell Oct 10, 2024
8fdc399
save
ltzmaxwell Oct 14, 2024
a604cdc
more test
ltzmaxwell Oct 16, 2024
2e6a97c
save
ltzmaxwell Nov 6, 2024
7bedb54
save
ltzmaxwell Nov 6, 2024
eeb5bd8
more obj info
ltzmaxwell Nov 8, 2024
9175b85
test
ltzmaxwell Nov 9, 2024
c41caa3
make test pass
ltzmaxwell Nov 12, 2024
48eb8b9
fixup
ltzmaxwell Nov 12, 2024
0bef907
fixup
ltzmaxwell Nov 12, 2024
585b370
test array
ltzmaxwell Nov 13, 2024
c8b24f5
add test
ltzmaxwell Nov 13, 2024
ff95ddc
debug
ltzmaxwell Nov 16, 2024
ecad113
more embede tests
ltzmaxwell Nov 22, 2024
e2670cc
start refactor
ltzmaxwell Nov 24, 2024
e28a2ba
save
ltzmaxwell Nov 25, 2024
696e6da
save
ltzmaxwell Nov 25, 2024
675355d
clean
ltzmaxwell Nov 25, 2024
4af9d45
save
ltzmaxwell Nov 25, 2024
588b9dd
change api
ltzmaxwell Nov 26, 2024
928bda2
fixup
ltzmaxwell Nov 26, 2024
35927e6
fixup
ltzmaxwell Nov 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/gno.land/r/demo/tests/crossrealm/crossrealm.gno
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func (ls *LocalStruct) String() string {
var local *LocalStruct

func init() {
local = &LocalStruct{A: 123}
local = &LocalStruct{A: 123} // this is attached first
}

// Make1 returns a local object wrapped by a p struct
Expand Down
30 changes: 30 additions & 0 deletions examples/gno.land/r/demo/tests/crossrealm/crossrealm2.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package crossrealm

// XXX, how about not interface
type Fooer interface{ Foo() }

var fooer Fooer

func SetFooer(f Fooer) Fooer {
fooer = f
return fooer
}

func CallFoo() { fooer.Foo() }

// container in external realm
type Container struct {
name string
f Fooer
}

var container Container // attached

func SetContainer(f Fooer) {
container.f = f // update
}

func SetContainer2(f Fooer) {
ff := f // associate to non-attached object
SetContainer(ff) // attach container, while ff is not attached
}
18 changes: 18 additions & 0 deletions examples/gno.land/r/demo/tests/crossrealm/crossrealm3.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package crossrealm

type Bar struct {
A int
}

var bar *Bar
var Bar2 *Bar // exported

func SetBar(b *Bar) *Bar {
bar = b
return bar
}

func CallBar() {
bar.A += 1
println(bar.A)
}
10 changes: 10 additions & 0 deletions examples/gno.land/r/demo/tests/crossrealm/crossrealm4.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package crossrealm

var S []Fooer

func SetSlice(fs []Fooer) {
S = fs
for _, f := range fs {
println(f)
}
}
13 changes: 13 additions & 0 deletions examples/gno.land/r/demo/tests/crossrealm/crossrealm5.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package crossrealm

type F func() bool

var f F

func SetCallback(ff F) {
f = ff
}

func ExecuteCallback() {
f()
}
66 changes: 66 additions & 0 deletions examples/gno.land/r/demo/tests/crossrealm/crossrealm6.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package crossrealm

type XYZ struct{ name string }

var s1 []XYZ
var s3 []XYZ
var s4 []XYZ
var s5 []*XYZ
var s6 = make([]*XYZ, 2)

var s7 [2]XYZ

func init() {
s1 = append(s1, XYZ{"1"})
s1 = append(s1, XYZ{"2"})

s3 = append(s3, XYZ{"3"})
s4 = append(s4, XYZ{"4"})

s5 = append(s5, &XYZ{"5"})

s6[0] = &XYZ{"6"}

s7[0] = XYZ{"7"}
s7[1] = XYZ{"7.1"} // should be real after this
}

func GetSlice() []XYZ {
return s1[1:]
}

// -------------------------------------------------------
var e1 = XYZ{"1"}
var e2 = XYZ{"2"}

func GetSlice2() []XYZ {
var s2 []XYZ
s2 = append(s2, e1)
s2 = append(s2, e2)
return s2
}

// ------------------------------------------------------
func GetSlice3() []XYZ {
s3 = append(s3, XYZ{"0"}) // this is real after function
return s3
}

func GetSlice4(f func(s []XYZ)) {
s4 = append(s4, XYZ{"0"}) // this is real after this function
f(s4) // XYZ{"0"} is floating
}

func GetSlice5() []*XYZ { // TODO, unwrap
return s5
}

func GetSlice6(f func(s []*XYZ)) {
s6[1] = &XYZ{"6.1"} // the initial value is deleted, so this is not real after append
f(s6)
}

func GetSlice7(f func(s [2]XYZ)) {
//s7[1] = XYZ{"7.1"}
f(s7)
}
36 changes: 36 additions & 0 deletions examples/gno.land/r/demo/tests/crossrealm/crossrealm7.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package crossrealm

type A struct {
name string
}

type B struct {
name string
}

type D struct {
name string
}

type C struct {
A
B
D
}

var a A = A{name: "a"}
var b B = B{name: "b"}

var c *C

func init() {
c = &C{}
c.A = a
c.B = b
}

func GetStruct(cb func(v *C)) *C {
c.D = D{name: "d"} // this is not attached before return
cb(c)
return c
}
12 changes: 12 additions & 0 deletions examples/gno.land/r/demo/tests/crossrealm/crossrealm8.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package crossrealm

var m map[string]int

func init() {
m = make(map[string]int)
m["a"] = 1
}

func GetMap() map[string]int {
return m
}
32 changes: 32 additions & 0 deletions examples/gno.land/r/demo/tests/crossrealm/crossrealm9.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package crossrealm

var ff = func() string { return "a" } // parent object already escaped

// XXX, this is special case, for ff, it's closure is referenced,
// so need to check all embedded items attached?
// see zrealm_crossrealm38.gno
func GetFunc() func() string {
return ff
}

func GetFunc2() func() string {
return func() string {
return "b"
}
}

type MyStruct struct{}

func (sv *MyStruct) M() string { return "a" }

var mysv *MyStruct = &MyStruct{}

//var f_local func() string
//
//func init() {
// f_local = mysv.M
//}

func GetMethod() func() string {
return mysv.M
}
1 change: 0 additions & 1 deletion gnovm/pkg/gnolang/gno_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ func BenchmarkIfStatement(b *testing.B) {
func main() {
for i:=0; i<10000; i++ {
if i > 10 {

}
}
}`
Expand Down
Loading
Loading