-
Notifications
You must be signed in to change notification settings - Fork 393
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
ltzmaxwell
wants to merge
83
commits into
gnolang:master
Choose a base branch
from
ltzmaxwell:dev/maxwell/cross-realm
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
83 commits
Select commit
Hold shift + click to select a range
2dcdfd5
naive fix
ltzmaxwell 3056bcd
Merge branch 'master' of https://github.com/gnolang/gno
ltzmaxwell e69dfc0
Merge branch 'master' of github.com:gnolang/gno
ltzmaxwell 9d05216
Merge branch 'master' of https://github.com/gnolang/gno
ltzmaxwell fb2f408
fix untyped bool
ltzmaxwell 22f973f
revert un-intentional change
ltzmaxwell 2926b3d
test files
ltzmaxwell c3e3bdd
debug
ltzmaxwell 72b28d7
debug
ltzmaxwell 00a59e7
save
ltzmaxwell 71c6fed
external type
ltzmaxwell 07d9029
save
ltzmaxwell 8fdc399
save
ltzmaxwell a604cdc
more test
ltzmaxwell 2e6a97c
save
ltzmaxwell 7bedb54
save
ltzmaxwell eeb5bd8
more obj info
ltzmaxwell 9175b85
test
ltzmaxwell c41caa3
make test pass
ltzmaxwell 48eb8b9
fixup
ltzmaxwell 0bef907
fixup
ltzmaxwell 585b370
test array
ltzmaxwell c8b24f5
add test
ltzmaxwell ff95ddc
debug
ltzmaxwell ecad113
more embede tests
ltzmaxwell e2670cc
start refactor
ltzmaxwell e28a2ba
save
ltzmaxwell 696e6da
save
ltzmaxwell 675355d
clean
ltzmaxwell 4af9d45
save
ltzmaxwell 588b9dd
change api
ltzmaxwell 928bda2
fixup
ltzmaxwell 35927e6
fixup
ltzmaxwell 8b435e6
fixup
ltzmaxwell 0d2c203
debug
ltzmaxwell e0a040e
add test
ltzmaxwell 3ec7a2e
fixup
ltzmaxwell fd7f8c8
refactor test
ltzmaxwell 453554b
fixup
ltzmaxwell 30883f0
debug
ltzmaxwell b0241aa
fixup
ltzmaxwell 926e6e9
fixup
ltzmaxwell bff5b19
fixup
ltzmaxwell 119e505
fixup
ltzmaxwell 91a38af
clean
ltzmaxwell 6e39af1
merge master
ltzmaxwell b09f61a
fixup{
ltzmaxwell aa06af6
func value check
ltzmaxwell ea06afc
fixup
ltzmaxwell ce22178
fixup
ltzmaxwell 78eca08
fixup
ltzmaxwell 36738b1
save
ltzmaxwell 0a25077
add some comments
ltzmaxwell 23644d8
refactor
ltzmaxwell 301935f
fixup
ltzmaxwell 3342991
fixup
ltzmaxwell 4ed5fe6
save
ltzmaxwell 6b13f34
fixup
ltzmaxwell 943a82e
fixup
ltzmaxwell a57e1bf
fixup
ltzmaxwell 5be6f68
fixup
ltzmaxwell 79e0903
fixup
ltzmaxwell 5a84415
fixup
ltzmaxwell dd7bfa4
fixup
ltzmaxwell 3e949ff
recursive guard
ltzmaxwell 77f4a22
fixup
ltzmaxwell f174e98
test
ltzmaxwell d0ead8c
fixup
ltzmaxwell f527e18
fixup
ltzmaxwell 0f7448d
fixup
ltzmaxwell c740c45
refactor
ltzmaxwell d2981b7
sync
ltzmaxwell e2274bc
recursive guard
ltzmaxwell 3cf2dab
revert machine change
ltzmaxwell 8a30b99
fixup
ltzmaxwell a64a951
test pass
ltzmaxwell b29397b
fixup
ltzmaxwell e0eb2b3
fixup
ltzmaxwell 1d80388
save, handle dirty oo
ltzmaxwell 938b3a4
fixup
ltzmaxwell 5aeadd6
fixup
ltzmaxwell 3bdaab2
clean
ltzmaxwell 9136a1d
sync
ltzmaxwell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
examples/gno.land/r/demo/tests/crossrealm/array/crossrealm_array.gno
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package crossrealm_array | ||
|
||
type Foo struct{ name string } | ||
|
||
var f = Foo{"foo"} | ||
|
||
func GetArray() [2]Foo { | ||
return [2]Foo{Foo{"a"}, Foo{"b"}} | ||
} | ||
|
||
func GetArray2() [2]*Foo { | ||
return [2]*Foo{&Foo{"a"}, &Foo{"b"}} | ||
} | ||
|
||
func GetArray3() [1]*Foo { | ||
return [1]*Foo{&f} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
examples/gno.land/r/demo/tests/crossrealm/func/crossrealm_func.gno
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package crossrealm_func | ||
|
||
type F func() bool | ||
|
||
var f F | ||
|
||
func SetCallback(ff F) { | ||
f = ff | ||
} | ||
|
||
func ExecuteCallback() { | ||
f() | ||
} | ||
|
||
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{} | ||
type MyStruct2 struct{ name string } | ||
|
||
func (sv *MyStruct) M() string { return "a" } | ||
|
||
var mysv *MyStruct = &MyStruct{} | ||
|
||
func (sv2 MyStruct2) M2() string { return "a2" } | ||
|
||
var mysv2 = MyStruct2{name: "struct_val"} | ||
|
||
func GetMethod() func() string { | ||
return mysv.M | ||
} | ||
|
||
func GetMethod2() func() string { | ||
return mysv2.M2 | ||
} |
35 changes: 35 additions & 0 deletions
35
examples/gno.land/r/demo/tests/crossrealm/iface/crossrealm_iface.gno
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package iface | ||
|
||
type Foo2 struct{} | ||
|
||
// 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 RunF() { | ||
container.f.Foo() | ||
} | ||
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 | ||
} |
37 changes: 37 additions & 0 deletions
37
examples/gno.land/r/demo/tests/crossrealm/map/crossrealm_map.gno
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package crossrealm_map | ||
|
||
type Foo struct{} | ||
|
||
var f = Foo{} | ||
|
||
var m map[string]int | ||
|
||
func init() { | ||
m = make(map[string]int) | ||
m["a"] = 1 | ||
} | ||
|
||
func GetMap() map[string]int { | ||
return m | ||
} | ||
|
||
func GetMap2(f func(map[string]int)) { | ||
m1 := map[string]int{"a": 1} | ||
f(m1) | ||
} | ||
|
||
func GetMap4() map[string]Foo { | ||
var m1 = map[string]Foo{"foo": f} | ||
return m1 | ||
} | ||
|
||
// -------------------------------------- | ||
type MyMap map[string]int | ||
|
||
var m2 = MyMap{"a": 1} | ||
|
||
func GetMap3() MyMap { | ||
return m2 | ||
} | ||
|
||
// TODO: add some map with elements of object |
124 changes: 124 additions & 0 deletions
124
examples/gno.land/r/demo/tests/crossrealm/slice/crossrealm_slice.gno
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
package crossrealm_slice | ||
|
||
import "gno.land/p/demo/tests/p_crossrealm" | ||
|
||
type Fooer interface{ Foo() } | ||
|
||
var S []Fooer | ||
|
||
func SetSlice(fs []Fooer) { | ||
S = fs | ||
for _, f := range fs { | ||
f.Foo() | ||
} | ||
} | ||
|
||
var Arr [3]Fooer | ||
|
||
func SetArray(arr [3]Fooer) { | ||
Arr = arr | ||
for _, f := range Arr { | ||
println(f) | ||
} | ||
} | ||
|
||
// ------------------------------------- | ||
type XYZ struct{ name string } | ||
|
||
var s1 []XYZ // underlying array is real after decl | ||
var s3 []XYZ | ||
|
||
// var s4 []XYZ | ||
var s4 = make([]XYZ, 1, 2) | ||
|
||
// NOTE that if new list allocated, XYZ{"4"} will be copied, and it's a new object | ||
// var s4 = make([]XYZ, 1) | ||
var s5 []*XYZ | ||
var s6 = make([]*XYZ, 2) | ||
|
||
var s7 [2]XYZ | ||
|
||
var s10 []int | ||
|
||
func init() { | ||
s1 = append(s1, XYZ{"1"}) | ||
s1 = append(s1, XYZ{"2"}) | ||
|
||
s3 = append(s3, XYZ{"3"}) | ||
//s4 = append(s4, XYZ{"4"}) | ||
s4[0] = 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 | ||
s10 = append(s10, 1) | ||
} | ||
|
||
func GetSlice() []XYZ { | ||
return s1[:] | ||
} | ||
|
||
// ------------------------------------------------------- | ||
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) | ||
} | ||
|
||
func GetSlice5() []*XYZ { // TODO, unwrap | ||
return s5 | ||
} | ||
|
||
func GetSlice6(f func(s []*XYZ)) { | ||
s6[1] = &XYZ{"6.1"} | ||
f(s6) | ||
} | ||
|
||
func GetSlice7(f func(s [2]XYZ)) { | ||
//s7[1] = XYZ{"7.1"} | ||
f(s7) | ||
} | ||
|
||
var s8 [1]p_crossrealm.Stringer | ||
|
||
func GetSlice8(f p_crossrealm.Stringer) [1]p_crossrealm.Stringer { | ||
s8[0] = f | ||
return s8 | ||
} | ||
|
||
func GetSlice9(f p_crossrealm.Stringer) [1]p_crossrealm.Stringer { | ||
var s9 [1]p_crossrealm.Stringer | ||
s9[0] = f | ||
return s9 | ||
} | ||
|
||
// XXX, s10 under array is real, and owned by this realm. | ||
func GetSlice10() []int { | ||
return s10 | ||
} | ||
|
||
func GetSlice11(f func(s []int)) { | ||
// XXX, this is valid cuz the type of | ||
// array is not defined in current realm(or any other), | ||
// and the underlying array is not owned by this realm. | ||
s11 := []int{1} | ||
f(s11) | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for object from pure package, make objectID with a prefix "purePkg", so it's possible to distinct with object from realm. this does not change the current realm object persistence. but it looks ugly.