From 2dcdfd55cfa7fab0ddb438b6d0046ec4013054a2 Mon Sep 17 00:00:00 2001 From: ltzMaxwell Date: Mon, 24 Jun 2024 16:52:58 +0800 Subject: [PATCH 01/40] naive fix --- gnovm/pkg/gnolang/gno_test.go | 84 +++++++++++++++++------------------ gnovm/pkg/gnolang/uverse.go | 5 ++- 2 files changed, 46 insertions(+), 43 deletions(-) diff --git a/gnovm/pkg/gnolang/gno_test.go b/gnovm/pkg/gnolang/gno_test.go index 54d808faefc..583a3a244ab 100644 --- a/gnovm/pkg/gnolang/gno_test.go +++ b/gnovm/pkg/gnolang/gno_test.go @@ -159,37 +159,37 @@ func main() { m.RunMain() } -func BenchmarkPreprocessForLoop(b *testing.B) { - m := NewMachine("test", nil) - c := `package test -func main() { - for i:=0; i<10000; i++ {} -}` - n := MustParseFile("main.go", c) - m.RunFiles(n) - - for i := 0; i < b.N; i++ { - m.RunMain() - } -} - -func BenchmarkIfStatement(b *testing.B) { - m := NewMachine("test", nil) - c := `package test -func main() { - for i:=0; i<10000; i++ { - if i > 10 { - - } - } -}` - n := MustParseFile("main.go", c) - m.RunFiles(n) - - for i := 0; i < b.N; i++ { - m.RunMain() - } -} +//func BenchmarkPreprocessForLoop(b *testing.B) { +// m := NewMachine("test", nil) +// c := `package test +//func main() { +// for i:=0; i<10000; i++ {} +//}` +// n := MustParseFile("main.go", c) +// m.RunFiles(n) +// +// for i := 0; i < b.N; i++ { +// m.RunMain() +// } +//} + +//func BenchmarkIfStatement(b *testing.B) { +// m := NewMachine("test", nil) +// c := `package test +//func main() { +// for i:=0; i<10000; i++ { +// if i > 10 { +// +// } +// } +//}` +// n := MustParseFile("main.go", c) +// m.RunFiles(n) +// +// for i := 0; i < b.N; i++ { +// m.RunMain() +// } +//} func TestDoOpEvalBaseConversion(t *testing.T) { m := NewMachine("test", nil) @@ -401,17 +401,17 @@ func BenchmarkBenchdata(b *testing.B) { name += "_param:" + param } b.Run(name, func(b *testing.B) { - if strings.HasPrefix(name, "matrix.gno_param") { - // CGO_ENABLED=0 go test -bench . -benchmem ./... -short -run=^$ -cpu 1,2 -count=1 ./... - // That is not just exposing test and benchmark traces as output, but these benchmarks are failing - // making the output unparseable: - /* - BenchmarkBenchdata/matrix.gno_param:3 panic: runtime error: index out of range [31] with length 25 [recovered] - panic: runtime error: index out of range [31] with length 25: - ... - */ - b.Skip("it panics causing an error when parsing benchmark results") - } + //if strings.HasPrefix(name, "matrix.gno_param") { + // // CGO_ENABLED=0 go test -bench . -benchmem ./... -short -run=^$ -cpu 1,2 -count=1 ./... + // // That is not just exposing test and benchmark traces as output, but these benchmarks are failing + // // making the output unparseable: + // /* + // BenchmarkBenchdata/matrix.gno_param:3 panic: runtime error: index out of range [31] with length 25 [recovered] + // panic: runtime error: index out of range [31] with length 25: + // ... + // */ + // b.Skip("it panics causing an error when parsing benchmark results") + //} // Gen template with N and param. var buf bytes.Buffer diff --git a/gnovm/pkg/gnolang/uverse.go b/gnovm/pkg/gnolang/uverse.go index 880a75396ca..ad886958adc 100644 --- a/gnovm/pkg/gnolang/uverse.go +++ b/gnovm/pkg/gnolang/uverse.go @@ -65,9 +65,11 @@ var ( const uversePkgPath = ".uverse" +var done bool + // Always returns a new copy from the latest state of source. func Uverse() *PackageValue { - if uverseValue == nil { + if uverseValue == nil || !done { pn := UverseNode() uverseValue = pn.NewPackage() } @@ -1017,6 +1019,7 @@ func UverseNode() *PackageNode { m.Exceptions = nil }, ) + done = true return uverseNode } From fb2f40842a52b8e26e6b58196273879806a675ea Mon Sep 17 00:00:00 2001 From: ltzMaxwell Date: Thu, 22 Aug 2024 23:39:02 +0800 Subject: [PATCH 02/40] fix untyped bool --- gnovm/pkg/gnolang/preprocess.go | 3 +++ gnovm/tests/files/types/eql_0f49.gno | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 gnovm/tests/files/types/eql_0f49.gno diff --git a/gnovm/pkg/gnolang/preprocess.go b/gnovm/pkg/gnolang/preprocess.go index ba60ead28f6..d7b52e3eed9 100644 --- a/gnovm/pkg/gnolang/preprocess.go +++ b/gnovm/pkg/gnolang/preprocess.go @@ -1207,6 +1207,9 @@ func Preprocess(store Store, ctx BlockNode, n Node) Node { "incompatible types in binary expression: %v %v %v", lt.TypeID(), n.Op, rt.TypeID())) } + // convert untyped to typed + checkOrConvertType(store, last, &n.Left, defaultTypeOf(lt), false) + checkOrConvertType(store, last, &n.Right, defaultTypeOf(rt), false) } else { // left untyped, right typed checkOrConvertType(store, last, &n.Left, rt, false) } diff --git a/gnovm/tests/files/types/eql_0f49.gno b/gnovm/tests/files/types/eql_0f49.gno new file mode 100644 index 00000000000..b5a4bf4ed05 --- /dev/null +++ b/gnovm/tests/files/types/eql_0f49.gno @@ -0,0 +1,21 @@ +package main + +func main() { + a := "1234" + b := "1234" + + cond := a == b + println(cond) + println(cond == (a == b)) + println((a == b) == cond) + println((a == b) == (a == b)) + println(cond && (a == b)) + println(cond || (a > b)) + +} + +// true +// true +// true +// true +// true From 22f973f97d5825455ed2eebd57aec01d802ec8ff Mon Sep 17 00:00:00 2001 From: ltzMaxwell Date: Tue, 27 Aug 2024 10:02:11 +0800 Subject: [PATCH 03/40] revert un-intentional change --- gnovm/pkg/gnolang/gno_test.go | 84 +++++++++++++++++------------------ gnovm/pkg/gnolang/uverse.go | 5 +-- 2 files changed, 43 insertions(+), 46 deletions(-) diff --git a/gnovm/pkg/gnolang/gno_test.go b/gnovm/pkg/gnolang/gno_test.go index 583a3a244ab..2c1ed2f003d 100644 --- a/gnovm/pkg/gnolang/gno_test.go +++ b/gnovm/pkg/gnolang/gno_test.go @@ -159,37 +159,37 @@ func main() { m.RunMain() } -//func BenchmarkPreprocessForLoop(b *testing.B) { -// m := NewMachine("test", nil) -// c := `package test -//func main() { -// for i:=0; i<10000; i++ {} -//}` -// n := MustParseFile("main.go", c) -// m.RunFiles(n) -// -// for i := 0; i < b.N; i++ { -// m.RunMain() -// } -//} - -//func BenchmarkIfStatement(b *testing.B) { -// m := NewMachine("test", nil) -// c := `package test -//func main() { -// for i:=0; i<10000; i++ { -// if i > 10 { -// -// } -// } -//}` -// n := MustParseFile("main.go", c) -// m.RunFiles(n) -// -// for i := 0; i < b.N; i++ { -// m.RunMain() -// } -//} +func BenchmarkPreprocessForLoop(b *testing.B) { + m := NewMachine("test", nil) + c := `package test +func main() { + for i:=0; i<10000; i++ {} +}` + n := MustParseFile("main.go", c) + m.RunFiles(n) + + for i := 0; i < b.N; i++ { + m.RunMain() + } +} + +func BenchmarkIfStatement(b *testing.B) { + m := NewMachine("test", nil) + c := `package test +func main() { + for i:=0; i<10000; i++ { + if i > 10 { + + } + } +}` + n := MustParseFile("main.go", c) + m.RunFiles(n) + + for i := 0; i < b.N; i++ { + m.RunMain() + } +} func TestDoOpEvalBaseConversion(t *testing.T) { m := NewMachine("test", nil) @@ -401,17 +401,17 @@ func BenchmarkBenchdata(b *testing.B) { name += "_param:" + param } b.Run(name, func(b *testing.B) { - //if strings.HasPrefix(name, "matrix.gno_param") { - // // CGO_ENABLED=0 go test -bench . -benchmem ./... -short -run=^$ -cpu 1,2 -count=1 ./... - // // That is not just exposing test and benchmark traces as output, but these benchmarks are failing - // // making the output unparseable: - // /* - // BenchmarkBenchdata/matrix.gno_param:3 panic: runtime error: index out of range [31] with length 25 [recovered] - // panic: runtime error: index out of range [31] with length 25: - // ... - // */ - // b.Skip("it panics causing an error when parsing benchmark results") - //} + if strings.HasPrefix(name, "matrix.gno_param") { + // CGO_ENABLED=0 go test -bench . -benchmem ./... -short -run=^$ -cpu 1,2 -count=1 ./... + // That is not just exposing test and benchmark traces as output, but these benchmarks are failing + // making the output unparseable: + /* + BenchmarkBenchdata/matrix.gno_param:3 panic: runtime error: index out of range [31] with length 25 [recovered] + panic: runtime error: index out of range [31] with length 25: + ... + */ + b.Skip("it panics causing an error when parsing benchmark results") + } // Gen template with N and param. var buf bytes.Buffer diff --git a/gnovm/pkg/gnolang/uverse.go b/gnovm/pkg/gnolang/uverse.go index ad886958adc..880a75396ca 100644 --- a/gnovm/pkg/gnolang/uverse.go +++ b/gnovm/pkg/gnolang/uverse.go @@ -65,11 +65,9 @@ var ( const uversePkgPath = ".uverse" -var done bool - // Always returns a new copy from the latest state of source. func Uverse() *PackageValue { - if uverseValue == nil || !done { + if uverseValue == nil { pn := UverseNode() uverseValue = pn.NewPackage() } @@ -1019,7 +1017,6 @@ func UverseNode() *PackageNode { m.Exceptions = nil }, ) - done = true return uverseNode } From 2926b3d2fdeb39eac6e6da0d58a8d0ccda3f2dbd Mon Sep 17 00:00:00 2001 From: ltzMaxwell Date: Mon, 23 Sep 2024 01:30:37 +0800 Subject: [PATCH 04/40] test files --- .../r/demo/tests/crossrealm/crossrealm2.gno | 27 ++++++++++++ .../r/demo/tests/crossrealm/crossrealm3.gno | 17 ++++++++ gnovm/tests/files/zrealm_crossrealm15.gno | 35 ++++++++++++++++ gnovm/tests/files/zrealm_crossrealm16.gno | 24 +++++++++++ gnovm/tests/files/zrealm_crossrealm17.gno | 31 ++++++++++++++ gnovm/tests/files/zrealm_crossrealm18.gno | 34 +++++++++++++++ gnovm/tests/files/zrealm_crossrealm19.gno | 33 +++++++++++++++ gnovm/tests/files/zrealm_crossrealm20.gno | 33 +++++++++++++++ gnovm/tests/files/zrealm_crossrealm21.gno | 24 +++++++++++ gnovm/tests/files/zrealm_crossrealm22.gno | 22 ++++++++++ gnovm/tests/files/zrealm_crossrealm23.gno | 22 ++++++++++ gnovm/tests/files/zrealm_crossrealm23a.gno | 22 ++++++++++ gnovm/tests/files/zrealm_crossrealm24.gno | 22 ++++++++++ gnovm/tests/files/zrealm_crossrealm25.gno | 39 ++++++++++++++++++ gnovm/tests/files/zrealm_crossrealm25a.gno | 41 +++++++++++++++++++ gnovm/tests/files/zrealm_crossrealm26.gno | 32 +++++++++++++++ gnovm/tests/files/zrealm_crossrealm27.gno | 29 +++++++++++++ gnovm/tests/files/zrealm_crossrealm27a.gno | 33 +++++++++++++++ 18 files changed, 520 insertions(+) create mode 100644 examples/gno.land/r/demo/tests/crossrealm/crossrealm2.gno create mode 100644 examples/gno.land/r/demo/tests/crossrealm/crossrealm3.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm15.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm16.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm17.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm18.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm19.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm20.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm21.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm22.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm23.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm23a.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm24.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm25.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm25a.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm26.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm27.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm27a.gno diff --git a/examples/gno.land/r/demo/tests/crossrealm/crossrealm2.gno b/examples/gno.land/r/demo/tests/crossrealm/crossrealm2.gno new file mode 100644 index 00000000000..8f12ec1322d --- /dev/null +++ b/examples/gno.land/r/demo/tests/crossrealm/crossrealm2.gno @@ -0,0 +1,27 @@ +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 { + f Fooer +} + +var container Container // TODO, check does this attach or not + +func AttachContainer() { + container = Container{} +} +func SetContainer(f Fooer) { + container.f = f +} diff --git a/examples/gno.land/r/demo/tests/crossrealm/crossrealm3.gno b/examples/gno.land/r/demo/tests/crossrealm/crossrealm3.gno new file mode 100644 index 00000000000..6fb1b958baf --- /dev/null +++ b/examples/gno.land/r/demo/tests/crossrealm/crossrealm3.gno @@ -0,0 +1,17 @@ +package crossrealm + +type Bar struct { + A int +} + +var bar *Bar + +func SetBar(b *Bar) *Bar { + bar = b + return bar +} + +func CallBar() { + bar.A += 1 + println(bar.A) +} diff --git a/gnovm/tests/files/zrealm_crossrealm15.gno b/gnovm/tests/files/zrealm_crossrealm15.gno new file mode 100644 index 00000000000..fd870731c0e --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm15.gno @@ -0,0 +1,35 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "std" + + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +type fooer struct{} + +func (fooer) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } + +var f *fooer + +// XXX, this attach a heapItem to current realm +func init() { + f = &fooer{} +} + +func main() { + // XXX, this associate a pointer to a value(already attached to local realm) + // to external realm, no attachment happens to the external realm. + crossrealm.SetFooer(f) + crossrealm.CallFoo() + print(".") +} + +// Output: +// hello gno.land/r/demo/tests/crossrealm +// . + +// Error: + +// Realm: diff --git a/gnovm/tests/files/zrealm_crossrealm16.gno b/gnovm/tests/files/zrealm_crossrealm16.gno new file mode 100644 index 00000000000..fd9f9889c38 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm16.gno @@ -0,0 +1,24 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +var b0 crossrealm.Bar + +func init() { + b0 = crossrealm.Bar{A: 1} // attach to this realm +} + +func main() { + crossrealm.SetBar(&b0) // set reference to external realm + crossrealm.CallBar() + print(".") +} + +// Output: +// 1 +// . + +// Error: diff --git a/gnovm/tests/files/zrealm_crossrealm17.gno b/gnovm/tests/files/zrealm_crossrealm17.gno new file mode 100644 index 00000000000..2cc82b960d5 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm17.gno @@ -0,0 +1,31 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "std" + + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +type container struct{ *fooer } + +func (container) Foo() { println("hello container " + std.CurrentRealm().PkgPath()) } + +type fooer struct{} + +var f *fooer + +func main() { + // not finalize yet, so this reference can not be attached to external realm, + // can only be associated to un-attached objects, only until the un-attached + // objects has not been attached to the external realm yet. + f = &fooer{} + c := &container{f} + crossrealm.SetFooer(c) + crossrealm.CallFoo() + print(".") +} + +// Output: +// hello container gno.land/r/demo/tests/crossrealm +// . diff --git a/gnovm/tests/files/zrealm_crossrealm18.gno b/gnovm/tests/files/zrealm_crossrealm18.gno new file mode 100644 index 00000000000..a1c8888fb7d --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm18.gno @@ -0,0 +1,34 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "std" + + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +type fooer struct{} + +func (fooer) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } + +var f crossrealm.Fooer = crossrealm.SetFooer(&fooer{}) + +func init() { + crossrealm.CallFoo() +} + +func main() { + crossrealm.CallFoo() + print(".") +} + +// Output: +// hello gno.land/r/demo/tests/crossrealm +// hello gno.land/r/demo/tests/crossrealm +// . + +// Error: + +// Realm: +// switchrealm["gno.land/r/demo/tests/crossrealm"] +// switchrealm["gno.land/r/crossrealm_test"] diff --git a/gnovm/tests/files/zrealm_crossrealm19.gno b/gnovm/tests/files/zrealm_crossrealm19.gno new file mode 100644 index 00000000000..62b6d08c78f --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm19.gno @@ -0,0 +1,33 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +var b0 = crossrealm.Bar{A: 1} + +// un-attached package level var +// is this attached? or not? another function to attach? +//var b *crossrealm.Bar = crossrealm.SetBar(&b0) + +func init() { + // crossrealm.CallFoo() + crossrealm.SetBar(&b0) +} + +func main() { + crossrealm.CallBar() + print(".") +} + +// Output: +// hello gno.land/r/demo/tests/crossrealm +// hello gno.land/r/demo/tests/crossrealm +// . + +// Error: + +// Realm: +// switchrealm["gno.land/r/demo/tests/crossrealm"] +// switchrealm["gno.land/r/crossrealm_test"] diff --git a/gnovm/tests/files/zrealm_crossrealm20.gno b/gnovm/tests/files/zrealm_crossrealm20.gno new file mode 100644 index 00000000000..62b6d08c78f --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm20.gno @@ -0,0 +1,33 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +var b0 = crossrealm.Bar{A: 1} + +// un-attached package level var +// is this attached? or not? another function to attach? +//var b *crossrealm.Bar = crossrealm.SetBar(&b0) + +func init() { + // crossrealm.CallFoo() + crossrealm.SetBar(&b0) +} + +func main() { + crossrealm.CallBar() + print(".") +} + +// Output: +// hello gno.land/r/demo/tests/crossrealm +// hello gno.land/r/demo/tests/crossrealm +// . + +// Error: + +// Realm: +// switchrealm["gno.land/r/demo/tests/crossrealm"] +// switchrealm["gno.land/r/crossrealm_test"] diff --git a/gnovm/tests/files/zrealm_crossrealm21.gno b/gnovm/tests/files/zrealm_crossrealm21.gno new file mode 100644 index 00000000000..5babaff955b --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm21.gno @@ -0,0 +1,24 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +var b0 crossrealm.Bar + +// XXX, this should fail while trying to attach +// value of type defined in another realm. +// NOTE: the check can be in runtime or in preprocess. +func init() { + b0 = crossrealm.Bar{A: 1} +} + +func main() { + print(".") +} + +// Output: +// . + +// Error: diff --git a/gnovm/tests/files/zrealm_crossrealm22.gno b/gnovm/tests/files/zrealm_crossrealm22.gno new file mode 100644 index 00000000000..8e294e969d3 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm22.gno @@ -0,0 +1,22 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +type Bar struct { + A int +} + +var b0 Bar + +// XXX this works attach value with type defined in same realm +func init() { + b0 = Bar{A: 1} +} + +func main() { + print(".") +} + +// Output: +// . + +// Error: diff --git a/gnovm/tests/files/zrealm_crossrealm23.gno b/gnovm/tests/files/zrealm_crossrealm23.gno new file mode 100644 index 00000000000..ec2f19a9351 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm23.gno @@ -0,0 +1,22 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import "gno.land/p/demo/tests/p_crossrealm" + +var b0 p_crossrealm.Container + +// XXX, this works attach value with type defined in p +func init() { + b0 = p_crossrealm.Container{ + A: 1, + } +} + +func main() { + print(".") +} + +// Output: +// . + +// Error: diff --git a/gnovm/tests/files/zrealm_crossrealm23a.gno b/gnovm/tests/files/zrealm_crossrealm23a.gno new file mode 100644 index 00000000000..21416cdde8f --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm23a.gno @@ -0,0 +1,22 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import "gno.land/p/demo/tests/p_crossrealm" + +var b0 *p_crossrealm.Container + +// XXX, this works, attach reference with type defined in p +func init() { + b0 = &p_crossrealm.Container{ + A: 1, + } +} + +func main() { + print(".") +} + +// Output: +// . + +// Error: diff --git a/gnovm/tests/files/zrealm_crossrealm24.gno b/gnovm/tests/files/zrealm_crossrealm24.gno new file mode 100644 index 00000000000..e6c7d8d2e3c --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm24.gno @@ -0,0 +1,22 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +var b0 *crossrealm.Bar + +// XXX, should work to attach by reference +func init() { + b0 = &crossrealm.Bar{A: 1} +} + +func main() { + print(".") +} + +// Output: +// . + +// Error: diff --git a/gnovm/tests/files/zrealm_crossrealm25.gno b/gnovm/tests/files/zrealm_crossrealm25.gno new file mode 100644 index 00000000000..5ea5e4a520f --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm25.gno @@ -0,0 +1,39 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "std" + + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +type fooer struct{} + +func (fooer) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } + +var f fooer + +// When an association occurs by reference to an object already +// attached to an external realm, no attachment occurs. For example, +// pointers to external realm attached objects may be associated +// with a realm object (whether attached or not), such as assigned +// to the field of a struct, but this does not attach the external +// realm object to the container, in this case the struct. +func init() { + f = fooer{} +} + +func main() { + // XXX, this associate a pointer to a value(already attached to local realm) + // to external realm, no attachment happens to the external realm. + crossrealm.AttachContainer() // this attach container first + crossrealm.SetContainer(&f) + print(".") +} + +// Output: +// . + +// Error: + +// Realm: diff --git a/gnovm/tests/files/zrealm_crossrealm25a.gno b/gnovm/tests/files/zrealm_crossrealm25a.gno new file mode 100644 index 00000000000..1700e72b25f --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm25a.gno @@ -0,0 +1,41 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "std" + + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +type fooer struct{} + +func (fooer) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } + +var f fooer + +// When an association occurs by reference to an object already +// attached to an external realm, no attachment occurs. For example, +// pointers to external realm attached objects may be associated +// with a realm object (whether attached or not), such as assigned +// to the field of a struct, but this does not attach the external +// realm object to the container, in this case the struct. +func init() { + f = fooer{} +} + +func main() { + // XXX, this associate a pointer to a value(not attached) + // to external realm, no attachment happens to the external realm. + + // XXX, attach to un-attached external realm + //crossrealm.AttachContainer() // this attach container first + crossrealm.SetContainer(&f) + print(".") +} + +// Output: +// . + +// Error: + +// Realm: diff --git a/gnovm/tests/files/zrealm_crossrealm26.gno b/gnovm/tests/files/zrealm_crossrealm26.gno new file mode 100644 index 00000000000..6fff7ac6b96 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm26.gno @@ -0,0 +1,32 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "std" + + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +type fooer struct{} + +func (fooer) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } + +var f fooer + +// Pointers to external realm objects that are not yet +// attached to the external realm may not be associated +// with an attached object. + +func main() { + crossrealm.AttachContainer() // this attach container first + f = fooer{} // not attached to local realm yet, cannot be able to attach to external attached even by reference + crossrealm.SetContainer(&f) + print(".") +} + +// Output: +// . + +// Error: + +// Realm: diff --git a/gnovm/tests/files/zrealm_crossrealm27.gno b/gnovm/tests/files/zrealm_crossrealm27.gno new file mode 100644 index 00000000000..28a091d7e7c --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm27.gno @@ -0,0 +1,29 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "std" + + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +type fooer struct{} + +func (fooer) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } + +var f fooer + +// XXX, this should work when reference to not attached local object +// associated to external realm *NOT* attached object. +func main() { + f = fooer{} + crossrealm.SetContainer(&f) + print(".") +} + +// Output: +// . + +// Error: + +// Realm: diff --git a/gnovm/tests/files/zrealm_crossrealm27a.gno b/gnovm/tests/files/zrealm_crossrealm27a.gno new file mode 100644 index 00000000000..6d29277240e --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm27a.gno @@ -0,0 +1,33 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "std" + + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +type fooer struct{} + +func (fooer) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } + +var f fooer + +// XXX, this should work when reference to not attached local object +// associated to external realm *NOT* attached object. +// XXX, panic should happen when the attachment happen in external realm + +// In this way, all references to external realm objects that are reachable +// from a realm’s package global variables must already be attached to the external realm. +func main() { + f = fooer{} + crossrealm.SetContainer(&f) + print(".") +} + +// Output: +// . + +// Error: + +// Realm: From c3e3bdd6cc403e6e1d91e63bf44685f8f018982e Mon Sep 17 00:00:00 2001 From: ltzMaxwell Date: Mon, 23 Sep 2024 10:06:52 +0200 Subject: [PATCH 05/40] debug --- gnovm/pkg/gnolang/machine.go | 83 +++++++++++++++----- gnovm/pkg/gnolang/op_assign.go | 3 + gnovm/pkg/gnolang/op_call.go | 7 ++ gnovm/pkg/gnolang/op_eval.go | 3 + gnovm/pkg/gnolang/op_exec.go | 2 + gnovm/pkg/gnolang/op_expressions.go | 3 + gnovm/pkg/gnolang/ownership.go | 51 ++++++++---- gnovm/pkg/gnolang/realm.go | 116 +++++++++++++++++++++++++++- gnovm/pkg/gnolang/store.go | 5 ++ gnovm/pkg/gnolang/values.go | 22 ++++++ 10 files changed, 255 insertions(+), 40 deletions(-) diff --git a/gnovm/pkg/gnolang/machine.go b/gnovm/pkg/gnolang/machine.go index 24f94abc10b..ad3fbeee7f2 100644 --- a/gnovm/pkg/gnolang/machine.go +++ b/gnovm/pkg/gnolang/machine.go @@ -47,8 +47,8 @@ func (e UnhandledPanicError) Error() string { type Machine struct { // State - Ops []Op // main operations - NumOps int + Ops []Op // operations stack + NumOps int // number of operations Values []TypedValue // buffer of values to be operated on NumValues int // number of values Exprs []Expr // pending expressions @@ -58,9 +58,9 @@ type Machine struct { Package *PackageValue // active package Realm *Realm // active realm Alloc *Allocator // memory allocations - Exceptions []Exception - NumResults int // number of results returned - Cycles int64 // number of "cpu" cycles + Exceptions []Exception // exceptions stack + NumResults int // number of results returned + Cycles int64 // number of "cpu" cycles performed Debugger Debugger @@ -210,17 +210,28 @@ func (m *Machine) Release() { machinePool.Put(m) } +// Convenience for initial setup of the machine. func (m *Machine) SetActivePackage(pv *PackageValue) { + //fmt.Println("---SetActivePackage, pv: ", pv) if err := m.CheckEmpty(); err != nil { panic(errors.Wrap(err, "set package when machine not empty")) } m.Package = pv m.Realm = pv.GetRealm() + //fmt.Println("---SetActivePackage, m.Realm", m.Realm) m.Blocks = []*Block{ pv.GetBlock(m.Store), } } +func (m *Machine) setCurrentPackage(pv *PackageValue) { + m.Package = pv + rlm := pv.GetRealm() + if rlm != nil { + m.Realm = rlm + } +} + //---------------------------------------- // top level Run* methods. @@ -275,6 +286,7 @@ func (m *Machine) RunMemPackageWithOverrides(memPkg *std.MemPackage, save bool) } func (m *Machine) runMemPackage(memPkg *std.MemPackage, save, overrides bool) (*PackageNode, *PackageValue) { + fmt.Println("---runMemPackage, save: ", save) // parse files. files := ParseMemPackage(memPkg) if !overrides && checkDuplicates(files) { @@ -296,6 +308,7 @@ func (m *Machine) runMemPackage(memPkg *std.MemPackage, save, overrides bool) (* m.SetActivePackage(pv) // run files. updates := m.RunFileDecls(files.Files...) + fmt.Println("---updates: ", updates) // save package value and mempackage. // XXX save condition will be removed once gonative is removed. var throwaway *Realm @@ -305,6 +318,7 @@ func (m *Machine) runMemPackage(memPkg *std.MemPackage, save, overrides bool) (* if throwaway != nil { m.Realm = throwaway } + fmt.Println("---save, throwaway: ", throwaway) } // run init functions m.runInitFromUpdates(pv, updates) @@ -714,13 +728,16 @@ func (m *Machine) runFileDecls(fns ...*FileNode) []TypedValue { // multiple files belonging to the same package in // lexical file name order to a compiler." func (m *Machine) runInitFromUpdates(pv *PackageValue, updates []TypedValue) { + fmt.Println("---runInitFromUpdates") for _, tv := range updates { + fmt.Println("---tv: ", tv) if tv.IsDefined() && tv.T.Kind() == FuncKind && tv.V != nil { fv, ok := tv.V.(*FuncValue) if !ok { continue // skip native functions. } if strings.HasPrefix(string(fv.Name), "init.") { + fmt.Println("---fv.Name: ", fv.Name) fb := pv.GetFileBlock(m.Store, fv.FileName) m.PushBlock(fb) m.RunFunc(fv.Name) @@ -767,10 +784,12 @@ func (m *Machine) saveNewPackageValuesAndTypes() (throwaway *Realm) { // Pass in the realm from m.saveNewPackageValuesAndTypes() // in case a throwaway was created. func (m *Machine) resavePackageValues(rlm *Realm) { + fmt.Println("---resavePackageValues, realm: ", rlm) // save package value and dependencies. pv := m.Package if pv.IsRealm() { rlm = pv.Realm + fmt.Println("---rlm: ", rlm) rlm.FinalizeRealmTransaction(m.ReadOnly, m.Store) // re-save package realm info. m.Store.SetPackageRealm(rlm) @@ -1832,6 +1851,7 @@ func (m *Machine) PushFrameBasic(s Stmt) { // ensure the counts are consistent, otherwise we mask // bugs with frame pops. func (m *Machine) PushFrameCall(cx *CallExpr, fv *FuncValue, recv TypedValue) { + fmt.Printf("---PushFrameCall---, cx: %v, fv: %v, recv: %v\n", cx, fv, recv) fr := &Frame{ Source: cx, NumOps: m.NumOps, @@ -1857,29 +1877,54 @@ func (m *Machine) PushFrameCall(cx *CallExpr, fv *FuncValue, recv TypedValue) { m.Printf("+F %#v\n", fr) } m.Frames = append(m.Frames, fr) - pv := fv.GetPackage(m.Store) - if pv == nil { - panic(fmt.Sprintf("package value missing in store: %s", fv.PkgPath)) - } - rlm := pv.GetRealm() - if rlm == nil && recv.IsDefined() { + fmt.Println("---recv: ", recv) + if recv.IsDefined() { + // If the receiver is defined, we enter the receiver's realm. obj := recv.GetFirstObject(m.Store) + fmt.Println("---obj, rt of obj: ", obj, reflect.TypeOf(obj)) + fmt.Println("---obj.GetObjectID: ", obj.GetObjectID()) + fmt.Printf("---obj addr: %p\n", obj) if obj == nil { // could be a nil receiver. - // just ignore. + // set package and realm of function. + pv := fv.GetPackage(m.Store) + if pv == nil { + panic(fmt.Sprintf("package value missing in store: %s", fv.PkgPath)) + } + m.setCurrentPackage(pv) // maybe new realm } else { recvOID := obj.GetObjectInfo().ID - if !recvOID.IsZero() { + fmt.Println("---recvOID is: ", recvOID) + if recvOID.IsZero() { + //panic("!!!should not happen!!!") + fmt.Println("!!! recvOID is ZERO!!!") + // TODO: object reference by external realm must first be attached, + // check here... + // NOTE: the reference has two types: + // 1. if associated with global or child of global, panic; + // 2. if associated with un-attached object directly/indirectly, ok, + // when the un-attached object is attached, check if the target + // object has been attached(become real), if not, panic. + + fmt.Println("---recv is ZERO, it's not owned, recv: ", recv) + fmt.Println("---recv is ZERO, m.realm: ", m.Realm) + + // receiver isn't owned yet. + // just continue with current package and realm. + // XXX is this reasonable? + } else { // override the pv and rlm with receiver's. recvPkgOID := ObjectIDFromPkgID(recvOID.PkgID) - pv = m.Store.GetObject(recvPkgOID).(*PackageValue) - rlm = pv.GetRealm() // done + pv := m.Store.GetObject(recvPkgOID).(*PackageValue) + m.setCurrentPackage(pv) // maybe new realm } } - } - m.Package = pv - if rlm != nil && m.Realm != rlm { - m.Realm = rlm // enter new realm + } else { + pv := fv.GetPackage(m.Store) + if pv == nil { + panic(fmt.Sprintf("package value missing in store: %s", fv.PkgPath)) + } + m.setCurrentPackage(pv) // maybe new realm } } diff --git a/gnovm/pkg/gnolang/op_assign.go b/gnovm/pkg/gnolang/op_assign.go index eb67ffcc351..a10429367ae 100644 --- a/gnovm/pkg/gnolang/op_assign.go +++ b/gnovm/pkg/gnolang/op_assign.go @@ -1,5 +1,7 @@ package gnolang +import "fmt" + func (m *Machine) doOpDefine() { s := m.PopStmt().(*AssignStmt) // Define each value evaluated for Lhs. @@ -25,6 +27,7 @@ func (m *Machine) doOpDefine() { } func (m *Machine) doOpAssign() { + fmt.Println("---doOpAssign, m.Realm: ", m.Realm) s := m.PopStmt().(*AssignStmt) // Assign each value evaluated for Lhs. // NOTE: PopValues() returns a slice in diff --git a/gnovm/pkg/gnolang/op_call.go b/gnovm/pkg/gnolang/op_call.go index 15531ec610d..d148457bd89 100644 --- a/gnovm/pkg/gnolang/op_call.go +++ b/gnovm/pkg/gnolang/op_call.go @@ -7,6 +7,7 @@ import ( ) func (m *Machine) doOpPrecall() { + fmt.Println("---doOpPrecall---") cx := m.PopExpr().(*CallExpr) v := m.PeekValue(1 + cx.NumArgs).V if debug { @@ -19,9 +20,13 @@ func (m *Machine) doOpPrecall() { } switch fv := v.(type) { case *FuncValue: + fmt.Println("---FuncValue, fv: ", fv) m.PushFrameCall(cx, fv, TypedValue{}) m.PushOp(OpCall) case *BoundMethodValue: + fmt.Println("---BoundMethodValue, fv: ", fv) + fmt.Println("---BoundMethodValue, fv.Func: ", fv.Func) + fmt.Println("---BoundMethodValue, fv.Receiver: ", fv.Receiver) m.PushFrameCall(cx, fv.Func, fv.Receiver) m.PushOp(OpCall) case TypeValue: @@ -46,6 +51,7 @@ func (m *Machine) doOpPrecall() { var gReturnStmt = &ReturnStmt{} func (m *Machine) doOpCall() { + fmt.Println("---doOpCall---") // NOTE: Frame won't be popped until the statement is complete, to // discard the correct number of results for func calls in ExprStmts. fr := m.LastFrame() @@ -199,6 +205,7 @@ func (m *Machine) doOpReturn() { finalize = true } if finalize { + fmt.Println("---going to finalizeRealmTransaction at return after call") // Finalize realm updates! // NOTE: This is a resource intensive undertaking. crlm.FinalizeRealmTransaction(m.ReadOnly, m.Store) diff --git a/gnovm/pkg/gnolang/op_eval.go b/gnovm/pkg/gnolang/op_eval.go index 701615fff13..3ef6da71210 100644 --- a/gnovm/pkg/gnolang/op_eval.go +++ b/gnovm/pkg/gnolang/op_eval.go @@ -37,6 +37,7 @@ func (m *Machine) doOpEval() { lb := m.LastBlock() // Push value, done. ptr := lb.GetPointerTo(m.Store, nx.Path) + fmt.Println("---ptr: ", ptr) m.PushValue(ptr.Deref()) return } @@ -242,6 +243,7 @@ func (m *Machine) doOpEval() { m.PushOp(OpEval) } case *CallExpr: + fmt.Println("---Eval, CallExpr, x: ", x) m.PushOp(OpPrecall) // Eval args. args := x.Args @@ -265,6 +267,7 @@ func (m *Machine) doOpEval() { m.PushExpr(x.X) m.PushOp(OpEval) case *SelectorExpr: + fmt.Println("---Eval, SelectorExpr, x: ", x) m.PushOp(OpSelector) // evaluate x m.PushExpr(x.X) diff --git a/gnovm/pkg/gnolang/op_exec.go b/gnovm/pkg/gnolang/op_exec.go index c7e8ffd600c..a0f84f82e66 100644 --- a/gnovm/pkg/gnolang/op_exec.go +++ b/gnovm/pkg/gnolang/op_exec.go @@ -56,6 +56,7 @@ func (m *Machine) doOpExec(op Op) { debug.Printf("PEEK STMT: %v\n", s) debug.Printf("%v\n", m) } + fmt.Printf("PEEK STMT: %v\n", s) // NOTE this could go in the switch statement, and we could // use the EXEC_SWITCH to jump back, rather than putting this @@ -485,6 +486,7 @@ EXEC_SWITCH: // All expressions push 1 value except calls, // which push as many as there are results. if _, ok := cs.X.(*CallExpr); ok { + fmt.Println("---CallExpr: ", cs.X) m.PushOp(OpPopResults) } else { m.PushOp(OpPopValue) diff --git a/gnovm/pkg/gnolang/op_expressions.go b/gnovm/pkg/gnolang/op_expressions.go index 8ff0b5bd538..7492a5f1ec7 100644 --- a/gnovm/pkg/gnolang/op_expressions.go +++ b/gnovm/pkg/gnolang/op_expressions.go @@ -76,9 +76,12 @@ func (m *Machine) doOpIndex2() { } func (m *Machine) doOpSelector() { + fmt.Println("---doOpSelector---") sx := m.PopExpr().(*SelectorExpr) xv := m.PeekValue(1) + fmt.Println("---xv: ", xv) res := xv.GetPointerTo(m.Alloc, m.Store, sx.Path).Deref() + fmt.Println("---res: ", res) if debug { m.Printf("-v[S] %v\n", xv) m.Printf("+v[S] %v\n", res) diff --git a/gnovm/pkg/gnolang/ownership.go b/gnovm/pkg/gnolang/ownership.go index 511b44bfc73..f46ba335a41 100644 --- a/gnovm/pkg/gnolang/ownership.go +++ b/gnovm/pkg/gnolang/ownership.go @@ -3,6 +3,7 @@ package gnolang import ( "encoding/hex" "fmt" + "reflect" "strconv" "strings" @@ -112,6 +113,8 @@ type Object interface { SetIsDeleted(bool, uint64) GetIsNewReal() bool SetIsNewReal(bool) + GetIsCrossRealm() bool + SetIsCrossRealm(bool) GetIsNewEscaped() bool SetIsNewEscaped(bool) GetIsNewDeleted() bool @@ -140,31 +143,36 @@ type ObjectInfo struct { RefCount int // for persistence. deleted/gc'd if 0. IsEscaped bool `json:",omitempty"` // hash in iavl. // MemRefCount int // consider for optimizations. - isDirty bool - isDeleted bool - isNewReal bool - isNewEscaped bool - isNewDeleted bool + isDirty bool + isDeleted bool + isNewReal bool + isCrossRealm bool + isNewEscaped bool + isNewDeleted bool + lastNewRealEscapedRealm PkgID // realm attached and escaped // XXX huh? owner Object // mem reference to owner. } -// Copy used for serialization of objects. // Note that "owner" is nil. func (oi *ObjectInfo) Copy() ObjectInfo { return ObjectInfo{ - ID: oi.ID, - Hash: oi.Hash.Copy(), - OwnerID: oi.OwnerID, - ModTime: oi.ModTime, - RefCount: oi.RefCount, - IsEscaped: oi.IsEscaped, - isDirty: oi.isDirty, - isDeleted: oi.isDeleted, - isNewReal: oi.isNewReal, - isNewEscaped: oi.isNewEscaped, - isNewDeleted: oi.isNewDeleted, + ID: oi.ID, + Hash: oi.Hash.Copy(), + OwnerID: oi.OwnerID, + ModTime: oi.ModTime, + RefCount: oi.RefCount, + IsEscaped: oi.IsEscaped, + /* + // XXX do the following need copying too? + isDirty: oi.isDirty, + isDeleted: oi.isDeleted, + isNewReal: oi.isNewReal, + isNewEscaped: oi.isNewEscaped, + isNewDeleted: oi.isNewDeleted, + lastNewRealEscapedRealm: oi.lastNewRealEscapedRealm, + */ } } @@ -305,6 +313,14 @@ func (oi *ObjectInfo) SetIsNewReal(x bool) { oi.isNewReal = x } +func (oi *ObjectInfo) GetIsCrossRealm() bool { + return oi.isCrossRealm +} + +func (oi *ObjectInfo) SetIsCrossRealm(x bool) { + oi.isCrossRealm = x +} + func (oi *ObjectInfo) GetIsNewEscaped() bool { return oi.isNewEscaped } @@ -326,6 +342,7 @@ func (oi *ObjectInfo) GetIsTransient() bool { } func (tv *TypedValue) GetFirstObject(store Store) Object { + fmt.Println("---GetFirstObject---, tv: ", tv, reflect.TypeOf(tv.V)) switch cv := tv.V.(type) { case PointerValue: return cv.GetBase(store) diff --git a/gnovm/pkg/gnolang/realm.go b/gnovm/pkg/gnolang/realm.go index 3710524130a..606375d06f9 100644 --- a/gnovm/pkg/gnolang/realm.go +++ b/gnovm/pkg/gnolang/realm.go @@ -134,6 +134,41 @@ func (rlm *Realm) String() string { // xo or co is nil if the element value is undefined or has no // associated object. func (rlm *Realm) DidUpdate(po, xo, co Object) { + fmt.Println("---DidUpdate---") + fmt.Println("---xo: ", xo, reflect.TypeOf(xo)) + fmt.Println("---co: ", co, reflect.TypeOf(co)) + fmt.Println("---po: ", po, reflect.TypeOf(po)) + + if co != nil { + fmt.Println("co.GetObjectInfo:", co.GetObjectInfo()) + } + + if sv, ok := po.(*StructValue); ok { + fmt.Println("---sv: ", sv) + fmt.Println("---sv.ID: ", sv.ObjectInfo.ID) + fmt.Println("---sv.Fields: ", sv.Fields) + fmt.Println("---sv.OwnerID: ", sv.ObjectInfo.OwnerID) + } else if bv, ok := po.(*Block); ok { + for _, tv := range bv.Values { + fmt.Println("----tv.T: ", tv.T) + fmt.Println("----tv.V: ", tv.V) + if csv, ok := co.(*StructValue); ok { + if csv == tv.V { + fmt.Println("---eql, csv: ", csv) + fmt.Println("---eql, T: ", tv.T, reflect.TypeOf(tv.T)) + if dt, ok := tv.T.(*DeclaredType); ok { + fmt.Println("---dt: ", dt, dt.PkgPath) + if IsRealmPath(dt.PkgPath) && dt.PkgPath != rlm.Path { + co.SetIsCrossRealm(true) + //panic("!!!") + } + } + } + } + } + } + + fmt.Println("---realm: ", rlm) if rlm == nil { return } @@ -148,10 +183,12 @@ func (rlm *Realm) DidUpdate(po, xo, co Object) { panic("cannot attach to a deleted object") } } - if po == nil || !po.GetIsReal() { + if po == nil || !po.GetIsReal() { // XXX, make sure po is attached return // do nothing. } + fmt.Println("---po.GetObjectID(): ", po.GetObjectID()) if po.GetObjectID().PkgID != rlm.ID { + fmt.Printf("po.GetObjectID().PkgID: %v, rlm.ID: %v\n", po.GetObjectID().PkgID, rlm.ID) panic("cannot modify external-realm or non-realm object") } @@ -166,18 +203,23 @@ func (rlm *Realm) DidUpdate(po, xo, co Object) { rlm.MarkDirty(po) if co != nil { + fmt.Println("---co: ", co) + fmt.Println("---co.GetRefCount: ", co.GetRefCount()) co.IncRefCount() if co.GetRefCount() > 1 { if co.GetIsEscaped() { // already escaped } else { - rlm.MarkNewEscaped(co) + rlm.MarkNewEscapedCheckCrossRealm(co) + //rlm.MarkNewEscaped(co) } } else if co.GetIsReal() { + println("---co is real") rlm.MarkDirty(co) } else { + println("---else") co.SetOwner(po) - rlm.MarkNewReal(co) + rlm.MarkNewReal(co) // co will be attached when finalize } } @@ -194,7 +236,35 @@ func (rlm *Realm) DidUpdate(po, xo, co Object) { //---------------------------------------- // mark* +func (rlm *Realm) MarkNewEscapedCheckCrossRealm(oo Object) { + fmt.Println("---MarkNewEscapedCheckCrossRealm---, oo: ", oo) + oi := oo.GetObjectInfo() + fmt.Println("----oi: ", oi) + fmt.Println("----oi.lastNewRealEscapedRealm: ", oi.lastNewRealEscapedRealm) + fmt.Println("----rlm.ID: ", rlm.ID) + + if oi.lastNewRealEscapedRealm == rlm.ID { + // already processed for this realm, + // see below. + return + } + if !oi.GetIsReal() { // e.g. attach object initialized in 'init', mark it as new real/attached, thus it has an object ID. + fmt.Println("---oi Not real, oi: ", oi.ID) + // this can happen if a ref +1 + // new object gets passed into + // an external realm function. + oi.lastNewRealEscapedRealm = rlm.ID + oi.SetIsNewReal(false) + rlm.MarkNewReal(oo) + } else { + fmt.Println("---oo is real, oi:", oi.ID) + // TODO: set last escape realm? + } + rlm.MarkNewEscaped(oo) +} + func (rlm *Realm) MarkNewReal(oo Object) { + fmt.Println("---markNewReal---, oo: ", oo) if debug { if pv, ok := oo.(*PackageValue); ok { // packages should have no owner. @@ -215,6 +285,7 @@ func (rlm *Realm) MarkNewReal(oo Object) { } } if oo.GetIsNewReal() { + println("---markNewReal---, oo: ", oo) return // already marked. } oo.SetIsNewReal(true) @@ -226,6 +297,7 @@ func (rlm *Realm) MarkNewReal(oo Object) { } func (rlm *Realm) MarkDirty(oo Object) { + fmt.Printf("rlm: %v MarkDirty: %v\n", rlm, oo) if debug { if !oo.GetIsReal() && !oo.GetIsNewReal() { panic("cannot mark unreal object as dirty") @@ -266,6 +338,7 @@ func (rlm *Realm) MarkNewDeleted(oo Object) { } func (rlm *Realm) MarkNewEscaped(oo Object) { + fmt.Println("---MarkNewEscaped---, oo: ", oo) if debug { if !oo.GetIsNewReal() && !oo.GetIsReal() { panic("cannot mark unreal object as new escaped") @@ -293,6 +366,10 @@ func (rlm *Realm) MarkNewEscaped(oo Object) { // OpReturn calls this when exiting a realm transaction. func (rlm *Realm) FinalizeRealmTransaction(readonly bool, store Store) { + fmt.Println("---FinalizeRealmTransaction---") + defer func() { + fmt.Println("---done FinalizeRealmTransaction---") + }() if readonly { if true || len(rlm.newCreated) > 0 || @@ -358,8 +435,16 @@ func (rlm *Realm) FinalizeRealmTransaction(readonly bool, store Store) { // All newly created objects become appended to .created, // and get assigned ids. func (rlm *Realm) processNewCreatedMarks(store Store) { + fmt.Println("---processNewCreatedMarks---") // Create new objects and their new descendants. - for _, oo := range rlm.newCreated { + //for _, oo := range rlm.newCreated { + for i := 0; i < len(rlm.newCreated); i++ { + oo := rlm.newCreated[i] + fmt.Println("---oo: ", oo) + if oo.GetIsCrossRealm() { + fmt.Println("---should not attach value with type defined in other realm") + //panic("---!!!") + } if debug { if oo.GetIsDirty() { panic("new created mark cannot be dirty") @@ -387,6 +472,8 @@ func (rlm *Realm) processNewCreatedMarks(store Store) { // oo must be marked new-real, and ref-count already incremented. func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { + fmt.Println("---incRefCreatedDescendants---, oo: ", oo) + fmt.Println("---incRefCreatedDescendants---, oo.GetObjectID: ", oo.GetObjectID()) if debug { if oo.GetIsDirty() { panic("cannot increase reference of descendants of dirty objects") @@ -409,7 +496,10 @@ func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { // recurse for children. more := getChildObjects2(store, oo) + fmt.Println("---more: ", more) for _, child := range more { + fmt.Println("---child: ", child) + fmt.Printf("---child addr: %p\n", child) if _, ok := child.(*PackageValue); ok { if debug { if child.GetRefCount() < 1 { @@ -421,12 +511,16 @@ func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { } child.IncRefCount() rc := child.GetRefCount() + fmt.Println("---rc: ", rc) if rc == 1 { + fmt.Println("---rc == 1") if child.GetIsReal() { + fmt.Println("---child is real, child: ", child) // a deleted real became undeleted. child.SetOwner(oo) rlm.MarkDirty(child) } else { + fmt.Println("---child NOT real, child: ", child) // a (possibly pre-existing) new object // became real (again). // NOTE: may already be marked for first gen @@ -443,6 +537,7 @@ func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { // may become unescaped later // in processNewEscapedMarks(). // NOTE: may already be escaped. + fmt.Println("---in recursive, mark new escaped, child: ", child) rlm.MarkNewEscaped(child) } } else { @@ -460,6 +555,7 @@ func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { // to rlm.deleted. // Must run *after* processNewCreatedMarks(). func (rlm *Realm) processNewDeletedMarks(store Store) { + fmt.Println("---processNewDeletedMarks---") for _, oo := range rlm.newDeleted { if debug { if oo.GetObjectID().IsZero() { @@ -523,6 +619,7 @@ func (rlm *Realm) decRefDeletedDescendants(store Store, oo Object) { // objects get their original owners marked dirty (to be further // marked via markDirtyAncestors). func (rlm *Realm) processNewEscapedMarks(store Store) { + fmt.Println("---processNewEscapedMarks---") escaped := make([]Object, 0, len(rlm.newEscaped)) // These are those marked by MarkNewEscaped(), // regardless of whether new-real or was real, @@ -531,6 +628,8 @@ func (rlm *Realm) processNewEscapedMarks(store Store) { // except for new-reals that get demoted // because ref-count isn't >= 2. for _, eo := range rlm.newEscaped { + fmt.Println("---processNewEscapedMarks, eo, eo.GetRefCount: ", eo, eo.GetRefCount()) + fmt.Println("---processNewEscapedMarks, eo, eo.GetObjectID: ", eo, eo.GetObjectID()) if debug { if !eo.GetIsNewEscaped() { panic("new escaped mark not marked as new escaped") @@ -584,6 +683,7 @@ func (rlm *Realm) processNewEscapedMarks(store Store) { // (ancestors) must be marked as dirty to update the // hash tree. func (rlm *Realm) markDirtyAncestors(store Store) { + fmt.Println("---markDirtyAncestors---") markAncestorsOne := func(oo Object) { for { if pv, ok := oo.(*PackageValue); ok { @@ -652,6 +752,7 @@ func (rlm *Realm) markDirtyAncestors(store Store) { // Saves .created and .updated objects. func (rlm *Realm) saveUnsavedObjects(store Store) { + fmt.Println("---saveUnsavedObjects---") for _, co := range rlm.created { // for i := len(rlm.created) - 1; i >= 0; i-- { // co := rlm.created[i] @@ -755,6 +856,7 @@ func (rlm *Realm) saveObject(store Store, oo Object) { // removeDeletedObjects func (rlm *Realm) removeDeletedObjects(store Store) { + fmt.Println("---removeDeletedObjects---") for _, do := range rlm.deleted { store.DelObject(do) } @@ -1061,6 +1163,7 @@ func copyTypeWithRefs(typ Type) Type { // Also checks for integrity of immediate children -- they must already be // persistent (real), and not dirty, or else this function panics. func copyValueWithRefs(val Value) Value { + fmt.Println("---copyValueWithRefs, val: ", val) switch cv := val.(type) { case nil: return nil @@ -1423,11 +1526,14 @@ func (rlm *Realm) nextObjectID() ObjectID { // Object gets its id set (panics if already set), and becomes // marked as new and real. func (rlm *Realm) assignNewObjectID(oo Object) ObjectID { + fmt.Printf("---assignNewObjectID, rlm: %v, oo: %v\n", rlm, oo) oid := oo.GetObjectID() + fmt.Println("---oid: ", oid) if !oid.IsZero() { panic("unexpected non-zero object id") } noid := rlm.nextObjectID() + fmt.Println("---noid: ", noid) oo.SetObjectID(noid) return noid } @@ -1443,6 +1549,7 @@ func toRefNode(bn BlockNode) RefNode { } func toRefValue(val Value) RefValue { + fmt.Println("---toRefValue", val) // TODO use type switch stmt. if ref, ok := val.(RefValue); ok { return ref @@ -1516,6 +1623,7 @@ func ensureUniq(oozz ...[]Object) { } func refOrCopyValue(tv TypedValue) TypedValue { + fmt.Println("---refOrCopyValue:", tv) if tv.T != nil { tv.T = refOrCopyType(tv.T) } diff --git a/gnovm/pkg/gnolang/store.go b/gnovm/pkg/gnolang/store.go index 038f4ba894b..30443032d12 100644 --- a/gnovm/pkg/gnolang/store.go +++ b/gnovm/pkg/gnolang/store.go @@ -324,9 +324,11 @@ func (ds *defaultStore) loadObjectSafe(oid ObjectID) Object { // NOTE: unlike GetObject(), SetObject() is also used to persist updated // package values. func (ds *defaultStore) SetObject(oo Object) { + fmt.Println("---SetObject---,oo: ", oo) oid := oo.GetObjectID() // replace children/fields with Ref. o2 := copyValueWithRefs(oo) + fmt.Println("---o2: ", o2) // marshal to binary. bz := amino.MustMarshalAny(o2) // set hash. @@ -361,8 +363,10 @@ func (ds *defaultStore) SetObject(oo Object) { if ds.opslog != nil { var op StoreOpType if oo.GetIsNewReal() { + fmt.Println("---oo is new real, oo: ", oo) op = StoreOpNew } else { + fmt.Println("---oo is mod, oo: ", oo) op = StoreOpMod } ds.opslog = append(ds.opslog, @@ -378,6 +382,7 @@ func (ds *defaultStore) SetObject(oo Object) { } func (ds *defaultStore) DelObject(oo Object) { + fmt.Println("---DelObject, oo: ", oo) oid := oo.GetObjectID() // delete from cache. delete(ds.cacheObjects, oid) diff --git a/gnovm/pkg/gnolang/values.go b/gnovm/pkg/gnolang/values.go index 5da7c15bb05..009f253e0e2 100644 --- a/gnovm/pkg/gnolang/values.go +++ b/gnovm/pkg/gnolang/values.go @@ -193,14 +193,17 @@ const ( ) func (pv *PointerValue) GetBase(store Store) Object { + fmt.Printf("GetBase, pv.Base: %v\n", pv.Base) switch cbase := pv.Base.(type) { case nil: return nil case RefValue: + println("---RefValue") base := store.GetObject(cbase.ObjectID).(Object) pv.Base = base return base case Object: + fmt.Println("---Object, cbase: ", cbase) return cbase default: panic(fmt.Sprintf("unexpected pointer base type %T", cbase)) @@ -211,6 +214,9 @@ func (pv *PointerValue) GetBase(store Store) Object { // TODO: document as something that enables into-native assignment. // TODO: maybe consider this as entrypoint for DataByteValue too? func (pv PointerValue) Assign2(alloc *Allocator, store Store, rlm *Realm, tv2 TypedValue, cu bool) { + fmt.Println("---Assign2, pv: ", pv) + fmt.Println("---Assign2, tv2: ", tv2) + fmt.Println("---Assign2, realm: ", rlm) // Special cases. if pv.Index == PointerIndexNative { // Special case if extended object && native. @@ -1701,6 +1707,7 @@ func (tv *TypedValue) Assign(alloc *Allocator, tv2 TypedValue, cu bool) { // allocated, *Allocator.AllocatePointer() is called separately, // as in OpRef. func (tv *TypedValue) GetPointerTo(alloc *Allocator, store Store, path ValuePath) PointerValue { + fmt.Println("---GetPointerTo, tv, rt of tv: ", tv, reflect.TypeOf(tv)) if debug { if tv.IsUndefined() { panic("GetPointerTo() on undefined value") @@ -1867,11 +1874,18 @@ func (tv *TypedValue) GetPointerTo(alloc *Allocator, store Store, path ValuePath panic("should not happen") } } + fmt.Println("---dtv: ", dtv) + fmt.Printf("---dtv addr: %p\n", dtv) dtv2 := dtv.Copy(alloc) + + fmt.Println("---dtv2: ", dtv2) + fmt.Printf("---dtv2 addr: %p\n", dtv2) + alloc.AllocateBoundMethod() bmv := &BoundMethodValue{ Func: mv, Receiver: dtv2, + //Receiver: *dtv, } return PointerValue{ TV: &TypedValue{ @@ -2431,7 +2445,9 @@ func (b *Block) GetParent(store Store) *Block { } func (b *Block) GetPointerToInt(store Store, index int) PointerValue { + fmt.Println("---GetPointerToInt") vv := fillValueTV(store, &b.Values[index]) + fmt.Println("---vv: ", vv) return PointerValue{ TV: vv, Base: b, @@ -2440,7 +2456,9 @@ func (b *Block) GetPointerToInt(store Store, index int) PointerValue { } func (b *Block) GetPointerTo(store Store, path ValuePath) PointerValue { + fmt.Println("---GetPointerTo, path: ", path) if path.IsBlockBlankPath() { + println("---isBlockBlankPath") if debug { if path.Name != blankIdentifier { panic(fmt.Sprintf( @@ -2621,13 +2639,17 @@ func typedString(s string) TypedValue { } func fillValueTV(store Store, tv *TypedValue) *TypedValue { + fmt.Println("---fillValueTV, tv: ", tv) switch cv := tv.V.(type) { case RefValue: + println("---tv.V RefValue") + fmt.Println("---cv: ", cv) if cv.PkgPath != "" { // load package tv.V = store.GetPackage(cv.PkgPath, false) } else { // load object // XXX XXX allocate object. tv.V = store.GetObject(cv.ObjectID) + fmt.Println("---tv.V: ", tv.V) } case PointerValue: // As a special case, cv.Base is filled From 72b28d76c55debe902e4c992663092370bac4fec Mon Sep 17 00:00:00 2001 From: ltzMaxwell Date: Fri, 27 Sep 2024 11:21:02 +0200 Subject: [PATCH 06/40] debug --- gnovm/pkg/gnolang/ownership.go | 3 ++- gnovm/pkg/gnolang/realm.go | 16 +++++++----- gnovm/tests/files/zrealm_crossrealm21.gno | 2 +- gnovm/tests/files/zrealm_crossrealm21a.gno | 29 ++++++++++++++++++++++ 4 files changed, 42 insertions(+), 8 deletions(-) create mode 100644 gnovm/tests/files/zrealm_crossrealm21a.gno diff --git a/gnovm/pkg/gnolang/ownership.go b/gnovm/pkg/gnolang/ownership.go index f46ba335a41..700f2e55dfb 100644 --- a/gnovm/pkg/gnolang/ownership.go +++ b/gnovm/pkg/gnolang/ownership.go @@ -113,7 +113,7 @@ type Object interface { SetIsDeleted(bool, uint64) GetIsNewReal() bool SetIsNewReal(bool) - GetIsCrossRealm() bool + GetIsCrossRealm() bool // XXX, does escape imply this? SetIsCrossRealm(bool) GetIsNewEscaped() bool SetIsNewEscaped(bool) @@ -341,6 +341,7 @@ func (oi *ObjectInfo) GetIsTransient() bool { return false } +// XXX, get first accessible object, maybe containing(parent) object, maybe itself. func (tv *TypedValue) GetFirstObject(store Store) Object { fmt.Println("---GetFirstObject---, tv: ", tv, reflect.TypeOf(tv.V)) switch cv := tv.V.(type) { diff --git a/gnovm/pkg/gnolang/realm.go b/gnovm/pkg/gnolang/realm.go index 606375d06f9..f41553250ed 100644 --- a/gnovm/pkg/gnolang/realm.go +++ b/gnovm/pkg/gnolang/realm.go @@ -186,6 +186,8 @@ func (rlm *Realm) DidUpdate(po, xo, co Object) { if po == nil || !po.GetIsReal() { // XXX, make sure po is attached return // do nothing. } + + // XXX, cross realm check fmt.Println("---po.GetObjectID(): ", po.GetObjectID()) if po.GetObjectID().PkgID != rlm.ID { fmt.Printf("po.GetObjectID().PkgID: %v, rlm.ID: %v\n", po.GetObjectID().PkgID, rlm.ID) @@ -205,15 +207,16 @@ func (rlm *Realm) DidUpdate(po, xo, co Object) { if co != nil { fmt.Println("---co: ", co) fmt.Println("---co.GetRefCount: ", co.GetRefCount()) + // XXX, inc ref count everytime assignment happens co.IncRefCount() - if co.GetRefCount() > 1 { + if co.GetRefCount() > 1 { // XXX, associated more the once? how this happen? if co.GetIsEscaped() { // already escaped } else { - rlm.MarkNewEscapedCheckCrossRealm(co) + rlm.MarkNewEscapedCheckCrossRealm(co) // XXX, track which realm escape from //rlm.MarkNewEscaped(co) } - } else if co.GetIsReal() { + } else if co.GetIsReal() { // XXX, attached in .init? println("---co is real") rlm.MarkDirty(co) } else { @@ -248,12 +251,12 @@ func (rlm *Realm) MarkNewEscapedCheckCrossRealm(oo Object) { // see below. return } - if !oi.GetIsReal() { // e.g. attach object initialized in 'init', mark it as new real/attached, thus it has an object ID. + if !oi.GetIsReal() { // XXX, this seems to be wrong -- an object escapes to other realm before it's attached(no objectID) fmt.Println("---oi Not real, oi: ", oi.ID) // this can happen if a ref +1 // new object gets passed into // an external realm function. - oi.lastNewRealEscapedRealm = rlm.ID + oi.lastNewRealEscapedRealm = rlm.ID // XXX, where the object escape from. oi.SetIsNewReal(false) rlm.MarkNewReal(oo) } else { @@ -296,6 +299,7 @@ func (rlm *Realm) MarkNewReal(oo Object) { rlm.newCreated = append(rlm.newCreated, oo) } +// mark dirty == updated func (rlm *Realm) MarkDirty(oo Object) { fmt.Printf("rlm: %v MarkDirty: %v\n", rlm, oo) if debug { @@ -491,7 +495,7 @@ func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { return } rlm.assignNewObjectID(oo) - rlm.created = append(rlm.created, oo) + rlm.created = append(rlm.created, oo) // XXX, here it becomes real. // RECURSE GUARD END // recurse for children. diff --git a/gnovm/tests/files/zrealm_crossrealm21.gno b/gnovm/tests/files/zrealm_crossrealm21.gno index 5babaff955b..44e40636e5a 100644 --- a/gnovm/tests/files/zrealm_crossrealm21.gno +++ b/gnovm/tests/files/zrealm_crossrealm21.gno @@ -9,7 +9,7 @@ var b0 crossrealm.Bar // XXX, this should fail while trying to attach // value of type defined in another realm. -// NOTE: the check can be in runtime or in preprocess. +// NOTE: the check can be in runtime or in preprocess(by simply checkin edge cases). func init() { b0 = crossrealm.Bar{A: 1} } diff --git a/gnovm/tests/files/zrealm_crossrealm21a.gno b/gnovm/tests/files/zrealm_crossrealm21a.gno new file mode 100644 index 00000000000..90783036a62 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm21a.gno @@ -0,0 +1,29 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +type Container struct { + b crossrealm.Bar +} + +var c Container + +// XXX, this should fail while trying to attach +// value of type defined in another realm. +// NOTE: the check can be in runtime or in preprocess(by simply checkin edge cases). +func init() { + b0 := crossrealm.Bar{A: 1} + c = Container{b: b0} +} + +func main() { + print(".") +} + +// Output: +// . + +// Error: From 00a59e7f5563395db7250f8772b31ac59dd29d3c Mon Sep 17 00:00:00 2001 From: ltzMaxwell Date: Mon, 7 Oct 2024 13:11:09 +0800 Subject: [PATCH 07/40] save --- examples/gno.land/r/demo/tests/crossrealm/crossrealm.gno | 2 +- gnovm/tests/files/zrealm_crossrealm21.gno | 8 +++----- gnovm/tests/files/zrealm_crossrealm21a.gno | 9 ++++----- gnovm/tests/files/zrealm_crossrealm22.gno | 7 +++---- gnovm/tests/files/zrealm_crossrealm23.gno | 7 +++---- gnovm/tests/files/zrealm_crossrealm23a.gno | 7 +++---- gnovm/tests/files/zrealm_crossrealm24.gno | 6 +++--- gnovm/tests/files/zrealm_crossrealm25a.gno | 2 +- 8 files changed, 21 insertions(+), 27 deletions(-) diff --git a/examples/gno.land/r/demo/tests/crossrealm/crossrealm.gno b/examples/gno.land/r/demo/tests/crossrealm/crossrealm.gno index 97273f642de..4ed3c8cc128 100644 --- a/examples/gno.land/r/demo/tests/crossrealm/crossrealm.gno +++ b/examples/gno.land/r/demo/tests/crossrealm/crossrealm.gno @@ -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 diff --git a/gnovm/tests/files/zrealm_crossrealm21.gno b/gnovm/tests/files/zrealm_crossrealm21.gno index 44e40636e5a..11093213162 100644 --- a/gnovm/tests/files/zrealm_crossrealm21.gno +++ b/gnovm/tests/files/zrealm_crossrealm21.gno @@ -7,9 +7,6 @@ import ( var b0 crossrealm.Bar -// XXX, this should fail while trying to attach -// value of type defined in another realm. -// NOTE: the check can be in runtime or in preprocess(by simply checkin edge cases). func init() { b0 = crossrealm.Bar{A: 1} } @@ -18,7 +15,8 @@ func main() { print(".") } -// Output: -// . +// XXX, this should fail while trying to attach +// value of type defined in another realm. +// NOTE: the check can be in runtime or in preprocess(by simply checkin edge cases). // Error: diff --git a/gnovm/tests/files/zrealm_crossrealm21a.gno b/gnovm/tests/files/zrealm_crossrealm21a.gno index 90783036a62..c8afe72843c 100644 --- a/gnovm/tests/files/zrealm_crossrealm21a.gno +++ b/gnovm/tests/files/zrealm_crossrealm21a.gno @@ -5,15 +5,13 @@ import ( crossrealm "gno.land/r/demo/tests/crossrealm" ) +// associate to a containing object type Container struct { b crossrealm.Bar } var c Container -// XXX, this should fail while trying to attach -// value of type defined in another realm. -// NOTE: the check can be in runtime or in preprocess(by simply checkin edge cases). func init() { b0 := crossrealm.Bar{A: 1} c = Container{b: b0} @@ -23,7 +21,8 @@ func main() { print(".") } -// Output: -// . +// XXX, this should fail while trying to attach +// value of type defined in another realm. +// NOTE: the check can be in runtime or in preprocess(by simply checkin edge cases). // Error: diff --git a/gnovm/tests/files/zrealm_crossrealm22.gno b/gnovm/tests/files/zrealm_crossrealm22.gno index 8e294e969d3..14c3dbd5311 100644 --- a/gnovm/tests/files/zrealm_crossrealm22.gno +++ b/gnovm/tests/files/zrealm_crossrealm22.gno @@ -7,7 +7,6 @@ type Bar struct { var b0 Bar -// XXX this works attach value with type defined in same realm func init() { b0 = Bar{A: 1} } @@ -16,7 +15,7 @@ func main() { print(".") } -// Output: -// . +// XXX this works. attach value with type defined in same realm -// Error: +// Output: +//. diff --git a/gnovm/tests/files/zrealm_crossrealm23.gno b/gnovm/tests/files/zrealm_crossrealm23.gno index ec2f19a9351..554bd41ceb0 100644 --- a/gnovm/tests/files/zrealm_crossrealm23.gno +++ b/gnovm/tests/files/zrealm_crossrealm23.gno @@ -5,7 +5,6 @@ import "gno.land/p/demo/tests/p_crossrealm" var b0 p_crossrealm.Container -// XXX, this works attach value with type defined in p func init() { b0 = p_crossrealm.Container{ A: 1, @@ -16,7 +15,7 @@ func main() { print(".") } -// Output: -// . +// XXX, this works attach value with type defined in p -// Error: +// Output: +//. diff --git a/gnovm/tests/files/zrealm_crossrealm23a.gno b/gnovm/tests/files/zrealm_crossrealm23a.gno index 21416cdde8f..61d8f0ec291 100644 --- a/gnovm/tests/files/zrealm_crossrealm23a.gno +++ b/gnovm/tests/files/zrealm_crossrealm23a.gno @@ -5,7 +5,6 @@ import "gno.land/p/demo/tests/p_crossrealm" var b0 *p_crossrealm.Container -// XXX, this works, attach reference with type defined in p func init() { b0 = &p_crossrealm.Container{ A: 1, @@ -16,7 +15,7 @@ func main() { print(".") } -// Output: -// . +// XXX, this works, attach reference with type defined in p -// Error: +// Output: +//. diff --git a/gnovm/tests/files/zrealm_crossrealm24.gno b/gnovm/tests/files/zrealm_crossrealm24.gno index e6c7d8d2e3c..01934436225 100644 --- a/gnovm/tests/files/zrealm_crossrealm24.gno +++ b/gnovm/tests/files/zrealm_crossrealm24.gno @@ -7,7 +7,6 @@ import ( var b0 *crossrealm.Bar -// XXX, should work to attach by reference func init() { b0 = &crossrealm.Bar{A: 1} } @@ -16,7 +15,8 @@ func main() { print(".") } +// XXX, should work to attach by reference to +// type defined in another realm. + // Output: // . - -// Error: diff --git a/gnovm/tests/files/zrealm_crossrealm25a.gno b/gnovm/tests/files/zrealm_crossrealm25a.gno index 1700e72b25f..cfdef023b31 100644 --- a/gnovm/tests/files/zrealm_crossrealm25a.gno +++ b/gnovm/tests/files/zrealm_crossrealm25a.gno @@ -27,7 +27,7 @@ func main() { // XXX, this associate a pointer to a value(not attached) // to external realm, no attachment happens to the external realm. - // XXX, attach to un-attached external realm + // XXX, associate to un-attached external realm //crossrealm.AttachContainer() // this attach container first crossrealm.SetContainer(&f) print(".") From 71c6fed12b3e63612267ab06b823ae124aa73c14 Mon Sep 17 00:00:00 2001 From: ltzMaxwell Date: Tue, 8 Oct 2024 23:48:06 +0800 Subject: [PATCH 08/40] external type --- gnovm/tests/files/zrealm_crossrealm0_stdlibs.gno | 2 +- gnovm/tests/files/zrealm_crossrealm1_stdlibs.gno | 2 +- gnovm/tests/files/zrealm_crossrealm2_stdlibs.gno | 2 +- gnovm/tests/files/zrealm_crossrealm3_stdlibs.gno | 2 +- gnovm/tests/files/zrealm_crossrealm4_stdlibs.gno | 2 +- gnovm/tests/files/zrealm_crossrealm5_stdlibs.gno | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gnovm/tests/files/zrealm_crossrealm0_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm0_stdlibs.gno index 5bf34c2c852..241338a4739 100644 --- a/gnovm/tests/files/zrealm_crossrealm0_stdlibs.gno +++ b/gnovm/tests/files/zrealm_crossrealm0_stdlibs.gno @@ -5,7 +5,7 @@ import ( "gno.land/r/demo/tests" ) -// NOTE: it is valid to persist external realm types. +// NOTE: it is *invalid* to persist external realm types. var somevalue tests.TestRealmObject func main() { diff --git a/gnovm/tests/files/zrealm_crossrealm1_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm1_stdlibs.gno index 686468b40c7..f89747c29c5 100644 --- a/gnovm/tests/files/zrealm_crossrealm1_stdlibs.gno +++ b/gnovm/tests/files/zrealm_crossrealm1_stdlibs.gno @@ -5,7 +5,7 @@ import ( "gno.land/r/demo/tests" ) -// NOTE: it is valid to persist external realm types. +// NOTE: it is *invalid* to persist external realm types. var somevalue tests.TestRealmObject func init() { diff --git a/gnovm/tests/files/zrealm_crossrealm2_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm2_stdlibs.gno index cfcd4e6898c..2e9f3b30637 100644 --- a/gnovm/tests/files/zrealm_crossrealm2_stdlibs.gno +++ b/gnovm/tests/files/zrealm_crossrealm2_stdlibs.gno @@ -5,7 +5,7 @@ import ( "gno.land/r/demo/tests" ) -// NOTE: it is valid to persist external realm types. +// NOTE: it is *invalid* to persist external realm types. var somevalue tests.TestRealmObject func init() { diff --git a/gnovm/tests/files/zrealm_crossrealm3_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm3_stdlibs.gno index 6aa9c5247d8..9dc099b3c43 100644 --- a/gnovm/tests/files/zrealm_crossrealm3_stdlibs.gno +++ b/gnovm/tests/files/zrealm_crossrealm3_stdlibs.gno @@ -5,7 +5,7 @@ import ( "gno.land/r/demo/tests" ) -// NOTE: it is valid to persist external realm types. +// NOTE: it is *invalid* to persist external realm types. var somevalue tests.TestRealmObject func init() { diff --git a/gnovm/tests/files/zrealm_crossrealm4_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm4_stdlibs.gno index 6aa9c5247d8..9dc099b3c43 100644 --- a/gnovm/tests/files/zrealm_crossrealm4_stdlibs.gno +++ b/gnovm/tests/files/zrealm_crossrealm4_stdlibs.gno @@ -5,7 +5,7 @@ import ( "gno.land/r/demo/tests" ) -// NOTE: it is valid to persist external realm types. +// NOTE: it is *invalid* to persist external realm types. var somevalue tests.TestRealmObject func init() { diff --git a/gnovm/tests/files/zrealm_crossrealm5_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm5_stdlibs.gno index 6aa9c5247d8..9dc099b3c43 100644 --- a/gnovm/tests/files/zrealm_crossrealm5_stdlibs.gno +++ b/gnovm/tests/files/zrealm_crossrealm5_stdlibs.gno @@ -5,7 +5,7 @@ import ( "gno.land/r/demo/tests" ) -// NOTE: it is valid to persist external realm types. +// NOTE: it is *invalid* to persist external realm types. var somevalue tests.TestRealmObject func init() { From 07d902957cc24ce1b7f19ac618edb1369579b620 Mon Sep 17 00:00:00 2001 From: ltzMaxwell Date: Thu, 10 Oct 2024 23:59:39 +0800 Subject: [PATCH 09/40] save --- .../r/demo/tests/crossrealm/crossrealm2.gno | 9 ++- gnovm/pkg/gnolang/machine.go | 1 + gnovm/pkg/gnolang/ownership.go | 7 ++ gnovm/pkg/gnolang/realm.go | 71 ++++++++++++++++--- gnovm/pkg/gnolang/values.go | 10 ++- gnovm/tests/files/zrealm_crossrealm21a.gno | 7 +- gnovm/tests/files/zrealm_crossrealm25.gno | 16 ++--- gnovm/tests/files/zrealm_crossrealm25a.gno | 13 +--- gnovm/tests/files/zrealm_crossrealm25b.gno | 33 +++++++++ gnovm/tests/files/zrealm_crossrealm25c.gno | 33 +++++++++ gnovm/tests/files/zrealm_crossrealm25d.gno | 36 ++++++++++ gnovm/tests/files/zrealm_crossrealm26.gno | 20 ++---- gnovm/tests/files/zrealm_crossrealm26a.gno | 24 +++++++ gnovm/tests/files/zrealm_crossrealm26b.gno | 21 ++++++ gnovm/tests/files/zrealm_crossrealm26c.gno | 19 +++++ 15 files changed, 270 insertions(+), 50 deletions(-) create mode 100644 gnovm/tests/files/zrealm_crossrealm25b.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm25c.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm25d.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm26a.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm26b.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm26c.gno diff --git a/examples/gno.land/r/demo/tests/crossrealm/crossrealm2.gno b/examples/gno.land/r/demo/tests/crossrealm/crossrealm2.gno index 8f12ec1322d..76cf0eef100 100644 --- a/examples/gno.land/r/demo/tests/crossrealm/crossrealm2.gno +++ b/examples/gno.land/r/demo/tests/crossrealm/crossrealm2.gno @@ -14,14 +14,19 @@ func CallFoo() { fooer.Foo() } // container in external realm type Container struct { - f Fooer + name string + f Fooer } var container Container // TODO, check does this attach or not func AttachContainer() { - container = Container{} + container = Container{name: "external_container"} } func SetContainer(f Fooer) { container.f = f } + +func SetContainer2(f Fooer) { + ff := f +} diff --git a/gnovm/pkg/gnolang/machine.go b/gnovm/pkg/gnolang/machine.go index ad3fbeee7f2..2a7323c3a3c 100644 --- a/gnovm/pkg/gnolang/machine.go +++ b/gnovm/pkg/gnolang/machine.go @@ -753,6 +753,7 @@ func (m *Machine) runInitFromUpdates(pv *PackageValue, updates []TypedValue) { // Returns a throwaway realm package is not a realm, // such as stdlibs or /p/ packages. func (m *Machine) saveNewPackageValuesAndTypes() (throwaway *Realm) { + fmt.Println("---saveNewPackageValuesAndTypes") // save package value and dependencies. pv := m.Package if pv.IsRealm() { diff --git a/gnovm/pkg/gnolang/ownership.go b/gnovm/pkg/gnolang/ownership.go index 700f2e55dfb..c622149a5b8 100644 --- a/gnovm/pkg/gnolang/ownership.go +++ b/gnovm/pkg/gnolang/ownership.go @@ -346,12 +346,19 @@ func (tv *TypedValue) GetFirstObject(store Store) Object { fmt.Println("---GetFirstObject---, tv: ", tv, reflect.TypeOf(tv.V)) switch cv := tv.V.(type) { case PointerValue: + println("---pointer value, get base") + if v, ok := cv.TV.V.(Object); ok { + fmt.Println("---v: ", v) + rc := v.GetRefCount() + fmt.Println("---rc: ", rc) + } return cv.GetBase(store) case *ArrayValue: return cv case *SliceValue: return cv.GetBase(store) case *StructValue: + println("---struct value") return cv case *FuncValue: return cv.GetClosure(store) diff --git a/gnovm/pkg/gnolang/realm.go b/gnovm/pkg/gnolang/realm.go index f41553250ed..02b2f66e752 100644 --- a/gnovm/pkg/gnolang/realm.go +++ b/gnovm/pkg/gnolang/realm.go @@ -135,14 +135,27 @@ func (rlm *Realm) String() string { // associated object. func (rlm *Realm) DidUpdate(po, xo, co Object) { fmt.Println("---DidUpdate---") - fmt.Println("---xo: ", xo, reflect.TypeOf(xo)) - fmt.Println("---co: ", co, reflect.TypeOf(co)) - fmt.Println("---po: ", po, reflect.TypeOf(po)) + fmt.Printf("---xo: %v, type of xo: %v\n", xo, reflect.TypeOf(xo)) + fmt.Printf("---co: %v, type of co: %v\n", co, reflect.TypeOf(co)) + fmt.Printf("---po: %v, type of po: %v\n", po, reflect.TypeOf(po)) + + fmt.Printf("xo: %p\n", xo) + if co != nil && co.GetIsCrossRealm() { + panic("!!!cross realm") + } + + if co != nil { + fmt.Println("--co isReal(attached): ", co.GetIsReal()) + fmt.Println("---co objectID: ", co.GetObjectID()) + } if co != nil { fmt.Println("co.GetObjectInfo:", co.GetObjectInfo()) + fmt.Printf("co: %p\n", co) } + // XXX, these can be improved by attach type info with co. + // the following does not work if sv, ok := po.(*StructValue); ok { fmt.Println("---sv: ", sv) fmt.Println("---sv.ID: ", sv.ObjectInfo.ID) @@ -159,6 +172,8 @@ func (rlm *Realm) DidUpdate(po, xo, co Object) { if dt, ok := tv.T.(*DeclaredType); ok { fmt.Println("---dt: ", dt, dt.PkgPath) if IsRealmPath(dt.PkgPath) && dt.PkgPath != rlm.Path { + fmt.Println("---set co to be cross realm object, co: ", co) + fmt.Printf("---%p\n", co) co.SetIsCrossRealm(true) //panic("!!!") } @@ -183,6 +198,7 @@ func (rlm *Realm) DidUpdate(po, xo, co Object) { panic("cannot attach to a deleted object") } } + fmt.Println("---po.GetIsReal: ", po.GetIsReal()) if po == nil || !po.GetIsReal() { // XXX, make sure po is attached return // do nothing. } @@ -209,8 +225,10 @@ func (rlm *Realm) DidUpdate(po, xo, co Object) { fmt.Println("---co.GetRefCount: ", co.GetRefCount()) // XXX, inc ref count everytime assignment happens co.IncRefCount() - if co.GetRefCount() > 1 { // XXX, associated more the once? how this happen? + fmt.Println("---after inc, co.GetRefCount: ", co.GetRefCount()) + if co.GetRefCount() > 1 { // XXX, associated more the once? how this happens? if co.GetIsEscaped() { + println("---already escaped, should check cross realm?") // already escaped } else { rlm.MarkNewEscapedCheckCrossRealm(co) // XXX, track which realm escape from @@ -228,6 +246,7 @@ func (rlm *Realm) DidUpdate(po, xo, co Object) { if xo != nil { xo.DecRefCount() + fmt.Println("---xo refCount after dec: ", xo.GetRefCount()) if xo.GetRefCount() == 0 { if xo.GetIsReal() { rlm.MarkNewDeleted(xo) @@ -243,8 +262,17 @@ func (rlm *Realm) MarkNewEscapedCheckCrossRealm(oo Object) { fmt.Println("---MarkNewEscapedCheckCrossRealm---, oo: ", oo) oi := oo.GetObjectInfo() fmt.Println("----oi: ", oi) + fmt.Println("----oi: ", oi) fmt.Println("----oi.lastNewRealEscapedRealm: ", oi.lastNewRealEscapedRealm) fmt.Println("----rlm.ID: ", rlm.ID) + fmt.Println("oi.GetIsReal: ", oi.GetIsReal()) + if oi.GetIsReal() { + lastRealmID := oi.GetObjectID().PkgID + fmt.Println("lastRealmID: ", lastRealmID) + if lastRealmID != rlm.ID { + panic("should not happen, cross realm!!!") + } + } if oi.lastNewRealEscapedRealm == rlm.ID { // already processed for this realm, @@ -262,6 +290,7 @@ func (rlm *Realm) MarkNewEscapedCheckCrossRealm(oo Object) { } else { fmt.Println("---oo is real, oi:", oi.ID) // TODO: set last escape realm? + println("---set last escape realm?") } rlm.MarkNewEscaped(oo) } @@ -288,7 +317,7 @@ func (rlm *Realm) MarkNewReal(oo Object) { } } if oo.GetIsNewReal() { - println("---markNewReal---, oo: ", oo) + println("---isNewReal---, oo: ", oo) return // already marked. } oo.SetIsNewReal(true) @@ -296,7 +325,9 @@ func (rlm *Realm) MarkNewReal(oo Object) { if rlm.newCreated == nil { rlm.newCreated = make([]Object, 0, 256) } + fmt.Println("---append oo to newCreated object: ", oo) rlm.newCreated = append(rlm.newCreated, oo) + fmt.Println("---len of new created: ", len(rlm.newCreated)) } // mark dirty == updated @@ -444,7 +475,19 @@ func (rlm *Realm) processNewCreatedMarks(store Store) { //for _, oo := range rlm.newCreated { for i := 0; i < len(rlm.newCreated); i++ { oo := rlm.newCreated[i] - fmt.Println("---oo: ", oo) + fmt.Printf("---oo[%d] is %v:\n", i, oo) + // TODO: here check embedded object cross + more := getChildObjects2(store, oo) + fmt.Println("---children of oo: ", more) + for _, c := range more { + fmt.Printf("---%p\n", c) + if c.GetIsCrossRealm() { + panic("---cross realm") + } else { + println("---not cross realm") + } + } + fmt.Println("---oo.GetRefCount(): ", oo.GetRefCount()) if oo.GetIsCrossRealm() { fmt.Println("---should not attach value with type defined in other realm") //panic("---!!!") @@ -502,7 +545,7 @@ func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { more := getChildObjects2(store, oo) fmt.Println("---more: ", more) for _, child := range more { - fmt.Println("---child: ", child) + fmt.Printf("---child: %v, type of child: %v \n", child, reflect.TypeOf(child)) fmt.Printf("---child addr: %p\n", child) if _, ok := child.(*PackageValue); ok { if debug { @@ -561,6 +604,7 @@ func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { func (rlm *Realm) processNewDeletedMarks(store Store) { fmt.Println("---processNewDeletedMarks---") for _, oo := range rlm.newDeleted { + fmt.Println("---oo: ", oo, oo.GetRefCount()) if debug { if oo.GetObjectID().IsZero() { panic("new deleted mark should have an object ID") @@ -905,9 +949,12 @@ func (rlm *Realm) clearMarks() { // Value is either Object or RefValue. // Shallow; doesn't recurse into objects. func getSelfOrChildObjects(val Value, more []Value) []Value { + fmt.Println("---getSelfOrChildObjects, val: ", val) if _, ok := val.(RefValue); ok { + println("---ref value") return append(more, val) } else if _, ok := val.(Object); ok { + println("---not ref value") return append(more, val) } else { return getChildObjects(val, more) @@ -917,6 +964,7 @@ func getSelfOrChildObjects(val Value, more []Value) []Value { // Gets child objects. // Shallow; doesn't recurse into objects. func getChildObjects(val Value, more []Value) []Value { + fmt.Println("---getChildObjects, val: ", val, reflect.TypeOf(val)) switch cv := val.(type) { case nil: return more @@ -943,7 +991,10 @@ func getChildObjects(val Value, more []Value) []Value { more = getSelfOrChildObjects(cv.Base, more) return more case *StructValue: + println("---struct value") for _, ctv := range cv.Fields { + // TODO: we have type infos here, so check check cross realm logic + fmt.Println("---ctv: ", ctv) more = getSelfOrChildObjects(ctv.V, more) } return more @@ -993,13 +1044,17 @@ func getChildObjects(val Value, more []Value) []Value { // like getChildObjects() but loads RefValues into objects. func getChildObjects2(store Store, val Value) []Object { + fmt.Println("---getChildObjects2, val: ", val) chos := getChildObjects(val, nil) + fmt.Println("---chos: ", chos) objs := make([]Object, 0, len(chos)) for _, child := range chos { if ref, ok := child.(RefValue); ok { + println("---ref value") oo := store.GetObject(ref.ObjectID) objs = append(objs, oo) } else if oo, ok := child.(Object); ok { + println("---not ref value") objs = append(objs, oo) } } @@ -1530,7 +1585,7 @@ func (rlm *Realm) nextObjectID() ObjectID { // Object gets its id set (panics if already set), and becomes // marked as new and real. func (rlm *Realm) assignNewObjectID(oo Object) ObjectID { - fmt.Printf("---assignNewObjectID, rlm: %v, oo: %v\n", rlm, oo) + fmt.Printf("---assignNewObjectID, rlm: %v, oo: %v, oo: %p\n", rlm, oo, oo) oid := oo.GetObjectID() fmt.Println("---oid: ", oid) if !oid.IsZero() { diff --git a/gnovm/pkg/gnolang/values.go b/gnovm/pkg/gnolang/values.go index 009f253e0e2..7231f1f4f74 100644 --- a/gnovm/pkg/gnolang/values.go +++ b/gnovm/pkg/gnolang/values.go @@ -290,8 +290,10 @@ func (pv PointerValue) Assign2(alloc *Allocator, store Store, rlm *Realm, tv2 Ty // General case if rlm != nil && pv.Base != nil { oo1 := pv.TV.GetFirstObject(store) + fmt.Println("---oo1: ", oo1) pv.TV.Assign(alloc, tv2, cu) oo2 := pv.TV.GetFirstObject(store) + fmt.Println("---oo2: ", oo2) rlm.DidUpdate(pv.Base.(Object), oo1, oo2) } else { pv.TV.Assign(alloc, tv2, cu) @@ -508,6 +510,7 @@ func (sv *StructValue) GetSubrefPointerTo(store Store, st *StructType, path Valu } func (sv *StructValue) Copy(alloc *Allocator) *StructValue { + fmt.Println("---StructValue copy, sv: ", sv) /* TODO consider second refcount field if sv.GetRefCount() == 0 { return sv @@ -523,7 +526,10 @@ func (sv *StructValue) Copy(alloc *Allocator) *StructValue { fields[i] = field.Copy(alloc) } - return alloc.NewStruct(fields) + nsv := alloc.NewStruct(fields) + nsv.ObjectInfo = sv.ObjectInfo.Copy() + return nsv + //return alloc.NewStruct(fields) } // ---------------------------------------- @@ -1695,7 +1701,7 @@ func (tv *TypedValue) Assign(alloc *Allocator, tv2 TypedValue, cu bool) { panic("should not happen") } } - *tv = tv2.Copy(alloc) + *tv = tv2.Copy(alloc) // TODO: why copy? if cu && isUntyped(tv.T) { ConvertUntypedTo(tv, defaultTypeOf(tv.T)) } diff --git a/gnovm/tests/files/zrealm_crossrealm21a.gno b/gnovm/tests/files/zrealm_crossrealm21a.gno index c8afe72843c..e77837400e3 100644 --- a/gnovm/tests/files/zrealm_crossrealm21a.gno +++ b/gnovm/tests/files/zrealm_crossrealm21a.gno @@ -7,14 +7,15 @@ import ( // associate to a containing object type Container struct { - b crossrealm.Bar + name string + b crossrealm.Bar } var c Container func init() { - b0 := crossrealm.Bar{A: 1} - c = Container{b: b0} + b0 := crossrealm.Bar{A: 1} // this is valid association + c = Container{name: "container", b: b0} // XXX, check recursively while finalize here } func main() { diff --git a/gnovm/tests/files/zrealm_crossrealm25.gno b/gnovm/tests/files/zrealm_crossrealm25.gno index 5ea5e4a520f..10b37896c8f 100644 --- a/gnovm/tests/files/zrealm_crossrealm25.gno +++ b/gnovm/tests/files/zrealm_crossrealm25.gno @@ -7,7 +7,7 @@ import ( crossrealm "gno.land/r/demo/tests/crossrealm" ) -type fooer struct{} +type fooer struct{ name string } func (fooer) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } @@ -20,20 +20,14 @@ var f fooer // to the field of a struct, but this does not attach the external // realm object to the container, in this case the struct. func init() { - f = fooer{} + f = fooer{name: "local_fooer"} // f attached to current realm } func main() { - // XXX, this associate a pointer to a value(already attached to local realm) - // to external realm, no attachment happens to the external realm. - crossrealm.AttachContainer() // this attach container first + crossrealm.AttachContainer() // this attaches container first crossrealm.SetContainer(&f) print(".") } -// Output: -// . - -// Error: - -// Realm: +// XXX, this associate a pointer to a value(already attached to local realm) +// to external realm, no attachment happens to the external realm. diff --git a/gnovm/tests/files/zrealm_crossrealm25a.gno b/gnovm/tests/files/zrealm_crossrealm25a.gno index cfdef023b31..7064b364d3d 100644 --- a/gnovm/tests/files/zrealm_crossrealm25a.gno +++ b/gnovm/tests/files/zrealm_crossrealm25a.gno @@ -24,18 +24,11 @@ func init() { } func main() { - // XXX, this associate a pointer to a value(not attached) - // to external realm, no attachment happens to the external realm. - // XXX, associate to un-attached external realm - //crossrealm.AttachContainer() // this attach container first crossrealm.SetContainer(&f) print(".") } -// Output: -// . - -// Error: - -// Realm: +// this should work. +// XXX, this associate a pointer to a floating object(not attached) +// to external realm, no attachment happens to the external realm. diff --git a/gnovm/tests/files/zrealm_crossrealm25b.gno b/gnovm/tests/files/zrealm_crossrealm25b.gno new file mode 100644 index 00000000000..57cfe2324ae --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm25b.gno @@ -0,0 +1,33 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +// pass pointer to an embedded object to external realm? + +import ( + "std" + + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +type fooer struct { + name string +} + +func (fooer) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } + +type localContainer struct { + name string + f fooer +} + +var lc localContainer + +func init() { + lc = localContainer{name: "local_container", f: fooer{name: "local_fooer"}} // attach +} + +func main() { + crossrealm.AttachContainer() // this attaches container first + crossrealm.SetContainer(&lc.f) + print(".") +} diff --git a/gnovm/tests/files/zrealm_crossrealm25c.gno b/gnovm/tests/files/zrealm_crossrealm25c.gno new file mode 100644 index 00000000000..9e8f961a21f --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm25c.gno @@ -0,0 +1,33 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +// pass pointer to an embedded object to external realm? + +import ( + "std" + + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +type fooer struct { + name string +} + +func (fooer) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } + +type localContainer struct { + name string + f fooer +} + +var lc localContainer + +func init() { + lc = localContainer{name: "local_container", f: fooer{name: "local_fooer"}} // attach +} + +func main() { + crossrealm.AttachContainer() // this attaches container first + crossrealm.SetContainer(lc.f) // should work + print(".") +} diff --git a/gnovm/tests/files/zrealm_crossrealm25d.gno b/gnovm/tests/files/zrealm_crossrealm25d.gno new file mode 100644 index 00000000000..46ccf45dac7 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm25d.gno @@ -0,0 +1,36 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +// pass pointer to an embedded object to external realm? + +import ( + "std" + + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +type fooer struct { + name string +} + +func (fooer) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } + +var f fooer + +type localContainer struct { + name string + ff fooer +} + +var lc localContainer + +func init() { + f = fooer{name: "local_fooer_global"} + lc = localContainer{name: "local_container", ff: f} // attach +} + +func main() { + crossrealm.AttachContainer() // this attaches container first + crossrealm.SetContainer(lc.ff) // this should not panic, lc.ff is not same with f(gloabl) + print(".") +} diff --git a/gnovm/tests/files/zrealm_crossrealm26.gno b/gnovm/tests/files/zrealm_crossrealm26.gno index 6fff7ac6b96..3dfabfd14fe 100644 --- a/gnovm/tests/files/zrealm_crossrealm26.gno +++ b/gnovm/tests/files/zrealm_crossrealm26.gno @@ -7,26 +7,18 @@ import ( crossrealm "gno.land/r/demo/tests/crossrealm" ) -type fooer struct{} +type fooer struct{ name string } func (fooer) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } var f fooer -// Pointers to external realm objects that are not yet -// attached to the external realm may not be associated -// with an attached object. +func init() { + f = fooer{name: "local_fooer"} +} func main() { - crossrealm.AttachContainer() // this attach container first - f = fooer{} // not attached to local realm yet, cannot be able to attach to external attached even by reference - crossrealm.SetContainer(&f) + crossrealm.AttachContainer() // this attaches container first + crossrealm.SetContainer(f) print(".") } - -// Output: -// . - -// Error: - -// Realm: diff --git a/gnovm/tests/files/zrealm_crossrealm26a.gno b/gnovm/tests/files/zrealm_crossrealm26a.gno new file mode 100644 index 00000000000..1fbf476e917 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm26a.gno @@ -0,0 +1,24 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "std" + + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +type fooer struct{ name string } + +func (fooer) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } + +var f fooer + +func init() { + f = fooer{name: "local_fooer"} +} + +func main() { + crossrealm.AttachContainer() // this attaches container first + crossrealm.SetContainer(&f) + print(".") +} diff --git a/gnovm/tests/files/zrealm_crossrealm26b.gno b/gnovm/tests/files/zrealm_crossrealm26b.gno new file mode 100644 index 00000000000..de672d5cca3 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm26b.gno @@ -0,0 +1,21 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "std" + + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +type fooer struct{ name string } + +func (fooer) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } + +var f fooer // this already attached + +func main() { + crossrealm.AttachContainer() // this attaches container first + f = fooer{name: "local_fooer"} // update to an already attached object + crossrealm.SetContainer(&f) + print(".") +} diff --git a/gnovm/tests/files/zrealm_crossrealm26c.gno b/gnovm/tests/files/zrealm_crossrealm26c.gno new file mode 100644 index 00000000000..3f7a92b33d0 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm26c.gno @@ -0,0 +1,19 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "std" + + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +type fooer struct{ name string } + +func (fooer) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } + +func main() { + crossrealm.AttachContainer() // this attaches container first + var f fooer = fooer{name: "local_fooer"} // this is not attached, should panic, even not escape + crossrealm.SetContainer(f) + print(".") +} From 8fdc399ab55c2caa5ee6108b7a2d9df6dd10a1af Mon Sep 17 00:00:00 2001 From: ltzMaxwell Date: Mon, 14 Oct 2024 08:11:03 +0800 Subject: [PATCH 10/40] save --- .../r/demo/tests/crossrealm/crossrealm2.gno | 5 +- gnovm/pkg/gnolang/ownership.go | 5 +- gnovm/pkg/gnolang/realm.go | 69 +++++++++++-------- gnovm/pkg/gnolang/values.go | 2 +- gnovm/tests/files/zrealm_crossrealm26a.gno | 2 +- gnovm/tests/files/zrealm_crossrealm26b.gno | 4 +- gnovm/tests/files/zrealm_crossrealm26c.gno | 2 +- gnovm/tests/files/zrealm_crossrealm27.gno | 12 +--- 8 files changed, 55 insertions(+), 46 deletions(-) diff --git a/examples/gno.land/r/demo/tests/crossrealm/crossrealm2.gno b/examples/gno.land/r/demo/tests/crossrealm/crossrealm2.gno index 76cf0eef100..784af2ab715 100644 --- a/examples/gno.land/r/demo/tests/crossrealm/crossrealm2.gno +++ b/examples/gno.land/r/demo/tests/crossrealm/crossrealm2.gno @@ -18,11 +18,12 @@ type Container struct { f Fooer } -var container Container // TODO, check does this attach or not +var container Container // XXX, not attached here func AttachContainer() { - container = Container{name: "external_container"} + container = Container{name: "external_container"} // attach after call } + func SetContainer(f Fooer) { container.f = f } diff --git a/gnovm/pkg/gnolang/ownership.go b/gnovm/pkg/gnolang/ownership.go index c622149a5b8..82e1d33f1e7 100644 --- a/gnovm/pkg/gnolang/ownership.go +++ b/gnovm/pkg/gnolang/ownership.go @@ -351,14 +351,17 @@ func (tv *TypedValue) GetFirstObject(store Store) Object { fmt.Println("---v: ", v) rc := v.GetRefCount() fmt.Println("---rc: ", rc) + fmt.Println("---v Owner: ", v.GetOwnerID()) + fmt.Println("---v.GetObjectID(): ", v.GetObjectID()) } - return cv.GetBase(store) + return cv.GetBase(store) // TODO: this is not enough for pointers case *ArrayValue: return cv case *SliceValue: return cv.GetBase(store) case *StructValue: println("---struct value") + fmt.Println("---cv.GetObjectID(): ", cv.GetObjectID()) return cv case *FuncValue: return cv.GetClosure(store) diff --git a/gnovm/pkg/gnolang/realm.go b/gnovm/pkg/gnolang/realm.go index 02b2f66e752..06ef3170578 100644 --- a/gnovm/pkg/gnolang/realm.go +++ b/gnovm/pkg/gnolang/realm.go @@ -133,6 +133,7 @@ func (rlm *Realm) String() string { // if rlm or po is nil, do nothing. // xo or co is nil if the element value is undefined or has no // associated object. +// TODO: func (rlm *Realm) DidUpdate(po, xo, co Object, attached bool) { func (rlm *Realm) DidUpdate(po, xo, co Object) { fmt.Println("---DidUpdate---") fmt.Printf("---xo: %v, type of xo: %v\n", xo, reflect.TypeOf(xo)) @@ -154,34 +155,42 @@ func (rlm *Realm) DidUpdate(po, xo, co Object) { fmt.Printf("co: %p\n", co) } - // XXX, these can be improved by attach type info with co. - // the following does not work - if sv, ok := po.(*StructValue); ok { - fmt.Println("---sv: ", sv) - fmt.Println("---sv.ID: ", sv.ObjectInfo.ID) - fmt.Println("---sv.Fields: ", sv.Fields) - fmt.Println("---sv.OwnerID: ", sv.ObjectInfo.OwnerID) - } else if bv, ok := po.(*Block); ok { - for _, tv := range bv.Values { - fmt.Println("----tv.T: ", tv.T) - fmt.Println("----tv.V: ", tv.V) - if csv, ok := co.(*StructValue); ok { - if csv == tv.V { - fmt.Println("---eql, csv: ", csv) - fmt.Println("---eql, T: ", tv.T, reflect.TypeOf(tv.T)) - if dt, ok := tv.T.(*DeclaredType); ok { - fmt.Println("---dt: ", dt, dt.PkgPath) - if IsRealmPath(dt.PkgPath) && dt.PkgPath != rlm.Path { - fmt.Println("---set co to be cross realm object, co: ", co) - fmt.Printf("---%p\n", co) - co.SetIsCrossRealm(true) - //panic("!!!") - } - } - } - } - } - } + //// XXX, these can be improved by attach type info with co. + //// the following does not work + //if sv, ok := po.(*StructValue); ok { + // fmt.Println("---sv: ", sv) + // fmt.Println("---sv.ID: ", sv.ObjectInfo.ID) + // fmt.Println("---sv.Fields: ", sv.Fields) + // fmt.Println("---sv.OwnerID: ", sv.ObjectInfo.OwnerID) + //} else if bv, ok := po.(*Block); ok { + // for _, tv := range bv.Values { + // fmt.Println("----tv.T: ", tv.T) + // fmt.Println("----tv.V: ", tv.V) + // if csv, ok := co.(*StructValue); ok { + // if csv == tv.V { + // fmt.Println("---eql, csv: ", csv) + // fmt.Println("---eql, T: ", tv.T, reflect.TypeOf(tv.T)) + // if dt, ok := tv.T.(*DeclaredType); ok { + // fmt.Println("---dt: ", dt, dt.PkgPath) + // if IsRealmPath(dt.PkgPath) && dt.PkgPath != rlm.Path { + // fmt.Println("---set co to be cross realm object, co: ", co) + // fmt.Printf("---%p\n", co) + // co.SetIsCrossRealm(true) + // //panic("!!!") + // } + // } + // } + // } + // } + //} + + // XXX, association happens here + // if is co is attached to external realm + // if xo is attached to realm, directly/indirectly; + // if associated with reference, ok + // else, panic("should not associate with value cross realm + // else if xo is not attached to realm, associate is ok too, check when finalize. + // else, panic when finalizing current realm. fmt.Println("---realm: ", rlm) if rlm == nil { @@ -246,7 +255,7 @@ func (rlm *Realm) DidUpdate(po, xo, co Object) { if xo != nil { xo.DecRefCount() - fmt.Println("---xo refCount after dec: ", xo.GetRefCount()) + fmt.Printf("---xo: %v refCount after dec: %v\n", xo, xo.GetRefCount()) if xo.GetRefCount() == 0 { if xo.GetIsReal() { rlm.MarkNewDeleted(xo) @@ -399,6 +408,8 @@ func (rlm *Realm) MarkNewEscaped(oo Object) { //---------------------------------------- // transactions +// TODO: check cross realm, that might be objects not attached +// to a realm gets attached here, which should panic. // OpReturn calls this when exiting a realm transaction. func (rlm *Realm) FinalizeRealmTransaction(readonly bool, store Store) { fmt.Println("---FinalizeRealmTransaction---") diff --git a/gnovm/pkg/gnolang/values.go b/gnovm/pkg/gnolang/values.go index 7231f1f4f74..ad6bc85a4b2 100644 --- a/gnovm/pkg/gnolang/values.go +++ b/gnovm/pkg/gnolang/values.go @@ -527,7 +527,7 @@ func (sv *StructValue) Copy(alloc *Allocator) *StructValue { } nsv := alloc.NewStruct(fields) - nsv.ObjectInfo = sv.ObjectInfo.Copy() + //nsv.ObjectInfo = sv.ObjectInfo.Copy() return nsv //return alloc.NewStruct(fields) } diff --git a/gnovm/tests/files/zrealm_crossrealm26a.gno b/gnovm/tests/files/zrealm_crossrealm26a.gno index 1fbf476e917..76f3bc4c93b 100644 --- a/gnovm/tests/files/zrealm_crossrealm26a.gno +++ b/gnovm/tests/files/zrealm_crossrealm26a.gno @@ -14,7 +14,7 @@ func (fooer) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } var f fooer func init() { - f = fooer{name: "local_fooer"} + f = fooer{name: "local_fooer"} // NOTE, from now on f is attached } func main() { diff --git a/gnovm/tests/files/zrealm_crossrealm26b.gno b/gnovm/tests/files/zrealm_crossrealm26b.gno index de672d5cca3..d2e2c33864b 100644 --- a/gnovm/tests/files/zrealm_crossrealm26b.gno +++ b/gnovm/tests/files/zrealm_crossrealm26b.gno @@ -11,11 +11,11 @@ type fooer struct{ name string } func (fooer) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } -var f fooer // this already attached +var f fooer // this is NOT attached func main() { crossrealm.AttachContainer() // this attaches container first - f = fooer{name: "local_fooer"} // update to an already attached object + f = fooer{name: "local_fooer"} // XXX, still not attached, panic crossrealm.SetContainer(&f) print(".") } diff --git a/gnovm/tests/files/zrealm_crossrealm26c.gno b/gnovm/tests/files/zrealm_crossrealm26c.gno index 3f7a92b33d0..35885aa0cd4 100644 --- a/gnovm/tests/files/zrealm_crossrealm26c.gno +++ b/gnovm/tests/files/zrealm_crossrealm26c.gno @@ -14,6 +14,6 @@ func (fooer) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } func main() { crossrealm.AttachContainer() // this attaches container first var f fooer = fooer{name: "local_fooer"} // this is not attached, should panic, even not escape - crossrealm.SetContainer(f) + crossrealm.SetContainer(&f) print(".") } diff --git a/gnovm/tests/files/zrealm_crossrealm27.gno b/gnovm/tests/files/zrealm_crossrealm27.gno index 28a091d7e7c..f0bbfee07de 100644 --- a/gnovm/tests/files/zrealm_crossrealm27.gno +++ b/gnovm/tests/files/zrealm_crossrealm27.gno @@ -16,14 +16,8 @@ var f fooer // XXX, this should work when reference to not attached local object // associated to external realm *NOT* attached object. func main() { - f = fooer{} - crossrealm.SetContainer(&f) + f = fooer{} // this is not attached + crossrealm.SetContainer(&f) // XXX, here should work to associate *NOT* attached object to external container + crossrealm.AttachContainer() // XXX, here should panic, to attach external *NOT* attached object print(".") } - -// Output: -// . - -// Error: - -// Realm: From a604cdc64befd20b9ce50eb9a9d295430173948a Mon Sep 17 00:00:00 2001 From: ltzMaxwell Date: Wed, 16 Oct 2024 18:18:11 +0800 Subject: [PATCH 11/40] more test --- .../r/demo/tests/crossrealm/crossrealm2.gno | 10 +- .../r/demo/tests/crossrealm/crossrealm3.gno | 1 + .../r/demo/tests/crossrealm/crossrealm4.gno | 7 + gnovm/pkg/gnolang/machine.go | 2 +- gnovm/pkg/gnolang/op_call.go | 1 + gnovm/pkg/gnolang/op_eval.go | 2 +- gnovm/pkg/gnolang/ownership.go | 3 +- gnovm/pkg/gnolang/realm.go | 124 +++++++++--------- gnovm/pkg/gnolang/store.go | 6 +- gnovm/pkg/gnolang/values.go | 17 +-- gnovm/tests/files/zrealm_crossrealm15.gno | 8 -- gnovm/tests/files/zrealm_crossrealm16.gno | 10 +- gnovm/tests/files/zrealm_crossrealm16a.gno | 16 +++ gnovm/tests/files/zrealm_crossrealm17.gno | 5 +- gnovm/tests/files/zrealm_crossrealm20.gno | 33 ----- gnovm/tests/files/zrealm_crossrealm21.gno | 2 - gnovm/tests/files/zrealm_crossrealm21a.gno | 8 +- gnovm/tests/files/zrealm_crossrealm22.gno | 3 - gnovm/tests/files/zrealm_crossrealm24.gno | 2 +- gnovm/tests/files/zrealm_crossrealm25.gno | 33 ----- gnovm/tests/files/zrealm_crossrealm25a.gno | 6 - gnovm/tests/files/zrealm_crossrealm25b.gno | 4 +- gnovm/tests/files/zrealm_crossrealm25c.gno | 2 +- gnovm/tests/files/zrealm_crossrealm25d.gno | 2 +- gnovm/tests/files/zrealm_crossrealm26.gno | 2 +- gnovm/tests/files/zrealm_crossrealm27.gno | 9 +- gnovm/tests/files/zrealm_crossrealm27a.gno | 19 +-- gnovm/tests/files/zrealm_crossrealm28.gno | 27 ++++ gnovm/tests/files/zrealm_crossrealm33.gno | 16 +++ 29 files changed, 174 insertions(+), 206 deletions(-) create mode 100644 examples/gno.land/r/demo/tests/crossrealm/crossrealm4.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm16a.gno delete mode 100644 gnovm/tests/files/zrealm_crossrealm20.gno delete mode 100644 gnovm/tests/files/zrealm_crossrealm25.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm28.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm33.gno diff --git a/examples/gno.land/r/demo/tests/crossrealm/crossrealm2.gno b/examples/gno.land/r/demo/tests/crossrealm/crossrealm2.gno index 784af2ab715..a85778e00c6 100644 --- a/examples/gno.land/r/demo/tests/crossrealm/crossrealm2.gno +++ b/examples/gno.land/r/demo/tests/crossrealm/crossrealm2.gno @@ -18,16 +18,22 @@ type Container struct { f Fooer } -var container Container // XXX, not attached here +var container Container // attached func AttachContainer() { container = Container{name: "external_container"} // attach after call } func SetContainer(f Fooer) { - container.f = f + container.f = f // update } func SetContainer2(f Fooer) { ff := f + container.f = f +} + +func SetContainer3(f Fooer) { + ff := f // associate to non-attached object + SetContainer(ff) // attach container, while ff is not attached } diff --git a/examples/gno.land/r/demo/tests/crossrealm/crossrealm3.gno b/examples/gno.land/r/demo/tests/crossrealm/crossrealm3.gno index 6fb1b958baf..1d1c0cf6f35 100644 --- a/examples/gno.land/r/demo/tests/crossrealm/crossrealm3.gno +++ b/examples/gno.land/r/demo/tests/crossrealm/crossrealm3.gno @@ -5,6 +5,7 @@ type Bar struct { } var bar *Bar +var Bar2 *Bar // exported func SetBar(b *Bar) *Bar { bar = b diff --git a/examples/gno.land/r/demo/tests/crossrealm/crossrealm4.gno b/examples/gno.land/r/demo/tests/crossrealm/crossrealm4.gno new file mode 100644 index 00000000000..e7d86663094 --- /dev/null +++ b/examples/gno.land/r/demo/tests/crossrealm/crossrealm4.gno @@ -0,0 +1,7 @@ +package crossrealm + +var S []Fooer + +func SetSlice(fs []Fooer) { + S = fs +} diff --git a/gnovm/pkg/gnolang/machine.go b/gnovm/pkg/gnolang/machine.go index 2a7323c3a3c..0265b45ba5e 100644 --- a/gnovm/pkg/gnolang/machine.go +++ b/gnovm/pkg/gnolang/machine.go @@ -730,7 +730,7 @@ func (m *Machine) runFileDecls(fns ...*FileNode) []TypedValue { func (m *Machine) runInitFromUpdates(pv *PackageValue, updates []TypedValue) { fmt.Println("---runInitFromUpdates") for _, tv := range updates { - fmt.Println("---tv: ", tv) + fmt.Println("---runInitFromUpdates, tv: ", tv) if tv.IsDefined() && tv.T.Kind() == FuncKind && tv.V != nil { fv, ok := tv.V.(*FuncValue) if !ok { diff --git a/gnovm/pkg/gnolang/op_call.go b/gnovm/pkg/gnolang/op_call.go index d148457bd89..34e4f553dff 100644 --- a/gnovm/pkg/gnolang/op_call.go +++ b/gnovm/pkg/gnolang/op_call.go @@ -241,6 +241,7 @@ func (m *Machine) doOpReturnFromBlock() { finalize = true } if finalize { + fmt.Println("---going to finalize") // Finalize realm updates! // NOTE: This is a resource intensive undertaking. crlm.FinalizeRealmTransaction(m.ReadOnly, m.Store) diff --git a/gnovm/pkg/gnolang/op_eval.go b/gnovm/pkg/gnolang/op_eval.go index 3ef6da71210..b13f06212b7 100644 --- a/gnovm/pkg/gnolang/op_eval.go +++ b/gnovm/pkg/gnolang/op_eval.go @@ -37,7 +37,7 @@ func (m *Machine) doOpEval() { lb := m.LastBlock() // Push value, done. ptr := lb.GetPointerTo(m.Store, nx.Path) - fmt.Println("---ptr: ", ptr) + //fmt.Println("---ptr: ", ptr) m.PushValue(ptr.Deref()) return } diff --git a/gnovm/pkg/gnolang/ownership.go b/gnovm/pkg/gnolang/ownership.go index 82e1d33f1e7..908c4ed8715 100644 --- a/gnovm/pkg/gnolang/ownership.go +++ b/gnovm/pkg/gnolang/ownership.go @@ -353,8 +353,9 @@ func (tv *TypedValue) GetFirstObject(store Store) Object { fmt.Println("---rc: ", rc) fmt.Println("---v Owner: ", v.GetOwnerID()) fmt.Println("---v.GetObjectID(): ", v.GetObjectID()) + fmt.Println("---is Attached?", v.GetIsReal()) } - return cv.GetBase(store) // TODO: this is not enough for pointers + return cv.GetBase(store) case *ArrayValue: return cv case *SliceValue: diff --git a/gnovm/pkg/gnolang/realm.go b/gnovm/pkg/gnolang/realm.go index 06ef3170578..0244b0c2229 100644 --- a/gnovm/pkg/gnolang/realm.go +++ b/gnovm/pkg/gnolang/realm.go @@ -139,51 +139,19 @@ func (rlm *Realm) DidUpdate(po, xo, co Object) { fmt.Printf("---xo: %v, type of xo: %v\n", xo, reflect.TypeOf(xo)) fmt.Printf("---co: %v, type of co: %v\n", co, reflect.TypeOf(co)) fmt.Printf("---po: %v, type of po: %v\n", po, reflect.TypeOf(po)) + fmt.Printf("---xo: %p\n", xo) - fmt.Printf("xo: %p\n", xo) - if co != nil && co.GetIsCrossRealm() { - panic("!!!cross realm") - } + //if co != nil && co.GetIsCrossRealm() { + // panic("!!!cross realm") + //} if co != nil { - fmt.Println("--co isReal(attached): ", co.GetIsReal()) + fmt.Println("---co isReal(attached): ", co.GetIsReal()) fmt.Println("---co objectID: ", co.GetObjectID()) + fmt.Println("---co.GetObjectInfo:", co.GetObjectInfo()) + fmt.Printf("---co: %p\n", co) } - if co != nil { - fmt.Println("co.GetObjectInfo:", co.GetObjectInfo()) - fmt.Printf("co: %p\n", co) - } - - //// XXX, these can be improved by attach type info with co. - //// the following does not work - //if sv, ok := po.(*StructValue); ok { - // fmt.Println("---sv: ", sv) - // fmt.Println("---sv.ID: ", sv.ObjectInfo.ID) - // fmt.Println("---sv.Fields: ", sv.Fields) - // fmt.Println("---sv.OwnerID: ", sv.ObjectInfo.OwnerID) - //} else if bv, ok := po.(*Block); ok { - // for _, tv := range bv.Values { - // fmt.Println("----tv.T: ", tv.T) - // fmt.Println("----tv.V: ", tv.V) - // if csv, ok := co.(*StructValue); ok { - // if csv == tv.V { - // fmt.Println("---eql, csv: ", csv) - // fmt.Println("---eql, T: ", tv.T, reflect.TypeOf(tv.T)) - // if dt, ok := tv.T.(*DeclaredType); ok { - // fmt.Println("---dt: ", dt, dt.PkgPath) - // if IsRealmPath(dt.PkgPath) && dt.PkgPath != rlm.Path { - // fmt.Println("---set co to be cross realm object, co: ", co) - // fmt.Printf("---%p\n", co) - // co.SetIsCrossRealm(true) - // //panic("!!!") - // } - // } - // } - // } - // } - //} - // XXX, association happens here // if is co is attached to external realm // if xo is attached to realm, directly/indirectly; @@ -192,7 +160,7 @@ func (rlm *Realm) DidUpdate(po, xo, co Object) { // else if xo is not attached to realm, associate is ok too, check when finalize. // else, panic when finalizing current realm. - fmt.Println("---realm: ", rlm) + fmt.Println("---current realm: ", rlm) if rlm == nil { return } @@ -207,8 +175,17 @@ func (rlm *Realm) DidUpdate(po, xo, co Object) { panic("cannot attach to a deleted object") } } + + // check if assignee is attached, if yes and assigner is not attached, panic + if xo != nil { + fmt.Println("---xo.GetIsReal: ", xo.GetIsReal()) + } else { + println("---xo is nil") + } fmt.Println("---po.GetIsReal: ", po.GetIsReal()) + if po == nil || !po.GetIsReal() { // XXX, make sure po is attached + fmt.Println("---po(Base) not real, do nothing!!!") return // do nothing. } @@ -251,6 +228,8 @@ func (rlm *Realm) DidUpdate(po, xo, co Object) { co.SetOwner(po) rlm.MarkNewReal(co) // co will be attached when finalize } + } else { + println("---co is nil, do nothing") } if xo != nil { @@ -261,6 +240,8 @@ func (rlm *Realm) DidUpdate(po, xo, co Object) { rlm.MarkNewDeleted(xo) } } + } else { + println("---xo is nil, do nothing") } } @@ -306,6 +287,7 @@ func (rlm *Realm) MarkNewEscapedCheckCrossRealm(oo Object) { func (rlm *Realm) MarkNewReal(oo Object) { fmt.Println("---markNewReal---, oo: ", oo) + fmt.Println("---markNewReal---, type of oo: ", reflect.TypeOf(oo)) if debug { if pv, ok := oo.(*PackageValue); ok { // packages should have no owner. @@ -341,7 +323,8 @@ func (rlm *Realm) MarkNewReal(oo Object) { // mark dirty == updated func (rlm *Realm) MarkDirty(oo Object) { - fmt.Printf("rlm: %v MarkDirty: %v\n", rlm, oo) + fmt.Printf("---current rlm: %v: \n", rlm) + fmt.Printf("---Mark Dirty %v: \n", oo) if debug { if !oo.GetIsReal() && !oo.GetIsNewReal() { panic("cannot mark unreal object as dirty") @@ -412,9 +395,9 @@ func (rlm *Realm) MarkNewEscaped(oo Object) { // to a realm gets attached here, which should panic. // OpReturn calls this when exiting a realm transaction. func (rlm *Realm) FinalizeRealmTransaction(readonly bool, store Store) { - fmt.Println("---FinalizeRealmTransaction---") + fmt.Println("-------------FinalizeRealmTransaction---------------") defer func() { - fmt.Println("---done FinalizeRealmTransaction---") + fmt.Println("================done FinalizeRealmTransaction==================") }() if readonly { if true || @@ -490,15 +473,17 @@ func (rlm *Realm) processNewCreatedMarks(store Store) { // TODO: here check embedded object cross more := getChildObjects2(store, oo) fmt.Println("---children of oo: ", more) - for _, c := range more { - fmt.Printf("---%p\n", c) + fmt.Println("---len of children: ", len(more)) + for i, c := range more { + fmt.Printf("[%d] of children is: %v\n", i, c) + //fmt.Printf("---%p\n", c) if c.GetIsCrossRealm() { panic("---cross realm") } else { println("---not cross realm") } } - fmt.Println("---oo.GetRefCount(): ", oo.GetRefCount()) + fmt.Println("---processNewCreatedMarks, oo.GetRefCount(): ", oo.GetRefCount()) if oo.GetIsCrossRealm() { fmt.Println("---should not attach value with type defined in other realm") //panic("---!!!") @@ -530,7 +515,7 @@ func (rlm *Realm) processNewCreatedMarks(store Store) { // oo must be marked new-real, and ref-count already incremented. func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { - fmt.Println("---incRefCreatedDescendants---, oo: ", oo) + fmt.Println("---incRefCreatedDescendants from oo: ", oo) fmt.Println("---incRefCreatedDescendants---, oo.GetObjectID: ", oo.GetObjectID()) if debug { if oo.GetIsDirty() { @@ -554,10 +539,11 @@ func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { // recurse for children. more := getChildObjects2(store, oo) - fmt.Println("---more: ", more) - for _, child := range more { - fmt.Printf("---child: %v, type of child: %v \n", child, reflect.TypeOf(child)) - fmt.Printf("---child addr: %p\n", child) + fmt.Println("---incRefCreatedDescendants, more: ", more) + fmt.Println("---len of more: ", len(more)) + for i, child := range more { + fmt.Printf("---[%d]child: %v, type of child: %v \n", i, child, reflect.TypeOf(child)) + //fmt.Printf("---child addr: %p\n", child) if _, ok := child.(*PackageValue); ok { if debug { if child.GetRefCount() < 1 { @@ -569,7 +555,7 @@ func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { } child.IncRefCount() rc := child.GetRefCount() - fmt.Println("---rc: ", rc) + fmt.Println("---rc after inc: ", rc) if rc == 1 { fmt.Println("---rc == 1") if child.GetIsReal() { @@ -589,6 +575,7 @@ func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { } } else if rc > 1 { if child.GetIsEscaped() { + fmt.Println("---child is escaped, child: ", child) // already escaped, do nothing. } else { // NOTE: do not unset owner here, @@ -686,9 +673,9 @@ func (rlm *Realm) processNewEscapedMarks(store Store) { // (and never can be unescaped,) // except for new-reals that get demoted // because ref-count isn't >= 2. - for _, eo := range rlm.newEscaped { - fmt.Println("---processNewEscapedMarks, eo, eo.GetRefCount: ", eo, eo.GetRefCount()) - fmt.Println("---processNewEscapedMarks, eo, eo.GetObjectID: ", eo, eo.GetObjectID()) + for i, eo := range rlm.newEscaped { + fmt.Printf("---processNewEscapedMarks, [%d]eo: %v\n", i, eo) + fmt.Println("---processNewEscapedMarks, eo.GetObjectID: ", eo.GetRefCount()) if debug { if !eo.GetIsNewEscaped() { panic("new escaped mark not marked as new escaped") @@ -811,19 +798,25 @@ func (rlm *Realm) markDirtyAncestors(store Store) { // Saves .created and .updated objects. func (rlm *Realm) saveUnsavedObjects(store Store) { - fmt.Println("---saveUnsavedObjects---") + fmt.Println("---saveUnsavedObjects, new created, new updated---") + fmt.Println("---len of new created: ", len(rlm.created)) + fmt.Println("---len of new updated: ", len(rlm.updated)) for _, co := range rlm.created { + fmt.Println("------saveUnsavedObject, co: ", co) // for i := len(rlm.created) - 1; i >= 0; i-- { // co := rlm.created[i] if !co.GetIsNewReal() { + println("---not new real") // might have happened already as child // of something else created. continue } else { + println("---new real") rlm.saveUnsavedObjectRecursively(store, co) } } for _, uo := range rlm.updated { + fmt.Println("---uo: ", uo) // for i := len(rlm.updated) - 1; i >= 0; i-- { // uo := rlm.updated[i] if !uo.GetIsDirty() { @@ -838,6 +831,7 @@ func (rlm *Realm) saveUnsavedObjects(store Store) { // store unsaved children first. func (rlm *Realm) saveUnsavedObjectRecursively(store Store, oo Object) { + fmt.Println("---saveUnsavedObjectRecursively, oo: ", oo) if debug { if !oo.GetIsNewReal() && !oo.GetIsDirty() { panic("cannot save new real or non-dirty objects") @@ -856,8 +850,14 @@ func (rlm *Realm) saveUnsavedObjectRecursively(store Store, oo Object) { } // first, save unsaved children. unsaved := getUnsavedChildObjects(oo) + fmt.Println("---unsaved: ", unsaved) for _, uch := range unsaved { + fmt.Println("---uch: ", uch) + fmt.Println("---uch.GetOwnerID(): ", uch.GetOwnerID()) + fmt.Println("---uch.GetRefCount(): ", uch.GetRefCount()) + fmt.Println("---type of uch: ", reflect.TypeOf(uch)) if uch.GetIsEscaped() || uch.GetIsNewEscaped() { + fmt.Println("---uch is escaped or new escaped") // no need to save preemptively. } else { rlm.saveUnsavedObjectRecursively(store, uch) @@ -865,6 +865,7 @@ func (rlm *Realm) saveUnsavedObjectRecursively(store Store, oo Object) { } // then, save self. if oo.GetIsNewReal() { + fmt.Println("---oo is new real: ", oo) // save created object. if debug { if oo.GetIsDirty() { @@ -874,6 +875,7 @@ func (rlm *Realm) saveUnsavedObjectRecursively(store Store, oo Object) { rlm.saveObject(store, oo) oo.SetIsNewReal(false) } else { + fmt.Println("---oo is not new real, update it: ", oo) // update existing object. if debug { if !oo.GetIsDirty() { @@ -892,7 +894,9 @@ func (rlm *Realm) saveUnsavedObjectRecursively(store Store, oo Object) { } func (rlm *Realm) saveObject(store Store, oo Object) { + fmt.Println("---saveObject: ", oo) oid := oo.GetObjectID() + fmt.Println("---saveObject: ", oid) if oid.IsZero() { panic("unexpected zero object id") } @@ -962,10 +966,10 @@ func (rlm *Realm) clearMarks() { func getSelfOrChildObjects(val Value, more []Value) []Value { fmt.Println("---getSelfOrChildObjects, val: ", val) if _, ok := val.(RefValue); ok { - println("---ref value") + //println("---ref value") return append(more, val) } else if _, ok := val.(Object); ok { - println("---not ref value") + //println("---not ref value") return append(more, val) } else { return getChildObjects(val, more) @@ -1061,11 +1065,11 @@ func getChildObjects2(store Store, val Value) []Object { objs := make([]Object, 0, len(chos)) for _, child := range chos { if ref, ok := child.(RefValue); ok { - println("---ref value") + //println("---ref value") oo := store.GetObject(ref.ObjectID) objs = append(objs, oo) } else if oo, ok := child.(Object); ok { - println("---not ref value") + //println("---not ref value") objs = append(objs, oo) } } diff --git a/gnovm/pkg/gnolang/store.go b/gnovm/pkg/gnolang/store.go index 30443032d12..69302a23a6d 100644 --- a/gnovm/pkg/gnolang/store.go +++ b/gnovm/pkg/gnolang/store.go @@ -328,7 +328,7 @@ func (ds *defaultStore) SetObject(oo Object) { oid := oo.GetObjectID() // replace children/fields with Ref. o2 := copyValueWithRefs(oo) - fmt.Println("---o2: ", o2) + fmt.Println("---SetObject, o2: ", o2) // marshal to binary. bz := amino.MustMarshalAny(o2) // set hash. @@ -363,10 +363,10 @@ func (ds *defaultStore) SetObject(oo Object) { if ds.opslog != nil { var op StoreOpType if oo.GetIsNewReal() { - fmt.Println("---oo is new real, oo: ", oo) + fmt.Println("---SetObject, oo is new real, oo: ", oo) op = StoreOpNew } else { - fmt.Println("---oo is mod, oo: ", oo) + fmt.Println("---SetObject, oo is mod, oo: ", oo) op = StoreOpMod } ds.opslog = append(ds.opslog, diff --git a/gnovm/pkg/gnolang/values.go b/gnovm/pkg/gnolang/values.go index ad6bc85a4b2..a98868fb956 100644 --- a/gnovm/pkg/gnolang/values.go +++ b/gnovm/pkg/gnolang/values.go @@ -294,6 +294,7 @@ func (pv PointerValue) Assign2(alloc *Allocator, store Store, rlm *Realm, tv2 Ty pv.TV.Assign(alloc, tv2, cu) oo2 := pv.TV.GetFirstObject(store) fmt.Println("---oo2: ", oo2) + // TODO: assert attached here? rlm.DidUpdate(pv.Base.(Object), oo1, oo2) } else { pv.TV.Assign(alloc, tv2, cu) @@ -2451,9 +2452,9 @@ func (b *Block) GetParent(store Store) *Block { } func (b *Block) GetPointerToInt(store Store, index int) PointerValue { - fmt.Println("---GetPointerToInt") + //fmt.Println("---GetPointerToInt") vv := fillValueTV(store, &b.Values[index]) - fmt.Println("---vv: ", vv) + //fmt.Println("---vv: ", vv) return PointerValue{ TV: vv, Base: b, @@ -2462,9 +2463,9 @@ func (b *Block) GetPointerToInt(store Store, index int) PointerValue { } func (b *Block) GetPointerTo(store Store, path ValuePath) PointerValue { - fmt.Println("---GetPointerTo, path: ", path) + //fmt.Println("---GetPointerTo, path: ", path) if path.IsBlockBlankPath() { - println("---isBlockBlankPath") + //println("---isBlockBlankPath") if debug { if path.Name != blankIdentifier { panic(fmt.Sprintf( @@ -2645,17 +2646,17 @@ func typedString(s string) TypedValue { } func fillValueTV(store Store, tv *TypedValue) *TypedValue { - fmt.Println("---fillValueTV, tv: ", tv) + //fmt.Println("---fillValueTV, tv: ", tv) switch cv := tv.V.(type) { case RefValue: - println("---tv.V RefValue") - fmt.Println("---cv: ", cv) + //println("---tv.V RefValue") + //fmt.Println("---cv: ", cv) if cv.PkgPath != "" { // load package tv.V = store.GetPackage(cv.PkgPath, false) } else { // load object // XXX XXX allocate object. tv.V = store.GetObject(cv.ObjectID) - fmt.Println("---tv.V: ", tv.V) + //fmt.Println("---tv.V: ", tv.V) } case PointerValue: // As a special case, cv.Base is filled diff --git a/gnovm/tests/files/zrealm_crossrealm15.gno b/gnovm/tests/files/zrealm_crossrealm15.gno index fd870731c0e..40b94662a70 100644 --- a/gnovm/tests/files/zrealm_crossrealm15.gno +++ b/gnovm/tests/files/zrealm_crossrealm15.gno @@ -25,11 +25,3 @@ func main() { crossrealm.CallFoo() print(".") } - -// Output: -// hello gno.land/r/demo/tests/crossrealm -// . - -// Error: - -// Realm: diff --git a/gnovm/tests/files/zrealm_crossrealm16.gno b/gnovm/tests/files/zrealm_crossrealm16.gno index fd9f9889c38..50c695884c4 100644 --- a/gnovm/tests/files/zrealm_crossrealm16.gno +++ b/gnovm/tests/files/zrealm_crossrealm16.gno @@ -8,17 +8,11 @@ import ( var b0 crossrealm.Bar func init() { - b0 = crossrealm.Bar{A: 1} // attach to this realm + b0 = crossrealm.Bar{A: 1} // XXX, should be invalid to attach external type } func main() { - crossrealm.SetBar(&b0) // set reference to external realm + crossrealm.SetBar(&b0) crossrealm.CallBar() print(".") } - -// Output: -// 1 -// . - -// Error: diff --git a/gnovm/tests/files/zrealm_crossrealm16a.gno b/gnovm/tests/files/zrealm_crossrealm16a.gno new file mode 100644 index 00000000000..5fbe6a072ab --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm16a.gno @@ -0,0 +1,16 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +var b0 crossrealm.Bar + +func init() { + crossrealm.Bar2.A = 2 // this should be valid +} + +func main() { + print(".") +} diff --git a/gnovm/tests/files/zrealm_crossrealm17.gno b/gnovm/tests/files/zrealm_crossrealm17.gno index 2cc82b960d5..e5587dedbee 100644 --- a/gnovm/tests/files/zrealm_crossrealm17.gno +++ b/gnovm/tests/files/zrealm_crossrealm17.gno @@ -16,10 +16,7 @@ type fooer struct{} var f *fooer func main() { - // not finalize yet, so this reference can not be attached to external realm, - // can only be associated to un-attached objects, only until the un-attached - // objects has not been attached to the external realm yet. - f = &fooer{} + f = &fooer{} // not attached c := &container{f} crossrealm.SetFooer(c) crossrealm.CallFoo() diff --git a/gnovm/tests/files/zrealm_crossrealm20.gno b/gnovm/tests/files/zrealm_crossrealm20.gno deleted file mode 100644 index 62b6d08c78f..00000000000 --- a/gnovm/tests/files/zrealm_crossrealm20.gno +++ /dev/null @@ -1,33 +0,0 @@ -// PKGPATH: gno.land/r/crossrealm_test -package crossrealm_test - -import ( - crossrealm "gno.land/r/demo/tests/crossrealm" -) - -var b0 = crossrealm.Bar{A: 1} - -// un-attached package level var -// is this attached? or not? another function to attach? -//var b *crossrealm.Bar = crossrealm.SetBar(&b0) - -func init() { - // crossrealm.CallFoo() - crossrealm.SetBar(&b0) -} - -func main() { - crossrealm.CallBar() - print(".") -} - -// Output: -// hello gno.land/r/demo/tests/crossrealm -// hello gno.land/r/demo/tests/crossrealm -// . - -// Error: - -// Realm: -// switchrealm["gno.land/r/demo/tests/crossrealm"] -// switchrealm["gno.land/r/crossrealm_test"] diff --git a/gnovm/tests/files/zrealm_crossrealm21.gno b/gnovm/tests/files/zrealm_crossrealm21.gno index 11093213162..324f669805b 100644 --- a/gnovm/tests/files/zrealm_crossrealm21.gno +++ b/gnovm/tests/files/zrealm_crossrealm21.gno @@ -18,5 +18,3 @@ func main() { // XXX, this should fail while trying to attach // value of type defined in another realm. // NOTE: the check can be in runtime or in preprocess(by simply checkin edge cases). - -// Error: diff --git a/gnovm/tests/files/zrealm_crossrealm21a.gno b/gnovm/tests/files/zrealm_crossrealm21a.gno index e77837400e3..63e514b8f0f 100644 --- a/gnovm/tests/files/zrealm_crossrealm21a.gno +++ b/gnovm/tests/files/zrealm_crossrealm21a.gno @@ -15,15 +15,9 @@ var c Container func init() { b0 := crossrealm.Bar{A: 1} // this is valid association - c = Container{name: "container", b: b0} // XXX, check recursively while finalize here + c = Container{name: "container", b: b0} // XXX, should panic } func main() { print(".") } - -// XXX, this should fail while trying to attach -// value of type defined in another realm. -// NOTE: the check can be in runtime or in preprocess(by simply checkin edge cases). - -// Error: diff --git a/gnovm/tests/files/zrealm_crossrealm22.gno b/gnovm/tests/files/zrealm_crossrealm22.gno index 14c3dbd5311..02a612bea9a 100644 --- a/gnovm/tests/files/zrealm_crossrealm22.gno +++ b/gnovm/tests/files/zrealm_crossrealm22.gno @@ -16,6 +16,3 @@ func main() { } // XXX this works. attach value with type defined in same realm - -// Output: -//. diff --git a/gnovm/tests/files/zrealm_crossrealm24.gno b/gnovm/tests/files/zrealm_crossrealm24.gno index 01934436225..a7697ffd980 100644 --- a/gnovm/tests/files/zrealm_crossrealm24.gno +++ b/gnovm/tests/files/zrealm_crossrealm24.gno @@ -16,7 +16,7 @@ func main() { } // XXX, should work to attach by reference to -// type defined in another realm. +// type defined in another realm??? // Output: // . diff --git a/gnovm/tests/files/zrealm_crossrealm25.gno b/gnovm/tests/files/zrealm_crossrealm25.gno deleted file mode 100644 index 10b37896c8f..00000000000 --- a/gnovm/tests/files/zrealm_crossrealm25.gno +++ /dev/null @@ -1,33 +0,0 @@ -// PKGPATH: gno.land/r/crossrealm_test -package crossrealm_test - -import ( - "std" - - crossrealm "gno.land/r/demo/tests/crossrealm" -) - -type fooer struct{ name string } - -func (fooer) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } - -var f fooer - -// When an association occurs by reference to an object already -// attached to an external realm, no attachment occurs. For example, -// pointers to external realm attached objects may be associated -// with a realm object (whether attached or not), such as assigned -// to the field of a struct, but this does not attach the external -// realm object to the container, in this case the struct. -func init() { - f = fooer{name: "local_fooer"} // f attached to current realm -} - -func main() { - crossrealm.AttachContainer() // this attaches container first - crossrealm.SetContainer(&f) - print(".") -} - -// XXX, this associate a pointer to a value(already attached to local realm) -// to external realm, no attachment happens to the external realm. diff --git a/gnovm/tests/files/zrealm_crossrealm25a.gno b/gnovm/tests/files/zrealm_crossrealm25a.gno index 7064b364d3d..ba2b51e1fe8 100644 --- a/gnovm/tests/files/zrealm_crossrealm25a.gno +++ b/gnovm/tests/files/zrealm_crossrealm25a.gno @@ -13,12 +13,6 @@ func (fooer) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } var f fooer -// When an association occurs by reference to an object already -// attached to an external realm, no attachment occurs. For example, -// pointers to external realm attached objects may be associated -// with a realm object (whether attached or not), such as assigned -// to the field of a struct, but this does not attach the external -// realm object to the container, in this case the struct. func init() { f = fooer{} } diff --git a/gnovm/tests/files/zrealm_crossrealm25b.gno b/gnovm/tests/files/zrealm_crossrealm25b.gno index 57cfe2324ae..ac2e2dce401 100644 --- a/gnovm/tests/files/zrealm_crossrealm25b.gno +++ b/gnovm/tests/files/zrealm_crossrealm25b.gno @@ -1,8 +1,6 @@ // PKGPATH: gno.land/r/crossrealm_test package crossrealm_test -// pass pointer to an embedded object to external realm? - import ( "std" @@ -31,3 +29,5 @@ func main() { crossrealm.SetContainer(&lc.f) print(".") } + +// XXX? diff --git a/gnovm/tests/files/zrealm_crossrealm25c.gno b/gnovm/tests/files/zrealm_crossrealm25c.gno index 9e8f961a21f..9a1d0e9cb1b 100644 --- a/gnovm/tests/files/zrealm_crossrealm25c.gno +++ b/gnovm/tests/files/zrealm_crossrealm25c.gno @@ -27,7 +27,7 @@ func init() { } func main() { - crossrealm.AttachContainer() // this attaches container first + crossrealm.AttachContainer() crossrealm.SetContainer(lc.f) // should work print(".") } diff --git a/gnovm/tests/files/zrealm_crossrealm25d.gno b/gnovm/tests/files/zrealm_crossrealm25d.gno index 46ccf45dac7..7558c658b46 100644 --- a/gnovm/tests/files/zrealm_crossrealm25d.gno +++ b/gnovm/tests/files/zrealm_crossrealm25d.gno @@ -30,7 +30,7 @@ func init() { } func main() { - crossrealm.AttachContainer() // this attaches container first + crossrealm.AttachContainer() crossrealm.SetContainer(lc.ff) // this should not panic, lc.ff is not same with f(gloabl) print(".") } diff --git a/gnovm/tests/files/zrealm_crossrealm26.gno b/gnovm/tests/files/zrealm_crossrealm26.gno index 3dfabfd14fe..5148cc0fefa 100644 --- a/gnovm/tests/files/zrealm_crossrealm26.gno +++ b/gnovm/tests/files/zrealm_crossrealm26.gno @@ -18,7 +18,7 @@ func init() { } func main() { - crossrealm.AttachContainer() // this attaches container first + crossrealm.AttachContainer() crossrealm.SetContainer(f) print(".") } diff --git a/gnovm/tests/files/zrealm_crossrealm27.gno b/gnovm/tests/files/zrealm_crossrealm27.gno index f0bbfee07de..32f8dd834f8 100644 --- a/gnovm/tests/files/zrealm_crossrealm27.gno +++ b/gnovm/tests/files/zrealm_crossrealm27.gno @@ -7,7 +7,9 @@ import ( crossrealm "gno.land/r/demo/tests/crossrealm" ) -type fooer struct{} +type fooer struct { + name string +} func (fooer) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } @@ -16,8 +18,7 @@ var f fooer // XXX, this should work when reference to not attached local object // associated to external realm *NOT* attached object. func main() { - f = fooer{} // this is not attached - crossrealm.SetContainer(&f) // XXX, here should work to associate *NOT* attached object to external container - crossrealm.AttachContainer() // XXX, here should panic, to attach external *NOT* attached object + f = fooer{name: "local_fooer"} // this is not attached + crossrealm.SetContainer2(&f) // XXX, here should work to associate *NOT* attached object to external container print(".") } diff --git a/gnovm/tests/files/zrealm_crossrealm27a.gno b/gnovm/tests/files/zrealm_crossrealm27a.gno index 6d29277240e..47ac14ecb04 100644 --- a/gnovm/tests/files/zrealm_crossrealm27a.gno +++ b/gnovm/tests/files/zrealm_crossrealm27a.gno @@ -7,27 +7,14 @@ import ( crossrealm "gno.land/r/demo/tests/crossrealm" ) -type fooer struct{} +type fooer struct{ name string } func (fooer) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } var f fooer -// XXX, this should work when reference to not attached local object -// associated to external realm *NOT* attached object. -// XXX, panic should happen when the attachment happen in external realm - -// In this way, all references to external realm objects that are reachable -// from a realm’s package global variables must already be attached to the external realm. func main() { - f = fooer{} - crossrealm.SetContainer(&f) + f = fooer{name: "local_fooer"} + crossrealm.SetContainer3(&f) print(".") } - -// Output: -// . - -// Error: - -// Realm: diff --git a/gnovm/tests/files/zrealm_crossrealm28.gno b/gnovm/tests/files/zrealm_crossrealm28.gno new file mode 100644 index 00000000000..65084d77c19 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm28.gno @@ -0,0 +1,27 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "std" + + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +type foo struct { + name string +} + +func (foo) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } + +var fs []crossrealm.Fooer + +func init() { + fs = append(fs, foo{name: "1"}) + fs = append(fs, foo{name: "2"}) + fs = append(fs, foo{name: "3"}) +} + +func main() { + println("ok") + crossrealm.SetSlice(fs) +} diff --git a/gnovm/tests/files/zrealm_crossrealm33.gno b/gnovm/tests/files/zrealm_crossrealm33.gno new file mode 100644 index 00000000000..b9d6d5e9718 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm33.gno @@ -0,0 +1,16 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +var ptr *int + +func init() { + ptr = new(int) +} + +func main() { + *ptr = 2 + println(*ptr) +} + +// Output: +// 2 From 2e6a97c27fb0bed8799e5f5583763ef245fa6d5f Mon Sep 17 00:00:00 2001 From: ltzMaxwell Date: Wed, 6 Nov 2024 09:38:50 +0800 Subject: [PATCH 12/40] save --- gnovm/tests/files/zrealm_crossrealm23a.gno | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/gnovm/tests/files/zrealm_crossrealm23a.gno b/gnovm/tests/files/zrealm_crossrealm23a.gno index 61d8f0ec291..b3f4f2ccd93 100644 --- a/gnovm/tests/files/zrealm_crossrealm23a.gno +++ b/gnovm/tests/files/zrealm_crossrealm23a.gno @@ -16,6 +16,4 @@ func main() { } // XXX, this works, attach reference with type defined in p - -// Output: -//. +// Attach pointer? From 7bedb54e4a6226fe1439fd4085c36b78dd477ad1 Mon Sep 17 00:00:00 2001 From: ltzMaxwell Date: Thu, 7 Nov 2024 07:32:51 +0800 Subject: [PATCH 13/40] save --- gnovm/pkg/gnolang/machine.go | 3 ++ gnovm/pkg/gnolang/realm.go | 44 ++++++++++++----------- gnovm/tests/files/zrealm_crossrealm21.gno | 2 +- 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/gnovm/pkg/gnolang/machine.go b/gnovm/pkg/gnolang/machine.go index 0265b45ba5e..7d00e8f0bef 100644 --- a/gnovm/pkg/gnolang/machine.go +++ b/gnovm/pkg/gnolang/machine.go @@ -287,6 +287,8 @@ func (m *Machine) RunMemPackageWithOverrides(memPkg *std.MemPackage, save bool) func (m *Machine) runMemPackage(memPkg *std.MemPackage, save, overrides bool) (*PackageNode, *PackageValue) { fmt.Println("---runMemPackage, save: ", save) + fmt.Println("---runMemPackage, memPkg: ", memPkg) + defer func() { fmt.Println("---done runMemPackage: ", memPkg) }() // parse files. files := ParseMemPackage(memPkg) if !overrides && checkDuplicates(files) { @@ -976,6 +978,7 @@ func (m *Machine) RunDeclaration(d Decl) { // package level, for which evaluations happen during // preprocessing). func (m *Machine) runDeclaration(d Decl) { + fmt.Println("---run declaration, d: ", d) switch d := d.(type) { case *FuncDecl: // nothing to do. diff --git a/gnovm/pkg/gnolang/realm.go b/gnovm/pkg/gnolang/realm.go index 0244b0c2229..49444d2f794 100644 --- a/gnovm/pkg/gnolang/realm.go +++ b/gnovm/pkg/gnolang/realm.go @@ -465,24 +465,25 @@ func (rlm *Realm) FinalizeRealmTransaction(readonly bool, store Store) { // and get assigned ids. func (rlm *Realm) processNewCreatedMarks(store Store) { fmt.Println("---processNewCreatedMarks---") + fmt.Println("---len of newCreated objects:", len(rlm.newCreated)) // Create new objects and their new descendants. //for _, oo := range rlm.newCreated { for i := 0; i < len(rlm.newCreated); i++ { oo := rlm.newCreated[i] fmt.Printf("---oo[%d] is %v:\n", i, oo) // TODO: here check embedded object cross - more := getChildObjects2(store, oo) - fmt.Println("---children of oo: ", more) - fmt.Println("---len of children: ", len(more)) - for i, c := range more { - fmt.Printf("[%d] of children is: %v\n", i, c) - //fmt.Printf("---%p\n", c) - if c.GetIsCrossRealm() { - panic("---cross realm") - } else { - println("---not cross realm") - } - } + //more := getChildObjects2(store, oo) + //fmt.Println("---children of oo: ", more) + //fmt.Println("---len of children: ", len(more)) + //for i, c := range more { + // fmt.Printf("[%d] of children is: %v\n", i, c) + // //fmt.Printf("---%p\n", c) + // if c.GetIsCrossRealm() { + // panic("---cross realm") + // } else { + // println("---not cross realm") + // } + //} fmt.Println("---processNewCreatedMarks, oo.GetRefCount(): ", oo.GetRefCount()) if oo.GetIsCrossRealm() { fmt.Println("---should not attach value with type defined in other realm") @@ -516,7 +517,7 @@ func (rlm *Realm) processNewCreatedMarks(store Store) { // oo must be marked new-real, and ref-count already incremented. func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { fmt.Println("---incRefCreatedDescendants from oo: ", oo) - fmt.Println("---incRefCreatedDescendants---, oo.GetObjectID: ", oo.GetObjectID()) + fmt.Println("---incRefCreatedDescendants, oo.GetObjectID: ", oo.GetObjectID()) if debug { if oo.GetIsDirty() { panic("cannot increase reference of descendants of dirty objects") @@ -539,7 +540,7 @@ func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { // recurse for children. more := getChildObjects2(store, oo) - fmt.Println("---incRefCreatedDescendants, more: ", more) + //fmt.Println("---incRefCreatedDescendants, more: ", more) fmt.Println("---len of more: ", len(more)) for i, child := range more { fmt.Printf("---[%d]child: %v, type of child: %v \n", i, child, reflect.TypeOf(child)) @@ -557,7 +558,6 @@ func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { rc := child.GetRefCount() fmt.Println("---rc after inc: ", rc) if rc == 1 { - fmt.Println("---rc == 1") if child.GetIsReal() { fmt.Println("---child is real, child: ", child) // a deleted real became undeleted. @@ -569,6 +569,8 @@ func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { // became real (again). // NOTE: may already be marked for first gen // newCreated or updated. + //fmt.Println("---Set owner to be: ", oo) + println("---set owner") child.SetOwner(oo) rlm.incRefCreatedDescendants(store, child) child.SetIsNewReal(true) @@ -964,7 +966,7 @@ func (rlm *Realm) clearMarks() { // Value is either Object or RefValue. // Shallow; doesn't recurse into objects. func getSelfOrChildObjects(val Value, more []Value) []Value { - fmt.Println("---getSelfOrChildObjects, val: ", val) + //fmt.Println("---getSelfOrChildObjects, val: ", val) if _, ok := val.(RefValue); ok { //println("---ref value") return append(more, val) @@ -979,7 +981,7 @@ func getSelfOrChildObjects(val Value, more []Value) []Value { // Gets child objects. // Shallow; doesn't recurse into objects. func getChildObjects(val Value, more []Value) []Value { - fmt.Println("---getChildObjects, val: ", val, reflect.TypeOf(val)) + //fmt.Println("---getChildObjects, val: ", val, reflect.TypeOf(val)) switch cv := val.(type) { case nil: return more @@ -1006,10 +1008,10 @@ func getChildObjects(val Value, more []Value) []Value { more = getSelfOrChildObjects(cv.Base, more) return more case *StructValue: - println("---struct value") + //println("---struct value") for _, ctv := range cv.Fields { // TODO: we have type infos here, so check check cross realm logic - fmt.Println("---ctv: ", ctv) + //fmt.Println("---ctv: ", ctv) more = getSelfOrChildObjects(ctv.V, more) } return more @@ -1059,9 +1061,9 @@ func getChildObjects(val Value, more []Value) []Value { // like getChildObjects() but loads RefValues into objects. func getChildObjects2(store Store, val Value) []Object { - fmt.Println("---getChildObjects2, val: ", val) + //fmt.Println("---getChildObjects2, val: ", val) chos := getChildObjects(val, nil) - fmt.Println("---chos: ", chos) + //fmt.Println("---chos: ", chos) objs := make([]Object, 0, len(chos)) for _, child := range chos { if ref, ok := child.(RefValue); ok { diff --git a/gnovm/tests/files/zrealm_crossrealm21.gno b/gnovm/tests/files/zrealm_crossrealm21.gno index 324f669805b..b065e31ee06 100644 --- a/gnovm/tests/files/zrealm_crossrealm21.gno +++ b/gnovm/tests/files/zrealm_crossrealm21.gno @@ -5,7 +5,7 @@ import ( crossrealm "gno.land/r/demo/tests/crossrealm" ) -var b0 crossrealm.Bar +var b0 crossrealm.Bar // run declarations func init() { b0 = crossrealm.Bar{A: 1} From eeb5bd8e5096504f5198278a51ec379fc9947a9a Mon Sep 17 00:00:00 2001 From: ltzMaxwell Date: Fri, 8 Nov 2024 09:21:41 +0800 Subject: [PATCH 14/40] more obj info --- gnovm/pkg/gnolang/machine.go | 1 + gnovm/pkg/gnolang/ownership.go | 89 +++++++++++++++++++++-- gnovm/pkg/gnolang/realm.go | 20 +++-- gnovm/pkg/gnolang/values.go | 13 +++- gnovm/tests/files/zrealm_crossrealm20.gno | 16 ++++ 5 files changed, 125 insertions(+), 14 deletions(-) create mode 100644 gnovm/tests/files/zrealm_crossrealm20.gno diff --git a/gnovm/pkg/gnolang/machine.go b/gnovm/pkg/gnolang/machine.go index 7d00e8f0bef..0f5d705b7e1 100644 --- a/gnovm/pkg/gnolang/machine.go +++ b/gnovm/pkg/gnolang/machine.go @@ -985,6 +985,7 @@ func (m *Machine) runDeclaration(d Decl) { // closure and package already set // during PackageNode.NewPackage(). case *ValueDecl: + fmt.Println("---valueDecl, d.Type, type of d.Type: ", d.Type, reflect.TypeOf(d.Type)) m.PushOp(OpHalt) m.PushStmt(d) m.PushOp(OpExec) diff --git a/gnovm/pkg/gnolang/ownership.go b/gnovm/pkg/gnolang/ownership.go index 908c4ed8715..fa9955e9090 100644 --- a/gnovm/pkg/gnolang/ownership.go +++ b/gnovm/pkg/gnolang/ownership.go @@ -113,8 +113,8 @@ type Object interface { SetIsDeleted(bool, uint64) GetIsNewReal() bool SetIsNewReal(bool) - GetIsCrossRealm() bool // XXX, does escape imply this? - SetIsCrossRealm(bool) + GetLastNewEscapedRealm() PkgID // XXX, does escape imply this? + SetLastNewEscapedRealm(pkgID PkgID) GetIsNewEscaped() bool SetIsNewEscaped(bool) GetIsNewDeleted() bool @@ -208,6 +208,9 @@ func (oi *ObjectInfo) MustGetObjectID() ObjectID { func (oi *ObjectInfo) SetObjectID(oid ObjectID) { oi.ID = oid } +func (oi *ObjectInfo) SetLastEscapedRealm(pkgId PkgID) { + oi.lastNewRealEscapedRealm = pkgId +} func (oi *ObjectInfo) GetHash() ValueHash { return oi.Hash @@ -313,12 +316,12 @@ func (oi *ObjectInfo) SetIsNewReal(x bool) { oi.isNewReal = x } -func (oi *ObjectInfo) GetIsCrossRealm() bool { - return oi.isCrossRealm +func (oi *ObjectInfo) GetLastNewEscapedRealm() PkgID { + return oi.lastNewRealEscapedRealm } -func (oi *ObjectInfo) SetIsCrossRealm(x bool) { - oi.isCrossRealm = x +func (oi *ObjectInfo) SetLastNewEscapedRealm(pkgId PkgID) { + oi.lastNewRealEscapedRealm = pkgId } func (oi *ObjectInfo) GetIsNewEscaped() bool { @@ -344,6 +347,14 @@ func (oi *ObjectInfo) GetIsTransient() bool { // XXX, get first accessible object, maybe containing(parent) object, maybe itself. func (tv *TypedValue) GetFirstObject(store Store) Object { fmt.Println("---GetFirstObject---, tv: ", tv, reflect.TypeOf(tv.V)) + fmt.Println("---tv.T, type of tv.T", tv.T, reflect.TypeOf(tv.T)) + if dt, ok := tv.T.(*DeclaredType); ok { + fmt.Println("---dt: ", dt) + fmt.Println("---dt.Name: ", dt.Name) + fmt.Println("---dt.PkgPath: ", dt.PkgPath) + fmt.Println("---PkgID: ", PkgIDFromPkgPath(dt.PkgPath)) + fmt.Println("---dt.Base: ", dt.Base) + } switch cv := tv.V.(type) { case PointerValue: println("---pointer value, get base") @@ -387,3 +398,69 @@ func (tv *TypedValue) GetFirstObject(store Store) Object { return nil } } + +// XXX, get first accessible object, maybe containing(parent) object, maybe itself. +func (tv *TypedValue) GetFirstObject2(store Store) (Object, PkgID) { + fmt.Println("---GetFirstObject2---, tv: ", tv, reflect.TypeOf(tv.V)) + fmt.Println("---tv.T, type of tv.T", tv.T, reflect.TypeOf(tv.T)) + var pkgId PkgID + if dt, ok := tv.T.(*DeclaredType); ok { + fmt.Println("---dt: ", dt) + fmt.Println("---dt.Name: ", dt.Name) + fmt.Println("---dt.PkgPath: ", dt.PkgPath) + fmt.Println("---PkgID: ", PkgIDFromPkgPath(dt.PkgPath)) + fmt.Println("---dt.Base: ", dt.Base) + pkgId = PkgIDFromPkgPath(dt.PkgPath) + } + switch cv := tv.V.(type) { + case PointerValue: + println("---pointer value, get base") + if v, ok := cv.TV.V.(Object); ok { + fmt.Println("---v: ", v) + rc := v.GetRefCount() + fmt.Println("---rc: ", rc) + fmt.Println("---v Owner: ", v.GetOwnerID()) + fmt.Println("---v.GetObjectID(): ", v.GetObjectID()) + fmt.Println("---is Attached?", v.GetIsReal()) + + if dt, ok := cv.TV.T.(*DeclaredType); ok { + fmt.Println("---dt: ", dt) + fmt.Println("---dt.Name: ", dt.Name) + fmt.Println("---dt.PkgPath: ", dt.PkgPath) + fmt.Println("---PkgID: ", PkgIDFromPkgPath(dt.PkgPath)) + fmt.Println("---dt.Base: ", dt.Base) + pkgId = PkgIDFromPkgPath(dt.PkgPath) + } + } + return cv.GetBase(store), pkgId + case *ArrayValue: + return cv, pkgId + case *SliceValue: + return cv.GetBase(store), pkgId + case *StructValue: + println("---struct value") + fmt.Println("---cv.GetObjectID(): ", cv.GetObjectID()) + return cv, pkgId + case *FuncValue: + return cv.GetClosure(store), pkgId + case *MapValue: + return cv, pkgId + case *BoundMethodValue: + return cv, pkgId + case *NativeValue: + // XXX allow PointerValue.Assign2 to pass nil for oo1/oo2. + // panic("realm logic for native values not supported") + return nil, pkgId + case *Block: + return cv, pkgId + case RefValue: + oo := store.GetObject(cv.ObjectID) + tv.V = oo + return oo, pkgId + case *HeapItemValue: + // should only appear in PointerValue.Base + panic("heap item value should only appear as a pointer's base") + default: + return nil, pkgId + } +} diff --git a/gnovm/pkg/gnolang/realm.go b/gnovm/pkg/gnolang/realm.go index 49444d2f794..136d831983b 100644 --- a/gnovm/pkg/gnolang/realm.go +++ b/gnovm/pkg/gnolang/realm.go @@ -135,11 +135,17 @@ func (rlm *Realm) String() string { // associated object. // TODO: func (rlm *Realm) DidUpdate(po, xo, co Object, attached bool) { func (rlm *Realm) DidUpdate(po, xo, co Object) { - fmt.Println("---DidUpdate---") + fmt.Println("---DidUpdate, rlm.ID: ", rlm.ID) fmt.Printf("---xo: %v, type of xo: %v\n", xo, reflect.TypeOf(xo)) fmt.Printf("---co: %v, type of co: %v\n", co, reflect.TypeOf(co)) fmt.Printf("---po: %v, type of po: %v\n", po, reflect.TypeOf(po)) - fmt.Printf("---xo: %p\n", xo) + //fmt.Printf("---xo: %p\n", xo) + if co != nil { + fmt.Println("co.LastNewEscapedRealm: ", co.GetLastNewEscapedRealm()) + if rlm.ID != co.GetLastNewEscapedRealm() { + panic("---cross realm!!!") + } + } //if co != nil && co.GetIsCrossRealm() { // panic("!!!cross realm") @@ -149,7 +155,7 @@ func (rlm *Realm) DidUpdate(po, xo, co Object) { fmt.Println("---co isReal(attached): ", co.GetIsReal()) fmt.Println("---co objectID: ", co.GetObjectID()) fmt.Println("---co.GetObjectInfo:", co.GetObjectInfo()) - fmt.Printf("---co: %p\n", co) + //fmt.Printf("---co: %p\n", co) } // XXX, association happens here @@ -485,10 +491,10 @@ func (rlm *Realm) processNewCreatedMarks(store Store) { // } //} fmt.Println("---processNewCreatedMarks, oo.GetRefCount(): ", oo.GetRefCount()) - if oo.GetIsCrossRealm() { - fmt.Println("---should not attach value with type defined in other realm") - //panic("---!!!") - } + //if oo.GetIsCrossRealm() { + // fmt.Println("---should not attach value with type defined in other realm") + // //panic("---!!!") + //} if debug { if oo.GetIsDirty() { panic("new created mark cannot be dirty") diff --git a/gnovm/pkg/gnolang/values.go b/gnovm/pkg/gnolang/values.go index a98868fb956..34b79de13c1 100644 --- a/gnovm/pkg/gnolang/values.go +++ b/gnovm/pkg/gnolang/values.go @@ -291,9 +291,20 @@ func (pv PointerValue) Assign2(alloc *Allocator, store Store, rlm *Realm, tv2 Ty if rlm != nil && pv.Base != nil { oo1 := pv.TV.GetFirstObject(store) fmt.Println("---oo1: ", oo1) + if oo1 != nil { + fmt.Println("---oo1.GetObjectID: ", oo1.GetObjectID()) + } pv.TV.Assign(alloc, tv2, cu) - oo2 := pv.TV.GetFirstObject(store) + oo2, pkgId := pv.TV.GetFirstObject2(store) fmt.Println("---oo2: ", oo2) + //fmt.Println("---oo2 objectInfo: ", oo2.GetObjectInfo()) + fmt.Println("---oo2 pkgId: ", pkgId) + //if oo2 != nil { + // fmt.Println("---oo2.GetObjectID: ", oo2.GetObjectID()) + //} + if oo2 != nil { + oo2.SetLastNewEscapedRealm(pkgId) + } // TODO: assert attached here? rlm.DidUpdate(pv.Base.(Object), oo1, oo2) } else { diff --git a/gnovm/tests/files/zrealm_crossrealm20.gno b/gnovm/tests/files/zrealm_crossrealm20.gno new file mode 100644 index 00000000000..06c81304212 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm20.gno @@ -0,0 +1,16 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +type local struct{} + +var a local + +var b0 crossrealm.Bar // run declarations + +func main() { + print(".") +} From 9175b859e6facc83c32d22352f487ed56df36f1f Mon Sep 17 00:00:00 2001 From: ltzMaxwell Date: Sat, 9 Nov 2024 22:41:16 +0800 Subject: [PATCH 15/40] test --- gnovm/pkg/gnolang/machine.go | 27 ++++++----- gnovm/pkg/gnolang/op_assign.go | 2 + gnovm/pkg/gnolang/op_exec.go | 1 + gnovm/pkg/gnolang/ownership.go | 36 +++++++++------ gnovm/pkg/gnolang/realm.go | 54 +++++++++++++++++----- gnovm/pkg/gnolang/values.go | 4 +- gnovm/tests/files/zrealm_crossrealm20.gno | 3 ++ gnovm/tests/files/zrealm_crossrealm21.gno | 3 ++ gnovm/tests/files/zrealm_crossrealm21a.gno | 3 ++ gnovm/tests/files/zrealm_crossrealm22.gno | 3 ++ gnovm/tests/files/zrealm_crossrealm23.gno | 2 +- gnovm/tests/files/zrealm_crossrealm23a.gno | 3 ++ gnovm/tests/files/zrealm_crossrealm25.gno | 27 +++++++++++ 13 files changed, 127 insertions(+), 41 deletions(-) create mode 100644 gnovm/tests/files/zrealm_crossrealm25.gno diff --git a/gnovm/pkg/gnolang/machine.go b/gnovm/pkg/gnolang/machine.go index 0f5d705b7e1..276ddc94f5f 100644 --- a/gnovm/pkg/gnolang/machine.go +++ b/gnovm/pkg/gnolang/machine.go @@ -492,19 +492,22 @@ func (m *Machine) Stacktrace() (stacktrace Stacktrace) { } calls := make([]StacktraceCall, 0, len(m.Stmts)) - nextStmtIndex := len(m.Stmts) - 1 - for i := len(m.Frames) - 1; i >= 0; i-- { - if m.Frames[i].IsCall() { - stm := m.Stmts[nextStmtIndex] - bs := stm.(*bodyStmt) - stm = bs.Body[bs.NextBodyIndex-1] - calls = append(calls, StacktraceCall{ - Stmt: stm, - Frame: m.Frames[i], - }) + var nextStmtIndex int + if len(m.Stmts) > 0 { + nextStmtIndex = len(m.Stmts) - 1 + for i := len(m.Frames) - 1; i >= 0; i-- { + if m.Frames[i].IsCall() { + stm := m.Stmts[nextStmtIndex] + bs := stm.(*bodyStmt) + stm = bs.Body[bs.NextBodyIndex-1] + calls = append(calls, StacktraceCall{ + Stmt: stm, + Frame: m.Frames[i], + }) + } + // if the frame is a call, the next statement is the last statement of the frame. + nextStmtIndex = m.Frames[i].NumStmts - 1 } - // if the frame is a call, the next statement is the last statement of the frame. - nextStmtIndex = m.Frames[i].NumStmts - 1 } // if the stacktrace is too long, we trim it down to maxStacktraceSize diff --git a/gnovm/pkg/gnolang/op_assign.go b/gnovm/pkg/gnolang/op_assign.go index a10429367ae..5a65d9f1190 100644 --- a/gnovm/pkg/gnolang/op_assign.go +++ b/gnovm/pkg/gnolang/op_assign.go @@ -3,11 +3,13 @@ package gnolang import "fmt" func (m *Machine) doOpDefine() { + fmt.Println("---doOpDefine---") s := m.PopStmt().(*AssignStmt) // Define each value evaluated for Lhs. // NOTE: PopValues() returns a slice in // forward order, not the usual reverse. rvs := m.PopValues(len(s.Lhs)) + fmt.Println("---rvs: ", rvs) lb := m.LastBlock() for i := 0; i < len(s.Lhs); i++ { // Get name and value of i'th term. diff --git a/gnovm/pkg/gnolang/op_exec.go b/gnovm/pkg/gnolang/op_exec.go index a0f84f82e66..a17f0203e1c 100644 --- a/gnovm/pkg/gnolang/op_exec.go +++ b/gnovm/pkg/gnolang/op_exec.go @@ -432,6 +432,7 @@ EXEC_SWITCH: if debug { debug.Printf("EXEC: %v\n", s) } + fmt.Printf("EXEC: %v\n", s) switch cs := s.(type) { case *AssignStmt: switch cs.Op { diff --git a/gnovm/pkg/gnolang/ownership.go b/gnovm/pkg/gnolang/ownership.go index fa9955e9090..0f2bfed10dd 100644 --- a/gnovm/pkg/gnolang/ownership.go +++ b/gnovm/pkg/gnolang/ownership.go @@ -158,12 +158,13 @@ type ObjectInfo struct { // Note that "owner" is nil. func (oi *ObjectInfo) Copy() ObjectInfo { return ObjectInfo{ - ID: oi.ID, - Hash: oi.Hash.Copy(), - OwnerID: oi.OwnerID, - ModTime: oi.ModTime, - RefCount: oi.RefCount, - IsEscaped: oi.IsEscaped, + ID: oi.ID, + Hash: oi.Hash.Copy(), + OwnerID: oi.OwnerID, + ModTime: oi.ModTime, + RefCount: oi.RefCount, + IsEscaped: oi.IsEscaped, + lastNewRealEscapedRealm: oi.lastNewRealEscapedRealm, /* // XXX do the following need copying too? isDirty: oi.isDirty, @@ -321,6 +322,7 @@ func (oi *ObjectInfo) GetLastNewEscapedRealm() PkgID { } func (oi *ObjectInfo) SetLastNewEscapedRealm(pkgId PkgID) { + fmt.Println("---SetLastNewEscapedRealm") oi.lastNewRealEscapedRealm = pkgId } @@ -410,7 +412,9 @@ func (tv *TypedValue) GetFirstObject2(store Store) (Object, PkgID) { fmt.Println("---dt.PkgPath: ", dt.PkgPath) fmt.Println("---PkgID: ", PkgIDFromPkgPath(dt.PkgPath)) fmt.Println("---dt.Base: ", dt.Base) - pkgId = PkgIDFromPkgPath(dt.PkgPath) + if IsRealmPath(dt.PkgPath) { + pkgId = PkgIDFromPkgPath(dt.PkgPath) + } } switch cv := tv.V.(type) { case PointerValue: @@ -423,14 +427,16 @@ func (tv *TypedValue) GetFirstObject2(store Store) (Object, PkgID) { fmt.Println("---v.GetObjectID(): ", v.GetObjectID()) fmt.Println("---is Attached?", v.GetIsReal()) - if dt, ok := cv.TV.T.(*DeclaredType); ok { - fmt.Println("---dt: ", dt) - fmt.Println("---dt.Name: ", dt.Name) - fmt.Println("---dt.PkgPath: ", dt.PkgPath) - fmt.Println("---PkgID: ", PkgIDFromPkgPath(dt.PkgPath)) - fmt.Println("---dt.Base: ", dt.Base) - pkgId = PkgIDFromPkgPath(dt.PkgPath) - } + //if dt, ok := cv.TV.T.(*DeclaredType); ok { + // fmt.Println("---dt: ", dt) + // fmt.Println("---dt.Name: ", dt.Name) + // fmt.Println("---dt.PkgPath: ", dt.PkgPath) + // fmt.Println("---PkgID: ", PkgIDFromPkgPath(dt.PkgPath)) + // fmt.Println("---dt.Base: ", dt.Base) + // if IsRealmPath(dt.PkgPath) { + // pkgId = PkgIDFromPkgPath(dt.PkgPath) + // } + //} } return cv.GetBase(store), pkgId case *ArrayValue: diff --git a/gnovm/pkg/gnolang/realm.go b/gnovm/pkg/gnolang/realm.go index 136d831983b..4fe9f3052ef 100644 --- a/gnovm/pkg/gnolang/realm.go +++ b/gnovm/pkg/gnolang/realm.go @@ -138,15 +138,15 @@ func (rlm *Realm) DidUpdate(po, xo, co Object) { fmt.Println("---DidUpdate, rlm.ID: ", rlm.ID) fmt.Printf("---xo: %v, type of xo: %v\n", xo, reflect.TypeOf(xo)) fmt.Printf("---co: %v, type of co: %v\n", co, reflect.TypeOf(co)) - fmt.Printf("---po: %v, type of po: %v\n", po, reflect.TypeOf(po)) //fmt.Printf("---xo: %p\n", xo) if co != nil { - fmt.Println("co.LastNewEscapedRealm: ", co.GetLastNewEscapedRealm()) - if rlm.ID != co.GetLastNewEscapedRealm() { - panic("---cross realm!!!") - } + fmt.Println("---co.LastNewEscapedRealm: ", co.GetLastNewEscapedRealm()) + //if rlm.ID != co.GetLastNewEscapedRealm() { + // panic("---cross realm!!!") + //} } + fmt.Printf("---po: %v, type of po: %v\n", po, reflect.TypeOf(po)) //if co != nil && co.GetIsCrossRealm() { // panic("!!!cross realm") //} @@ -265,9 +265,9 @@ func (rlm *Realm) MarkNewEscapedCheckCrossRealm(oo Object) { if oi.GetIsReal() { lastRealmID := oi.GetObjectID().PkgID fmt.Println("lastRealmID: ", lastRealmID) - if lastRealmID != rlm.ID { - panic("should not happen, cross realm!!!") - } + //if lastRealmID != rlm.ID { + // panic("should not happen, cross realm!!!") + //} } if oi.lastNewRealEscapedRealm == rlm.ID { @@ -520,9 +520,18 @@ func (rlm *Realm) processNewCreatedMarks(store Store) { } } +func isEmptyRealmID(pkgId PkgID) bool { + if pkgId.String() == "RID0000000000000000000000000000000000000000" { + return true + } + return false +} + // oo must be marked new-real, and ref-count already incremented. func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { - fmt.Println("---incRefCreatedDescendants from oo: ", oo) + fmt.Println("---incRefCreatedDescendants from oo: \n", oo) + fmt.Printf("addr of oo %p: ", oo) + fmt.Println("---incRefCreatedDescendants oo.GetLastEscapedRealm: ", oo.GetLastNewEscapedRealm()) fmt.Println("---incRefCreatedDescendants, oo.GetObjectID: ", oo.GetObjectID()) if debug { if oo.GetIsDirty() { @@ -533,6 +542,19 @@ func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { } } + // make some pkgId logic while assign + _, ok1 := oo.(*PackageValue) + _, ok2 := oo.(*Block) + if !ok1 && !ok2 { + if !isEmptyRealmID(oo.GetLastNewEscapedRealm()) { // ! /p + if oo.GetLastNewEscapedRealm() != rlm.ID { + fmt.Println("---oo.GetLastNewEscapedRealm: ", oo.GetLastNewEscapedRealm()) + fmt.Println("---rlm.ID: ", rlm.ID) + panic("!!!cross realm while attach object") + } + } + } + // RECURSE GUARD // if id already set, skip. // this happens when a node marked created was already @@ -683,6 +705,14 @@ func (rlm *Realm) processNewEscapedMarks(store Store) { // because ref-count isn't >= 2. for i, eo := range rlm.newEscaped { fmt.Printf("---processNewEscapedMarks, [%d]eo: %v\n", i, eo) + fmt.Println("---eo.GetLastEscapedRealm: ", eo.GetLastNewEscapedRealm()) + fmt.Println("---rlm.ID: ", rlm.ID) + // only check object from another realm + if !isEmptyRealmID(eo.GetLastNewEscapedRealm()) { + if eo.GetLastNewEscapedRealm() != rlm.ID { + panic("!!!Cross realm update") + } + } fmt.Println("---processNewEscapedMarks, eo.GetObjectID: ", eo.GetRefCount()) if debug { if !eo.GetIsNewEscaped() { @@ -1014,10 +1044,10 @@ func getChildObjects(val Value, more []Value) []Value { more = getSelfOrChildObjects(cv.Base, more) return more case *StructValue: - //println("---struct value") + println("---struct value") for _, ctv := range cv.Fields { // TODO: we have type infos here, so check check cross realm logic - //fmt.Println("---ctv: ", ctv) + fmt.Println("---ctv: ", ctv) more = getSelfOrChildObjects(ctv.V, more) } return more @@ -1067,7 +1097,7 @@ func getChildObjects(val Value, more []Value) []Value { // like getChildObjects() but loads RefValues into objects. func getChildObjects2(store Store, val Value) []Object { - //fmt.Println("---getChildObjects2, val: ", val) + fmt.Println("---getChildObjects2, val: ", val) chos := getChildObjects(val, nil) //fmt.Println("---chos: ", chos) objs := make([]Object, 0, len(chos)) diff --git a/gnovm/pkg/gnolang/values.go b/gnovm/pkg/gnolang/values.go index 34b79de13c1..f9d76993793 100644 --- a/gnovm/pkg/gnolang/values.go +++ b/gnovm/pkg/gnolang/values.go @@ -303,6 +303,7 @@ func (pv PointerValue) Assign2(alloc *Allocator, store Store, rlm *Realm, tv2 Ty // fmt.Println("---oo2.GetObjectID: ", oo2.GetObjectID()) //} if oo2 != nil { + fmt.Printf("addr of oo2: %p \n", oo2) oo2.SetLastNewEscapedRealm(pkgId) } // TODO: assert attached here? @@ -539,7 +540,8 @@ func (sv *StructValue) Copy(alloc *Allocator) *StructValue { } nsv := alloc.NewStruct(fields) - //nsv.ObjectInfo = sv.ObjectInfo.Copy() + fmt.Println("---sv.ObjectInfo", sv.ObjectInfo) + nsv.ObjectInfo = sv.ObjectInfo.Copy() return nsv //return alloc.NewStruct(fields) } diff --git a/gnovm/tests/files/zrealm_crossrealm20.gno b/gnovm/tests/files/zrealm_crossrealm20.gno index 06c81304212..53dd1b9d8a8 100644 --- a/gnovm/tests/files/zrealm_crossrealm20.gno +++ b/gnovm/tests/files/zrealm_crossrealm20.gno @@ -14,3 +14,6 @@ var b0 crossrealm.Bar // run declarations func main() { print(".") } + +// Error: +// !!!cross realm while attach object diff --git a/gnovm/tests/files/zrealm_crossrealm21.gno b/gnovm/tests/files/zrealm_crossrealm21.gno index b065e31ee06..1933c54d8c2 100644 --- a/gnovm/tests/files/zrealm_crossrealm21.gno +++ b/gnovm/tests/files/zrealm_crossrealm21.gno @@ -18,3 +18,6 @@ func main() { // XXX, this should fail while trying to attach // value of type defined in another realm. // NOTE: the check can be in runtime or in preprocess(by simply checkin edge cases). + +// Error: +// !!!cross realm while attach object diff --git a/gnovm/tests/files/zrealm_crossrealm21a.gno b/gnovm/tests/files/zrealm_crossrealm21a.gno index 63e514b8f0f..bd9ae0186d0 100644 --- a/gnovm/tests/files/zrealm_crossrealm21a.gno +++ b/gnovm/tests/files/zrealm_crossrealm21a.gno @@ -21,3 +21,6 @@ func init() { func main() { print(".") } + +// Error: +// !!!cross realm while attach object diff --git a/gnovm/tests/files/zrealm_crossrealm22.gno b/gnovm/tests/files/zrealm_crossrealm22.gno index 02a612bea9a..708e190c7f7 100644 --- a/gnovm/tests/files/zrealm_crossrealm22.gno +++ b/gnovm/tests/files/zrealm_crossrealm22.gno @@ -16,3 +16,6 @@ func main() { } // XXX this works. attach value with type defined in same realm + +// Output: +// . diff --git a/gnovm/tests/files/zrealm_crossrealm23.gno b/gnovm/tests/files/zrealm_crossrealm23.gno index 554bd41ceb0..2f0e9e1d6f2 100644 --- a/gnovm/tests/files/zrealm_crossrealm23.gno +++ b/gnovm/tests/files/zrealm_crossrealm23.gno @@ -18,4 +18,4 @@ func main() { // XXX, this works attach value with type defined in p // Output: -//. +// . diff --git a/gnovm/tests/files/zrealm_crossrealm23a.gno b/gnovm/tests/files/zrealm_crossrealm23a.gno index b3f4f2ccd93..18a9d1c324a 100644 --- a/gnovm/tests/files/zrealm_crossrealm23a.gno +++ b/gnovm/tests/files/zrealm_crossrealm23a.gno @@ -17,3 +17,6 @@ func main() { // XXX, this works, attach reference with type defined in p // Attach pointer? + +// Output: +// . diff --git a/gnovm/tests/files/zrealm_crossrealm25.gno b/gnovm/tests/files/zrealm_crossrealm25.gno new file mode 100644 index 00000000000..f451100e94a --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm25.gno @@ -0,0 +1,27 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "std" + + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +type fooer struct{} + +func (fooer) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } + +var f fooer + +func init() { + f = fooer{} +} + +func main() { + + crossrealm.SetContainer(f) + print(".") +} + +// Error: +// !!!Cross realm update From c41caa3e50c6440086f375bb0127c0ee8eb90b02 Mon Sep 17 00:00:00 2001 From: ltzMaxwell Date: Tue, 12 Nov 2024 16:20:02 +0800 Subject: [PATCH 16/40] make test pass --- gnovm/pkg/gnolang/ownership.go | 47 ++--- gnovm/pkg/gnolang/realm.go | 204 +++++++++++---------- gnovm/pkg/gnolang/values.go | 9 +- gnovm/tests/files/zrealm_crossrealm20.gno | 6 +- gnovm/tests/files/zrealm_crossrealm21.gno | 12 +- gnovm/tests/files/zrealm_crossrealm21a.gno | 2 +- gnovm/tests/files/zrealm_crossrealm22.gno | 2 - gnovm/tests/files/zrealm_crossrealm23a.gno | 3 - gnovm/tests/files/zrealm_crossrealm24.gno | 8 + gnovm/tests/files/zrealm_crossrealm25.gno | 7 +- gnovm/tests/files/zrealm_crossrealm25a.gno | 6 +- gnovm/tests/files/zrealm_crossrealm25b.gno | 5 +- gnovm/tests/files/zrealm_crossrealm25c.gno | 8 +- gnovm/tests/files/zrealm_crossrealm25d.gno | 12 +- gnovm/tests/files/zrealm_crossrealm25e.gno | 32 ++++ gnovm/tests/files/zrealm_crossrealm26.gno | 24 --- gnovm/tests/files/zrealm_crossrealm26a.gno | 24 --- gnovm/tests/files/zrealm_crossrealm26b.gno | 21 --- gnovm/tests/files/zrealm_crossrealm26c.gno | 19 -- gnovm/tests/files/zrealm_crossrealm27.gno | 9 +- gnovm/tests/files/zrealm_crossrealm27a.gno | 13 +- 21 files changed, 212 insertions(+), 261 deletions(-) create mode 100644 gnovm/tests/files/zrealm_crossrealm25e.gno delete mode 100644 gnovm/tests/files/zrealm_crossrealm26.gno delete mode 100644 gnovm/tests/files/zrealm_crossrealm26a.gno delete mode 100644 gnovm/tests/files/zrealm_crossrealm26b.gno delete mode 100644 gnovm/tests/files/zrealm_crossrealm26c.gno diff --git a/gnovm/pkg/gnolang/ownership.go b/gnovm/pkg/gnolang/ownership.go index 0f2bfed10dd..e4a51596b39 100644 --- a/gnovm/pkg/gnolang/ownership.go +++ b/gnovm/pkg/gnolang/ownership.go @@ -149,7 +149,7 @@ type ObjectInfo struct { isCrossRealm bool isNewEscaped bool isNewDeleted bool - lastNewRealEscapedRealm PkgID // realm attached and escaped + lastNewRealEscapedRealm PkgID // XXX huh? owner Object // mem reference to owner. @@ -402,7 +402,7 @@ func (tv *TypedValue) GetFirstObject(store Store) Object { } // XXX, get first accessible object, maybe containing(parent) object, maybe itself. -func (tv *TypedValue) GetFirstObject2(store Store) (Object, PkgID) { +func (tv *TypedValue) GetFirstObject2(store Store) (Object, PkgID, bool) { fmt.Println("---GetFirstObject2---, tv: ", tv, reflect.TypeOf(tv.V)) fmt.Println("---tv.T, type of tv.T", tv.T, reflect.TypeOf(tv.T)) var pkgId PkgID @@ -427,46 +427,47 @@ func (tv *TypedValue) GetFirstObject2(store Store) (Object, PkgID) { fmt.Println("---v.GetObjectID(): ", v.GetObjectID()) fmt.Println("---is Attached?", v.GetIsReal()) - //if dt, ok := cv.TV.T.(*DeclaredType); ok { - // fmt.Println("---dt: ", dt) - // fmt.Println("---dt.Name: ", dt.Name) - // fmt.Println("---dt.PkgPath: ", dt.PkgPath) - // fmt.Println("---PkgID: ", PkgIDFromPkgPath(dt.PkgPath)) - // fmt.Println("---dt.Base: ", dt.Base) - // if IsRealmPath(dt.PkgPath) { - // pkgId = PkgIDFromPkgPath(dt.PkgPath) - // } - //} + if dt, ok := cv.TV.T.(*DeclaredType); ok { + // b0 = &crossrealm.Bar{A: 1} this is valid + // no need to check cross + // XXX, is it right? + if _, ok := cv.GetBase(store).(*HeapItemValue); !ok { + if IsRealmPath(dt.PkgPath) { + pkgId = PkgIDFromPkgPath(dt.PkgPath) + } + } + } } - return cv.GetBase(store), pkgId + return cv.GetBase(store), pkgId, true case *ArrayValue: - return cv, pkgId + return cv, pkgId, false case *SliceValue: - return cv.GetBase(store), pkgId + // TODO: XXX + return cv.GetBase(store), pkgId, false case *StructValue: println("---struct value") fmt.Println("---cv.GetObjectID(): ", cv.GetObjectID()) - return cv, pkgId + return cv, pkgId, false case *FuncValue: - return cv.GetClosure(store), pkgId + return cv.GetClosure(store), pkgId, false case *MapValue: - return cv, pkgId + return cv, pkgId, false case *BoundMethodValue: - return cv, pkgId + return cv, pkgId, false case *NativeValue: // XXX allow PointerValue.Assign2 to pass nil for oo1/oo2. // panic("realm logic for native values not supported") - return nil, pkgId + return nil, pkgId, false case *Block: - return cv, pkgId + return cv, pkgId, false case RefValue: oo := store.GetObject(cv.ObjectID) tv.V = oo - return oo, pkgId + return oo, pkgId, false case *HeapItemValue: // should only appear in PointerValue.Base panic("heap item value should only appear as a pointer's base") default: - return nil, pkgId + return nil, pkgId, false } } diff --git a/gnovm/pkg/gnolang/realm.go b/gnovm/pkg/gnolang/realm.go index 4fe9f3052ef..f9ce4fc84d3 100644 --- a/gnovm/pkg/gnolang/realm.go +++ b/gnovm/pkg/gnolang/realm.go @@ -138,35 +138,92 @@ func (rlm *Realm) DidUpdate(po, xo, co Object) { fmt.Println("---DidUpdate, rlm.ID: ", rlm.ID) fmt.Printf("---xo: %v, type of xo: %v\n", xo, reflect.TypeOf(xo)) fmt.Printf("---co: %v, type of co: %v\n", co, reflect.TypeOf(co)) - //fmt.Printf("---xo: %p\n", xo) + if co != nil { fmt.Println("---co.LastNewEscapedRealm: ", co.GetLastNewEscapedRealm()) - //if rlm.ID != co.GetLastNewEscapedRealm() { - // panic("---cross realm!!!") - //} + fmt.Println("---co.GetRefCount: ", co.GetRefCount()) + fmt.Println("---co isReal(attached): ", co.GetIsReal()) + fmt.Println("---co objectID: ", co.GetObjectID()) } fmt.Printf("---po: %v, type of po: %v\n", po, reflect.TypeOf(po)) - //if co != nil && co.GetIsCrossRealm() { - // panic("!!!cross realm") - //} + + if rlm == nil { + return + } + if debug { + if co != nil && co.GetIsDeleted() { + panic("cannot attach a deleted object") + } + if po != nil && po.GetIsTransient() { + panic("cannot attach to a transient object") + } + if po != nil && po.GetIsDeleted() { + panic("cannot attach to a deleted object") + } + } + + if po == nil || !po.GetIsReal() { // XXX, make sure po is attached + fmt.Println("---po(Base) not real, do nothing!!!") + return // do nothing. + } + + // XXX check if this boosts performance + // XXX with broad integration benchmarking. + // XXX if co == xo { + // XXX } + + // From here on, po is real (not new-real). + // Updates to .newCreated/.newEscaped /.newDeleted made here. (first gen) + // More appends happen during FinalizeRealmTransactions(). (second+ gen) + rlm.MarkDirty(po) if co != nil { + fmt.Println("---co.GetRefCount: ", co.GetRefCount()) + // XXX, inc ref count everytime assignment happens + co.IncRefCount() + fmt.Println("---after inc, co.GetRefCount: ", co.GetRefCount()) + if co.GetRefCount() > 1 { + if co.GetIsEscaped() { + // XXX, why packageBlock is automatically escaped? + println("---already escaped, should check cross realm?") + // already escaped + } else { + rlm.MarkNewEscapedCheckCrossRealm(co, false) + } + } else if co.GetIsReal() { + rlm.MarkDirty(co) + } else { + co.SetOwner(po) + rlm.MarkNewReal(co) // co will be attached when finalize + } + } + + if xo != nil { + xo.DecRefCount() + fmt.Printf("---xo: %v refCount after dec: %v\n", xo, xo.GetRefCount()) + if xo.GetRefCount() == 0 { + if xo.GetIsReal() { + rlm.MarkNewDeleted(xo) + } + } + } +} + +func (rlm *Realm) DidUpdate2(po, xo, co Object, reference bool) { + fmt.Println("---DidUpdate, rlm.ID: ", rlm.ID) + fmt.Printf("---xo: %v, type of xo: %v\n", xo, reflect.TypeOf(xo)) + fmt.Printf("---co: %v, type of co: %v\n", co, reflect.TypeOf(co)) + + if co != nil { + fmt.Println("---co.LastNewEscapedRealm: ", co.GetLastNewEscapedRealm()) + fmt.Println("---co.GetRefCount: ", co.GetRefCount()) fmt.Println("---co isReal(attached): ", co.GetIsReal()) fmt.Println("---co objectID: ", co.GetObjectID()) - fmt.Println("---co.GetObjectInfo:", co.GetObjectInfo()) - //fmt.Printf("---co: %p\n", co) } - // XXX, association happens here - // if is co is attached to external realm - // if xo is attached to realm, directly/indirectly; - // if associated with reference, ok - // else, panic("should not associate with value cross realm - // else if xo is not attached to realm, associate is ok too, check when finalize. - // else, panic when finalizing current realm. + fmt.Printf("---po: %v, type of po: %v\n", po, reflect.TypeOf(po)) - fmt.Println("---current realm: ", rlm) if rlm == nil { return } @@ -182,26 +239,11 @@ func (rlm *Realm) DidUpdate(po, xo, co Object) { } } - // check if assignee is attached, if yes and assigner is not attached, panic - if xo != nil { - fmt.Println("---xo.GetIsReal: ", xo.GetIsReal()) - } else { - println("---xo is nil") - } - fmt.Println("---po.GetIsReal: ", po.GetIsReal()) - if po == nil || !po.GetIsReal() { // XXX, make sure po is attached fmt.Println("---po(Base) not real, do nothing!!!") return // do nothing. } - // XXX, cross realm check - fmt.Println("---po.GetObjectID(): ", po.GetObjectID()) - if po.GetObjectID().PkgID != rlm.ID { - fmt.Printf("po.GetObjectID().PkgID: %v, rlm.ID: %v\n", po.GetObjectID().PkgID, rlm.ID) - panic("cannot modify external-realm or non-realm object") - } - // XXX check if this boosts performance // XXX with broad integration benchmarking. // XXX if co == xo { @@ -213,29 +255,24 @@ func (rlm *Realm) DidUpdate(po, xo, co Object) { rlm.MarkDirty(po) if co != nil { - fmt.Println("---co: ", co) fmt.Println("---co.GetRefCount: ", co.GetRefCount()) // XXX, inc ref count everytime assignment happens co.IncRefCount() fmt.Println("---after inc, co.GetRefCount: ", co.GetRefCount()) - if co.GetRefCount() > 1 { // XXX, associated more the once? how this happens? + if co.GetRefCount() > 1 { if co.GetIsEscaped() { + // XXX, why packageBlock is automatically escaped? println("---already escaped, should check cross realm?") // already escaped } else { - rlm.MarkNewEscapedCheckCrossRealm(co) // XXX, track which realm escape from - //rlm.MarkNewEscaped(co) + rlm.MarkNewEscapedCheckCrossRealm(co, reference) } - } else if co.GetIsReal() { // XXX, attached in .init? - println("---co is real") + } else if co.GetIsReal() { rlm.MarkDirty(co) } else { - println("---else") co.SetOwner(po) rlm.MarkNewReal(co) // co will be attached when finalize } - } else { - println("---co is nil, do nothing") } if xo != nil { @@ -246,54 +283,39 @@ func (rlm *Realm) DidUpdate(po, xo, co Object) { rlm.MarkNewDeleted(xo) } } - } else { - println("---xo is nil, do nothing") } } //---------------------------------------- // mark* -func (rlm *Realm) MarkNewEscapedCheckCrossRealm(oo Object) { +func (rlm *Realm) MarkNewEscapedCheckCrossRealm(oo Object, reference bool) { fmt.Println("---MarkNewEscapedCheckCrossRealm---, oo: ", oo) - oi := oo.GetObjectInfo() - fmt.Println("----oi: ", oi) - fmt.Println("----oi: ", oi) - fmt.Println("----oi.lastNewRealEscapedRealm: ", oi.lastNewRealEscapedRealm) - fmt.Println("----rlm.ID: ", rlm.ID) - fmt.Println("oi.GetIsReal: ", oi.GetIsReal()) - if oi.GetIsReal() { - lastRealmID := oi.GetObjectID().PkgID - fmt.Println("lastRealmID: ", lastRealmID) - //if lastRealmID != rlm.ID { - // panic("should not happen, cross realm!!!") - //} - } + fmt.Println("---rlm.ID: ", rlm.ID) + + fmt.Println("---oo.GetRefCount(): ", oo.GetRefCount()) + fmt.Println("---oo.lastNewRealEscapedRealm: ", oo.GetLastNewEscapedRealm()) + fmt.Println("---oo.GetIsReal: ", oo.GetIsReal()) - if oi.lastNewRealEscapedRealm == rlm.ID { - // already processed for this realm, - // see below. + if oo.GetLastNewEscapedRealm() == rlm.ID { return } - if !oi.GetIsReal() { // XXX, this seems to be wrong -- an object escapes to other realm before it's attached(no objectID) - fmt.Println("---oi Not real, oi: ", oi.ID) - // this can happen if a ref +1 - // new object gets passed into - // an external realm function. - oi.lastNewRealEscapedRealm = rlm.ID // XXX, where the object escape from. - oi.SetIsNewReal(false) - rlm.MarkNewReal(oo) - } else { - fmt.Println("---oo is real, oi:", oi.ID) - // TODO: set last escape realm? - println("---set last escape realm?") + + if oo.GetLastNewEscapedRealm() != rlm.ID { // crossing realm + if reference { + if !oo.GetIsReal() { // oo is not attached in the origin realm + panic("should not happen while attempting to attach unattached object by reference from external realm") + } + } else { + panic("should not happen while attempting to attach objects by value from external realm") + } } + rlm.MarkNewEscaped(oo) } func (rlm *Realm) MarkNewReal(oo Object) { fmt.Println("---markNewReal---, oo: ", oo) - fmt.Println("---markNewReal---, type of oo: ", reflect.TypeOf(oo)) if debug { if pv, ok := oo.(*PackageValue); ok { // packages should have no owner. @@ -520,18 +542,12 @@ func (rlm *Realm) processNewCreatedMarks(store Store) { } } -func isEmptyRealmID(pkgId PkgID) bool { - if pkgId.String() == "RID0000000000000000000000000000000000000000" { - return true - } - return false -} - // oo must be marked new-real, and ref-count already incremented. func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { - fmt.Println("---incRefCreatedDescendants from oo: \n", oo) - fmt.Printf("addr of oo %p: ", oo) + fmt.Println("---incRefCreatedDescendants, rlm.ID: ", rlm.ID) fmt.Println("---incRefCreatedDescendants oo.GetLastEscapedRealm: ", oo.GetLastNewEscapedRealm()) + + fmt.Println("---incRefCreatedDescendants from oo: ", oo) fmt.Println("---incRefCreatedDescendants, oo.GetObjectID: ", oo.GetObjectID()) if debug { if oo.GetIsDirty() { @@ -544,13 +560,12 @@ func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { // make some pkgId logic while assign _, ok1 := oo.(*PackageValue) - _, ok2 := oo.(*Block) - if !ok1 && !ok2 { - if !isEmptyRealmID(oo.GetLastNewEscapedRealm()) { // ! /p + if !ok1 { + if !oo.GetLastNewEscapedRealm().IsZero() { if oo.GetLastNewEscapedRealm() != rlm.ID { fmt.Println("---oo.GetLastNewEscapedRealm: ", oo.GetLastNewEscapedRealm()) fmt.Println("---rlm.ID: ", rlm.ID) - panic("!!!cross realm while attach object") + panic("should not happen while attempting to attach new real object from external realm") } } } @@ -569,7 +584,7 @@ func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { // recurse for children. more := getChildObjects2(store, oo) //fmt.Println("---incRefCreatedDescendants, more: ", more) - fmt.Println("---len of more: ", len(more)) + fmt.Println("---len of more: ", len(more)) for i, child := range more { fmt.Printf("---[%d]child: %v, type of child: %v \n", i, child, reflect.TypeOf(child)) //fmt.Printf("---child addr: %p\n", child) @@ -706,13 +721,16 @@ func (rlm *Realm) processNewEscapedMarks(store Store) { for i, eo := range rlm.newEscaped { fmt.Printf("---processNewEscapedMarks, [%d]eo: %v\n", i, eo) fmt.Println("---eo.GetLastEscapedRealm: ", eo.GetLastNewEscapedRealm()) + fmt.Println("---eo.GetRefCount(): ", eo.GetRefCount()) fmt.Println("---rlm.ID: ", rlm.ID) - // only check object from another realm - if !isEmptyRealmID(eo.GetLastNewEscapedRealm()) { - if eo.GetLastNewEscapedRealm() != rlm.ID { - panic("!!!Cross realm update") - } - } + //// only check object from another realm + //if !eo.GetLastNewEscapedRealm().IsZero() { + // if eo.GetLastNewEscapedRealm() != rlm.ID { + // //if !eo.GetIsReal() { + // panic("!!!Cross realm update") + // //} + // } + //} fmt.Println("---processNewEscapedMarks, eo.GetObjectID: ", eo.GetRefCount()) if debug { if !eo.GetIsNewEscaped() { diff --git a/gnovm/pkg/gnolang/values.go b/gnovm/pkg/gnolang/values.go index f9d76993793..661cf39fb24 100644 --- a/gnovm/pkg/gnolang/values.go +++ b/gnovm/pkg/gnolang/values.go @@ -295,19 +295,14 @@ func (pv PointerValue) Assign2(alloc *Allocator, store Store, rlm *Realm, tv2 Ty fmt.Println("---oo1.GetObjectID: ", oo1.GetObjectID()) } pv.TV.Assign(alloc, tv2, cu) - oo2, pkgId := pv.TV.GetFirstObject2(store) + oo2, pkgId, reference := pv.TV.GetFirstObject2(store) fmt.Println("---oo2: ", oo2) - //fmt.Println("---oo2 objectInfo: ", oo2.GetObjectInfo()) fmt.Println("---oo2 pkgId: ", pkgId) - //if oo2 != nil { - // fmt.Println("---oo2.GetObjectID: ", oo2.GetObjectID()) - //} if oo2 != nil { - fmt.Printf("addr of oo2: %p \n", oo2) oo2.SetLastNewEscapedRealm(pkgId) } // TODO: assert attached here? - rlm.DidUpdate(pv.Base.(Object), oo1, oo2) + rlm.DidUpdate2(pv.Base.(Object), oo1, oo2, reference) } else { pv.TV.Assign(alloc, tv2, cu) } diff --git a/gnovm/tests/files/zrealm_crossrealm20.gno b/gnovm/tests/files/zrealm_crossrealm20.gno index 53dd1b9d8a8..f03e3b3af66 100644 --- a/gnovm/tests/files/zrealm_crossrealm20.gno +++ b/gnovm/tests/files/zrealm_crossrealm20.gno @@ -5,10 +5,6 @@ import ( crossrealm "gno.land/r/demo/tests/crossrealm" ) -type local struct{} - -var a local - var b0 crossrealm.Bar // run declarations func main() { @@ -16,4 +12,4 @@ func main() { } // Error: -// !!!cross realm while attach object +// should not happen while attempting to attach new real object from external realm diff --git a/gnovm/tests/files/zrealm_crossrealm21.gno b/gnovm/tests/files/zrealm_crossrealm21.gno index 1933c54d8c2..ae8b58a44f6 100644 --- a/gnovm/tests/files/zrealm_crossrealm21.gno +++ b/gnovm/tests/files/zrealm_crossrealm21.gno @@ -5,19 +5,13 @@ import ( crossrealm "gno.land/r/demo/tests/crossrealm" ) -var b0 crossrealm.Bar // run declarations - func init() { - b0 = crossrealm.Bar{A: 1} + b0 := crossrealm.Bar{A: 1} } func main() { print(".") } -// XXX, this should fail while trying to attach -// value of type defined in another realm. -// NOTE: the check can be in runtime or in preprocess(by simply checkin edge cases). - -// Error: -// !!!cross realm while attach object +// Output: +// . diff --git a/gnovm/tests/files/zrealm_crossrealm21a.gno b/gnovm/tests/files/zrealm_crossrealm21a.gno index bd9ae0186d0..a50a6614920 100644 --- a/gnovm/tests/files/zrealm_crossrealm21a.gno +++ b/gnovm/tests/files/zrealm_crossrealm21a.gno @@ -23,4 +23,4 @@ func main() { } // Error: -// !!!cross realm while attach object +// should not happen while attempting to attach new real object from external realm diff --git a/gnovm/tests/files/zrealm_crossrealm22.gno b/gnovm/tests/files/zrealm_crossrealm22.gno index 708e190c7f7..e45db3510e0 100644 --- a/gnovm/tests/files/zrealm_crossrealm22.gno +++ b/gnovm/tests/files/zrealm_crossrealm22.gno @@ -15,7 +15,5 @@ func main() { print(".") } -// XXX this works. attach value with type defined in same realm - // Output: // . diff --git a/gnovm/tests/files/zrealm_crossrealm23a.gno b/gnovm/tests/files/zrealm_crossrealm23a.gno index 18a9d1c324a..10a2006a98b 100644 --- a/gnovm/tests/files/zrealm_crossrealm23a.gno +++ b/gnovm/tests/files/zrealm_crossrealm23a.gno @@ -15,8 +15,5 @@ func main() { print(".") } -// XXX, this works, attach reference with type defined in p -// Attach pointer? - // Output: // . diff --git a/gnovm/tests/files/zrealm_crossrealm24.gno b/gnovm/tests/files/zrealm_crossrealm24.gno index a7697ffd980..2f370d55b18 100644 --- a/gnovm/tests/files/zrealm_crossrealm24.gno +++ b/gnovm/tests/files/zrealm_crossrealm24.gno @@ -5,6 +5,14 @@ import ( crossrealm "gno.land/r/demo/tests/crossrealm" ) +// XXX, this equals to: +// +// type LocalBar *crossrealm.Bar +// var b0 LocalBar +// +// both should be valid +// TODO: expand this + var b0 *crossrealm.Bar func init() { diff --git a/gnovm/tests/files/zrealm_crossrealm25.gno b/gnovm/tests/files/zrealm_crossrealm25.gno index f451100e94a..68da79914b6 100644 --- a/gnovm/tests/files/zrealm_crossrealm25.gno +++ b/gnovm/tests/files/zrealm_crossrealm25.gno @@ -7,21 +7,20 @@ import ( crossrealm "gno.land/r/demo/tests/crossrealm" ) -type fooer struct{} +type fooer struct{ name string } func (fooer) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } var f fooer func init() { - f = fooer{} + f = fooer{name: "local fooer"} } func main() { - crossrealm.SetContainer(f) print(".") } // Error: -// !!!Cross realm update +// should not happen while attempting to attach objects by value from external realm diff --git a/gnovm/tests/files/zrealm_crossrealm25a.gno b/gnovm/tests/files/zrealm_crossrealm25a.gno index ba2b51e1fe8..6b8a25e6dd3 100644 --- a/gnovm/tests/files/zrealm_crossrealm25a.gno +++ b/gnovm/tests/files/zrealm_crossrealm25a.gno @@ -18,11 +18,9 @@ func init() { } func main() { - crossrealm.SetContainer(&f) print(".") } -// this should work. -// XXX, this associate a pointer to a floating object(not attached) -// to external realm, no attachment happens to the external realm. +// Output: +// . diff --git a/gnovm/tests/files/zrealm_crossrealm25b.gno b/gnovm/tests/files/zrealm_crossrealm25b.gno index ac2e2dce401..112b4fe599f 100644 --- a/gnovm/tests/files/zrealm_crossrealm25b.gno +++ b/gnovm/tests/files/zrealm_crossrealm25b.gno @@ -21,13 +21,14 @@ type localContainer struct { var lc localContainer func init() { + // container attached, embedded object attached lc = localContainer{name: "local_container", f: fooer{name: "local_fooer"}} // attach } func main() { - crossrealm.AttachContainer() // this attaches container first crossrealm.SetContainer(&lc.f) print(".") } -// XXX? +// Output: +// . diff --git a/gnovm/tests/files/zrealm_crossrealm25c.gno b/gnovm/tests/files/zrealm_crossrealm25c.gno index 9a1d0e9cb1b..74599ba2106 100644 --- a/gnovm/tests/files/zrealm_crossrealm25c.gno +++ b/gnovm/tests/files/zrealm_crossrealm25c.gno @@ -1,8 +1,6 @@ // PKGPATH: gno.land/r/crossrealm_test package crossrealm_test -// pass pointer to an embedded object to external realm? - import ( "std" @@ -27,7 +25,9 @@ func init() { } func main() { - crossrealm.AttachContainer() - crossrealm.SetContainer(lc.f) // should work + crossrealm.SetContainer(lc.f) print(".") } + +// Error: +// should not happen while attempting to attach objects by value from external realm diff --git a/gnovm/tests/files/zrealm_crossrealm25d.gno b/gnovm/tests/files/zrealm_crossrealm25d.gno index 7558c658b46..9d8af7decc1 100644 --- a/gnovm/tests/files/zrealm_crossrealm25d.gno +++ b/gnovm/tests/files/zrealm_crossrealm25d.gno @@ -1,8 +1,6 @@ // PKGPATH: gno.land/r/crossrealm_test package crossrealm_test -// pass pointer to an embedded object to external realm? - import ( "std" @@ -15,8 +13,6 @@ type fooer struct { func (fooer) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } -var f fooer - type localContainer struct { name string ff fooer @@ -25,12 +21,14 @@ type localContainer struct { var lc localContainer func init() { - f = fooer{name: "local_fooer_global"} + f := fooer{name: "local_fooer_global"} lc = localContainer{name: "local_container", ff: f} // attach } func main() { - crossrealm.AttachContainer() - crossrealm.SetContainer(lc.ff) // this should not panic, lc.ff is not same with f(gloabl) + crossrealm.SetContainer(lc.ff) print(".") } + +// Error: +// should not happen while attempting to attach objects by value from external realm diff --git a/gnovm/tests/files/zrealm_crossrealm25e.gno b/gnovm/tests/files/zrealm_crossrealm25e.gno new file mode 100644 index 00000000000..439839e8aa9 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm25e.gno @@ -0,0 +1,32 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "std" + + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +type fooer struct { + name string +} + +func (fooer) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } + +type localContainer struct { + name string + f fooer +} + +var lc localContainer +var ff fooer + +func main() { + ff = fooer{name: "local_fooer"} // ref 1, unreal + lc = localContainer{name: "local_container", f: ff} + crossrealm.SetContainer(lc.f) + print(".") +} + +// Error: +// should not happen while attempting to attach objects by value from external realm diff --git a/gnovm/tests/files/zrealm_crossrealm26.gno b/gnovm/tests/files/zrealm_crossrealm26.gno deleted file mode 100644 index 5148cc0fefa..00000000000 --- a/gnovm/tests/files/zrealm_crossrealm26.gno +++ /dev/null @@ -1,24 +0,0 @@ -// PKGPATH: gno.land/r/crossrealm_test -package crossrealm_test - -import ( - "std" - - crossrealm "gno.land/r/demo/tests/crossrealm" -) - -type fooer struct{ name string } - -func (fooer) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } - -var f fooer - -func init() { - f = fooer{name: "local_fooer"} -} - -func main() { - crossrealm.AttachContainer() - crossrealm.SetContainer(f) - print(".") -} diff --git a/gnovm/tests/files/zrealm_crossrealm26a.gno b/gnovm/tests/files/zrealm_crossrealm26a.gno deleted file mode 100644 index 76f3bc4c93b..00000000000 --- a/gnovm/tests/files/zrealm_crossrealm26a.gno +++ /dev/null @@ -1,24 +0,0 @@ -// PKGPATH: gno.land/r/crossrealm_test -package crossrealm_test - -import ( - "std" - - crossrealm "gno.land/r/demo/tests/crossrealm" -) - -type fooer struct{ name string } - -func (fooer) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } - -var f fooer - -func init() { - f = fooer{name: "local_fooer"} // NOTE, from now on f is attached -} - -func main() { - crossrealm.AttachContainer() // this attaches container first - crossrealm.SetContainer(&f) - print(".") -} diff --git a/gnovm/tests/files/zrealm_crossrealm26b.gno b/gnovm/tests/files/zrealm_crossrealm26b.gno deleted file mode 100644 index d2e2c33864b..00000000000 --- a/gnovm/tests/files/zrealm_crossrealm26b.gno +++ /dev/null @@ -1,21 +0,0 @@ -// PKGPATH: gno.land/r/crossrealm_test -package crossrealm_test - -import ( - "std" - - crossrealm "gno.land/r/demo/tests/crossrealm" -) - -type fooer struct{ name string } - -func (fooer) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } - -var f fooer // this is NOT attached - -func main() { - crossrealm.AttachContainer() // this attaches container first - f = fooer{name: "local_fooer"} // XXX, still not attached, panic - crossrealm.SetContainer(&f) - print(".") -} diff --git a/gnovm/tests/files/zrealm_crossrealm26c.gno b/gnovm/tests/files/zrealm_crossrealm26c.gno deleted file mode 100644 index 35885aa0cd4..00000000000 --- a/gnovm/tests/files/zrealm_crossrealm26c.gno +++ /dev/null @@ -1,19 +0,0 @@ -// PKGPATH: gno.land/r/crossrealm_test -package crossrealm_test - -import ( - "std" - - crossrealm "gno.land/r/demo/tests/crossrealm" -) - -type fooer struct{ name string } - -func (fooer) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } - -func main() { - crossrealm.AttachContainer() // this attaches container first - var f fooer = fooer{name: "local_fooer"} // this is not attached, should panic, even not escape - crossrealm.SetContainer(&f) - print(".") -} diff --git a/gnovm/tests/files/zrealm_crossrealm27.gno b/gnovm/tests/files/zrealm_crossrealm27.gno index 32f8dd834f8..9889cc194c7 100644 --- a/gnovm/tests/files/zrealm_crossrealm27.gno +++ b/gnovm/tests/files/zrealm_crossrealm27.gno @@ -15,10 +15,11 @@ func (fooer) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } var f fooer -// XXX, this should work when reference to not attached local object -// associated to external realm *NOT* attached object. func main() { - f = fooer{name: "local_fooer"} // this is not attached - crossrealm.SetContainer2(&f) // XXX, here should work to associate *NOT* attached object to external container + f = fooer{name: "local_fooer"} + crossrealm.SetContainer2(&f) print(".") } + +// Output: +// . diff --git a/gnovm/tests/files/zrealm_crossrealm27a.gno b/gnovm/tests/files/zrealm_crossrealm27a.gno index 47ac14ecb04..8eb4d4686a1 100644 --- a/gnovm/tests/files/zrealm_crossrealm27a.gno +++ b/gnovm/tests/files/zrealm_crossrealm27a.gno @@ -7,14 +7,17 @@ import ( crossrealm "gno.land/r/demo/tests/crossrealm" ) -type fooer struct{ name string } +type fooer struct { + name string +} func (fooer) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } -var f fooer - func main() { - f = fooer{name: "local_fooer"} - crossrealm.SetContainer3(&f) + f := fooer{name: "local_fooer"} // f is "new real" cuz it's parent object is new real + crossrealm.SetContainer2(&f) // attach new real from external realm, panic print(".") } + +// Error: +// should not happen while attempting to attach new real object from external realm From 48eb8b97eccde72fcb202dd5c0e3d578ba16bb4f Mon Sep 17 00:00:00 2001 From: ltzMaxwell Date: Tue, 12 Nov 2024 22:51:36 +0800 Subject: [PATCH 17/40] fixup --- gnovm/pkg/gnolang/ownership.go | 10 ++++++++- gnovm/pkg/gnolang/realm.go | 8 +++---- gnovm/pkg/gnolang/values.go | 16 +++++++------- gnovm/tests/files/zrealm_crossrealm29.gno | 25 ++++++++++++++++++++++ gnovm/tests/files/zrealm_crossrealm29a.gno | 21 ++++++++++++++++++ 5 files changed, 67 insertions(+), 13 deletions(-) create mode 100644 gnovm/tests/files/zrealm_crossrealm29.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm29a.gno diff --git a/gnovm/pkg/gnolang/ownership.go b/gnovm/pkg/gnolang/ownership.go index e4a51596b39..9dc3515e1d1 100644 --- a/gnovm/pkg/gnolang/ownership.go +++ b/gnovm/pkg/gnolang/ownership.go @@ -449,7 +449,15 @@ func (tv *TypedValue) GetFirstObject2(store Store) (Object, PkgID, bool) { fmt.Println("---cv.GetObjectID(): ", cv.GetObjectID()) return cv, pkgId, false case *FuncValue: - return cv.GetClosure(store), pkgId, false + fmt.Println("---FuncValue") + clo := cv.GetClosure(store) + fmt.Println("---clo: ", clo) + fmt.Println("clo...PkgPath", clo.Source.GetLocation().PkgPath) + //if clo.GetObjectID().PkgID.IsZero() { + // p := clo.Source.GetParentNode(store) + // fmt.Println("---p: ", p) + //} + return cv.GetClosure(store), PkgIDFromPkgPath(clo.Source.GetLocation().PkgPath), false case *MapValue: return cv, pkgId, false case *BoundMethodValue: diff --git a/gnovm/pkg/gnolang/realm.go b/gnovm/pkg/gnolang/realm.go index f9ce4fc84d3..8eac3781547 100644 --- a/gnovm/pkg/gnolang/realm.go +++ b/gnovm/pkg/gnolang/realm.go @@ -210,7 +210,7 @@ func (rlm *Realm) DidUpdate(po, xo, co Object) { } } -func (rlm *Realm) DidUpdate2(po, xo, co Object, reference bool) { +func (rlm *Realm) DidUpdate2(po, xo, co Object, isRef bool) { fmt.Println("---DidUpdate, rlm.ID: ", rlm.ID) fmt.Printf("---xo: %v, type of xo: %v\n", xo, reflect.TypeOf(xo)) fmt.Printf("---co: %v, type of co: %v\n", co, reflect.TypeOf(co)) @@ -265,7 +265,7 @@ func (rlm *Realm) DidUpdate2(po, xo, co Object, reference bool) { println("---already escaped, should check cross realm?") // already escaped } else { - rlm.MarkNewEscapedCheckCrossRealm(co, reference) + rlm.MarkNewEscapedCheckCrossRealm(co, isRef) } } else if co.GetIsReal() { rlm.MarkDirty(co) @@ -289,7 +289,7 @@ func (rlm *Realm) DidUpdate2(po, xo, co Object, reference bool) { //---------------------------------------- // mark* -func (rlm *Realm) MarkNewEscapedCheckCrossRealm(oo Object, reference bool) { +func (rlm *Realm) MarkNewEscapedCheckCrossRealm(oo Object, isRef bool) { fmt.Println("---MarkNewEscapedCheckCrossRealm---, oo: ", oo) fmt.Println("---rlm.ID: ", rlm.ID) @@ -302,7 +302,7 @@ func (rlm *Realm) MarkNewEscapedCheckCrossRealm(oo Object, reference bool) { } if oo.GetLastNewEscapedRealm() != rlm.ID { // crossing realm - if reference { + if isRef { if !oo.GetIsReal() { // oo is not attached in the origin realm panic("should not happen while attempting to attach unattached object by reference from external realm") } diff --git a/gnovm/pkg/gnolang/values.go b/gnovm/pkg/gnolang/values.go index 661cf39fb24..dbd680860ba 100644 --- a/gnovm/pkg/gnolang/values.go +++ b/gnovm/pkg/gnolang/values.go @@ -291,18 +291,14 @@ func (pv PointerValue) Assign2(alloc *Allocator, store Store, rlm *Realm, tv2 Ty if rlm != nil && pv.Base != nil { oo1 := pv.TV.GetFirstObject(store) fmt.Println("---oo1: ", oo1) - if oo1 != nil { - fmt.Println("---oo1.GetObjectID: ", oo1.GetObjectID()) - } pv.TV.Assign(alloc, tv2, cu) - oo2, pkgId, reference := pv.TV.GetFirstObject2(store) + oo2, pkgId, isRef := pv.TV.GetFirstObject2(store) fmt.Println("---oo2: ", oo2) fmt.Println("---oo2 pkgId: ", pkgId) if oo2 != nil { - oo2.SetLastNewEscapedRealm(pkgId) + oo2.SetLastNewEscapedRealm(pkgId) // attach origin package info } - // TODO: assert attached here? - rlm.DidUpdate2(pv.Base.(Object), oo1, oo2, reference) + rlm.DidUpdate2(pv.Base.(Object), oo1, oo2, isRef) } else { pv.TV.Assign(alloc, tv2, cu) } @@ -1046,6 +1042,7 @@ func (tv *TypedValue) ClearNum() { } func (tv TypedValue) Copy(alloc *Allocator) (cp TypedValue) { + fmt.Println("---Copy, type of tv.V: ", reflect.TypeOf(tv.V)) switch cv := tv.V.(type) { case BigintValue: cp.T = tv.T @@ -1060,6 +1057,7 @@ func (tv TypedValue) Copy(alloc *Allocator) (cp TypedValue) { cp.T = tv.T cp.V = cv.Copy(alloc) default: + println("---default") cp = tv } return @@ -1698,6 +1696,8 @@ func (tv *TypedValue) ComputeMapKey(store Store, omitType bool) MapKey { // cu: convert untyped after assignment. pass false // for const definitions, but true for all else. func (tv *TypedValue) Assign(alloc *Allocator, tv2 TypedValue, cu bool) { + fmt.Println("---Assign, tv: ", tv) + fmt.Println("---Assign, tv2: ", tv2, reflect.TypeOf(tv2)) if debug { if tv.T == DataByteType { // assignment to data byte types should only @@ -1710,7 +1710,7 @@ func (tv *TypedValue) Assign(alloc *Allocator, tv2 TypedValue, cu bool) { panic("should not happen") } } - *tv = tv2.Copy(alloc) // TODO: why copy? + *tv = tv2.Copy(alloc) if cu && isUntyped(tv.T) { ConvertUntypedTo(tv, defaultTypeOf(tv.T)) } diff --git a/gnovm/tests/files/zrealm_crossrealm29.gno b/gnovm/tests/files/zrealm_crossrealm29.gno new file mode 100644 index 00000000000..b2c7ede7d32 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm29.gno @@ -0,0 +1,25 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "std" + + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +//var f1 = func() bool { +// println("callback") +// return true +//} + +func main() { + f := func() bool { + println("callback") + return true + } + crossrealm.SetCallback(f) + crossrealm.ExecuteCallback() +} + +// Error: +// should not happen while attempting to attach new real object from external realm diff --git a/gnovm/tests/files/zrealm_crossrealm29a.gno b/gnovm/tests/files/zrealm_crossrealm29a.gno new file mode 100644 index 00000000000..6688e9dd933 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm29a.gno @@ -0,0 +1,21 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "std" + + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +var f = func() bool { + println("callback") + return true +} + +func main() { + crossrealm.SetCallback(f) + crossrealm.ExecuteCallback() +} + +// Output: +// callback From 0bef9078ad3c03a235c2a253675a900c328df429 Mon Sep 17 00:00:00 2001 From: ltzMaxwell Date: Tue, 12 Nov 2024 23:13:58 +0800 Subject: [PATCH 18/40] fixup --- gnovm/pkg/gnolang/ownership.go | 4 ---- gnovm/pkg/gnolang/realm.go | 13 ++++--------- .../files/zrealm_crossrealm0_stdlibs.gno | 4 ++-- .../files/zrealm_crossrealm1_stdlibs.gno | 4 ++-- gnovm/tests/files/zrealm_crossrealm29.gno | 5 ----- gnovm/tests/files/zrealm_crossrealm29b.gno | 19 +++++++++++++++++++ 6 files changed, 27 insertions(+), 22 deletions(-) create mode 100644 gnovm/tests/files/zrealm_crossrealm29b.gno diff --git a/gnovm/pkg/gnolang/ownership.go b/gnovm/pkg/gnolang/ownership.go index 9dc3515e1d1..5a89556429f 100644 --- a/gnovm/pkg/gnolang/ownership.go +++ b/gnovm/pkg/gnolang/ownership.go @@ -453,10 +453,6 @@ func (tv *TypedValue) GetFirstObject2(store Store) (Object, PkgID, bool) { clo := cv.GetClosure(store) fmt.Println("---clo: ", clo) fmt.Println("clo...PkgPath", clo.Source.GetLocation().PkgPath) - //if clo.GetObjectID().PkgID.IsZero() { - // p := clo.Source.GetParentNode(store) - // fmt.Println("---p: ", p) - //} return cv.GetClosure(store), PkgIDFromPkgPath(clo.Source.GetLocation().PkgPath), false case *MapValue: return cv, pkgId, false diff --git a/gnovm/pkg/gnolang/realm.go b/gnovm/pkg/gnolang/realm.go index 8eac3781547..dd7c1e68226 100644 --- a/gnovm/pkg/gnolang/realm.go +++ b/gnovm/pkg/gnolang/realm.go @@ -559,15 +559,10 @@ func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { } // make some pkgId logic while assign - _, ok1 := oo.(*PackageValue) - if !ok1 { - if !oo.GetLastNewEscapedRealm().IsZero() { - if oo.GetLastNewEscapedRealm() != rlm.ID { - fmt.Println("---oo.GetLastNewEscapedRealm: ", oo.GetLastNewEscapedRealm()) - fmt.Println("---rlm.ID: ", rlm.ID) - panic("should not happen while attempting to attach new real object from external realm") - } - } + if !oo.GetLastNewEscapedRealm().IsZero() && oo.GetLastNewEscapedRealm() != rlm.ID { + fmt.Println("---oo.GetLastNewEscapedRealm: ", oo.GetLastNewEscapedRealm()) + fmt.Println("---rlm.ID: ", rlm.ID) + panic("should not happen while attempting to attach new real object from external realm") } // RECURSE GUARD diff --git a/gnovm/tests/files/zrealm_crossrealm0_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm0_stdlibs.gno index 241338a4739..0dd479d24e4 100644 --- a/gnovm/tests/files/zrealm_crossrealm0_stdlibs.gno +++ b/gnovm/tests/files/zrealm_crossrealm0_stdlibs.gno @@ -13,5 +13,5 @@ func main() { println(somevalue) } -// Output: -// (struct{("test" string)} gno.land/r/demo/tests.TestRealmObject) +// Error: +// should not happen while attempting to attach new real object from external realm diff --git a/gnovm/tests/files/zrealm_crossrealm1_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm1_stdlibs.gno index f89747c29c5..836c317b7dc 100644 --- a/gnovm/tests/files/zrealm_crossrealm1_stdlibs.gno +++ b/gnovm/tests/files/zrealm_crossrealm1_stdlibs.gno @@ -16,5 +16,5 @@ func main() { println(somevalue) } -// Output: -// (struct{("test" string)} gno.land/r/demo/tests.TestRealmObject) +// Error: +// should not happen while attempting to attach new real object from external realm diff --git a/gnovm/tests/files/zrealm_crossrealm29.gno b/gnovm/tests/files/zrealm_crossrealm29.gno index b2c7ede7d32..cb4cbe050e1 100644 --- a/gnovm/tests/files/zrealm_crossrealm29.gno +++ b/gnovm/tests/files/zrealm_crossrealm29.gno @@ -7,11 +7,6 @@ import ( crossrealm "gno.land/r/demo/tests/crossrealm" ) -//var f1 = func() bool { -// println("callback") -// return true -//} - func main() { f := func() bool { println("callback") diff --git a/gnovm/tests/files/zrealm_crossrealm29b.gno b/gnovm/tests/files/zrealm_crossrealm29b.gno new file mode 100644 index 00000000000..62e90a9d988 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm29b.gno @@ -0,0 +1,19 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "std" + + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +func main() { + crossrealm.SetCallback(func() bool { + println("callback") + return true + }) + crossrealm.ExecuteCallback() +} + +// Error: +// should not happen while attempting to attach new real object from external realm From 585b370fd81dcbb8f5a4b316c6a46c53d2371c00 Mon Sep 17 00:00:00 2001 From: ltzMaxwell Date: Wed, 13 Nov 2024 16:23:54 +0800 Subject: [PATCH 19/40] test array --- .../r/demo/tests/crossrealm/crossrealm2.gno | 9 ---- .../r/demo/tests/crossrealm/crossrealm4.gno | 3 ++ .../r/demo/tests/crossrealm/crossrealm5.gno | 13 ++++++ .../r/demo/tests/crossrealm/crossrealm6.gno | 41 +++++++++++++++++ gnovm/pkg/gnolang/alloc.go | 7 ++- gnovm/pkg/gnolang/op_assign.go | 1 + gnovm/pkg/gnolang/ownership.go | 46 +++++++++++++------ gnovm/pkg/gnolang/realm.go | 45 +++++++++++++++--- gnovm/pkg/gnolang/values.go | 4 +- gnovm/tests/files/zrealm_crossrealm28.gno | 8 ++-- gnovm/tests/files/zrealm_crossrealm28a.gno | 27 +++++++++++ gnovm/tests/files/zrealm_crossrealm28b.gno | 28 +++++++++++ gnovm/tests/files/zrealm_crossrealm28c.gno | 30 ++++++++++++ gnovm/tests/files/zrealm_crossrealm30.gno | 18 ++++++++ gnovm/tests/files/zrealm_crossrealm31.gno | 18 ++++++++ gnovm/tests/files/zrealm_crossrealm32.gno | 18 ++++++++ gnovm/tests/files/zrealm_crossrealm33.gno | 20 +++++--- 17 files changed, 294 insertions(+), 42 deletions(-) create mode 100644 examples/gno.land/r/demo/tests/crossrealm/crossrealm5.gno create mode 100644 examples/gno.land/r/demo/tests/crossrealm/crossrealm6.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm28a.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm28b.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm28c.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm30.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm31.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm32.gno diff --git a/examples/gno.land/r/demo/tests/crossrealm/crossrealm2.gno b/examples/gno.land/r/demo/tests/crossrealm/crossrealm2.gno index a85778e00c6..528b8cba023 100644 --- a/examples/gno.land/r/demo/tests/crossrealm/crossrealm2.gno +++ b/examples/gno.land/r/demo/tests/crossrealm/crossrealm2.gno @@ -20,20 +20,11 @@ type Container struct { var container Container // attached -func AttachContainer() { - container = Container{name: "external_container"} // attach after call -} - func SetContainer(f Fooer) { container.f = f // update } func SetContainer2(f Fooer) { - ff := f - container.f = f -} - -func SetContainer3(f Fooer) { ff := f // associate to non-attached object SetContainer(ff) // attach container, while ff is not attached } diff --git a/examples/gno.land/r/demo/tests/crossrealm/crossrealm4.gno b/examples/gno.land/r/demo/tests/crossrealm/crossrealm4.gno index e7d86663094..d58aba3553f 100644 --- a/examples/gno.land/r/demo/tests/crossrealm/crossrealm4.gno +++ b/examples/gno.land/r/demo/tests/crossrealm/crossrealm4.gno @@ -4,4 +4,7 @@ var S []Fooer func SetSlice(fs []Fooer) { S = fs + for _, f := range fs { + println(f) + } } diff --git a/examples/gno.land/r/demo/tests/crossrealm/crossrealm5.gno b/examples/gno.land/r/demo/tests/crossrealm/crossrealm5.gno new file mode 100644 index 00000000000..a8d20091de5 --- /dev/null +++ b/examples/gno.land/r/demo/tests/crossrealm/crossrealm5.gno @@ -0,0 +1,13 @@ +package crossrealm + +type F func() bool + +var f F + +func SetCallback(ff F) { + f = ff +} + +func ExecuteCallback() { + f() +} diff --git a/examples/gno.land/r/demo/tests/crossrealm/crossrealm6.gno b/examples/gno.land/r/demo/tests/crossrealm/crossrealm6.gno new file mode 100644 index 00000000000..1ba3d9c6df4 --- /dev/null +++ b/examples/gno.land/r/demo/tests/crossrealm/crossrealm6.gno @@ -0,0 +1,41 @@ +package crossrealm + +type XYZ struct{ name string } + +var s1 []XYZ +var s3 []XYZ +var s4 []XYZ + +func init() { + s1 = append(s1, XYZ{"1"}) + s1 = append(s1, XYZ{"2"}) + + s3 = append(s3, XYZ{"3"}) + s4 = append(s4, XYZ{"4"}) +} + +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) // floating +} diff --git a/gnovm/pkg/gnolang/alloc.go b/gnovm/pkg/gnolang/alloc.go index 6fef5eda834..4088d9bc1f5 100644 --- a/gnovm/pkg/gnolang/alloc.go +++ b/gnovm/pkg/gnolang/alloc.go @@ -1,6 +1,9 @@ package gnolang -import "reflect" +import ( + "fmt" + "reflect" +) // Keeps track of in-memory allocations. // In the future, allocations within realm boundaries will be @@ -121,6 +124,7 @@ func (alloc *Allocator) AllocateDataArray(size int64) { } func (alloc *Allocator) AllocateListArray(items int64) { + fmt.Println("---AllocateListArray---") alloc.Allocate(allocArray + allocArrayItem*items) } @@ -225,6 +229,7 @@ func (alloc *Allocator) NewSlice(base Value, offset, length, maxcap int) *SliceV // NOTE: also allocates the underlying array from list. func (alloc *Allocator) NewSliceFromList(list []TypedValue) *SliceValue { + fmt.Println("---NewSliceFromList") alloc.AllocateSlice() alloc.AllocateListArray(int64(cap(list))) fullList := list[:cap(list)] diff --git a/gnovm/pkg/gnolang/op_assign.go b/gnovm/pkg/gnolang/op_assign.go index 5a65d9f1190..d8db20cac5f 100644 --- a/gnovm/pkg/gnolang/op_assign.go +++ b/gnovm/pkg/gnolang/op_assign.go @@ -31,6 +31,7 @@ func (m *Machine) doOpDefine() { func (m *Machine) doOpAssign() { fmt.Println("---doOpAssign, m.Realm: ", m.Realm) s := m.PopStmt().(*AssignStmt) + fmt.Println("---s: ", s) // Assign each value evaluated for Lhs. // NOTE: PopValues() returns a slice in // forward order, not the usual reverse. diff --git a/gnovm/pkg/gnolang/ownership.go b/gnovm/pkg/gnolang/ownership.go index 5a89556429f..e801c7cfb73 100644 --- a/gnovm/pkg/gnolang/ownership.go +++ b/gnovm/pkg/gnolang/ownership.go @@ -402,10 +402,9 @@ func (tv *TypedValue) GetFirstObject(store Store) Object { } // XXX, get first accessible object, maybe containing(parent) object, maybe itself. -func (tv *TypedValue) GetFirstObject2(store Store) (Object, PkgID, bool) { +func (tv *TypedValue) GetFirstObject2(store Store) (obj Object, pkgId PkgID, isRef bool, length int, offset int) { fmt.Println("---GetFirstObject2---, tv: ", tv, reflect.TypeOf(tv.V)) fmt.Println("---tv.T, type of tv.T", tv.T, reflect.TypeOf(tv.T)) - var pkgId PkgID if dt, ok := tv.T.(*DeclaredType); ok { fmt.Println("---dt: ", dt) fmt.Println("---dt.Name: ", dt.Name) @@ -438,40 +437,59 @@ func (tv *TypedValue) GetFirstObject2(store Store) (Object, PkgID, bool) { } } } - return cv.GetBase(store), pkgId, true + obj, isRef = cv.GetBase(store), true + return case *ArrayValue: - return cv, pkgId, false + fmt.Println("---array value, T: ", tv.T) + fmt.Println("---Elem PkgPath: ", tv.T.Elem().GetPkgPath()) + + obj, pkgId, isRef = cv, PkgIDFromPkgPath(tv.T.Elem().GetPkgPath()), false + return case *SliceValue: - // TODO: XXX - return cv.GetBase(store), pkgId, false + base := cv.GetBase(store) + fmt.Println("---SliceValue, base: ", base) + fmt.Printf("---SliceValue len: %d, cap:%d, offsetL:%d \n", cv.Length, cv.Maxcap, cv.Offset) + fmt.Println("---tv.T...PkgPath: ", tv.T.Elem().GetPkgPath()) + fmt.Println("---type of base: ", reflect.TypeOf(base)) + + obj, pkgId, isRef, length, offset = cv.GetBase(store), PkgIDFromPkgPath(tv.T.Elem().GetPkgPath()), true, cv.GetLength(), cv.Offset + return case *StructValue: println("---struct value") fmt.Println("---cv.GetObjectID(): ", cv.GetObjectID()) - return cv, pkgId, false + obj, isRef = cv, false + return case *FuncValue: fmt.Println("---FuncValue") clo := cv.GetClosure(store) fmt.Println("---clo: ", clo) fmt.Println("clo...PkgPath", clo.Source.GetLocation().PkgPath) - return cv.GetClosure(store), PkgIDFromPkgPath(clo.Source.GetLocation().PkgPath), false + obj, pkgId, isRef = cv.GetClosure(store), PkgIDFromPkgPath(clo.Source.GetLocation().PkgPath), false + return case *MapValue: - return cv, pkgId, false + obj, isRef = cv, false + return case *BoundMethodValue: - return cv, pkgId, false + obj, isRef = cv, false + return case *NativeValue: // XXX allow PointerValue.Assign2 to pass nil for oo1/oo2. // panic("realm logic for native values not supported") - return nil, pkgId, false + obj, isRef = nil, false + return case *Block: - return cv, pkgId, false + obj, isRef = cv, false + return case RefValue: oo := store.GetObject(cv.ObjectID) tv.V = oo - return oo, pkgId, false + obj, isRef = oo, false + return case *HeapItemValue: // should only appear in PointerValue.Base panic("heap item value should only appear as a pointer's base") default: - return nil, pkgId, false + obj, isRef = nil, false + return } } diff --git a/gnovm/pkg/gnolang/realm.go b/gnovm/pkg/gnolang/realm.go index dd7c1e68226..af85c35f2ec 100644 --- a/gnovm/pkg/gnolang/realm.go +++ b/gnovm/pkg/gnolang/realm.go @@ -189,7 +189,7 @@ func (rlm *Realm) DidUpdate(po, xo, co Object) { println("---already escaped, should check cross realm?") // already escaped } else { - rlm.MarkNewEscapedCheckCrossRealm(co, false) + rlm.MarkNewEscapedCheckCrossRealm(nil, co, false, 0, 0) } } else if co.GetIsReal() { rlm.MarkDirty(co) @@ -210,7 +210,7 @@ func (rlm *Realm) DidUpdate(po, xo, co Object) { } } -func (rlm *Realm) DidUpdate2(po, xo, co Object, isRef bool) { +func (rlm *Realm) DidUpdate2(store Store, po, xo, co Object, isRef bool, length, offset int) { fmt.Println("---DidUpdate, rlm.ID: ", rlm.ID) fmt.Printf("---xo: %v, type of xo: %v\n", xo, reflect.TypeOf(xo)) fmt.Printf("---co: %v, type of co: %v\n", co, reflect.TypeOf(co)) @@ -265,7 +265,7 @@ func (rlm *Realm) DidUpdate2(po, xo, co Object, isRef bool) { println("---already escaped, should check cross realm?") // already escaped } else { - rlm.MarkNewEscapedCheckCrossRealm(co, isRef) + rlm.MarkNewEscapedCheckCrossRealm(store, co, isRef, length, offset) } } else if co.GetIsReal() { rlm.MarkDirty(co) @@ -289,7 +289,7 @@ func (rlm *Realm) DidUpdate2(po, xo, co Object, isRef bool) { //---------------------------------------- // mark* -func (rlm *Realm) MarkNewEscapedCheckCrossRealm(oo Object, isRef bool) { +func (rlm *Realm) MarkNewEscapedCheckCrossRealm(store Store, oo Object, isRef bool, length, offset int) { fmt.Println("---MarkNewEscapedCheckCrossRealm---, oo: ", oo) fmt.Println("---rlm.ID: ", rlm.ID) @@ -303,8 +303,41 @@ func (rlm *Realm) MarkNewEscapedCheckCrossRealm(oo Object, isRef bool) { if oo.GetLastNewEscapedRealm() != rlm.ID { // crossing realm if isRef { - if !oo.GetIsReal() { // oo is not attached in the origin realm - panic("should not happen while attempting to attach unattached object by reference from external realm") + fmt.Println("---length: ", length) + if length != 0 { // TODO: explicit array check + fmt.Println("---offset: ", offset) + fmt.Println("---escaped array, check if elements are real") + for i := offset; i < length; i++ { + e := oo.(*ArrayValue).List[i] + fmt.Println("---e: ", e, reflect.TypeOf(e.V)) + if _, ok := e.V.(RefValue); ok { // TODO: does this already enough + fmt.Println("---escaped: ", e.V.(RefValue).Escaped) + fmt.Println("---string: ", e.V.(RefValue).String()) + fmt.Println("---pkgpath: ", e.V.(RefValue).PkgPath) + fmt.Println("---objectID: ", e.V.(RefValue).ObjectID) + if store != nil { + oo := store.GetObject(e.V.(RefValue).ObjectID) + fmt.Println("---oo: ", oo) + fmt.Println("---oo.GetIsReal: ", oo.GetIsReal()) + if !oo.GetIsReal() { + panic("should not happen while reference unreal element from array of external realm") + } + } + } else { + fmt.Println("---e.V: ", e.V) + fmt.Println("---e.V: ", reflect.TypeOf(e.V)) + isreal := e.V.(Object).GetIsReal() + fmt.Println("---isreal: ", isreal) + fmt.Println("---objectID: ", e.V.(Object).GetObjectID()) + if !isreal { + panic("should not happen while reference unreal element from external realm") + } + } + } + } else { // other than array + if !oo.GetIsReal() { // oo is not attached in the origin realm + panic("should not happen while attempting to attach unattached object by reference from external realm") + } } } else { panic("should not happen while attempting to attach objects by value from external realm") diff --git a/gnovm/pkg/gnolang/values.go b/gnovm/pkg/gnolang/values.go index dbd680860ba..5028dc7fdc3 100644 --- a/gnovm/pkg/gnolang/values.go +++ b/gnovm/pkg/gnolang/values.go @@ -292,13 +292,13 @@ func (pv PointerValue) Assign2(alloc *Allocator, store Store, rlm *Realm, tv2 Ty oo1 := pv.TV.GetFirstObject(store) fmt.Println("---oo1: ", oo1) pv.TV.Assign(alloc, tv2, cu) - oo2, pkgId, isRef := pv.TV.GetFirstObject2(store) + oo2, pkgId, isRef, length, offset := pv.TV.GetFirstObject2(store) fmt.Println("---oo2: ", oo2) fmt.Println("---oo2 pkgId: ", pkgId) if oo2 != nil { oo2.SetLastNewEscapedRealm(pkgId) // attach origin package info } - rlm.DidUpdate2(pv.Base.(Object), oo1, oo2, isRef) + rlm.DidUpdate2(store, pv.Base.(Object), oo1, oo2, isRef, length, offset) } else { pv.TV.Assign(alloc, tv2, cu) } diff --git a/gnovm/tests/files/zrealm_crossrealm28.gno b/gnovm/tests/files/zrealm_crossrealm28.gno index 65084d77c19..7b9a9379ef7 100644 --- a/gnovm/tests/files/zrealm_crossrealm28.gno +++ b/gnovm/tests/files/zrealm_crossrealm28.gno @@ -13,15 +13,17 @@ type foo struct { func (foo) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } -var fs []crossrealm.Fooer +var fs []crossrealm.Fooer // panic func init() { - fs = append(fs, foo{name: "1"}) + fs = append(fs, foo{name: "1"}) // attached fs = append(fs, foo{name: "2"}) - fs = append(fs, foo{name: "3"}) } func main() { println("ok") crossrealm.SetSlice(fs) } + +// Error: +// should not happen while attempting to attach new real object from external realm diff --git a/gnovm/tests/files/zrealm_crossrealm28a.gno b/gnovm/tests/files/zrealm_crossrealm28a.gno new file mode 100644 index 00000000000..089b54c4209 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm28a.gno @@ -0,0 +1,27 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "std" + + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +type foo struct { + name string +} + +func (foo) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } + +var arr []crossrealm.Fooer + +func main() { + arr = append(arr, foo{name: "1"}) + arr = append(arr, foo{name: "2"}) + arr = append(arr, foo{name: "3"}) + + println(".") +} + +// Error: +// should not happen while attempting to attach new real object from external realm diff --git a/gnovm/tests/files/zrealm_crossrealm28b.gno b/gnovm/tests/files/zrealm_crossrealm28b.gno new file mode 100644 index 00000000000..1cb7685ec3d --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm28b.gno @@ -0,0 +1,28 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "std" + + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +type foo struct { + name string +} + +func (foo) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } + +var arr [2]crossrealm.Fooer // panic + +func main() { + arr[0] = foo{name: "1"} + arr[1] = foo{name: "2"} + + fs := arr[1:] + println("ok") + crossrealm.SetSlice(fs) +} + +// Error: +// should not happen while attempting to attach new real object from external realm diff --git a/gnovm/tests/files/zrealm_crossrealm28c.gno b/gnovm/tests/files/zrealm_crossrealm28c.gno new file mode 100644 index 00000000000..7dad77b41b2 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm28c.gno @@ -0,0 +1,30 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "std" + + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +type foo struct { + name string +} + +func (foo) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } + +func main() { + var arr []crossrealm.Fooer // not attached here + arr = append(arr, foo{name: "1"}) + arr = append(arr, foo{name: "2"}) + arr = append(arr, foo{name: "3"}) + + fs := arr[1:] + println("ok") + crossrealm.SetSlice(fs) +} + +// Output: +// ok +// (struct{("2" string)} gno.land/r/crossrealm_test.foo) +// (struct{("3" string)} gno.land/r/crossrealm_test.foo) diff --git a/gnovm/tests/files/zrealm_crossrealm30.gno b/gnovm/tests/files/zrealm_crossrealm30.gno new file mode 100644 index 00000000000..cac8dd6cd8e --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm30.gno @@ -0,0 +1,18 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "std" + + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +var SS []crossrealm.XYZ + +func main() { + SS = crossrealm.GetSlice() // this is valid if elem are all attached in origin realm + println(".") +} + +// Output: +// . diff --git a/gnovm/tests/files/zrealm_crossrealm31.gno b/gnovm/tests/files/zrealm_crossrealm31.gno new file mode 100644 index 00000000000..d3fab4041b9 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm31.gno @@ -0,0 +1,18 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "std" + + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +var SS []crossrealm.XYZ + +func main() { + SS = crossrealm.GetSlice2() // this is valid if elem are all attached in origin realm + println(".") +} + +// Error: +// should not happen while attempting to attach new real object from external realm diff --git a/gnovm/tests/files/zrealm_crossrealm32.gno b/gnovm/tests/files/zrealm_crossrealm32.gno new file mode 100644 index 00000000000..5dd6dafbc20 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm32.gno @@ -0,0 +1,18 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "std" + + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +var SS []crossrealm.XYZ + +func main() { + SS = crossrealm.GetSlice3() + println(".") +} + +// Output: +// . diff --git a/gnovm/tests/files/zrealm_crossrealm33.gno b/gnovm/tests/files/zrealm_crossrealm33.gno index b9d6d5e9718..1d892444305 100644 --- a/gnovm/tests/files/zrealm_crossrealm33.gno +++ b/gnovm/tests/files/zrealm_crossrealm33.gno @@ -1,16 +1,22 @@ // PKGPATH: gno.land/r/crossrealm_test package crossrealm_test -var ptr *int +import ( + "std" -func init() { - ptr = new(int) + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +var SS []crossrealm.XYZ + +var f = func(s []crossrealm.XYZ) { + SS = s } func main() { - *ptr = 2 - println(*ptr) + crossrealm.GetSlice4(f) + println(".") } -// Output: -// 2 +// Error: +// should not happen while reference unreal element from external realm From c8b24f597351c1d3d48cde4aeb489f3ea9e9b56c Mon Sep 17 00:00:00 2001 From: ltzMaxwell Date: Wed, 13 Nov 2024 18:08:31 +0800 Subject: [PATCH 20/40] add test --- .../r/demo/tests/crossrealm/crossrealm6.gno | 6 ++++++ gnovm/pkg/gnolang/realm.go | 11 ++--------- gnovm/tests/files/zrealm_crossrealm34.gno | 17 +++++++++++++++++ 3 files changed, 25 insertions(+), 9 deletions(-) create mode 100644 gnovm/tests/files/zrealm_crossrealm34.gno diff --git a/examples/gno.land/r/demo/tests/crossrealm/crossrealm6.gno b/examples/gno.land/r/demo/tests/crossrealm/crossrealm6.gno index 1ba3d9c6df4..b01669d1d13 100644 --- a/examples/gno.land/r/demo/tests/crossrealm/crossrealm6.gno +++ b/examples/gno.land/r/demo/tests/crossrealm/crossrealm6.gno @@ -5,6 +5,7 @@ type XYZ struct{ name string } var s1 []XYZ var s3 []XYZ var s4 []XYZ +var s5 []*XYZ func init() { s1 = append(s1, XYZ{"1"}) @@ -12,6 +13,7 @@ func init() { s3 = append(s3, XYZ{"3"}) s4 = append(s4, XYZ{"4"}) + s5 = append(s5, &XYZ{"5"}) } func GetSlice() []XYZ { @@ -39,3 +41,7 @@ func GetSlice4(f func(s []XYZ)) { s4 = append(s4, XYZ{"0"}) // this is real after this function f(s4) // floating } + +func GetSlice5() []*XYZ { // TODO, unwrap + return s5 +} diff --git a/gnovm/pkg/gnolang/realm.go b/gnovm/pkg/gnolang/realm.go index af85c35f2ec..dea50778060 100644 --- a/gnovm/pkg/gnolang/realm.go +++ b/gnovm/pkg/gnolang/realm.go @@ -751,15 +751,6 @@ func (rlm *Realm) processNewEscapedMarks(store Store) { fmt.Println("---eo.GetLastEscapedRealm: ", eo.GetLastNewEscapedRealm()) fmt.Println("---eo.GetRefCount(): ", eo.GetRefCount()) fmt.Println("---rlm.ID: ", rlm.ID) - //// only check object from another realm - //if !eo.GetLastNewEscapedRealm().IsZero() { - // if eo.GetLastNewEscapedRealm() != rlm.ID { - // //if !eo.GetIsReal() { - // panic("!!!Cross realm update") - // //} - // } - //} - fmt.Println("---processNewEscapedMarks, eo.GetObjectID: ", eo.GetRefCount()) if debug { if !eo.GetIsNewEscaped() { panic("new escaped mark not marked as new escaped") @@ -793,12 +784,14 @@ func (rlm *Realm) processNewEscapedMarks(store Store) { // will be saved regardless. } else { // exists, mark dirty. + fmt.Println("---exists, mark dirty, po: ", po) rlm.MarkDirty(po) } if eo.GetObjectID().IsZero() { panic("new escaped mark has no object ID") } // escaped has no owner. + println("---escaped has no owner") eo.SetOwner(nil) } } diff --git a/gnovm/tests/files/zrealm_crossrealm34.gno b/gnovm/tests/files/zrealm_crossrealm34.gno new file mode 100644 index 00000000000..fc45616807a --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm34.gno @@ -0,0 +1,17 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "std" + + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +var SS []*crossrealm.XYZ + +func main() { + SS = crossrealm.GetSlice5() + println(".") +} + +// Error: From ff95ddc435774367039fd76af1e5c35622ddff24 Mon Sep 17 00:00:00 2001 From: ltzMaxwell Date: Sat, 16 Nov 2024 23:19:33 +0800 Subject: [PATCH 21/40] debug --- .../r/demo/tests/crossrealm/crossrealm6.gno | 3 ++- gnovm/pkg/gnolang/realm.go | 17 +++++++++++++++-- gnovm/pkg/gnolang/values.go | 4 ++++ gnovm/tests/files/zrealm_crossrealm31.gno | 2 +- gnovm/tests/files/zrealm_crossrealm34.gno | 2 ++ gnovm/tests/files/zrealm_crossrealm35.gno | 17 +++++++++++++++++ 6 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 gnovm/tests/files/zrealm_crossrealm35.gno diff --git a/examples/gno.land/r/demo/tests/crossrealm/crossrealm6.gno b/examples/gno.land/r/demo/tests/crossrealm/crossrealm6.gno index b01669d1d13..7563a40be05 100644 --- a/examples/gno.land/r/demo/tests/crossrealm/crossrealm6.gno +++ b/examples/gno.land/r/demo/tests/crossrealm/crossrealm6.gno @@ -13,6 +13,7 @@ func init() { s3 = append(s3, XYZ{"3"}) s4 = append(s4, XYZ{"4"}) + s5 = append(s5, &XYZ{"5"}) } @@ -39,7 +40,7 @@ func GetSlice3() []XYZ { func GetSlice4(f func(s []XYZ)) { s4 = append(s4, XYZ{"0"}) // this is real after this function - f(s4) // floating + f(s4) // XYZ{"0"} is floating } func GetSlice5() []*XYZ { // TODO, unwrap diff --git a/gnovm/pkg/gnolang/realm.go b/gnovm/pkg/gnolang/realm.go index dea50778060..6eecb5810f6 100644 --- a/gnovm/pkg/gnolang/realm.go +++ b/gnovm/pkg/gnolang/realm.go @@ -216,6 +216,15 @@ func (rlm *Realm) DidUpdate2(store Store, po, xo, co Object, isRef bool, length, fmt.Printf("---co: %v, type of co: %v\n", co, reflect.TypeOf(co)) if co != nil { + if av, ok := co.(*ArrayValue); ok { + fmt.Println("---array value") + fmt.Println("---av: ", av) + fmt.Println("---av.Data: ", av.Data) + fmt.Println("---av.List: ", av.List, len(av.List)) + fmt.Println("---av.List[0]: ", av.List[0]) + } else { + println("not arrayvalue") + } fmt.Println("---co.LastNewEscapedRealm: ", co.GetLastNewEscapedRealm()) fmt.Println("---co.GetRefCount: ", co.GetRefCount()) fmt.Println("---co isReal(attached): ", co.GetIsReal()) @@ -289,6 +298,7 @@ func (rlm *Realm) DidUpdate2(store Store, po, xo, co Object, isRef bool, length, //---------------------------------------- // mark* +// TODO: move these crossrealm check logic before 'DidUpdate' func (rlm *Realm) MarkNewEscapedCheckCrossRealm(store Store, oo Object, isRef bool, length, offset int) { fmt.Println("---MarkNewEscapedCheckCrossRealm---, oo: ", oo) fmt.Println("---rlm.ID: ", rlm.ID) @@ -310,7 +320,7 @@ func (rlm *Realm) MarkNewEscapedCheckCrossRealm(store Store, oo Object, isRef bo for i := offset; i < length; i++ { e := oo.(*ArrayValue).List[i] fmt.Println("---e: ", e, reflect.TypeOf(e.V)) - if _, ok := e.V.(RefValue); ok { // TODO: does this already enough + if _, ok := e.V.(RefValue); ok { // TODO: XXX, does this already enough fmt.Println("---escaped: ", e.V.(RefValue).Escaped) fmt.Println("---string: ", e.V.(RefValue).String()) fmt.Println("---pkgpath: ", e.V.(RefValue).PkgPath) @@ -326,6 +336,9 @@ func (rlm *Realm) MarkNewEscapedCheckCrossRealm(store Store, oo Object, isRef bo } else { fmt.Println("---e.V: ", e.V) fmt.Println("---e.V: ", reflect.TypeOf(e.V)) + if p, ok := e.V.(PointerValue); ok { + fmt.Println("---is nil? ", p.TV == nil) + } isreal := e.V.(Object).GetIsReal() fmt.Println("---isreal: ", isreal) fmt.Println("---objectID: ", e.V.(Object).GetObjectID()) @@ -591,7 +604,7 @@ func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { } } - // make some pkgId logic while assign + // XXX, oo must be new real here, it's not escaped if !oo.GetLastNewEscapedRealm().IsZero() && oo.GetLastNewEscapedRealm() != rlm.ID { fmt.Println("---oo.GetLastNewEscapedRealm: ", oo.GetLastNewEscapedRealm()) fmt.Println("---rlm.ID: ", rlm.ID) diff --git a/gnovm/pkg/gnolang/values.go b/gnovm/pkg/gnolang/values.go index 5028dc7fdc3..3f68543ed20 100644 --- a/gnovm/pkg/gnolang/values.go +++ b/gnovm/pkg/gnolang/values.go @@ -298,6 +298,7 @@ func (pv PointerValue) Assign2(alloc *Allocator, store Store, rlm *Realm, tv2 Ty if oo2 != nil { oo2.SetLastNewEscapedRealm(pkgId) // attach origin package info } + // TODO: make check happens in here? rlm.DidUpdate2(store, pv.Base.(Object), oo1, oo2, isRef, length, offset) } else { pv.TV.Assign(alloc, tv2, cu) @@ -422,14 +423,17 @@ type SliceValue struct { } func (sv *SliceValue) GetBase(store Store) *ArrayValue { + fmt.Println("---GetBase") switch cv := sv.Base.(type) { case nil: return nil case RefValue: + fmt.Println("---RefValue, cv.ObjectID: ", cv.ObjectID) array := store.GetObject(cv.ObjectID).(*ArrayValue) sv.Base = array return array case *ArrayValue: + println("---ArrayValue") return cv default: panic("should not happen") diff --git a/gnovm/tests/files/zrealm_crossrealm31.gno b/gnovm/tests/files/zrealm_crossrealm31.gno index d3fab4041b9..366fafb377a 100644 --- a/gnovm/tests/files/zrealm_crossrealm31.gno +++ b/gnovm/tests/files/zrealm_crossrealm31.gno @@ -10,7 +10,7 @@ import ( var SS []crossrealm.XYZ func main() { - SS = crossrealm.GetSlice2() // this is valid if elem are all attached in origin realm + SS = crossrealm.GetSlice2() println(".") } diff --git a/gnovm/tests/files/zrealm_crossrealm34.gno b/gnovm/tests/files/zrealm_crossrealm34.gno index fc45616807a..d38d84eaa1c 100644 --- a/gnovm/tests/files/zrealm_crossrealm34.gno +++ b/gnovm/tests/files/zrealm_crossrealm34.gno @@ -15,3 +15,5 @@ func main() { } // Error: +// interface conversion: gnolang.PointerValue is not gnolang.Object: missing method DecRefCount +// *** CHECK THE ERR MESSAGES ABOVE, MAKE SURE IT'S WHAT YOU EXPECTED, DELETE THIS LINE AND RUN TEST AGAIN *** diff --git a/gnovm/tests/files/zrealm_crossrealm35.gno b/gnovm/tests/files/zrealm_crossrealm35.gno new file mode 100644 index 00000000000..dd34eed2fc3 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm35.gno @@ -0,0 +1,17 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +type XYZ struct{ name string } + +var S []*XYZ + +func init() { + S = append(S, &XYZ{"1"}) +} + +func main() { + println(S[0].name) +} + +// Output: +// 1 From ecad113a33205f4d5e8b34823cd02c0d15022fd4 Mon Sep 17 00:00:00 2001 From: ltzMaxwell Date: Fri, 22 Nov 2024 19:03:46 +0900 Subject: [PATCH 22/40] more embede tests --- .../r/demo/tests/crossrealm/crossrealm6.gno | 18 +++++ .../r/demo/tests/crossrealm/crossrealm7.gno | 36 ++++++++++ gnovm/pkg/gnolang/op_expressions.go | 6 +- gnovm/pkg/gnolang/realm.go | 72 ++++++++++++++++--- gnovm/pkg/gnolang/values.go | 29 ++++++-- gnovm/tests/files/zrealm_crossrealm34a.gno | 22 ++++++ gnovm/tests/files/zrealm_crossrealm34b.gno | 23 ++++++ gnovm/tests/files/zrealm_crossrealm35.gno | 3 +- gnovm/tests/files/zrealm_crossrealm36.gno | 17 +++++ 9 files changed, 211 insertions(+), 15 deletions(-) create mode 100644 examples/gno.land/r/demo/tests/crossrealm/crossrealm7.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm34a.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm34b.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm36.gno diff --git a/examples/gno.land/r/demo/tests/crossrealm/crossrealm6.gno b/examples/gno.land/r/demo/tests/crossrealm/crossrealm6.gno index 7563a40be05..ad4cad9ebac 100644 --- a/examples/gno.land/r/demo/tests/crossrealm/crossrealm6.gno +++ b/examples/gno.land/r/demo/tests/crossrealm/crossrealm6.gno @@ -6,6 +6,9 @@ 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"}) @@ -15,6 +18,11 @@ func init() { 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 { @@ -46,3 +54,13 @@ func GetSlice4(f func(s []XYZ)) { 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) +} diff --git a/examples/gno.land/r/demo/tests/crossrealm/crossrealm7.gno b/examples/gno.land/r/demo/tests/crossrealm/crossrealm7.gno new file mode 100644 index 00000000000..2cb43b369ce --- /dev/null +++ b/examples/gno.land/r/demo/tests/crossrealm/crossrealm7.gno @@ -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 +} diff --git a/gnovm/pkg/gnolang/op_expressions.go b/gnovm/pkg/gnolang/op_expressions.go index 7492a5f1ec7..72d428ae59c 100644 --- a/gnovm/pkg/gnolang/op_expressions.go +++ b/gnovm/pkg/gnolang/op_expressions.go @@ -16,6 +16,8 @@ func (m *Machine) doOpIndex1() { } iv := m.PopValue() // index xv := m.PeekValue(1) // x + fmt.Println("---doOpIndex1, iv: ", iv) + fmt.Println("---doOpIndex1, xv: ", xv) switch ct := baseOf(xv.T).(type) { case *MapType: mv := xv.V.(*MapValue) @@ -31,6 +33,7 @@ func (m *Machine) doOpIndex1() { } default: res := xv.GetPointerAtIndex(m.Alloc, m.Store, iv) + fmt.Println("---doOpIndex1, res: ", res.Deref()) *xv = res.Deref() // reuse as result } } @@ -44,6 +47,7 @@ func (m *Machine) doOpIndex2() { } iv := m.PeekValue(1) // index xv := m.PeekValue(2) // x + fmt.Println("---doOpIndex2: ", iv) switch ct := baseOf(xv.T).(type) { case *MapType: vt := ct.Value @@ -81,7 +85,7 @@ func (m *Machine) doOpSelector() { xv := m.PeekValue(1) fmt.Println("---xv: ", xv) res := xv.GetPointerTo(m.Alloc, m.Store, sx.Path).Deref() - fmt.Println("---res: ", res) + fmt.Println("---doOpSelector, res after Deref: ", res) if debug { m.Printf("-v[S] %v\n", xv) m.Printf("+v[S] %v\n", res) diff --git a/gnovm/pkg/gnolang/realm.go b/gnovm/pkg/gnolang/realm.go index 6eecb5810f6..9fafb42f5e3 100644 --- a/gnovm/pkg/gnolang/realm.go +++ b/gnovm/pkg/gnolang/realm.go @@ -313,6 +313,30 @@ func (rlm *Realm) MarkNewEscapedCheckCrossRealm(store Store, oo Object, isRef bo if oo.GetLastNewEscapedRealm() != rlm.ID { // crossing realm if isRef { + + if hiv, ok := oo.(*HeapItemValue); ok { + fmt.Println("---hiv: ", hiv) + r := fillValueTV(store, &hiv.Value) + fmt.Println("---r: ", r) + if sv, ok := hiv.Value.V.(*StructValue); ok { + fmt.Println("---sv: ", sv) + if !sv.GetIsReal() { + panic("---sv is not real!!!") + } + for _, fv := range sv.Fields { + rfv := fillValueTV(store, &fv) + fmt.Println("---rfv: ", rfv) + if oo, ok := rfv.V.(Object); ok { + if !oo.GetIsReal() { + panic(fmt.Sprintf("---should not happen, %v: is not real \n", oo)) + } + } + } + } + } + + // ===================================================== + fmt.Println("---length: ", length) if length != 0 { // TODO: explicit array check fmt.Println("---offset: ", offset) @@ -336,15 +360,47 @@ func (rlm *Realm) MarkNewEscapedCheckCrossRealm(store Store, oo Object, isRef bo } else { fmt.Println("---e.V: ", e.V) fmt.Println("---e.V: ", reflect.TypeOf(e.V)) - if p, ok := e.V.(PointerValue); ok { - fmt.Println("---is nil? ", p.TV == nil) - } - isreal := e.V.(Object).GetIsReal() - fmt.Println("---isreal: ", isreal) - fmt.Println("---objectID: ", e.V.(Object).GetObjectID()) - if !isreal { - panic("should not happen while reference unreal element from external realm") + + res := oo.(*ArrayValue).GetPointerAtIndexInt2(store, i, nil).Deref() + fmt.Println("---res: ", res) + fmt.Println("---type of res: ", reflect.TypeOf(res.V)) + if p, ok := res.V.(PointerValue); ok { + fmt.Println("---p.TV: ", p.TV) + fmt.Println("---p.Base: ", p.Base) + + rr := fillValueTV(store, p.TV) + fmt.Println("---rr: ", rr) + + if sv, ok := p.TV.V.(*StructValue); ok { + fmt.Println("---sv: ", sv) + fmt.Println("---sv.GetIsReal", sv.GetIsReal()) + if !sv.GetIsReal() { + panic(fmt.Sprintf("---should not happen, %v: is not real \n", sv)) + } + fmt.Println("---sv.ObjectID", sv.GetObjectID()) + } } + + //if p, ok := e.V.(PointerValue); ok { + // fmt.Println("---is nil? ", p.TV == nil) + // r := fillValueTV(store, &e) + // fmt.Println("---r: ", r) + // if ref, ok := r.V.(RefValue); ok { + // base := store.GetObject(ref.ObjectID).(Value) + // fmt.Println("---base: ", base) + // } + // fmt.Println("---type of r: ", reflect.TypeOf(r.V)) + // if p, ok := r.V.(PointerValue); ok { + // fmt.Println("---p.TV: ", p.TV) + // fmt.Println("---p.Base: ", p.Base) + // } + //} + //isreal := e.V.(Object).GetIsReal() + //fmt.Println("---isreal: ", isreal) + //fmt.Println("---objectID: ", e.V.(Object).GetObjectID()) + //if !isreal { + // panic("should not happen while reference unreal element from external realm") + //} } } } else { // other than array diff --git a/gnovm/pkg/gnolang/values.go b/gnovm/pkg/gnolang/values.go index 3f68543ed20..f4554fd8a89 100644 --- a/gnovm/pkg/gnolang/values.go +++ b/gnovm/pkg/gnolang/values.go @@ -372,6 +372,7 @@ func (av *ArrayValue) GetLength() int { // et is only required for .List byte-arrays. func (av *ArrayValue) GetPointerAtIndexInt2(store Store, ii int, et Type) PointerValue { + fmt.Println("----av, GetPointerAtIndexInt2: ", av) if av.Data == nil { ev := fillValueTV(store, &av.List[ii]) // by reference return PointerValue{ @@ -450,6 +451,7 @@ func (sv *SliceValue) GetLength() int { // et is only required for .List byte-slices. func (sv *SliceValue) GetPointerAtIndexInt2(store Store, ii int, et Type) PointerValue { + fmt.Println("---sv, GetPointerAtIndexInt2: ", sv) // Necessary run-time slice bounds check if ii < 0 { panic(fmt.Sprintf( @@ -472,6 +474,7 @@ type StructValue struct { // TODO handle unexported fields in debug, and also ensure in the preprocessor. func (sv *StructValue) GetPointerTo(store Store, path ValuePath) PointerValue { + fmt.Println("---sv GetPointerTo: ", sv) if debug { if path.Depth != 0 { panic(fmt.Sprintf( @@ -483,6 +486,8 @@ func (sv *StructValue) GetPointerTo(store Store, path ValuePath) PointerValue { } func (sv *StructValue) GetPointerToInt(store Store, index int) PointerValue { + fmt.Println("---sv, GetPointerToInt: ", sv) + fmt.Println("---index: ", index) fv := fillValueTV(store, &sv.Fields[index]) return PointerValue{ TV: fv, @@ -1726,7 +1731,10 @@ func (tv *TypedValue) Assign(alloc *Allocator, tv2 TypedValue, cu bool) { // allocated, *Allocator.AllocatePointer() is called separately, // as in OpRef. func (tv *TypedValue) GetPointerTo(alloc *Allocator, store Store, path ValuePath) PointerValue { - fmt.Println("---GetPointerTo, tv, rt of tv: ", tv, reflect.TypeOf(tv)) + fmt.Println("---GetPointerTo, tv: ", tv) + fmt.Println("---rt of tv: ", reflect.TypeOf(tv)) + fmt.Println("---path: ", path) + fmt.Println("---path.Type: ", path.Type) if debug { if tv.IsUndefined() { panic("GetPointerTo() on undefined value") @@ -1824,6 +1832,7 @@ func (tv *TypedValue) GetPointerTo(alloc *Allocator, store Store, path ValuePath fillValueTV(store, dtv) } + fmt.Println("---2, path.Type: ", path.Type) switch path.Type { case VPBlock: switch dtv.T.(type) { @@ -1836,8 +1845,12 @@ func (tv *TypedValue) GetPointerTo(alloc *Allocator, store Store, path ValuePath case VPField: switch baseOf(dtv.T).(type) { case *StructType: + println("---StructType") + fmt.Println("---dtv: ", dtv) + fmt.Println("---return pointer of dtv: ", dtv.V.(*StructValue).GetPointerTo(store, path)) return dtv.V.(*StructValue).GetPointerTo(store, path) case *TypeType: + println("---TypeType") switch t := dtv.V.(TypeValue).Type.(type) { case *PointerType: dt := t.Elt.(*DeclaredType) @@ -2054,6 +2067,7 @@ func (tv *TypedValue) GetPointerAtIndexInt(store Store, ii int) PointerValue { } func (tv *TypedValue) GetPointerAtIndex(alloc *Allocator, store Store, iv *TypedValue) PointerValue { + fmt.Println("---tv, GetPointerAtIndex: ", tv) switch bt := baseOf(tv.T).(type) { case PrimitiveType: if bt == StringType || bt == UntypedStringType { @@ -2658,19 +2672,20 @@ func typedString(s string) TypedValue { } func fillValueTV(store Store, tv *TypedValue) *TypedValue { - //fmt.Println("---fillValueTV, tv: ", tv) + fmt.Println("---fillValueTV, tv: ", tv) switch cv := tv.V.(type) { case RefValue: - //println("---tv.V RefValue") - //fmt.Println("---cv: ", cv) + println("---tv.V RefValue") + fmt.Println("---cv: ", cv) if cv.PkgPath != "" { // load package tv.V = store.GetPackage(cv.PkgPath, false) } else { // load object // XXX XXX allocate object. tv.V = store.GetObject(cv.ObjectID) - //fmt.Println("---tv.V: ", tv.V) + fmt.Println("---tv.V: ", tv.V) } case PointerValue: + fmt.Println("---PointerValue") // As a special case, cv.Base is filled // and cv.TV set appropriately. // Alternatively, could implement @@ -2678,11 +2693,14 @@ func fillValueTV(store Store, tv *TypedValue) *TypedValue { // but for execution speed traded off for // loading speed, we do the following for now: if ref, ok := cv.Base.(RefValue); ok { + fmt.Println("---cv.Base: ", ref) base := store.GetObject(ref.ObjectID).(Value) + fmt.Println("---base: ", base) cv.Base = base switch cb := base.(type) { case *ArrayValue: et := baseOf(tv.T).(*PointerType).Elt + fmt.Println("---et: ", et) epv := cb.GetPointerAtIndexInt2(store, cv.Index, et) cv.TV = epv.TV // TODO optimize? (epv.* ignored) case *StructValue: @@ -2696,6 +2714,7 @@ func fillValueTV(store Store, tv *TypedValue) *TypedValue { vpv := cb.GetPointerToInt(store, cv.Index) cv.TV = vpv.TV // TODO optimize? case *HeapItemValue: + fmt.Println("---HeapItemValue: ", cb.Value) cv.TV = &cb.Value default: panic("should not happen") diff --git a/gnovm/tests/files/zrealm_crossrealm34a.gno b/gnovm/tests/files/zrealm_crossrealm34a.gno new file mode 100644 index 00000000000..00dd06ba292 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm34a.gno @@ -0,0 +1,22 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "std" + + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +var SS []*crossrealm.XYZ + +var f = func(s []*crossrealm.XYZ) { + SS = s +} + +func main() { + crossrealm.GetSlice6(f) + println(".") +} + +// Error: +// ---should not happen, struct{("6.1" string)}: is not real diff --git a/gnovm/tests/files/zrealm_crossrealm34b.gno b/gnovm/tests/files/zrealm_crossrealm34b.gno new file mode 100644 index 00000000000..9f4a52019b0 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm34b.gno @@ -0,0 +1,23 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "std" + + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +var SS [2]crossrealm.XYZ + +var f = func(s [2]crossrealm.XYZ) { + SS = s +} + +func main() { + crossrealm.GetSlice7(f) + println(".") +} + +// Error: +// should not happen while attempting to attach new real object from external realm +// *** CHECK THE ERR MESSAGES ABOVE, MAKE SURE IT'S WHAT YOU EXPECTED, DELETE THIS LINE AND RUN TEST AGAIN *** diff --git a/gnovm/tests/files/zrealm_crossrealm35.gno b/gnovm/tests/files/zrealm_crossrealm35.gno index dd34eed2fc3..3a223dca545 100644 --- a/gnovm/tests/files/zrealm_crossrealm35.gno +++ b/gnovm/tests/files/zrealm_crossrealm35.gno @@ -10,7 +10,8 @@ func init() { } func main() { - println(S[0].name) + a := S[0].name + println(a) } // Output: diff --git a/gnovm/tests/files/zrealm_crossrealm36.gno b/gnovm/tests/files/zrealm_crossrealm36.gno new file mode 100644 index 00000000000..a4ce8f9497f --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm36.gno @@ -0,0 +1,17 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import crossrealm "gno.land/r/demo/tests/crossrealm" + +var s *crossrealm.C + +func cb(c *crossrealm.C) { + s = c +} +func main() { + crossrealm.GetStruct(cb) + println(s) +} + +// Error: +// ---should not happen, struct{("d" string)}: is not real From e2670cc477b107e474d4073920a75bc860eae05c Mon Sep 17 00:00:00 2001 From: ltzMaxwell Date: Sun, 24 Nov 2024 17:59:25 +0900 Subject: [PATCH 23/40] start refactor --- gnovm/pkg/gnolang/realm.go | 46 ++++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/gnovm/pkg/gnolang/realm.go b/gnovm/pkg/gnolang/realm.go index 9fafb42f5e3..d423bdba604 100644 --- a/gnovm/pkg/gnolang/realm.go +++ b/gnovm/pkg/gnolang/realm.go @@ -298,9 +298,27 @@ func (rlm *Realm) DidUpdate2(store Store, po, xo, co Object, isRef bool, length, //---------------------------------------- // mark* +// oo can can be base of the originType, like array for a slice type. +// originType may contain infos like len, cap for slice type, etc. +// XXX, oo coming here must be referenced type, since they already escaped. +// XXX, so oo has been persisted, thus fillValueTv.. +func checkCrossRealm(store Store, oo Object, originType Type) { + fmt.Println("---checkCrossReal, oo: ", oo) + fmt.Println("---originType: ", originType) + switch v := oo.(type) { + case *HeapItemValue: + fmt.Println("---heapItemValue: ", v) + case *ArrayValue: + fmt.Println("---ArrayValue: ", v) + default: + fmt.Println("---v :", v) + } +} + // TODO: move these crossrealm check logic before 'DidUpdate' func (rlm *Realm) MarkNewEscapedCheckCrossRealm(store Store, oo Object, isRef bool, length, offset int) { fmt.Println("---MarkNewEscapedCheckCrossRealm---, oo: ", oo) + checkCrossRealm(store, oo, nil) fmt.Println("---rlm.ID: ", rlm.ID) fmt.Println("---oo.GetRefCount(): ", oo.GetRefCount()) @@ -403,7 +421,7 @@ func (rlm *Realm) MarkNewEscapedCheckCrossRealm(store Store, oo Object, isRef bo //} } } - } else { // other than array + } else { // other than array if !oo.GetIsReal() { // oo is not attached in the origin realm panic("should not happen while attempting to attach unattached object by reference from external realm") } @@ -531,13 +549,13 @@ func (rlm *Realm) FinalizeRealmTransaction(readonly bool, store Store) { }() if readonly { if true || - len(rlm.newCreated) > 0 || - len(rlm.newEscaped) > 0 || - len(rlm.newDeleted) > 0 || - len(rlm.created) > 0 || - len(rlm.updated) > 0 || - len(rlm.deleted) > 0 || - len(rlm.escaped) > 0 { + len(rlm.newCreated) > 0 || + len(rlm.newEscaped) > 0 || + len(rlm.newDeleted) > 0 || + len(rlm.created) > 0 || + len(rlm.updated) > 0 || + len(rlm.deleted) > 0 || + len(rlm.escaped) > 0 { panic("realm updates in readonly transaction") } return @@ -552,9 +570,9 @@ func (rlm *Realm) FinalizeRealmTransaction(readonly bool, store Store) { ensureUniq(rlm.newDeleted) ensureUniq(rlm.updated) if false || - rlm.created != nil || - rlm.deleted != nil || - rlm.escaped != nil { + rlm.created != nil || + rlm.deleted != nil || + rlm.escaped != nil { panic("realm should not have created, deleted, or escaped marks before beginning finalization") } } @@ -988,9 +1006,9 @@ func (rlm *Realm) saveUnsavedObjectRecursively(store Store, oo Object) { } // deleted objects should not have gotten here. if false || - oo.GetRefCount() <= 0 || - oo.GetIsNewDeleted() || - oo.GetIsDeleted() { + oo.GetRefCount() <= 0 || + oo.GetIsNewDeleted() || + oo.GetIsDeleted() { panic("cannot save deleted objects") } } From e28a2ba329440fe47c0b629531ba0a05ce9611fe Mon Sep 17 00:00:00 2001 From: ltzMaxwell Date: Mon, 25 Nov 2024 10:42:49 +0900 Subject: [PATCH 24/40] save --- gnovm/pkg/gnolang/realm.go | 174 +++++++++++---------- gnovm/tests/files/zrealm_crossrealm34b.gno | 1 - 2 files changed, 89 insertions(+), 86 deletions(-) diff --git a/gnovm/pkg/gnolang/realm.go b/gnovm/pkg/gnolang/realm.go index d423bdba604..ef2df487aae 100644 --- a/gnovm/pkg/gnolang/realm.go +++ b/gnovm/pkg/gnolang/realm.go @@ -301,15 +301,83 @@ func (rlm *Realm) DidUpdate2(store Store, po, xo, co Object, isRef bool, length, // oo can can be base of the originType, like array for a slice type. // originType may contain infos like len, cap for slice type, etc. // XXX, oo coming here must be referenced type, since they already escaped. -// XXX, so oo has been persisted, thus fillValueTv.. -func checkCrossRealm(store Store, oo Object, originType Type) { +// XXX, so oo has been persisted, thus fillValueTV +func checkCrossRealm(store Store, oo Object, offset, length int) { fmt.Println("---checkCrossReal, oo: ", oo) - fmt.Println("---originType: ", originType) switch v := oo.(type) { + case *StructValue: + fmt.Println("---StructValue...") + fmt.Println("---sv: ", v) + if !v.GetIsReal() { + panic("---sv is not real!!!") + } + for _, fv := range v.Fields { + fmt.Println("---fv: ", fv) + fmt.Println("---type of fv: ", reflect.TypeOf(fv.V)) + // XXX, consider this + //if _, ok := fv.V.(RefValue); !ok { + // panic("---sv is not ref value!!!") + //} + rfv := fillValueTV(store, &fv) + fmt.Println("---rfv: ", rfv) + if oo, ok := rfv.V.(Object); ok { + if !oo.GetIsReal() { + panic(fmt.Sprintf("---should not happen, %v: is not real \n", oo)) + } + } + } + case *HeapItemValue: fmt.Println("---heapItemValue: ", v) + //r := fillValueTV(store, &v.Value) + //fmt.Println("---r: ", r) + + checkCrossRealm(store, v.Value.V.(Object), 0, 0) case *ArrayValue: fmt.Println("---ArrayValue: ", v) + fmt.Println("---offset: ", offset) + fmt.Println("---escaped array, check if elements are real") + for i := offset; i < length; i++ { + e := oo.(*ArrayValue).List[i] + fmt.Println("---e: ", e, reflect.TypeOf(e.V)) + if _, ok := e.V.(RefValue); ok { // TODO: XXX, does this already enough + fmt.Println("---escaped: ", e.V.(RefValue).Escaped) + fmt.Println("---string: ", e.V.(RefValue).String()) + fmt.Println("---pkgpath: ", e.V.(RefValue).PkgPath) + fmt.Println("---objectID: ", e.V.(RefValue).ObjectID) + if store != nil { + oo := store.GetObject(e.V.(RefValue).ObjectID) + fmt.Println("---oo: ", oo) + fmt.Println("---oo.GetIsReal: ", oo.GetIsReal()) + if !oo.GetIsReal() { + panic("should not happen while reference unreal element from array of external realm") + } + } + } else { + fmt.Println("---e.V: ", e.V) + fmt.Println("---e.V: ", reflect.TypeOf(e.V)) + + res := oo.(*ArrayValue).GetPointerAtIndexInt2(store, i, nil).Deref() + fmt.Println("---res: ", res) + fmt.Println("---type of res: ", reflect.TypeOf(res.V)) + if p, ok := res.V.(PointerValue); ok { + fmt.Println("---p.TV: ", p.TV) + fmt.Println("---p.Base: ", p.Base) + + rr := fillValueTV(store, p.TV) + fmt.Println("---rr: ", rr) + + if sv, ok := p.TV.V.(*StructValue); ok { + fmt.Println("---sv: ", sv) + fmt.Println("---sv.GetIsReal", sv.GetIsReal()) + if !sv.GetIsReal() { + panic(fmt.Sprintf("---should not happen, %v: is not real \n", sv)) + } + fmt.Println("---sv.ObjectID", sv.GetObjectID()) + } + } + } + } default: fmt.Println("---v :", v) } @@ -318,7 +386,7 @@ func checkCrossRealm(store Store, oo Object, originType Type) { // TODO: move these crossrealm check logic before 'DidUpdate' func (rlm *Realm) MarkNewEscapedCheckCrossRealm(store Store, oo Object, isRef bool, length, offset int) { fmt.Println("---MarkNewEscapedCheckCrossRealm---, oo: ", oo) - checkCrossRealm(store, oo, nil) + checkCrossRealm(store, oo, offset, length) fmt.Println("---rlm.ID: ", rlm.ID) fmt.Println("---oo.GetRefCount(): ", oo.GetRefCount()) @@ -334,93 +402,29 @@ func (rlm *Realm) MarkNewEscapedCheckCrossRealm(store Store, oo Object, isRef bo if hiv, ok := oo.(*HeapItemValue); ok { fmt.Println("---hiv: ", hiv) - r := fillValueTV(store, &hiv.Value) - fmt.Println("---r: ", r) - if sv, ok := hiv.Value.V.(*StructValue); ok { - fmt.Println("---sv: ", sv) - if !sv.GetIsReal() { - panic("---sv is not real!!!") - } - for _, fv := range sv.Fields { - rfv := fillValueTV(store, &fv) - fmt.Println("---rfv: ", rfv) - if oo, ok := rfv.V.(Object); ok { - if !oo.GetIsReal() { - panic(fmt.Sprintf("---should not happen, %v: is not real \n", oo)) - } - } - } - } + //r := fillValueTV(store, &hiv.Value) + //fmt.Println("---r: ", r) + //if sv, ok := hiv.Value.V.(*StructValue); ok { + // fmt.Println("---sv: ", sv) + // if !sv.GetIsReal() { + // panic("---sv is not real!!!") + // } + // for _, fv := range sv.Fields { + // rfv := fillValueTV(store, &fv) + // fmt.Println("---rfv: ", rfv) + // if oo, ok := rfv.V.(Object); ok { + // if !oo.GetIsReal() { + // panic(fmt.Sprintf("---should not happen, %v: is not real \n", oo)) + // } + // } + // } + //} } // ===================================================== fmt.Println("---length: ", length) if length != 0 { // TODO: explicit array check - fmt.Println("---offset: ", offset) - fmt.Println("---escaped array, check if elements are real") - for i := offset; i < length; i++ { - e := oo.(*ArrayValue).List[i] - fmt.Println("---e: ", e, reflect.TypeOf(e.V)) - if _, ok := e.V.(RefValue); ok { // TODO: XXX, does this already enough - fmt.Println("---escaped: ", e.V.(RefValue).Escaped) - fmt.Println("---string: ", e.V.(RefValue).String()) - fmt.Println("---pkgpath: ", e.V.(RefValue).PkgPath) - fmt.Println("---objectID: ", e.V.(RefValue).ObjectID) - if store != nil { - oo := store.GetObject(e.V.(RefValue).ObjectID) - fmt.Println("---oo: ", oo) - fmt.Println("---oo.GetIsReal: ", oo.GetIsReal()) - if !oo.GetIsReal() { - panic("should not happen while reference unreal element from array of external realm") - } - } - } else { - fmt.Println("---e.V: ", e.V) - fmt.Println("---e.V: ", reflect.TypeOf(e.V)) - - res := oo.(*ArrayValue).GetPointerAtIndexInt2(store, i, nil).Deref() - fmt.Println("---res: ", res) - fmt.Println("---type of res: ", reflect.TypeOf(res.V)) - if p, ok := res.V.(PointerValue); ok { - fmt.Println("---p.TV: ", p.TV) - fmt.Println("---p.Base: ", p.Base) - - rr := fillValueTV(store, p.TV) - fmt.Println("---rr: ", rr) - - if sv, ok := p.TV.V.(*StructValue); ok { - fmt.Println("---sv: ", sv) - fmt.Println("---sv.GetIsReal", sv.GetIsReal()) - if !sv.GetIsReal() { - panic(fmt.Sprintf("---should not happen, %v: is not real \n", sv)) - } - fmt.Println("---sv.ObjectID", sv.GetObjectID()) - } - } - - //if p, ok := e.V.(PointerValue); ok { - // fmt.Println("---is nil? ", p.TV == nil) - // r := fillValueTV(store, &e) - // fmt.Println("---r: ", r) - // if ref, ok := r.V.(RefValue); ok { - // base := store.GetObject(ref.ObjectID).(Value) - // fmt.Println("---base: ", base) - // } - // fmt.Println("---type of r: ", reflect.TypeOf(r.V)) - // if p, ok := r.V.(PointerValue); ok { - // fmt.Println("---p.TV: ", p.TV) - // fmt.Println("---p.Base: ", p.Base) - // } - //} - //isreal := e.V.(Object).GetIsReal() - //fmt.Println("---isreal: ", isreal) - //fmt.Println("---objectID: ", e.V.(Object).GetObjectID()) - //if !isreal { - // panic("should not happen while reference unreal element from external realm") - //} - } - } } else { // other than array if !oo.GetIsReal() { // oo is not attached in the origin realm panic("should not happen while attempting to attach unattached object by reference from external realm") diff --git a/gnovm/tests/files/zrealm_crossrealm34b.gno b/gnovm/tests/files/zrealm_crossrealm34b.gno index 9f4a52019b0..673d2538188 100644 --- a/gnovm/tests/files/zrealm_crossrealm34b.gno +++ b/gnovm/tests/files/zrealm_crossrealm34b.gno @@ -20,4 +20,3 @@ func main() { // Error: // should not happen while attempting to attach new real object from external realm -// *** CHECK THE ERR MESSAGES ABOVE, MAKE SURE IT'S WHAT YOU EXPECTED, DELETE THIS LINE AND RUN TEST AGAIN *** From 696e6dae67c16fae4a2ca735e8825401d4b9de9d Mon Sep 17 00:00:00 2001 From: ltzMaxwell Date: Mon, 25 Nov 2024 10:48:04 +0900 Subject: [PATCH 25/40] save --- gnovm/pkg/gnolang/realm.go | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/gnovm/pkg/gnolang/realm.go b/gnovm/pkg/gnolang/realm.go index ef2df487aae..a3fa623ce48 100644 --- a/gnovm/pkg/gnolang/realm.go +++ b/gnovm/pkg/gnolang/realm.go @@ -425,7 +425,7 @@ func (rlm *Realm) MarkNewEscapedCheckCrossRealm(store Store, oo Object, isRef bo fmt.Println("---length: ", length) if length != 0 { // TODO: explicit array check - } else { // other than array + } else { // other than array if !oo.GetIsReal() { // oo is not attached in the origin realm panic("should not happen while attempting to attach unattached object by reference from external realm") } @@ -553,13 +553,13 @@ func (rlm *Realm) FinalizeRealmTransaction(readonly bool, store Store) { }() if readonly { if true || - len(rlm.newCreated) > 0 || - len(rlm.newEscaped) > 0 || - len(rlm.newDeleted) > 0 || - len(rlm.created) > 0 || - len(rlm.updated) > 0 || - len(rlm.deleted) > 0 || - len(rlm.escaped) > 0 { + len(rlm.newCreated) > 0 || + len(rlm.newEscaped) > 0 || + len(rlm.newDeleted) > 0 || + len(rlm.created) > 0 || + len(rlm.updated) > 0 || + len(rlm.deleted) > 0 || + len(rlm.escaped) > 0 { panic("realm updates in readonly transaction") } return @@ -574,9 +574,9 @@ func (rlm *Realm) FinalizeRealmTransaction(readonly bool, store Store) { ensureUniq(rlm.newDeleted) ensureUniq(rlm.updated) if false || - rlm.created != nil || - rlm.deleted != nil || - rlm.escaped != nil { + rlm.created != nil || + rlm.deleted != nil || + rlm.escaped != nil { panic("realm should not have created, deleted, or escaped marks before beginning finalization") } } @@ -1010,9 +1010,9 @@ func (rlm *Realm) saveUnsavedObjectRecursively(store Store, oo Object) { } // deleted objects should not have gotten here. if false || - oo.GetRefCount() <= 0 || - oo.GetIsNewDeleted() || - oo.GetIsDeleted() { + oo.GetRefCount() <= 0 || + oo.GetIsNewDeleted() || + oo.GetIsDeleted() { panic("cannot save deleted objects") } } From 675355d55ea9248d268d5164812ded854ff26303 Mon Sep 17 00:00:00 2001 From: ltzMaxwell Date: Mon, 25 Nov 2024 17:16:40 +0900 Subject: [PATCH 26/40] clean --- .../r/demo/tests/crossrealm/crossrealm8.gno | 12 + .../r/demo/tests/crossrealm/crossrealm9.gno | 32 ++ gnovm/pkg/gnolang/alloc.go | 3 - gnovm/pkg/gnolang/machine.go | 35 ++- gnovm/pkg/gnolang/op_call.go | 14 +- gnovm/pkg/gnolang/op_eval.go | 4 +- gnovm/pkg/gnolang/op_exec.go | 6 +- gnovm/pkg/gnolang/op_expressions.go | 14 +- gnovm/pkg/gnolang/ownership.go | 56 ++-- gnovm/pkg/gnolang/realm.go | 273 +++++++----------- gnovm/pkg/gnolang/store.go | 10 +- gnovm/pkg/gnolang/values.go | 66 ++--- .../files/zrealm_crossrealm10_stdlibs.gno | 14 - .../files/zrealm_crossrealm11_stdlibs.gno | 146 ---------- .../files/zrealm_crossrealm12_stdlibs.gno | 37 --- .../files/zrealm_crossrealm13_stdlibs.gno | 48 --- .../files/zrealm_crossrealm13a_stdlibs.gno | 46 --- gnovm/tests/files/zrealm_crossrealm14.gno | 17 -- gnovm/tests/files/zrealm_crossrealm15.gno | 27 -- gnovm/tests/files/zrealm_crossrealm16.gno | 18 -- gnovm/tests/files/zrealm_crossrealm16a.gno | 16 - gnovm/tests/files/zrealm_crossrealm17.gno | 28 -- gnovm/tests/files/zrealm_crossrealm18.gno | 34 --- gnovm/tests/files/zrealm_crossrealm19.gno | 33 --- .../files/zrealm_crossrealm1_stdlibs.gno | 20 -- .../files/zrealm_crossrealm2_stdlibs.gno | 22 -- gnovm/tests/files/zrealm_crossrealm34.gno | 5 +- gnovm/tests/files/zrealm_crossrealm37.gno | 14 + gnovm/tests/files/zrealm_crossrealm38.gno | 13 + ...m0_stdlibs.gno => zrealm_crossrealm39.gno} | 11 +- .../files/zrealm_crossrealm3_stdlibs.gno | 22 -- gnovm/tests/files/zrealm_crossrealm40.gno | 13 + .../files/zrealm_crossrealm4_stdlibs.gno | 22 -- .../files/zrealm_crossrealm5_stdlibs.gno | 22 -- .../files/zrealm_crossrealm6_stdlibs.gno | 21 -- .../files/zrealm_crossrealm7_stdlibs.gno | 14 - .../files/zrealm_crossrealm8_stdlibs.gno | 14 - .../files/zrealm_crossrealm9_stdlibs.gno | 14 - 38 files changed, 291 insertions(+), 925 deletions(-) create mode 100644 examples/gno.land/r/demo/tests/crossrealm/crossrealm8.gno create mode 100644 examples/gno.land/r/demo/tests/crossrealm/crossrealm9.gno delete mode 100644 gnovm/tests/files/zrealm_crossrealm10_stdlibs.gno delete mode 100644 gnovm/tests/files/zrealm_crossrealm11_stdlibs.gno delete mode 100644 gnovm/tests/files/zrealm_crossrealm12_stdlibs.gno delete mode 100644 gnovm/tests/files/zrealm_crossrealm13_stdlibs.gno delete mode 100644 gnovm/tests/files/zrealm_crossrealm13a_stdlibs.gno delete mode 100644 gnovm/tests/files/zrealm_crossrealm14.gno delete mode 100644 gnovm/tests/files/zrealm_crossrealm15.gno delete mode 100644 gnovm/tests/files/zrealm_crossrealm16.gno delete mode 100644 gnovm/tests/files/zrealm_crossrealm16a.gno delete mode 100644 gnovm/tests/files/zrealm_crossrealm17.gno delete mode 100644 gnovm/tests/files/zrealm_crossrealm18.gno delete mode 100644 gnovm/tests/files/zrealm_crossrealm19.gno delete mode 100644 gnovm/tests/files/zrealm_crossrealm1_stdlibs.gno delete mode 100644 gnovm/tests/files/zrealm_crossrealm2_stdlibs.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm37.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm38.gno rename gnovm/tests/files/{zrealm_crossrealm0_stdlibs.gno => zrealm_crossrealm39.gno} (50%) delete mode 100644 gnovm/tests/files/zrealm_crossrealm3_stdlibs.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm40.gno delete mode 100644 gnovm/tests/files/zrealm_crossrealm4_stdlibs.gno delete mode 100644 gnovm/tests/files/zrealm_crossrealm5_stdlibs.gno delete mode 100644 gnovm/tests/files/zrealm_crossrealm6_stdlibs.gno delete mode 100644 gnovm/tests/files/zrealm_crossrealm7_stdlibs.gno delete mode 100644 gnovm/tests/files/zrealm_crossrealm8_stdlibs.gno delete mode 100644 gnovm/tests/files/zrealm_crossrealm9_stdlibs.gno diff --git a/examples/gno.land/r/demo/tests/crossrealm/crossrealm8.gno b/examples/gno.land/r/demo/tests/crossrealm/crossrealm8.gno new file mode 100644 index 00000000000..a3241dfe721 --- /dev/null +++ b/examples/gno.land/r/demo/tests/crossrealm/crossrealm8.gno @@ -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 +} diff --git a/examples/gno.land/r/demo/tests/crossrealm/crossrealm9.gno b/examples/gno.land/r/demo/tests/crossrealm/crossrealm9.gno new file mode 100644 index 00000000000..7961fe4a2ec --- /dev/null +++ b/examples/gno.land/r/demo/tests/crossrealm/crossrealm9.gno @@ -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 +} diff --git a/gnovm/pkg/gnolang/alloc.go b/gnovm/pkg/gnolang/alloc.go index 4088d9bc1f5..0c88f1383b2 100644 --- a/gnovm/pkg/gnolang/alloc.go +++ b/gnovm/pkg/gnolang/alloc.go @@ -1,7 +1,6 @@ package gnolang import ( - "fmt" "reflect" ) @@ -124,7 +123,6 @@ func (alloc *Allocator) AllocateDataArray(size int64) { } func (alloc *Allocator) AllocateListArray(items int64) { - fmt.Println("---AllocateListArray---") alloc.Allocate(allocArray + allocArrayItem*items) } @@ -229,7 +227,6 @@ func (alloc *Allocator) NewSlice(base Value, offset, length, maxcap int) *SliceV // NOTE: also allocates the underlying array from list. func (alloc *Allocator) NewSliceFromList(list []TypedValue) *SliceValue { - fmt.Println("---NewSliceFromList") alloc.AllocateSlice() alloc.AllocateListArray(int64(cap(list))) fullList := list[:cap(list)] diff --git a/gnovm/pkg/gnolang/machine.go b/gnovm/pkg/gnolang/machine.go index 276ddc94f5f..9765d43b0db 100644 --- a/gnovm/pkg/gnolang/machine.go +++ b/gnovm/pkg/gnolang/machine.go @@ -286,9 +286,9 @@ func (m *Machine) RunMemPackageWithOverrides(memPkg *std.MemPackage, save bool) } func (m *Machine) runMemPackage(memPkg *std.MemPackage, save, overrides bool) (*PackageNode, *PackageValue) { - fmt.Println("---runMemPackage, save: ", save) - fmt.Println("---runMemPackage, memPkg: ", memPkg) - defer func() { fmt.Println("---done runMemPackage: ", memPkg) }() + //fmt.Println("---runMemPackage, save: ", save) + //fmt.Println("---runMemPackage, memPkg: ", memPkg) + //defer func() { fmt.Println("---done runMemPackage: ", memPkg) }() // parse files. files := ParseMemPackage(memPkg) if !overrides && checkDuplicates(files) { @@ -310,7 +310,7 @@ func (m *Machine) runMemPackage(memPkg *std.MemPackage, save, overrides bool) (* m.SetActivePackage(pv) // run files. updates := m.RunFileDecls(files.Files...) - fmt.Println("---updates: ", updates) + //fmt.Println("---updates: ", updates) // save package value and mempackage. // XXX save condition will be removed once gonative is removed. var throwaway *Realm @@ -320,7 +320,7 @@ func (m *Machine) runMemPackage(memPkg *std.MemPackage, save, overrides bool) (* if throwaway != nil { m.Realm = throwaway } - fmt.Println("---save, throwaway: ", throwaway) + //fmt.Println("---save, throwaway: ", throwaway) } // run init functions m.runInitFromUpdates(pv, updates) @@ -733,16 +733,15 @@ func (m *Machine) runFileDecls(fns ...*FileNode) []TypedValue { // multiple files belonging to the same package in // lexical file name order to a compiler." func (m *Machine) runInitFromUpdates(pv *PackageValue, updates []TypedValue) { - fmt.Println("---runInitFromUpdates") for _, tv := range updates { - fmt.Println("---runInitFromUpdates, tv: ", tv) + //fmt.Println("---runInitFromUpdates, tv: ", tv) if tv.IsDefined() && tv.T.Kind() == FuncKind && tv.V != nil { fv, ok := tv.V.(*FuncValue) if !ok { continue // skip native functions. } if strings.HasPrefix(string(fv.Name), "init.") { - fmt.Println("---fv.Name: ", fv.Name) + //fmt.Println("---fv.Name: ", fv.Name) fb := pv.GetFileBlock(m.Store, fv.FileName) m.PushBlock(fb) m.RunFunc(fv.Name) @@ -758,7 +757,7 @@ func (m *Machine) runInitFromUpdates(pv *PackageValue, updates []TypedValue) { // Returns a throwaway realm package is not a realm, // such as stdlibs or /p/ packages. func (m *Machine) saveNewPackageValuesAndTypes() (throwaway *Realm) { - fmt.Println("---saveNewPackageValuesAndTypes") + //fmt.Println("---saveNewPackageValuesAndTypes") // save package value and dependencies. pv := m.Package if pv.IsRealm() { @@ -790,12 +789,12 @@ func (m *Machine) saveNewPackageValuesAndTypes() (throwaway *Realm) { // Pass in the realm from m.saveNewPackageValuesAndTypes() // in case a throwaway was created. func (m *Machine) resavePackageValues(rlm *Realm) { - fmt.Println("---resavePackageValues, realm: ", rlm) + //fmt.Println("---resavePackageValues, realm: ", rlm) // save package value and dependencies. pv := m.Package if pv.IsRealm() { rlm = pv.Realm - fmt.Println("---rlm: ", rlm) + //fmt.Println("---rlm: ", rlm) rlm.FinalizeRealmTransaction(m.ReadOnly, m.Store) // re-save package realm info. m.Store.SetPackageRealm(rlm) @@ -981,14 +980,14 @@ func (m *Machine) RunDeclaration(d Decl) { // package level, for which evaluations happen during // preprocessing). func (m *Machine) runDeclaration(d Decl) { - fmt.Println("---run declaration, d: ", d) + //fmt.Println("---run declaration, d: ", d) switch d := d.(type) { case *FuncDecl: // nothing to do. // closure and package already set // during PackageNode.NewPackage(). case *ValueDecl: - fmt.Println("---valueDecl, d.Type, type of d.Type: ", d.Type, reflect.TypeOf(d.Type)) + //fmt.Println("---valueDecl, d.Type, type of d.Type: ", d.Type, reflect.TypeOf(d.Type)) m.PushOp(OpHalt) m.PushStmt(d) m.PushOp(OpExec) @@ -1859,7 +1858,7 @@ func (m *Machine) PushFrameBasic(s Stmt) { // ensure the counts are consistent, otherwise we mask // bugs with frame pops. func (m *Machine) PushFrameCall(cx *CallExpr, fv *FuncValue, recv TypedValue) { - fmt.Printf("---PushFrameCall---, cx: %v, fv: %v, recv: %v\n", cx, fv, recv) + //fmt.Printf("---PushFrameCall---, cx: %v, fv: %v, recv: %v\n", cx, fv, recv) fr := &Frame{ Source: cx, NumOps: m.NumOps, @@ -1885,13 +1884,13 @@ func (m *Machine) PushFrameCall(cx *CallExpr, fv *FuncValue, recv TypedValue) { m.Printf("+F %#v\n", fr) } m.Frames = append(m.Frames, fr) - fmt.Println("---recv: ", recv) + //fmt.Println("---recv: ", recv) if recv.IsDefined() { // If the receiver is defined, we enter the receiver's realm. obj := recv.GetFirstObject(m.Store) - fmt.Println("---obj, rt of obj: ", obj, reflect.TypeOf(obj)) - fmt.Println("---obj.GetObjectID: ", obj.GetObjectID()) - fmt.Printf("---obj addr: %p\n", obj) + //fmt.Println("---obj, rt of obj: ", obj, reflect.TypeOf(obj)) + //fmt.Println("---obj.GetObjectID: ", obj.GetObjectID()) + //fmt.Printf("---obj addr: %p\n", obj) if obj == nil { // could be a nil receiver. // set package and realm of function. diff --git a/gnovm/pkg/gnolang/op_call.go b/gnovm/pkg/gnolang/op_call.go index 34e4f553dff..5bb9f3ec748 100644 --- a/gnovm/pkg/gnolang/op_call.go +++ b/gnovm/pkg/gnolang/op_call.go @@ -7,7 +7,7 @@ import ( ) func (m *Machine) doOpPrecall() { - fmt.Println("---doOpPrecall---") + //fmt.Println("---doOpPrecall---") cx := m.PopExpr().(*CallExpr) v := m.PeekValue(1 + cx.NumArgs).V if debug { @@ -20,13 +20,13 @@ func (m *Machine) doOpPrecall() { } switch fv := v.(type) { case *FuncValue: - fmt.Println("---FuncValue, fv: ", fv) + //fmt.Println("---FuncValue, fv: ", fv) m.PushFrameCall(cx, fv, TypedValue{}) m.PushOp(OpCall) case *BoundMethodValue: - fmt.Println("---BoundMethodValue, fv: ", fv) - fmt.Println("---BoundMethodValue, fv.Func: ", fv.Func) - fmt.Println("---BoundMethodValue, fv.Receiver: ", fv.Receiver) + //fmt.Println("---BoundMethodValue, fv: ", fv) + //fmt.Println("---BoundMethodValue, fv.Func: ", fv.Func) + //fmt.Println("---BoundMethodValue, fv.Receiver: ", fv.Receiver) m.PushFrameCall(cx, fv.Func, fv.Receiver) m.PushOp(OpCall) case TypeValue: @@ -51,7 +51,7 @@ func (m *Machine) doOpPrecall() { var gReturnStmt = &ReturnStmt{} func (m *Machine) doOpCall() { - fmt.Println("---doOpCall---") + //fmt.Println("---doOpCall---") // NOTE: Frame won't be popped until the statement is complete, to // discard the correct number of results for func calls in ExprStmts. fr := m.LastFrame() @@ -205,7 +205,6 @@ func (m *Machine) doOpReturn() { finalize = true } if finalize { - fmt.Println("---going to finalizeRealmTransaction at return after call") // Finalize realm updates! // NOTE: This is a resource intensive undertaking. crlm.FinalizeRealmTransaction(m.ReadOnly, m.Store) @@ -241,7 +240,6 @@ func (m *Machine) doOpReturnFromBlock() { finalize = true } if finalize { - fmt.Println("---going to finalize") // Finalize realm updates! // NOTE: This is a resource intensive undertaking. crlm.FinalizeRealmTransaction(m.ReadOnly, m.Store) diff --git a/gnovm/pkg/gnolang/op_eval.go b/gnovm/pkg/gnolang/op_eval.go index b13f06212b7..d9a381bba96 100644 --- a/gnovm/pkg/gnolang/op_eval.go +++ b/gnovm/pkg/gnolang/op_eval.go @@ -243,7 +243,7 @@ func (m *Machine) doOpEval() { m.PushOp(OpEval) } case *CallExpr: - fmt.Println("---Eval, CallExpr, x: ", x) + //fmt.Println("---Eval, CallExpr, x: ", x) m.PushOp(OpPrecall) // Eval args. args := x.Args @@ -267,7 +267,7 @@ func (m *Machine) doOpEval() { m.PushExpr(x.X) m.PushOp(OpEval) case *SelectorExpr: - fmt.Println("---Eval, SelectorExpr, x: ", x) + //fmt.Println("---Eval, SelectorExpr, x: ", x) m.PushOp(OpSelector) // evaluate x m.PushExpr(x.X) diff --git a/gnovm/pkg/gnolang/op_exec.go b/gnovm/pkg/gnolang/op_exec.go index a17f0203e1c..3d50b4d8131 100644 --- a/gnovm/pkg/gnolang/op_exec.go +++ b/gnovm/pkg/gnolang/op_exec.go @@ -56,7 +56,7 @@ func (m *Machine) doOpExec(op Op) { debug.Printf("PEEK STMT: %v\n", s) debug.Printf("%v\n", m) } - fmt.Printf("PEEK STMT: %v\n", s) + //fmt.Printf("PEEK STMT: %v\n", s) // NOTE this could go in the switch statement, and we could // use the EXEC_SWITCH to jump back, rather than putting this @@ -432,7 +432,7 @@ EXEC_SWITCH: if debug { debug.Printf("EXEC: %v\n", s) } - fmt.Printf("EXEC: %v\n", s) + //fmt.Printf("EXEC: %v\n", s) switch cs := s.(type) { case *AssignStmt: switch cs.Op { @@ -487,7 +487,7 @@ EXEC_SWITCH: // All expressions push 1 value except calls, // which push as many as there are results. if _, ok := cs.X.(*CallExpr); ok { - fmt.Println("---CallExpr: ", cs.X) + //fmt.Println("---CallExpr: ", cs.X) m.PushOp(OpPopResults) } else { m.PushOp(OpPopValue) diff --git a/gnovm/pkg/gnolang/op_expressions.go b/gnovm/pkg/gnolang/op_expressions.go index 72d428ae59c..a95261909eb 100644 --- a/gnovm/pkg/gnolang/op_expressions.go +++ b/gnovm/pkg/gnolang/op_expressions.go @@ -16,8 +16,8 @@ func (m *Machine) doOpIndex1() { } iv := m.PopValue() // index xv := m.PeekValue(1) // x - fmt.Println("---doOpIndex1, iv: ", iv) - fmt.Println("---doOpIndex1, xv: ", xv) + //fmt.Println("---doOpIndex1, iv: ", iv) + //fmt.Println("---doOpIndex1, xv: ", xv) switch ct := baseOf(xv.T).(type) { case *MapType: mv := xv.V.(*MapValue) @@ -33,7 +33,7 @@ func (m *Machine) doOpIndex1() { } default: res := xv.GetPointerAtIndex(m.Alloc, m.Store, iv) - fmt.Println("---doOpIndex1, res: ", res.Deref()) + //fmt.Println("---doOpIndex1, res: ", res.Deref()) *xv = res.Deref() // reuse as result } } @@ -47,7 +47,7 @@ func (m *Machine) doOpIndex2() { } iv := m.PeekValue(1) // index xv := m.PeekValue(2) // x - fmt.Println("---doOpIndex2: ", iv) + //fmt.Println("---doOpIndex2: ", iv) switch ct := baseOf(xv.T).(type) { case *MapType: vt := ct.Value @@ -80,12 +80,12 @@ func (m *Machine) doOpIndex2() { } func (m *Machine) doOpSelector() { - fmt.Println("---doOpSelector---") + //fmt.Println("---doOpSelector---") sx := m.PopExpr().(*SelectorExpr) xv := m.PeekValue(1) - fmt.Println("---xv: ", xv) + //fmt.Println("---xv: ", xv) res := xv.GetPointerTo(m.Alloc, m.Store, sx.Path).Deref() - fmt.Println("---doOpSelector, res after Deref: ", res) + //fmt.Println("---doOpSelector, res after Deref: ", res) if debug { m.Printf("-v[S] %v\n", xv) m.Printf("+v[S] %v\n", res) diff --git a/gnovm/pkg/gnolang/ownership.go b/gnovm/pkg/gnolang/ownership.go index e801c7cfb73..67352a7c93e 100644 --- a/gnovm/pkg/gnolang/ownership.go +++ b/gnovm/pkg/gnolang/ownership.go @@ -348,34 +348,14 @@ func (oi *ObjectInfo) GetIsTransient() bool { // XXX, get first accessible object, maybe containing(parent) object, maybe itself. func (tv *TypedValue) GetFirstObject(store Store) Object { - fmt.Println("---GetFirstObject---, tv: ", tv, reflect.TypeOf(tv.V)) - fmt.Println("---tv.T, type of tv.T", tv.T, reflect.TypeOf(tv.T)) - if dt, ok := tv.T.(*DeclaredType); ok { - fmt.Println("---dt: ", dt) - fmt.Println("---dt.Name: ", dt.Name) - fmt.Println("---dt.PkgPath: ", dt.PkgPath) - fmt.Println("---PkgID: ", PkgIDFromPkgPath(dt.PkgPath)) - fmt.Println("---dt.Base: ", dt.Base) - } switch cv := tv.V.(type) { case PointerValue: - println("---pointer value, get base") - if v, ok := cv.TV.V.(Object); ok { - fmt.Println("---v: ", v) - rc := v.GetRefCount() - fmt.Println("---rc: ", rc) - fmt.Println("---v Owner: ", v.GetOwnerID()) - fmt.Println("---v.GetObjectID(): ", v.GetObjectID()) - fmt.Println("---is Attached?", v.GetIsReal()) - } return cv.GetBase(store) case *ArrayValue: return cv case *SliceValue: return cv.GetBase(store) case *StructValue: - println("---struct value") - fmt.Println("---cv.GetObjectID(): ", cv.GetObjectID()) return cv case *FuncValue: return cv.GetClosure(store) @@ -404,13 +384,13 @@ func (tv *TypedValue) GetFirstObject(store Store) Object { // XXX, get first accessible object, maybe containing(parent) object, maybe itself. func (tv *TypedValue) GetFirstObject2(store Store) (obj Object, pkgId PkgID, isRef bool, length int, offset int) { fmt.Println("---GetFirstObject2---, tv: ", tv, reflect.TypeOf(tv.V)) - fmt.Println("---tv.T, type of tv.T", tv.T, reflect.TypeOf(tv.T)) + //fmt.Println("---tv.T, type of tv.T", tv.T, reflect.TypeOf(tv.T)) if dt, ok := tv.T.(*DeclaredType); ok { - fmt.Println("---dt: ", dt) - fmt.Println("---dt.Name: ", dt.Name) - fmt.Println("---dt.PkgPath: ", dt.PkgPath) - fmt.Println("---PkgID: ", PkgIDFromPkgPath(dt.PkgPath)) - fmt.Println("---dt.Base: ", dt.Base) + //fmt.Println("---dt: ", dt) + //fmt.Println("---dt.Name: ", dt.Name) + //fmt.Println("---dt.PkgPath: ", dt.PkgPath) + //fmt.Println("---PkgID: ", PkgIDFromPkgPath(dt.PkgPath)) + //fmt.Println("---dt.Base: ", dt.Base) if IsRealmPath(dt.PkgPath) { pkgId = PkgIDFromPkgPath(dt.PkgPath) } @@ -420,11 +400,11 @@ func (tv *TypedValue) GetFirstObject2(store Store) (obj Object, pkgId PkgID, isR println("---pointer value, get base") if v, ok := cv.TV.V.(Object); ok { fmt.Println("---v: ", v) - rc := v.GetRefCount() - fmt.Println("---rc: ", rc) - fmt.Println("---v Owner: ", v.GetOwnerID()) - fmt.Println("---v.GetObjectID(): ", v.GetObjectID()) - fmt.Println("---is Attached?", v.GetIsReal()) + //rc := v.GetRefCount() + //fmt.Println("---rc: ", rc) + //fmt.Println("---v Owner: ", v.GetOwnerID()) + //fmt.Println("---v.GetObjectID(): ", v.GetObjectID()) + //fmt.Println("---is Attached?", v.GetIsReal()) if dt, ok := cv.TV.T.(*DeclaredType); ok { // b0 = &crossrealm.Bar{A: 1} this is valid @@ -441,22 +421,22 @@ func (tv *TypedValue) GetFirstObject2(store Store) (obj Object, pkgId PkgID, isR return case *ArrayValue: fmt.Println("---array value, T: ", tv.T) - fmt.Println("---Elem PkgPath: ", tv.T.Elem().GetPkgPath()) + //fmt.Println("---Elem PkgPath: ", tv.T.Elem().GetPkgPath()) obj, pkgId, isRef = cv, PkgIDFromPkgPath(tv.T.Elem().GetPkgPath()), false return case *SliceValue: - base := cv.GetBase(store) - fmt.Println("---SliceValue, base: ", base) - fmt.Printf("---SliceValue len: %d, cap:%d, offsetL:%d \n", cv.Length, cv.Maxcap, cv.Offset) - fmt.Println("---tv.T...PkgPath: ", tv.T.Elem().GetPkgPath()) - fmt.Println("---type of base: ", reflect.TypeOf(base)) + //base := cv.GetBase(store) + //fmt.Println("---SliceValue, base: ", base) + //fmt.Printf("---SliceValue len: %d, cap:%d, offsetL:%d \n", cv.Length, cv.Maxcap, cv.Offset) + //fmt.Println("---tv.T...PkgPath: ", tv.T.Elem().GetPkgPath()) + //fmt.Println("---type of base: ", reflect.TypeOf(base)) obj, pkgId, isRef, length, offset = cv.GetBase(store), PkgIDFromPkgPath(tv.T.Elem().GetPkgPath()), true, cv.GetLength(), cv.Offset return case *StructValue: println("---struct value") - fmt.Println("---cv.GetObjectID(): ", cv.GetObjectID()) + //fmt.Println("---cv.GetObjectID(): ", cv.GetObjectID()) obj, isRef = cv, false return case *FuncValue: diff --git a/gnovm/pkg/gnolang/realm.go b/gnovm/pkg/gnolang/realm.go index a3fa623ce48..743200e0645 100644 --- a/gnovm/pkg/gnolang/realm.go +++ b/gnovm/pkg/gnolang/realm.go @@ -135,18 +135,18 @@ func (rlm *Realm) String() string { // associated object. // TODO: func (rlm *Realm) DidUpdate(po, xo, co Object, attached bool) { func (rlm *Realm) DidUpdate(po, xo, co Object) { - fmt.Println("---DidUpdate, rlm.ID: ", rlm.ID) - fmt.Printf("---xo: %v, type of xo: %v\n", xo, reflect.TypeOf(xo)) - fmt.Printf("---co: %v, type of co: %v\n", co, reflect.TypeOf(co)) - - if co != nil { - fmt.Println("---co.LastNewEscapedRealm: ", co.GetLastNewEscapedRealm()) - fmt.Println("---co.GetRefCount: ", co.GetRefCount()) - fmt.Println("---co isReal(attached): ", co.GetIsReal()) - fmt.Println("---co objectID: ", co.GetObjectID()) - } - - fmt.Printf("---po: %v, type of po: %v\n", po, reflect.TypeOf(po)) + //fmt.Println("---DidUpdate, rlm.ID: ", rlm.ID) + //fmt.Printf("---xo: %v, type of xo: %v\n", xo, reflect.TypeOf(xo)) + //fmt.Printf("---co: %v, type of co: %v\n", co, reflect.TypeOf(co)) + // + //if co != nil { + // fmt.Println("---co.LastNewEscapedRealm: ", co.GetLastNewEscapedRealm()) + // fmt.Println("---co.GetRefCount: ", co.GetRefCount()) + // fmt.Println("---co isReal(attached): ", co.GetIsReal()) + // fmt.Println("---co objectID: ", co.GetObjectID()) + //} + + //fmt.Printf("---po: %v, type of po: %v\n", po, reflect.TypeOf(po)) if rlm == nil { return @@ -179,14 +179,14 @@ func (rlm *Realm) DidUpdate(po, xo, co Object) { rlm.MarkDirty(po) if co != nil { - fmt.Println("---co.GetRefCount: ", co.GetRefCount()) + //fmt.Println("---co.GetRefCount: ", co.GetRefCount()) // XXX, inc ref count everytime assignment happens co.IncRefCount() - fmt.Println("---after inc, co.GetRefCount: ", co.GetRefCount()) + //fmt.Println("---after inc, co.GetRefCount: ", co.GetRefCount()) if co.GetRefCount() > 1 { if co.GetIsEscaped() { // XXX, why packageBlock is automatically escaped? - println("---already escaped, should check cross realm?") + //println("---already escaped, should check cross realm?") // already escaped } else { rlm.MarkNewEscapedCheckCrossRealm(nil, co, false, 0, 0) @@ -201,7 +201,7 @@ func (rlm *Realm) DidUpdate(po, xo, co Object) { if xo != nil { xo.DecRefCount() - fmt.Printf("---xo: %v refCount after dec: %v\n", xo, xo.GetRefCount()) + //fmt.Printf("---xo: %v refCount after dec: %v\n", xo, xo.GetRefCount()) if xo.GetRefCount() == 0 { if xo.GetIsReal() { rlm.MarkNewDeleted(xo) @@ -212,25 +212,8 @@ func (rlm *Realm) DidUpdate(po, xo, co Object) { func (rlm *Realm) DidUpdate2(store Store, po, xo, co Object, isRef bool, length, offset int) { fmt.Println("---DidUpdate, rlm.ID: ", rlm.ID) - fmt.Printf("---xo: %v, type of xo: %v\n", xo, reflect.TypeOf(xo)) + //fmt.Printf("---xo: %v, type of xo: %v\n", xo, reflect.TypeOf(xo)) fmt.Printf("---co: %v, type of co: %v\n", co, reflect.TypeOf(co)) - - if co != nil { - if av, ok := co.(*ArrayValue); ok { - fmt.Println("---array value") - fmt.Println("---av: ", av) - fmt.Println("---av.Data: ", av.Data) - fmt.Println("---av.List: ", av.List, len(av.List)) - fmt.Println("---av.List[0]: ", av.List[0]) - } else { - println("not arrayvalue") - } - fmt.Println("---co.LastNewEscapedRealm: ", co.GetLastNewEscapedRealm()) - fmt.Println("---co.GetRefCount: ", co.GetRefCount()) - fmt.Println("---co isReal(attached): ", co.GetIsReal()) - fmt.Println("---co objectID: ", co.GetObjectID()) - } - fmt.Printf("---po: %v, type of po: %v\n", po, reflect.TypeOf(po)) if rlm == nil { @@ -264,12 +247,12 @@ func (rlm *Realm) DidUpdate2(store Store, po, xo, co Object, isRef bool, length, rlm.MarkDirty(po) if co != nil { - fmt.Println("---co.GetRefCount: ", co.GetRefCount()) + //fmt.Println("---co.GetRefCount: ", co.GetRefCount()) // XXX, inc ref count everytime assignment happens co.IncRefCount() fmt.Println("---after inc, co.GetRefCount: ", co.GetRefCount()) if co.GetRefCount() > 1 { - if co.GetIsEscaped() { + if co.GetIsEscaped() { // XXX, this implies attached? // XXX, why packageBlock is automatically escaped? println("---already escaped, should check cross realm?") // already escaped @@ -326,7 +309,8 @@ func checkCrossRealm(store Store, oo Object, offset, length int) { } } } - + case *MapValue: + println("---mapValue...") case *HeapItemValue: fmt.Println("---heapItemValue: ", v) //r := fillValueTV(store, &v.Value) @@ -338,7 +322,11 @@ func checkCrossRealm(store Store, oo Object, offset, length int) { fmt.Println("---offset: ", offset) fmt.Println("---escaped array, check if elements are real") for i := offset; i < length; i++ { - e := oo.(*ArrayValue).List[i] + // XXX, difference between them? + //e := oo.(*ArrayValue).List[i] + //res := oo.(*ArrayValue).GetPointerAtIndexInt2(store, i, nil).Deref() + e := oo.(*ArrayValue).GetPointerAtIndexInt2(store, i, nil).Deref() + fmt.Println("---e: ", e, reflect.TypeOf(e.V)) if _, ok := e.V.(RefValue); ok { // TODO: XXX, does this already enough fmt.Println("---escaped: ", e.V.(RefValue).Escaped) @@ -357,13 +345,13 @@ func checkCrossRealm(store Store, oo Object, offset, length int) { fmt.Println("---e.V: ", e.V) fmt.Println("---e.V: ", reflect.TypeOf(e.V)) - res := oo.(*ArrayValue).GetPointerAtIndexInt2(store, i, nil).Deref() - fmt.Println("---res: ", res) - fmt.Println("---type of res: ", reflect.TypeOf(res.V)) - if p, ok := res.V.(PointerValue); ok { + if p, ok := e.V.(PointerValue); ok { fmt.Println("---p.TV: ", p.TV) + fmt.Println("---p.Index: ", p.Index) fmt.Println("---p.Base: ", p.Base) + //r1 := fillValueTV(store, &p.Base) + rr := fillValueTV(store, p.TV) fmt.Println("---rr: ", rr) @@ -375,23 +363,27 @@ func checkCrossRealm(store Store, oo Object, offset, length int) { } fmt.Println("---sv.ObjectID", sv.GetObjectID()) } + } else { + println("---e.V is not pointer") + if !e.V.(Object).GetIsReal() { + panic("should not happen while reference unreal element from external realm") + } } } } default: - fmt.Println("---v :", v) + //fmt.Println("---v :", v) } } -// TODO: move these crossrealm check logic before 'DidUpdate' +// escaped realm should be reference object func (rlm *Realm) MarkNewEscapedCheckCrossRealm(store Store, oo Object, isRef bool, length, offset int) { - fmt.Println("---MarkNewEscapedCheckCrossRealm---, oo: ", oo) - checkCrossRealm(store, oo, offset, length) - fmt.Println("---rlm.ID: ", rlm.ID) - - fmt.Println("---oo.GetRefCount(): ", oo.GetRefCount()) - fmt.Println("---oo.lastNewRealEscapedRealm: ", oo.GetLastNewEscapedRealm()) - fmt.Println("---oo.GetIsReal: ", oo.GetIsReal()) + fmt.Println("---MarkNewEscapedCheckCrossRealm") + //fmt.Println("---isRef: ", isRef) + //fmt.Println("---rlm.ID: ", rlm.ID) + //fmt.Println("---oo.GetRefCount(): ", oo.GetRefCount()) + //fmt.Println("---oo.lastNewRealEscapedRealm: ", oo.GetLastNewEscapedRealm()) + //fmt.Println("---oo.GetIsReal: ", oo.GetIsReal()) if oo.GetLastNewEscapedRealm() == rlm.ID { return @@ -399,37 +391,7 @@ func (rlm *Realm) MarkNewEscapedCheckCrossRealm(store Store, oo Object, isRef bo if oo.GetLastNewEscapedRealm() != rlm.ID { // crossing realm if isRef { - - if hiv, ok := oo.(*HeapItemValue); ok { - fmt.Println("---hiv: ", hiv) - //r := fillValueTV(store, &hiv.Value) - //fmt.Println("---r: ", r) - //if sv, ok := hiv.Value.V.(*StructValue); ok { - // fmt.Println("---sv: ", sv) - // if !sv.GetIsReal() { - // panic("---sv is not real!!!") - // } - // for _, fv := range sv.Fields { - // rfv := fillValueTV(store, &fv) - // fmt.Println("---rfv: ", rfv) - // if oo, ok := rfv.V.(Object); ok { - // if !oo.GetIsReal() { - // panic(fmt.Sprintf("---should not happen, %v: is not real \n", oo)) - // } - // } - // } - //} - } - - // ===================================================== - - fmt.Println("---length: ", length) - if length != 0 { // TODO: explicit array check - } else { // other than array - if !oo.GetIsReal() { // oo is not attached in the origin realm - panic("should not happen while attempting to attach unattached object by reference from external realm") - } - } + checkCrossRealm(store, oo, offset, length) } else { panic("should not happen while attempting to attach objects by value from external realm") } @@ -439,7 +401,7 @@ func (rlm *Realm) MarkNewEscapedCheckCrossRealm(store Store, oo Object, isRef bo } func (rlm *Realm) MarkNewReal(oo Object) { - fmt.Println("---markNewReal---, oo: ", oo) + //fmt.Println("---markNewReal---, oo: ", oo) if debug { if pv, ok := oo.(*PackageValue); ok { // packages should have no owner. @@ -468,15 +430,15 @@ func (rlm *Realm) MarkNewReal(oo Object) { if rlm.newCreated == nil { rlm.newCreated = make([]Object, 0, 256) } - fmt.Println("---append oo to newCreated object: ", oo) + //fmt.Println("---append oo to newCreated object: ", oo) rlm.newCreated = append(rlm.newCreated, oo) - fmt.Println("---len of new created: ", len(rlm.newCreated)) + //fmt.Println("---len of new created: ", len(rlm.newCreated)) } // mark dirty == updated func (rlm *Realm) MarkDirty(oo Object) { - fmt.Printf("---current rlm: %v: \n", rlm) - fmt.Printf("---Mark Dirty %v: \n", oo) + //fmt.Printf("---current rlm: %v: \n", rlm) + //fmt.Printf("---Mark Dirty %v: \n", oo) if debug { if !oo.GetIsReal() && !oo.GetIsNewReal() { panic("cannot mark unreal object as dirty") @@ -517,7 +479,7 @@ func (rlm *Realm) MarkNewDeleted(oo Object) { } func (rlm *Realm) MarkNewEscaped(oo Object) { - fmt.Println("---MarkNewEscaped---, oo: ", oo) + //fmt.Println("---MarkNewEscaped---, oo: ", oo) if debug { if !oo.GetIsNewReal() && !oo.GetIsReal() { panic("cannot mark unreal object as new escaped") @@ -616,30 +578,15 @@ func (rlm *Realm) FinalizeRealmTransaction(readonly bool, store Store) { // All newly created objects become appended to .created, // and get assigned ids. func (rlm *Realm) processNewCreatedMarks(store Store) { - fmt.Println("---processNewCreatedMarks---") - fmt.Println("---len of newCreated objects:", len(rlm.newCreated)) + //fmt.Println("---processNewCreatedMarks---") + //fmt.Println("---len of newCreated objects:", len(rlm.newCreated)) // Create new objects and their new descendants. //for _, oo := range rlm.newCreated { for i := 0; i < len(rlm.newCreated); i++ { oo := rlm.newCreated[i] - fmt.Printf("---oo[%d] is %v:\n", i, oo) - // TODO: here check embedded object cross - //more := getChildObjects2(store, oo) - //fmt.Println("---children of oo: ", more) - //fmt.Println("---len of children: ", len(more)) - //for i, c := range more { - // fmt.Printf("[%d] of children is: %v\n", i, c) - // //fmt.Printf("---%p\n", c) - // if c.GetIsCrossRealm() { - // panic("---cross realm") - // } else { - // println("---not cross realm") - // } - //} - fmt.Println("---processNewCreatedMarks, oo.GetRefCount(): ", oo.GetRefCount()) - //if oo.GetIsCrossRealm() { - // fmt.Println("---should not attach value with type defined in other realm") - // //panic("---!!!") + //fmt.Printf("---oo[%d] is %v:\n", i, oo) + //if _, ok := oo.(*BoundMethodValue); ok { + // panic("should not happen persist bound method") //} if debug { if oo.GetIsDirty() { @@ -668,11 +615,11 @@ func (rlm *Realm) processNewCreatedMarks(store Store) { // oo must be marked new-real, and ref-count already incremented. func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { - fmt.Println("---incRefCreatedDescendants, rlm.ID: ", rlm.ID) - fmt.Println("---incRefCreatedDescendants oo.GetLastEscapedRealm: ", oo.GetLastNewEscapedRealm()) + //fmt.Println("---incRefCreatedDescendants, rlm.ID: ", rlm.ID) + //fmt.Println("---incRefCreatedDescendants oo.GetLastEscapedRealm: ", oo.GetLastNewEscapedRealm()) + //fmt.Println("---incRefCreatedDescendants from oo: ", oo) + //fmt.Println("---incRefCreatedDescendants, oo.GetObjectID: ", oo.GetObjectID()) - fmt.Println("---incRefCreatedDescendants from oo: ", oo) - fmt.Println("---incRefCreatedDescendants, oo.GetObjectID: ", oo.GetObjectID()) if debug { if oo.GetIsDirty() { panic("cannot increase reference of descendants of dirty objects") @@ -684,8 +631,8 @@ func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { // XXX, oo must be new real here, it's not escaped if !oo.GetLastNewEscapedRealm().IsZero() && oo.GetLastNewEscapedRealm() != rlm.ID { - fmt.Println("---oo.GetLastNewEscapedRealm: ", oo.GetLastNewEscapedRealm()) - fmt.Println("---rlm.ID: ", rlm.ID) + //fmt.Println("---oo.GetLastNewEscapedRealm: ", oo.GetLastNewEscapedRealm()) + //fmt.Println("---rlm.ID: ", rlm.ID) panic("should not happen while attempting to attach new real object from external realm") } @@ -703,9 +650,9 @@ func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { // recurse for children. more := getChildObjects2(store, oo) //fmt.Println("---incRefCreatedDescendants, more: ", more) - fmt.Println("---len of more: ", len(more)) - for i, child := range more { - fmt.Printf("---[%d]child: %v, type of child: %v \n", i, child, reflect.TypeOf(child)) + //fmt.Println("---len of more: ", len(more)) + for _, child := range more { + //fmt.Printf("---[%d]child: %v, type of child: %v \n", i, child, reflect.TypeOf(child)) //fmt.Printf("---child addr: %p\n", child) if _, ok := child.(*PackageValue); ok { if debug { @@ -718,35 +665,35 @@ func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { } child.IncRefCount() rc := child.GetRefCount() - fmt.Println("---rc after inc: ", rc) + //fmt.Println("---rc after inc: ", rc) if rc == 1 { if child.GetIsReal() { - fmt.Println("---child is real, child: ", child) + //fmt.Println("---child is real, child: ", child) // a deleted real became undeleted. child.SetOwner(oo) rlm.MarkDirty(child) } else { - fmt.Println("---child NOT real, child: ", child) + //fmt.Println("---child NOT real, child: ", child) // a (possibly pre-existing) new object // became real (again). // NOTE: may already be marked for first gen // newCreated or updated. //fmt.Println("---Set owner to be: ", oo) - println("---set owner") + //println("---set owner") child.SetOwner(oo) rlm.incRefCreatedDescendants(store, child) child.SetIsNewReal(true) } } else if rc > 1 { if child.GetIsEscaped() { - fmt.Println("---child is escaped, child: ", child) + //fmt.Println("---child is escaped, child: ", child) // already escaped, do nothing. } else { // NOTE: do not unset owner here, // may become unescaped later // in processNewEscapedMarks(). // NOTE: may already be escaped. - fmt.Println("---in recursive, mark new escaped, child: ", child) + //fmt.Println("---in recursive, mark new escaped, child: ", child) rlm.MarkNewEscaped(child) } } else { @@ -764,9 +711,9 @@ func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { // to rlm.deleted. // Must run *after* processNewCreatedMarks(). func (rlm *Realm) processNewDeletedMarks(store Store) { - fmt.Println("---processNewDeletedMarks---") + //fmt.Println("---processNewDeletedMarks---") for _, oo := range rlm.newDeleted { - fmt.Println("---oo: ", oo, oo.GetRefCount()) + //fmt.Println("---oo: ", oo, oo.GetRefCount()) if debug { if oo.GetObjectID().IsZero() { panic("new deleted mark should have an object ID") @@ -829,7 +776,7 @@ func (rlm *Realm) decRefDeletedDescendants(store Store, oo Object) { // objects get their original owners marked dirty (to be further // marked via markDirtyAncestors). func (rlm *Realm) processNewEscapedMarks(store Store) { - fmt.Println("---processNewEscapedMarks---") + //fmt.Println("---processNewEscapedMarks---") escaped := make([]Object, 0, len(rlm.newEscaped)) // These are those marked by MarkNewEscaped(), // regardless of whether new-real or was real, @@ -837,11 +784,11 @@ func (rlm *Realm) processNewEscapedMarks(store Store) { // (and never can be unescaped,) // except for new-reals that get demoted // because ref-count isn't >= 2. - for i, eo := range rlm.newEscaped { - fmt.Printf("---processNewEscapedMarks, [%d]eo: %v\n", i, eo) - fmt.Println("---eo.GetLastEscapedRealm: ", eo.GetLastNewEscapedRealm()) - fmt.Println("---eo.GetRefCount(): ", eo.GetRefCount()) - fmt.Println("---rlm.ID: ", rlm.ID) + for _, eo := range rlm.newEscaped { + //fmt.Printf("---processNewEscapedMarks, [%d]eo: %v\n", i, eo) + //fmt.Println("---eo.GetLastEscapedRealm: ", eo.GetLastNewEscapedRealm()) + //fmt.Println("---eo.GetRefCount(): ", eo.GetRefCount()) + //fmt.Println("---rlm.ID: ", rlm.ID) if debug { if !eo.GetIsNewEscaped() { panic("new escaped mark not marked as new escaped") @@ -875,14 +822,14 @@ func (rlm *Realm) processNewEscapedMarks(store Store) { // will be saved regardless. } else { // exists, mark dirty. - fmt.Println("---exists, mark dirty, po: ", po) + //fmt.Println("---exists, mark dirty, po: ", po) rlm.MarkDirty(po) } if eo.GetObjectID().IsZero() { panic("new escaped mark has no object ID") } // escaped has no owner. - println("---escaped has no owner") + //println("---escaped has no owner") eo.SetOwner(nil) } } @@ -897,7 +844,7 @@ func (rlm *Realm) processNewEscapedMarks(store Store) { // (ancestors) must be marked as dirty to update the // hash tree. func (rlm *Realm) markDirtyAncestors(store Store) { - fmt.Println("---markDirtyAncestors---") + //fmt.Println("---markDirtyAncestors---") markAncestorsOne := func(oo Object) { for { if pv, ok := oo.(*PackageValue); ok { @@ -966,26 +913,26 @@ func (rlm *Realm) markDirtyAncestors(store Store) { // Saves .created and .updated objects. func (rlm *Realm) saveUnsavedObjects(store Store) { - fmt.Println("---saveUnsavedObjects, new created, new updated---") - fmt.Println("---len of new created: ", len(rlm.created)) - fmt.Println("---len of new updated: ", len(rlm.updated)) + //fmt.Println("---saveUnsavedObjects, new created, new updated---") + //fmt.Println("---len of new created: ", len(rlm.created)) + //fmt.Println("---len of new updated: ", len(rlm.updated)) for _, co := range rlm.created { - fmt.Println("------saveUnsavedObject, co: ", co) + //fmt.Println("------saveUnsavedObject, co: ", co) // for i := len(rlm.created) - 1; i >= 0; i-- { // co := rlm.created[i] if !co.GetIsNewReal() { - println("---not new real") + //println("---not new real") // might have happened already as child // of something else created. continue } else { - println("---new real") + //println("---new real") rlm.saveUnsavedObjectRecursively(store, co) } } for _, uo := range rlm.updated { - fmt.Println("---uo: ", uo) - // for i := len(rlm.updated) - 1; i >= 0; i-- { + //fmt.Println("---uo: ", uo) + // uo := rlm.updated[i] if !uo.GetIsDirty() { // might have happened already as child @@ -999,7 +946,7 @@ func (rlm *Realm) saveUnsavedObjects(store Store) { // store unsaved children first. func (rlm *Realm) saveUnsavedObjectRecursively(store Store, oo Object) { - fmt.Println("---saveUnsavedObjectRecursively, oo: ", oo) + //fmt.Println("---saveUnsavedObjectRecursively, oo: ", oo) if debug { if !oo.GetIsNewReal() && !oo.GetIsDirty() { panic("cannot save new real or non-dirty objects") @@ -1018,14 +965,14 @@ func (rlm *Realm) saveUnsavedObjectRecursively(store Store, oo Object) { } // first, save unsaved children. unsaved := getUnsavedChildObjects(oo) - fmt.Println("---unsaved: ", unsaved) + //fmt.Println("---unsaved: ", unsaved) for _, uch := range unsaved { - fmt.Println("---uch: ", uch) - fmt.Println("---uch.GetOwnerID(): ", uch.GetOwnerID()) - fmt.Println("---uch.GetRefCount(): ", uch.GetRefCount()) - fmt.Println("---type of uch: ", reflect.TypeOf(uch)) + //fmt.Println("---uch: ", uch) + //fmt.Println("---uch.GetOwnerID(): ", uch.GetOwnerID()) + //fmt.Println("---uch.GetRefCount(): ", uch.GetRefCount()) + //fmt.Println("---type of uch: ", reflect.TypeOf(uch)) if uch.GetIsEscaped() || uch.GetIsNewEscaped() { - fmt.Println("---uch is escaped or new escaped") + //fmt.Println("---uch is escaped or new escaped") // no need to save preemptively. } else { rlm.saveUnsavedObjectRecursively(store, uch) @@ -1033,7 +980,7 @@ func (rlm *Realm) saveUnsavedObjectRecursively(store Store, oo Object) { } // then, save self. if oo.GetIsNewReal() { - fmt.Println("---oo is new real: ", oo) + //fmt.Println("---oo is new real: ", oo) // save created object. if debug { if oo.GetIsDirty() { @@ -1043,7 +990,7 @@ func (rlm *Realm) saveUnsavedObjectRecursively(store Store, oo Object) { rlm.saveObject(store, oo) oo.SetIsNewReal(false) } else { - fmt.Println("---oo is not new real, update it: ", oo) + //fmt.Println("---oo is not new real, update it: ", oo) // update existing object. if debug { if !oo.GetIsDirty() { @@ -1062,9 +1009,9 @@ func (rlm *Realm) saveUnsavedObjectRecursively(store Store, oo Object) { } func (rlm *Realm) saveObject(store Store, oo Object) { - fmt.Println("---saveObject: ", oo) + //fmt.Println("---saveObject: ", oo) oid := oo.GetObjectID() - fmt.Println("---saveObject: ", oid) + //fmt.Println("---saveObject: ", oid) if oid.IsZero() { panic("unexpected zero object id") } @@ -1087,7 +1034,7 @@ func (rlm *Realm) saveObject(store Store, oo Object) { // removeDeletedObjects func (rlm *Realm) removeDeletedObjects(store Store) { - fmt.Println("---removeDeletedObjects---") + //fmt.Println("---removeDeletedObjects---") for _, do := range rlm.deleted { store.DelObject(do) } @@ -1174,10 +1121,10 @@ func getChildObjects(val Value, more []Value) []Value { more = getSelfOrChildObjects(cv.Base, more) return more case *StructValue: - println("---struct value") + //println("---struct value") for _, ctv := range cv.Fields { // TODO: we have type infos here, so check check cross realm logic - fmt.Println("---ctv: ", ctv) + //fmt.Println("---ctv: ", ctv) more = getSelfOrChildObjects(ctv.V, more) } return more @@ -1227,7 +1174,7 @@ func getChildObjects(val Value, more []Value) []Value { // like getChildObjects() but loads RefValues into objects. func getChildObjects2(store Store, val Value) []Object { - fmt.Println("---getChildObjects2, val: ", val) + //fmt.Println("---getChildObjects2, val: ", val) chos := getChildObjects(val, nil) //fmt.Println("---chos: ", chos) objs := make([]Object, 0, len(chos)) @@ -1405,7 +1352,7 @@ func copyTypeWithRefs(typ Type) Type { // Also checks for integrity of immediate children -- they must already be // persistent (real), and not dirty, or else this function panics. func copyValueWithRefs(val Value) Value { - fmt.Println("---copyValueWithRefs, val: ", val) + //fmt.Println("---copyValueWithRefs, val: ", val) switch cv := val.(type) { case nil: return nil @@ -1768,14 +1715,14 @@ func (rlm *Realm) nextObjectID() ObjectID { // Object gets its id set (panics if already set), and becomes // marked as new and real. func (rlm *Realm) assignNewObjectID(oo Object) ObjectID { - fmt.Printf("---assignNewObjectID, rlm: %v, oo: %v, oo: %p\n", rlm, oo, oo) + //fmt.Printf("---assignNewObjectID, rlm: %v, oo: %v, oo: %p\n", rlm, oo, oo) oid := oo.GetObjectID() - fmt.Println("---oid: ", oid) + //fmt.Println("---oid: ", oid) if !oid.IsZero() { panic("unexpected non-zero object id") } noid := rlm.nextObjectID() - fmt.Println("---noid: ", noid) + //fmt.Println("---noid: ", noid) oo.SetObjectID(noid) return noid } @@ -1791,7 +1738,7 @@ func toRefNode(bn BlockNode) RefNode { } func toRefValue(val Value) RefValue { - fmt.Println("---toRefValue", val) + //fmt.Println("---toRefValue", val) // TODO use type switch stmt. if ref, ok := val.(RefValue); ok { return ref @@ -1865,7 +1812,7 @@ func ensureUniq(oozz ...[]Object) { } func refOrCopyValue(tv TypedValue) TypedValue { - fmt.Println("---refOrCopyValue:", tv) + //fmt.Println("---refOrCopyValue:", tv) if tv.T != nil { tv.T = refOrCopyType(tv.T) } diff --git a/gnovm/pkg/gnolang/store.go b/gnovm/pkg/gnolang/store.go index 69302a23a6d..8db812ae333 100644 --- a/gnovm/pkg/gnolang/store.go +++ b/gnovm/pkg/gnolang/store.go @@ -324,11 +324,11 @@ func (ds *defaultStore) loadObjectSafe(oid ObjectID) Object { // NOTE: unlike GetObject(), SetObject() is also used to persist updated // package values. func (ds *defaultStore) SetObject(oo Object) { - fmt.Println("---SetObject---,oo: ", oo) + //fmt.Println("---SetObject---,oo: ", oo) oid := oo.GetObjectID() // replace children/fields with Ref. o2 := copyValueWithRefs(oo) - fmt.Println("---SetObject, o2: ", o2) + //fmt.Println("---SetObject, o2: ", o2) // marshal to binary. bz := amino.MustMarshalAny(o2) // set hash. @@ -363,10 +363,10 @@ func (ds *defaultStore) SetObject(oo Object) { if ds.opslog != nil { var op StoreOpType if oo.GetIsNewReal() { - fmt.Println("---SetObject, oo is new real, oo: ", oo) + //fmt.Println("---SetObject, oo is new real, oo: ", oo) op = StoreOpNew } else { - fmt.Println("---SetObject, oo is mod, oo: ", oo) + //fmt.Println("---SetObject, oo is mod, oo: ", oo) op = StoreOpMod } ds.opslog = append(ds.opslog, @@ -382,7 +382,7 @@ func (ds *defaultStore) SetObject(oo Object) { } func (ds *defaultStore) DelObject(oo Object) { - fmt.Println("---DelObject, oo: ", oo) + //fmt.Println("---DelObject, oo: ", oo) oid := oo.GetObjectID() // delete from cache. delete(ds.cacheObjects, oid) diff --git a/gnovm/pkg/gnolang/values.go b/gnovm/pkg/gnolang/values.go index f4554fd8a89..5f4c527d800 100644 --- a/gnovm/pkg/gnolang/values.go +++ b/gnovm/pkg/gnolang/values.go @@ -214,9 +214,9 @@ func (pv *PointerValue) GetBase(store Store) Object { // TODO: document as something that enables into-native assignment. // TODO: maybe consider this as entrypoint for DataByteValue too? func (pv PointerValue) Assign2(alloc *Allocator, store Store, rlm *Realm, tv2 TypedValue, cu bool) { - fmt.Println("---Assign2, pv: ", pv) - fmt.Println("---Assign2, tv2: ", tv2) - fmt.Println("---Assign2, realm: ", rlm) + //fmt.Println("---Assign2, pv: ", pv) + //fmt.Println("---Assign2, tv2: ", tv2) + //fmt.Println("---Assign2, realm: ", rlm) // Special cases. if pv.Index == PointerIndexNative { // Special case if extended object && native. @@ -290,11 +290,11 @@ func (pv PointerValue) Assign2(alloc *Allocator, store Store, rlm *Realm, tv2 Ty // General case if rlm != nil && pv.Base != nil { oo1 := pv.TV.GetFirstObject(store) - fmt.Println("---oo1: ", oo1) + //fmt.Println("---oo1: ", oo1) pv.TV.Assign(alloc, tv2, cu) oo2, pkgId, isRef, length, offset := pv.TV.GetFirstObject2(store) - fmt.Println("---oo2: ", oo2) - fmt.Println("---oo2 pkgId: ", pkgId) + //fmt.Println("---oo2: ", oo2) + //fmt.Println("---oo2 pkgId: ", pkgId) if oo2 != nil { oo2.SetLastNewEscapedRealm(pkgId) // attach origin package info } @@ -523,7 +523,7 @@ func (sv *StructValue) GetSubrefPointerTo(store Store, st *StructType, path Valu } func (sv *StructValue) Copy(alloc *Allocator) *StructValue { - fmt.Println("---StructValue copy, sv: ", sv) + //fmt.Println("---StructValue copy, sv: ", sv) /* TODO consider second refcount field if sv.GetRefCount() == 0 { return sv @@ -1051,7 +1051,7 @@ func (tv *TypedValue) ClearNum() { } func (tv TypedValue) Copy(alloc *Allocator) (cp TypedValue) { - fmt.Println("---Copy, type of tv.V: ", reflect.TypeOf(tv.V)) + //fmt.Println("---Copy, type of tv.V: ", reflect.TypeOf(tv.V)) switch cv := tv.V.(type) { case BigintValue: cp.T = tv.T @@ -1066,7 +1066,7 @@ func (tv TypedValue) Copy(alloc *Allocator) (cp TypedValue) { cp.T = tv.T cp.V = cv.Copy(alloc) default: - println("---default") + //println("---default") cp = tv } return @@ -1705,8 +1705,8 @@ func (tv *TypedValue) ComputeMapKey(store Store, omitType bool) MapKey { // cu: convert untyped after assignment. pass false // for const definitions, but true for all else. func (tv *TypedValue) Assign(alloc *Allocator, tv2 TypedValue, cu bool) { - fmt.Println("---Assign, tv: ", tv) - fmt.Println("---Assign, tv2: ", tv2, reflect.TypeOf(tv2)) + //fmt.Println("---Assign, tv: ", tv) + //fmt.Println("---Assign, tv2: ", tv2, reflect.TypeOf(tv2)) if debug { if tv.T == DataByteType { // assignment to data byte types should only @@ -1731,10 +1731,10 @@ func (tv *TypedValue) Assign(alloc *Allocator, tv2 TypedValue, cu bool) { // allocated, *Allocator.AllocatePointer() is called separately, // as in OpRef. func (tv *TypedValue) GetPointerTo(alloc *Allocator, store Store, path ValuePath) PointerValue { - fmt.Println("---GetPointerTo, tv: ", tv) - fmt.Println("---rt of tv: ", reflect.TypeOf(tv)) - fmt.Println("---path: ", path) - fmt.Println("---path.Type: ", path.Type) + //fmt.Println("---GetPointerTo, tv: ", tv) + //fmt.Println("---rt of tv: ", reflect.TypeOf(tv)) + //fmt.Println("---path: ", path) + //fmt.Println("---path.Type: ", path.Type) if debug { if tv.IsUndefined() { panic("GetPointerTo() on undefined value") @@ -1832,7 +1832,7 @@ func (tv *TypedValue) GetPointerTo(alloc *Allocator, store Store, path ValuePath fillValueTV(store, dtv) } - fmt.Println("---2, path.Type: ", path.Type) + //fmt.Println("---2, path.Type: ", path.Type) switch path.Type { case VPBlock: switch dtv.T.(type) { @@ -1845,12 +1845,12 @@ func (tv *TypedValue) GetPointerTo(alloc *Allocator, store Store, path ValuePath case VPField: switch baseOf(dtv.T).(type) { case *StructType: - println("---StructType") - fmt.Println("---dtv: ", dtv) - fmt.Println("---return pointer of dtv: ", dtv.V.(*StructValue).GetPointerTo(store, path)) + //println("---StructType") + //fmt.Println("---dtv: ", dtv) + //fmt.Println("---return pointer of dtv: ", dtv.V.(*StructValue).GetPointerTo(store, path)) return dtv.V.(*StructValue).GetPointerTo(store, path) case *TypeType: - println("---TypeType") + //println("---TypeType") switch t := dtv.V.(TypeValue).Type.(type) { case *PointerType: dt := t.Elt.(*DeclaredType) @@ -1906,12 +1906,12 @@ func (tv *TypedValue) GetPointerTo(alloc *Allocator, store Store, path ValuePath panic("should not happen") } } - fmt.Println("---dtv: ", dtv) - fmt.Printf("---dtv addr: %p\n", dtv) + //fmt.Println("---dtv: ", dtv) + //fmt.Printf("---dtv addr: %p\n", dtv) dtv2 := dtv.Copy(alloc) - fmt.Println("---dtv2: ", dtv2) - fmt.Printf("---dtv2 addr: %p\n", dtv2) + //fmt.Println("---dtv2: ", dtv2) + //fmt.Printf("---dtv2 addr: %p\n", dtv2) alloc.AllocateBoundMethod() bmv := &BoundMethodValue{ @@ -2067,7 +2067,7 @@ func (tv *TypedValue) GetPointerAtIndexInt(store Store, ii int) PointerValue { } func (tv *TypedValue) GetPointerAtIndex(alloc *Allocator, store Store, iv *TypedValue) PointerValue { - fmt.Println("---tv, GetPointerAtIndex: ", tv) + //fmt.Println("---tv, GetPointerAtIndex: ", tv) switch bt := baseOf(tv.T).(type) { case PrimitiveType: if bt == StringType || bt == UntypedStringType { @@ -2672,20 +2672,20 @@ func typedString(s string) TypedValue { } func fillValueTV(store Store, tv *TypedValue) *TypedValue { - fmt.Println("---fillValueTV, tv: ", tv) + //fmt.Println("---fillValueTV, tv: ", tv) switch cv := tv.V.(type) { case RefValue: - println("---tv.V RefValue") - fmt.Println("---cv: ", cv) + //println("---tv.V RefValue") + //fmt.Println("---cv: ", cv) if cv.PkgPath != "" { // load package tv.V = store.GetPackage(cv.PkgPath, false) } else { // load object // XXX XXX allocate object. tv.V = store.GetObject(cv.ObjectID) - fmt.Println("---tv.V: ", tv.V) + //fmt.Println("---tv.V: ", tv.V) } case PointerValue: - fmt.Println("---PointerValue") + //fmt.Println("---PointerValue") // As a special case, cv.Base is filled // and cv.TV set appropriately. // Alternatively, could implement @@ -2693,9 +2693,9 @@ func fillValueTV(store Store, tv *TypedValue) *TypedValue { // but for execution speed traded off for // loading speed, we do the following for now: if ref, ok := cv.Base.(RefValue); ok { - fmt.Println("---cv.Base: ", ref) + //fmt.Println("---cv.Base: ", ref) base := store.GetObject(ref.ObjectID).(Value) - fmt.Println("---base: ", base) + //fmt.Println("---base: ", base) cv.Base = base switch cb := base.(type) { case *ArrayValue: @@ -2714,7 +2714,7 @@ func fillValueTV(store Store, tv *TypedValue) *TypedValue { vpv := cb.GetPointerToInt(store, cv.Index) cv.TV = vpv.TV // TODO optimize? case *HeapItemValue: - fmt.Println("---HeapItemValue: ", cb.Value) + //fmt.Println("---HeapItemValue: ", cb.Value) cv.TV = &cb.Value default: panic("should not happen") diff --git a/gnovm/tests/files/zrealm_crossrealm10_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm10_stdlibs.gno deleted file mode 100644 index 73ad3ea74d7..00000000000 --- a/gnovm/tests/files/zrealm_crossrealm10_stdlibs.gno +++ /dev/null @@ -1,14 +0,0 @@ -// PKGPATH: gno.land/r/crossrealm_test -package crossrealm_test - -import ( - "gno.land/p/demo/tests" -) - -func main() { - tests.ModifyTestRealmObject2c() - println("done") -} - -// Error: -// cannot modify external-realm or non-realm object diff --git a/gnovm/tests/files/zrealm_crossrealm11_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm11_stdlibs.gno deleted file mode 100644 index e6f33c50654..00000000000 --- a/gnovm/tests/files/zrealm_crossrealm11_stdlibs.gno +++ /dev/null @@ -1,146 +0,0 @@ -// PKGPATH: gno.land/r/crossrealm_test -package crossrealm_test - -import ( - ptests "gno.land/p/demo/tests" - "gno.land/p/demo/ufmt" - rtests "gno.land/r/demo/tests" - "std" -) - -func getPrevRealm() std.Realm { - return std.PrevRealm() -} - -func Exec(fn func()) { - fn() -} - -func main() { - // Create a map of the potential callers, this will give more understandable - // output than the bech32 addresses. - callersByAddr := make(map[std.Address]string) - for _, caller := range []string{ - "user1.gno", "gno.land/r/crossrealm_test", "gno.land/r/demo/tests", - } { - addr := std.DerivePkgAddr(caller) - callersByAddr[addr] = caller - } - - assertRealm := func(r std.Realm) { - pkgPath := callersByAddr[r.Addr()] - if r.IsUser() && pkgPath != "user1.gno" { - panic(ufmt.Sprintf("ERROR: expected: 'user1.gno', got:'%s'", pkgPath)) - } else if !r.IsUser() && pkgPath != r.PkgPath() { - panic(ufmt.Sprintf("ERROR: expected: '%s', got: '%s'", pkgPath, r.PkgPath())) - } - } - - tests := []struct { - callStackAdd string - callerFn func() std.Realm - }{ - { - callStackAdd: "", - callerFn: std.PrevRealm, - }, - { - callStackAdd: " -> r/crossrealm_test.getPrevRealm", - callerFn: getPrevRealm, - }, - { - callStackAdd: " -> p/demo/tests", - callerFn: ptests.GetPrevRealm, - }, - { - callStackAdd: " -> p/demo/tests -> p/demo/tests/subtests", - callerFn: ptests.GetPSubtestsPrevRealm, - }, - { - callStackAdd: " -> r/demo/tests", - callerFn: rtests.GetPrevRealm, - }, - { - callStackAdd: " -> r/demo/tests -> r/demo/tests/subtests", - callerFn: rtests.GetRSubtestsPrevRealm, - }, - { - callStackAdd: " -> p/demo/tests -> r/demo/tests", - callerFn: ptests.GetRTestsGetPrevRealm, - }, - } - - println("---") // needed to have space prefixes - printColumns("STACK", "std.PrevRealm") - printColumns("-----", "------------------") - - baseCallStack := "user1.gno -> r/crossrealm_test.main" - for i, tt := range tests { - printColumns(baseCallStack+tt.callStackAdd, callersByAddr[tt.callerFn().Addr()]) - Exec(func() { - r := tt.callerFn() - assertRealm(r) - printColumns(baseCallStack+" -> r/crossrealm_test.Exec"+tt.callStackAdd, callersByAddr[r.Addr()]) - }) - rtests.Exec(func() { - r := tt.callerFn() - assertRealm(r) - printColumns(baseCallStack+" -> r/demo/tests.Exec"+tt.callStackAdd, callersByAddr[r.Addr()]) - }) - ptests.Exec(func() { - r := tt.callerFn() - assertRealm(r) - printColumns(baseCallStack+" -> p/demo/tests.Exec"+tt.callStackAdd, callersByAddr[r.Addr()]) - }) - } -} - -func printColumns(left, right string) { - const w = 105 - - output := "" - padding := w - len(left) - - // strings.Repeat is not always available when using various imports modes. - for i := 0; i < padding; i++ { - output += " " - } - - output += left - output += " = " - output += right - println(output) -} - -// Output: -// --- -// STACK = std.PrevRealm -// ----- = ------------------ -// user1.gno -> r/crossrealm_test.main = user1.gno -// user1.gno -> r/crossrealm_test.main -> r/crossrealm_test.Exec = user1.gno -// user1.gno -> r/crossrealm_test.main -> r/demo/tests.Exec = gno.land/r/demo/tests -// user1.gno -> r/crossrealm_test.main -> p/demo/tests.Exec = user1.gno -// user1.gno -> r/crossrealm_test.main -> r/crossrealm_test.getPrevRealm = user1.gno -// user1.gno -> r/crossrealm_test.main -> r/crossrealm_test.Exec -> r/crossrealm_test.getPrevRealm = user1.gno -// user1.gno -> r/crossrealm_test.main -> r/demo/tests.Exec -> r/crossrealm_test.getPrevRealm = gno.land/r/demo/tests -// user1.gno -> r/crossrealm_test.main -> p/demo/tests.Exec -> r/crossrealm_test.getPrevRealm = user1.gno -// user1.gno -> r/crossrealm_test.main -> p/demo/tests = user1.gno -// user1.gno -> r/crossrealm_test.main -> r/crossrealm_test.Exec -> p/demo/tests = user1.gno -// user1.gno -> r/crossrealm_test.main -> r/demo/tests.Exec -> p/demo/tests = gno.land/r/demo/tests -// user1.gno -> r/crossrealm_test.main -> p/demo/tests.Exec -> p/demo/tests = user1.gno -// user1.gno -> r/crossrealm_test.main -> p/demo/tests -> p/demo/tests/subtests = user1.gno -// user1.gno -> r/crossrealm_test.main -> r/crossrealm_test.Exec -> p/demo/tests -> p/demo/tests/subtests = user1.gno -// user1.gno -> r/crossrealm_test.main -> r/demo/tests.Exec -> p/demo/tests -> p/demo/tests/subtests = gno.land/r/demo/tests -// user1.gno -> r/crossrealm_test.main -> p/demo/tests.Exec -> p/demo/tests -> p/demo/tests/subtests = user1.gno -// user1.gno -> r/crossrealm_test.main -> r/demo/tests = gno.land/r/crossrealm_test -// user1.gno -> r/crossrealm_test.main -> r/crossrealm_test.Exec -> r/demo/tests = gno.land/r/crossrealm_test -// user1.gno -> r/crossrealm_test.main -> r/demo/tests.Exec -> r/demo/tests = gno.land/r/crossrealm_test -// user1.gno -> r/crossrealm_test.main -> p/demo/tests.Exec -> r/demo/tests = gno.land/r/crossrealm_test -// user1.gno -> r/crossrealm_test.main -> r/demo/tests -> r/demo/tests/subtests = gno.land/r/demo/tests -// user1.gno -> r/crossrealm_test.main -> r/crossrealm_test.Exec -> r/demo/tests -> r/demo/tests/subtests = gno.land/r/demo/tests -// user1.gno -> r/crossrealm_test.main -> r/demo/tests.Exec -> r/demo/tests -> r/demo/tests/subtests = gno.land/r/demo/tests -// user1.gno -> r/crossrealm_test.main -> p/demo/tests.Exec -> r/demo/tests -> r/demo/tests/subtests = gno.land/r/demo/tests -// user1.gno -> r/crossrealm_test.main -> p/demo/tests -> r/demo/tests = gno.land/r/crossrealm_test -// user1.gno -> r/crossrealm_test.main -> r/crossrealm_test.Exec -> p/demo/tests -> r/demo/tests = gno.land/r/crossrealm_test -// user1.gno -> r/crossrealm_test.main -> r/demo/tests.Exec -> p/demo/tests -> r/demo/tests = gno.land/r/crossrealm_test -// user1.gno -> r/crossrealm_test.main -> p/demo/tests.Exec -> p/demo/tests -> r/demo/tests = gno.land/r/crossrealm_test diff --git a/gnovm/tests/files/zrealm_crossrealm12_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm12_stdlibs.gno deleted file mode 100644 index f2f229cd5de..00000000000 --- a/gnovm/tests/files/zrealm_crossrealm12_stdlibs.gno +++ /dev/null @@ -1,37 +0,0 @@ -// PKGPATH: gno.land/r/crossrealm_test -package crossrealm_test - -import ( - "fmt" - "std" - - psubtests "gno.land/p/demo/tests/subtests" - rsubtests "gno.land/r/demo/tests/subtests" -) - -func main() { - tests := []struct { - fn func() std.Realm - }{ - {std.CurrentRealm}, - {psubtests.GetCurrentRealm}, - {rsubtests.GetCurrentRealm}, - } - - for _, test := range tests { - r := test.fn() - - if std.DerivePkgAddr(r.PkgPath()) != r.Addr() { - panic(fmt.Sprintf("ERROR: expected: %v, got: %v", - std.DerivePkgAddr(r.PkgPath()), r.Addr(), - )) - } - - println(r.PkgPath(), r.Addr()) - } -} - -// Output: -// gno.land/r/crossrealm_test g1vla5mffzum6060t99u4xhm8mnhgxr0sz4k574p -// gno.land/r/crossrealm_test g1vla5mffzum6060t99u4xhm8mnhgxr0sz4k574p -// gno.land/r/demo/tests/subtests g13g48xnr7lzxsrvny0uf6lhx0cfaxy4n0n5geuf diff --git a/gnovm/tests/files/zrealm_crossrealm13_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm13_stdlibs.gno deleted file mode 100644 index 4daeb6de366..00000000000 --- a/gnovm/tests/files/zrealm_crossrealm13_stdlibs.gno +++ /dev/null @@ -1,48 +0,0 @@ -package main - -import ( - "std" -) - -func main() { - PrintRealm() - println(pad("CurrentRealm:"), std.CurrentRealm()) - println(pad("PrevRealm:"), std.PrevRealm()) - std.TestSetRealm(std.NewUserRealm("g1user")) - PrintRealm() - println(pad("CurrentRealm:"), std.CurrentRealm()) - println(pad("PrevRealm:"), std.PrevRealm()) - std.TestSetRealm(std.NewCodeRealm("gno.land/r/demo/users")) - PrintRealm() - println(pad("CurrentRealm:"), std.CurrentRealm()) - println(pad("PrevRealm:"), std.PrevRealm()) -} - -func pad(s string) string { - for len(s) < 26 { - s += " " - } - return s -} - -func PrintRealm() { - println(pad("PrintRealm: CurrentRealm:"), std.CurrentRealm()) - println(pad("PrintRealm: PrevRealm:"), std.PrevRealm()) -} - -// Because this is the context of a package, using PrintRealm() -// should not change the output of the main function. - -// Output: -// PrintRealm: CurrentRealm: (struct{("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm" std.Address),("" string)} std.Realm) -// PrintRealm: PrevRealm: (struct{("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm" std.Address),("" string)} std.Realm) -// CurrentRealm: (struct{("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm" std.Address),("" string)} std.Realm) -// PrevRealm: (struct{("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm" std.Address),("" string)} std.Realm) -// PrintRealm: CurrentRealm: (struct{("g1user" std.Address),("" string)} std.Realm) -// PrintRealm: PrevRealm: (struct{("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm" std.Address),("" string)} std.Realm) -// CurrentRealm: (struct{("g1user" std.Address),("" string)} std.Realm) -// PrevRealm: (struct{("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm" std.Address),("" string)} std.Realm) -// PrintRealm: CurrentRealm: (struct{("g17m4ga9t9dxn8uf06p3cahdavzfexe33ecg8v2s" std.Address),("gno.land/r/demo/users" string)} std.Realm) -// PrintRealm: PrevRealm: (struct{("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm" std.Address),("" string)} std.Realm) -// CurrentRealm: (struct{("g17m4ga9t9dxn8uf06p3cahdavzfexe33ecg8v2s" std.Address),("gno.land/r/demo/users" string)} std.Realm) -// PrevRealm: (struct{("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm" std.Address),("" string)} std.Realm) diff --git a/gnovm/tests/files/zrealm_crossrealm13a_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm13a_stdlibs.gno deleted file mode 100644 index 2fc37804fce..00000000000 --- a/gnovm/tests/files/zrealm_crossrealm13a_stdlibs.gno +++ /dev/null @@ -1,46 +0,0 @@ -// PKGPATH: gno.land/r/demo/groups -package groups - -import ( - "std" -) - -func main() { - PrintRealm() - println(pad("CurrentRealm:"), std.CurrentRealm()) - println(pad("PrevRealm:"), std.PrevRealm()) - std.TestSetRealm(std.NewUserRealm("g1user")) - PrintRealm() - println(pad("CurrentRealm:"), std.CurrentRealm()) - println(pad("PrevRealm:"), std.PrevRealm()) - std.TestSetRealm(std.NewCodeRealm("gno.land/r/demo/users")) - PrintRealm() - println(pad("CurrentRealm:"), std.CurrentRealm()) - println(pad("PrevRealm:"), std.PrevRealm()) -} - -func pad(s string) string { - for len(s) < 26 { - s += " " - } - return s -} - -func PrintRealm() { - println(pad("PrintRealm: CurrentRealm:"), std.CurrentRealm()) - println(pad("PrintRealm: PrevRealm:"), std.PrevRealm()) -} - -// Output: -// PrintRealm: CurrentRealm: (struct{("g1r0mlnkc05z0fv49km99z60qnp95tengyqfdr02" std.Address),("gno.land/r/demo/groups" string)} std.Realm) -// PrintRealm: PrevRealm: (struct{("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm" std.Address),("" string)} std.Realm) -// CurrentRealm: (struct{("g1r0mlnkc05z0fv49km99z60qnp95tengyqfdr02" std.Address),("gno.land/r/demo/groups" string)} std.Realm) -// PrevRealm: (struct{("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm" std.Address),("" string)} std.Realm) -// PrintRealm: CurrentRealm: (struct{("g1r0mlnkc05z0fv49km99z60qnp95tengyqfdr02" std.Address),("gno.land/r/demo/groups" string)} std.Realm) -// PrintRealm: PrevRealm: (struct{("g1user" std.Address),("" string)} std.Realm) -// CurrentRealm: (struct{("g1user" std.Address),("" string)} std.Realm) -// PrevRealm: (struct{("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm" std.Address),("" string)} std.Realm) -// PrintRealm: CurrentRealm: (struct{("g1r0mlnkc05z0fv49km99z60qnp95tengyqfdr02" std.Address),("gno.land/r/demo/groups" string)} std.Realm) -// PrintRealm: PrevRealm: (struct{("g17m4ga9t9dxn8uf06p3cahdavzfexe33ecg8v2s" std.Address),("gno.land/r/demo/users" string)} std.Realm) -// CurrentRealm: (struct{("g17m4ga9t9dxn8uf06p3cahdavzfexe33ecg8v2s" std.Address),("gno.land/r/demo/users" string)} std.Realm) -// PrevRealm: (struct{("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm" std.Address),("" string)} std.Realm) diff --git a/gnovm/tests/files/zrealm_crossrealm14.gno b/gnovm/tests/files/zrealm_crossrealm14.gno deleted file mode 100644 index 23451e6f5d1..00000000000 --- a/gnovm/tests/files/zrealm_crossrealm14.gno +++ /dev/null @@ -1,17 +0,0 @@ -// PKGPATH: gno.land/r/crossrealm_test -package crossrealm_test - -import ( - crossrealm "gno.land/r/demo/tests/crossrealm" -) - -func main() { - // even though we are running within a realm, - // we aren't storing the result of crossrealm.Make1(), - // so this should print fine. - crossrealm.Make1().Touch().Print() -} - -// Output: -// A: 2 -// B: LocalStruct{123} diff --git a/gnovm/tests/files/zrealm_crossrealm15.gno b/gnovm/tests/files/zrealm_crossrealm15.gno deleted file mode 100644 index 40b94662a70..00000000000 --- a/gnovm/tests/files/zrealm_crossrealm15.gno +++ /dev/null @@ -1,27 +0,0 @@ -// PKGPATH: gno.land/r/crossrealm_test -package crossrealm_test - -import ( - "std" - - crossrealm "gno.land/r/demo/tests/crossrealm" -) - -type fooer struct{} - -func (fooer) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } - -var f *fooer - -// XXX, this attach a heapItem to current realm -func init() { - f = &fooer{} -} - -func main() { - // XXX, this associate a pointer to a value(already attached to local realm) - // to external realm, no attachment happens to the external realm. - crossrealm.SetFooer(f) - crossrealm.CallFoo() - print(".") -} diff --git a/gnovm/tests/files/zrealm_crossrealm16.gno b/gnovm/tests/files/zrealm_crossrealm16.gno deleted file mode 100644 index 50c695884c4..00000000000 --- a/gnovm/tests/files/zrealm_crossrealm16.gno +++ /dev/null @@ -1,18 +0,0 @@ -// PKGPATH: gno.land/r/crossrealm_test -package crossrealm_test - -import ( - crossrealm "gno.land/r/demo/tests/crossrealm" -) - -var b0 crossrealm.Bar - -func init() { - b0 = crossrealm.Bar{A: 1} // XXX, should be invalid to attach external type -} - -func main() { - crossrealm.SetBar(&b0) - crossrealm.CallBar() - print(".") -} diff --git a/gnovm/tests/files/zrealm_crossrealm16a.gno b/gnovm/tests/files/zrealm_crossrealm16a.gno deleted file mode 100644 index 5fbe6a072ab..00000000000 --- a/gnovm/tests/files/zrealm_crossrealm16a.gno +++ /dev/null @@ -1,16 +0,0 @@ -// PKGPATH: gno.land/r/crossrealm_test -package crossrealm_test - -import ( - crossrealm "gno.land/r/demo/tests/crossrealm" -) - -var b0 crossrealm.Bar - -func init() { - crossrealm.Bar2.A = 2 // this should be valid -} - -func main() { - print(".") -} diff --git a/gnovm/tests/files/zrealm_crossrealm17.gno b/gnovm/tests/files/zrealm_crossrealm17.gno deleted file mode 100644 index e5587dedbee..00000000000 --- a/gnovm/tests/files/zrealm_crossrealm17.gno +++ /dev/null @@ -1,28 +0,0 @@ -// PKGPATH: gno.land/r/crossrealm_test -package crossrealm_test - -import ( - "std" - - crossrealm "gno.land/r/demo/tests/crossrealm" -) - -type container struct{ *fooer } - -func (container) Foo() { println("hello container " + std.CurrentRealm().PkgPath()) } - -type fooer struct{} - -var f *fooer - -func main() { - f = &fooer{} // not attached - c := &container{f} - crossrealm.SetFooer(c) - crossrealm.CallFoo() - print(".") -} - -// Output: -// hello container gno.land/r/demo/tests/crossrealm -// . diff --git a/gnovm/tests/files/zrealm_crossrealm18.gno b/gnovm/tests/files/zrealm_crossrealm18.gno deleted file mode 100644 index a1c8888fb7d..00000000000 --- a/gnovm/tests/files/zrealm_crossrealm18.gno +++ /dev/null @@ -1,34 +0,0 @@ -// PKGPATH: gno.land/r/crossrealm_test -package crossrealm_test - -import ( - "std" - - crossrealm "gno.land/r/demo/tests/crossrealm" -) - -type fooer struct{} - -func (fooer) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } - -var f crossrealm.Fooer = crossrealm.SetFooer(&fooer{}) - -func init() { - crossrealm.CallFoo() -} - -func main() { - crossrealm.CallFoo() - print(".") -} - -// Output: -// hello gno.land/r/demo/tests/crossrealm -// hello gno.land/r/demo/tests/crossrealm -// . - -// Error: - -// Realm: -// switchrealm["gno.land/r/demo/tests/crossrealm"] -// switchrealm["gno.land/r/crossrealm_test"] diff --git a/gnovm/tests/files/zrealm_crossrealm19.gno b/gnovm/tests/files/zrealm_crossrealm19.gno deleted file mode 100644 index 62b6d08c78f..00000000000 --- a/gnovm/tests/files/zrealm_crossrealm19.gno +++ /dev/null @@ -1,33 +0,0 @@ -// PKGPATH: gno.land/r/crossrealm_test -package crossrealm_test - -import ( - crossrealm "gno.land/r/demo/tests/crossrealm" -) - -var b0 = crossrealm.Bar{A: 1} - -// un-attached package level var -// is this attached? or not? another function to attach? -//var b *crossrealm.Bar = crossrealm.SetBar(&b0) - -func init() { - // crossrealm.CallFoo() - crossrealm.SetBar(&b0) -} - -func main() { - crossrealm.CallBar() - print(".") -} - -// Output: -// hello gno.land/r/demo/tests/crossrealm -// hello gno.land/r/demo/tests/crossrealm -// . - -// Error: - -// Realm: -// switchrealm["gno.land/r/demo/tests/crossrealm"] -// switchrealm["gno.land/r/crossrealm_test"] diff --git a/gnovm/tests/files/zrealm_crossrealm1_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm1_stdlibs.gno deleted file mode 100644 index 836c317b7dc..00000000000 --- a/gnovm/tests/files/zrealm_crossrealm1_stdlibs.gno +++ /dev/null @@ -1,20 +0,0 @@ -// PKGPATH: gno.land/r/crossrealm_test -package crossrealm_test - -import ( - "gno.land/r/demo/tests" -) - -// NOTE: it is *invalid* to persist external realm types. -var somevalue tests.TestRealmObject - -func init() { - somevalue.Field = "test" -} - -func main() { - println(somevalue) -} - -// Error: -// should not happen while attempting to attach new real object from external realm diff --git a/gnovm/tests/files/zrealm_crossrealm2_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm2_stdlibs.gno deleted file mode 100644 index 2e9f3b30637..00000000000 --- a/gnovm/tests/files/zrealm_crossrealm2_stdlibs.gno +++ /dev/null @@ -1,22 +0,0 @@ -// PKGPATH: gno.land/r/crossrealm_test -package crossrealm_test - -import ( - "gno.land/r/demo/tests" -) - -// NOTE: it is *invalid* to persist external realm types. -var somevalue tests.TestRealmObject - -func init() { - somevalue.Field = "test" -} - -func main() { - // NOTE: but it is invalid to modify it using an external realm function. - tests.ModifyTestRealmObject(&somevalue) - println(somevalue) -} - -// Error: -// cannot modify external-realm or non-realm object diff --git a/gnovm/tests/files/zrealm_crossrealm34.gno b/gnovm/tests/files/zrealm_crossrealm34.gno index d38d84eaa1c..0cd5be053ff 100644 --- a/gnovm/tests/files/zrealm_crossrealm34.gno +++ b/gnovm/tests/files/zrealm_crossrealm34.gno @@ -14,6 +14,5 @@ func main() { println(".") } -// Error: -// interface conversion: gnolang.PointerValue is not gnolang.Object: missing method DecRefCount -// *** CHECK THE ERR MESSAGES ABOVE, MAKE SURE IT'S WHAT YOU EXPECTED, DELETE THIS LINE AND RUN TEST AGAIN *** +// Output: +// . diff --git a/gnovm/tests/files/zrealm_crossrealm37.gno b/gnovm/tests/files/zrealm_crossrealm37.gno new file mode 100644 index 00000000000..65dc493b100 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm37.gno @@ -0,0 +1,14 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import crossrealm "gno.land/r/demo/tests/crossrealm" + +var m1 map[string]int + +func main() { + m1 = crossrealm.GetMap() + println(m1) +} + +// Error: +// should not happen while attempting to attach objects by value from external realm diff --git a/gnovm/tests/files/zrealm_crossrealm38.gno b/gnovm/tests/files/zrealm_crossrealm38.gno new file mode 100644 index 00000000000..29b6c9f6670 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm38.gno @@ -0,0 +1,13 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import crossrealm "gno.land/r/demo/tests/crossrealm" + +var f func() string + +func main() { + f = crossrealm.GetFunc() + println(f) +} + +// Output: diff --git a/gnovm/tests/files/zrealm_crossrealm0_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm39.gno similarity index 50% rename from gnovm/tests/files/zrealm_crossrealm0_stdlibs.gno rename to gnovm/tests/files/zrealm_crossrealm39.gno index 0dd479d24e4..f638eb67f4d 100644 --- a/gnovm/tests/files/zrealm_crossrealm0_stdlibs.gno +++ b/gnovm/tests/files/zrealm_crossrealm39.gno @@ -1,16 +1,13 @@ // PKGPATH: gno.land/r/crossrealm_test package crossrealm_test -import ( - "gno.land/r/demo/tests" -) +import crossrealm "gno.land/r/demo/tests/crossrealm" -// NOTE: it is *invalid* to persist external realm types. -var somevalue tests.TestRealmObject +var f func() string func main() { - somevalue.Field = "test" - println(somevalue) + f = crossrealm.GetFunc2() + println(f) } // Error: diff --git a/gnovm/tests/files/zrealm_crossrealm3_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm3_stdlibs.gno deleted file mode 100644 index 9dc099b3c43..00000000000 --- a/gnovm/tests/files/zrealm_crossrealm3_stdlibs.gno +++ /dev/null @@ -1,22 +0,0 @@ -// PKGPATH: gno.land/r/crossrealm_test -package crossrealm_test - -import ( - "gno.land/r/demo/tests" -) - -// NOTE: it is *invalid* to persist external realm types. -var somevalue tests.TestRealmObject - -func init() { - somevalue.Field = "test" -} - -func main() { - // NOTE: but it is invalid to modify it using an external realm function. - somevalue.Modify() - println(somevalue) -} - -// Error: -// cannot modify external-realm or non-realm object diff --git a/gnovm/tests/files/zrealm_crossrealm40.gno b/gnovm/tests/files/zrealm_crossrealm40.gno new file mode 100644 index 00000000000..af9d89d59ac --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm40.gno @@ -0,0 +1,13 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import crossrealm "gno.land/r/demo/tests/crossrealm" + +var f func() string + +func main() { + f = crossrealm.GetMethod() // XXX, this attach boundmethodvalue to current realm, shoud panic + println(f) +} + +// Error: diff --git a/gnovm/tests/files/zrealm_crossrealm4_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm4_stdlibs.gno deleted file mode 100644 index 9dc099b3c43..00000000000 --- a/gnovm/tests/files/zrealm_crossrealm4_stdlibs.gno +++ /dev/null @@ -1,22 +0,0 @@ -// PKGPATH: gno.land/r/crossrealm_test -package crossrealm_test - -import ( - "gno.land/r/demo/tests" -) - -// NOTE: it is *invalid* to persist external realm types. -var somevalue tests.TestRealmObject - -func init() { - somevalue.Field = "test" -} - -func main() { - // NOTE: but it is invalid to modify it using an external realm function. - somevalue.Modify() - println(somevalue) -} - -// Error: -// cannot modify external-realm or non-realm object diff --git a/gnovm/tests/files/zrealm_crossrealm5_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm5_stdlibs.gno deleted file mode 100644 index 9dc099b3c43..00000000000 --- a/gnovm/tests/files/zrealm_crossrealm5_stdlibs.gno +++ /dev/null @@ -1,22 +0,0 @@ -// PKGPATH: gno.land/r/crossrealm_test -package crossrealm_test - -import ( - "gno.land/r/demo/tests" -) - -// NOTE: it is *invalid* to persist external realm types. -var somevalue tests.TestRealmObject - -func init() { - somevalue.Field = "test" -} - -func main() { - // NOTE: but it is invalid to modify it using an external realm function. - somevalue.Modify() - println(somevalue) -} - -// Error: -// cannot modify external-realm or non-realm object diff --git a/gnovm/tests/files/zrealm_crossrealm6_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm6_stdlibs.gno deleted file mode 100644 index d2e7a4b096a..00000000000 --- a/gnovm/tests/files/zrealm_crossrealm6_stdlibs.gno +++ /dev/null @@ -1,21 +0,0 @@ -// PKGPATH: gno.land/r/crossrealm_test -package crossrealm_test - -import ( - "gno.land/p/demo/tests" -) - -var somevalue tests.TestRealmObject2 - -func init() { - somevalue.Field = "test" -} - -func main() { - // this is OK because the method is declared in a non-realm package. - somevalue.Modify() - println(somevalue) -} - -// Output: -// (struct{("modified" string)} gno.land/p/demo/tests.TestRealmObject2) diff --git a/gnovm/tests/files/zrealm_crossrealm7_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm7_stdlibs.gno deleted file mode 100644 index 5a4dc3002cc..00000000000 --- a/gnovm/tests/files/zrealm_crossrealm7_stdlibs.gno +++ /dev/null @@ -1,14 +0,0 @@ -// PKGPATH: gno.land/r/crossrealm_test -package crossrealm_test - -import ( - "gno.land/p/demo/tests" -) - -func main() { - tests.ModifyTestRealmObject2a() - println("done") -} - -// Error: -// cannot modify external-realm or non-realm object diff --git a/gnovm/tests/files/zrealm_crossrealm8_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm8_stdlibs.gno deleted file mode 100644 index f03085ff4c7..00000000000 --- a/gnovm/tests/files/zrealm_crossrealm8_stdlibs.gno +++ /dev/null @@ -1,14 +0,0 @@ -// PKGPATH: gno.land/r/crossrealm_test -package crossrealm_test - -import ( - "gno.land/p/demo/tests" -) - -func main() { - tests.ModifyTestRealmObject2b() - println("done") -} - -// Error: -// cannot modify external-realm or non-realm object diff --git a/gnovm/tests/files/zrealm_crossrealm9_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm9_stdlibs.gno deleted file mode 100644 index 96a7a3484d7..00000000000 --- a/gnovm/tests/files/zrealm_crossrealm9_stdlibs.gno +++ /dev/null @@ -1,14 +0,0 @@ -// PKGPATH: gno.land/r/crossrealm_test -package crossrealm_test - -import ( - "gno.land/p/demo/tests" -) - -func main() { - tests.SomeValue2.Field = "modified" - println("done") -} - -// Error: -// cannot modify external-realm or non-realm object From 4af9d458dbe6bad076228c978bafe09616d5d147 Mon Sep 17 00:00:00 2001 From: ltzMaxwell Date: Mon, 25 Nov 2024 19:55:03 +0900 Subject: [PATCH 27/40] save --- gnovm/pkg/gnolang/op_call.go | 3 -- gnovm/pkg/gnolang/op_eval.go | 4 -- gnovm/pkg/gnolang/op_expressions.go | 7 ---- gnovm/pkg/gnolang/realm.go | 48 +++++++---------------- gnovm/pkg/gnolang/uverse.go | 1 + gnovm/pkg/gnolang/values.go | 3 -- gnovm/tests/files/zrealm_crossrealm38.gno | 3 +- 7 files changed, 18 insertions(+), 51 deletions(-) diff --git a/gnovm/pkg/gnolang/op_call.go b/gnovm/pkg/gnolang/op_call.go index 5bb9f3ec748..5bc54ec1f53 100644 --- a/gnovm/pkg/gnolang/op_call.go +++ b/gnovm/pkg/gnolang/op_call.go @@ -7,7 +7,6 @@ import ( ) func (m *Machine) doOpPrecall() { - //fmt.Println("---doOpPrecall---") cx := m.PopExpr().(*CallExpr) v := m.PeekValue(1 + cx.NumArgs).V if debug { @@ -20,7 +19,6 @@ func (m *Machine) doOpPrecall() { } switch fv := v.(type) { case *FuncValue: - //fmt.Println("---FuncValue, fv: ", fv) m.PushFrameCall(cx, fv, TypedValue{}) m.PushOp(OpCall) case *BoundMethodValue: @@ -51,7 +49,6 @@ func (m *Machine) doOpPrecall() { var gReturnStmt = &ReturnStmt{} func (m *Machine) doOpCall() { - //fmt.Println("---doOpCall---") // NOTE: Frame won't be popped until the statement is complete, to // discard the correct number of results for func calls in ExprStmts. fr := m.LastFrame() diff --git a/gnovm/pkg/gnolang/op_eval.go b/gnovm/pkg/gnolang/op_eval.go index d9a381bba96..1fe26555239 100644 --- a/gnovm/pkg/gnolang/op_eval.go +++ b/gnovm/pkg/gnolang/op_eval.go @@ -21,7 +21,6 @@ func (m *Machine) doOpEval() { x := m.PeekExpr(1) if debug { debug.Printf("EVAL: (%T) %v\n", x, x) - // fmt.Println(m.String()) } // This case moved out of switch for performance. // TODO: understand this better. @@ -37,7 +36,6 @@ func (m *Machine) doOpEval() { lb := m.LastBlock() // Push value, done. ptr := lb.GetPointerTo(m.Store, nx.Path) - //fmt.Println("---ptr: ", ptr) m.PushValue(ptr.Deref()) return } @@ -243,7 +241,6 @@ func (m *Machine) doOpEval() { m.PushOp(OpEval) } case *CallExpr: - //fmt.Println("---Eval, CallExpr, x: ", x) m.PushOp(OpPrecall) // Eval args. args := x.Args @@ -267,7 +264,6 @@ func (m *Machine) doOpEval() { m.PushExpr(x.X) m.PushOp(OpEval) case *SelectorExpr: - //fmt.Println("---Eval, SelectorExpr, x: ", x) m.PushOp(OpSelector) // evaluate x m.PushExpr(x.X) diff --git a/gnovm/pkg/gnolang/op_expressions.go b/gnovm/pkg/gnolang/op_expressions.go index a95261909eb..8ff0b5bd538 100644 --- a/gnovm/pkg/gnolang/op_expressions.go +++ b/gnovm/pkg/gnolang/op_expressions.go @@ -16,8 +16,6 @@ func (m *Machine) doOpIndex1() { } iv := m.PopValue() // index xv := m.PeekValue(1) // x - //fmt.Println("---doOpIndex1, iv: ", iv) - //fmt.Println("---doOpIndex1, xv: ", xv) switch ct := baseOf(xv.T).(type) { case *MapType: mv := xv.V.(*MapValue) @@ -33,7 +31,6 @@ func (m *Machine) doOpIndex1() { } default: res := xv.GetPointerAtIndex(m.Alloc, m.Store, iv) - //fmt.Println("---doOpIndex1, res: ", res.Deref()) *xv = res.Deref() // reuse as result } } @@ -47,7 +44,6 @@ func (m *Machine) doOpIndex2() { } iv := m.PeekValue(1) // index xv := m.PeekValue(2) // x - //fmt.Println("---doOpIndex2: ", iv) switch ct := baseOf(xv.T).(type) { case *MapType: vt := ct.Value @@ -80,12 +76,9 @@ func (m *Machine) doOpIndex2() { } func (m *Machine) doOpSelector() { - //fmt.Println("---doOpSelector---") sx := m.PopExpr().(*SelectorExpr) xv := m.PeekValue(1) - //fmt.Println("---xv: ", xv) res := xv.GetPointerTo(m.Alloc, m.Store, sx.Path).Deref() - //fmt.Println("---doOpSelector, res after Deref: ", res) if debug { m.Printf("-v[S] %v\n", xv) m.Printf("+v[S] %v\n", res) diff --git a/gnovm/pkg/gnolang/realm.go b/gnovm/pkg/gnolang/realm.go index 743200e0645..be5acee97eb 100644 --- a/gnovm/pkg/gnolang/realm.go +++ b/gnovm/pkg/gnolang/realm.go @@ -133,21 +133,7 @@ func (rlm *Realm) String() string { // if rlm or po is nil, do nothing. // xo or co is nil if the element value is undefined or has no // associated object. -// TODO: func (rlm *Realm) DidUpdate(po, xo, co Object, attached bool) { func (rlm *Realm) DidUpdate(po, xo, co Object) { - //fmt.Println("---DidUpdate, rlm.ID: ", rlm.ID) - //fmt.Printf("---xo: %v, type of xo: %v\n", xo, reflect.TypeOf(xo)) - //fmt.Printf("---co: %v, type of co: %v\n", co, reflect.TypeOf(co)) - // - //if co != nil { - // fmt.Println("---co.LastNewEscapedRealm: ", co.GetLastNewEscapedRealm()) - // fmt.Println("---co.GetRefCount: ", co.GetRefCount()) - // fmt.Println("---co isReal(attached): ", co.GetIsReal()) - // fmt.Println("---co objectID: ", co.GetObjectID()) - //} - - //fmt.Printf("---po: %v, type of po: %v\n", po, reflect.TypeOf(po)) - if rlm == nil { return } @@ -164,7 +150,6 @@ func (rlm *Realm) DidUpdate(po, xo, co Object) { } if po == nil || !po.GetIsReal() { // XXX, make sure po is attached - fmt.Println("---po(Base) not real, do nothing!!!") return // do nothing. } @@ -179,16 +164,14 @@ func (rlm *Realm) DidUpdate(po, xo, co Object) { rlm.MarkDirty(po) if co != nil { - //fmt.Println("---co.GetRefCount: ", co.GetRefCount()) // XXX, inc ref count everytime assignment happens co.IncRefCount() - //fmt.Println("---after inc, co.GetRefCount: ", co.GetRefCount()) if co.GetRefCount() > 1 { if co.GetIsEscaped() { // XXX, why packageBlock is automatically escaped? - //println("---already escaped, should check cross realm?") // already escaped } else { + // XXX, just mark rlm.MarkNewEscapedCheckCrossRealm(nil, co, false, 0, 0) } } else if co.GetIsReal() { @@ -201,7 +184,6 @@ func (rlm *Realm) DidUpdate(po, xo, co Object) { if xo != nil { xo.DecRefCount() - //fmt.Printf("---xo: %v refCount after dec: %v\n", xo, xo.GetRefCount()) if xo.GetRefCount() == 0 { if xo.GetIsReal() { rlm.MarkNewDeleted(xo) @@ -327,6 +309,7 @@ func checkCrossRealm(store Store, oo Object, offset, length int) { //res := oo.(*ArrayValue).GetPointerAtIndexInt2(store, i, nil).Deref() e := oo.(*ArrayValue).GetPointerAtIndexInt2(store, i, nil).Deref() + // TODO: replace these logic fmt.Println("---e: ", e, reflect.TypeOf(e.V)) if _, ok := e.V.(RefValue); ok { // TODO: XXX, does this already enough fmt.Println("---escaped: ", e.V.(RefValue).Escaped) @@ -401,7 +384,6 @@ func (rlm *Realm) MarkNewEscapedCheckCrossRealm(store Store, oo Object, isRef bo } func (rlm *Realm) MarkNewReal(oo Object) { - //fmt.Println("---markNewReal---, oo: ", oo) if debug { if pv, ok := oo.(*PackageValue); ok { // packages should have no owner. @@ -515,13 +497,13 @@ func (rlm *Realm) FinalizeRealmTransaction(readonly bool, store Store) { }() if readonly { if true || - len(rlm.newCreated) > 0 || - len(rlm.newEscaped) > 0 || - len(rlm.newDeleted) > 0 || - len(rlm.created) > 0 || - len(rlm.updated) > 0 || - len(rlm.deleted) > 0 || - len(rlm.escaped) > 0 { + len(rlm.newCreated) > 0 || + len(rlm.newEscaped) > 0 || + len(rlm.newDeleted) > 0 || + len(rlm.created) > 0 || + len(rlm.updated) > 0 || + len(rlm.deleted) > 0 || + len(rlm.escaped) > 0 { panic("realm updates in readonly transaction") } return @@ -536,9 +518,9 @@ func (rlm *Realm) FinalizeRealmTransaction(readonly bool, store Store) { ensureUniq(rlm.newDeleted) ensureUniq(rlm.updated) if false || - rlm.created != nil || - rlm.deleted != nil || - rlm.escaped != nil { + rlm.created != nil || + rlm.deleted != nil || + rlm.escaped != nil { panic("realm should not have created, deleted, or escaped marks before beginning finalization") } } @@ -957,9 +939,9 @@ func (rlm *Realm) saveUnsavedObjectRecursively(store Store, oo Object) { } // deleted objects should not have gotten here. if false || - oo.GetRefCount() <= 0 || - oo.GetIsNewDeleted() || - oo.GetIsDeleted() { + oo.GetRefCount() <= 0 || + oo.GetIsNewDeleted() || + oo.GetIsDeleted() { panic("cannot save deleted objects") } } diff --git a/gnovm/pkg/gnolang/uverse.go b/gnovm/pkg/gnolang/uverse.go index 880a75396ca..b13bd1a4317 100644 --- a/gnovm/pkg/gnolang/uverse.go +++ b/gnovm/pkg/gnolang/uverse.go @@ -303,6 +303,7 @@ func UverseNode() *PackageNode { newElem := arg1Base.List[arg1Offset+i].unrefCopy(m.Alloc, m.Store) list[arg0Offset+arg0Length+i] = newElem + // XXX, DidUpdate2? m.Realm.DidUpdate( arg0Base, oldElem.GetFirstObject(m.Store), diff --git a/gnovm/pkg/gnolang/values.go b/gnovm/pkg/gnolang/values.go index 5f4c527d800..f64ed670403 100644 --- a/gnovm/pkg/gnolang/values.go +++ b/gnovm/pkg/gnolang/values.go @@ -1732,9 +1732,6 @@ func (tv *TypedValue) Assign(alloc *Allocator, tv2 TypedValue, cu bool) { // as in OpRef. func (tv *TypedValue) GetPointerTo(alloc *Allocator, store Store, path ValuePath) PointerValue { //fmt.Println("---GetPointerTo, tv: ", tv) - //fmt.Println("---rt of tv: ", reflect.TypeOf(tv)) - //fmt.Println("---path: ", path) - //fmt.Println("---path.Type: ", path.Type) if debug { if tv.IsUndefined() { panic("GetPointerTo() on undefined value") diff --git a/gnovm/tests/files/zrealm_crossrealm38.gno b/gnovm/tests/files/zrealm_crossrealm38.gno index 29b6c9f6670..3eda0c34e7e 100644 --- a/gnovm/tests/files/zrealm_crossrealm38.gno +++ b/gnovm/tests/files/zrealm_crossrealm38.gno @@ -7,7 +7,8 @@ var f func() string func main() { f = crossrealm.GetFunc() - println(f) + println(f()) } // Output: +// a From 588b9dd28aa13224b47756456d181bce5362a425 Mon Sep 17 00:00:00 2001 From: ltzMaxwell Date: Tue, 26 Nov 2024 11:58:20 +0900 Subject: [PATCH 28/40] change api --- gnovm/pkg/gnolang/ownership.go | 65 +++------------ gnovm/pkg/gnolang/realm.go | 146 +++++++++++++++++---------------- gnovm/pkg/gnolang/values.go | 12 ++- 3 files changed, 97 insertions(+), 126 deletions(-) diff --git a/gnovm/pkg/gnolang/ownership.go b/gnovm/pkg/gnolang/ownership.go index 67352a7c93e..0f9dbbc1f15 100644 --- a/gnovm/pkg/gnolang/ownership.go +++ b/gnovm/pkg/gnolang/ownership.go @@ -382,34 +382,30 @@ func (tv *TypedValue) GetFirstObject(store Store) Object { } // XXX, get first accessible object, maybe containing(parent) object, maybe itself. -func (tv *TypedValue) GetFirstObject2(store Store) (obj Object, pkgId PkgID, isRef bool, length int, offset int) { +func (tv *TypedValue) GetFirstObject2(store Store) (obj Object, pkgId PkgID) { fmt.Println("---GetFirstObject2---, tv: ", tv, reflect.TypeOf(tv.V)) - //fmt.Println("---tv.T, type of tv.T", tv.T, reflect.TypeOf(tv.T)) + // general case if dt, ok := tv.T.(*DeclaredType); ok { //fmt.Println("---dt: ", dt) //fmt.Println("---dt.Name: ", dt.Name) //fmt.Println("---dt.PkgPath: ", dt.PkgPath) //fmt.Println("---PkgID: ", PkgIDFromPkgPath(dt.PkgPath)) - //fmt.Println("---dt.Base: ", dt.Base) if IsRealmPath(dt.PkgPath) { pkgId = PkgIDFromPkgPath(dt.PkgPath) } } + + // get first object + obj = tv.GetFirstObject(store) + + fmt.Println("---obj: ", obj) switch cv := tv.V.(type) { case PointerValue: - println("---pointer value, get base") + println("---pointer value") if v, ok := cv.TV.V.(Object); ok { fmt.Println("---v: ", v) - //rc := v.GetRefCount() - //fmt.Println("---rc: ", rc) - //fmt.Println("---v Owner: ", v.GetOwnerID()) - //fmt.Println("---v.GetObjectID(): ", v.GetObjectID()) - //fmt.Println("---is Attached?", v.GetIsReal()) - + // TODO: check this if dt, ok := cv.TV.T.(*DeclaredType); ok { - // b0 = &crossrealm.Bar{A: 1} this is valid - // no need to check cross - // XXX, is it right? if _, ok := cv.GetBase(store).(*HeapItemValue); !ok { if IsRealmPath(dt.PkgPath) { pkgId = PkgIDFromPkgPath(dt.PkgPath) @@ -417,59 +413,22 @@ func (tv *TypedValue) GetFirstObject2(store Store) (obj Object, pkgId PkgID, isR } } } - obj, isRef = cv.GetBase(store), true return case *ArrayValue: fmt.Println("---array value, T: ", tv.T) - //fmt.Println("---Elem PkgPath: ", tv.T.Elem().GetPkgPath()) - - obj, pkgId, isRef = cv, PkgIDFromPkgPath(tv.T.Elem().GetPkgPath()), false + pkgId = PkgIDFromPkgPath(tv.T.Elem().GetPkgPath()) return case *SliceValue: - //base := cv.GetBase(store) - //fmt.Println("---SliceValue, base: ", base) - //fmt.Printf("---SliceValue len: %d, cap:%d, offsetL:%d \n", cv.Length, cv.Maxcap, cv.Offset) - //fmt.Println("---tv.T...PkgPath: ", tv.T.Elem().GetPkgPath()) - //fmt.Println("---type of base: ", reflect.TypeOf(base)) - - obj, pkgId, isRef, length, offset = cv.GetBase(store), PkgIDFromPkgPath(tv.T.Elem().GetPkgPath()), true, cv.GetLength(), cv.Offset - return - case *StructValue: - println("---struct value") - //fmt.Println("---cv.GetObjectID(): ", cv.GetObjectID()) - obj, isRef = cv, false + pkgId = PkgIDFromPkgPath(tv.T.Elem().GetPkgPath()) return case *FuncValue: fmt.Println("---FuncValue") clo := cv.GetClosure(store) fmt.Println("---clo: ", clo) fmt.Println("clo...PkgPath", clo.Source.GetLocation().PkgPath) - obj, pkgId, isRef = cv.GetClosure(store), PkgIDFromPkgPath(clo.Source.GetLocation().PkgPath), false - return - case *MapValue: - obj, isRef = cv, false - return - case *BoundMethodValue: - obj, isRef = cv, false - return - case *NativeValue: - // XXX allow PointerValue.Assign2 to pass nil for oo1/oo2. - // panic("realm logic for native values not supported") - obj, isRef = nil, false - return - case *Block: - obj, isRef = cv, false - return - case RefValue: - oo := store.GetObject(cv.ObjectID) - tv.V = oo - obj, isRef = oo, false + pkgId = PkgIDFromPkgPath(clo.Source.GetLocation().PkgPath) return - case *HeapItemValue: - // should only appear in PointerValue.Base - panic("heap item value should only appear as a pointer's base") default: - obj, isRef = nil, false return } } diff --git a/gnovm/pkg/gnolang/realm.go b/gnovm/pkg/gnolang/realm.go index be5acee97eb..f746592951f 100644 --- a/gnovm/pkg/gnolang/realm.go +++ b/gnovm/pkg/gnolang/realm.go @@ -172,7 +172,7 @@ func (rlm *Realm) DidUpdate(po, xo, co Object) { // already escaped } else { // XXX, just mark - rlm.MarkNewEscapedCheckCrossRealm(nil, co, false, 0, 0) + rlm.MarkNewEscaped(co) } } else if co.GetIsReal() { rlm.MarkDirty(co) @@ -192,8 +192,9 @@ func (rlm *Realm) DidUpdate(po, xo, co Object) { } } -func (rlm *Realm) DidUpdate2(store Store, po, xo, co Object, isRef bool, length, offset int) { - fmt.Println("---DidUpdate, rlm.ID: ", rlm.ID) +// ref value is the derived value from co, like a slice. +func (rlm *Realm) DidUpdate2(store Store, po, xo, co Object, refValue Value) { + fmt.Println("---DidUpdate2, rlm.ID: ", rlm.ID) //fmt.Printf("---xo: %v, type of xo: %v\n", xo, reflect.TypeOf(xo)) fmt.Printf("---co: %v, type of co: %v\n", co, reflect.TypeOf(co)) fmt.Printf("---po: %v, type of po: %v\n", po, reflect.TypeOf(po)) @@ -239,7 +240,7 @@ func (rlm *Realm) DidUpdate2(store Store, po, xo, co Object, isRef bool, length, println("---already escaped, should check cross realm?") // already escaped } else { - rlm.MarkNewEscapedCheckCrossRealm(store, co, isRef, length, offset) + rlm.MarkNewEscapedCheckCrossRealm(store, co, refValue) } } else if co.GetIsReal() { rlm.MarkDirty(co) @@ -267,7 +268,7 @@ func (rlm *Realm) DidUpdate2(store Store, po, xo, co Object, isRef bool, length, // originType may contain infos like len, cap for slice type, etc. // XXX, oo coming here must be referenced type, since they already escaped. // XXX, so oo has been persisted, thus fillValueTV -func checkCrossRealm(store Store, oo Object, offset, length int) { +func checkCrossRealm(store Store, oo Object, refValue Value) { fmt.Println("---checkCrossReal, oo: ", oo) switch v := oo.(type) { case *StructValue: @@ -298,58 +299,63 @@ func checkCrossRealm(store Store, oo Object, offset, length int) { //r := fillValueTV(store, &v.Value) //fmt.Println("---r: ", r) - checkCrossRealm(store, v.Value.V.(Object), 0, 0) + checkCrossRealm(store, v.Value.V.(Object), refValue) case *ArrayValue: - fmt.Println("---ArrayValue: ", v) - fmt.Println("---offset: ", offset) - fmt.Println("---escaped array, check if elements are real") - for i := offset; i < length; i++ { - // XXX, difference between them? - //e := oo.(*ArrayValue).List[i] - //res := oo.(*ArrayValue).GetPointerAtIndexInt2(store, i, nil).Deref() - e := oo.(*ArrayValue).GetPointerAtIndexInt2(store, i, nil).Deref() - - // TODO: replace these logic - fmt.Println("---e: ", e, reflect.TypeOf(e.V)) - if _, ok := e.V.(RefValue); ok { // TODO: XXX, does this already enough - fmt.Println("---escaped: ", e.V.(RefValue).Escaped) - fmt.Println("---string: ", e.V.(RefValue).String()) - fmt.Println("---pkgpath: ", e.V.(RefValue).PkgPath) - fmt.Println("---objectID: ", e.V.(RefValue).ObjectID) - if store != nil { - oo := store.GetObject(e.V.(RefValue).ObjectID) - fmt.Println("---oo: ", oo) - fmt.Println("---oo.GetIsReal: ", oo.GetIsReal()) - if !oo.GetIsReal() { - panic("should not happen while reference unreal element from array of external realm") - } - } - } else { - fmt.Println("---e.V: ", e.V) - fmt.Println("---e.V: ", reflect.TypeOf(e.V)) - - if p, ok := e.V.(PointerValue); ok { - fmt.Println("---p.TV: ", p.TV) - fmt.Println("---p.Index: ", p.Index) - fmt.Println("---p.Base: ", p.Base) - - //r1 := fillValueTV(store, &p.Base) - - rr := fillValueTV(store, p.TV) - fmt.Println("---rr: ", rr) - - if sv, ok := p.TV.V.(*StructValue); ok { - fmt.Println("---sv: ", sv) - fmt.Println("---sv.GetIsReal", sv.GetIsReal()) - if !sv.GetIsReal() { - panic(fmt.Sprintf("---should not happen, %v: is not real \n", sv)) + if sv, ok := refValue.(*SliceValue); !ok { + panic("should be slice value") + } else { + offset := sv.Offset + length := sv.Length + fmt.Println("---ArrayValue: ", v) + fmt.Println("---offset: ", offset) + fmt.Println("---escaped array, check if elements are real") + for i := offset; i < length; i++ { + // XXX, difference between them? + //e := oo.(*ArrayValue).List[i] + e := oo.(*ArrayValue).GetPointerAtIndexInt2(store, i, nil).Deref() + + // TODO: replace these logic + fmt.Println("---e: ", e, reflect.TypeOf(e.V)) + if _, ok := e.V.(RefValue); ok { // TODO: XXX, does this already enough + fmt.Println("---escaped: ", e.V.(RefValue).Escaped) + fmt.Println("---string: ", e.V.(RefValue).String()) + fmt.Println("---pkgpath: ", e.V.(RefValue).PkgPath) + fmt.Println("---objectID: ", e.V.(RefValue).ObjectID) + if store != nil { + oo := store.GetObject(e.V.(RefValue).ObjectID) + fmt.Println("---oo: ", oo) + fmt.Println("---oo.GetIsReal: ", oo.GetIsReal()) + if !oo.GetIsReal() { + panic("should not happen while reference unreal element from array of external realm") } - fmt.Println("---sv.ObjectID", sv.GetObjectID()) } } else { - println("---e.V is not pointer") - if !e.V.(Object).GetIsReal() { - panic("should not happen while reference unreal element from external realm") + fmt.Println("---e.V: ", e.V) + fmt.Println("---e.V: ", reflect.TypeOf(e.V)) + + if p, ok := e.V.(PointerValue); ok { + fmt.Println("---p.TV: ", p.TV) + fmt.Println("---p.Index: ", p.Index) + fmt.Println("---p.Base: ", p.Base) + + //r1 := fillValueTV(store, &p.Base) + + rr := fillValueTV(store, p.TV) + fmt.Println("---rr: ", rr) + + if sv, ok := p.TV.V.(*StructValue); ok { + fmt.Println("---sv: ", sv) + fmt.Println("---sv.GetIsReal", sv.GetIsReal()) + if !sv.GetIsReal() { + panic(fmt.Sprintf("---should not happen, %v: is not real \n", sv)) + } + fmt.Println("---sv.ObjectID", sv.GetObjectID()) + } + } else { + println("---e.V is not pointer") + if !e.V.(Object).GetIsReal() { + panic("should not happen while reference unreal element from external realm") + } } } } @@ -360,9 +366,9 @@ func checkCrossRealm(store Store, oo Object, offset, length int) { } // escaped realm should be reference object -func (rlm *Realm) MarkNewEscapedCheckCrossRealm(store Store, oo Object, isRef bool, length, offset int) { +func (rlm *Realm) MarkNewEscapedCheckCrossRealm(store Store, oo Object, refValue Value) { fmt.Println("---MarkNewEscapedCheckCrossRealm") - //fmt.Println("---isRef: ", isRef) + fmt.Println("---refValue: ", refValue) //fmt.Println("---rlm.ID: ", rlm.ID) //fmt.Println("---oo.GetRefCount(): ", oo.GetRefCount()) //fmt.Println("---oo.lastNewRealEscapedRealm: ", oo.GetLastNewEscapedRealm()) @@ -373,8 +379,8 @@ func (rlm *Realm) MarkNewEscapedCheckCrossRealm(store Store, oo Object, isRef bo } if oo.GetLastNewEscapedRealm() != rlm.ID { // crossing realm - if isRef { - checkCrossRealm(store, oo, offset, length) + if refValue != nil { // is reference object from external realm + checkCrossRealm(store, oo, refValue) } else { panic("should not happen while attempting to attach objects by value from external realm") } @@ -497,13 +503,13 @@ func (rlm *Realm) FinalizeRealmTransaction(readonly bool, store Store) { }() if readonly { if true || - len(rlm.newCreated) > 0 || - len(rlm.newEscaped) > 0 || - len(rlm.newDeleted) > 0 || - len(rlm.created) > 0 || - len(rlm.updated) > 0 || - len(rlm.deleted) > 0 || - len(rlm.escaped) > 0 { + len(rlm.newCreated) > 0 || + len(rlm.newEscaped) > 0 || + len(rlm.newDeleted) > 0 || + len(rlm.created) > 0 || + len(rlm.updated) > 0 || + len(rlm.deleted) > 0 || + len(rlm.escaped) > 0 { panic("realm updates in readonly transaction") } return @@ -518,9 +524,9 @@ func (rlm *Realm) FinalizeRealmTransaction(readonly bool, store Store) { ensureUniq(rlm.newDeleted) ensureUniq(rlm.updated) if false || - rlm.created != nil || - rlm.deleted != nil || - rlm.escaped != nil { + rlm.created != nil || + rlm.deleted != nil || + rlm.escaped != nil { panic("realm should not have created, deleted, or escaped marks before beginning finalization") } } @@ -939,9 +945,9 @@ func (rlm *Realm) saveUnsavedObjectRecursively(store Store, oo Object) { } // deleted objects should not have gotten here. if false || - oo.GetRefCount() <= 0 || - oo.GetIsNewDeleted() || - oo.GetIsDeleted() { + oo.GetRefCount() <= 0 || + oo.GetIsNewDeleted() || + oo.GetIsDeleted() { panic("cannot save deleted objects") } } diff --git a/gnovm/pkg/gnolang/values.go b/gnovm/pkg/gnolang/values.go index f64ed670403..8dfc5a6100c 100644 --- a/gnovm/pkg/gnolang/values.go +++ b/gnovm/pkg/gnolang/values.go @@ -257,7 +257,7 @@ func (pv PointerValue) Assign2(alloc *Allocator, store Store, rlm *Realm, tv2 Ty panic("should not happen") } if nv, ok := tv2.V.(*NativeValue); !ok || - nv.Value.Kind() != reflect.Func { + nv.Value.Kind() != reflect.Func { panic("should not happen") } } @@ -292,14 +292,20 @@ func (pv PointerValue) Assign2(alloc *Allocator, store Store, rlm *Realm, tv2 Ty oo1 := pv.TV.GetFirstObject(store) //fmt.Println("---oo1: ", oo1) pv.TV.Assign(alloc, tv2, cu) - oo2, pkgId, isRef, length, offset := pv.TV.GetFirstObject2(store) + oo2, pkgId := pv.TV.GetFirstObject2(store) + + var refValue Value + switch rv := pv.TV.V.(type) { + case *SliceValue, PointerValue: + refValue = rv + } //fmt.Println("---oo2: ", oo2) //fmt.Println("---oo2 pkgId: ", pkgId) if oo2 != nil { oo2.SetLastNewEscapedRealm(pkgId) // attach origin package info } // TODO: make check happens in here? - rlm.DidUpdate2(store, pv.Base.(Object), oo1, oo2, isRef, length, offset) + rlm.DidUpdate2(store, pv.Base.(Object), oo1, oo2, refValue) } else { pv.TV.Assign(alloc, tv2, cu) } From 928bda27d82d7c43ebcbb0b4f239d77f26d3da6c Mon Sep 17 00:00:00 2001 From: ltzMaxwell Date: Tue, 26 Nov 2024 14:02:39 +0900 Subject: [PATCH 29/40] fixup --- gnovm/pkg/gnolang/realm.go | 94 ++++++++++------------ gnovm/pkg/gnolang/values.go | 3 +- gnovm/tests/files/zrealm_crossrealm33.gno | 2 +- gnovm/tests/files/zrealm_crossrealm34a.gno | 2 +- gnovm/tests/files/zrealm_crossrealm36.gno | 2 +- gnovm/tests/files/zrealm_crossrealm40.gno | 1 + 6 files changed, 48 insertions(+), 56 deletions(-) diff --git a/gnovm/pkg/gnolang/realm.go b/gnovm/pkg/gnolang/realm.go index f746592951f..093e2b8b7d4 100644 --- a/gnovm/pkg/gnolang/realm.go +++ b/gnovm/pkg/gnolang/realm.go @@ -275,8 +275,10 @@ func checkCrossRealm(store Store, oo Object, refValue Value) { fmt.Println("---StructValue...") fmt.Println("---sv: ", v) if !v.GetIsReal() { - panic("---sv is not real!!!") + panic(fmt.Sprintf("should not happen, %v is not real\n", v)) } + fmt.Println("---sv is real, check fields") + // check fields for _, fv := range v.Fields { fmt.Println("---fv: ", fv) fmt.Println("---type of fv: ", reflect.TypeOf(fv.V)) @@ -286,18 +288,31 @@ func checkCrossRealm(store Store, oo Object, refValue Value) { //} rfv := fillValueTV(store, &fv) fmt.Println("---rfv: ", rfv) - if oo, ok := rfv.V.(Object); ok { - if !oo.GetIsReal() { - panic(fmt.Sprintf("---should not happen, %v: is not real \n", oo)) + fmt.Println("---type of rfv.V: ", reflect.TypeOf(rfv.V)) + + if fo, ok := rfv.V.(Object); ok { + checkCrossRealm(store, fo, nil) + } else { // reference to object + var reo Object + switch rv := rfv.V.(type) { + case *SliceValue, PointerValue: // if reference object from external realm + refValue = rv + // TODO: consider pkgId here, A -> B - > A?... + // yes, check PkgId per object + reo, _ = rfv.GetFirstObject2(store) + fmt.Println("---reo: ", reo) + // XXX, if elem of array is slice?, GetFirstObject2?... + checkCrossRealm(store, reo, refValue) } } } case *MapValue: println("---mapValue...") + // TODO: check elem? NO. case *HeapItemValue: fmt.Println("---heapItemValue: ", v) - //r := fillValueTV(store, &v.Value) - //fmt.Println("---r: ", r) + r := fillValueTV(store, &v.Value) + fmt.Println("---r: ", r) checkCrossRealm(store, v.Value.V.(Object), refValue) case *ArrayValue: @@ -307,55 +322,30 @@ func checkCrossRealm(store Store, oo Object, refValue Value) { offset := sv.Offset length := sv.Length fmt.Println("---ArrayValue: ", v) - fmt.Println("---offset: ", offset) + fmt.Printf("---offset: %d, length: %d \n", offset, length) fmt.Println("---escaped array, check if elements are real") + for i := offset; i < length; i++ { // XXX, difference between them? - //e := oo.(*ArrayValue).List[i] - e := oo.(*ArrayValue).GetPointerAtIndexInt2(store, i, nil).Deref() - - // TODO: replace these logic - fmt.Println("---e: ", e, reflect.TypeOf(e.V)) - if _, ok := e.V.(RefValue); ok { // TODO: XXX, does this already enough - fmt.Println("---escaped: ", e.V.(RefValue).Escaped) - fmt.Println("---string: ", e.V.(RefValue).String()) - fmt.Println("---pkgpath: ", e.V.(RefValue).PkgPath) - fmt.Println("---objectID: ", e.V.(RefValue).ObjectID) - if store != nil { - oo := store.GetObject(e.V.(RefValue).ObjectID) - fmt.Println("---oo: ", oo) - fmt.Println("---oo.GetIsReal: ", oo.GetIsReal()) - if !oo.GetIsReal() { - panic("should not happen while reference unreal element from array of external realm") - } - } - } else { - fmt.Println("---e.V: ", e.V) - fmt.Println("---e.V: ", reflect.TypeOf(e.V)) - - if p, ok := e.V.(PointerValue); ok { - fmt.Println("---p.TV: ", p.TV) - fmt.Println("---p.Index: ", p.Index) - fmt.Println("---p.Base: ", p.Base) - - //r1 := fillValueTV(store, &p.Base) - - rr := fillValueTV(store, p.TV) - fmt.Println("---rr: ", rr) - - if sv, ok := p.TV.V.(*StructValue); ok { - fmt.Println("---sv: ", sv) - fmt.Println("---sv.GetIsReal", sv.GetIsReal()) - if !sv.GetIsReal() { - panic(fmt.Sprintf("---should not happen, %v: is not real \n", sv)) - } - fmt.Println("---sv.ObjectID", sv.GetObjectID()) - } - } else { - println("---e.V is not pointer") - if !e.V.(Object).GetIsReal() { - panic("should not happen while reference unreal element from external realm") - } + ee := oo.(*ArrayValue).List[i] + e := fillValueTV(store, &ee) + + //e := oo.(*ArrayValue).GetPointerAtIndexInt2(store, i, nil).Deref() + fmt.Printf("---e[%d]: %v\n", i, e) + fmt.Printf("---type of e[%d].V: %v\n", i, reflect.TypeOf(e.V)) + if eo, ok := e.V.(Object); ok { + checkCrossRealm(store, eo, nil) + } else { // reference to object + var reo Object + switch rv := e.V.(type) { + case *SliceValue, PointerValue: // if reference object from external realm + refValue = rv + // TODO: consider pkgId here, A -> B - > A?... + // yes, check PkgId per object + reo, _ = e.GetFirstObject2(store) + fmt.Println("---reo: ", reo) + // XXX, if elem of array is slice?, GetFirstObject2?... + checkCrossRealm(store, reo, refValue) } } } diff --git a/gnovm/pkg/gnolang/values.go b/gnovm/pkg/gnolang/values.go index 8dfc5a6100c..5f8fe658de4 100644 --- a/gnovm/pkg/gnolang/values.go +++ b/gnovm/pkg/gnolang/values.go @@ -257,7 +257,7 @@ func (pv PointerValue) Assign2(alloc *Allocator, store Store, rlm *Realm, tv2 Ty panic("should not happen") } if nv, ok := tv2.V.(*NativeValue); !ok || - nv.Value.Kind() != reflect.Func { + nv.Value.Kind() != reflect.Func { panic("should not happen") } } @@ -294,6 +294,7 @@ func (pv PointerValue) Assign2(alloc *Allocator, store Store, rlm *Realm, tv2 Ty pv.TV.Assign(alloc, tv2, cu) oo2, pkgId := pv.TV.GetFirstObject2(store) + // TODO: move to GetFirstObject2 var refValue Value switch rv := pv.TV.V.(type) { case *SliceValue, PointerValue: diff --git a/gnovm/tests/files/zrealm_crossrealm33.gno b/gnovm/tests/files/zrealm_crossrealm33.gno index 1d892444305..845caa81f04 100644 --- a/gnovm/tests/files/zrealm_crossrealm33.gno +++ b/gnovm/tests/files/zrealm_crossrealm33.gno @@ -19,4 +19,4 @@ func main() { } // Error: -// should not happen while reference unreal element from external realm +// should not happen, struct{("0" string)} is not real diff --git a/gnovm/tests/files/zrealm_crossrealm34a.gno b/gnovm/tests/files/zrealm_crossrealm34a.gno index 00dd06ba292..b15af3bc3b9 100644 --- a/gnovm/tests/files/zrealm_crossrealm34a.gno +++ b/gnovm/tests/files/zrealm_crossrealm34a.gno @@ -19,4 +19,4 @@ func main() { } // Error: -// ---should not happen, struct{("6.1" string)}: is not real +// should not happen, struct{("6.1" string)} is not real diff --git a/gnovm/tests/files/zrealm_crossrealm36.gno b/gnovm/tests/files/zrealm_crossrealm36.gno index a4ce8f9497f..4a45ef0984d 100644 --- a/gnovm/tests/files/zrealm_crossrealm36.gno +++ b/gnovm/tests/files/zrealm_crossrealm36.gno @@ -14,4 +14,4 @@ func main() { } // Error: -// ---should not happen, struct{("d" string)}: is not real +// should not happen, struct{("d" string)} is not real diff --git a/gnovm/tests/files/zrealm_crossrealm40.gno b/gnovm/tests/files/zrealm_crossrealm40.gno index af9d89d59ac..7f5e126dc2b 100644 --- a/gnovm/tests/files/zrealm_crossrealm40.gno +++ b/gnovm/tests/files/zrealm_crossrealm40.gno @@ -10,4 +10,5 @@ func main() { println(f) } +// XXX, fix this. // Error: From 35927e633113c70ebb8034f4587638633243fe01 Mon Sep 17 00:00:00 2001 From: ltzMaxwell Date: Tue, 26 Nov 2024 16:07:55 +0900 Subject: [PATCH 30/40] fixup --- gnovm/pkg/gnolang/alloc.go | 4 +- gnovm/pkg/gnolang/gno_test.go | 1 - gnovm/pkg/gnolang/machine.go | 24 --- gnovm/pkg/gnolang/op_assign.go | 6 - gnovm/pkg/gnolang/op_call.go | 3 - gnovm/pkg/gnolang/op_eval.go | 1 + gnovm/pkg/gnolang/op_exec.go | 3 - gnovm/pkg/gnolang/ownership.go | 15 +- gnovm/pkg/gnolang/preprocess.go | 3 - gnovm/pkg/gnolang/realm.go | 33 +--- gnovm/pkg/gnolang/store.go | 3 - gnovm/pkg/gnolang/values.go | 32 ---- gnovm/tests/files/types/eql_0f49.gno | 21 --- .../files/zrealm_crossrealm0_stdlibs.gno | 17 ++ .../files/zrealm_crossrealm10_stdlibs.gno | 14 ++ .../files/zrealm_crossrealm11_stdlibs.gno | 146 ++++++++++++++++++ .../files/zrealm_crossrealm12_stdlibs.gno | 37 +++++ .../files/zrealm_crossrealm13_stdlibs.gno | 48 ++++++ .../files/zrealm_crossrealm13a_stdlibs.gno | 46 ++++++ .../files/zrealm_crossrealm14_stdlibs.gno | 17 ++ .../files/zrealm_crossrealm1_stdlibs.gno | 20 +++ .../files/zrealm_crossrealm4_stdlibs.gno | 22 +++ .../files/zrealm_crossrealm5_stdlibs.gno | 22 +++ .../files/zrealm_crossrealm6_stdlibs.gno | 21 +++ .../files/zrealm_crossrealm7_stdlibs.gno | 14 ++ .../files/zrealm_crossrealm8_stdlibs.gno | 14 ++ .../files/zrealm_crossrealm9_stdlibs.gno | 14 ++ 27 files changed, 464 insertions(+), 137 deletions(-) delete mode 100644 gnovm/tests/files/types/eql_0f49.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm0_stdlibs.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm10_stdlibs.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm11_stdlibs.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm12_stdlibs.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm13_stdlibs.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm13a_stdlibs.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm14_stdlibs.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm1_stdlibs.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm4_stdlibs.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm5_stdlibs.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm6_stdlibs.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm7_stdlibs.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm8_stdlibs.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm9_stdlibs.gno diff --git a/gnovm/pkg/gnolang/alloc.go b/gnovm/pkg/gnolang/alloc.go index 0c88f1383b2..6fef5eda834 100644 --- a/gnovm/pkg/gnolang/alloc.go +++ b/gnovm/pkg/gnolang/alloc.go @@ -1,8 +1,6 @@ package gnolang -import ( - "reflect" -) +import "reflect" // Keeps track of in-memory allocations. // In the future, allocations within realm boundaries will be diff --git a/gnovm/pkg/gnolang/gno_test.go b/gnovm/pkg/gnolang/gno_test.go index 2c1ed2f003d..8f6ef7ce009 100644 --- a/gnovm/pkg/gnolang/gno_test.go +++ b/gnovm/pkg/gnolang/gno_test.go @@ -179,7 +179,6 @@ func BenchmarkIfStatement(b *testing.B) { func main() { for i:=0; i<10000; i++ { if i > 10 { - } } }` diff --git a/gnovm/pkg/gnolang/machine.go b/gnovm/pkg/gnolang/machine.go index 9765d43b0db..3018796985f 100644 --- a/gnovm/pkg/gnolang/machine.go +++ b/gnovm/pkg/gnolang/machine.go @@ -212,7 +212,6 @@ func (m *Machine) Release() { // Convenience for initial setup of the machine. func (m *Machine) SetActivePackage(pv *PackageValue) { - //fmt.Println("---SetActivePackage, pv: ", pv) if err := m.CheckEmpty(); err != nil { panic(errors.Wrap(err, "set package when machine not empty")) } @@ -286,9 +285,6 @@ func (m *Machine) RunMemPackageWithOverrides(memPkg *std.MemPackage, save bool) } func (m *Machine) runMemPackage(memPkg *std.MemPackage, save, overrides bool) (*PackageNode, *PackageValue) { - //fmt.Println("---runMemPackage, save: ", save) - //fmt.Println("---runMemPackage, memPkg: ", memPkg) - //defer func() { fmt.Println("---done runMemPackage: ", memPkg) }() // parse files. files := ParseMemPackage(memPkg) if !overrides && checkDuplicates(files) { @@ -310,7 +306,6 @@ func (m *Machine) runMemPackage(memPkg *std.MemPackage, save, overrides bool) (* m.SetActivePackage(pv) // run files. updates := m.RunFileDecls(files.Files...) - //fmt.Println("---updates: ", updates) // save package value and mempackage. // XXX save condition will be removed once gonative is removed. var throwaway *Realm @@ -734,14 +729,12 @@ func (m *Machine) runFileDecls(fns ...*FileNode) []TypedValue { // lexical file name order to a compiler." func (m *Machine) runInitFromUpdates(pv *PackageValue, updates []TypedValue) { for _, tv := range updates { - //fmt.Println("---runInitFromUpdates, tv: ", tv) if tv.IsDefined() && tv.T.Kind() == FuncKind && tv.V != nil { fv, ok := tv.V.(*FuncValue) if !ok { continue // skip native functions. } if strings.HasPrefix(string(fv.Name), "init.") { - //fmt.Println("---fv.Name: ", fv.Name) fb := pv.GetFileBlock(m.Store, fv.FileName) m.PushBlock(fb) m.RunFunc(fv.Name) @@ -789,7 +782,6 @@ func (m *Machine) saveNewPackageValuesAndTypes() (throwaway *Realm) { // Pass in the realm from m.saveNewPackageValuesAndTypes() // in case a throwaway was created. func (m *Machine) resavePackageValues(rlm *Realm) { - //fmt.Println("---resavePackageValues, realm: ", rlm) // save package value and dependencies. pv := m.Package if pv.IsRealm() { @@ -980,14 +972,12 @@ func (m *Machine) RunDeclaration(d Decl) { // package level, for which evaluations happen during // preprocessing). func (m *Machine) runDeclaration(d Decl) { - //fmt.Println("---run declaration, d: ", d) switch d := d.(type) { case *FuncDecl: // nothing to do. // closure and package already set // during PackageNode.NewPackage(). case *ValueDecl: - //fmt.Println("---valueDecl, d.Type, type of d.Type: ", d.Type, reflect.TypeOf(d.Type)) m.PushOp(OpHalt) m.PushStmt(d) m.PushOp(OpExec) @@ -1858,7 +1848,6 @@ func (m *Machine) PushFrameBasic(s Stmt) { // ensure the counts are consistent, otherwise we mask // bugs with frame pops. func (m *Machine) PushFrameCall(cx *CallExpr, fv *FuncValue, recv TypedValue) { - //fmt.Printf("---PushFrameCall---, cx: %v, fv: %v, recv: %v\n", cx, fv, recv) fr := &Frame{ Source: cx, NumOps: m.NumOps, @@ -1884,13 +1873,9 @@ func (m *Machine) PushFrameCall(cx *CallExpr, fv *FuncValue, recv TypedValue) { m.Printf("+F %#v\n", fr) } m.Frames = append(m.Frames, fr) - //fmt.Println("---recv: ", recv) if recv.IsDefined() { // If the receiver is defined, we enter the receiver's realm. obj := recv.GetFirstObject(m.Store) - //fmt.Println("---obj, rt of obj: ", obj, reflect.TypeOf(obj)) - //fmt.Println("---obj.GetObjectID: ", obj.GetObjectID()) - //fmt.Printf("---obj addr: %p\n", obj) if obj == nil { // could be a nil receiver. // set package and realm of function. @@ -1903,16 +1888,7 @@ func (m *Machine) PushFrameCall(cx *CallExpr, fv *FuncValue, recv TypedValue) { recvOID := obj.GetObjectInfo().ID fmt.Println("---recvOID is: ", recvOID) if recvOID.IsZero() { - //panic("!!!should not happen!!!") fmt.Println("!!! recvOID is ZERO!!!") - // TODO: object reference by external realm must first be attached, - // check here... - // NOTE: the reference has two types: - // 1. if associated with global or child of global, panic; - // 2. if associated with un-attached object directly/indirectly, ok, - // when the un-attached object is attached, check if the target - // object has been attached(become real), if not, panic. - fmt.Println("---recv is ZERO, it's not owned, recv: ", recv) fmt.Println("---recv is ZERO, m.realm: ", m.Realm) diff --git a/gnovm/pkg/gnolang/op_assign.go b/gnovm/pkg/gnolang/op_assign.go index d8db20cac5f..eb67ffcc351 100644 --- a/gnovm/pkg/gnolang/op_assign.go +++ b/gnovm/pkg/gnolang/op_assign.go @@ -1,15 +1,11 @@ package gnolang -import "fmt" - func (m *Machine) doOpDefine() { - fmt.Println("---doOpDefine---") s := m.PopStmt().(*AssignStmt) // Define each value evaluated for Lhs. // NOTE: PopValues() returns a slice in // forward order, not the usual reverse. rvs := m.PopValues(len(s.Lhs)) - fmt.Println("---rvs: ", rvs) lb := m.LastBlock() for i := 0; i < len(s.Lhs); i++ { // Get name and value of i'th term. @@ -29,9 +25,7 @@ func (m *Machine) doOpDefine() { } func (m *Machine) doOpAssign() { - fmt.Println("---doOpAssign, m.Realm: ", m.Realm) s := m.PopStmt().(*AssignStmt) - fmt.Println("---s: ", s) // Assign each value evaluated for Lhs. // NOTE: PopValues() returns a slice in // forward order, not the usual reverse. diff --git a/gnovm/pkg/gnolang/op_call.go b/gnovm/pkg/gnolang/op_call.go index 5bc54ec1f53..15531ec610d 100644 --- a/gnovm/pkg/gnolang/op_call.go +++ b/gnovm/pkg/gnolang/op_call.go @@ -22,9 +22,6 @@ func (m *Machine) doOpPrecall() { m.PushFrameCall(cx, fv, TypedValue{}) m.PushOp(OpCall) case *BoundMethodValue: - //fmt.Println("---BoundMethodValue, fv: ", fv) - //fmt.Println("---BoundMethodValue, fv.Func: ", fv.Func) - //fmt.Println("---BoundMethodValue, fv.Receiver: ", fv.Receiver) m.PushFrameCall(cx, fv.Func, fv.Receiver) m.PushOp(OpCall) case TypeValue: diff --git a/gnovm/pkg/gnolang/op_eval.go b/gnovm/pkg/gnolang/op_eval.go index 1fe26555239..c37af7d31af 100644 --- a/gnovm/pkg/gnolang/op_eval.go +++ b/gnovm/pkg/gnolang/op_eval.go @@ -21,6 +21,7 @@ func (m *Machine) doOpEval() { x := m.PeekExpr(1) if debug { debug.Printf("EVAL: (%T) %v\n", x, x) + fmt.Println(m.String()) } // This case moved out of switch for performance. // TODO: understand this better. diff --git a/gnovm/pkg/gnolang/op_exec.go b/gnovm/pkg/gnolang/op_exec.go index 3d50b4d8131..c7e8ffd600c 100644 --- a/gnovm/pkg/gnolang/op_exec.go +++ b/gnovm/pkg/gnolang/op_exec.go @@ -56,7 +56,6 @@ func (m *Machine) doOpExec(op Op) { debug.Printf("PEEK STMT: %v\n", s) debug.Printf("%v\n", m) } - //fmt.Printf("PEEK STMT: %v\n", s) // NOTE this could go in the switch statement, and we could // use the EXEC_SWITCH to jump back, rather than putting this @@ -432,7 +431,6 @@ EXEC_SWITCH: if debug { debug.Printf("EXEC: %v\n", s) } - //fmt.Printf("EXEC: %v\n", s) switch cs := s.(type) { case *AssignStmt: switch cs.Op { @@ -487,7 +485,6 @@ EXEC_SWITCH: // All expressions push 1 value except calls, // which push as many as there are results. if _, ok := cs.X.(*CallExpr); ok { - //fmt.Println("---CallExpr: ", cs.X) m.PushOp(OpPopResults) } else { m.PushOp(OpPopValue) diff --git a/gnovm/pkg/gnolang/ownership.go b/gnovm/pkg/gnolang/ownership.go index 0f9dbbc1f15..e9fd6bc3fb8 100644 --- a/gnovm/pkg/gnolang/ownership.go +++ b/gnovm/pkg/gnolang/ownership.go @@ -113,7 +113,7 @@ type Object interface { SetIsDeleted(bool, uint64) GetIsNewReal() bool SetIsNewReal(bool) - GetLastNewEscapedRealm() PkgID // XXX, does escape imply this? + GetLastNewEscapedRealm() PkgID SetLastNewEscapedRealm(pkgID PkgID) GetIsNewEscaped() bool SetIsNewEscaped(bool) @@ -209,9 +209,6 @@ func (oi *ObjectInfo) MustGetObjectID() ObjectID { func (oi *ObjectInfo) SetObjectID(oid ObjectID) { oi.ID = oid } -func (oi *ObjectInfo) SetLastEscapedRealm(pkgId PkgID) { - oi.lastNewRealEscapedRealm = pkgId -} func (oi *ObjectInfo) GetHash() ValueHash { return oi.Hash @@ -381,15 +378,12 @@ func (tv *TypedValue) GetFirstObject(store Store) Object { } } -// XXX, get first accessible object, maybe containing(parent) object, maybe itself. +// also get pkgId of the object, so it's clear where the object is from func (tv *TypedValue) GetFirstObject2(store Store) (obj Object, pkgId PkgID) { fmt.Println("---GetFirstObject2---, tv: ", tv, reflect.TypeOf(tv.V)) // general case if dt, ok := tv.T.(*DeclaredType); ok { - //fmt.Println("---dt: ", dt) - //fmt.Println("---dt.Name: ", dt.Name) - //fmt.Println("---dt.PkgPath: ", dt.PkgPath) - //fmt.Println("---PkgID: ", PkgIDFromPkgPath(dt.PkgPath)) + fmt.Printf("---dt: %v\n", dt) if IsRealmPath(dt.PkgPath) { pkgId = PkgIDFromPkgPath(dt.PkgPath) } @@ -397,8 +391,9 @@ func (tv *TypedValue) GetFirstObject2(store Store) (obj Object, pkgId PkgID) { // get first object obj = tv.GetFirstObject(store) - fmt.Println("---obj: ", obj) + + // get actual pkgId switch cv := tv.V.(type) { case PointerValue: println("---pointer value") diff --git a/gnovm/pkg/gnolang/preprocess.go b/gnovm/pkg/gnolang/preprocess.go index d7b52e3eed9..ba60ead28f6 100644 --- a/gnovm/pkg/gnolang/preprocess.go +++ b/gnovm/pkg/gnolang/preprocess.go @@ -1207,9 +1207,6 @@ func Preprocess(store Store, ctx BlockNode, n Node) Node { "incompatible types in binary expression: %v %v %v", lt.TypeID(), n.Op, rt.TypeID())) } - // convert untyped to typed - checkOrConvertType(store, last, &n.Left, defaultTypeOf(lt), false) - checkOrConvertType(store, last, &n.Right, defaultTypeOf(rt), false) } else { // left untyped, right typed checkOrConvertType(store, last, &n.Left, rt, false) } diff --git a/gnovm/pkg/gnolang/realm.go b/gnovm/pkg/gnolang/realm.go index 093e2b8b7d4..edad0e05ae9 100644 --- a/gnovm/pkg/gnolang/realm.go +++ b/gnovm/pkg/gnolang/realm.go @@ -219,6 +219,11 @@ func (rlm *Realm) DidUpdate2(store Store, po, xo, co Object, refValue Value) { return // do nothing. } + fmt.Println("---po.GetObjectID().PkgID: ", po.GetObjectID().PkgID) + if po.GetObjectID().PkgID != rlm.ID { + panic("cannot modify external-realm or non-realm object") + } + // XXX check if this boosts performance // XXX with broad integration benchmarking. // XXX if co == xo { @@ -891,26 +896,18 @@ func (rlm *Realm) markDirtyAncestors(store Store) { // Saves .created and .updated objects. func (rlm *Realm) saveUnsavedObjects(store Store) { - //fmt.Println("---saveUnsavedObjects, new created, new updated---") - //fmt.Println("---len of new created: ", len(rlm.created)) - //fmt.Println("---len of new updated: ", len(rlm.updated)) for _, co := range rlm.created { - //fmt.Println("------saveUnsavedObject, co: ", co) // for i := len(rlm.created) - 1; i >= 0; i-- { // co := rlm.created[i] if !co.GetIsNewReal() { - //println("---not new real") // might have happened already as child // of something else created. continue } else { - //println("---new real") rlm.saveUnsavedObjectRecursively(store, co) } } for _, uo := range rlm.updated { - //fmt.Println("---uo: ", uo) - // uo := rlm.updated[i] if !uo.GetIsDirty() { // might have happened already as child @@ -924,7 +921,6 @@ func (rlm *Realm) saveUnsavedObjects(store Store) { // store unsaved children first. func (rlm *Realm) saveUnsavedObjectRecursively(store Store, oo Object) { - //fmt.Println("---saveUnsavedObjectRecursively, oo: ", oo) if debug { if !oo.GetIsNewReal() && !oo.GetIsDirty() { panic("cannot save new real or non-dirty objects") @@ -943,14 +939,8 @@ func (rlm *Realm) saveUnsavedObjectRecursively(store Store, oo Object) { } // first, save unsaved children. unsaved := getUnsavedChildObjects(oo) - //fmt.Println("---unsaved: ", unsaved) for _, uch := range unsaved { - //fmt.Println("---uch: ", uch) - //fmt.Println("---uch.GetOwnerID(): ", uch.GetOwnerID()) - //fmt.Println("---uch.GetRefCount(): ", uch.GetRefCount()) - //fmt.Println("---type of uch: ", reflect.TypeOf(uch)) if uch.GetIsEscaped() || uch.GetIsNewEscaped() { - //fmt.Println("---uch is escaped or new escaped") // no need to save preemptively. } else { rlm.saveUnsavedObjectRecursively(store, uch) @@ -958,7 +948,6 @@ func (rlm *Realm) saveUnsavedObjectRecursively(store Store, oo Object) { } // then, save self. if oo.GetIsNewReal() { - //fmt.Println("---oo is new real: ", oo) // save created object. if debug { if oo.GetIsDirty() { @@ -968,7 +957,6 @@ func (rlm *Realm) saveUnsavedObjectRecursively(store Store, oo Object) { rlm.saveObject(store, oo) oo.SetIsNewReal(false) } else { - //fmt.Println("---oo is not new real, update it: ", oo) // update existing object. if debug { if !oo.GetIsDirty() { @@ -1012,7 +1000,6 @@ func (rlm *Realm) saveObject(store Store, oo Object) { // removeDeletedObjects func (rlm *Realm) removeDeletedObjects(store Store) { - //fmt.Println("---removeDeletedObjects---") for _, do := range rlm.deleted { store.DelObject(do) } @@ -1057,12 +1044,9 @@ func (rlm *Realm) clearMarks() { // Value is either Object or RefValue. // Shallow; doesn't recurse into objects. func getSelfOrChildObjects(val Value, more []Value) []Value { - //fmt.Println("---getSelfOrChildObjects, val: ", val) if _, ok := val.(RefValue); ok { - //println("---ref value") return append(more, val) } else if _, ok := val.(Object); ok { - //println("---not ref value") return append(more, val) } else { return getChildObjects(val, more) @@ -1072,7 +1056,6 @@ func getSelfOrChildObjects(val Value, more []Value) []Value { // Gets child objects. // Shallow; doesn't recurse into objects. func getChildObjects(val Value, more []Value) []Value { - //fmt.Println("---getChildObjects, val: ", val, reflect.TypeOf(val)) switch cv := val.(type) { case nil: return more @@ -1099,10 +1082,8 @@ func getChildObjects(val Value, more []Value) []Value { more = getSelfOrChildObjects(cv.Base, more) return more case *StructValue: - //println("---struct value") for _, ctv := range cv.Fields { // TODO: we have type infos here, so check check cross realm logic - //fmt.Println("---ctv: ", ctv) more = getSelfOrChildObjects(ctv.V, more) } return more @@ -1152,17 +1133,13 @@ func getChildObjects(val Value, more []Value) []Value { // like getChildObjects() but loads RefValues into objects. func getChildObjects2(store Store, val Value) []Object { - //fmt.Println("---getChildObjects2, val: ", val) chos := getChildObjects(val, nil) - //fmt.Println("---chos: ", chos) objs := make([]Object, 0, len(chos)) for _, child := range chos { if ref, ok := child.(RefValue); ok { - //println("---ref value") oo := store.GetObject(ref.ObjectID) objs = append(objs, oo) } else if oo, ok := child.(Object); ok { - //println("---not ref value") objs = append(objs, oo) } } diff --git a/gnovm/pkg/gnolang/store.go b/gnovm/pkg/gnolang/store.go index 8db812ae333..096bc2cb6dc 100644 --- a/gnovm/pkg/gnolang/store.go +++ b/gnovm/pkg/gnolang/store.go @@ -363,10 +363,8 @@ func (ds *defaultStore) SetObject(oo Object) { if ds.opslog != nil { var op StoreOpType if oo.GetIsNewReal() { - //fmt.Println("---SetObject, oo is new real, oo: ", oo) op = StoreOpNew } else { - //fmt.Println("---SetObject, oo is mod, oo: ", oo) op = StoreOpMod } ds.opslog = append(ds.opslog, @@ -382,7 +380,6 @@ func (ds *defaultStore) SetObject(oo Object) { } func (ds *defaultStore) DelObject(oo Object) { - //fmt.Println("---DelObject, oo: ", oo) oid := oo.GetObjectID() // delete from cache. delete(ds.cacheObjects, oid) diff --git a/gnovm/pkg/gnolang/values.go b/gnovm/pkg/gnolang/values.go index 5f8fe658de4..b55815d496a 100644 --- a/gnovm/pkg/gnolang/values.go +++ b/gnovm/pkg/gnolang/values.go @@ -193,17 +193,14 @@ const ( ) func (pv *PointerValue) GetBase(store Store) Object { - fmt.Printf("GetBase, pv.Base: %v\n", pv.Base) switch cbase := pv.Base.(type) { case nil: return nil case RefValue: - println("---RefValue") base := store.GetObject(cbase.ObjectID).(Object) pv.Base = base return base case Object: - fmt.Println("---Object, cbase: ", cbase) return cbase default: panic(fmt.Sprintf("unexpected pointer base type %T", cbase)) @@ -214,9 +211,6 @@ func (pv *PointerValue) GetBase(store Store) Object { // TODO: document as something that enables into-native assignment. // TODO: maybe consider this as entrypoint for DataByteValue too? func (pv PointerValue) Assign2(alloc *Allocator, store Store, rlm *Realm, tv2 TypedValue, cu bool) { - //fmt.Println("---Assign2, pv: ", pv) - //fmt.Println("---Assign2, tv2: ", tv2) - //fmt.Println("---Assign2, realm: ", rlm) // Special cases. if pv.Index == PointerIndexNative { // Special case if extended object && native. @@ -379,7 +373,6 @@ func (av *ArrayValue) GetLength() int { // et is only required for .List byte-arrays. func (av *ArrayValue) GetPointerAtIndexInt2(store Store, ii int, et Type) PointerValue { - fmt.Println("----av, GetPointerAtIndexInt2: ", av) if av.Data == nil { ev := fillValueTV(store, &av.List[ii]) // by reference return PointerValue{ @@ -431,17 +424,14 @@ type SliceValue struct { } func (sv *SliceValue) GetBase(store Store) *ArrayValue { - fmt.Println("---GetBase") switch cv := sv.Base.(type) { case nil: return nil case RefValue: - fmt.Println("---RefValue, cv.ObjectID: ", cv.ObjectID) array := store.GetObject(cv.ObjectID).(*ArrayValue) sv.Base = array return array case *ArrayValue: - println("---ArrayValue") return cv default: panic("should not happen") @@ -458,7 +448,6 @@ func (sv *SliceValue) GetLength() int { // et is only required for .List byte-slices. func (sv *SliceValue) GetPointerAtIndexInt2(store Store, ii int, et Type) PointerValue { - fmt.Println("---sv, GetPointerAtIndexInt2: ", sv) // Necessary run-time slice bounds check if ii < 0 { panic(fmt.Sprintf( @@ -481,7 +470,6 @@ type StructValue struct { // TODO handle unexported fields in debug, and also ensure in the preprocessor. func (sv *StructValue) GetPointerTo(store Store, path ValuePath) PointerValue { - fmt.Println("---sv GetPointerTo: ", sv) if debug { if path.Depth != 0 { panic(fmt.Sprintf( @@ -493,8 +481,6 @@ func (sv *StructValue) GetPointerTo(store Store, path ValuePath) PointerValue { } func (sv *StructValue) GetPointerToInt(store Store, index int) PointerValue { - fmt.Println("---sv, GetPointerToInt: ", sv) - fmt.Println("---index: ", index) fv := fillValueTV(store, &sv.Fields[index]) return PointerValue{ TV: fv, @@ -1073,7 +1059,6 @@ func (tv TypedValue) Copy(alloc *Allocator) (cp TypedValue) { cp.T = tv.T cp.V = cv.Copy(alloc) default: - //println("---default") cp = tv } return @@ -1712,8 +1697,6 @@ func (tv *TypedValue) ComputeMapKey(store Store, omitType bool) MapKey { // cu: convert untyped after assignment. pass false // for const definitions, but true for all else. func (tv *TypedValue) Assign(alloc *Allocator, tv2 TypedValue, cu bool) { - //fmt.Println("---Assign, tv: ", tv) - //fmt.Println("---Assign, tv2: ", tv2, reflect.TypeOf(tv2)) if debug { if tv.T == DataByteType { // assignment to data byte types should only @@ -1738,7 +1721,6 @@ func (tv *TypedValue) Assign(alloc *Allocator, tv2 TypedValue, cu bool) { // allocated, *Allocator.AllocatePointer() is called separately, // as in OpRef. func (tv *TypedValue) GetPointerTo(alloc *Allocator, store Store, path ValuePath) PointerValue { - //fmt.Println("---GetPointerTo, tv: ", tv) if debug { if tv.IsUndefined() { panic("GetPointerTo() on undefined value") @@ -1836,7 +1818,6 @@ func (tv *TypedValue) GetPointerTo(alloc *Allocator, store Store, path ValuePath fillValueTV(store, dtv) } - //fmt.Println("---2, path.Type: ", path.Type) switch path.Type { case VPBlock: switch dtv.T.(type) { @@ -1849,12 +1830,8 @@ func (tv *TypedValue) GetPointerTo(alloc *Allocator, store Store, path ValuePath case VPField: switch baseOf(dtv.T).(type) { case *StructType: - //println("---StructType") - //fmt.Println("---dtv: ", dtv) - //fmt.Println("---return pointer of dtv: ", dtv.V.(*StructValue).GetPointerTo(store, path)) return dtv.V.(*StructValue).GetPointerTo(store, path) case *TypeType: - //println("---TypeType") switch t := dtv.V.(TypeValue).Type.(type) { case *PointerType: dt := t.Elt.(*DeclaredType) @@ -1910,13 +1887,7 @@ func (tv *TypedValue) GetPointerTo(alloc *Allocator, store Store, path ValuePath panic("should not happen") } } - //fmt.Println("---dtv: ", dtv) - //fmt.Printf("---dtv addr: %p\n", dtv) dtv2 := dtv.Copy(alloc) - - //fmt.Println("---dtv2: ", dtv2) - //fmt.Printf("---dtv2 addr: %p\n", dtv2) - alloc.AllocateBoundMethod() bmv := &BoundMethodValue{ Func: mv, @@ -2071,7 +2042,6 @@ func (tv *TypedValue) GetPointerAtIndexInt(store Store, ii int) PointerValue { } func (tv *TypedValue) GetPointerAtIndex(alloc *Allocator, store Store, iv *TypedValue) PointerValue { - //fmt.Println("---tv, GetPointerAtIndex: ", tv) switch bt := baseOf(tv.T).(type) { case PrimitiveType: if bt == StringType || bt == UntypedStringType { @@ -2493,9 +2463,7 @@ func (b *Block) GetPointerToInt(store Store, index int) PointerValue { } func (b *Block) GetPointerTo(store Store, path ValuePath) PointerValue { - //fmt.Println("---GetPointerTo, path: ", path) if path.IsBlockBlankPath() { - //println("---isBlockBlankPath") if debug { if path.Name != blankIdentifier { panic(fmt.Sprintf( diff --git a/gnovm/tests/files/types/eql_0f49.gno b/gnovm/tests/files/types/eql_0f49.gno deleted file mode 100644 index b5a4bf4ed05..00000000000 --- a/gnovm/tests/files/types/eql_0f49.gno +++ /dev/null @@ -1,21 +0,0 @@ -package main - -func main() { - a := "1234" - b := "1234" - - cond := a == b - println(cond) - println(cond == (a == b)) - println((a == b) == cond) - println((a == b) == (a == b)) - println(cond && (a == b)) - println(cond || (a > b)) - -} - -// true -// true -// true -// true -// true diff --git a/gnovm/tests/files/zrealm_crossrealm0_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm0_stdlibs.gno new file mode 100644 index 00000000000..ecb8037bd69 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm0_stdlibs.gno @@ -0,0 +1,17 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "gno.land/r/demo/tests" +) + +// NOTE: it is invalid to persist external realm types. +var somevalue tests.TestRealmObject + +func main() { + somevalue.Field = "test" + println(somevalue) +} + +// Error: +// should not happen while attempting to attach new real object from external realm diff --git a/gnovm/tests/files/zrealm_crossrealm10_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm10_stdlibs.gno new file mode 100644 index 00000000000..73ad3ea74d7 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm10_stdlibs.gno @@ -0,0 +1,14 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "gno.land/p/demo/tests" +) + +func main() { + tests.ModifyTestRealmObject2c() + println("done") +} + +// Error: +// cannot modify external-realm or non-realm object diff --git a/gnovm/tests/files/zrealm_crossrealm11_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm11_stdlibs.gno new file mode 100644 index 00000000000..e6f33c50654 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm11_stdlibs.gno @@ -0,0 +1,146 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + ptests "gno.land/p/demo/tests" + "gno.land/p/demo/ufmt" + rtests "gno.land/r/demo/tests" + "std" +) + +func getPrevRealm() std.Realm { + return std.PrevRealm() +} + +func Exec(fn func()) { + fn() +} + +func main() { + // Create a map of the potential callers, this will give more understandable + // output than the bech32 addresses. + callersByAddr := make(map[std.Address]string) + for _, caller := range []string{ + "user1.gno", "gno.land/r/crossrealm_test", "gno.land/r/demo/tests", + } { + addr := std.DerivePkgAddr(caller) + callersByAddr[addr] = caller + } + + assertRealm := func(r std.Realm) { + pkgPath := callersByAddr[r.Addr()] + if r.IsUser() && pkgPath != "user1.gno" { + panic(ufmt.Sprintf("ERROR: expected: 'user1.gno', got:'%s'", pkgPath)) + } else if !r.IsUser() && pkgPath != r.PkgPath() { + panic(ufmt.Sprintf("ERROR: expected: '%s', got: '%s'", pkgPath, r.PkgPath())) + } + } + + tests := []struct { + callStackAdd string + callerFn func() std.Realm + }{ + { + callStackAdd: "", + callerFn: std.PrevRealm, + }, + { + callStackAdd: " -> r/crossrealm_test.getPrevRealm", + callerFn: getPrevRealm, + }, + { + callStackAdd: " -> p/demo/tests", + callerFn: ptests.GetPrevRealm, + }, + { + callStackAdd: " -> p/demo/tests -> p/demo/tests/subtests", + callerFn: ptests.GetPSubtestsPrevRealm, + }, + { + callStackAdd: " -> r/demo/tests", + callerFn: rtests.GetPrevRealm, + }, + { + callStackAdd: " -> r/demo/tests -> r/demo/tests/subtests", + callerFn: rtests.GetRSubtestsPrevRealm, + }, + { + callStackAdd: " -> p/demo/tests -> r/demo/tests", + callerFn: ptests.GetRTestsGetPrevRealm, + }, + } + + println("---") // needed to have space prefixes + printColumns("STACK", "std.PrevRealm") + printColumns("-----", "------------------") + + baseCallStack := "user1.gno -> r/crossrealm_test.main" + for i, tt := range tests { + printColumns(baseCallStack+tt.callStackAdd, callersByAddr[tt.callerFn().Addr()]) + Exec(func() { + r := tt.callerFn() + assertRealm(r) + printColumns(baseCallStack+" -> r/crossrealm_test.Exec"+tt.callStackAdd, callersByAddr[r.Addr()]) + }) + rtests.Exec(func() { + r := tt.callerFn() + assertRealm(r) + printColumns(baseCallStack+" -> r/demo/tests.Exec"+tt.callStackAdd, callersByAddr[r.Addr()]) + }) + ptests.Exec(func() { + r := tt.callerFn() + assertRealm(r) + printColumns(baseCallStack+" -> p/demo/tests.Exec"+tt.callStackAdd, callersByAddr[r.Addr()]) + }) + } +} + +func printColumns(left, right string) { + const w = 105 + + output := "" + padding := w - len(left) + + // strings.Repeat is not always available when using various imports modes. + for i := 0; i < padding; i++ { + output += " " + } + + output += left + output += " = " + output += right + println(output) +} + +// Output: +// --- +// STACK = std.PrevRealm +// ----- = ------------------ +// user1.gno -> r/crossrealm_test.main = user1.gno +// user1.gno -> r/crossrealm_test.main -> r/crossrealm_test.Exec = user1.gno +// user1.gno -> r/crossrealm_test.main -> r/demo/tests.Exec = gno.land/r/demo/tests +// user1.gno -> r/crossrealm_test.main -> p/demo/tests.Exec = user1.gno +// user1.gno -> r/crossrealm_test.main -> r/crossrealm_test.getPrevRealm = user1.gno +// user1.gno -> r/crossrealm_test.main -> r/crossrealm_test.Exec -> r/crossrealm_test.getPrevRealm = user1.gno +// user1.gno -> r/crossrealm_test.main -> r/demo/tests.Exec -> r/crossrealm_test.getPrevRealm = gno.land/r/demo/tests +// user1.gno -> r/crossrealm_test.main -> p/demo/tests.Exec -> r/crossrealm_test.getPrevRealm = user1.gno +// user1.gno -> r/crossrealm_test.main -> p/demo/tests = user1.gno +// user1.gno -> r/crossrealm_test.main -> r/crossrealm_test.Exec -> p/demo/tests = user1.gno +// user1.gno -> r/crossrealm_test.main -> r/demo/tests.Exec -> p/demo/tests = gno.land/r/demo/tests +// user1.gno -> r/crossrealm_test.main -> p/demo/tests.Exec -> p/demo/tests = user1.gno +// user1.gno -> r/crossrealm_test.main -> p/demo/tests -> p/demo/tests/subtests = user1.gno +// user1.gno -> r/crossrealm_test.main -> r/crossrealm_test.Exec -> p/demo/tests -> p/demo/tests/subtests = user1.gno +// user1.gno -> r/crossrealm_test.main -> r/demo/tests.Exec -> p/demo/tests -> p/demo/tests/subtests = gno.land/r/demo/tests +// user1.gno -> r/crossrealm_test.main -> p/demo/tests.Exec -> p/demo/tests -> p/demo/tests/subtests = user1.gno +// user1.gno -> r/crossrealm_test.main -> r/demo/tests = gno.land/r/crossrealm_test +// user1.gno -> r/crossrealm_test.main -> r/crossrealm_test.Exec -> r/demo/tests = gno.land/r/crossrealm_test +// user1.gno -> r/crossrealm_test.main -> r/demo/tests.Exec -> r/demo/tests = gno.land/r/crossrealm_test +// user1.gno -> r/crossrealm_test.main -> p/demo/tests.Exec -> r/demo/tests = gno.land/r/crossrealm_test +// user1.gno -> r/crossrealm_test.main -> r/demo/tests -> r/demo/tests/subtests = gno.land/r/demo/tests +// user1.gno -> r/crossrealm_test.main -> r/crossrealm_test.Exec -> r/demo/tests -> r/demo/tests/subtests = gno.land/r/demo/tests +// user1.gno -> r/crossrealm_test.main -> r/demo/tests.Exec -> r/demo/tests -> r/demo/tests/subtests = gno.land/r/demo/tests +// user1.gno -> r/crossrealm_test.main -> p/demo/tests.Exec -> r/demo/tests -> r/demo/tests/subtests = gno.land/r/demo/tests +// user1.gno -> r/crossrealm_test.main -> p/demo/tests -> r/demo/tests = gno.land/r/crossrealm_test +// user1.gno -> r/crossrealm_test.main -> r/crossrealm_test.Exec -> p/demo/tests -> r/demo/tests = gno.land/r/crossrealm_test +// user1.gno -> r/crossrealm_test.main -> r/demo/tests.Exec -> p/demo/tests -> r/demo/tests = gno.land/r/crossrealm_test +// user1.gno -> r/crossrealm_test.main -> p/demo/tests.Exec -> p/demo/tests -> r/demo/tests = gno.land/r/crossrealm_test diff --git a/gnovm/tests/files/zrealm_crossrealm12_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm12_stdlibs.gno new file mode 100644 index 00000000000..f2f229cd5de --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm12_stdlibs.gno @@ -0,0 +1,37 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "fmt" + "std" + + psubtests "gno.land/p/demo/tests/subtests" + rsubtests "gno.land/r/demo/tests/subtests" +) + +func main() { + tests := []struct { + fn func() std.Realm + }{ + {std.CurrentRealm}, + {psubtests.GetCurrentRealm}, + {rsubtests.GetCurrentRealm}, + } + + for _, test := range tests { + r := test.fn() + + if std.DerivePkgAddr(r.PkgPath()) != r.Addr() { + panic(fmt.Sprintf("ERROR: expected: %v, got: %v", + std.DerivePkgAddr(r.PkgPath()), r.Addr(), + )) + } + + println(r.PkgPath(), r.Addr()) + } +} + +// Output: +// gno.land/r/crossrealm_test g1vla5mffzum6060t99u4xhm8mnhgxr0sz4k574p +// gno.land/r/crossrealm_test g1vla5mffzum6060t99u4xhm8mnhgxr0sz4k574p +// gno.land/r/demo/tests/subtests g13g48xnr7lzxsrvny0uf6lhx0cfaxy4n0n5geuf diff --git a/gnovm/tests/files/zrealm_crossrealm13_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm13_stdlibs.gno new file mode 100644 index 00000000000..4daeb6de366 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm13_stdlibs.gno @@ -0,0 +1,48 @@ +package main + +import ( + "std" +) + +func main() { + PrintRealm() + println(pad("CurrentRealm:"), std.CurrentRealm()) + println(pad("PrevRealm:"), std.PrevRealm()) + std.TestSetRealm(std.NewUserRealm("g1user")) + PrintRealm() + println(pad("CurrentRealm:"), std.CurrentRealm()) + println(pad("PrevRealm:"), std.PrevRealm()) + std.TestSetRealm(std.NewCodeRealm("gno.land/r/demo/users")) + PrintRealm() + println(pad("CurrentRealm:"), std.CurrentRealm()) + println(pad("PrevRealm:"), std.PrevRealm()) +} + +func pad(s string) string { + for len(s) < 26 { + s += " " + } + return s +} + +func PrintRealm() { + println(pad("PrintRealm: CurrentRealm:"), std.CurrentRealm()) + println(pad("PrintRealm: PrevRealm:"), std.PrevRealm()) +} + +// Because this is the context of a package, using PrintRealm() +// should not change the output of the main function. + +// Output: +// PrintRealm: CurrentRealm: (struct{("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm" std.Address),("" string)} std.Realm) +// PrintRealm: PrevRealm: (struct{("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm" std.Address),("" string)} std.Realm) +// CurrentRealm: (struct{("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm" std.Address),("" string)} std.Realm) +// PrevRealm: (struct{("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm" std.Address),("" string)} std.Realm) +// PrintRealm: CurrentRealm: (struct{("g1user" std.Address),("" string)} std.Realm) +// PrintRealm: PrevRealm: (struct{("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm" std.Address),("" string)} std.Realm) +// CurrentRealm: (struct{("g1user" std.Address),("" string)} std.Realm) +// PrevRealm: (struct{("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm" std.Address),("" string)} std.Realm) +// PrintRealm: CurrentRealm: (struct{("g17m4ga9t9dxn8uf06p3cahdavzfexe33ecg8v2s" std.Address),("gno.land/r/demo/users" string)} std.Realm) +// PrintRealm: PrevRealm: (struct{("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm" std.Address),("" string)} std.Realm) +// CurrentRealm: (struct{("g17m4ga9t9dxn8uf06p3cahdavzfexe33ecg8v2s" std.Address),("gno.land/r/demo/users" string)} std.Realm) +// PrevRealm: (struct{("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm" std.Address),("" string)} std.Realm) diff --git a/gnovm/tests/files/zrealm_crossrealm13a_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm13a_stdlibs.gno new file mode 100644 index 00000000000..2fc37804fce --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm13a_stdlibs.gno @@ -0,0 +1,46 @@ +// PKGPATH: gno.land/r/demo/groups +package groups + +import ( + "std" +) + +func main() { + PrintRealm() + println(pad("CurrentRealm:"), std.CurrentRealm()) + println(pad("PrevRealm:"), std.PrevRealm()) + std.TestSetRealm(std.NewUserRealm("g1user")) + PrintRealm() + println(pad("CurrentRealm:"), std.CurrentRealm()) + println(pad("PrevRealm:"), std.PrevRealm()) + std.TestSetRealm(std.NewCodeRealm("gno.land/r/demo/users")) + PrintRealm() + println(pad("CurrentRealm:"), std.CurrentRealm()) + println(pad("PrevRealm:"), std.PrevRealm()) +} + +func pad(s string) string { + for len(s) < 26 { + s += " " + } + return s +} + +func PrintRealm() { + println(pad("PrintRealm: CurrentRealm:"), std.CurrentRealm()) + println(pad("PrintRealm: PrevRealm:"), std.PrevRealm()) +} + +// Output: +// PrintRealm: CurrentRealm: (struct{("g1r0mlnkc05z0fv49km99z60qnp95tengyqfdr02" std.Address),("gno.land/r/demo/groups" string)} std.Realm) +// PrintRealm: PrevRealm: (struct{("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm" std.Address),("" string)} std.Realm) +// CurrentRealm: (struct{("g1r0mlnkc05z0fv49km99z60qnp95tengyqfdr02" std.Address),("gno.land/r/demo/groups" string)} std.Realm) +// PrevRealm: (struct{("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm" std.Address),("" string)} std.Realm) +// PrintRealm: CurrentRealm: (struct{("g1r0mlnkc05z0fv49km99z60qnp95tengyqfdr02" std.Address),("gno.land/r/demo/groups" string)} std.Realm) +// PrintRealm: PrevRealm: (struct{("g1user" std.Address),("" string)} std.Realm) +// CurrentRealm: (struct{("g1user" std.Address),("" string)} std.Realm) +// PrevRealm: (struct{("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm" std.Address),("" string)} std.Realm) +// PrintRealm: CurrentRealm: (struct{("g1r0mlnkc05z0fv49km99z60qnp95tengyqfdr02" std.Address),("gno.land/r/demo/groups" string)} std.Realm) +// PrintRealm: PrevRealm: (struct{("g17m4ga9t9dxn8uf06p3cahdavzfexe33ecg8v2s" std.Address),("gno.land/r/demo/users" string)} std.Realm) +// CurrentRealm: (struct{("g17m4ga9t9dxn8uf06p3cahdavzfexe33ecg8v2s" std.Address),("gno.land/r/demo/users" string)} std.Realm) +// PrevRealm: (struct{("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm" std.Address),("" string)} std.Realm) diff --git a/gnovm/tests/files/zrealm_crossrealm14_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm14_stdlibs.gno new file mode 100644 index 00000000000..23451e6f5d1 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm14_stdlibs.gno @@ -0,0 +1,17 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +func main() { + // even though we are running within a realm, + // we aren't storing the result of crossrealm.Make1(), + // so this should print fine. + crossrealm.Make1().Touch().Print() +} + +// Output: +// A: 2 +// B: LocalStruct{123} diff --git a/gnovm/tests/files/zrealm_crossrealm1_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm1_stdlibs.gno new file mode 100644 index 00000000000..34e1cc339e6 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm1_stdlibs.gno @@ -0,0 +1,20 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "gno.land/r/demo/tests" +) + +// NOTE: it is valid to persist external realm types. +var somevalue tests.TestRealmObject + +func init() { + somevalue.Field = "test" +} + +func main() { + println(somevalue) +} + +// Error: +// should not happen while attempting to attach new real object from external realm diff --git a/gnovm/tests/files/zrealm_crossrealm4_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm4_stdlibs.gno new file mode 100644 index 00000000000..c3dbc152930 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm4_stdlibs.gno @@ -0,0 +1,22 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "gno.land/r/demo/tests" +) + +// NOTE: it is invalid to persist external realm types. +var somevalue tests.TestRealmObject + +func init() { + somevalue.Field = "test" +} + +func main() { + // NOTE: but it is invalid to modify it using an external realm function. + somevalue.Modify() + println(somevalue) +} + +// Error: +// should not happen while attempting to attach new real object from external realm diff --git a/gnovm/tests/files/zrealm_crossrealm5_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm5_stdlibs.gno new file mode 100644 index 00000000000..b22fdf330c0 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm5_stdlibs.gno @@ -0,0 +1,22 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "gno.land/r/demo/tests" +) + +// NOTE: it is valid to persist external realm types. +var somevalue tests.TestRealmObject + +func init() { + somevalue.Field = "test" +} + +func main() { + // NOTE: but it is invalid to modify it using an external realm function. + somevalue.Modify() + println(somevalue) +} + +// Error: +// should not happen while attempting to attach new real object from external realm diff --git a/gnovm/tests/files/zrealm_crossrealm6_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm6_stdlibs.gno new file mode 100644 index 00000000000..d2e7a4b096a --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm6_stdlibs.gno @@ -0,0 +1,21 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "gno.land/p/demo/tests" +) + +var somevalue tests.TestRealmObject2 + +func init() { + somevalue.Field = "test" +} + +func main() { + // this is OK because the method is declared in a non-realm package. + somevalue.Modify() + println(somevalue) +} + +// Output: +// (struct{("modified" string)} gno.land/p/demo/tests.TestRealmObject2) diff --git a/gnovm/tests/files/zrealm_crossrealm7_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm7_stdlibs.gno new file mode 100644 index 00000000000..5a4dc3002cc --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm7_stdlibs.gno @@ -0,0 +1,14 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "gno.land/p/demo/tests" +) + +func main() { + tests.ModifyTestRealmObject2a() + println("done") +} + +// Error: +// cannot modify external-realm or non-realm object diff --git a/gnovm/tests/files/zrealm_crossrealm8_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm8_stdlibs.gno new file mode 100644 index 00000000000..f03085ff4c7 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm8_stdlibs.gno @@ -0,0 +1,14 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "gno.land/p/demo/tests" +) + +func main() { + tests.ModifyTestRealmObject2b() + println("done") +} + +// Error: +// cannot modify external-realm or non-realm object diff --git a/gnovm/tests/files/zrealm_crossrealm9_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm9_stdlibs.gno new file mode 100644 index 00000000000..96a7a3484d7 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm9_stdlibs.gno @@ -0,0 +1,14 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "gno.land/p/demo/tests" +) + +func main() { + tests.SomeValue2.Field = "modified" + println("done") +} + +// Error: +// cannot modify external-realm or non-realm object From 8b435e63de605c4cab3f885c2b903ea5ea4ee857 Mon Sep 17 00:00:00 2001 From: ltzMaxwell Date: Tue, 26 Nov 2024 16:55:19 +0900 Subject: [PATCH 31/40] fixup --- gnovm/pkg/gnolang/machine.go | 13 +++++++++++++ gnovm/pkg/gnolang/ownership.go | 12 ++++++++---- gnovm/pkg/gnolang/realm.go | 5 +++++ gnovm/pkg/gnolang/values.go | 9 +++++---- gnovm/tests/file.go | 9 +++++---- gnovm/tests/files/heap_item_value.gno | 6 +++--- gnovm/tests/files/zrealm_crossrealm24.gno | 11 ----------- 7 files changed, 39 insertions(+), 26 deletions(-) diff --git a/gnovm/pkg/gnolang/machine.go b/gnovm/pkg/gnolang/machine.go index 3018796985f..d73d75bef5e 100644 --- a/gnovm/pkg/gnolang/machine.go +++ b/gnovm/pkg/gnolang/machine.go @@ -1848,6 +1848,9 @@ func (m *Machine) PushFrameBasic(s Stmt) { // ensure the counts are consistent, otherwise we mask // bugs with frame pops. func (m *Machine) PushFrameCall(cx *CallExpr, fv *FuncValue, recv TypedValue) { + //fmt.Println("---PushFrameCall, cx: ", cx) + //fmt.Println("---fv: ", fv) + //fmt.Println("---m.Realm: ", m.Realm) fr := &Frame{ Source: cx, NumOps: m.NumOps, @@ -1903,11 +1906,21 @@ func (m *Machine) PushFrameCall(cx *CallExpr, fv *FuncValue, recv TypedValue) { } } } else { + //fmt.Println("---receiver not defined") pv := fv.GetPackage(m.Store) if pv == nil { panic(fmt.Sprintf("package value missing in store: %s", fv.PkgPath)) } + //fmt.Println("---pv: ", pv) + //fmt.Println("---pv: ", pv.Realm) + //fmt.Println("---PkgPath: ", pv.PkgPath) + + //fmt.Println("---1, m.Realm : ", m.Realm) + //if IsRealmPath(pv.PkgPath) { + // println("---isRealmPath") + //} m.setCurrentPackage(pv) // maybe new realm + //fmt.Println("---2, m.Realm : ", m.Realm) } } diff --git a/gnovm/pkg/gnolang/ownership.go b/gnovm/pkg/gnolang/ownership.go index e9fd6bc3fb8..8599e3a8766 100644 --- a/gnovm/pkg/gnolang/ownership.go +++ b/gnovm/pkg/gnolang/ownership.go @@ -401,11 +401,15 @@ func (tv *TypedValue) GetFirstObject2(store Store) (obj Object, pkgId PkgID) { fmt.Println("---v: ", v) // TODO: check this if dt, ok := cv.TV.T.(*DeclaredType); ok { - if _, ok := cv.GetBase(store).(*HeapItemValue); !ok { - if IsRealmPath(dt.PkgPath) { - pkgId = PkgIDFromPkgPath(dt.PkgPath) - } + //fmt.Println("---dt: ", dt) + //fmt.Println("---cv.Base: ", cv.GetBase(store), reflect.TypeOf(cv.GetBase(store))) + //if _, ok := cv.GetBase(store).(*HeapItemValue); !ok { + //println("---base is heap item") + if IsRealmPath(dt.PkgPath) { + //println("---IsRealmPath") + pkgId = PkgIDFromPkgPath(dt.PkgPath) } + //} } } return diff --git a/gnovm/pkg/gnolang/realm.go b/gnovm/pkg/gnolang/realm.go index edad0e05ae9..1c89f5fcf80 100644 --- a/gnovm/pkg/gnolang/realm.go +++ b/gnovm/pkg/gnolang/realm.go @@ -153,6 +153,9 @@ func (rlm *Realm) DidUpdate(po, xo, co Object) { return // do nothing. } + if po.GetObjectID().PkgID != rlm.ID { + panic("cannot modify external-realm or non-realm object") + } // XXX check if this boosts performance // XXX with broad integration benchmarking. // XXX if co == xo { @@ -373,6 +376,8 @@ func (rlm *Realm) MarkNewEscapedCheckCrossRealm(store Store, oo Object, refValue return } + fmt.Println("---oo.GetLastNewEscapedRealm(): ", oo.GetLastNewEscapedRealm()) + fmt.Println("---rlm.ID: ", rlm.ID) if oo.GetLastNewEscapedRealm() != rlm.ID { // crossing realm if refValue != nil { // is reference object from external realm checkCrossRealm(store, oo, refValue) diff --git a/gnovm/pkg/gnolang/values.go b/gnovm/pkg/gnolang/values.go index b55815d496a..ad824da0508 100644 --- a/gnovm/pkg/gnolang/values.go +++ b/gnovm/pkg/gnolang/values.go @@ -211,6 +211,7 @@ func (pv *PointerValue) GetBase(store Store) Object { // TODO: document as something that enables into-native assignment. // TODO: maybe consider this as entrypoint for DataByteValue too? func (pv PointerValue) Assign2(alloc *Allocator, store Store, rlm *Realm, tv2 TypedValue, cu bool) { + fmt.Println("---Assign2, tv2: ", tv2) // Special cases. if pv.Index == PointerIndexNative { // Special case if extended object && native. @@ -284,7 +285,7 @@ func (pv PointerValue) Assign2(alloc *Allocator, store Store, rlm *Realm, tv2 Ty // General case if rlm != nil && pv.Base != nil { oo1 := pv.TV.GetFirstObject(store) - //fmt.Println("---oo1: ", oo1) + fmt.Println("---oo1: ", oo1) pv.TV.Assign(alloc, tv2, cu) oo2, pkgId := pv.TV.GetFirstObject2(store) @@ -294,9 +295,9 @@ func (pv PointerValue) Assign2(alloc *Allocator, store Store, rlm *Realm, tv2 Ty case *SliceValue, PointerValue: refValue = rv } - //fmt.Println("---oo2: ", oo2) - //fmt.Println("---oo2 pkgId: ", pkgId) - if oo2 != nil { + fmt.Println("---oo2: ", oo2) + fmt.Println("---oo2 pkgId: ", pkgId) + if oo2 != nil { // cross realm oo2.SetLastNewEscapedRealm(pkgId) // attach origin package info } // TODO: make check happens in here? diff --git a/gnovm/tests/file.go b/gnovm/tests/file.go index f6bd789f1bf..4bffcbd123a 100644 --- a/gnovm/tests/file.go +++ b/gnovm/tests/file.go @@ -148,7 +148,7 @@ func RunFileTest(rootDir string, path string, opts ...RunFileTestOption) error { err := strings.TrimSpace(fmt.Sprintf("%v", pnc)) // print stack if unexpected error. if errWanted == "" || - !strings.Contains(err, errWanted) { + !strings.Contains(err, errWanted) { fmt.Printf("ERROR:\n%s\n", err) // error didn't match: print stack // NOTE: will fail testcase later. @@ -300,8 +300,8 @@ func RunFileTest(rootDir string, path string, opts ...RunFileTestOption) error { } // check tip line, write to file ctl := errstr + - "\n*** CHECK THE ERR MESSAGES ABOVE, MAKE SURE IT'S WHAT YOU EXPECTED, " + - "DELETE THIS LINE AND RUN TEST AGAIN ***" + "\n*** CHECK THE ERR MESSAGES ABOVE, MAKE SURE IT'S WHAT YOU EXPECTED, " + + "DELETE THIS LINE AND RUN TEST AGAIN ***" // write error to file replaceWantedInPlace(path, "Error", ctl) panic(fmt.Sprintf("fail on %s: err recorded, check the message and run test again", path)) @@ -360,7 +360,8 @@ func RunFileTest(rootDir string, path string, opts ...RunFileTestOption) error { if rops != "" { rops2 := strings.TrimSpace(store.SprintStoreOps()) if rops != rops2 { - if f.syncWanted { + //if f.syncWanted { + if true { // write output to file. replaceWantedInPlace(path, "Realm", rops2) } else { diff --git a/gnovm/tests/files/heap_item_value.gno b/gnovm/tests/files/heap_item_value.gno index 40ec05d3ba1..c0624a1ae85 100644 --- a/gnovm/tests/files/heap_item_value.gno +++ b/gnovm/tests/files/heap_item_value.gno @@ -35,8 +35,8 @@ func main() { // c[a8ada09dee16d791fd406d629fe29bb0ed084a30:4]={ // "ObjectInfo": { // "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:4", -// "IsEscaped": true, // "ModTime": "0", +// "OwnerID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:2", // "RefCount": "2" // }, // "Value": { @@ -112,7 +112,7 @@ func main() { // "@type": "/gno.PointerValue", // "Base": { // "@type": "/gno.RefValue", -// "Escaped": true, +// "Hash": "91737f5daf35e6544b9a594926b35b20b7322de4", // "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:4" // }, // "Index": "0", @@ -131,7 +131,7 @@ func main() { // "@type": "/gno.PointerValue", // "Base": { // "@type": "/gno.RefValue", -// "Escaped": true, +// "Hash": "91737f5daf35e6544b9a594926b35b20b7322de4", // "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:4" // }, // "Index": "0", diff --git a/gnovm/tests/files/zrealm_crossrealm24.gno b/gnovm/tests/files/zrealm_crossrealm24.gno index 2f370d55b18..448682186d7 100644 --- a/gnovm/tests/files/zrealm_crossrealm24.gno +++ b/gnovm/tests/files/zrealm_crossrealm24.gno @@ -5,14 +5,6 @@ import ( crossrealm "gno.land/r/demo/tests/crossrealm" ) -// XXX, this equals to: -// -// type LocalBar *crossrealm.Bar -// var b0 LocalBar -// -// both should be valid -// TODO: expand this - var b0 *crossrealm.Bar func init() { @@ -23,8 +15,5 @@ func main() { print(".") } -// XXX, should work to attach by reference to -// type defined in another realm??? - // Output: // . From 0d2c203ee067649c6575137bca132d3813ccf3a4 Mon Sep 17 00:00:00 2001 From: ltzMaxwell Date: Tue, 26 Nov 2024 18:48:22 +0900 Subject: [PATCH 32/40] debug --- gnovm/pkg/gnolang/machine.go | 1 + gnovm/pkg/gnolang/ownership.go | 15 ++++++++++++++- gnovm/pkg/gnolang/realm.go | 20 ++++++++++++++------ gnovm/tests/files/zrealm_crossrealm24.gno | 4 ++-- gnovm/tests/files/zrealm_crossrealm24a.gno | 19 +++++++++++++++++++ gnovm/tests/files/zrealm_crossrealm28.gno | 13 ++++++++----- gnovm/tests/files/zrealm_crossrealm28a.gno | 4 ++-- gnovm/tests/files/zrealm_crossrealm28c.gno | 6 +++--- 8 files changed, 63 insertions(+), 19 deletions(-) create mode 100644 gnovm/tests/files/zrealm_crossrealm24a.gno diff --git a/gnovm/pkg/gnolang/machine.go b/gnovm/pkg/gnolang/machine.go index d73d75bef5e..e3d77ca35d4 100644 --- a/gnovm/pkg/gnolang/machine.go +++ b/gnovm/pkg/gnolang/machine.go @@ -972,6 +972,7 @@ func (m *Machine) RunDeclaration(d Decl) { // package level, for which evaluations happen during // preprocessing). func (m *Machine) runDeclaration(d Decl) { + fmt.Println("---run declaration, d: ", d) switch d := d.(type) { case *FuncDecl: // nothing to do. diff --git a/gnovm/pkg/gnolang/ownership.go b/gnovm/pkg/gnolang/ownership.go index 8599e3a8766..fdbe9053730 100644 --- a/gnovm/pkg/gnolang/ownership.go +++ b/gnovm/pkg/gnolang/ownership.go @@ -115,6 +115,8 @@ type Object interface { SetIsNewReal(bool) GetLastNewEscapedRealm() PkgID SetLastNewEscapedRealm(pkgID PkgID) + GetIsRef() bool + SetIsRef(bool) GetIsNewEscaped() bool SetIsNewEscaped(bool) GetIsNewDeleted() bool @@ -146,7 +148,7 @@ type ObjectInfo struct { isDirty bool isDeleted bool isNewReal bool - isCrossRealm bool + isRef bool isNewEscaped bool isNewDeleted bool lastNewRealEscapedRealm PkgID @@ -323,6 +325,14 @@ func (oi *ObjectInfo) SetLastNewEscapedRealm(pkgId PkgID) { oi.lastNewRealEscapedRealm = pkgId } +func (oi *ObjectInfo) GetIsRef() bool { + return oi.isRef +} + +func (oi *ObjectInfo) SetIsRef(isRef bool) { + oi.isRef = isRef +} + func (oi *ObjectInfo) GetIsNewEscaped() bool { return oi.isNewEscaped } @@ -419,6 +429,9 @@ func (tv *TypedValue) GetFirstObject2(store Store) (obj Object, pkgId PkgID) { return case *SliceValue: pkgId = PkgIDFromPkgPath(tv.T.Elem().GetPkgPath()) + base := cv.GetBase(store) + fmt.Println("---base: ", base) + fmt.Println("---base.ID: ", base.ID) return case *FuncValue: fmt.Println("---FuncValue") diff --git a/gnovm/pkg/gnolang/realm.go b/gnovm/pkg/gnolang/realm.go index 1c89f5fcf80..742b3b27901 100644 --- a/gnovm/pkg/gnolang/realm.go +++ b/gnovm/pkg/gnolang/realm.go @@ -217,6 +217,11 @@ func (rlm *Realm) DidUpdate2(store Store, po, xo, co Object, refValue Value) { } } + if refValue != nil { + fmt.Printf("---SetIsRef, co: %v\n", co) + co.SetIsRef(true) + } + if po == nil || !po.GetIsReal() { // XXX, make sure po is attached fmt.Println("---po(Base) not real, do nothing!!!") return // do nothing. @@ -566,13 +571,13 @@ func (rlm *Realm) FinalizeRealmTransaction(readonly bool, store Store) { // All newly created objects become appended to .created, // and get assigned ids. func (rlm *Realm) processNewCreatedMarks(store Store) { - //fmt.Println("---processNewCreatedMarks---") + fmt.Println("---processNewCreatedMarks---") //fmt.Println("---len of newCreated objects:", len(rlm.newCreated)) // Create new objects and their new descendants. //for _, oo := range rlm.newCreated { for i := 0; i < len(rlm.newCreated); i++ { oo := rlm.newCreated[i] - //fmt.Printf("---oo[%d] is %v:\n", i, oo) + fmt.Printf("---oo[%d] is %v:\n", i, oo) //if _, ok := oo.(*BoundMethodValue); ok { // panic("should not happen persist bound method") //} @@ -605,7 +610,8 @@ func (rlm *Realm) processNewCreatedMarks(store Store) { func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { //fmt.Println("---incRefCreatedDescendants, rlm.ID: ", rlm.ID) //fmt.Println("---incRefCreatedDescendants oo.GetLastEscapedRealm: ", oo.GetLastNewEscapedRealm()) - //fmt.Println("---incRefCreatedDescendants from oo: ", oo) + fmt.Println("---incRefCreatedDescendants from oo: ", oo) + //fmt.Println("---oo.GetRefCount: ", oo.GetRefCount()) //fmt.Println("---incRefCreatedDescendants, oo.GetObjectID: ", oo.GetObjectID()) if debug { @@ -618,7 +624,9 @@ func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { } // XXX, oo must be new real here, it's not escaped - if !oo.GetLastNewEscapedRealm().IsZero() && oo.GetLastNewEscapedRealm() != rlm.ID { + // if it's reference, all right + fmt.Println("---oo.GetIsRef: ", oo.GetIsRef()) + if !oo.GetLastNewEscapedRealm().IsZero() && oo.GetLastNewEscapedRealm() != rlm.ID && !oo.GetIsRef() { //fmt.Println("---oo.GetLastNewEscapedRealm: ", oo.GetLastNewEscapedRealm()) //fmt.Println("---rlm.ID: ", rlm.ID) panic("should not happen while attempting to attach new real object from external realm") @@ -980,9 +988,9 @@ func (rlm *Realm) saveUnsavedObjectRecursively(store Store, oo Object) { } func (rlm *Realm) saveObject(store Store, oo Object) { - //fmt.Println("---saveObject: ", oo) + fmt.Println("---saveObject: ", oo) oid := oo.GetObjectID() - //fmt.Println("---saveObject: ", oid) + fmt.Println("---saveObject: ", oid) if oid.IsZero() { panic("unexpected zero object id") } diff --git a/gnovm/tests/files/zrealm_crossrealm24.gno b/gnovm/tests/files/zrealm_crossrealm24.gno index 448682186d7..81a2b773137 100644 --- a/gnovm/tests/files/zrealm_crossrealm24.gno +++ b/gnovm/tests/files/zrealm_crossrealm24.gno @@ -5,10 +5,10 @@ import ( crossrealm "gno.land/r/demo/tests/crossrealm" ) -var b0 *crossrealm.Bar +var b0 *crossrealm.Bar // this is not attached, po is not real func init() { - b0 = &crossrealm.Bar{A: 1} + b0 = &crossrealm.Bar{A: 22} // heapItem } func main() { diff --git a/gnovm/tests/files/zrealm_crossrealm24a.gno b/gnovm/tests/files/zrealm_crossrealm24a.gno new file mode 100644 index 00000000000..afb7b969768 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm24a.gno @@ -0,0 +1,19 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +var b0 *crossrealm.Bar = &crossrealm.Bar{A: 11} // not attached here + +func init() { + b0 = &crossrealm.Bar{A: 22} +} + +func main() { + print(".") +} + +// Output: +// . diff --git a/gnovm/tests/files/zrealm_crossrealm28.gno b/gnovm/tests/files/zrealm_crossrealm28.gno index 7b9a9379ef7..73b468aaa1c 100644 --- a/gnovm/tests/files/zrealm_crossrealm28.gno +++ b/gnovm/tests/files/zrealm_crossrealm28.gno @@ -13,17 +13,20 @@ type foo struct { func (foo) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } -var fs []crossrealm.Fooer // panic +// XXX, consider this +var fs []crossrealm.Fooer func init() { - fs = append(fs, foo{name: "1"}) // attached + fs = append(fs, foo{name: "1"}) fs = append(fs, foo{name: "2"}) } func main() { - println("ok") crossrealm.SetSlice(fs) + println("ok") } -// Error: -// should not happen while attempting to attach new real object from external realm +// Output: +// (struct{("1" string)} gno.land/r/crossrealm_test.foo) +// (struct{("2" string)} gno.land/r/crossrealm_test.foo) +// ok diff --git a/gnovm/tests/files/zrealm_crossrealm28a.gno b/gnovm/tests/files/zrealm_crossrealm28a.gno index 089b54c4209..f386768ff5f 100644 --- a/gnovm/tests/files/zrealm_crossrealm28a.gno +++ b/gnovm/tests/files/zrealm_crossrealm28a.gno @@ -23,5 +23,5 @@ func main() { println(".") } -// Error: -// should not happen while attempting to attach new real object from external realm +// Output: +// . diff --git a/gnovm/tests/files/zrealm_crossrealm28c.gno b/gnovm/tests/files/zrealm_crossrealm28c.gno index 7dad77b41b2..96f6fe746c4 100644 --- a/gnovm/tests/files/zrealm_crossrealm28c.gno +++ b/gnovm/tests/files/zrealm_crossrealm28c.gno @@ -14,17 +14,17 @@ type foo struct { func (foo) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } func main() { - var arr []crossrealm.Fooer // not attached here + var arr []crossrealm.Fooer // XXX, the array object should be in current realm arr = append(arr, foo{name: "1"}) arr = append(arr, foo{name: "2"}) arr = append(arr, foo{name: "3"}) fs := arr[1:] - println("ok") crossrealm.SetSlice(fs) + println("ok") } // Output: -// ok // (struct{("2" string)} gno.land/r/crossrealm_test.foo) // (struct{("3" string)} gno.land/r/crossrealm_test.foo) +// ok From e0a040e853336b2ad914c916070407167364b744 Mon Sep 17 00:00:00 2001 From: ltzMaxwell Date: Thu, 28 Nov 2024 12:58:46 +0900 Subject: [PATCH 33/40] add test --- gnovm/pkg/gnolang/op_assign.go | 4 ++++ gnovm/pkg/gnolang/op_decl.go | 2 ++ gnovm/pkg/gnolang/op_eval.go | 2 ++ gnovm/tests/files/zrealm_crossrealm41.gno | 20 ++++++++++++++++++++ gnovm/tests/files/zrealm_crossrealm42.gno | 12 ++++++++++++ 5 files changed, 40 insertions(+) create mode 100644 gnovm/tests/files/zrealm_crossrealm41.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm42.gno diff --git a/gnovm/pkg/gnolang/op_assign.go b/gnovm/pkg/gnolang/op_assign.go index eb67ffcc351..41d210df3ee 100644 --- a/gnovm/pkg/gnolang/op_assign.go +++ b/gnovm/pkg/gnolang/op_assign.go @@ -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. @@ -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. diff --git a/gnovm/pkg/gnolang/op_decl.go b/gnovm/pkg/gnolang/op_decl.go index 2c20c43ae2f..a17b95935b7 100644 --- a/gnovm/pkg/gnolang/op_decl.go +++ b/gnovm/pkg/gnolang/op_decl.go @@ -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 { @@ -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. diff --git a/gnovm/pkg/gnolang/op_eval.go b/gnovm/pkg/gnolang/op_eval.go index c37af7d31af..8aaffa074c4 100644 --- a/gnovm/pkg/gnolang/op_eval.go +++ b/gnovm/pkg/gnolang/op_eval.go @@ -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 { @@ -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 } diff --git a/gnovm/tests/files/zrealm_crossrealm41.gno b/gnovm/tests/files/zrealm_crossrealm41.gno new file mode 100644 index 00000000000..1d921647607 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm41.gno @@ -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) diff --git a/gnovm/tests/files/zrealm_crossrealm42.gno b/gnovm/tests/files/zrealm_crossrealm42.gno new file mode 100644 index 00000000000..c4ea99ff24d --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm42.gno @@ -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) +} From 3ec7a2e7ca45ad5971465ebe6f72be51b7577c4b Mon Sep 17 00:00:00 2001 From: ltzMaxwell Date: Mon, 30 Dec 2024 23:51:57 +0800 Subject: [PATCH 34/40] fixup --- .../r/demo/tests/crossrealm/crossrealm3.gno | 18 - .../{crossrealm5.gno => crossrealm_func.gno} | 0 .../{crossrealm9.gno => crossrealm_func2.gno} | 0 .../{crossrealm2.gno => crossrealm_iface.gno} | 0 .../{crossrealm8.gno => crossrealm_map.gno} | 0 .../{crossrealm.gno => crossrealm_p.gno} | 0 .../{crossrealm4.gno => crossrealm_slice.gno} | 0 ...{crossrealm6.gno => crossrealm_slice2.gno} | 4 +- .../tests/crossrealm/crossrealm_struct.gno | 28 + ...crossrealm7.gno => crossrealm_struct2.gno} | 0 gnovm/pkg/gnolang/ownership.go | 35 +- gnovm/pkg/gnolang/realm.go | 57 +- gnovm/pkg/gnolang/store.go | 8 +- gnovm/pkg/gnolang/values.go | 15 +- .../files/zrealm_crossrealm0_stdlibs.gno | 2 +- .../files/zrealm_crossrealm1_stdlibs.gno | 2 +- gnovm/tests/files/zrealm_crossrealm20.gno | 2 +- gnovm/tests/files/zrealm_crossrealm21a.gno | 2 +- gnovm/tests/files/zrealm_crossrealm21b.gno | 26 + gnovm/tests/files/zrealm_crossrealm22.gno | 19 - gnovm/tests/files/zrealm_crossrealm23a.gno | 122 +- gnovm/tests/files/zrealm_crossrealm23b.gno | 109 + gnovm/tests/files/zrealm_crossrealm24.gno | 204 +- gnovm/tests/files/zrealm_crossrealm24a.gno | 7 +- gnovm/tests/files/zrealm_crossrealm24b.gno | 22 + gnovm/tests/files/zrealm_crossrealm24c.gno | 23 + gnovm/tests/files/zrealm_crossrealm24d.gno | 214 + gnovm/tests/files/zrealm_crossrealm25.gno | 2 +- gnovm/tests/files/zrealm_crossrealm25b.gno | 39 + gnovm/tests/files/zrealm_crossrealm25c.gno | 2 +- gnovm/tests/files/zrealm_crossrealm25d.gno | 2 +- gnovm/tests/files/zrealm_crossrealm25e.gno | 2 +- gnovm/tests/files/zrealm_crossrealm27.gno | 211 + gnovm/tests/files/zrealm_crossrealm27a.gno | 2 +- gnovm/tests/files/zrealm_crossrealm28.gno | 16 +- gnovm/tests/files/zrealm_crossrealm28a.gno | 27 - gnovm/tests/files/zrealm_crossrealm28b.gno | 10 +- gnovm/tests/files/zrealm_crossrealm29.gno | 2 +- gnovm/tests/files/zrealm_crossrealm29a.gno | 6 +- gnovm/tests/files/zrealm_crossrealm29b.gno | 2 +- gnovm/tests/files/zrealm_crossrealm29c.gno | 19 + gnovm/tests/files/zrealm_crossrealm31.gno | 2 +- gnovm/tests/files/zrealm_crossrealm32.gno | 5438 +++++++++++++++++ gnovm/tests/files/zrealm_crossrealm34.gno | 86 + gnovm/tests/files/zrealm_crossrealm34b.gno | 2 +- gnovm/tests/files/zrealm_crossrealm35.gno | 18 - gnovm/tests/files/zrealm_crossrealm37.gno | 2 +- gnovm/tests/files/zrealm_crossrealm38.gno | 4 +- gnovm/tests/files/zrealm_crossrealm39.gno | 2 +- gnovm/tests/files/zrealm_crossrealm40.gno | 2 +- gnovm/tests/files/zrealm_crossrealm42.gno | 6 +- gnovm/tests/files/zrealm_crossrealm43.gno | 16 + .../files/zrealm_crossrealm4_stdlibs.gno | 2 +- .../files/zrealm_crossrealm5_stdlibs.gno | 2 +- 54 files changed, 6674 insertions(+), 169 deletions(-) delete mode 100644 examples/gno.land/r/demo/tests/crossrealm/crossrealm3.gno rename examples/gno.land/r/demo/tests/crossrealm/{crossrealm5.gno => crossrealm_func.gno} (100%) rename examples/gno.land/r/demo/tests/crossrealm/{crossrealm9.gno => crossrealm_func2.gno} (100%) rename examples/gno.land/r/demo/tests/crossrealm/{crossrealm2.gno => crossrealm_iface.gno} (100%) rename examples/gno.land/r/demo/tests/crossrealm/{crossrealm8.gno => crossrealm_map.gno} (100%) rename examples/gno.land/r/demo/tests/crossrealm/{crossrealm.gno => crossrealm_p.gno} (100%) rename examples/gno.land/r/demo/tests/crossrealm/{crossrealm4.gno => crossrealm_slice.gno} (100%) rename examples/gno.land/r/demo/tests/crossrealm/{crossrealm6.gno => crossrealm_slice2.gno} (92%) create mode 100644 examples/gno.land/r/demo/tests/crossrealm/crossrealm_struct.gno rename examples/gno.land/r/demo/tests/crossrealm/{crossrealm7.gno => crossrealm_struct2.gno} (100%) create mode 100644 gnovm/tests/files/zrealm_crossrealm21b.gno delete mode 100644 gnovm/tests/files/zrealm_crossrealm22.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm23b.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm24b.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm24c.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm24d.gno delete mode 100644 gnovm/tests/files/zrealm_crossrealm28a.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm29c.gno delete mode 100644 gnovm/tests/files/zrealm_crossrealm35.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm43.gno diff --git a/examples/gno.land/r/demo/tests/crossrealm/crossrealm3.gno b/examples/gno.land/r/demo/tests/crossrealm/crossrealm3.gno deleted file mode 100644 index 1d1c0cf6f35..00000000000 --- a/examples/gno.land/r/demo/tests/crossrealm/crossrealm3.gno +++ /dev/null @@ -1,18 +0,0 @@ -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) -} diff --git a/examples/gno.land/r/demo/tests/crossrealm/crossrealm5.gno b/examples/gno.land/r/demo/tests/crossrealm/crossrealm_func.gno similarity index 100% rename from examples/gno.land/r/demo/tests/crossrealm/crossrealm5.gno rename to examples/gno.land/r/demo/tests/crossrealm/crossrealm_func.gno diff --git a/examples/gno.land/r/demo/tests/crossrealm/crossrealm9.gno b/examples/gno.land/r/demo/tests/crossrealm/crossrealm_func2.gno similarity index 100% rename from examples/gno.land/r/demo/tests/crossrealm/crossrealm9.gno rename to examples/gno.land/r/demo/tests/crossrealm/crossrealm_func2.gno diff --git a/examples/gno.land/r/demo/tests/crossrealm/crossrealm2.gno b/examples/gno.land/r/demo/tests/crossrealm/crossrealm_iface.gno similarity index 100% rename from examples/gno.land/r/demo/tests/crossrealm/crossrealm2.gno rename to examples/gno.land/r/demo/tests/crossrealm/crossrealm_iface.gno diff --git a/examples/gno.land/r/demo/tests/crossrealm/crossrealm8.gno b/examples/gno.land/r/demo/tests/crossrealm/crossrealm_map.gno similarity index 100% rename from examples/gno.land/r/demo/tests/crossrealm/crossrealm8.gno rename to examples/gno.land/r/demo/tests/crossrealm/crossrealm_map.gno diff --git a/examples/gno.land/r/demo/tests/crossrealm/crossrealm.gno b/examples/gno.land/r/demo/tests/crossrealm/crossrealm_p.gno similarity index 100% rename from examples/gno.land/r/demo/tests/crossrealm/crossrealm.gno rename to examples/gno.land/r/demo/tests/crossrealm/crossrealm_p.gno diff --git a/examples/gno.land/r/demo/tests/crossrealm/crossrealm4.gno b/examples/gno.land/r/demo/tests/crossrealm/crossrealm_slice.gno similarity index 100% rename from examples/gno.land/r/demo/tests/crossrealm/crossrealm4.gno rename to examples/gno.land/r/demo/tests/crossrealm/crossrealm_slice.gno diff --git a/examples/gno.land/r/demo/tests/crossrealm/crossrealm6.gno b/examples/gno.land/r/demo/tests/crossrealm/crossrealm_slice2.gno similarity index 92% rename from examples/gno.land/r/demo/tests/crossrealm/crossrealm6.gno rename to examples/gno.land/r/demo/tests/crossrealm/crossrealm_slice2.gno index ad4cad9ebac..f74a9623d0a 100644 --- a/examples/gno.land/r/demo/tests/crossrealm/crossrealm6.gno +++ b/examples/gno.land/r/demo/tests/crossrealm/crossrealm_slice2.gno @@ -56,8 +56,8 @@ func GetSlice5() []*XYZ { // TODO, unwrap } 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) + s6[1] = &XYZ{"6.1"} + f(s6) // not real now } func GetSlice7(f func(s [2]XYZ)) { diff --git a/examples/gno.land/r/demo/tests/crossrealm/crossrealm_struct.gno b/examples/gno.land/r/demo/tests/crossrealm/crossrealm_struct.gno new file mode 100644 index 00000000000..f3eb3f21f00 --- /dev/null +++ b/examples/gno.land/r/demo/tests/crossrealm/crossrealm_struct.gno @@ -0,0 +1,28 @@ +package crossrealm + +type Bar struct { + A int +} + +var bar *Bar + +// TODO: deprovision this +var Bar2 *Bar = &Bar{A: 22} // exported + +func (b *Bar) String() { + println("b.A: ", b.A) +} + +func SetBar(b *Bar) *Bar { + bar = b + return bar +} + +func ChangeBar() { + Bar2.A += 1 + //println(Bar2.A) +} + +func (b *Bar) ModifyBar() { + b.A += 1 +} diff --git a/examples/gno.land/r/demo/tests/crossrealm/crossrealm7.gno b/examples/gno.land/r/demo/tests/crossrealm/crossrealm_struct2.gno similarity index 100% rename from examples/gno.land/r/demo/tests/crossrealm/crossrealm7.gno rename to examples/gno.land/r/demo/tests/crossrealm/crossrealm_struct2.gno diff --git a/gnovm/pkg/gnolang/ownership.go b/gnovm/pkg/gnolang/ownership.go index fdbe9053730..df532be6f4c 100644 --- a/gnovm/pkg/gnolang/ownership.go +++ b/gnovm/pkg/gnolang/ownership.go @@ -113,8 +113,8 @@ type Object interface { SetIsDeleted(bool, uint64) GetIsNewReal() bool SetIsNewReal(bool) - GetLastNewEscapedRealm() PkgID - SetLastNewEscapedRealm(pkgID PkgID) + GetOriginRealm() PkgID + SetOriginRealm(pkgID PkgID) GetIsRef() bool SetIsRef(bool) GetIsNewEscaped() bool @@ -256,6 +256,7 @@ func (oi *ObjectInfo) GetModTime() uint64 { } func (oi *ObjectInfo) IncRefCount() int { + fmt.Println("---IncRefCount") oi.RefCount++ return oi.RefCount } @@ -316,11 +317,11 @@ func (oi *ObjectInfo) SetIsNewReal(x bool) { oi.isNewReal = x } -func (oi *ObjectInfo) GetLastNewEscapedRealm() PkgID { +func (oi *ObjectInfo) GetOriginRealm() PkgID { return oi.lastNewRealEscapedRealm } -func (oi *ObjectInfo) SetLastNewEscapedRealm(pkgId PkgID) { +func (oi *ObjectInfo) SetOriginRealm(pkgId PkgID) { fmt.Println("---SetLastNewEscapedRealm") oi.lastNewRealEscapedRealm = pkgId } @@ -394,8 +395,12 @@ func (tv *TypedValue) GetFirstObject2(store Store) (obj Object, pkgId PkgID) { // general case if dt, ok := tv.T.(*DeclaredType); ok { fmt.Printf("---dt: %v\n", dt) - if IsRealmPath(dt.PkgPath) { - pkgId = PkgIDFromPkgPath(dt.PkgPath) + fmt.Println("---dt.base: ", dt.Base) + if _, ok := dt.Base.(*FuncType); !ok { + fmt.Println("---dt.base.PkgPath: ", dt.Base.GetPkgPath()) + if IsRealmPath(dt.Base.GetPkgPath()) { + pkgId = PkgIDFromPkgPath(dt.Base.GetPkgPath()) + } } } @@ -411,7 +416,7 @@ func (tv *TypedValue) GetFirstObject2(store Store) (obj Object, pkgId PkgID) { fmt.Println("---v: ", v) // TODO: check this if dt, ok := cv.TV.T.(*DeclaredType); ok { - //fmt.Println("---dt: ", dt) + fmt.Println("---dt: ", dt) //fmt.Println("---cv.Base: ", cv.GetBase(store), reflect.TypeOf(cv.GetBase(store))) //if _, ok := cv.GetBase(store).(*HeapItemValue); !ok { //println("---base is heap item") @@ -421,6 +426,7 @@ func (tv *TypedValue) GetFirstObject2(store Store) (obj Object, pkgId PkgID) { } //} } + fmt.Println("---pkgId; ", pkgId) } return case *ArrayValue: @@ -440,6 +446,21 @@ func (tv *TypedValue) GetFirstObject2(store Store) (obj Object, pkgId PkgID) { fmt.Println("clo...PkgPath", clo.Source.GetLocation().PkgPath) pkgId = PkgIDFromPkgPath(clo.Source.GetLocation().PkgPath) return + case *BoundMethodValue: + fmt.Println("---BoundMethodValue, recv: ", cv.Receiver) + fmt.Println("---type of T: ", reflect.TypeOf(cv.Receiver.T)) + if pv, ok := cv.Receiver.V.(PointerValue); ok { + println("---pointer value") + // TODO: check this + if dt, ok := pv.TV.T.(*DeclaredType); ok { + fmt.Println("---2, dt: ", dt) + if IsRealmPath(dt.PkgPath) { + pkgId = PkgIDFromPkgPath(dt.PkgPath) + } + } + fmt.Println("---pkgId; ", pkgId) + } + return default: return } diff --git a/gnovm/pkg/gnolang/realm.go b/gnovm/pkg/gnolang/realm.go index 742b3b27901..a4b62601a13 100644 --- a/gnovm/pkg/gnolang/realm.go +++ b/gnovm/pkg/gnolang/realm.go @@ -197,10 +197,13 @@ func (rlm *Realm) DidUpdate(po, xo, co Object) { // ref value is the derived value from co, like a slice. func (rlm *Realm) DidUpdate2(store Store, po, xo, co Object, refValue Value) { - fmt.Println("---DidUpdate2, rlm.ID: ", rlm.ID) - //fmt.Printf("---xo: %v, type of xo: %v\n", xo, reflect.TypeOf(xo)) + fmt.Printf("---DidUpdate2, po: %v, type of po: %v\n", po, reflect.TypeOf(po)) + fmt.Printf("---xo: %v, type of xo: %v\n", xo, reflect.TypeOf(xo)) fmt.Printf("---co: %v, type of co: %v\n", co, reflect.TypeOf(co)) - fmt.Printf("---po: %v, type of po: %v\n", po, reflect.TypeOf(po)) + if co != nil { + fmt.Println("co.GetOriginRealm: ", co.GetOriginRealm()) + } + fmt.Println("---rlm.ID: ", rlm.ID) if rlm == nil { return @@ -227,6 +230,7 @@ func (rlm *Realm) DidUpdate2(store Store, po, xo, co Object, refValue Value) { return // do nothing. } + // TODO: check not real external here, if po is real, association is invalid fmt.Println("---po.GetObjectID().PkgID: ", po.GetObjectID().PkgID) if po.GetObjectID().PkgID != rlm.ID { panic("cannot modify external-realm or non-realm object") @@ -252,6 +256,7 @@ func (rlm *Realm) DidUpdate2(store Store, po, xo, co Object, refValue Value) { // XXX, why packageBlock is automatically escaped? println("---already escaped, should check cross realm?") // already escaped + rlm.MarkNewEscapedCheckCrossRealm(store, co, refValue) } else { rlm.MarkNewEscapedCheckCrossRealm(store, co, refValue) } @@ -282,7 +287,7 @@ func (rlm *Realm) DidUpdate2(store Store, po, xo, co Object, refValue Value) { // XXX, oo coming here must be referenced type, since they already escaped. // XXX, so oo has been persisted, thus fillValueTV func checkCrossRealm(store Store, oo Object, refValue Value) { - fmt.Println("---checkCrossReal, oo: ", oo) + fmt.Println("---checkCrossRealm, oo: ", oo) switch v := oo.(type) { case *StructValue: fmt.Println("---StructValue...") @@ -377,21 +382,23 @@ func (rlm *Realm) MarkNewEscapedCheckCrossRealm(store Store, oo Object, refValue //fmt.Println("---oo.lastNewRealEscapedRealm: ", oo.GetLastNewEscapedRealm()) //fmt.Println("---oo.GetIsReal: ", oo.GetIsReal()) - if oo.GetLastNewEscapedRealm() == rlm.ID { + if oo.GetOriginRealm() == rlm.ID { return } - fmt.Println("---oo.GetLastNewEscapedRealm(): ", oo.GetLastNewEscapedRealm()) + fmt.Println("---oo.GetLastNewEscapedRealm(): ", oo.GetOriginRealm()) fmt.Println("---rlm.ID: ", rlm.ID) - if oo.GetLastNewEscapedRealm() != rlm.ID { // crossing realm + if oo.GetOriginRealm() != rlm.ID { // crossing realm if refValue != nil { // is reference object from external realm checkCrossRealm(store, oo, refValue) } else { - panic("should not happen while attempting to attach objects by value from external realm") + panic("cannot attach objects by value from external realm") } } - rlm.MarkNewEscaped(oo) + if !oo.GetIsEscaped() { + rlm.MarkNewEscaped(oo) + } } func (rlm *Realm) MarkNewReal(oo Object) { @@ -609,9 +616,9 @@ func (rlm *Realm) processNewCreatedMarks(store Store) { // oo must be marked new-real, and ref-count already incremented. func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { //fmt.Println("---incRefCreatedDescendants, rlm.ID: ", rlm.ID) - //fmt.Println("---incRefCreatedDescendants oo.GetLastEscapedRealm: ", oo.GetLastNewEscapedRealm()) fmt.Println("---incRefCreatedDescendants from oo: ", oo) - //fmt.Println("---oo.GetRefCount: ", oo.GetRefCount()) + fmt.Println("---oo.GetOriginRealm: ", oo.GetOriginRealm()) + fmt.Println("---oo.GetRefCount: ", oo.GetRefCount()) //fmt.Println("---incRefCreatedDescendants, oo.GetObjectID: ", oo.GetObjectID()) if debug { @@ -626,10 +633,14 @@ func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { // XXX, oo must be new real here, it's not escaped // if it's reference, all right fmt.Println("---oo.GetIsRef: ", oo.GetIsRef()) - if !oo.GetLastNewEscapedRealm().IsZero() && oo.GetLastNewEscapedRealm() != rlm.ID && !oo.GetIsRef() { + if !oo.GetOriginRealm().IsZero() && oo.GetOriginRealm() != rlm.ID { //fmt.Println("---oo.GetLastNewEscapedRealm: ", oo.GetLastNewEscapedRealm()) //fmt.Println("---rlm.ID: ", rlm.ID) - panic("should not happen while attempting to attach new real object from external realm") + if oo.GetIsRef() { + panic("cannot attach a reference to an unreal object from an external realm") + } else { + panic("cannot attach a value of a type defined by another realm") + } } // RECURSE GUARD @@ -661,7 +672,7 @@ func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { } child.IncRefCount() rc := child.GetRefCount() - //fmt.Println("---rc after inc: ", rc) + fmt.Println("---rc after inc: ", rc) if rc == 1 { if child.GetIsReal() { //fmt.Println("---child is real, child: ", child) @@ -990,7 +1001,8 @@ func (rlm *Realm) saveUnsavedObjectRecursively(store Store, oo Object) { func (rlm *Realm) saveObject(store Store, oo Object) { fmt.Println("---saveObject: ", oo) oid := oo.GetObjectID() - fmt.Println("---saveObject: ", oid) + fmt.Println("---oid: ", oid) + fmt.Println("---oo.GetRefCount: ", oo.GetRefCount()) if oid.IsZero() { panic("unexpected zero object id") } @@ -1207,9 +1219,12 @@ func copyMethods(methods []TypedValue) []TypedValue { } func refOrCopyType(typ Type) Type { + fmt.Println("---refOrCopyType, typ: ", typ) if dt, ok := typ.(*DeclaredType); ok { + fmt.Println("---declared type: ", dt) return RefType{ID: dt.TypeID()} } else { + println("---else") return copyTypeWithRefs(typ) } } @@ -1230,6 +1245,7 @@ func copyFieldsWithRefs(fields []FieldType) []FieldType { // Copies type but with references to dependant types; // the result is suitable for persistence bytes serialization. func copyTypeWithRefs(typ Type) Type { + fmt.Println("---copyTypeWithRefs, typ: ", typ) switch ct := typ.(type) { case nil: panic("cannot copy nil types") @@ -1320,7 +1336,7 @@ func copyTypeWithRefs(typ Type) Type { // Also checks for integrity of immediate children -- they must already be // persistent (real), and not dirty, or else this function panics. func copyValueWithRefs(val Value) Value { - //fmt.Println("---copyValueWithRefs, val: ", val) + fmt.Println("---copyValueWithRefs, val: ", val) switch cv := val.(type) { case nil: return nil @@ -1371,6 +1387,7 @@ func copyValueWithRefs(val Value) Value { Maxcap: cv.Maxcap, } case *StructValue: + println("---struct value") fields := make([]TypedValue, len(cv.Fields)) for i, ftv := range cv.Fields { fields[i] = refOrCopyValue(ftv) @@ -1495,6 +1512,7 @@ func copyValueWithRefs(val Value) Value { // (fully) fills the type. func fillType(store Store, typ Type) Type { + fmt.Println("---fillType, typ: ", typ) switch ct := typ.(type) { case nil: return nil @@ -1570,6 +1588,7 @@ func fillType(store Store, typ Type) Type { } return ct case RefType: + println("---ref type") return store.GetType(ct.TypeID()) default: panic(fmt.Sprintf( @@ -1578,6 +1597,7 @@ func fillType(store Store, typ Type) Type { } func fillTypesTV(store Store, tv *TypedValue) { + fmt.Println("---fillTypesTV, tv: ", tv) tv.T = fillType(store, tv.T) tv.V = fillTypesOfValue(store, tv.V) } @@ -1585,6 +1605,7 @@ func fillTypesTV(store Store, tv *TypedValue) { // Partially fills loaded objects shallowly, similarly to // getUnsavedTypes. Replaces all RefTypes with corresponding types. func fillTypesOfValue(store Store, val Value) Value { + fmt.Println("---fillTypesOfValue, val: ", val) switch cv := val.(type) { case nil: // do nothing return cv @@ -1615,6 +1636,7 @@ func fillTypesOfValue(store Store, val Value) Value { fillTypesOfValue(store, cv.Base) return cv case *StructValue: + println("struct value") for i := 0; i < len(cv.Fields); i++ { ctv := &cv.Fields[i] fillTypesTV(store, ctv) @@ -1780,10 +1802,11 @@ func ensureUniq(oozz ...[]Object) { } func refOrCopyValue(tv TypedValue) TypedValue { - //fmt.Println("---refOrCopyValue:", tv) + fmt.Println("---refOrCopyValue:", tv) if tv.T != nil { tv.T = refOrCopyType(tv.T) } + fmt.Println("---Tv.T: ", tv.T) if obj, ok := tv.V.(Object); ok { tv.V = toRefValue(obj) return tv diff --git a/gnovm/pkg/gnolang/store.go b/gnovm/pkg/gnolang/store.go index 096bc2cb6dc..e2dea647ae2 100644 --- a/gnovm/pkg/gnolang/store.go +++ b/gnovm/pkg/gnolang/store.go @@ -299,6 +299,7 @@ func (ds *defaultStore) GetObjectSafe(oid ObjectID) Object { // loads and caches an object. // CONTRACT: object isn't already in the cache. func (ds *defaultStore) loadObjectSafe(oid ObjectID) Object { + fmt.Println("---loadObjectSafe, oid: ", oid) key := backendObjectKey(oid) hashbz := ds.baseStore.Get([]byte(key)) if hashbz != nil { @@ -324,11 +325,11 @@ func (ds *defaultStore) loadObjectSafe(oid ObjectID) Object { // NOTE: unlike GetObject(), SetObject() is also used to persist updated // package values. func (ds *defaultStore) SetObject(oo Object) { - //fmt.Println("---SetObject---,oo: ", oo) + fmt.Println("---SetObject: ", oo) oid := oo.GetObjectID() // replace children/fields with Ref. o2 := copyValueWithRefs(oo) - //fmt.Println("---SetObject, o2: ", o2) + fmt.Println("---o2: ", o2) // marshal to binary. bz := amino.MustMarshalAny(o2) // set hash. @@ -399,7 +400,9 @@ func (ds *defaultStore) DelObject(oo Object) { // NOTE: The implementation matches that of GetObject() in anticipation of what // the persistent type system might work like. func (ds *defaultStore) GetType(tid TypeID) Type { + fmt.Println("---GetType: ", tid) tt := ds.GetTypeSafe(tid) + fmt.Println("---tt: ", tt) if tt == nil { ds.Print() panic(fmt.Sprintf("unexpected type with id %s", tid.String())) @@ -408,6 +411,7 @@ func (ds *defaultStore) GetType(tid TypeID) Type { } func (ds *defaultStore) GetTypeSafe(tid TypeID) Type { + fmt.Println("---GetTypeSafe: ", tid) // check cache. if tt, exists := ds.cacheTypes[tid]; exists { return tt diff --git a/gnovm/pkg/gnolang/values.go b/gnovm/pkg/gnolang/values.go index ad824da0508..9951a4fb6a7 100644 --- a/gnovm/pkg/gnolang/values.go +++ b/gnovm/pkg/gnolang/values.go @@ -211,7 +211,8 @@ func (pv *PointerValue) GetBase(store Store) Object { // TODO: document as something that enables into-native assignment. // TODO: maybe consider this as entrypoint for DataByteValue too? func (pv PointerValue) Assign2(alloc *Allocator, store Store, rlm *Realm, tv2 TypedValue, cu bool) { - fmt.Println("---Assign2, tv2: ", tv2) + fmt.Println("---Assign2, pv: ", pv) + fmt.Println("---tv2: ", tv2) // Special cases. if pv.Index == PointerIndexNative { // Special case if extended object && native. @@ -298,7 +299,7 @@ func (pv PointerValue) Assign2(alloc *Allocator, store Store, rlm *Realm, tv2 Ty fmt.Println("---oo2: ", oo2) fmt.Println("---oo2 pkgId: ", pkgId) if oo2 != nil { // cross realm - oo2.SetLastNewEscapedRealm(pkgId) // attach origin package info + oo2.SetOriginRealm(pkgId) // attach origin package info } // TODO: make check happens in here? rlm.DidUpdate2(store, pv.Base.(Object), oo1, oo2, refValue) @@ -2645,20 +2646,20 @@ func typedString(s string) TypedValue { } func fillValueTV(store Store, tv *TypedValue) *TypedValue { - //fmt.Println("---fillValueTV, tv: ", tv) + fmt.Println("---fillValueTV, tv: ", tv) switch cv := tv.V.(type) { case RefValue: - //println("---tv.V RefValue") - //fmt.Println("---cv: ", cv) + println("---tv.V RefValue") + fmt.Println("---cv: ", cv) if cv.PkgPath != "" { // load package tv.V = store.GetPackage(cv.PkgPath, false) } else { // load object // XXX XXX allocate object. tv.V = store.GetObject(cv.ObjectID) - //fmt.Println("---tv.V: ", tv.V) + fmt.Println("---tv.V: ", tv.V) } case PointerValue: - //fmt.Println("---PointerValue") + fmt.Println("---PointerValue") // As a special case, cv.Base is filled // and cv.TV set appropriately. // Alternatively, could implement diff --git a/gnovm/tests/files/zrealm_crossrealm0_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm0_stdlibs.gno index ecb8037bd69..b425344615e 100644 --- a/gnovm/tests/files/zrealm_crossrealm0_stdlibs.gno +++ b/gnovm/tests/files/zrealm_crossrealm0_stdlibs.gno @@ -14,4 +14,4 @@ func main() { } // Error: -// should not happen while attempting to attach new real object from external realm +// cannot attach a value of a type defined by another realm diff --git a/gnovm/tests/files/zrealm_crossrealm1_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm1_stdlibs.gno index 34e1cc339e6..ee401bd7774 100644 --- a/gnovm/tests/files/zrealm_crossrealm1_stdlibs.gno +++ b/gnovm/tests/files/zrealm_crossrealm1_stdlibs.gno @@ -17,4 +17,4 @@ func main() { } // Error: -// should not happen while attempting to attach new real object from external realm +// cannot attach a value of a type defined by another realm diff --git a/gnovm/tests/files/zrealm_crossrealm20.gno b/gnovm/tests/files/zrealm_crossrealm20.gno index f03e3b3af66..4e0fcb57591 100644 --- a/gnovm/tests/files/zrealm_crossrealm20.gno +++ b/gnovm/tests/files/zrealm_crossrealm20.gno @@ -12,4 +12,4 @@ func main() { } // Error: -// should not happen while attempting to attach new real object from external realm +// cannot attach a value of a type defined by another realm diff --git a/gnovm/tests/files/zrealm_crossrealm21a.gno b/gnovm/tests/files/zrealm_crossrealm21a.gno index a50a6614920..6f8c7570e85 100644 --- a/gnovm/tests/files/zrealm_crossrealm21a.gno +++ b/gnovm/tests/files/zrealm_crossrealm21a.gno @@ -23,4 +23,4 @@ func main() { } // Error: -// should not happen while attempting to attach new real object from external realm +// cannot attach a value of a type defined by another realm diff --git a/gnovm/tests/files/zrealm_crossrealm21b.gno b/gnovm/tests/files/zrealm_crossrealm21b.gno new file mode 100644 index 00000000000..4e6a497a588 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm21b.gno @@ -0,0 +1,26 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +// associate to a containing object +type Container struct { + name string + b *crossrealm.Bar +} + +var c Container + +func init() { + b0 := &crossrealm.Bar{A: 1} // this is valid association + c = Container{name: "container", b: b0} // XXX, should panic +} + +func main() { + print(".") +} + +// Error: +// cannot attach a reference to an unreal object from an external realm diff --git a/gnovm/tests/files/zrealm_crossrealm22.gno b/gnovm/tests/files/zrealm_crossrealm22.gno deleted file mode 100644 index e45db3510e0..00000000000 --- a/gnovm/tests/files/zrealm_crossrealm22.gno +++ /dev/null @@ -1,19 +0,0 @@ -// PKGPATH: gno.land/r/crossrealm_test -package crossrealm_test - -type Bar struct { - A int -} - -var b0 Bar - -func init() { - b0 = Bar{A: 1} -} - -func main() { - print(".") -} - -// Output: -// . diff --git a/gnovm/tests/files/zrealm_crossrealm23a.gno b/gnovm/tests/files/zrealm_crossrealm23a.gno index 10a2006a98b..1865874ca38 100644 --- a/gnovm/tests/files/zrealm_crossrealm23a.gno +++ b/gnovm/tests/files/zrealm_crossrealm23a.gno @@ -5,15 +5,129 @@ import "gno.land/p/demo/tests/p_crossrealm" var b0 *p_crossrealm.Container -func init() { +func main() { b0 = &p_crossrealm.Container{ A: 1, } -} - -func main() { print(".") } // Output: // . + +// Realm: +// switchrealm["gno.land/r/crossrealm_test"] +// c[f5a516808f8976c33939133293d598ce3bca4e8d:5]={ +// "Fields": [ +// { +// "N": "AQAAAAAAAAA=", +// "T": { +// "@type": "/gno.PrimitiveType", +// "value": "32" +// } +// }, +// {} +// ], +// "ObjectInfo": { +// "ID": "f5a516808f8976c33939133293d598ce3bca4e8d:5", +// "ModTime": "0", +// "OwnerID": "f5a516808f8976c33939133293d598ce3bca4e8d:4", +// "RefCount": "1" +// } +// } +// c[f5a516808f8976c33939133293d598ce3bca4e8d:4]={ +// "ObjectInfo": { +// "ID": "f5a516808f8976c33939133293d598ce3bca4e8d:4", +// "ModTime": "0", +// "OwnerID": "f5a516808f8976c33939133293d598ce3bca4e8d:2", +// "RefCount": "1" +// }, +// "Value": { +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/tests/p_crossrealm.Container" +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "01799eb680e2f34495c1050457f9ccd79795a561", +// "ObjectID": "f5a516808f8976c33939133293d598ce3bca4e8d:5" +// } +// } +// } +// u[f5a516808f8976c33939133293d598ce3bca4e8d:2]={ +// "Blank": {}, +// "ObjectInfo": { +// "ID": "f5a516808f8976c33939133293d598ce3bca4e8d:2", +// "IsEscaped": true, +// "ModTime": "3", +// "RefCount": "2" +// }, +// "Parent": null, +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "0", +// "File": "", +// "Line": "0", +// "PkgPath": "gno.land/r/crossrealm_test" +// } +// }, +// "Values": [ +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/tests/p_crossrealm.Container" +// } +// }, +// "V": { +// "@type": "/gno.PointerValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Hash": "49801c40c9c71898edc425edc24654efb17f7164", +// "ObjectID": "f5a516808f8976c33939133293d598ce3bca4e8d:4" +// }, +// "Index": "0", +// "TV": null +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "f5a516808f8976c33939133293d598ce3bca4e8d:3" +// }, +// "FileName": "main.gno", +// "IsMethod": false, +// "Name": "main", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/crossrealm_test", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "main.gno", +// "Line": "8", +// "PkgPath": "gno.land/r/crossrealm_test" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// } +// } +// } +// ] +// } diff --git a/gnovm/tests/files/zrealm_crossrealm23b.gno b/gnovm/tests/files/zrealm_crossrealm23b.gno new file mode 100644 index 00000000000..29b94f4cb76 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm23b.gno @@ -0,0 +1,109 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import "gno.land/p/demo/tests/p_crossrealm" + +var b0 p_crossrealm.Container + +func main() { + b0 = p_crossrealm.Container{ + A: 1, + } + print(".") +} + +// XXX, this works attach value with type defined in p + +// Output: +// . + +// Realm: +// switchrealm["gno.land/r/crossrealm_test"] +// c[f5a516808f8976c33939133293d598ce3bca4e8d:5]={ +// "Fields": [ +// { +// "N": "AQAAAAAAAAA=", +// "T": { +// "@type": "/gno.PrimitiveType", +// "value": "32" +// } +// }, +// {} +// ], +// "ObjectInfo": { +// "ID": "f5a516808f8976c33939133293d598ce3bca4e8d:5", +// "ModTime": "0", +// "OwnerID": "f5a516808f8976c33939133293d598ce3bca4e8d:2", +// "RefCount": "1" +// } +// } +// u[f5a516808f8976c33939133293d598ce3bca4e8d:2]={ +// "Blank": {}, +// "ObjectInfo": { +// "ID": "f5a516808f8976c33939133293d598ce3bca4e8d:2", +// "IsEscaped": true, +// "ModTime": "4", +// "RefCount": "2" +// }, +// "Parent": null, +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "0", +// "File": "", +// "Line": "0", +// "PkgPath": "gno.land/r/crossrealm_test" +// } +// }, +// "Values": [ +// { +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/tests/p_crossrealm.Container" +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "9e2d3b66941a43f567a3e83c2d2df8205f433f1c", +// "ObjectID": "f5a516808f8976c33939133293d598ce3bca4e8d:5" +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "f5a516808f8976c33939133293d598ce3bca4e8d:4" +// }, +// "FileName": "main.gno", +// "IsMethod": false, +// "Name": "main", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/crossrealm_test", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "main.gno", +// "Line": "8", +// "PkgPath": "gno.land/r/crossrealm_test" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// } +// } +// } +// ] +// } +// d[f5a516808f8976c33939133293d598ce3bca4e8d:3] diff --git a/gnovm/tests/files/zrealm_crossrealm24.gno b/gnovm/tests/files/zrealm_crossrealm24.gno index 81a2b773137..a1f2ccab778 100644 --- a/gnovm/tests/files/zrealm_crossrealm24.gno +++ b/gnovm/tests/files/zrealm_crossrealm24.gno @@ -5,15 +5,211 @@ import ( crossrealm "gno.land/r/demo/tests/crossrealm" ) -var b0 *crossrealm.Bar // this is not attached, po is not real +type Ibar interface { + String() +} + +var ib Ibar + +var b0 *crossrealm.Bar func init() { - b0 = &crossrealm.Bar{A: 22} // heapItem } func main() { - print(".") + b0 = crossrealm.Bar2 + ib = crossrealm.Bar2 + println(ib) + crossrealm.ChangeBar() + println(ib) + println(b0) } // Output: -// . +// &(struct{(22 int)} gno.land/r/demo/tests/crossrealm.Bar) +// &(struct{(23 int)} gno.land/r/demo/tests/crossrealm.Bar) +// &(struct{(23 int)} gno.land/r/demo/tests/crossrealm.Bar) + +// Realm: +// switchrealm["gno.land/r/demo/tests/crossrealm"] +// u[1712ac7adcfdc8e58a67e5615e20fb312394c4df:20]={ +// "Fields": [ +// { +// "N": "FwAAAAAAAAA=", +// "T": { +// "@type": "/gno.PrimitiveType", +// "value": "32" +// } +// } +// ], +// "ObjectInfo": { +// "ID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:20", +// "ModTime": "44", +// "OwnerID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:19", +// "RefCount": "1" +// } +// } +// switchrealm["gno.land/r/crossrealm_test"] +// u[f5a516808f8976c33939133293d598ce3bca4e8d:2]={ +// "Blank": {}, +// "ObjectInfo": { +// "ID": "f5a516808f8976c33939133293d598ce3bca4e8d:2", +// "IsEscaped": true, +// "ModTime": "3", +// "RefCount": "2" +// }, +// "Parent": null, +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "0", +// "File": "", +// "Line": "0", +// "PkgPath": "gno.land/r/crossrealm_test" +// } +// }, +// "Values": [ +// { +// "T": { +// "@type": "/gno.TypeType" +// }, +// "V": { +// "@type": "/gno.TypeValue", +// "Type": { +// "@type": "/gno.DeclaredType", +// "Base": { +// "@type": "/gno.InterfaceType", +// "Generic": "", +// "Methods": [ +// { +// "Embedded": false, +// "Name": "String", +// "Tag": "", +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// } +// } +// ], +// "PkgPath": "gno.land/r/crossrealm_test" +// }, +// "Methods": [], +// "Name": "Ibar", +// "PkgPath": "gno.land/r/crossrealm_test" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Bar" +// } +// }, +// "V": { +// "@type": "/gno.PointerValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:19" +// }, +// "Index": "0", +// "TV": null +// } +// }, +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Bar" +// } +// }, +// "V": { +// "@type": "/gno.PointerValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:19" +// }, +// "Index": "0", +// "TV": null +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "f5a516808f8976c33939133293d598ce3bca4e8d:3" +// }, +// "FileName": "main.gno", +// "IsMethod": false, +// "Name": "init.3", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/crossrealm_test", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "main.gno", +// "Line": "16", +// "PkgPath": "gno.land/r/crossrealm_test" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "f5a516808f8976c33939133293d598ce3bca4e8d:3" +// }, +// "FileName": "main.gno", +// "IsMethod": false, +// "Name": "main", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/crossrealm_test", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "main.gno", +// "Line": "19", +// "PkgPath": "gno.land/r/crossrealm_test" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// } +// } +// } +// ] +// } diff --git a/gnovm/tests/files/zrealm_crossrealm24a.gno b/gnovm/tests/files/zrealm_crossrealm24a.gno index afb7b969768..4f69450bde4 100644 --- a/gnovm/tests/files/zrealm_crossrealm24a.gno +++ b/gnovm/tests/files/zrealm_crossrealm24a.gno @@ -5,15 +5,14 @@ import ( crossrealm "gno.land/r/demo/tests/crossrealm" ) -var b0 *crossrealm.Bar = &crossrealm.Bar{A: 11} // not attached here +var b0 *crossrealm.Bar = &crossrealm.Bar{A: 11} func init() { - b0 = &crossrealm.Bar{A: 22} } func main() { print(".") } -// Output: -// . +// Error: +// cannot attach a reference to an unreal object from an external realm diff --git a/gnovm/tests/files/zrealm_crossrealm24b.gno b/gnovm/tests/files/zrealm_crossrealm24b.gno new file mode 100644 index 00000000000..53eda7705c8 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm24b.gno @@ -0,0 +1,22 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +// TODO: +// type XX crossrealm.Bar + +var b1 *crossrealm.Bar // this is valid decl, NOT attach + +func init() { +} + +func main() { + b1 = &crossrealm.Bar{A: 22} // this should panic + println(b1) +} + +// Error: +// cannot attach a reference to an unreal object from an external realm diff --git a/gnovm/tests/files/zrealm_crossrealm24c.gno b/gnovm/tests/files/zrealm_crossrealm24c.gno new file mode 100644 index 00000000000..1360003dade --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm24c.gno @@ -0,0 +1,23 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "fmt" + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +type Dt *crossrealm.Bar + +var b Dt + +func init() { +} + +func main() { + b = &crossrealm.Bar{A: 22} // this should panic + //println(b) + fmt.Println(b) +} + +// Error: +// cannot attach a reference to an unreal object from an external realm diff --git a/gnovm/tests/files/zrealm_crossrealm24d.gno b/gnovm/tests/files/zrealm_crossrealm24d.gno new file mode 100644 index 00000000000..5c5df3ee123 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm24d.gno @@ -0,0 +1,214 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + crossrealm "gno.land/r/demo/tests/crossrealm" +) + +type Ibar interface { + String() +} + +var ib Ibar + +var b0 *crossrealm.Bar // no attach + +func init() {} + +func main() { + b0 = crossrealm.Bar2 // attach by reference + ib = crossrealm.Bar2 + println(ib) + b0.ModifyBar() // call bound methond + println(ib) + println(b0) +} + +// Output: +// &(struct{(22 int)} gno.land/r/demo/tests/crossrealm.Bar) +// &(struct{(23 int)} gno.land/r/demo/tests/crossrealm.Bar) +// &(struct{(23 int)} gno.land/r/demo/tests/crossrealm.Bar) + +// Realm: +// switchrealm["gno.land/r/demo/tests/crossrealm"] +// u[1712ac7adcfdc8e58a67e5615e20fb312394c4df:20]={ +// "Fields": [ +// { +// "N": "FwAAAAAAAAA=", +// "T": { +// "@type": "/gno.PrimitiveType", +// "value": "32" +// } +// } +// ], +// "ObjectInfo": { +// "ID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:20", +// "ModTime": "44", +// "OwnerID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:19", +// "RefCount": "1" +// } +// } +// switchrealm["gno.land/r/crossrealm_test"] +// u[f5a516808f8976c33939133293d598ce3bca4e8d:2]={ +// "Blank": {}, +// "ObjectInfo": { +// "ID": "f5a516808f8976c33939133293d598ce3bca4e8d:2", +// "IsEscaped": true, +// "ModTime": "3", +// "RefCount": "2" +// }, +// "Parent": null, +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "0", +// "File": "", +// "Line": "0", +// "PkgPath": "gno.land/r/crossrealm_test" +// } +// }, +// "Values": [ +// { +// "T": { +// "@type": "/gno.TypeType" +// }, +// "V": { +// "@type": "/gno.TypeValue", +// "Type": { +// "@type": "/gno.DeclaredType", +// "Base": { +// "@type": "/gno.InterfaceType", +// "Generic": "", +// "Methods": [ +// { +// "Embedded": false, +// "Name": "String", +// "Tag": "", +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// } +// } +// ], +// "PkgPath": "gno.land/r/crossrealm_test" +// }, +// "Methods": [], +// "Name": "Ibar", +// "PkgPath": "gno.land/r/crossrealm_test" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Bar" +// } +// }, +// "V": { +// "@type": "/gno.PointerValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:19" +// }, +// "Index": "0", +// "TV": null +// } +// }, +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Bar" +// } +// }, +// "V": { +// "@type": "/gno.PointerValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:19" +// }, +// "Index": "0", +// "TV": null +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "f5a516808f8976c33939133293d598ce3bca4e8d:3" +// }, +// "FileName": "main.gno", +// "IsMethod": false, +// "Name": "init.3", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/crossrealm_test", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "main.gno", +// "Line": "16", +// "PkgPath": "gno.land/r/crossrealm_test" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "f5a516808f8976c33939133293d598ce3bca4e8d:3" +// }, +// "FileName": "main.gno", +// "IsMethod": false, +// "Name": "main", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/crossrealm_test", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "main.gno", +// "Line": "18", +// "PkgPath": "gno.land/r/crossrealm_test" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// } +// } +// } +// ] +// } diff --git a/gnovm/tests/files/zrealm_crossrealm25.gno b/gnovm/tests/files/zrealm_crossrealm25.gno index 68da79914b6..11a30a1a17e 100644 --- a/gnovm/tests/files/zrealm_crossrealm25.gno +++ b/gnovm/tests/files/zrealm_crossrealm25.gno @@ -23,4 +23,4 @@ func main() { } // Error: -// should not happen while attempting to attach objects by value from external realm +// cannot attach objects by value from external realm diff --git a/gnovm/tests/files/zrealm_crossrealm25b.gno b/gnovm/tests/files/zrealm_crossrealm25b.gno index 112b4fe599f..b5744340648 100644 --- a/gnovm/tests/files/zrealm_crossrealm25b.gno +++ b/gnovm/tests/files/zrealm_crossrealm25b.gno @@ -32,3 +32,42 @@ func main() { // Output: // . + +// Realm: +// switchrealm["gno.land/r/demo/tests/crossrealm"] +// u[1712ac7adcfdc8e58a67e5615e20fb312394c4df:8]={ +// "Fields": [ +// { +// "T": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// }, +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/crossrealm_test.fooer" +// } +// }, +// "V": { +// "@type": "/gno.PointerValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "f5a516808f8976c33939133293d598ce3bca4e8d:6" +// }, +// "Index": "1", +// "TV": null +// } +// } +// ], +// "ObjectInfo": { +// "ID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:8", +// "ModTime": "44", +// "OwnerID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:2", +// "RefCount": "1" +// } +// } +// switchrealm["gno.land/r/crossrealm_test"] diff --git a/gnovm/tests/files/zrealm_crossrealm25c.gno b/gnovm/tests/files/zrealm_crossrealm25c.gno index 74599ba2106..b70dd3aa4ea 100644 --- a/gnovm/tests/files/zrealm_crossrealm25c.gno +++ b/gnovm/tests/files/zrealm_crossrealm25c.gno @@ -30,4 +30,4 @@ func main() { } // Error: -// should not happen while attempting to attach objects by value from external realm +// cannot attach objects by value from external realm diff --git a/gnovm/tests/files/zrealm_crossrealm25d.gno b/gnovm/tests/files/zrealm_crossrealm25d.gno index 9d8af7decc1..fa05f3dfae5 100644 --- a/gnovm/tests/files/zrealm_crossrealm25d.gno +++ b/gnovm/tests/files/zrealm_crossrealm25d.gno @@ -31,4 +31,4 @@ func main() { } // Error: -// should not happen while attempting to attach objects by value from external realm +// cannot attach objects by value from external realm diff --git a/gnovm/tests/files/zrealm_crossrealm25e.gno b/gnovm/tests/files/zrealm_crossrealm25e.gno index 439839e8aa9..ce9d137c378 100644 --- a/gnovm/tests/files/zrealm_crossrealm25e.gno +++ b/gnovm/tests/files/zrealm_crossrealm25e.gno @@ -29,4 +29,4 @@ func main() { } // Error: -// should not happen while attempting to attach objects by value from external realm +// cannot attach objects by value from external realm diff --git a/gnovm/tests/files/zrealm_crossrealm27.gno b/gnovm/tests/files/zrealm_crossrealm27.gno index 9889cc194c7..fab4a6cc54b 100644 --- a/gnovm/tests/files/zrealm_crossrealm27.gno +++ b/gnovm/tests/files/zrealm_crossrealm27.gno @@ -23,3 +23,214 @@ func main() { // Output: // . + +// Realm: +// switchrealm["gno.land/r/demo/tests/crossrealm"] +// u[1712ac7adcfdc8e58a67e5615e20fb312394c4df:8]={ +// "Fields": [ +// { +// "T": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// }, +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/crossrealm_test.fooer" +// } +// }, +// "V": { +// "@type": "/gno.PointerValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "f5a516808f8976c33939133293d598ce3bca4e8d:2" +// }, +// "Index": "1", +// "TV": null +// } +// } +// ], +// "ObjectInfo": { +// "ID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:8", +// "ModTime": "44", +// "OwnerID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:2", +// "RefCount": "1" +// } +// } +// switchrealm["gno.land/r/crossrealm_test"] +// c[f5a516808f8976c33939133293d598ce3bca4e8d:5]={ +// "Fields": [ +// { +// "T": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// }, +// "V": { +// "@type": "/gno.StringValue", +// "value": "local_fooer" +// } +// } +// ], +// "ObjectInfo": { +// "ID": "f5a516808f8976c33939133293d598ce3bca4e8d:5", +// "ModTime": "0", +// "OwnerID": "f5a516808f8976c33939133293d598ce3bca4e8d:2", +// "RefCount": "1" +// } +// } +// u[f5a516808f8976c33939133293d598ce3bca4e8d:2]={ +// "Blank": {}, +// "ObjectInfo": { +// "ID": "f5a516808f8976c33939133293d598ce3bca4e8d:2", +// "IsEscaped": true, +// "ModTime": "4", +// "RefCount": "3" +// }, +// "Parent": null, +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "0", +// "File": "", +// "Line": "0", +// "PkgPath": "gno.land/r/crossrealm_test" +// } +// }, +// "Values": [ +// { +// "T": { +// "@type": "/gno.TypeType" +// }, +// "V": { +// "@type": "/gno.TypeValue", +// "Type": { +// "@type": "/gno.DeclaredType", +// "Base": { +// "@type": "/gno.StructType", +// "Fields": [ +// { +// "Embedded": false, +// "Name": "name", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// } +// ], +// "PkgPath": "gno.land/r/crossrealm_test" +// }, +// "Methods": [ +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": ".recv", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/crossrealm_test.fooer" +// } +// } +// ], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": null, +// "FileName": "main.gno", +// "IsMethod": true, +// "Name": "Foo", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/crossrealm_test", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "main.gno", +// "Line": "14", +// "PkgPath": "gno.land/r/crossrealm_test" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": ".recv", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/crossrealm_test.fooer" +// } +// } +// ], +// "Results": [] +// } +// } +// } +// ], +// "Name": "fooer", +// "PkgPath": "gno.land/r/crossrealm_test" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/crossrealm_test.fooer" +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "01b50926620ac1c9cff16ae679ccc89029394a2d", +// "ObjectID": "f5a516808f8976c33939133293d598ce3bca4e8d:5" +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "f5a516808f8976c33939133293d598ce3bca4e8d:4" +// }, +// "FileName": "main.gno", +// "IsMethod": false, +// "Name": "main", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/crossrealm_test", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "main.gno", +// "Line": "18", +// "PkgPath": "gno.land/r/crossrealm_test" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// } +// } +// } +// ] +// } +// d[f5a516808f8976c33939133293d598ce3bca4e8d:3] diff --git a/gnovm/tests/files/zrealm_crossrealm27a.gno b/gnovm/tests/files/zrealm_crossrealm27a.gno index 8eb4d4686a1..cefcf319a88 100644 --- a/gnovm/tests/files/zrealm_crossrealm27a.gno +++ b/gnovm/tests/files/zrealm_crossrealm27a.gno @@ -20,4 +20,4 @@ func main() { } // Error: -// should not happen while attempting to attach new real object from external realm +// cannot attach a reference to an unreal object from an external realm diff --git a/gnovm/tests/files/zrealm_crossrealm28.gno b/gnovm/tests/files/zrealm_crossrealm28.gno index 73b468aaa1c..87bc87813a2 100644 --- a/gnovm/tests/files/zrealm_crossrealm28.gno +++ b/gnovm/tests/files/zrealm_crossrealm28.gno @@ -17,16 +17,16 @@ func (foo) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } var fs []crossrealm.Fooer func init() { - fs = append(fs, foo{name: "1"}) - fs = append(fs, foo{name: "2"}) + //fs = append(fs, foo{name: "1"}) // type of elem is from external realm + //s1 := []crossrealm.Fooer{foo{name: "s1"}} + //r := append(fs, s1) + + r := append(fs, foo{name: "1"}) // type of elem is from external realm, but no panic since no attach + fs = r // panic while attach } func main() { - crossrealm.SetSlice(fs) - println("ok") } -// Output: -// (struct{("1" string)} gno.land/r/crossrealm_test.foo) -// (struct{("2" string)} gno.land/r/crossrealm_test.foo) -// ok +// Error: +// cannot attach a reference to an unreal object from an external realm diff --git a/gnovm/tests/files/zrealm_crossrealm28a.gno b/gnovm/tests/files/zrealm_crossrealm28a.gno deleted file mode 100644 index f386768ff5f..00000000000 --- a/gnovm/tests/files/zrealm_crossrealm28a.gno +++ /dev/null @@ -1,27 +0,0 @@ -// PKGPATH: gno.land/r/crossrealm_test -package crossrealm_test - -import ( - "std" - - crossrealm "gno.land/r/demo/tests/crossrealm" -) - -type foo struct { - name string -} - -func (foo) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } - -var arr []crossrealm.Fooer - -func main() { - arr = append(arr, foo{name: "1"}) - arr = append(arr, foo{name: "2"}) - arr = append(arr, foo{name: "3"}) - - println(".") -} - -// Output: -// . diff --git a/gnovm/tests/files/zrealm_crossrealm28b.gno b/gnovm/tests/files/zrealm_crossrealm28b.gno index 1cb7685ec3d..ca89bb8ba3c 100644 --- a/gnovm/tests/files/zrealm_crossrealm28b.gno +++ b/gnovm/tests/files/zrealm_crossrealm28b.gno @@ -13,16 +13,10 @@ type foo struct { func (foo) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } -var arr [2]crossrealm.Fooer // panic +var arr [2]crossrealm.Fooer // panic while attach zero value func main() { - arr[0] = foo{name: "1"} - arr[1] = foo{name: "2"} - - fs := arr[1:] - println("ok") - crossrealm.SetSlice(fs) } // Error: -// should not happen while attempting to attach new real object from external realm +// cannot attach a value of a type defined by another realm diff --git a/gnovm/tests/files/zrealm_crossrealm29.gno b/gnovm/tests/files/zrealm_crossrealm29.gno index cb4cbe050e1..2ca67b09cd1 100644 --- a/gnovm/tests/files/zrealm_crossrealm29.gno +++ b/gnovm/tests/files/zrealm_crossrealm29.gno @@ -17,4 +17,4 @@ func main() { } // Error: -// should not happen while attempting to attach new real object from external realm +// cannot attach a value of a type defined by another realm diff --git a/gnovm/tests/files/zrealm_crossrealm29a.gno b/gnovm/tests/files/zrealm_crossrealm29a.gno index 6688e9dd933..aaeda22503e 100644 --- a/gnovm/tests/files/zrealm_crossrealm29a.gno +++ b/gnovm/tests/files/zrealm_crossrealm29a.gno @@ -13,9 +13,9 @@ var f = func() bool { } func main() { - crossrealm.SetCallback(f) + crossrealm.SetCallback(f) // func value crossrealm.ExecuteCallback() } -// Output: -// callback +// Error: +// cannot attach objects by value from external realm diff --git a/gnovm/tests/files/zrealm_crossrealm29b.gno b/gnovm/tests/files/zrealm_crossrealm29b.gno index 62e90a9d988..c0e00f79852 100644 --- a/gnovm/tests/files/zrealm_crossrealm29b.gno +++ b/gnovm/tests/files/zrealm_crossrealm29b.gno @@ -16,4 +16,4 @@ func main() { } // Error: -// should not happen while attempting to attach new real object from external realm +// cannot attach a value of a type defined by another realm diff --git a/gnovm/tests/files/zrealm_crossrealm29c.gno b/gnovm/tests/files/zrealm_crossrealm29c.gno new file mode 100644 index 00000000000..fdd1cf278af --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm29c.gno @@ -0,0 +1,19 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +type Foo struct { +} + +var a = Foo{} + +var f = func() bool { + println("callback") + return true +} + +func main() { + println("ok") +} + +// Output: +// ok diff --git a/gnovm/tests/files/zrealm_crossrealm31.gno b/gnovm/tests/files/zrealm_crossrealm31.gno index 366fafb377a..70d62fe320b 100644 --- a/gnovm/tests/files/zrealm_crossrealm31.gno +++ b/gnovm/tests/files/zrealm_crossrealm31.gno @@ -15,4 +15,4 @@ func main() { } // Error: -// should not happen while attempting to attach new real object from external realm +// cannot attach a reference to an unreal object from an external realm diff --git a/gnovm/tests/files/zrealm_crossrealm32.gno b/gnovm/tests/files/zrealm_crossrealm32.gno index 5dd6dafbc20..a9f196ed62b 100644 --- a/gnovm/tests/files/zrealm_crossrealm32.gno +++ b/gnovm/tests/files/zrealm_crossrealm32.gno @@ -16,3 +16,5441 @@ func main() { // Output: // . + +// Realm: +// switchrealm["gno.land/r/demo/tests/crossrealm"] +// c[1712ac7adcfdc8e58a67e5615e20fb312394c4df:46]={ +// "Fields": [ +// { +// "T": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// }, +// "V": { +// "@type": "/gno.StringValue", +// "value": "0" +// } +// } +// ], +// "ObjectInfo": { +// "ID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:46", +// "ModTime": "0", +// "OwnerID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:45", +// "RefCount": "1" +// } +// } +// c[1712ac7adcfdc8e58a67e5615e20fb312394c4df:45]={ +// "Data": null, +// "List": [ +// { +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:32" +// } +// }, +// { +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "2489b816b7c9cfcc07f7e853718aaa019016fced", +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:46" +// } +// } +// ], +// "ObjectInfo": { +// "ID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:45", +// "ModTime": "0", +// "OwnerID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:2", +// "RefCount": "1" +// } +// } +// u[1712ac7adcfdc8e58a67e5615e20fb312394c4df:2]={ +// "Blank": {}, +// "ObjectInfo": { +// "ID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:2", +// "IsEscaped": true, +// "ModTime": "44", +// "RefCount": "10" +// }, +// "Parent": null, +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "0", +// "File": "", +// "Line": "0", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Values": [ +// { +// "T": { +// "@type": "/gno.TypeType" +// }, +// "V": { +// "@type": "/gno.TypeValue", +// "Type": { +// "@type": "/gno.DeclaredType", +// "Base": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "4" +// } +// } +// ] +// }, +// "Methods": [], +// "Name": "F", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.F" +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "ff", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.F" +// } +// } +// ], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:3" +// }, +// "FileName": "crossrealm_func.gno", +// "IsMethod": false, +// "Name": "SetCallback", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_func.gno", +// "Line": "7", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "ff", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.F" +// } +// } +// ], +// "Results": [] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:3" +// }, +// "FileName": "crossrealm_func.gno", +// "IsMethod": false, +// "Name": "ExecuteCallback", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_func.gno", +// "Line": "11", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:4" +// }, +// "FileName": "", +// "IsMethod": false, +// "Name": "", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "10", +// "File": "crossrealm_func2.gno", +// "Line": "3", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// } +// ] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// } +// ] +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:4" +// }, +// "FileName": "crossrealm_func2.gno", +// "IsMethod": false, +// "Name": "GetFunc", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_func2.gno", +// "Line": "8", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// } +// ] +// } +// } +// ] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// } +// ] +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:4" +// }, +// "FileName": "crossrealm_func2.gno", +// "IsMethod": false, +// "Name": "GetFunc2", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_func2.gno", +// "Line": "12", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// } +// ] +// } +// } +// ] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.TypeType" +// }, +// "V": { +// "@type": "/gno.TypeValue", +// "Type": { +// "@type": "/gno.DeclaredType", +// "Base": { +// "@type": "/gno.StructType", +// "Fields": [], +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// }, +// "Methods": [ +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "sv", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.MyStruct" +// } +// } +// } +// ], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": null, +// "FileName": "crossrealm_func2.gno", +// "IsMethod": true, +// "Name": "M", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_func2.gno", +// "Line": "20", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "sv", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.MyStruct" +// } +// } +// } +// ], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// } +// ] +// } +// } +// } +// ], +// "Name": "MyStruct", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.MyStruct" +// } +// }, +// "V": { +// "@type": "/gno.PointerValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Hash": "66606f1f6d50797bbe89640247170078dcbf0e6a", +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:5" +// }, +// "Index": "0", +// "TV": null +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// } +// ] +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:4" +// }, +// "FileName": "crossrealm_func2.gno", +// "IsMethod": false, +// "Name": "GetMethod", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_func2.gno", +// "Line": "30", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// } +// ] +// } +// } +// ] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.TypeType" +// }, +// "V": { +// "@type": "/gno.TypeValue", +// "Type": { +// "@type": "/gno.DeclaredType", +// "Base": { +// "@type": "/gno.InterfaceType", +// "Generic": "", +// "Methods": [ +// { +// "Embedded": false, +// "Name": "Foo", +// "Tag": "", +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// } +// } +// ], +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// }, +// "Methods": [], +// "Name": "Fooer", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" +// } +// } +// ], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:7" +// }, +// "FileName": "crossrealm_iface.gno", +// "IsMethod": false, +// "Name": "SetFooer", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_iface.gno", +// "Line": "8", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" +// } +// } +// ], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" +// } +// } +// ] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:7" +// }, +// "FileName": "crossrealm_iface.gno", +// "IsMethod": false, +// "Name": "CallFoo", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_iface.gno", +// "Line": "13", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.TypeType" +// }, +// "V": { +// "@type": "/gno.TypeValue", +// "Type": { +// "@type": "/gno.DeclaredType", +// "Base": { +// "@type": "/gno.StructType", +// "Fields": [ +// { +// "Embedded": false, +// "Name": "name", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// }, +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" +// } +// } +// ], +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// }, +// "Methods": [], +// "Name": "Container", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Container" +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "a7562372e10ade1d106ae5ef9e97c170ee4b50f1", +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:8" +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" +// } +// } +// ], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:7" +// }, +// "FileName": "crossrealm_iface.gno", +// "IsMethod": false, +// "Name": "SetContainer", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_iface.gno", +// "Line": "23", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" +// } +// } +// ], +// "Results": [] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" +// } +// } +// ], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:7" +// }, +// "FileName": "crossrealm_iface.gno", +// "IsMethod": false, +// "Name": "SetContainer2", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_iface.gno", +// "Line": "27", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" +// } +// } +// ], +// "Results": [] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.MapType", +// "Key": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// }, +// "Value": { +// "@type": "/gno.PrimitiveType", +// "value": "32" +// } +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "cda4bc373a1cceedd07fe9fd29410bfd5732df7c", +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:25" +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:9" +// }, +// "FileName": "crossrealm_map.gno", +// "IsMethod": false, +// "Name": "init.19", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_map.gno", +// "Line": "5", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.MapType", +// "Key": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// }, +// "Value": { +// "@type": "/gno.PrimitiveType", +// "value": "32" +// } +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:9" +// }, +// "FileName": "crossrealm_map.gno", +// "IsMethod": false, +// "Name": "GetMap", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_map.gno", +// "Line": "10", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.MapType", +// "Key": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// }, +// "Value": { +// "@type": "/gno.PrimitiveType", +// "value": "32" +// } +// } +// } +// ] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.TypeType" +// }, +// "V": { +// "@type": "/gno.TypeValue", +// "Type": { +// "@type": "/gno.DeclaredType", +// "Base": { +// "@type": "/gno.StructType", +// "Fields": [ +// { +// "Embedded": false, +// "Name": "A", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "32" +// } +// } +// ], +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// }, +// "Methods": [ +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "ls", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.LocalStruct" +// } +// } +// } +// ], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": null, +// "FileName": "crossrealm_p.gno", +// "IsMethod": true, +// "Name": "String", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_p.gno", +// "Line": "12", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "ls", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.LocalStruct" +// } +// } +// } +// ], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// } +// ] +// } +// } +// } +// ], +// "Name": "LocalStruct", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.LocalStruct" +// } +// }, +// "V": { +// "@type": "/gno.PointerValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Hash": "921bae5520c2c8b9d456b47651ea80481836de4e", +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:26" +// }, +// "Index": "0", +// "TV": null +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:10" +// }, +// "FileName": "crossrealm_p.gno", +// "IsMethod": false, +// "Name": "init.23", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_p.gno", +// "Line": "19", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/tests/p_crossrealm.Container" +// } +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:10" +// }, +// "FileName": "crossrealm_p.gno", +// "IsMethod": false, +// "Name": "Make1", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_p.gno", +// "Line": "24", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/tests/p_crossrealm.Container" +// } +// } +// } +// ] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" +// }, +// "Vrd": false +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "fs", +// "Tag": "", +// "Type": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" +// }, +// "Vrd": false +// } +// } +// ], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:11" +// }, +// "FileName": "crossrealm_slice.gno", +// "IsMethod": false, +// "Name": "SetSlice", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_slice.gno", +// "Line": "5", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "fs", +// "Tag": "", +// "Type": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" +// }, +// "Vrd": false +// } +// } +// ], +// "Results": [] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.TypeType" +// }, +// "V": { +// "@type": "/gno.TypeValue", +// "Type": { +// "@type": "/gno.DeclaredType", +// "Base": { +// "@type": "/gno.StructType", +// "Fields": [ +// { +// "Embedded": false, +// "Name": "name", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// } +// ], +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// }, +// "Methods": [], +// "Name": "XYZ", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// }, +// "Vrd": false +// }, +// "V": { +// "@type": "/gno.SliceValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Hash": "b3b42c06d65da2199792616887b55d65b79f075e", +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:28" +// }, +// "Length": "2", +// "Maxcap": "2", +// "Offset": "0" +// } +// }, +// { +// "T": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// }, +// "Vrd": false +// }, +// "V": { +// "@type": "/gno.SliceValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Hash": "fa5658dcf95bafce7154d3380ebf7e9211b4ab4d", +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:45" +// }, +// "Length": "2", +// "Maxcap": "2", +// "Offset": "0" +// } +// }, +// { +// "T": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// }, +// "Vrd": false +// }, +// "V": { +// "@type": "/gno.SliceValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Hash": "7c8932f1337c257a3236c79d7d8b4211812d8385", +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:33" +// }, +// "Length": "1", +// "Maxcap": "1", +// "Offset": "0" +// } +// }, +// { +// "T": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// } +// }, +// "Vrd": false +// }, +// "V": { +// "@type": "/gno.SliceValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Hash": "dbf56198a94f3a1d98c501d1b8c58b88bfbe8bce", +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:35" +// }, +// "Length": "1", +// "Maxcap": "1", +// "Offset": "0" +// } +// }, +// { +// "T": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// } +// }, +// "Vrd": false +// }, +// "V": { +// "@type": "/gno.SliceValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Hash": "8f5471d881fd68800170d03c52907ce7a7607d09", +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:12" +// }, +// "Length": "2", +// "Maxcap": "2", +// "Offset": "0" +// } +// }, +// { +// "T": { +// "@type": "/gno.ArrayType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// }, +// "Len": "2", +// "Vrd": false +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "41d4fd3b5431d4cd8494803a01f437bddd45b521", +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:13" +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:16" +// }, +// "FileName": "crossrealm_slice2.gno", +// "IsMethod": false, +// "Name": "init.34", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_slice2.gno", +// "Line": "13", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// }, +// "Vrd": false +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:16" +// }, +// "FileName": "crossrealm_slice2.gno", +// "IsMethod": false, +// "Name": "GetSlice", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_slice2.gno", +// "Line": "28", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// }, +// "Vrd": false +// } +// } +// ] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "b439d9527c852f481b3dcc9c4ad27fcf6b2cbc6e", +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:17" +// } +// }, +// { +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "c3a08360b77971b3c8a35a4c9c0955f6336760c4", +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:18" +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// }, +// "Vrd": false +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:16" +// }, +// "FileName": "crossrealm_slice2.gno", +// "IsMethod": false, +// "Name": "GetSlice2", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_slice2.gno", +// "Line": "36", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// }, +// "Vrd": false +// } +// } +// ] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// }, +// "Vrd": false +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:16" +// }, +// "FileName": "crossrealm_slice2.gno", +// "IsMethod": false, +// "Name": "GetSlice3", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_slice2.gno", +// "Line": "44", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// }, +// "Vrd": false +// } +// } +// ] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "s", +// "Tag": "", +// "Type": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// }, +// "Vrd": false +// } +// } +// ], +// "Results": [] +// } +// } +// ], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:16" +// }, +// "FileName": "crossrealm_slice2.gno", +// "IsMethod": false, +// "Name": "GetSlice4", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_slice2.gno", +// "Line": "49", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "s", +// "Tag": "", +// "Type": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// }, +// "Vrd": false +// } +// } +// ], +// "Results": [] +// } +// } +// ], +// "Results": [] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// } +// }, +// "Vrd": false +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:16" +// }, +// "FileName": "crossrealm_slice2.gno", +// "IsMethod": false, +// "Name": "GetSlice5", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_slice2.gno", +// "Line": "54", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// } +// }, +// "Vrd": false +// } +// } +// ] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "s", +// "Tag": "", +// "Type": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// } +// }, +// "Vrd": false +// } +// } +// ], +// "Results": [] +// } +// } +// ], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:16" +// }, +// "FileName": "crossrealm_slice2.gno", +// "IsMethod": false, +// "Name": "GetSlice6", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_slice2.gno", +// "Line": "58", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "s", +// "Tag": "", +// "Type": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// } +// }, +// "Vrd": false +// } +// } +// ], +// "Results": [] +// } +// } +// ], +// "Results": [] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "s", +// "Tag": "", +// "Type": { +// "@type": "/gno.ArrayType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// }, +// "Len": "2", +// "Vrd": false +// } +// } +// ], +// "Results": [] +// } +// } +// ], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:16" +// }, +// "FileName": "crossrealm_slice2.gno", +// "IsMethod": false, +// "Name": "GetSlice7", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_slice2.gno", +// "Line": "63", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "s", +// "Tag": "", +// "Type": { +// "@type": "/gno.ArrayType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// }, +// "Len": "2", +// "Vrd": false +// } +// } +// ], +// "Results": [] +// } +// } +// ], +// "Results": [] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.TypeType" +// }, +// "V": { +// "@type": "/gno.TypeValue", +// "Type": { +// "@type": "/gno.DeclaredType", +// "Base": { +// "@type": "/gno.StructType", +// "Fields": [ +// { +// "Embedded": false, +// "Name": "A", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "32" +// } +// } +// ], +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// }, +// "Methods": [ +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "b", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Bar" +// } +// } +// } +// ], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": null, +// "FileName": "crossrealm_struct.gno", +// "IsMethod": true, +// "Name": "String", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_struct.gno", +// "Line": "12", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "b", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Bar" +// } +// } +// } +// ], +// "Results": [] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "b", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Bar" +// } +// } +// } +// ], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": null, +// "FileName": "crossrealm_struct.gno", +// "IsMethod": true, +// "Name": "ModifyBar", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_struct.gno", +// "Line": "26", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "b", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Bar" +// } +// } +// } +// ], +// "Results": [] +// } +// } +// } +// ], +// "Name": "Bar", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Bar" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Bar" +// } +// }, +// "V": { +// "@type": "/gno.PointerValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Hash": "eb498518bc671b8c1625ffbe54846ac1df8601a5", +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:19" +// }, +// "Index": "0", +// "TV": null +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "b", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Bar" +// } +// } +// } +// ], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Bar" +// } +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:21" +// }, +// "FileName": "crossrealm_struct.gno", +// "IsMethod": false, +// "Name": "SetBar", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_struct.gno", +// "Line": "16", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "b", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Bar" +// } +// } +// } +// ], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Bar" +// } +// } +// } +// ] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:21" +// }, +// "FileName": "crossrealm_struct.gno", +// "IsMethod": false, +// "Name": "ChangeBar", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_struct.gno", +// "Line": "21", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.TypeType" +// }, +// "V": { +// "@type": "/gno.TypeValue", +// "Type": { +// "@type": "/gno.DeclaredType", +// "Base": { +// "@type": "/gno.StructType", +// "Fields": [ +// { +// "Embedded": false, +// "Name": "name", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// } +// ], +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// }, +// "Methods": [], +// "Name": "A", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.TypeType" +// }, +// "V": { +// "@type": "/gno.TypeValue", +// "Type": { +// "@type": "/gno.DeclaredType", +// "Base": { +// "@type": "/gno.StructType", +// "Fields": [ +// { +// "Embedded": false, +// "Name": "name", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// } +// ], +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// }, +// "Methods": [], +// "Name": "B", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.TypeType" +// }, +// "V": { +// "@type": "/gno.TypeValue", +// "Type": { +// "@type": "/gno.DeclaredType", +// "Base": { +// "@type": "/gno.StructType", +// "Fields": [ +// { +// "Embedded": false, +// "Name": "name", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// } +// ], +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// }, +// "Methods": [], +// "Name": "D", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.TypeType" +// }, +// "V": { +// "@type": "/gno.TypeValue", +// "Type": { +// "@type": "/gno.DeclaredType", +// "Base": { +// "@type": "/gno.StructType", +// "Fields": [ +// { +// "Embedded": true, +// "Name": "A", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.A" +// } +// }, +// { +// "Embedded": true, +// "Name": "B", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.B" +// } +// }, +// { +// "Embedded": true, +// "Name": "D", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.D" +// } +// } +// ], +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// }, +// "Methods": [], +// "Name": "C", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.A" +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "600bc777de2ebe4f91378028f2331fdfdc891ddc", +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:22" +// } +// }, +// { +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.B" +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "78dd21cd9cef4925a96ee4fbbf182d1494f646d5", +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:23" +// } +// }, +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.C" +// } +// }, +// "V": { +// "@type": "/gno.PointerValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Hash": "c443db3ae26b6a807ae6a997f395af8ca986b3b3", +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:42" +// }, +// "Index": "0", +// "TV": null +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:24" +// }, +// "FileName": "crossrealm_struct2.gno", +// "IsMethod": false, +// "Name": "init.56", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_struct2.gno", +// "Line": "26", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "cb", +// "Tag": "", +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "v", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.C" +// } +// } +// } +// ], +// "Results": [] +// } +// } +// ], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.C" +// } +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:24" +// }, +// "FileName": "crossrealm_struct2.gno", +// "IsMethod": false, +// "Name": "GetStruct", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_struct2.gno", +// "Line": "32", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "cb", +// "Tag": "", +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "v", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.C" +// } +// } +// } +// ], +// "Results": [] +// } +// } +// ], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.C" +// } +// } +// } +// ] +// } +// } +// } +// ] +// } +// d[1712ac7adcfdc8e58a67e5615e20fb312394c4df:31] +// d[1712ac7adcfdc8e58a67e5615e20fb312394c4df:32] +// switchrealm["gno.land/r/crossrealm_test"] +// u[f5a516808f8976c33939133293d598ce3bca4e8d:2]={ +// "Blank": {}, +// "ObjectInfo": { +// "ID": "f5a516808f8976c33939133293d598ce3bca4e8d:2", +// "IsEscaped": true, +// "ModTime": "3", +// "RefCount": "2" +// }, +// "Parent": null, +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "0", +// "File": "", +// "Line": "0", +// "PkgPath": "gno.land/r/crossrealm_test" +// } +// }, +// "Values": [ +// { +// "T": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// }, +// "Vrd": false +// }, +// "V": { +// "@type": "/gno.SliceValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:45" +// }, +// "Length": "2", +// "Maxcap": "2", +// "Offset": "0" +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "f5a516808f8976c33939133293d598ce3bca4e8d:3" +// }, +// "FileName": "main.gno", +// "IsMethod": false, +// "Name": "main", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/crossrealm_test", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "main.gno", +// "Line": "12", +// "PkgPath": "gno.land/r/crossrealm_test" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// } +// } +// } +// ] +// } +// u[1712ac7adcfdc8e58a67e5615e20fb312394c4df:2]={ +// "Blank": {}, +// "ObjectInfo": { +// "ID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:2", +// "IsEscaped": true, +// "ModTime": "3", +// "RefCount": "10" +// }, +// "Parent": null, +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "0", +// "File": "", +// "Line": "0", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Values": [ +// { +// "T": { +// "@type": "/gno.TypeType" +// }, +// "V": { +// "@type": "/gno.TypeValue", +// "Type": { +// "@type": "/gno.DeclaredType", +// "Base": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "4" +// } +// } +// ] +// }, +// "Methods": [], +// "Name": "F", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.F" +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "ff", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.F" +// } +// } +// ], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:3" +// }, +// "FileName": "crossrealm_func.gno", +// "IsMethod": false, +// "Name": "SetCallback", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_func.gno", +// "Line": "7", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "ff", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.F" +// } +// } +// ], +// "Results": [] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:3" +// }, +// "FileName": "crossrealm_func.gno", +// "IsMethod": false, +// "Name": "ExecuteCallback", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_func.gno", +// "Line": "11", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:4" +// }, +// "FileName": "", +// "IsMethod": false, +// "Name": "", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "10", +// "File": "crossrealm_func2.gno", +// "Line": "3", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// } +// ] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// } +// ] +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:4" +// }, +// "FileName": "crossrealm_func2.gno", +// "IsMethod": false, +// "Name": "GetFunc", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_func2.gno", +// "Line": "8", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// } +// ] +// } +// } +// ] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// } +// ] +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:4" +// }, +// "FileName": "crossrealm_func2.gno", +// "IsMethod": false, +// "Name": "GetFunc2", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_func2.gno", +// "Line": "12", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// } +// ] +// } +// } +// ] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.TypeType" +// }, +// "V": { +// "@type": "/gno.TypeValue", +// "Type": { +// "@type": "/gno.DeclaredType", +// "Base": { +// "@type": "/gno.StructType", +// "Fields": [], +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// }, +// "Methods": [ +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "sv", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.MyStruct" +// } +// } +// } +// ], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": null, +// "FileName": "crossrealm_func2.gno", +// "IsMethod": true, +// "Name": "M", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_func2.gno", +// "Line": "20", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "sv", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.MyStruct" +// } +// } +// } +// ], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// } +// ] +// } +// } +// } +// ], +// "Name": "MyStruct", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.MyStruct" +// } +// }, +// "V": { +// "@type": "/gno.PointerValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Hash": "66606f1f6d50797bbe89640247170078dcbf0e6a", +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:5" +// }, +// "Index": "0", +// "TV": null +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// } +// ] +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:4" +// }, +// "FileName": "crossrealm_func2.gno", +// "IsMethod": false, +// "Name": "GetMethod", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_func2.gno", +// "Line": "30", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// } +// ] +// } +// } +// ] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.TypeType" +// }, +// "V": { +// "@type": "/gno.TypeValue", +// "Type": { +// "@type": "/gno.DeclaredType", +// "Base": { +// "@type": "/gno.InterfaceType", +// "Generic": "", +// "Methods": [ +// { +// "Embedded": false, +// "Name": "Foo", +// "Tag": "", +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// } +// } +// ], +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// }, +// "Methods": [], +// "Name": "Fooer", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" +// } +// } +// ], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:7" +// }, +// "FileName": "crossrealm_iface.gno", +// "IsMethod": false, +// "Name": "SetFooer", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_iface.gno", +// "Line": "8", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" +// } +// } +// ], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" +// } +// } +// ] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:7" +// }, +// "FileName": "crossrealm_iface.gno", +// "IsMethod": false, +// "Name": "CallFoo", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_iface.gno", +// "Line": "13", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.TypeType" +// }, +// "V": { +// "@type": "/gno.TypeValue", +// "Type": { +// "@type": "/gno.DeclaredType", +// "Base": { +// "@type": "/gno.StructType", +// "Fields": [ +// { +// "Embedded": false, +// "Name": "name", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// }, +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" +// } +// } +// ], +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// }, +// "Methods": [], +// "Name": "Container", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Container" +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "a7562372e10ade1d106ae5ef9e97c170ee4b50f1", +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:8" +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" +// } +// } +// ], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:7" +// }, +// "FileName": "crossrealm_iface.gno", +// "IsMethod": false, +// "Name": "SetContainer", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_iface.gno", +// "Line": "23", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" +// } +// } +// ], +// "Results": [] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" +// } +// } +// ], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:7" +// }, +// "FileName": "crossrealm_iface.gno", +// "IsMethod": false, +// "Name": "SetContainer2", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_iface.gno", +// "Line": "27", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" +// } +// } +// ], +// "Results": [] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.MapType", +// "Key": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// }, +// "Value": { +// "@type": "/gno.PrimitiveType", +// "value": "32" +// } +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "cda4bc373a1cceedd07fe9fd29410bfd5732df7c", +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:25" +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:9" +// }, +// "FileName": "crossrealm_map.gno", +// "IsMethod": false, +// "Name": "init.19", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_map.gno", +// "Line": "5", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.MapType", +// "Key": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// }, +// "Value": { +// "@type": "/gno.PrimitiveType", +// "value": "32" +// } +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:9" +// }, +// "FileName": "crossrealm_map.gno", +// "IsMethod": false, +// "Name": "GetMap", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_map.gno", +// "Line": "10", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.MapType", +// "Key": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// }, +// "Value": { +// "@type": "/gno.PrimitiveType", +// "value": "32" +// } +// } +// } +// ] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.TypeType" +// }, +// "V": { +// "@type": "/gno.TypeValue", +// "Type": { +// "@type": "/gno.DeclaredType", +// "Base": { +// "@type": "/gno.StructType", +// "Fields": [ +// { +// "Embedded": false, +// "Name": "A", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "32" +// } +// } +// ], +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// }, +// "Methods": [ +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "ls", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.LocalStruct" +// } +// } +// } +// ], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": null, +// "FileName": "crossrealm_p.gno", +// "IsMethod": true, +// "Name": "String", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_p.gno", +// "Line": "12", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "ls", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.LocalStruct" +// } +// } +// } +// ], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// } +// ] +// } +// } +// } +// ], +// "Name": "LocalStruct", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.LocalStruct" +// } +// }, +// "V": { +// "@type": "/gno.PointerValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Hash": "921bae5520c2c8b9d456b47651ea80481836de4e", +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:26" +// }, +// "Index": "0", +// "TV": null +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:10" +// }, +// "FileName": "crossrealm_p.gno", +// "IsMethod": false, +// "Name": "init.23", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_p.gno", +// "Line": "19", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/tests/p_crossrealm.Container" +// } +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:10" +// }, +// "FileName": "crossrealm_p.gno", +// "IsMethod": false, +// "Name": "Make1", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_p.gno", +// "Line": "24", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/tests/p_crossrealm.Container" +// } +// } +// } +// ] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" +// }, +// "Vrd": false +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "fs", +// "Tag": "", +// "Type": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" +// }, +// "Vrd": false +// } +// } +// ], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:11" +// }, +// "FileName": "crossrealm_slice.gno", +// "IsMethod": false, +// "Name": "SetSlice", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_slice.gno", +// "Line": "5", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "fs", +// "Tag": "", +// "Type": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" +// }, +// "Vrd": false +// } +// } +// ], +// "Results": [] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.TypeType" +// }, +// "V": { +// "@type": "/gno.TypeValue", +// "Type": { +// "@type": "/gno.DeclaredType", +// "Base": { +// "@type": "/gno.StructType", +// "Fields": [ +// { +// "Embedded": false, +// "Name": "name", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// } +// ], +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// }, +// "Methods": [], +// "Name": "XYZ", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// }, +// "Vrd": false +// }, +// "V": { +// "@type": "/gno.SliceValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Hash": "b3b42c06d65da2199792616887b55d65b79f075e", +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:28" +// }, +// "Length": "2", +// "Maxcap": "2", +// "Offset": "0" +// } +// }, +// { +// "T": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// }, +// "Vrd": false +// }, +// "V": { +// "@type": "/gno.SliceValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:45" +// }, +// "Length": "2", +// "Maxcap": "2", +// "Offset": "0" +// } +// }, +// { +// "T": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// }, +// "Vrd": false +// }, +// "V": { +// "@type": "/gno.SliceValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Hash": "7c8932f1337c257a3236c79d7d8b4211812d8385", +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:33" +// }, +// "Length": "1", +// "Maxcap": "1", +// "Offset": "0" +// } +// }, +// { +// "T": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// } +// }, +// "Vrd": false +// }, +// "V": { +// "@type": "/gno.SliceValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Hash": "dbf56198a94f3a1d98c501d1b8c58b88bfbe8bce", +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:35" +// }, +// "Length": "1", +// "Maxcap": "1", +// "Offset": "0" +// } +// }, +// { +// "T": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// } +// }, +// "Vrd": false +// }, +// "V": { +// "@type": "/gno.SliceValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Hash": "8f5471d881fd68800170d03c52907ce7a7607d09", +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:12" +// }, +// "Length": "2", +// "Maxcap": "2", +// "Offset": "0" +// } +// }, +// { +// "T": { +// "@type": "/gno.ArrayType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// }, +// "Len": "2", +// "Vrd": false +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "41d4fd3b5431d4cd8494803a01f437bddd45b521", +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:13" +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:16" +// }, +// "FileName": "crossrealm_slice2.gno", +// "IsMethod": false, +// "Name": "init.34", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_slice2.gno", +// "Line": "13", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// }, +// "Vrd": false +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:16" +// }, +// "FileName": "crossrealm_slice2.gno", +// "IsMethod": false, +// "Name": "GetSlice", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_slice2.gno", +// "Line": "28", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// }, +// "Vrd": false +// } +// } +// ] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "b439d9527c852f481b3dcc9c4ad27fcf6b2cbc6e", +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:17" +// } +// }, +// { +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "c3a08360b77971b3c8a35a4c9c0955f6336760c4", +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:18" +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// }, +// "Vrd": false +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:16" +// }, +// "FileName": "crossrealm_slice2.gno", +// "IsMethod": false, +// "Name": "GetSlice2", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_slice2.gno", +// "Line": "36", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// }, +// "Vrd": false +// } +// } +// ] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// }, +// "Vrd": false +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:16" +// }, +// "FileName": "crossrealm_slice2.gno", +// "IsMethod": false, +// "Name": "GetSlice3", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_slice2.gno", +// "Line": "44", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// }, +// "Vrd": false +// } +// } +// ] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "s", +// "Tag": "", +// "Type": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// }, +// "Vrd": false +// } +// } +// ], +// "Results": [] +// } +// } +// ], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:16" +// }, +// "FileName": "crossrealm_slice2.gno", +// "IsMethod": false, +// "Name": "GetSlice4", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_slice2.gno", +// "Line": "49", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "s", +// "Tag": "", +// "Type": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// }, +// "Vrd": false +// } +// } +// ], +// "Results": [] +// } +// } +// ], +// "Results": [] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// } +// }, +// "Vrd": false +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:16" +// }, +// "FileName": "crossrealm_slice2.gno", +// "IsMethod": false, +// "Name": "GetSlice5", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_slice2.gno", +// "Line": "54", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// } +// }, +// "Vrd": false +// } +// } +// ] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "s", +// "Tag": "", +// "Type": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// } +// }, +// "Vrd": false +// } +// } +// ], +// "Results": [] +// } +// } +// ], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:16" +// }, +// "FileName": "crossrealm_slice2.gno", +// "IsMethod": false, +// "Name": "GetSlice6", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_slice2.gno", +// "Line": "58", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "s", +// "Tag": "", +// "Type": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// } +// }, +// "Vrd": false +// } +// } +// ], +// "Results": [] +// } +// } +// ], +// "Results": [] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "s", +// "Tag": "", +// "Type": { +// "@type": "/gno.ArrayType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// }, +// "Len": "2", +// "Vrd": false +// } +// } +// ], +// "Results": [] +// } +// } +// ], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:16" +// }, +// "FileName": "crossrealm_slice2.gno", +// "IsMethod": false, +// "Name": "GetSlice7", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_slice2.gno", +// "Line": "63", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "s", +// "Tag": "", +// "Type": { +// "@type": "/gno.ArrayType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// }, +// "Len": "2", +// "Vrd": false +// } +// } +// ], +// "Results": [] +// } +// } +// ], +// "Results": [] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.TypeType" +// }, +// "V": { +// "@type": "/gno.TypeValue", +// "Type": { +// "@type": "/gno.DeclaredType", +// "Base": { +// "@type": "/gno.StructType", +// "Fields": [ +// { +// "Embedded": false, +// "Name": "A", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "32" +// } +// } +// ], +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// }, +// "Methods": [ +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "b", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Bar" +// } +// } +// } +// ], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": null, +// "FileName": "crossrealm_struct.gno", +// "IsMethod": true, +// "Name": "String", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_struct.gno", +// "Line": "12", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "b", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Bar" +// } +// } +// } +// ], +// "Results": [] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "b", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Bar" +// } +// } +// } +// ], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": null, +// "FileName": "crossrealm_struct.gno", +// "IsMethod": true, +// "Name": "ModifyBar", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_struct.gno", +// "Line": "26", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "b", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Bar" +// } +// } +// } +// ], +// "Results": [] +// } +// } +// } +// ], +// "Name": "Bar", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Bar" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Bar" +// } +// }, +// "V": { +// "@type": "/gno.PointerValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Hash": "eb498518bc671b8c1625ffbe54846ac1df8601a5", +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:19" +// }, +// "Index": "0", +// "TV": null +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "b", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Bar" +// } +// } +// } +// ], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Bar" +// } +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:21" +// }, +// "FileName": "crossrealm_struct.gno", +// "IsMethod": false, +// "Name": "SetBar", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_struct.gno", +// "Line": "16", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "b", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Bar" +// } +// } +// } +// ], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.Bar" +// } +// } +// } +// ] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:21" +// }, +// "FileName": "crossrealm_struct.gno", +// "IsMethod": false, +// "Name": "ChangeBar", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_struct.gno", +// "Line": "21", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.TypeType" +// }, +// "V": { +// "@type": "/gno.TypeValue", +// "Type": { +// "@type": "/gno.DeclaredType", +// "Base": { +// "@type": "/gno.StructType", +// "Fields": [ +// { +// "Embedded": false, +// "Name": "name", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// } +// ], +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// }, +// "Methods": [], +// "Name": "A", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.TypeType" +// }, +// "V": { +// "@type": "/gno.TypeValue", +// "Type": { +// "@type": "/gno.DeclaredType", +// "Base": { +// "@type": "/gno.StructType", +// "Fields": [ +// { +// "Embedded": false, +// "Name": "name", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// } +// ], +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// }, +// "Methods": [], +// "Name": "B", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.TypeType" +// }, +// "V": { +// "@type": "/gno.TypeValue", +// "Type": { +// "@type": "/gno.DeclaredType", +// "Base": { +// "@type": "/gno.StructType", +// "Fields": [ +// { +// "Embedded": false, +// "Name": "name", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// } +// ], +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// }, +// "Methods": [], +// "Name": "D", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.TypeType" +// }, +// "V": { +// "@type": "/gno.TypeValue", +// "Type": { +// "@type": "/gno.DeclaredType", +// "Base": { +// "@type": "/gno.StructType", +// "Fields": [ +// { +// "Embedded": true, +// "Name": "A", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.A" +// } +// }, +// { +// "Embedded": true, +// "Name": "B", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.B" +// } +// }, +// { +// "Embedded": true, +// "Name": "D", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.D" +// } +// } +// ], +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// }, +// "Methods": [], +// "Name": "C", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.A" +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "600bc777de2ebe4f91378028f2331fdfdc891ddc", +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:22" +// } +// }, +// { +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.B" +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "78dd21cd9cef4925a96ee4fbbf182d1494f646d5", +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:23" +// } +// }, +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.C" +// } +// }, +// "V": { +// "@type": "/gno.PointerValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Hash": "c443db3ae26b6a807ae6a997f395af8ca986b3b3", +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:42" +// }, +// "Index": "0", +// "TV": null +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:24" +// }, +// "FileName": "crossrealm_struct2.gno", +// "IsMethod": false, +// "Name": "init.56", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_struct2.gno", +// "Line": "26", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "cb", +// "Tag": "", +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "v", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.C" +// } +// } +// } +// ], +// "Results": [] +// } +// } +// ], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.C" +// } +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:24" +// }, +// "FileName": "crossrealm_struct2.gno", +// "IsMethod": false, +// "Name": "GetStruct", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_struct2.gno", +// "Line": "32", +// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "cb", +// "Tag": "", +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "v", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.C" +// } +// } +// } +// ], +// "Results": [] +// } +// } +// ], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.C" +// } +// } +// } +// ] +// } +// } +// } +// ] +// } diff --git a/gnovm/tests/files/zrealm_crossrealm34.gno b/gnovm/tests/files/zrealm_crossrealm34.gno index 0cd5be053ff..14f51d9de75 100644 --- a/gnovm/tests/files/zrealm_crossrealm34.gno +++ b/gnovm/tests/files/zrealm_crossrealm34.gno @@ -16,3 +16,89 @@ func main() { // Output: // . + +// Realm: +// switchrealm["gno.land/r/demo/tests/crossrealm"] +// switchrealm["gno.land/r/crossrealm_test"] +// u[f5a516808f8976c33939133293d598ce3bca4e8d:2]={ +// "Blank": {}, +// "ObjectInfo": { +// "ID": "f5a516808f8976c33939133293d598ce3bca4e8d:2", +// "IsEscaped": true, +// "ModTime": "3", +// "RefCount": "2" +// }, +// "Parent": null, +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "0", +// "File": "", +// "Line": "0", +// "PkgPath": "gno.land/r/crossrealm_test" +// } +// }, +// "Values": [ +// { +// "T": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// } +// }, +// "Vrd": false +// }, +// "V": { +// "@type": "/gno.SliceValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:35" +// }, +// "Length": "1", +// "Maxcap": "1", +// "Offset": "0" +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "f5a516808f8976c33939133293d598ce3bca4e8d:3" +// }, +// "FileName": "main.gno", +// "IsMethod": false, +// "Name": "main", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/crossrealm_test", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "main.gno", +// "Line": "12", +// "PkgPath": "gno.land/r/crossrealm_test" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// } +// } +// } +// ] +// } diff --git a/gnovm/tests/files/zrealm_crossrealm34b.gno b/gnovm/tests/files/zrealm_crossrealm34b.gno index 673d2538188..ba1c8a8e398 100644 --- a/gnovm/tests/files/zrealm_crossrealm34b.gno +++ b/gnovm/tests/files/zrealm_crossrealm34b.gno @@ -19,4 +19,4 @@ func main() { } // Error: -// should not happen while attempting to attach new real object from external realm +// cannot attach a value of a type defined by another realm diff --git a/gnovm/tests/files/zrealm_crossrealm35.gno b/gnovm/tests/files/zrealm_crossrealm35.gno deleted file mode 100644 index 3a223dca545..00000000000 --- a/gnovm/tests/files/zrealm_crossrealm35.gno +++ /dev/null @@ -1,18 +0,0 @@ -// PKGPATH: gno.land/r/crossrealm_test -package crossrealm_test - -type XYZ struct{ name string } - -var S []*XYZ - -func init() { - S = append(S, &XYZ{"1"}) -} - -func main() { - a := S[0].name - println(a) -} - -// Output: -// 1 diff --git a/gnovm/tests/files/zrealm_crossrealm37.gno b/gnovm/tests/files/zrealm_crossrealm37.gno index 65dc493b100..a445dd73074 100644 --- a/gnovm/tests/files/zrealm_crossrealm37.gno +++ b/gnovm/tests/files/zrealm_crossrealm37.gno @@ -11,4 +11,4 @@ func main() { } // Error: -// should not happen while attempting to attach objects by value from external realm +// cannot attach objects by value from external realm diff --git a/gnovm/tests/files/zrealm_crossrealm38.gno b/gnovm/tests/files/zrealm_crossrealm38.gno index 3eda0c34e7e..59627cdd4bd 100644 --- a/gnovm/tests/files/zrealm_crossrealm38.gno +++ b/gnovm/tests/files/zrealm_crossrealm38.gno @@ -10,5 +10,5 @@ func main() { println(f()) } -// Output: -// a +// Error: +// cannot attach objects by value from external realm diff --git a/gnovm/tests/files/zrealm_crossrealm39.gno b/gnovm/tests/files/zrealm_crossrealm39.gno index f638eb67f4d..7cd5e0de0af 100644 --- a/gnovm/tests/files/zrealm_crossrealm39.gno +++ b/gnovm/tests/files/zrealm_crossrealm39.gno @@ -11,4 +11,4 @@ func main() { } // Error: -// should not happen while attempting to attach new real object from external realm +// cannot attach a value of a type defined by another realm diff --git a/gnovm/tests/files/zrealm_crossrealm40.gno b/gnovm/tests/files/zrealm_crossrealm40.gno index 7f5e126dc2b..dde17b0dd20 100644 --- a/gnovm/tests/files/zrealm_crossrealm40.gno +++ b/gnovm/tests/files/zrealm_crossrealm40.gno @@ -10,5 +10,5 @@ func main() { println(f) } -// XXX, fix this. // Error: +// cannot attach a value of a type defined by another realm diff --git a/gnovm/tests/files/zrealm_crossrealm42.gno b/gnovm/tests/files/zrealm_crossrealm42.gno index c4ea99ff24d..28abca22cb7 100644 --- a/gnovm/tests/files/zrealm_crossrealm42.gno +++ b/gnovm/tests/files/zrealm_crossrealm42.gno @@ -2,11 +2,15 @@ package crossrealm_test import crossrealm "gno.land/r/demo/tests/crossrealm" +import "fmt" type LocalBar crossrealm.Bar var lb LocalBar func main() { - println(lb) + fmt.Println(lb) } + +// Error: +// cannot attach a value of a type defined by another realm diff --git a/gnovm/tests/files/zrealm_crossrealm43.gno b/gnovm/tests/files/zrealm_crossrealm43.gno new file mode 100644 index 00000000000..2b5e5ee7b05 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm43.gno @@ -0,0 +1,16 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import crossrealm "gno.land/r/demo/tests/crossrealm" +import "fmt" + +type LocalBar *crossrealm.Bar // no attach + +var lb LocalBar + +func main() { + lb = &crossrealm.Bar{A: 1} +} + +// Error: +// cannot attach a reference to an unreal object from an external realm diff --git a/gnovm/tests/files/zrealm_crossrealm4_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm4_stdlibs.gno index c3dbc152930..c1ddc5157a0 100644 --- a/gnovm/tests/files/zrealm_crossrealm4_stdlibs.gno +++ b/gnovm/tests/files/zrealm_crossrealm4_stdlibs.gno @@ -19,4 +19,4 @@ func main() { } // Error: -// should not happen while attempting to attach new real object from external realm +// cannot attach a value of a type defined by another realm diff --git a/gnovm/tests/files/zrealm_crossrealm5_stdlibs.gno b/gnovm/tests/files/zrealm_crossrealm5_stdlibs.gno index b22fdf330c0..e0c800aa624 100644 --- a/gnovm/tests/files/zrealm_crossrealm5_stdlibs.gno +++ b/gnovm/tests/files/zrealm_crossrealm5_stdlibs.gno @@ -19,4 +19,4 @@ func main() { } // Error: -// should not happen while attempting to attach new real object from external realm +// cannot attach a value of a type defined by another realm From fd7f8c8e4e784978097e50debcdc98f002761d18 Mon Sep 17 00:00:00 2001 From: ltzMaxwell Date: Tue, 31 Dec 2024 18:30:26 +0800 Subject: [PATCH 35/40] refactor test --- .../demo/tests/crossrealm/crossrealm_func.gno | 13 - .../tests/crossrealm/crossrealm_slice.gno | 10 - .../tests/crossrealm/crossrealm_struct.gno | 28 - .../tests/crossrealm/crossrealm_struct2.gno | 36 - .../crossrealm_func.gno} | 14 +- .../{ => iface}/crossrealm_iface.gno | 2 +- .../crossrealm/{ => map}/crossrealm_map.gno | 2 +- .../crossrealm_slice.gno} | 14 +- .../crossrealm/struct/crossrealm_struct.gno | 64 + gnovm/tests/files/zrealm_crossrealm20.gno | 2 +- gnovm/tests/files/zrealm_crossrealm21.gno | 2 +- gnovm/tests/files/zrealm_crossrealm21a.gno | 2 +- gnovm/tests/files/zrealm_crossrealm21b.gno | 2 +- gnovm/tests/files/zrealm_crossrealm24.gno | 26 +- gnovm/tests/files/zrealm_crossrealm24a.gno | 2 +- gnovm/tests/files/zrealm_crossrealm24b.gno | 2 +- gnovm/tests/files/zrealm_crossrealm24c.gno | 2 +- gnovm/tests/files/zrealm_crossrealm24d.gno | 26 +- gnovm/tests/files/zrealm_crossrealm25.gno | 2 +- gnovm/tests/files/zrealm_crossrealm25a.gno | 2 +- gnovm/tests/files/zrealm_crossrealm25b.gno | 12 +- gnovm/tests/files/zrealm_crossrealm25c.gno | 2 +- gnovm/tests/files/zrealm_crossrealm25d.gno | 2 +- gnovm/tests/files/zrealm_crossrealm25e.gno | 2 +- gnovm/tests/files/zrealm_crossrealm27.gno | 12 +- gnovm/tests/files/zrealm_crossrealm27a.gno | 2 +- gnovm/tests/files/zrealm_crossrealm28.gno | 2 +- gnovm/tests/files/zrealm_crossrealm28b.gno | 2 +- gnovm/tests/files/zrealm_crossrealm28c.gno | 2 +- gnovm/tests/files/zrealm_crossrealm29.gno | 2 +- gnovm/tests/files/zrealm_crossrealm29a.gno | 2 +- gnovm/tests/files/zrealm_crossrealm29b.gno | 2 +- gnovm/tests/files/zrealm_crossrealm30.gno | 2 +- gnovm/tests/files/zrealm_crossrealm31.gno | 2 +- gnovm/tests/files/zrealm_crossrealm32.gno | 5706 ++++------------- gnovm/tests/files/zrealm_crossrealm33.gno | 2 +- gnovm/tests/files/zrealm_crossrealm34.gno | 8 +- gnovm/tests/files/zrealm_crossrealm34a.gno | 2 +- gnovm/tests/files/zrealm_crossrealm34b.gno | 2 +- gnovm/tests/files/zrealm_crossrealm36.gno | 2 +- gnovm/tests/files/zrealm_crossrealm37.gno | 2 +- gnovm/tests/files/zrealm_crossrealm38.gno | 2 +- gnovm/tests/files/zrealm_crossrealm39.gno | 2 +- gnovm/tests/files/zrealm_crossrealm40.gno | 2 +- gnovm/tests/files/zrealm_crossrealm42.gno | 2 +- gnovm/tests/files/zrealm_crossrealm43.gno | 2 +- 46 files changed, 1237 insertions(+), 4798 deletions(-) delete mode 100644 examples/gno.land/r/demo/tests/crossrealm/crossrealm_func.gno delete mode 100644 examples/gno.land/r/demo/tests/crossrealm/crossrealm_slice.gno delete mode 100644 examples/gno.land/r/demo/tests/crossrealm/crossrealm_struct.gno delete mode 100644 examples/gno.land/r/demo/tests/crossrealm/crossrealm_struct2.gno rename examples/gno.land/r/demo/tests/crossrealm/{crossrealm_func2.gno => func/crossrealm_func.gno} (82%) rename examples/gno.land/r/demo/tests/crossrealm/{ => iface}/crossrealm_iface.gno (96%) rename examples/gno.land/r/demo/tests/crossrealm/{ => map}/crossrealm_map.gno (84%) rename examples/gno.land/r/demo/tests/crossrealm/{crossrealm_slice2.gno => slice/crossrealm_slice.gno} (85%) create mode 100644 examples/gno.land/r/demo/tests/crossrealm/struct/crossrealm_struct.gno diff --git a/examples/gno.land/r/demo/tests/crossrealm/crossrealm_func.gno b/examples/gno.land/r/demo/tests/crossrealm/crossrealm_func.gno deleted file mode 100644 index a8d20091de5..00000000000 --- a/examples/gno.land/r/demo/tests/crossrealm/crossrealm_func.gno +++ /dev/null @@ -1,13 +0,0 @@ -package crossrealm - -type F func() bool - -var f F - -func SetCallback(ff F) { - f = ff -} - -func ExecuteCallback() { - f() -} diff --git a/examples/gno.land/r/demo/tests/crossrealm/crossrealm_slice.gno b/examples/gno.land/r/demo/tests/crossrealm/crossrealm_slice.gno deleted file mode 100644 index d58aba3553f..00000000000 --- a/examples/gno.land/r/demo/tests/crossrealm/crossrealm_slice.gno +++ /dev/null @@ -1,10 +0,0 @@ -package crossrealm - -var S []Fooer - -func SetSlice(fs []Fooer) { - S = fs - for _, f := range fs { - println(f) - } -} diff --git a/examples/gno.land/r/demo/tests/crossrealm/crossrealm_struct.gno b/examples/gno.land/r/demo/tests/crossrealm/crossrealm_struct.gno deleted file mode 100644 index f3eb3f21f00..00000000000 --- a/examples/gno.land/r/demo/tests/crossrealm/crossrealm_struct.gno +++ /dev/null @@ -1,28 +0,0 @@ -package crossrealm - -type Bar struct { - A int -} - -var bar *Bar - -// TODO: deprovision this -var Bar2 *Bar = &Bar{A: 22} // exported - -func (b *Bar) String() { - println("b.A: ", b.A) -} - -func SetBar(b *Bar) *Bar { - bar = b - return bar -} - -func ChangeBar() { - Bar2.A += 1 - //println(Bar2.A) -} - -func (b *Bar) ModifyBar() { - b.A += 1 -} diff --git a/examples/gno.land/r/demo/tests/crossrealm/crossrealm_struct2.gno b/examples/gno.land/r/demo/tests/crossrealm/crossrealm_struct2.gno deleted file mode 100644 index 2cb43b369ce..00000000000 --- a/examples/gno.land/r/demo/tests/crossrealm/crossrealm_struct2.gno +++ /dev/null @@ -1,36 +0,0 @@ -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 -} diff --git a/examples/gno.land/r/demo/tests/crossrealm/crossrealm_func2.gno b/examples/gno.land/r/demo/tests/crossrealm/func/crossrealm_func.gno similarity index 82% rename from examples/gno.land/r/demo/tests/crossrealm/crossrealm_func2.gno rename to examples/gno.land/r/demo/tests/crossrealm/func/crossrealm_func.gno index 7961fe4a2ec..9589cac78bd 100644 --- a/examples/gno.land/r/demo/tests/crossrealm/crossrealm_func2.gno +++ b/examples/gno.land/r/demo/tests/crossrealm/func/crossrealm_func.gno @@ -1,4 +1,16 @@ -package crossrealm +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 diff --git a/examples/gno.land/r/demo/tests/crossrealm/crossrealm_iface.gno b/examples/gno.land/r/demo/tests/crossrealm/iface/crossrealm_iface.gno similarity index 96% rename from examples/gno.land/r/demo/tests/crossrealm/crossrealm_iface.gno rename to examples/gno.land/r/demo/tests/crossrealm/iface/crossrealm_iface.gno index 528b8cba023..769a2e3ad59 100644 --- a/examples/gno.land/r/demo/tests/crossrealm/crossrealm_iface.gno +++ b/examples/gno.land/r/demo/tests/crossrealm/iface/crossrealm_iface.gno @@ -1,4 +1,4 @@ -package crossrealm +package iface // XXX, how about not interface type Fooer interface{ Foo() } diff --git a/examples/gno.land/r/demo/tests/crossrealm/crossrealm_map.gno b/examples/gno.land/r/demo/tests/crossrealm/map/crossrealm_map.gno similarity index 84% rename from examples/gno.land/r/demo/tests/crossrealm/crossrealm_map.gno rename to examples/gno.land/r/demo/tests/crossrealm/map/crossrealm_map.gno index a3241dfe721..eff818c6fdf 100644 --- a/examples/gno.land/r/demo/tests/crossrealm/crossrealm_map.gno +++ b/examples/gno.land/r/demo/tests/crossrealm/map/crossrealm_map.gno @@ -1,4 +1,4 @@ -package crossrealm +package crossrealm_map var m map[string]int diff --git a/examples/gno.land/r/demo/tests/crossrealm/crossrealm_slice2.gno b/examples/gno.land/r/demo/tests/crossrealm/slice/crossrealm_slice.gno similarity index 85% rename from examples/gno.land/r/demo/tests/crossrealm/crossrealm_slice2.gno rename to examples/gno.land/r/demo/tests/crossrealm/slice/crossrealm_slice.gno index f74a9623d0a..18f86c9a1b2 100644 --- a/examples/gno.land/r/demo/tests/crossrealm/crossrealm_slice2.gno +++ b/examples/gno.land/r/demo/tests/crossrealm/slice/crossrealm_slice.gno @@ -1,5 +1,17 @@ -package crossrealm +package crossrealm_slice +type Fooer interface{ Foo() } + +var S []Fooer + +func SetSlice(fs []Fooer) { + S = fs + for _, f := range fs { + println(f) + } +} + +// ------------------------------------- type XYZ struct{ name string } var s1 []XYZ diff --git a/examples/gno.land/r/demo/tests/crossrealm/struct/crossrealm_struct.gno b/examples/gno.land/r/demo/tests/crossrealm/struct/crossrealm_struct.gno new file mode 100644 index 00000000000..dc5a90038b6 --- /dev/null +++ b/examples/gno.land/r/demo/tests/crossrealm/struct/crossrealm_struct.gno @@ -0,0 +1,64 @@ +package crossrealm_struct + +type Bar struct { + A int +} + +var bar *Bar + +// TODO: deprovision this +var Bar2 *Bar = &Bar{A: 22} // exported + +func (b *Bar) String() { + println("b.A: ", b.A) +} + +func SetBar(b *Bar) *Bar { + bar = b + return bar +} + +func ChangeBar() { + Bar2.A += 1 + //println(Bar2.A) +} + +func (b *Bar) ModifyBar() { + b.A += 1 +} + +// ------------------------------------------------- +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 +} diff --git a/gnovm/tests/files/zrealm_crossrealm20.gno b/gnovm/tests/files/zrealm_crossrealm20.gno index 4e0fcb57591..3bac413912d 100644 --- a/gnovm/tests/files/zrealm_crossrealm20.gno +++ b/gnovm/tests/files/zrealm_crossrealm20.gno @@ -2,7 +2,7 @@ package crossrealm_test import ( - crossrealm "gno.land/r/demo/tests/crossrealm" + crossrealm "gno.land/r/demo/tests/crossrealm/struct" ) var b0 crossrealm.Bar // run declarations diff --git a/gnovm/tests/files/zrealm_crossrealm21.gno b/gnovm/tests/files/zrealm_crossrealm21.gno index ae8b58a44f6..dea0cc50103 100644 --- a/gnovm/tests/files/zrealm_crossrealm21.gno +++ b/gnovm/tests/files/zrealm_crossrealm21.gno @@ -2,7 +2,7 @@ package crossrealm_test import ( - crossrealm "gno.land/r/demo/tests/crossrealm" + crossrealm "gno.land/r/demo/tests/crossrealm/struct" ) func init() { diff --git a/gnovm/tests/files/zrealm_crossrealm21a.gno b/gnovm/tests/files/zrealm_crossrealm21a.gno index 6f8c7570e85..1ac379df2e0 100644 --- a/gnovm/tests/files/zrealm_crossrealm21a.gno +++ b/gnovm/tests/files/zrealm_crossrealm21a.gno @@ -2,7 +2,7 @@ package crossrealm_test import ( - crossrealm "gno.land/r/demo/tests/crossrealm" + crossrealm "gno.land/r/demo/tests/crossrealm/struct" ) // associate to a containing object diff --git a/gnovm/tests/files/zrealm_crossrealm21b.gno b/gnovm/tests/files/zrealm_crossrealm21b.gno index 4e6a497a588..635a92bc0e1 100644 --- a/gnovm/tests/files/zrealm_crossrealm21b.gno +++ b/gnovm/tests/files/zrealm_crossrealm21b.gno @@ -2,7 +2,7 @@ package crossrealm_test import ( - crossrealm "gno.land/r/demo/tests/crossrealm" + crossrealm "gno.land/r/demo/tests/crossrealm/struct" ) // associate to a containing object diff --git a/gnovm/tests/files/zrealm_crossrealm24.gno b/gnovm/tests/files/zrealm_crossrealm24.gno index a1f2ccab778..9b46421f253 100644 --- a/gnovm/tests/files/zrealm_crossrealm24.gno +++ b/gnovm/tests/files/zrealm_crossrealm24.gno @@ -2,7 +2,7 @@ package crossrealm_test import ( - crossrealm "gno.land/r/demo/tests/crossrealm" + crossrealm "gno.land/r/demo/tests/crossrealm/struct" ) type Ibar interface { @@ -26,13 +26,13 @@ func main() { } // Output: -// &(struct{(22 int)} gno.land/r/demo/tests/crossrealm.Bar) -// &(struct{(23 int)} gno.land/r/demo/tests/crossrealm.Bar) -// &(struct{(23 int)} gno.land/r/demo/tests/crossrealm.Bar) +// &(struct{(22 int)} gno.land/r/demo/tests/crossrealm/struct.Bar) +// &(struct{(23 int)} gno.land/r/demo/tests/crossrealm/struct.Bar) +// &(struct{(23 int)} gno.land/r/demo/tests/crossrealm/struct.Bar) // Realm: -// switchrealm["gno.land/r/demo/tests/crossrealm"] -// u[1712ac7adcfdc8e58a67e5615e20fb312394c4df:20]={ +// switchrealm["gno.land/r/demo/tests/crossrealm/struct"] +// u[5965ae851c02ab677bc8394b408535c1db9b2635:4]={ // "Fields": [ // { // "N": "FwAAAAAAAAA=", @@ -43,9 +43,9 @@ func main() { // } // ], // "ObjectInfo": { -// "ID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:20", -// "ModTime": "44", -// "OwnerID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:19", +// "ID": "5965ae851c02ab677bc8394b408535c1db9b2635:4", +// "ModTime": "10", +// "OwnerID": "5965ae851c02ab677bc8394b408535c1db9b2635:3", // "RefCount": "1" // } // } @@ -106,7 +106,7 @@ func main() { // "@type": "/gno.PointerType", // "Elt": { // "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Bar" +// "ID": "gno.land/r/demo/tests/crossrealm/struct.Bar" // } // }, // "V": { @@ -114,7 +114,7 @@ func main() { // "Base": { // "@type": "/gno.RefValue", // "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:19" +// "ObjectID": "5965ae851c02ab677bc8394b408535c1db9b2635:3" // }, // "Index": "0", // "TV": null @@ -125,7 +125,7 @@ func main() { // "@type": "/gno.PointerType", // "Elt": { // "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Bar" +// "ID": "gno.land/r/demo/tests/crossrealm/struct.Bar" // } // }, // "V": { @@ -133,7 +133,7 @@ func main() { // "Base": { // "@type": "/gno.RefValue", // "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:19" +// "ObjectID": "5965ae851c02ab677bc8394b408535c1db9b2635:3" // }, // "Index": "0", // "TV": null diff --git a/gnovm/tests/files/zrealm_crossrealm24a.gno b/gnovm/tests/files/zrealm_crossrealm24a.gno index 4f69450bde4..0177783a82f 100644 --- a/gnovm/tests/files/zrealm_crossrealm24a.gno +++ b/gnovm/tests/files/zrealm_crossrealm24a.gno @@ -2,7 +2,7 @@ package crossrealm_test import ( - crossrealm "gno.land/r/demo/tests/crossrealm" + crossrealm "gno.land/r/demo/tests/crossrealm/struct" ) var b0 *crossrealm.Bar = &crossrealm.Bar{A: 11} diff --git a/gnovm/tests/files/zrealm_crossrealm24b.gno b/gnovm/tests/files/zrealm_crossrealm24b.gno index 53eda7705c8..5fe246e439d 100644 --- a/gnovm/tests/files/zrealm_crossrealm24b.gno +++ b/gnovm/tests/files/zrealm_crossrealm24b.gno @@ -2,7 +2,7 @@ package crossrealm_test import ( - crossrealm "gno.land/r/demo/tests/crossrealm" + crossrealm "gno.land/r/demo/tests/crossrealm/struct" ) // TODO: diff --git a/gnovm/tests/files/zrealm_crossrealm24c.gno b/gnovm/tests/files/zrealm_crossrealm24c.gno index 1360003dade..eb6b3dcbf8a 100644 --- a/gnovm/tests/files/zrealm_crossrealm24c.gno +++ b/gnovm/tests/files/zrealm_crossrealm24c.gno @@ -3,7 +3,7 @@ package crossrealm_test import ( "fmt" - crossrealm "gno.land/r/demo/tests/crossrealm" + crossrealm "gno.land/r/demo/tests/crossrealm/struct" ) type Dt *crossrealm.Bar diff --git a/gnovm/tests/files/zrealm_crossrealm24d.gno b/gnovm/tests/files/zrealm_crossrealm24d.gno index 5c5df3ee123..43d40d5b7a1 100644 --- a/gnovm/tests/files/zrealm_crossrealm24d.gno +++ b/gnovm/tests/files/zrealm_crossrealm24d.gno @@ -2,7 +2,7 @@ package crossrealm_test import ( - crossrealm "gno.land/r/demo/tests/crossrealm" + crossrealm "gno.land/r/demo/tests/crossrealm/struct" ) type Ibar interface { @@ -25,13 +25,13 @@ func main() { } // Output: -// &(struct{(22 int)} gno.land/r/demo/tests/crossrealm.Bar) -// &(struct{(23 int)} gno.land/r/demo/tests/crossrealm.Bar) -// &(struct{(23 int)} gno.land/r/demo/tests/crossrealm.Bar) +// &(struct{(22 int)} gno.land/r/demo/tests/crossrealm/struct.Bar) +// &(struct{(23 int)} gno.land/r/demo/tests/crossrealm/struct.Bar) +// &(struct{(23 int)} gno.land/r/demo/tests/crossrealm/struct.Bar) // Realm: -// switchrealm["gno.land/r/demo/tests/crossrealm"] -// u[1712ac7adcfdc8e58a67e5615e20fb312394c4df:20]={ +// switchrealm["gno.land/r/demo/tests/crossrealm/struct"] +// u[5965ae851c02ab677bc8394b408535c1db9b2635:4]={ // "Fields": [ // { // "N": "FwAAAAAAAAA=", @@ -42,9 +42,9 @@ func main() { // } // ], // "ObjectInfo": { -// "ID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:20", -// "ModTime": "44", -// "OwnerID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:19", +// "ID": "5965ae851c02ab677bc8394b408535c1db9b2635:4", +// "ModTime": "10", +// "OwnerID": "5965ae851c02ab677bc8394b408535c1db9b2635:3", // "RefCount": "1" // } // } @@ -105,7 +105,7 @@ func main() { // "@type": "/gno.PointerType", // "Elt": { // "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Bar" +// "ID": "gno.land/r/demo/tests/crossrealm/struct.Bar" // } // }, // "V": { @@ -113,7 +113,7 @@ func main() { // "Base": { // "@type": "/gno.RefValue", // "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:19" +// "ObjectID": "5965ae851c02ab677bc8394b408535c1db9b2635:3" // }, // "Index": "0", // "TV": null @@ -124,7 +124,7 @@ func main() { // "@type": "/gno.PointerType", // "Elt": { // "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Bar" +// "ID": "gno.land/r/demo/tests/crossrealm/struct.Bar" // } // }, // "V": { @@ -132,7 +132,7 @@ func main() { // "Base": { // "@type": "/gno.RefValue", // "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:19" +// "ObjectID": "5965ae851c02ab677bc8394b408535c1db9b2635:3" // }, // "Index": "0", // "TV": null diff --git a/gnovm/tests/files/zrealm_crossrealm25.gno b/gnovm/tests/files/zrealm_crossrealm25.gno index 11a30a1a17e..4b856ac244f 100644 --- a/gnovm/tests/files/zrealm_crossrealm25.gno +++ b/gnovm/tests/files/zrealm_crossrealm25.gno @@ -4,7 +4,7 @@ package crossrealm_test import ( "std" - crossrealm "gno.land/r/demo/tests/crossrealm" + crossrealm "gno.land/r/demo/tests/crossrealm/iface" ) type fooer struct{ name string } diff --git a/gnovm/tests/files/zrealm_crossrealm25a.gno b/gnovm/tests/files/zrealm_crossrealm25a.gno index 6b8a25e6dd3..df9f6d157d2 100644 --- a/gnovm/tests/files/zrealm_crossrealm25a.gno +++ b/gnovm/tests/files/zrealm_crossrealm25a.gno @@ -4,7 +4,7 @@ package crossrealm_test import ( "std" - crossrealm "gno.land/r/demo/tests/crossrealm" + crossrealm "gno.land/r/demo/tests/crossrealm/iface" ) type fooer struct{} diff --git a/gnovm/tests/files/zrealm_crossrealm25b.gno b/gnovm/tests/files/zrealm_crossrealm25b.gno index b5744340648..166c811ee75 100644 --- a/gnovm/tests/files/zrealm_crossrealm25b.gno +++ b/gnovm/tests/files/zrealm_crossrealm25b.gno @@ -4,7 +4,7 @@ package crossrealm_test import ( "std" - crossrealm "gno.land/r/demo/tests/crossrealm" + crossrealm "gno.land/r/demo/tests/crossrealm/iface" ) type fooer struct { @@ -34,8 +34,8 @@ func main() { // . // Realm: -// switchrealm["gno.land/r/demo/tests/crossrealm"] -// u[1712ac7adcfdc8e58a67e5615e20fb312394c4df:8]={ +// switchrealm["gno.land/r/demo/tests/crossrealm/iface"] +// u[5836d1a3cec217737a5553d4c1a03d8897d5f281:4]={ // "Fields": [ // { // "T": { @@ -64,9 +64,9 @@ func main() { // } // ], // "ObjectInfo": { -// "ID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:8", -// "ModTime": "44", -// "OwnerID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:2", +// "ID": "5836d1a3cec217737a5553d4c1a03d8897d5f281:4", +// "ModTime": "4", +// "OwnerID": "5836d1a3cec217737a5553d4c1a03d8897d5f281:2", // "RefCount": "1" // } // } diff --git a/gnovm/tests/files/zrealm_crossrealm25c.gno b/gnovm/tests/files/zrealm_crossrealm25c.gno index b70dd3aa4ea..3ed3a1871ba 100644 --- a/gnovm/tests/files/zrealm_crossrealm25c.gno +++ b/gnovm/tests/files/zrealm_crossrealm25c.gno @@ -4,7 +4,7 @@ package crossrealm_test import ( "std" - crossrealm "gno.land/r/demo/tests/crossrealm" + crossrealm "gno.land/r/demo/tests/crossrealm/iface" ) type fooer struct { diff --git a/gnovm/tests/files/zrealm_crossrealm25d.gno b/gnovm/tests/files/zrealm_crossrealm25d.gno index fa05f3dfae5..8c2f1990d13 100644 --- a/gnovm/tests/files/zrealm_crossrealm25d.gno +++ b/gnovm/tests/files/zrealm_crossrealm25d.gno @@ -4,7 +4,7 @@ package crossrealm_test import ( "std" - crossrealm "gno.land/r/demo/tests/crossrealm" + crossrealm "gno.land/r/demo/tests/crossrealm/iface" ) type fooer struct { diff --git a/gnovm/tests/files/zrealm_crossrealm25e.gno b/gnovm/tests/files/zrealm_crossrealm25e.gno index ce9d137c378..7e0f8d29a2c 100644 --- a/gnovm/tests/files/zrealm_crossrealm25e.gno +++ b/gnovm/tests/files/zrealm_crossrealm25e.gno @@ -4,7 +4,7 @@ package crossrealm_test import ( "std" - crossrealm "gno.land/r/demo/tests/crossrealm" + crossrealm "gno.land/r/demo/tests/crossrealm/iface" ) type fooer struct { diff --git a/gnovm/tests/files/zrealm_crossrealm27.gno b/gnovm/tests/files/zrealm_crossrealm27.gno index fab4a6cc54b..c3c437ab04b 100644 --- a/gnovm/tests/files/zrealm_crossrealm27.gno +++ b/gnovm/tests/files/zrealm_crossrealm27.gno @@ -4,7 +4,7 @@ package crossrealm_test import ( "std" - crossrealm "gno.land/r/demo/tests/crossrealm" + crossrealm "gno.land/r/demo/tests/crossrealm/iface" ) type fooer struct { @@ -25,8 +25,8 @@ func main() { // . // Realm: -// switchrealm["gno.land/r/demo/tests/crossrealm"] -// u[1712ac7adcfdc8e58a67e5615e20fb312394c4df:8]={ +// switchrealm["gno.land/r/demo/tests/crossrealm/iface"] +// u[5836d1a3cec217737a5553d4c1a03d8897d5f281:4]={ // "Fields": [ // { // "T": { @@ -55,9 +55,9 @@ func main() { // } // ], // "ObjectInfo": { -// "ID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:8", -// "ModTime": "44", -// "OwnerID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:2", +// "ID": "5836d1a3cec217737a5553d4c1a03d8897d5f281:4", +// "ModTime": "4", +// "OwnerID": "5836d1a3cec217737a5553d4c1a03d8897d5f281:2", // "RefCount": "1" // } // } diff --git a/gnovm/tests/files/zrealm_crossrealm27a.gno b/gnovm/tests/files/zrealm_crossrealm27a.gno index cefcf319a88..a70d2b1fba4 100644 --- a/gnovm/tests/files/zrealm_crossrealm27a.gno +++ b/gnovm/tests/files/zrealm_crossrealm27a.gno @@ -4,7 +4,7 @@ package crossrealm_test import ( "std" - crossrealm "gno.land/r/demo/tests/crossrealm" + crossrealm "gno.land/r/demo/tests/crossrealm/iface" ) type fooer struct { diff --git a/gnovm/tests/files/zrealm_crossrealm28.gno b/gnovm/tests/files/zrealm_crossrealm28.gno index 87bc87813a2..ad69b0318be 100644 --- a/gnovm/tests/files/zrealm_crossrealm28.gno +++ b/gnovm/tests/files/zrealm_crossrealm28.gno @@ -4,7 +4,7 @@ package crossrealm_test import ( "std" - crossrealm "gno.land/r/demo/tests/crossrealm" + crossrealm "gno.land/r/demo/tests/crossrealm/iface" ) type foo struct { diff --git a/gnovm/tests/files/zrealm_crossrealm28b.gno b/gnovm/tests/files/zrealm_crossrealm28b.gno index ca89bb8ba3c..255d824ba77 100644 --- a/gnovm/tests/files/zrealm_crossrealm28b.gno +++ b/gnovm/tests/files/zrealm_crossrealm28b.gno @@ -4,7 +4,7 @@ package crossrealm_test import ( "std" - crossrealm "gno.land/r/demo/tests/crossrealm" + crossrealm "gno.land/r/demo/tests/crossrealm/iface" ) type foo struct { diff --git a/gnovm/tests/files/zrealm_crossrealm28c.gno b/gnovm/tests/files/zrealm_crossrealm28c.gno index 96f6fe746c4..7f2970d7a2b 100644 --- a/gnovm/tests/files/zrealm_crossrealm28c.gno +++ b/gnovm/tests/files/zrealm_crossrealm28c.gno @@ -4,7 +4,7 @@ package crossrealm_test import ( "std" - crossrealm "gno.land/r/demo/tests/crossrealm" + crossrealm "gno.land/r/demo/tests/crossrealm/slice" ) type foo struct { diff --git a/gnovm/tests/files/zrealm_crossrealm29.gno b/gnovm/tests/files/zrealm_crossrealm29.gno index 2ca67b09cd1..6c7ed5e073d 100644 --- a/gnovm/tests/files/zrealm_crossrealm29.gno +++ b/gnovm/tests/files/zrealm_crossrealm29.gno @@ -4,7 +4,7 @@ package crossrealm_test import ( "std" - crossrealm "gno.land/r/demo/tests/crossrealm" + crossrealm "gno.land/r/demo/tests/crossrealm/func" ) func main() { diff --git a/gnovm/tests/files/zrealm_crossrealm29a.gno b/gnovm/tests/files/zrealm_crossrealm29a.gno index aaeda22503e..3303a5dde9a 100644 --- a/gnovm/tests/files/zrealm_crossrealm29a.gno +++ b/gnovm/tests/files/zrealm_crossrealm29a.gno @@ -4,7 +4,7 @@ package crossrealm_test import ( "std" - crossrealm "gno.land/r/demo/tests/crossrealm" + crossrealm "gno.land/r/demo/tests/crossrealm/func" ) var f = func() bool { diff --git a/gnovm/tests/files/zrealm_crossrealm29b.gno b/gnovm/tests/files/zrealm_crossrealm29b.gno index c0e00f79852..9425782cd1b 100644 --- a/gnovm/tests/files/zrealm_crossrealm29b.gno +++ b/gnovm/tests/files/zrealm_crossrealm29b.gno @@ -4,7 +4,7 @@ package crossrealm_test import ( "std" - crossrealm "gno.land/r/demo/tests/crossrealm" + crossrealm "gno.land/r/demo/tests/crossrealm/func" ) func main() { diff --git a/gnovm/tests/files/zrealm_crossrealm30.gno b/gnovm/tests/files/zrealm_crossrealm30.gno index cac8dd6cd8e..1c797a882cf 100644 --- a/gnovm/tests/files/zrealm_crossrealm30.gno +++ b/gnovm/tests/files/zrealm_crossrealm30.gno @@ -4,7 +4,7 @@ package crossrealm_test import ( "std" - crossrealm "gno.land/r/demo/tests/crossrealm" + crossrealm "gno.land/r/demo/tests/crossrealm/slice" ) var SS []crossrealm.XYZ diff --git a/gnovm/tests/files/zrealm_crossrealm31.gno b/gnovm/tests/files/zrealm_crossrealm31.gno index 70d62fe320b..dc00b5204fe 100644 --- a/gnovm/tests/files/zrealm_crossrealm31.gno +++ b/gnovm/tests/files/zrealm_crossrealm31.gno @@ -4,7 +4,7 @@ package crossrealm_test import ( "std" - crossrealm "gno.land/r/demo/tests/crossrealm" + crossrealm "gno.land/r/demo/tests/crossrealm/slice" ) var SS []crossrealm.XYZ diff --git a/gnovm/tests/files/zrealm_crossrealm32.gno b/gnovm/tests/files/zrealm_crossrealm32.gno index a9f196ed62b..e8ec8b0e2a7 100644 --- a/gnovm/tests/files/zrealm_crossrealm32.gno +++ b/gnovm/tests/files/zrealm_crossrealm32.gno @@ -4,7 +4,7 @@ package crossrealm_test import ( "std" - crossrealm "gno.land/r/demo/tests/crossrealm" + crossrealm "gno.land/r/demo/tests/crossrealm/slice" ) var SS []crossrealm.XYZ @@ -18,8 +18,8 @@ func main() { // . // Realm: -// switchrealm["gno.land/r/demo/tests/crossrealm"] -// c[1712ac7adcfdc8e58a67e5615e20fb312394c4df:46]={ +// switchrealm["gno.land/r/demo/tests/crossrealm/slice"] +// c[ff34c6500d0daee58e4ac9899c0e7ecc131db63e:25]={ // "Fields": [ // { // "T": { @@ -33,52 +33,52 @@ func main() { // } // ], // "ObjectInfo": { -// "ID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:46", +// "ID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:25", // "ModTime": "0", -// "OwnerID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:45", +// "OwnerID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:24", // "RefCount": "1" // } // } -// c[1712ac7adcfdc8e58a67e5615e20fb312394c4df:45]={ +// c[ff34c6500d0daee58e4ac9899c0e7ecc131db63e:24]={ // "Data": null, // "List": [ // { // "T": { // "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" // }, // "V": { // "@type": "/gno.RefValue", // "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:32" +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:14" // } // }, // { // "T": { // "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" // }, // "V": { // "@type": "/gno.RefValue", -// "Hash": "2489b816b7c9cfcc07f7e853718aaa019016fced", -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:46" +// "Hash": "d0a7406378470009aced840189d7ac80419e2b2b", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:25" // } // } // ], // "ObjectInfo": { -// "ID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:45", +// "ID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:24", // "ModTime": "0", -// "OwnerID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:2", +// "OwnerID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:2", // "RefCount": "1" // } // } -// u[1712ac7adcfdc8e58a67e5615e20fb312394c4df:2]={ +// u[ff34c6500d0daee58e4ac9899c0e7ecc131db63e:2]={ // "Blank": {}, // "ObjectInfo": { -// "ID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:2", +// "ID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:2", // "IsEscaped": true, -// "ModTime": "44", -// "RefCount": "10" +// "ModTime": "23", +// "RefCount": "2" // }, // "Parent": null, // "Source": { @@ -88,7 +88,7 @@ func main() { // "Column": "0", // "File": "", // "Line": "0", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, // "Values": [ @@ -101,30 +101,36 @@ func main() { // "Type": { // "@type": "/gno.DeclaredType", // "Base": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ +// "@type": "/gno.InterfaceType", +// "Generic": "", +// "Methods": [ // { // "Embedded": false, -// "Name": "", +// "Name": "Foo", // "Tag": "", // "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "4" +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] // } // } -// ] +// ], +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // }, // "Methods": [], -// "Name": "F", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// "Name": "Fooer", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // } // }, // { // "T": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.F" +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm/slice.Fooer" +// }, +// "Vrd": false // } // }, // { @@ -133,11 +139,15 @@ func main() { // "Params": [ // { // "Embedded": false, -// "Name": "ff", +// "Name": "fs", // "Tag": "", // "Type": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.F" +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm/slice.Fooer" +// }, +// "Vrd": false // } // } // ], @@ -148,22 +158,22 @@ func main() { // "Closure": { // "@type": "/gno.RefValue", // "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:3" +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:3" // }, -// "FileName": "crossrealm_func.gno", +// "FileName": "crossrealm_slice.gno", // "IsMethod": false, -// "Name": "SetCallback", +// "Name": "SetSlice", // "NativeName": "", // "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice", // "Source": { // "@type": "/gno.RefNode", // "BlockNode": null, // "Location": { // "Column": "1", -// "File": "crossrealm_func.gno", +// "File": "crossrealm_slice.gno", // "Line": "7", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, // "Type": { @@ -171,11 +181,15 @@ func main() { // "Params": [ // { // "Embedded": false, -// "Name": "ff", +// "Name": "fs", // "Tag": "", // "Type": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.F" +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm/slice.Fooer" +// }, +// "Vrd": false // } // } // ], @@ -185,6 +199,162 @@ func main() { // }, // { // "T": { +// "@type": "/gno.TypeType" +// }, +// "V": { +// "@type": "/gno.TypeValue", +// "Type": { +// "@type": "/gno.DeclaredType", +// "Base": { +// "@type": "/gno.StructType", +// "Fields": [ +// { +// "Embedded": false, +// "Name": "name", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// } +// ], +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" +// }, +// "Methods": [], +// "Name": "XYZ", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" +// }, +// "Vrd": false +// }, +// "V": { +// "@type": "/gno.SliceValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Hash": "1b66d81a105bccbb2c1cb48b5826de001451c4f4", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:10" +// }, +// "Length": "2", +// "Maxcap": "2", +// "Offset": "0" +// } +// }, +// { +// "T": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" +// }, +// "Vrd": false +// }, +// "V": { +// "@type": "/gno.SliceValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Hash": "4e2c5feb184ed4c3756c8662f4849b05e55b510a", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:24" +// }, +// "Length": "2", +// "Maxcap": "2", +// "Offset": "0" +// } +// }, +// { +// "T": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" +// }, +// "Vrd": false +// }, +// "V": { +// "@type": "/gno.SliceValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Hash": "f6278e80ac84fd1944704d0ab55f4ba1b01e76f1", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:15" +// }, +// "Length": "1", +// "Maxcap": "1", +// "Offset": "0" +// } +// }, +// { +// "T": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" +// } +// }, +// "Vrd": false +// }, +// "V": { +// "@type": "/gno.SliceValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Hash": "875dcfc247f2beb0db7a9556971202d5f83953a7", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:17" +// }, +// "Length": "1", +// "Maxcap": "1", +// "Offset": "0" +// } +// }, +// { +// "T": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" +// } +// }, +// "Vrd": false +// }, +// "V": { +// "@type": "/gno.SliceValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Hash": "df881fbce43e93be6a59fa06c45b5b9959c2d597", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:4" +// }, +// "Length": "2", +// "Maxcap": "2", +// "Offset": "0" +// } +// }, +// { +// "T": { +// "@type": "/gno.ArrayType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" +// }, +// "Len": "2", +// "Vrd": false +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "719153550186d4f8347763b1c1ffcbb9b62a967f", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:5" +// } +// }, +// { +// "T": { // "@type": "/gno.FuncType", // "Params": [], // "Results": [] @@ -194,22 +364,22 @@ func main() { // "Closure": { // "@type": "/gno.RefValue", // "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:3" +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:3" // }, -// "FileName": "crossrealm_func.gno", +// "FileName": "crossrealm_slice.gno", // "IsMethod": false, -// "Name": "ExecuteCallback", +// "Name": "init.10", // "NativeName": "", // "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice", // "Source": { // "@type": "/gno.RefNode", // "BlockNode": null, // "Location": { // "Column": "1", -// "File": "crossrealm_func.gno", -// "Line": "11", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// "File": "crossrealm_slice.gno", +// "Line": "25", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, // "Type": { @@ -229,8 +399,12 @@ func main() { // "Name": "", // "Tag": "", // "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "16" +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" +// }, +// "Vrd": false // } // } // ] @@ -240,22 +414,22 @@ func main() { // "Closure": { // "@type": "/gno.RefValue", // "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:4" +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:3" // }, -// "FileName": "", +// "FileName": "crossrealm_slice.gno", // "IsMethod": false, -// "Name": "", +// "Name": "GetSlice", // "NativeName": "", // "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice", // "Source": { // "@type": "/gno.RefNode", // "BlockNode": null, // "Location": { -// "Column": "10", -// "File": "crossrealm_func2.gno", -// "Line": "3", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// "Column": "1", +// "File": "crossrealm_slice.gno", +// "Line": "40", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, // "Type": { @@ -267,8 +441,12 @@ func main() { // "Name": "", // "Tag": "", // "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "16" +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" +// }, +// "Vrd": false // } // } // ] @@ -277,6 +455,28 @@ func main() { // }, // { // "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "d10003fa5a9ebd5bb30cadd5e11bd5aad76ec9f4", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:8" +// } +// }, +// { +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "8a2889ef5ccf6c7e4ec0c59ed627267fa3a51026", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:9" +// } +// }, +// { +// "T": { // "@type": "/gno.FuncType", // "Params": [], // "Results": [ @@ -285,19 +485,12 @@ func main() { // "Name": "", // "Tag": "", // "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// } -// } -// ] +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" +// }, +// "Vrd": false // } // } // ] @@ -307,22 +500,22 @@ func main() { // "Closure": { // "@type": "/gno.RefValue", // "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:4" +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:3" // }, -// "FileName": "crossrealm_func2.gno", +// "FileName": "crossrealm_slice.gno", // "IsMethod": false, -// "Name": "GetFunc", +// "Name": "GetSlice2", // "NativeName": "", // "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice", // "Source": { // "@type": "/gno.RefNode", // "BlockNode": null, // "Location": { // "Column": "1", -// "File": "crossrealm_func2.gno", -// "Line": "8", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// "File": "crossrealm_slice.gno", +// "Line": "48", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, // "Type": { @@ -334,19 +527,12 @@ func main() { // "Name": "", // "Tag": "", // "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// } -// } -// ] +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" +// }, +// "Vrd": false // } // } // ] @@ -363,19 +549,12 @@ func main() { // "Name": "", // "Tag": "", // "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// } -// } -// ] +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" +// }, +// "Vrd": false // } // } // ] @@ -385,22 +564,22 @@ func main() { // "Closure": { // "@type": "/gno.RefValue", // "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:4" +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:3" // }, -// "FileName": "crossrealm_func2.gno", +// "FileName": "crossrealm_slice.gno", // "IsMethod": false, -// "Name": "GetFunc2", +// "Name": "GetSlice3", // "NativeName": "", // "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice", // "Source": { // "@type": "/gno.RefNode", // "BlockNode": null, // "Location": { // "Column": "1", -// "File": "crossrealm_func2.gno", -// "Line": "12", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// "File": "crossrealm_slice.gno", +// "Line": "56", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, // "Type": { @@ -412,19 +591,12 @@ func main() { // "Name": "", // "Tag": "", // "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// } -// } -// ] +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" +// }, +// "Vrd": false // } // } // ] @@ -433,119 +605,88 @@ func main() { // }, // { // "T": { -// "@type": "/gno.TypeType" +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "s", +// "Tag": "", +// "Type": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" +// }, +// "Vrd": false +// } +// } +// ], +// "Results": [] +// } +// } +// ], +// "Results": [] // }, // "V": { -// "@type": "/gno.TypeValue", +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:3" +// }, +// "FileName": "crossrealm_slice.gno", +// "IsMethod": false, +// "Name": "GetSlice4", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_slice.gno", +// "Line": "61", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" +// } +// }, // "Type": { -// "@type": "/gno.DeclaredType", -// "Base": { -// "@type": "/gno.StructType", -// "Fields": [], -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// }, -// "Methods": [ +// "@type": "/gno.FuncType", +// "Params": [ // { -// "T": { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { // "@type": "/gno.FuncType", // "Params": [ // { // "Embedded": false, -// "Name": "sv", +// "Name": "s", // "Tag": "", // "Type": { -// "@type": "/gno.PointerType", +// "@type": "/gno.SliceType", // "Elt": { // "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.MyStruct" -// } +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" +// }, +// "Vrd": false // } // } // ], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// } -// } -// ] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": null, -// "FileName": "crossrealm_func2.gno", -// "IsMethod": true, -// "Name": "M", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_func2.gno", -// "Line": "20", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "sv", -// "Tag": "", -// "Type": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.MyStruct" -// } -// } -// } -// ], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// } -// } -// ] -// } +// "Results": [] // } // } // ], -// "Name": "MyStruct", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.MyStruct" +// "Results": [] // } -// }, -// "V": { -// "@type": "/gno.PointerValue", -// "Base": { -// "@type": "/gno.RefValue", -// "Hash": "66606f1f6d50797bbe89640247170078dcbf0e6a", -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:5" -// }, -// "Index": "0", -// "TV": null // } // }, // { @@ -558,19 +699,15 @@ func main() { // "Name": "", // "Tag": "", // "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// } +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" // } -// ] +// }, +// "Vrd": false // } // } // ] @@ -580,22 +717,22 @@ func main() { // "Closure": { // "@type": "/gno.RefValue", // "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:4" +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:3" // }, -// "FileName": "crossrealm_func2.gno", +// "FileName": "crossrealm_slice.gno", // "IsMethod": false, -// "Name": "GetMethod", +// "Name": "GetSlice5", // "NativeName": "", // "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice", // "Source": { // "@type": "/gno.RefNode", // "BlockNode": null, // "Location": { // "Column": "1", -// "File": "crossrealm_func2.gno", -// "Line": "30", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// "File": "crossrealm_slice.gno", +// "Line": "66", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, // "Type": { @@ -607,19 +744,15 @@ func main() { // "Name": "", // "Tag": "", // "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// } +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" // } -// ] +// }, +// "Vrd": false // } // } // ] @@ -628,43 +761,6 @@ func main() { // }, // { // "T": { -// "@type": "/gno.TypeType" -// }, -// "V": { -// "@type": "/gno.TypeValue", -// "Type": { -// "@type": "/gno.DeclaredType", -// "Base": { -// "@type": "/gno.InterfaceType", -// "Generic": "", -// "Methods": [ -// { -// "Embedded": false, -// "Name": "Foo", -// "Tag": "", -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// } -// } -// ], -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// }, -// "Methods": [], -// "Name": "Fooer", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" -// } -// }, -// { -// "T": { // "@type": "/gno.FuncType", // "Params": [ // { @@ -672,44 +768,52 @@ func main() { // "Name": "f", // "Tag": "", // "Type": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "s", +// "Tag": "", +// "Type": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" +// } +// }, +// "Vrd": false +// } +// } +// ], +// "Results": [] // } // } // ], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" -// } -// } -// ] +// "Results": [] // }, // "V": { // "@type": "/gno.FuncValue", // "Closure": { // "@type": "/gno.RefValue", // "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:7" +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:3" // }, -// "FileName": "crossrealm_iface.gno", +// "FileName": "crossrealm_slice.gno", // "IsMethod": false, -// "Name": "SetFooer", +// "Name": "GetSlice6", // "NativeName": "", // "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice", // "Source": { // "@type": "/gno.RefNode", // "BlockNode": null, // "Location": { // "Column": "1", -// "File": "crossrealm_iface.gno", -// "Line": "8", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// "File": "crossrealm_slice.gno", +// "Line": "70", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, // "Type": { @@ -720,29 +824,63 @@ func main() { // "Name": "f", // "Tag": "", // "Type": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "s", +// "Tag": "", +// "Type": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" +// } +// }, +// "Vrd": false +// } +// } +// ], +// "Results": [] // } // } // ], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" -// } -// } -// ] +// "Results": [] // } // } // }, // { // "T": { // "@type": "/gno.FuncType", -// "Params": [], +// "Params": [ +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "s", +// "Tag": "", +// "Type": { +// "@type": "/gno.ArrayType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" +// }, +// "Len": "2", +// "Vrd": false +// } +// } +// ], +// "Results": [] +// } +// } +// ], // "Results": [] // }, // "V": { @@ -750,94 +888,107 @@ func main() { // "Closure": { // "@type": "/gno.RefValue", // "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:7" +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:3" // }, -// "FileName": "crossrealm_iface.gno", +// "FileName": "crossrealm_slice.gno", // "IsMethod": false, -// "Name": "CallFoo", +// "Name": "GetSlice7", // "NativeName": "", // "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice", // "Source": { // "@type": "/gno.RefNode", // "BlockNode": null, // "Location": { // "Column": "1", -// "File": "crossrealm_iface.gno", -// "Line": "13", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// "File": "crossrealm_slice.gno", +// "Line": "75", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, // "Type": { // "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.TypeType" -// }, -// "V": { -// "@type": "/gno.TypeValue", -// "Type": { -// "@type": "/gno.DeclaredType", -// "Base": { -// "@type": "/gno.StructType", -// "Fields": [ -// { -// "Embedded": false, -// "Name": "name", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// } -// }, -// { -// "Embedded": false, -// "Name": "f", -// "Tag": "", -// "Type": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" -// } +// "Params": [ +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "s", +// "Tag": "", +// "Type": { +// "@type": "/gno.ArrayType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" +// }, +// "Len": "2", +// "Vrd": false +// } +// } +// ], +// "Results": [] // } -// ], -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// }, -// "Methods": [], -// "Name": "Container", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// ], +// "Results": [] // } // } -// }, +// } +// ] +// } +// d[ff34c6500d0daee58e4ac9899c0e7ecc131db63e:13] +// d[ff34c6500d0daee58e4ac9899c0e7ecc131db63e:14] +// switchrealm["gno.land/r/crossrealm_test"] +// u[f5a516808f8976c33939133293d598ce3bca4e8d:2]={ +// "Blank": {}, +// "ObjectInfo": { +// "ID": "f5a516808f8976c33939133293d598ce3bca4e8d:2", +// "IsEscaped": true, +// "ModTime": "3", +// "RefCount": "2" +// }, +// "Parent": null, +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "0", +// "File": "", +// "Line": "0", +// "PkgPath": "gno.land/r/crossrealm_test" +// } +// }, +// "Values": [ // { // "T": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Container" +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" +// }, +// "Vrd": false // }, // "V": { -// "@type": "/gno.RefValue", -// "Hash": "a7562372e10ade1d106ae5ef9e97c170ee4b50f1", -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:8" +// "@type": "/gno.SliceValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:24" +// }, +// "Length": "2", +// "Maxcap": "2", +// "Offset": "0" // } // }, // { // "T": { // "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "f", -// "Tag": "", -// "Type": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" -// } -// } -// ], +// "Params": [], // "Results": [] // }, // "V": { @@ -845,40 +996,93 @@ func main() { // "Closure": { // "@type": "/gno.RefValue", // "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:7" +// "ObjectID": "f5a516808f8976c33939133293d598ce3bca4e8d:3" // }, -// "FileName": "crossrealm_iface.gno", +// "FileName": "main.gno", // "IsMethod": false, -// "Name": "SetContainer", +// "Name": "main", // "NativeName": "", // "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "PkgPath": "gno.land/r/crossrealm_test", // "Source": { // "@type": "/gno.RefNode", // "BlockNode": null, // "Location": { // "Column": "1", -// "File": "crossrealm_iface.gno", -// "Line": "23", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// "File": "main.gno", +// "Line": "12", +// "PkgPath": "gno.land/r/crossrealm_test" // } // }, // "Type": { // "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "f", -// "Tag": "", -// "Type": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" -// } -// } -// ], +// "Params": [], // "Results": [] // } // } +// } +// ] +// } +// u[ff34c6500d0daee58e4ac9899c0e7ecc131db63e:2]={ +// "Blank": {}, +// "ObjectInfo": { +// "ID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:2", +// "IsEscaped": true, +// "ModTime": "3", +// "RefCount": "2" +// }, +// "Parent": null, +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "0", +// "File": "", +// "Line": "0", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" +// } +// }, +// "Values": [ +// { +// "T": { +// "@type": "/gno.TypeType" +// }, +// "V": { +// "@type": "/gno.TypeValue", +// "Type": { +// "@type": "/gno.DeclaredType", +// "Base": { +// "@type": "/gno.InterfaceType", +// "Generic": "", +// "Methods": [ +// { +// "Embedded": false, +// "Name": "Foo", +// "Tag": "", +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// } +// } +// ], +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" +// }, +// "Methods": [], +// "Name": "Fooer", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm/slice.Fooer" +// }, +// "Vrd": false +// } // }, // { // "T": { @@ -886,11 +1090,15 @@ func main() { // "Params": [ // { // "Embedded": false, -// "Name": "f", +// "Name": "fs", // "Tag": "", // "Type": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm/slice.Fooer" +// }, +// "Vrd": false // } // } // ], @@ -901,22 +1109,22 @@ func main() { // "Closure": { // "@type": "/gno.RefValue", // "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:7" +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:3" // }, -// "FileName": "crossrealm_iface.gno", +// "FileName": "crossrealm_slice.gno", // "IsMethod": false, -// "Name": "SetContainer2", +// "Name": "SetSlice", // "NativeName": "", // "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice", // "Source": { // "@type": "/gno.RefNode", // "BlockNode": null, // "Location": { // "Column": "1", -// "File": "crossrealm_iface.gno", -// "Line": "27", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// "File": "crossrealm_slice.gno", +// "Line": "7", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, // "Type": { @@ -924,11 +1132,15 @@ func main() { // "Params": [ // { // "Embedded": false, -// "Name": "f", +// "Name": "fs", // "Tag": "", // "Type": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm/slice.Fooer" +// }, +// "Vrd": false // } // } // ], @@ -938,253 +1150,158 @@ func main() { // }, // { // "T": { -// "@type": "/gno.MapType", -// "Key": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// }, -// "Value": { -// "@type": "/gno.PrimitiveType", -// "value": "32" -// } +// "@type": "/gno.TypeType" // }, // "V": { -// "@type": "/gno.RefValue", -// "Hash": "cda4bc373a1cceedd07fe9fd29410bfd5732df7c", -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:25" +// "@type": "/gno.TypeValue", +// "Type": { +// "@type": "/gno.DeclaredType", +// "Base": { +// "@type": "/gno.StructType", +// "Fields": [ +// { +// "Embedded": false, +// "Name": "name", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// } +// ], +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" +// }, +// "Methods": [], +// "Name": "XYZ", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" +// } // } // }, // { // "T": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" +// }, +// "Vrd": false // }, // "V": { -// "@type": "/gno.FuncValue", -// "Closure": { +// "@type": "/gno.SliceValue", +// "Base": { // "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:9" -// }, -// "FileName": "crossrealm_map.gno", -// "IsMethod": false, -// "Name": "init.19", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_map.gno", -// "Line": "5", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } +// "Hash": "1b66d81a105bccbb2c1cb48b5826de001451c4f4", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:10" // }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// } +// "Length": "2", +// "Maxcap": "2", +// "Offset": "0" // } // }, // { // "T": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.MapType", -// "Key": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// }, -// "Value": { -// "@type": "/gno.PrimitiveType", -// "value": "32" -// } -// } -// } -// ] +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" +// }, +// "Vrd": false // }, // "V": { -// "@type": "/gno.FuncValue", -// "Closure": { +// "@type": "/gno.SliceValue", +// "Base": { // "@type": "/gno.RefValue", // "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:9" +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:24" // }, -// "FileName": "crossrealm_map.gno", -// "IsMethod": false, -// "Name": "GetMap", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_map.gno", -// "Line": "10", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } +// "Length": "2", +// "Maxcap": "2", +// "Offset": "0" +// } +// }, +// { +// "T": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" // }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.MapType", -// "Key": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// }, -// "Value": { -// "@type": "/gno.PrimitiveType", -// "value": "32" -// } -// } -// } -// ] -// } +// "Vrd": false +// }, +// "V": { +// "@type": "/gno.SliceValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Hash": "f6278e80ac84fd1944704d0ab55f4ba1b01e76f1", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:15" +// }, +// "Length": "1", +// "Maxcap": "1", +// "Offset": "0" // } // }, // { // "T": { -// "@type": "/gno.TypeType" +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" +// } +// }, +// "Vrd": false // }, // "V": { -// "@type": "/gno.TypeValue", -// "Type": { -// "@type": "/gno.DeclaredType", -// "Base": { -// "@type": "/gno.StructType", -// "Fields": [ -// { -// "Embedded": false, -// "Name": "A", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "32" -// } -// } -// ], -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// }, -// "Methods": [ -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "ls", -// "Tag": "", -// "Type": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.LocalStruct" -// } -// } -// } -// ], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// } -// } -// ] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": null, -// "FileName": "crossrealm_p.gno", -// "IsMethod": true, -// "Name": "String", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_p.gno", -// "Line": "12", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "ls", -// "Tag": "", -// "Type": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.LocalStruct" -// } -// } -// } -// ], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// } -// } -// ] -// } -// } -// } -// ], -// "Name": "LocalStruct", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } +// "@type": "/gno.SliceValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Hash": "875dcfc247f2beb0db7a9556971202d5f83953a7", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:17" +// }, +// "Length": "1", +// "Maxcap": "1", +// "Offset": "0" // } // }, // { // "T": { -// "@type": "/gno.PointerType", +// "@type": "/gno.SliceType", // "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.LocalStruct" -// } +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" +// } +// }, +// "Vrd": false // }, // "V": { -// "@type": "/gno.PointerValue", +// "@type": "/gno.SliceValue", // "Base": { // "@type": "/gno.RefValue", -// "Hash": "921bae5520c2c8b9d456b47651ea80481836de4e", -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:26" +// "Hash": "df881fbce43e93be6a59fa06c45b5b9959c2d597", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:4" +// }, +// "Length": "2", +// "Maxcap": "2", +// "Offset": "0" +// } +// }, +// { +// "T": { +// "@type": "/gno.ArrayType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" // }, -// "Index": "0", -// "TV": null +// "Len": "2", +// "Vrd": false +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "719153550186d4f8347763b1c1ffcbb9b62a967f", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:5" // } // }, // { @@ -1198,22 +1315,22 @@ func main() { // "Closure": { // "@type": "/gno.RefValue", // "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:10" +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:3" // }, -// "FileName": "crossrealm_p.gno", +// "FileName": "crossrealm_slice.gno", // "IsMethod": false, -// "Name": "init.23", +// "Name": "init.10", // "NativeName": "", // "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice", // "Source": { // "@type": "/gno.RefNode", // "BlockNode": null, // "Location": { // "Column": "1", -// "File": "crossrealm_p.gno", -// "Line": "19", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// "File": "crossrealm_slice.gno", +// "Line": "25", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, // "Type": { @@ -1233,11 +1350,12 @@ func main() { // "Name": "", // "Tag": "", // "Type": { -// "@type": "/gno.PointerType", +// "@type": "/gno.SliceType", // "Elt": { // "@type": "/gno.RefType", -// "ID": "gno.land/p/demo/tests/p_crossrealm.Container" -// } +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" +// }, +// "Vrd": false // } // } // ] @@ -1247,22 +1365,22 @@ func main() { // "Closure": { // "@type": "/gno.RefValue", // "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:10" +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:3" // }, -// "FileName": "crossrealm_p.gno", +// "FileName": "crossrealm_slice.gno", // "IsMethod": false, -// "Name": "Make1", +// "Name": "GetSlice", // "NativeName": "", // "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice", // "Source": { // "@type": "/gno.RefNode", // "BlockNode": null, // "Location": { // "Column": "1", -// "File": "crossrealm_p.gno", -// "Line": "24", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// "File": "crossrealm_slice.gno", +// "Line": "40", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, // "Type": { @@ -1274,11 +1392,12 @@ func main() { // "Name": "", // "Tag": "", // "Type": { -// "@type": "/gno.PointerType", +// "@type": "/gno.SliceType", // "Elt": { // "@type": "/gno.RefType", -// "ID": "gno.land/p/demo/tests/p_crossrealm.Container" -// } +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" +// }, +// "Vrd": false // } // } // ] @@ -1287,313 +1406,133 @@ func main() { // }, // { // "T": { -// "@type": "/gno.SliceType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" -// }, -// "Vrd": false +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "d10003fa5a9ebd5bb30cadd5e11bd5aad76ec9f4", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:8" +// } +// }, +// { +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "8a2889ef5ccf6c7e4ec0c59ed627267fa3a51026", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:9" // } // }, // { // "T": { // "@type": "/gno.FuncType", -// "Params": [ +// "Params": [], +// "Results": [ // { // "Embedded": false, -// "Name": "fs", +// "Name": "", // "Tag": "", // "Type": { // "@type": "/gno.SliceType", // "Elt": { // "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" // }, // "Vrd": false // } // } -// ], -// "Results": [] +// ] // }, // "V": { // "@type": "/gno.FuncValue", // "Closure": { // "@type": "/gno.RefValue", // "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:11" +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:3" // }, // "FileName": "crossrealm_slice.gno", // "IsMethod": false, -// "Name": "SetSlice", +// "Name": "GetSlice2", // "NativeName": "", // "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice", // "Source": { // "@type": "/gno.RefNode", // "BlockNode": null, // "Location": { // "Column": "1", // "File": "crossrealm_slice.gno", -// "Line": "5", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// "Line": "48", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, // "Type": { // "@type": "/gno.FuncType", -// "Params": [ +// "Params": [], +// "Results": [ // { // "Embedded": false, -// "Name": "fs", +// "Name": "", // "Tag": "", // "Type": { // "@type": "/gno.SliceType", // "Elt": { // "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" // }, // "Vrd": false // } // } -// ], -// "Results": [] +// ] // } // } // }, // { // "T": { -// "@type": "/gno.TypeType" +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" +// }, +// "Vrd": false +// } +// } +// ] // }, // "V": { -// "@type": "/gno.TypeValue", -// "Type": { -// "@type": "/gno.DeclaredType", -// "Base": { -// "@type": "/gno.StructType", -// "Fields": [ -// { -// "Embedded": false, -// "Name": "name", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// } -// } -// ], -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// }, -// "Methods": [], -// "Name": "XYZ", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.SliceType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" -// }, -// "Vrd": false -// }, -// "V": { -// "@type": "/gno.SliceValue", -// "Base": { -// "@type": "/gno.RefValue", -// "Hash": "b3b42c06d65da2199792616887b55d65b79f075e", -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:28" -// }, -// "Length": "2", -// "Maxcap": "2", -// "Offset": "0" -// } -// }, -// { -// "T": { -// "@type": "/gno.SliceType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" -// }, -// "Vrd": false -// }, -// "V": { -// "@type": "/gno.SliceValue", -// "Base": { -// "@type": "/gno.RefValue", -// "Hash": "fa5658dcf95bafce7154d3380ebf7e9211b4ab4d", -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:45" -// }, -// "Length": "2", -// "Maxcap": "2", -// "Offset": "0" -// } -// }, -// { -// "T": { -// "@type": "/gno.SliceType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" -// }, -// "Vrd": false -// }, -// "V": { -// "@type": "/gno.SliceValue", -// "Base": { -// "@type": "/gno.RefValue", -// "Hash": "7c8932f1337c257a3236c79d7d8b4211812d8385", -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:33" -// }, -// "Length": "1", -// "Maxcap": "1", -// "Offset": "0" -// } -// }, -// { -// "T": { -// "@type": "/gno.SliceType", -// "Elt": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" -// } -// }, -// "Vrd": false -// }, -// "V": { -// "@type": "/gno.SliceValue", -// "Base": { -// "@type": "/gno.RefValue", -// "Hash": "dbf56198a94f3a1d98c501d1b8c58b88bfbe8bce", -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:35" -// }, -// "Length": "1", -// "Maxcap": "1", -// "Offset": "0" -// } -// }, -// { -// "T": { -// "@type": "/gno.SliceType", -// "Elt": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" -// } -// }, -// "Vrd": false -// }, -// "V": { -// "@type": "/gno.SliceValue", -// "Base": { -// "@type": "/gno.RefValue", -// "Hash": "8f5471d881fd68800170d03c52907ce7a7607d09", -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:12" -// }, -// "Length": "2", -// "Maxcap": "2", -// "Offset": "0" -// } -// }, -// { -// "T": { -// "@type": "/gno.ArrayType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" -// }, -// "Len": "2", -// "Vrd": false -// }, -// "V": { -// "@type": "/gno.RefValue", -// "Hash": "41d4fd3b5431d4cd8494803a01f437bddd45b521", -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:13" -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:16" -// }, -// "FileName": "crossrealm_slice2.gno", -// "IsMethod": false, -// "Name": "init.34", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_slice2.gno", -// "Line": "13", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.SliceType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" -// }, -// "Vrd": false -// } -// } -// ] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:16" -// }, -// "FileName": "crossrealm_slice2.gno", -// "IsMethod": false, -// "Name": "GetSlice", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_slice2.gno", -// "Line": "28", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:3" +// }, +// "FileName": "crossrealm_slice.gno", +// "IsMethod": false, +// "Name": "GetSlice3", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_slice.gno", +// "Line": "56", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" +// } +// }, // "Type": { // "@type": "/gno.FuncType", // "Params": [], @@ -1606,3710 +1545,203 @@ func main() { // "@type": "/gno.SliceType", // "Elt": { // "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" // }, -// "Vrd": false -// } -// } -// ] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" -// }, -// "V": { -// "@type": "/gno.RefValue", -// "Hash": "b439d9527c852f481b3dcc9c4ad27fcf6b2cbc6e", -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:17" -// } -// }, -// { -// "T": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" -// }, -// "V": { -// "@type": "/gno.RefValue", -// "Hash": "c3a08360b77971b3c8a35a4c9c0955f6336760c4", -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:18" -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.SliceType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" -// }, -// "Vrd": false -// } -// } -// ] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:16" -// }, -// "FileName": "crossrealm_slice2.gno", -// "IsMethod": false, -// "Name": "GetSlice2", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_slice2.gno", -// "Line": "36", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.SliceType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" -// }, -// "Vrd": false -// } -// } -// ] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.SliceType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" -// }, -// "Vrd": false -// } -// } -// ] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:16" -// }, -// "FileName": "crossrealm_slice2.gno", -// "IsMethod": false, -// "Name": "GetSlice3", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_slice2.gno", -// "Line": "44", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.SliceType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" -// }, -// "Vrd": false -// } -// } -// ] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "f", -// "Tag": "", -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "s", -// "Tag": "", -// "Type": { -// "@type": "/gno.SliceType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" -// }, -// "Vrd": false -// } -// } -// ], -// "Results": [] -// } -// } -// ], -// "Results": [] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:16" -// }, -// "FileName": "crossrealm_slice2.gno", -// "IsMethod": false, -// "Name": "GetSlice4", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_slice2.gno", -// "Line": "49", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "f", -// "Tag": "", -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "s", -// "Tag": "", -// "Type": { -// "@type": "/gno.SliceType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" -// }, -// "Vrd": false -// } -// } -// ], -// "Results": [] -// } -// } -// ], -// "Results": [] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.SliceType", -// "Elt": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" -// } -// }, -// "Vrd": false -// } -// } -// ] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:16" -// }, -// "FileName": "crossrealm_slice2.gno", -// "IsMethod": false, -// "Name": "GetSlice5", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_slice2.gno", -// "Line": "54", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.SliceType", -// "Elt": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" -// } -// }, -// "Vrd": false -// } -// } -// ] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "f", -// "Tag": "", -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "s", -// "Tag": "", -// "Type": { -// "@type": "/gno.SliceType", -// "Elt": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" -// } -// }, -// "Vrd": false -// } -// } -// ], -// "Results": [] -// } -// } -// ], -// "Results": [] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:16" -// }, -// "FileName": "crossrealm_slice2.gno", -// "IsMethod": false, -// "Name": "GetSlice6", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_slice2.gno", -// "Line": "58", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "f", -// "Tag": "", -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "s", -// "Tag": "", -// "Type": { -// "@type": "/gno.SliceType", -// "Elt": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" -// } -// }, -// "Vrd": false -// } -// } -// ], -// "Results": [] -// } -// } -// ], -// "Results": [] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "f", -// "Tag": "", -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "s", -// "Tag": "", -// "Type": { -// "@type": "/gno.ArrayType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" -// }, -// "Len": "2", -// "Vrd": false -// } -// } -// ], -// "Results": [] -// } -// } -// ], -// "Results": [] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:16" -// }, -// "FileName": "crossrealm_slice2.gno", -// "IsMethod": false, -// "Name": "GetSlice7", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_slice2.gno", -// "Line": "63", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "f", -// "Tag": "", -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "s", -// "Tag": "", -// "Type": { -// "@type": "/gno.ArrayType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" -// }, -// "Len": "2", -// "Vrd": false -// } -// } -// ], -// "Results": [] -// } -// } -// ], -// "Results": [] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.TypeType" -// }, -// "V": { -// "@type": "/gno.TypeValue", -// "Type": { -// "@type": "/gno.DeclaredType", -// "Base": { -// "@type": "/gno.StructType", -// "Fields": [ -// { -// "Embedded": false, -// "Name": "A", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "32" -// } -// } -// ], -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// }, -// "Methods": [ -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "b", -// "Tag": "", -// "Type": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Bar" -// } -// } -// } -// ], -// "Results": [] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": null, -// "FileName": "crossrealm_struct.gno", -// "IsMethod": true, -// "Name": "String", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_struct.gno", -// "Line": "12", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "b", -// "Tag": "", -// "Type": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Bar" -// } -// } -// } -// ], -// "Results": [] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "b", -// "Tag": "", -// "Type": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Bar" -// } -// } -// } -// ], -// "Results": [] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": null, -// "FileName": "crossrealm_struct.gno", -// "IsMethod": true, -// "Name": "ModifyBar", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_struct.gno", -// "Line": "26", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "b", -// "Tag": "", -// "Type": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Bar" -// } -// } -// } -// ], -// "Results": [] -// } -// } -// } -// ], -// "Name": "Bar", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Bar" -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Bar" -// } -// }, -// "V": { -// "@type": "/gno.PointerValue", -// "Base": { -// "@type": "/gno.RefValue", -// "Hash": "eb498518bc671b8c1625ffbe54846ac1df8601a5", -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:19" -// }, -// "Index": "0", -// "TV": null -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "b", -// "Tag": "", -// "Type": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Bar" -// } -// } -// } -// ], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Bar" -// } -// } -// } -// ] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:21" -// }, -// "FileName": "crossrealm_struct.gno", -// "IsMethod": false, -// "Name": "SetBar", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_struct.gno", -// "Line": "16", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "b", -// "Tag": "", -// "Type": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Bar" -// } -// } -// } -// ], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Bar" -// } -// } -// } -// ] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:21" -// }, -// "FileName": "crossrealm_struct.gno", -// "IsMethod": false, -// "Name": "ChangeBar", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_struct.gno", -// "Line": "21", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.TypeType" -// }, -// "V": { -// "@type": "/gno.TypeValue", -// "Type": { -// "@type": "/gno.DeclaredType", -// "Base": { -// "@type": "/gno.StructType", -// "Fields": [ -// { -// "Embedded": false, -// "Name": "name", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// } -// } -// ], -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// }, -// "Methods": [], -// "Name": "A", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.TypeType" -// }, -// "V": { -// "@type": "/gno.TypeValue", -// "Type": { -// "@type": "/gno.DeclaredType", -// "Base": { -// "@type": "/gno.StructType", -// "Fields": [ -// { -// "Embedded": false, -// "Name": "name", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// } -// } -// ], -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// }, -// "Methods": [], -// "Name": "B", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.TypeType" -// }, -// "V": { -// "@type": "/gno.TypeValue", -// "Type": { -// "@type": "/gno.DeclaredType", -// "Base": { -// "@type": "/gno.StructType", -// "Fields": [ -// { -// "Embedded": false, -// "Name": "name", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// } -// } -// ], -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// }, -// "Methods": [], -// "Name": "D", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.TypeType" -// }, -// "V": { -// "@type": "/gno.TypeValue", -// "Type": { -// "@type": "/gno.DeclaredType", -// "Base": { -// "@type": "/gno.StructType", -// "Fields": [ -// { -// "Embedded": true, -// "Name": "A", -// "Tag": "", -// "Type": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.A" -// } -// }, -// { -// "Embedded": true, -// "Name": "B", -// "Tag": "", -// "Type": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.B" -// } -// }, -// { -// "Embedded": true, -// "Name": "D", -// "Tag": "", -// "Type": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.D" -// } -// } -// ], -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// }, -// "Methods": [], -// "Name": "C", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.A" -// }, -// "V": { -// "@type": "/gno.RefValue", -// "Hash": "600bc777de2ebe4f91378028f2331fdfdc891ddc", -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:22" -// } -// }, -// { -// "T": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.B" -// }, -// "V": { -// "@type": "/gno.RefValue", -// "Hash": "78dd21cd9cef4925a96ee4fbbf182d1494f646d5", -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:23" -// } -// }, -// { -// "T": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.C" -// } -// }, -// "V": { -// "@type": "/gno.PointerValue", -// "Base": { -// "@type": "/gno.RefValue", -// "Hash": "c443db3ae26b6a807ae6a997f395af8ca986b3b3", -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:42" -// }, -// "Index": "0", -// "TV": null -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:24" -// }, -// "FileName": "crossrealm_struct2.gno", -// "IsMethod": false, -// "Name": "init.56", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_struct2.gno", -// "Line": "26", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "cb", -// "Tag": "", -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "v", -// "Tag": "", -// "Type": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.C" -// } -// } -// } -// ], -// "Results": [] -// } -// } -// ], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.C" -// } -// } -// } -// ] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:24" -// }, -// "FileName": "crossrealm_struct2.gno", -// "IsMethod": false, -// "Name": "GetStruct", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_struct2.gno", -// "Line": "32", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "cb", -// "Tag": "", -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "v", -// "Tag": "", -// "Type": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.C" -// } -// } -// } -// ], -// "Results": [] -// } -// } -// ], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.C" -// } -// } -// } -// ] -// } -// } -// } -// ] -// } -// d[1712ac7adcfdc8e58a67e5615e20fb312394c4df:31] -// d[1712ac7adcfdc8e58a67e5615e20fb312394c4df:32] -// switchrealm["gno.land/r/crossrealm_test"] -// u[f5a516808f8976c33939133293d598ce3bca4e8d:2]={ -// "Blank": {}, -// "ObjectInfo": { -// "ID": "f5a516808f8976c33939133293d598ce3bca4e8d:2", -// "IsEscaped": true, -// "ModTime": "3", -// "RefCount": "2" -// }, -// "Parent": null, -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "0", -// "File": "", -// "Line": "0", -// "PkgPath": "gno.land/r/crossrealm_test" -// } -// }, -// "Values": [ -// { -// "T": { -// "@type": "/gno.SliceType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" -// }, -// "Vrd": false -// }, -// "V": { -// "@type": "/gno.SliceValue", -// "Base": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:45" -// }, -// "Length": "2", -// "Maxcap": "2", -// "Offset": "0" -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "f5a516808f8976c33939133293d598ce3bca4e8d:3" -// }, -// "FileName": "main.gno", -// "IsMethod": false, -// "Name": "main", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/crossrealm_test", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "main.gno", -// "Line": "12", -// "PkgPath": "gno.land/r/crossrealm_test" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// } -// } -// } -// ] -// } -// u[1712ac7adcfdc8e58a67e5615e20fb312394c4df:2]={ -// "Blank": {}, -// "ObjectInfo": { -// "ID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:2", -// "IsEscaped": true, -// "ModTime": "3", -// "RefCount": "10" -// }, -// "Parent": null, -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "0", -// "File": "", -// "Line": "0", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Values": [ -// { -// "T": { -// "@type": "/gno.TypeType" -// }, -// "V": { -// "@type": "/gno.TypeValue", -// "Type": { -// "@type": "/gno.DeclaredType", -// "Base": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "4" -// } -// } -// ] -// }, -// "Methods": [], -// "Name": "F", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.F" -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "ff", -// "Tag": "", -// "Type": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.F" -// } -// } -// ], -// "Results": [] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:3" -// }, -// "FileName": "crossrealm_func.gno", -// "IsMethod": false, -// "Name": "SetCallback", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_func.gno", -// "Line": "7", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "ff", -// "Tag": "", -// "Type": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.F" -// } -// } -// ], -// "Results": [] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:3" -// }, -// "FileName": "crossrealm_func.gno", -// "IsMethod": false, -// "Name": "ExecuteCallback", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_func.gno", -// "Line": "11", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// } -// } -// ] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:4" -// }, -// "FileName": "", -// "IsMethod": false, -// "Name": "", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "10", -// "File": "crossrealm_func2.gno", -// "Line": "3", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// } -// } -// ] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// } -// } -// ] -// } -// } -// ] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:4" -// }, -// "FileName": "crossrealm_func2.gno", -// "IsMethod": false, -// "Name": "GetFunc", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_func2.gno", -// "Line": "8", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// } -// } -// ] -// } -// } -// ] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// } -// } -// ] -// } -// } -// ] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:4" -// }, -// "FileName": "crossrealm_func2.gno", -// "IsMethod": false, -// "Name": "GetFunc2", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_func2.gno", -// "Line": "12", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// } -// } -// ] -// } -// } -// ] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.TypeType" -// }, -// "V": { -// "@type": "/gno.TypeValue", -// "Type": { -// "@type": "/gno.DeclaredType", -// "Base": { -// "@type": "/gno.StructType", -// "Fields": [], -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// }, -// "Methods": [ -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "sv", -// "Tag": "", -// "Type": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.MyStruct" -// } -// } -// } -// ], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// } -// } -// ] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": null, -// "FileName": "crossrealm_func2.gno", -// "IsMethod": true, -// "Name": "M", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_func2.gno", -// "Line": "20", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "sv", -// "Tag": "", -// "Type": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.MyStruct" -// } -// } -// } -// ], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// } -// } -// ] -// } -// } -// } -// ], -// "Name": "MyStruct", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.MyStruct" -// } -// }, -// "V": { -// "@type": "/gno.PointerValue", -// "Base": { -// "@type": "/gno.RefValue", -// "Hash": "66606f1f6d50797bbe89640247170078dcbf0e6a", -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:5" -// }, -// "Index": "0", -// "TV": null -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// } -// } -// ] -// } -// } -// ] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:4" -// }, -// "FileName": "crossrealm_func2.gno", -// "IsMethod": false, -// "Name": "GetMethod", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_func2.gno", -// "Line": "30", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// } -// } -// ] -// } -// } -// ] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.TypeType" -// }, -// "V": { -// "@type": "/gno.TypeValue", -// "Type": { -// "@type": "/gno.DeclaredType", -// "Base": { -// "@type": "/gno.InterfaceType", -// "Generic": "", -// "Methods": [ -// { -// "Embedded": false, -// "Name": "Foo", -// "Tag": "", -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// } -// } -// ], -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// }, -// "Methods": [], -// "Name": "Fooer", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "f", -// "Tag": "", -// "Type": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" -// } -// } -// ], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" -// } -// } -// ] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:7" -// }, -// "FileName": "crossrealm_iface.gno", -// "IsMethod": false, -// "Name": "SetFooer", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_iface.gno", -// "Line": "8", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "f", -// "Tag": "", -// "Type": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" -// } -// } -// ], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" -// } -// } -// ] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:7" -// }, -// "FileName": "crossrealm_iface.gno", -// "IsMethod": false, -// "Name": "CallFoo", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_iface.gno", -// "Line": "13", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.TypeType" -// }, -// "V": { -// "@type": "/gno.TypeValue", -// "Type": { -// "@type": "/gno.DeclaredType", -// "Base": { -// "@type": "/gno.StructType", -// "Fields": [ -// { -// "Embedded": false, -// "Name": "name", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// } -// }, -// { -// "Embedded": false, -// "Name": "f", -// "Tag": "", -// "Type": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" -// } -// } -// ], -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// }, -// "Methods": [], -// "Name": "Container", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Container" -// }, -// "V": { -// "@type": "/gno.RefValue", -// "Hash": "a7562372e10ade1d106ae5ef9e97c170ee4b50f1", -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:8" -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "f", -// "Tag": "", -// "Type": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" -// } -// } -// ], -// "Results": [] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:7" -// }, -// "FileName": "crossrealm_iface.gno", -// "IsMethod": false, -// "Name": "SetContainer", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_iface.gno", -// "Line": "23", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "f", -// "Tag": "", -// "Type": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" -// } -// } -// ], -// "Results": [] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "f", -// "Tag": "", -// "Type": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" -// } -// } -// ], -// "Results": [] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:7" -// }, -// "FileName": "crossrealm_iface.gno", -// "IsMethod": false, -// "Name": "SetContainer2", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_iface.gno", -// "Line": "27", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "f", -// "Tag": "", -// "Type": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" -// } -// } -// ], -// "Results": [] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.MapType", -// "Key": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// }, -// "Value": { -// "@type": "/gno.PrimitiveType", -// "value": "32" -// } -// }, -// "V": { -// "@type": "/gno.RefValue", -// "Hash": "cda4bc373a1cceedd07fe9fd29410bfd5732df7c", -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:25" -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:9" -// }, -// "FileName": "crossrealm_map.gno", -// "IsMethod": false, -// "Name": "init.19", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_map.gno", -// "Line": "5", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.MapType", -// "Key": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// }, -// "Value": { -// "@type": "/gno.PrimitiveType", -// "value": "32" -// } -// } -// } -// ] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:9" -// }, -// "FileName": "crossrealm_map.gno", -// "IsMethod": false, -// "Name": "GetMap", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_map.gno", -// "Line": "10", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.MapType", -// "Key": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// }, -// "Value": { -// "@type": "/gno.PrimitiveType", -// "value": "32" -// } -// } -// } -// ] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.TypeType" -// }, -// "V": { -// "@type": "/gno.TypeValue", -// "Type": { -// "@type": "/gno.DeclaredType", -// "Base": { -// "@type": "/gno.StructType", -// "Fields": [ -// { -// "Embedded": false, -// "Name": "A", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "32" -// } -// } -// ], -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// }, -// "Methods": [ -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "ls", -// "Tag": "", -// "Type": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.LocalStruct" -// } -// } -// } -// ], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// } -// } -// ] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": null, -// "FileName": "crossrealm_p.gno", -// "IsMethod": true, -// "Name": "String", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_p.gno", -// "Line": "12", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "ls", -// "Tag": "", -// "Type": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.LocalStruct" -// } -// } -// } -// ], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// } -// } -// ] -// } -// } -// } -// ], -// "Name": "LocalStruct", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.LocalStruct" -// } -// }, -// "V": { -// "@type": "/gno.PointerValue", -// "Base": { -// "@type": "/gno.RefValue", -// "Hash": "921bae5520c2c8b9d456b47651ea80481836de4e", -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:26" -// }, -// "Index": "0", -// "TV": null -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:10" -// }, -// "FileName": "crossrealm_p.gno", -// "IsMethod": false, -// "Name": "init.23", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_p.gno", -// "Line": "19", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/p/demo/tests/p_crossrealm.Container" -// } -// } -// } -// ] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:10" -// }, -// "FileName": "crossrealm_p.gno", -// "IsMethod": false, -// "Name": "Make1", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_p.gno", -// "Line": "24", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/p/demo/tests/p_crossrealm.Container" -// } -// } -// } -// ] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.SliceType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" -// }, -// "Vrd": false -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "fs", -// "Tag": "", -// "Type": { -// "@type": "/gno.SliceType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" -// }, -// "Vrd": false -// } -// } -// ], -// "Results": [] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:11" -// }, -// "FileName": "crossrealm_slice.gno", -// "IsMethod": false, -// "Name": "SetSlice", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_slice.gno", -// "Line": "5", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "fs", -// "Tag": "", -// "Type": { -// "@type": "/gno.SliceType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Fooer" -// }, -// "Vrd": false -// } -// } -// ], -// "Results": [] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.TypeType" -// }, -// "V": { -// "@type": "/gno.TypeValue", -// "Type": { -// "@type": "/gno.DeclaredType", -// "Base": { -// "@type": "/gno.StructType", -// "Fields": [ -// { -// "Embedded": false, -// "Name": "name", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// } -// } -// ], -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// }, -// "Methods": [], -// "Name": "XYZ", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.SliceType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" -// }, -// "Vrd": false -// }, -// "V": { -// "@type": "/gno.SliceValue", -// "Base": { -// "@type": "/gno.RefValue", -// "Hash": "b3b42c06d65da2199792616887b55d65b79f075e", -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:28" -// }, -// "Length": "2", -// "Maxcap": "2", -// "Offset": "0" -// } -// }, -// { -// "T": { -// "@type": "/gno.SliceType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" -// }, -// "Vrd": false -// }, -// "V": { -// "@type": "/gno.SliceValue", -// "Base": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:45" -// }, -// "Length": "2", -// "Maxcap": "2", -// "Offset": "0" -// } -// }, -// { -// "T": { -// "@type": "/gno.SliceType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" -// }, -// "Vrd": false -// }, -// "V": { -// "@type": "/gno.SliceValue", -// "Base": { -// "@type": "/gno.RefValue", -// "Hash": "7c8932f1337c257a3236c79d7d8b4211812d8385", -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:33" -// }, -// "Length": "1", -// "Maxcap": "1", -// "Offset": "0" -// } -// }, -// { -// "T": { -// "@type": "/gno.SliceType", -// "Elt": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" -// } -// }, -// "Vrd": false -// }, -// "V": { -// "@type": "/gno.SliceValue", -// "Base": { -// "@type": "/gno.RefValue", -// "Hash": "dbf56198a94f3a1d98c501d1b8c58b88bfbe8bce", -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:35" -// }, -// "Length": "1", -// "Maxcap": "1", -// "Offset": "0" -// } -// }, -// { -// "T": { -// "@type": "/gno.SliceType", -// "Elt": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" -// } -// }, -// "Vrd": false -// }, -// "V": { -// "@type": "/gno.SliceValue", -// "Base": { -// "@type": "/gno.RefValue", -// "Hash": "8f5471d881fd68800170d03c52907ce7a7607d09", -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:12" -// }, -// "Length": "2", -// "Maxcap": "2", -// "Offset": "0" -// } -// }, -// { -// "T": { -// "@type": "/gno.ArrayType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" -// }, -// "Len": "2", -// "Vrd": false -// }, -// "V": { -// "@type": "/gno.RefValue", -// "Hash": "41d4fd3b5431d4cd8494803a01f437bddd45b521", -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:13" -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:16" -// }, -// "FileName": "crossrealm_slice2.gno", -// "IsMethod": false, -// "Name": "init.34", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_slice2.gno", -// "Line": "13", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.SliceType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" -// }, -// "Vrd": false -// } -// } -// ] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:16" -// }, -// "FileName": "crossrealm_slice2.gno", -// "IsMethod": false, -// "Name": "GetSlice", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_slice2.gno", -// "Line": "28", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.SliceType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" -// }, -// "Vrd": false -// } -// } -// ] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" -// }, -// "V": { -// "@type": "/gno.RefValue", -// "Hash": "b439d9527c852f481b3dcc9c4ad27fcf6b2cbc6e", -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:17" -// } -// }, -// { -// "T": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" -// }, -// "V": { -// "@type": "/gno.RefValue", -// "Hash": "c3a08360b77971b3c8a35a4c9c0955f6336760c4", -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:18" -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.SliceType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" -// }, -// "Vrd": false -// } -// } -// ] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:16" -// }, -// "FileName": "crossrealm_slice2.gno", -// "IsMethod": false, -// "Name": "GetSlice2", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_slice2.gno", -// "Line": "36", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.SliceType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" -// }, -// "Vrd": false -// } -// } -// ] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.SliceType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" -// }, -// "Vrd": false -// } -// } -// ] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:16" -// }, -// "FileName": "crossrealm_slice2.gno", -// "IsMethod": false, -// "Name": "GetSlice3", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_slice2.gno", -// "Line": "44", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.SliceType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" -// }, -// "Vrd": false -// } -// } -// ] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "f", -// "Tag": "", -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "s", -// "Tag": "", -// "Type": { -// "@type": "/gno.SliceType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" -// }, -// "Vrd": false -// } -// } -// ], -// "Results": [] -// } -// } -// ], -// "Results": [] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:16" -// }, -// "FileName": "crossrealm_slice2.gno", -// "IsMethod": false, -// "Name": "GetSlice4", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_slice2.gno", -// "Line": "49", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "f", -// "Tag": "", -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "s", -// "Tag": "", -// "Type": { -// "@type": "/gno.SliceType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" -// }, -// "Vrd": false -// } -// } -// ], -// "Results": [] -// } -// } -// ], -// "Results": [] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.SliceType", -// "Elt": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" -// } -// }, -// "Vrd": false -// } -// } -// ] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:16" -// }, -// "FileName": "crossrealm_slice2.gno", -// "IsMethod": false, -// "Name": "GetSlice5", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_slice2.gno", -// "Line": "54", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.SliceType", -// "Elt": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" -// } -// }, -// "Vrd": false -// } -// } -// ] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "f", -// "Tag": "", -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "s", -// "Tag": "", -// "Type": { -// "@type": "/gno.SliceType", -// "Elt": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" -// } -// }, -// "Vrd": false -// } -// } -// ], -// "Results": [] -// } -// } -// ], -// "Results": [] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:16" -// }, -// "FileName": "crossrealm_slice2.gno", -// "IsMethod": false, -// "Name": "GetSlice6", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_slice2.gno", -// "Line": "58", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "f", -// "Tag": "", -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "s", -// "Tag": "", -// "Type": { -// "@type": "/gno.SliceType", -// "Elt": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" -// } -// }, -// "Vrd": false -// } -// } -// ], -// "Results": [] -// } -// } -// ], -// "Results": [] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "f", -// "Tag": "", -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "s", -// "Tag": "", -// "Type": { -// "@type": "/gno.ArrayType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" -// }, -// "Len": "2", -// "Vrd": false -// } -// } -// ], -// "Results": [] -// } -// } -// ], -// "Results": [] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:16" -// }, -// "FileName": "crossrealm_slice2.gno", -// "IsMethod": false, -// "Name": "GetSlice7", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_slice2.gno", -// "Line": "63", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "f", -// "Tag": "", -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "s", -// "Tag": "", -// "Type": { -// "@type": "/gno.ArrayType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" -// }, -// "Len": "2", -// "Vrd": false -// } -// } -// ], -// "Results": [] -// } -// } -// ], -// "Results": [] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.TypeType" -// }, -// "V": { -// "@type": "/gno.TypeValue", -// "Type": { -// "@type": "/gno.DeclaredType", -// "Base": { -// "@type": "/gno.StructType", -// "Fields": [ -// { -// "Embedded": false, -// "Name": "A", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "32" -// } -// } -// ], -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// }, -// "Methods": [ -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "b", -// "Tag": "", -// "Type": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Bar" -// } -// } -// } -// ], -// "Results": [] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": null, -// "FileName": "crossrealm_struct.gno", -// "IsMethod": true, -// "Name": "String", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_struct.gno", -// "Line": "12", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "b", -// "Tag": "", -// "Type": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Bar" -// } -// } -// } -// ], -// "Results": [] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "b", -// "Tag": "", -// "Type": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Bar" -// } -// } -// } -// ], -// "Results": [] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": null, -// "FileName": "crossrealm_struct.gno", -// "IsMethod": true, -// "Name": "ModifyBar", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_struct.gno", -// "Line": "26", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "b", -// "Tag": "", -// "Type": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Bar" -// } -// } -// } -// ], -// "Results": [] -// } -// } -// } -// ], -// "Name": "Bar", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Bar" -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Bar" -// } -// }, -// "V": { -// "@type": "/gno.PointerValue", -// "Base": { -// "@type": "/gno.RefValue", -// "Hash": "eb498518bc671b8c1625ffbe54846ac1df8601a5", -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:19" -// }, -// "Index": "0", -// "TV": null -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "b", -// "Tag": "", -// "Type": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Bar" -// } -// } -// } -// ], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Bar" -// } -// } -// } -// ] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:21" -// }, -// "FileName": "crossrealm_struct.gno", -// "IsMethod": false, -// "Name": "SetBar", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_struct.gno", -// "Line": "16", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [ -// { -// "Embedded": false, -// "Name": "b", -// "Tag": "", -// "Type": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Bar" -// } -// } -// } -// ], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.Bar" -// } -// } -// } -// ] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:21" -// }, -// "FileName": "crossrealm_struct.gno", -// "IsMethod": false, -// "Name": "ChangeBar", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "crossrealm_struct.gno", -// "Line": "21", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.TypeType" -// }, -// "V": { -// "@type": "/gno.TypeValue", -// "Type": { -// "@type": "/gno.DeclaredType", -// "Base": { -// "@type": "/gno.StructType", -// "Fields": [ -// { -// "Embedded": false, -// "Name": "name", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// } -// } -// ], -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// }, -// "Methods": [], -// "Name": "A", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.TypeType" -// }, -// "V": { -// "@type": "/gno.TypeValue", -// "Type": { -// "@type": "/gno.DeclaredType", -// "Base": { -// "@type": "/gno.StructType", -// "Fields": [ -// { -// "Embedded": false, -// "Name": "name", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// } -// } -// ], -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// }, -// "Methods": [], -// "Name": "B", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.TypeType" -// }, -// "V": { -// "@type": "/gno.TypeValue", -// "Type": { -// "@type": "/gno.DeclaredType", -// "Base": { -// "@type": "/gno.StructType", -// "Fields": [ -// { -// "Embedded": false, -// "Name": "name", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// } -// } -// ], -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// }, -// "Methods": [], -// "Name": "D", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.TypeType" -// }, -// "V": { -// "@type": "/gno.TypeValue", -// "Type": { -// "@type": "/gno.DeclaredType", -// "Base": { -// "@type": "/gno.StructType", -// "Fields": [ -// { -// "Embedded": true, -// "Name": "A", -// "Tag": "", -// "Type": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.A" -// } -// }, -// { -// "Embedded": true, -// "Name": "B", -// "Tag": "", -// "Type": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.B" -// } -// }, -// { -// "Embedded": true, -// "Name": "D", -// "Tag": "", -// "Type": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.D" -// } +// "Vrd": false // } -// ], -// "PkgPath": "gno.land/r/demo/tests/crossrealm" -// }, -// "Methods": [], -// "Name": "C", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// } +// ] // } // } // }, // { // "T": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.A" -// }, -// "V": { -// "@type": "/gno.RefValue", -// "Hash": "600bc777de2ebe4f91378028f2331fdfdc891ddc", -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:22" -// } -// }, -// { -// "T": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.B" +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "s", +// "Tag": "", +// "Type": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" +// }, +// "Vrd": false +// } +// } +// ], +// "Results": [] +// } +// } +// ], +// "Results": [] // }, // "V": { -// "@type": "/gno.RefValue", -// "Hash": "78dd21cd9cef4925a96ee4fbbf182d1494f646d5", -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:23" +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:3" +// }, +// "FileName": "crossrealm_slice.gno", +// "IsMethod": false, +// "Name": "GetSlice4", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_slice.gno", +// "Line": "61", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "s", +// "Tag": "", +// "Type": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" +// }, +// "Vrd": false +// } +// } +// ], +// "Results": [] +// } +// } +// ], +// "Results": [] +// } // } // }, // { // "T": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.C" -// } +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" +// } +// }, +// "Vrd": false +// } +// } +// ] // }, // "V": { -// "@type": "/gno.PointerValue", -// "Base": { +// "@type": "/gno.FuncValue", +// "Closure": { // "@type": "/gno.RefValue", -// "Hash": "c443db3ae26b6a807ae6a997f395af8ca986b3b3", -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:42" +// "Escaped": true, +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:3" +// }, +// "FileName": "crossrealm_slice.gno", +// "IsMethod": false, +// "Name": "GetSlice5", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_slice.gno", +// "Line": "66", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" +// } // }, -// "Index": "0", -// "TV": null +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" +// } +// }, +// "Vrd": false +// } +// } +// ] +// } // } // }, // { // "T": { // "@type": "/gno.FuncType", -// "Params": [], +// "Params": [ +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "s", +// "Tag": "", +// "Type": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" +// } +// }, +// "Vrd": false +// } +// } +// ], +// "Results": [] +// } +// } +// ], // "Results": [] // }, // "V": { @@ -5317,27 +1749,55 @@ func main() { // "Closure": { // "@type": "/gno.RefValue", // "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:24" +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:3" // }, -// "FileName": "crossrealm_struct2.gno", +// "FileName": "crossrealm_slice.gno", // "IsMethod": false, -// "Name": "init.56", +// "Name": "GetSlice6", // "NativeName": "", // "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice", // "Source": { // "@type": "/gno.RefNode", // "BlockNode": null, // "Location": { // "Column": "1", -// "File": "crossrealm_struct2.gno", -// "Line": "26", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// "File": "crossrealm_slice.gno", +// "Line": "70", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, // "Type": { // "@type": "/gno.FuncType", -// "Params": [], +// "Params": [ +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "s", +// "Tag": "", +// "Type": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" +// } +// }, +// "Vrd": false +// } +// } +// ], +// "Results": [] +// } +// } +// ], // "Results": [] // } // } @@ -5348,21 +1808,23 @@ func main() { // "Params": [ // { // "Embedded": false, -// "Name": "cb", +// "Name": "f", // "Tag": "", // "Type": { // "@type": "/gno.FuncType", // "Params": [ // { // "Embedded": false, -// "Name": "v", +// "Name": "s", // "Tag": "", // "Type": { -// "@type": "/gno.PointerType", +// "@type": "/gno.ArrayType", // "Elt": { // "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.C" -// } +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" +// }, +// "Len": "2", +// "Vrd": false // } // } // ], @@ -5370,42 +1832,29 @@ func main() { // } // } // ], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.C" -// } -// } -// } -// ] +// "Results": [] // }, // "V": { // "@type": "/gno.FuncValue", // "Closure": { // "@type": "/gno.RefValue", // "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:24" +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:3" // }, -// "FileName": "crossrealm_struct2.gno", +// "FileName": "crossrealm_slice.gno", // "IsMethod": false, -// "Name": "GetStruct", +// "Name": "GetSlice7", // "NativeName": "", // "NativePkg": "", -// "PkgPath": "gno.land/r/demo/tests/crossrealm", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice", // "Source": { // "@type": "/gno.RefNode", // "BlockNode": null, // "Location": { // "Column": "1", -// "File": "crossrealm_struct2.gno", -// "Line": "32", -// "PkgPath": "gno.land/r/demo/tests/crossrealm" +// "File": "crossrealm_slice.gno", +// "Line": "75", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, // "Type": { @@ -5413,21 +1862,23 @@ func main() { // "Params": [ // { // "Embedded": false, -// "Name": "cb", +// "Name": "f", // "Tag": "", // "Type": { // "@type": "/gno.FuncType", // "Params": [ // { // "Embedded": false, -// "Name": "v", +// "Name": "s", // "Tag": "", // "Type": { -// "@type": "/gno.PointerType", +// "@type": "/gno.ArrayType", // "Elt": { // "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.C" -// } +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" +// }, +// "Len": "2", +// "Vrd": false // } // } // ], @@ -5435,20 +1886,7 @@ func main() { // } // } // ], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.C" -// } -// } -// } -// ] +// "Results": [] // } // } // } diff --git a/gnovm/tests/files/zrealm_crossrealm33.gno b/gnovm/tests/files/zrealm_crossrealm33.gno index 845caa81f04..87f5da43bdd 100644 --- a/gnovm/tests/files/zrealm_crossrealm33.gno +++ b/gnovm/tests/files/zrealm_crossrealm33.gno @@ -4,7 +4,7 @@ package crossrealm_test import ( "std" - crossrealm "gno.land/r/demo/tests/crossrealm" + crossrealm "gno.land/r/demo/tests/crossrealm/slice" ) var SS []crossrealm.XYZ diff --git a/gnovm/tests/files/zrealm_crossrealm34.gno b/gnovm/tests/files/zrealm_crossrealm34.gno index 14f51d9de75..bee619ecbcb 100644 --- a/gnovm/tests/files/zrealm_crossrealm34.gno +++ b/gnovm/tests/files/zrealm_crossrealm34.gno @@ -4,7 +4,7 @@ package crossrealm_test import ( "std" - crossrealm "gno.land/r/demo/tests/crossrealm" + crossrealm "gno.land/r/demo/tests/crossrealm/slice" ) var SS []*crossrealm.XYZ @@ -18,7 +18,7 @@ func main() { // . // Realm: -// switchrealm["gno.land/r/demo/tests/crossrealm"] +// switchrealm["gno.land/r/demo/tests/crossrealm/slice"] // switchrealm["gno.land/r/crossrealm_test"] // u[f5a516808f8976c33939133293d598ce3bca4e8d:2]={ // "Blank": {}, @@ -47,7 +47,7 @@ func main() { // "@type": "/gno.PointerType", // "Elt": { // "@type": "/gno.RefType", -// "ID": "gno.land/r/demo/tests/crossrealm.XYZ" +// "ID": "gno.land/r/demo/tests/crossrealm/slice.XYZ" // } // }, // "Vrd": false @@ -57,7 +57,7 @@ func main() { // "Base": { // "@type": "/gno.RefValue", // "Escaped": true, -// "ObjectID": "1712ac7adcfdc8e58a67e5615e20fb312394c4df:35" +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:17" // }, // "Length": "1", // "Maxcap": "1", diff --git a/gnovm/tests/files/zrealm_crossrealm34a.gno b/gnovm/tests/files/zrealm_crossrealm34a.gno index b15af3bc3b9..85a55301ebd 100644 --- a/gnovm/tests/files/zrealm_crossrealm34a.gno +++ b/gnovm/tests/files/zrealm_crossrealm34a.gno @@ -4,7 +4,7 @@ package crossrealm_test import ( "std" - crossrealm "gno.land/r/demo/tests/crossrealm" + crossrealm "gno.land/r/demo/tests/crossrealm/slice" ) var SS []*crossrealm.XYZ diff --git a/gnovm/tests/files/zrealm_crossrealm34b.gno b/gnovm/tests/files/zrealm_crossrealm34b.gno index ba1c8a8e398..6cc613e1237 100644 --- a/gnovm/tests/files/zrealm_crossrealm34b.gno +++ b/gnovm/tests/files/zrealm_crossrealm34b.gno @@ -4,7 +4,7 @@ package crossrealm_test import ( "std" - crossrealm "gno.land/r/demo/tests/crossrealm" + crossrealm "gno.land/r/demo/tests/crossrealm/slice" ) var SS [2]crossrealm.XYZ diff --git a/gnovm/tests/files/zrealm_crossrealm36.gno b/gnovm/tests/files/zrealm_crossrealm36.gno index 4a45ef0984d..b707faca7dc 100644 --- a/gnovm/tests/files/zrealm_crossrealm36.gno +++ b/gnovm/tests/files/zrealm_crossrealm36.gno @@ -1,7 +1,7 @@ // PKGPATH: gno.land/r/crossrealm_test package crossrealm_test -import crossrealm "gno.land/r/demo/tests/crossrealm" +import crossrealm "gno.land/r/demo/tests/crossrealm/struct" var s *crossrealm.C diff --git a/gnovm/tests/files/zrealm_crossrealm37.gno b/gnovm/tests/files/zrealm_crossrealm37.gno index a445dd73074..5745feb7a2a 100644 --- a/gnovm/tests/files/zrealm_crossrealm37.gno +++ b/gnovm/tests/files/zrealm_crossrealm37.gno @@ -1,7 +1,7 @@ // PKGPATH: gno.land/r/crossrealm_test package crossrealm_test -import crossrealm "gno.land/r/demo/tests/crossrealm" +import crossrealm "gno.land/r/demo/tests/crossrealm/map" var m1 map[string]int diff --git a/gnovm/tests/files/zrealm_crossrealm38.gno b/gnovm/tests/files/zrealm_crossrealm38.gno index 59627cdd4bd..1b82f4b617f 100644 --- a/gnovm/tests/files/zrealm_crossrealm38.gno +++ b/gnovm/tests/files/zrealm_crossrealm38.gno @@ -1,7 +1,7 @@ // PKGPATH: gno.land/r/crossrealm_test package crossrealm_test -import crossrealm "gno.land/r/demo/tests/crossrealm" +import crossrealm "gno.land/r/demo/tests/crossrealm/func" var f func() string diff --git a/gnovm/tests/files/zrealm_crossrealm39.gno b/gnovm/tests/files/zrealm_crossrealm39.gno index 7cd5e0de0af..e400c486214 100644 --- a/gnovm/tests/files/zrealm_crossrealm39.gno +++ b/gnovm/tests/files/zrealm_crossrealm39.gno @@ -1,7 +1,7 @@ // PKGPATH: gno.land/r/crossrealm_test package crossrealm_test -import crossrealm "gno.land/r/demo/tests/crossrealm" +import crossrealm "gno.land/r/demo/tests/crossrealm/func" var f func() string diff --git a/gnovm/tests/files/zrealm_crossrealm40.gno b/gnovm/tests/files/zrealm_crossrealm40.gno index dde17b0dd20..3d105a77b8f 100644 --- a/gnovm/tests/files/zrealm_crossrealm40.gno +++ b/gnovm/tests/files/zrealm_crossrealm40.gno @@ -1,7 +1,7 @@ // PKGPATH: gno.land/r/crossrealm_test package crossrealm_test -import crossrealm "gno.land/r/demo/tests/crossrealm" +import crossrealm "gno.land/r/demo/tests/crossrealm/func" var f func() string diff --git a/gnovm/tests/files/zrealm_crossrealm42.gno b/gnovm/tests/files/zrealm_crossrealm42.gno index 28abca22cb7..626bbd7dcb8 100644 --- a/gnovm/tests/files/zrealm_crossrealm42.gno +++ b/gnovm/tests/files/zrealm_crossrealm42.gno @@ -1,7 +1,7 @@ // PKGPATH: gno.land/r/crossrealm_test package crossrealm_test -import crossrealm "gno.land/r/demo/tests/crossrealm" +import crossrealm "gno.land/r/demo/tests/crossrealm/struct" import "fmt" type LocalBar crossrealm.Bar diff --git a/gnovm/tests/files/zrealm_crossrealm43.gno b/gnovm/tests/files/zrealm_crossrealm43.gno index 2b5e5ee7b05..01d07ea4a6e 100644 --- a/gnovm/tests/files/zrealm_crossrealm43.gno +++ b/gnovm/tests/files/zrealm_crossrealm43.gno @@ -1,7 +1,7 @@ // PKGPATH: gno.land/r/crossrealm_test package crossrealm_test -import crossrealm "gno.land/r/demo/tests/crossrealm" +import crossrealm "gno.land/r/demo/tests/crossrealm/struct" import "fmt" type LocalBar *crossrealm.Bar // no attach From 453554be851b5fc54d211a9e536303638a64d8dc Mon Sep 17 00:00:00 2001 From: ltzMaxwell Date: Wed, 1 Jan 2025 23:30:59 +0800 Subject: [PATCH 36/40] fixup --- .../crossrealm/slice/crossrealm_slice.gno | 15 + .../crossrealm/struct/crossrealm_struct.gno | 1 + gnovm/pkg/gnolang/debug.go | 12 + gnovm/pkg/gnolang/debug_false.go | 2 + gnovm/pkg/gnolang/machine.go | 6 + gnovm/pkg/gnolang/op_call.go | 6 + gnovm/pkg/gnolang/op_exec.go | 1 + gnovm/pkg/gnolang/ownership.go | 117 +++-- gnovm/pkg/gnolang/realm.go | 84 ++-- gnovm/pkg/gnolang/uverse.go | 1 + gnovm/pkg/gnolang/values.go | 25 +- gnovm/tests/files/zrealm_crossrealm24.gno | 2 +- gnovm/tests/files/zrealm_crossrealm24d.gno | 2 +- gnovm/tests/files/zrealm_crossrealm24e.gno | 18 + gnovm/tests/files/zrealm_crossrealm32.gno | 472 ++++++++++++++++-- gnovm/tests/files/zrealm_crossrealm34.gno | 2 +- gnovm/tests/files/zrealm_crossrealm35.gno | 26 + gnovm/tests/files/zrealm_crossrealm35a.gno | 261 ++++++++++ 18 files changed, 884 insertions(+), 169 deletions(-) create mode 100644 gnovm/tests/files/zrealm_crossrealm24e.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm35.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm35a.gno diff --git a/examples/gno.land/r/demo/tests/crossrealm/slice/crossrealm_slice.gno b/examples/gno.land/r/demo/tests/crossrealm/slice/crossrealm_slice.gno index 18f86c9a1b2..4185d8c020d 100644 --- a/examples/gno.land/r/demo/tests/crossrealm/slice/crossrealm_slice.gno +++ b/examples/gno.land/r/demo/tests/crossrealm/slice/crossrealm_slice.gno @@ -1,5 +1,7 @@ package crossrealm_slice +import "gno.land/p/demo/tests/p_crossrealm" + type Fooer interface{ Foo() } var S []Fooer @@ -76,3 +78,16 @@ 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 +} diff --git a/examples/gno.land/r/demo/tests/crossrealm/struct/crossrealm_struct.gno b/examples/gno.land/r/demo/tests/crossrealm/struct/crossrealm_struct.gno index dc5a90038b6..6f6e8cb798d 100644 --- a/examples/gno.land/r/demo/tests/crossrealm/struct/crossrealm_struct.gno +++ b/examples/gno.land/r/demo/tests/crossrealm/struct/crossrealm_struct.gno @@ -8,6 +8,7 @@ var bar *Bar // TODO: deprovision this var Bar2 *Bar = &Bar{A: 22} // exported +var Bar3 Bar = Bar{A: 22} func (b *Bar) String() { println("b.A: ", b.A) diff --git a/gnovm/pkg/gnolang/debug.go b/gnovm/pkg/gnolang/debug.go index c7f9311ffe4..30db0aa415c 100644 --- a/gnovm/pkg/gnolang/debug.go +++ b/gnovm/pkg/gnolang/debug.go @@ -45,6 +45,18 @@ func init() { var enabled bool = true +func (debugging) Println2(args ...interface{}) { + if debug2 { + fmt.Println(append([]interface{}{"DEBUG:"}, args...)...) + } +} + +func (debugging) Printf2(format string, args ...interface{}) { + if debug2 { + fmt.Printf("DEBUG: "+format, args...) + } +} + func (debugging) Println(args ...interface{}) { if debug { if enabled { diff --git a/gnovm/pkg/gnolang/debug_false.go b/gnovm/pkg/gnolang/debug_false.go index ce714452be7..015ef2d088d 100644 --- a/gnovm/pkg/gnolang/debug_false.go +++ b/gnovm/pkg/gnolang/debug_false.go @@ -3,3 +3,5 @@ package gnolang const debug debugging = false + +const debug2 debugging = true diff --git a/gnovm/pkg/gnolang/machine.go b/gnovm/pkg/gnolang/machine.go index e3d77ca35d4..1ee97a52775 100644 --- a/gnovm/pkg/gnolang/machine.go +++ b/gnovm/pkg/gnolang/machine.go @@ -1974,6 +1974,7 @@ func (m *Machine) PopFrameAndReset() { // TODO: optimize by passing in last frame. func (m *Machine) PopFrameAndReturn() { + debug2.Println2("PopFrameAndReturn") fr := m.PopFrame() fr.Popped = true if debug { @@ -1996,6 +1997,11 @@ func (m *Machine) PopFrameAndReturn() { if res.IsUndefined() && rtypes[i].Type.Kind() != InterfaceKind { res.T = rtypes[i].Type } + debug2.Println2("res: ", res) + debug2.Printf2("addr of res: %p \n", &res) + if oo, ok := res.V.(Object); ok { + debug2.Println2("oo.GetObjectInfo(): ", oo.GetObjectInfo()) + } m.Values[fr.NumValues+i] = res } m.NumValues = fr.NumValues + numRes diff --git a/gnovm/pkg/gnolang/op_call.go b/gnovm/pkg/gnolang/op_call.go index 15531ec610d..d2e5c02df8d 100644 --- a/gnovm/pkg/gnolang/op_call.go +++ b/gnovm/pkg/gnolang/op_call.go @@ -46,6 +46,7 @@ func (m *Machine) doOpPrecall() { var gReturnStmt = &ReturnStmt{} func (m *Machine) doOpCall() { + debug2.Println2("doOpCall") // NOTE: Frame won't be popped until the statement is complete, to // discard the correct number of results for func calls in ExprStmts. fr := m.LastFrame() @@ -180,6 +181,8 @@ func (m *Machine) doOpCallDeferNativeBody() { // Assumes that result values are pushed onto the Values stack. func (m *Machine) doOpReturn() { + debug2.Println2("doOpReturn") + debug2.Println2("---done doOpReturn") cfr := m.PopUntilLastCallFrame() // See if we are exiting a realm boundary. // NOTE: there are other ways to implement realm boundary transitions, @@ -199,6 +202,7 @@ func (m *Machine) doOpReturn() { finalize = true } if finalize { + debug2.Println2("finalizing") // Finalize realm updates! // NOTE: This is a resource intensive undertaking. crlm.FinalizeRealmTransaction(m.ReadOnly, m.Store) @@ -211,6 +215,7 @@ func (m *Machine) doOpReturn() { // Like doOpReturn, but with results from the block; // i.e. named result vars declared in func signatures. func (m *Machine) doOpReturnFromBlock() { + debug2.Println2("doOpReturnFromBlock") // Copy results from block. cfr := m.PopUntilLastCallFrame() ft := cfr.Func.GetType(m.Store) @@ -247,6 +252,7 @@ func (m *Machine) doOpReturnFromBlock() { // deferred statements can refer to results with name // expressions. func (m *Machine) doOpReturnToBlock() { + debug2.Println2("doOpReturnToBlock") cfr := m.MustLastCallFrame(1) ft := cfr.Func.GetType(m.Store) numParams := len(ft.Params) diff --git a/gnovm/pkg/gnolang/op_exec.go b/gnovm/pkg/gnolang/op_exec.go index c7e8ffd600c..92f623faf5c 100644 --- a/gnovm/pkg/gnolang/op_exec.go +++ b/gnovm/pkg/gnolang/op_exec.go @@ -431,6 +431,7 @@ EXEC_SWITCH: if debug { debug.Printf("EXEC: %v\n", s) } + debug2.Printf2("EXEC: %v\n", s) switch cs := s.(type) { case *AssignStmt: switch cs.Op { diff --git a/gnovm/pkg/gnolang/ownership.go b/gnovm/pkg/gnolang/ownership.go index df532be6f4c..afed6aa0e8c 100644 --- a/gnovm/pkg/gnolang/ownership.go +++ b/gnovm/pkg/gnolang/ownership.go @@ -392,76 +392,71 @@ func (tv *TypedValue) GetFirstObject(store Store) Object { // also get pkgId of the object, so it's clear where the object is from func (tv *TypedValue) GetFirstObject2(store Store) (obj Object, pkgId PkgID) { fmt.Println("---GetFirstObject2---, tv: ", tv, reflect.TypeOf(tv.V)) - // general case - if dt, ok := tv.T.(*DeclaredType); ok { - fmt.Printf("---dt: %v\n", dt) - fmt.Println("---dt.base: ", dt.Base) - if _, ok := dt.Base.(*FuncType); !ok { - fmt.Println("---dt.base.PkgPath: ", dt.Base.GetPkgPath()) - if IsRealmPath(dt.Base.GetPkgPath()) { - pkgId = PkgIDFromPkgPath(dt.Base.GetPkgPath()) - } - } - } // get first object obj = tv.GetFirstObject(store) fmt.Println("---obj: ", obj) + if obj != nil { + pkgId = obj.GetObjectID().PkgID + } - // get actual pkgId - switch cv := tv.V.(type) { - case PointerValue: - println("---pointer value") - if v, ok := cv.TV.V.(Object); ok { - fmt.Println("---v: ", v) - // TODO: check this - if dt, ok := cv.TV.T.(*DeclaredType); ok { - fmt.Println("---dt: ", dt) - //fmt.Println("---cv.Base: ", cv.GetBase(store), reflect.TypeOf(cv.GetBase(store))) - //if _, ok := cv.GetBase(store).(*HeapItemValue); !ok { - //println("---base is heap item") - if IsRealmPath(dt.PkgPath) { - //println("---IsRealmPath") - pkgId = PkgIDFromPkgPath(dt.PkgPath) + if pkgId.IsZero() { + switch cv := obj.(type) { + case *ArrayValue: + fmt.Println("---array value, T: ", tv.T) + debug2.Println2("objectInfo: ", cv.GetObjectInfo()) + if IsRealmPath(tv.T.Elem().GetPkgPath()) { + // TODO: func type don't have pkgpath, retrieve from clo + pkgId = PkgIDFromPkgPath(tv.T.Elem().GetPkgPath()) + } + return + case *Block: + pkgId = PkgIDFromPkgPath(cv.Source.GetLocation().PkgPath) + return + case *HeapItemValue: + debug2.Println2("heapItemValue: ", cv) + debug2.Println2("heapItemValue.Value.T: ", cv.Value.T) + if dt, ok := cv.Value.T.(*DeclaredType); ok { + fmt.Printf("---dt: %v\n", dt) + fmt.Println("---dt.base: ", dt.Base) + if _, ok := dt.Base.(*FuncType); !ok { + fmt.Println("---dt.base.PkgPath: ", dt.Base.GetPkgPath()) + if IsRealmPath(dt.Base.GetPkgPath()) { + pkgId = PkgIDFromPkgPath(dt.Base.GetPkgPath()) + } } - //} } - fmt.Println("---pkgId; ", pkgId) - } - return - case *ArrayValue: - fmt.Println("---array value, T: ", tv.T) - pkgId = PkgIDFromPkgPath(tv.T.Elem().GetPkgPath()) - return - case *SliceValue: - pkgId = PkgIDFromPkgPath(tv.T.Elem().GetPkgPath()) - base := cv.GetBase(store) - fmt.Println("---base: ", base) - fmt.Println("---base.ID: ", base.ID) - return - case *FuncValue: - fmt.Println("---FuncValue") - clo := cv.GetClosure(store) - fmt.Println("---clo: ", clo) - fmt.Println("clo...PkgPath", clo.Source.GetLocation().PkgPath) - pkgId = PkgIDFromPkgPath(clo.Source.GetLocation().PkgPath) - return - case *BoundMethodValue: - fmt.Println("---BoundMethodValue, recv: ", cv.Receiver) - fmt.Println("---type of T: ", reflect.TypeOf(cv.Receiver.T)) - if pv, ok := cv.Receiver.V.(PointerValue); ok { - println("---pointer value") - // TODO: check this - if dt, ok := pv.TV.T.(*DeclaredType); ok { - fmt.Println("---2, dt: ", dt) - if IsRealmPath(dt.PkgPath) { - pkgId = PkgIDFromPkgPath(dt.PkgPath) + return + case *BoundMethodValue: + fmt.Println("---BoundMethodValue, recv: ", cv.Receiver) + fmt.Println("---type of T: ", reflect.TypeOf(cv.Receiver.T)) + if pv, ok := cv.Receiver.V.(PointerValue); ok { + println("---pointer value") + // TODO: check this + if dt, ok := pv.TV.T.(*DeclaredType); ok { + fmt.Println("---2, dt: ", dt) + if IsRealmPath(dt.PkgPath) { + pkgId = PkgIDFromPkgPath(dt.PkgPath) + } } + fmt.Println("---pkgId; ", pkgId) } - fmt.Println("---pkgId; ", pkgId) + return + case *MapValue, *StructValue: + if dt, ok := tv.T.(*DeclaredType); ok { + fmt.Printf("---dt: %v\n", dt) + fmt.Println("---dt.base: ", dt.Base) + if _, ok := dt.Base.(*FuncType); !ok { + fmt.Println("---dt.base.PkgPath: ", dt.Base.GetPkgPath()) + if IsRealmPath(dt.Base.GetPkgPath()) { + pkgId = PkgIDFromPkgPath(dt.Base.GetPkgPath()) + } + } + } + return + default: + // do nothing } - return - default: - return } + return } diff --git a/gnovm/pkg/gnolang/realm.go b/gnovm/pkg/gnolang/realm.go index a4b62601a13..7605877caac 100644 --- a/gnovm/pkg/gnolang/realm.go +++ b/gnovm/pkg/gnolang/realm.go @@ -221,7 +221,6 @@ func (rlm *Realm) DidUpdate2(store Store, po, xo, co Object, refValue Value) { } if refValue != nil { - fmt.Printf("---SetIsRef, co: %v\n", co) co.SetIsRef(true) } @@ -252,8 +251,7 @@ func (rlm *Realm) DidUpdate2(store Store, po, xo, co Object, refValue Value) { co.IncRefCount() fmt.Println("---after inc, co.GetRefCount: ", co.GetRefCount()) if co.GetRefCount() > 1 { - if co.GetIsEscaped() { // XXX, this implies attached? - // XXX, why packageBlock is automatically escaped? + if co.GetIsEscaped() { println("---already escaped, should check cross realm?") // already escaped rlm.MarkNewEscapedCheckCrossRealm(store, co, refValue) @@ -282,31 +280,21 @@ func (rlm *Realm) DidUpdate2(store Store, po, xo, co Object, refValue Value) { //---------------------------------------- // mark* -// oo can can be base of the originType, like array for a slice type. -// originType may contain infos like len, cap for slice type, etc. -// XXX, oo coming here must be referenced type, since they already escaped. +// XXX, oo here must be referenced type, since they already escaped. // XXX, so oo has been persisted, thus fillValueTV func checkCrossRealm(store Store, oo Object, refValue Value) { - fmt.Println("---checkCrossRealm, oo: ", oo) + debug2.Println2("checkCrossRealm, oo: ", oo, reflect.TypeOf(oo)) switch v := oo.(type) { case *StructValue: - fmt.Println("---StructValue...") - fmt.Println("---sv: ", v) + // TODO: rm this if !v.GetIsReal() { panic(fmt.Sprintf("should not happen, %v is not real\n", v)) } - fmt.Println("---sv is real, check fields") // check fields for _, fv := range v.Fields { - fmt.Println("---fv: ", fv) - fmt.Println("---type of fv: ", reflect.TypeOf(fv.V)) - // XXX, consider this - //if _, ok := fv.V.(RefValue); !ok { - // panic("---sv is not ref value!!!") - //} + debug2.Println2("fv: ", fv) rfv := fillValueTV(store, &fv) - fmt.Println("---rfv: ", rfv) - fmt.Println("---type of rfv.V: ", reflect.TypeOf(rfv.V)) + debug2.Println2("---rfv: ", rfv) if fo, ok := rfv.V.(Object); ok { checkCrossRealm(store, fo, nil) @@ -317,7 +305,12 @@ func checkCrossRealm(store Store, oo Object, refValue Value) { refValue = rv // TODO: consider pkgId here, A -> B - > A?... // yes, check PkgId per object - reo, _ = rfv.GetFirstObject2(store) + var pkgId PkgID + reo, pkgId = rfv.GetFirstObject2(store) + // TODO: simplify + if !pkgId.IsZero() { + reo.SetOriginRealm(pkgId) + } fmt.Println("---reo: ", reo) // XXX, if elem of array is slice?, GetFirstObject2?... checkCrossRealm(store, reo, refValue) @@ -326,7 +319,7 @@ func checkCrossRealm(store Store, oo Object, refValue Value) { } case *MapValue: println("---mapValue...") - // TODO: check elem? NO. + // TODO: check elem? case *HeapItemValue: fmt.Println("---heapItemValue: ", v) r := fillValueTV(store, &v.Value) @@ -339,18 +332,20 @@ func checkCrossRealm(store Store, oo Object, refValue Value) { } else { offset := sv.Offset length := sv.Length - fmt.Println("---ArrayValue: ", v) - fmt.Printf("---offset: %d, length: %d \n", offset, length) - fmt.Println("---escaped array, check if elements are real") + debug2.Println2("ArrayValue: ", v) + debug2.Printf2("offset: %d, length: %d \n", offset, length) + debug2.Println2("escaped array, check if elements are real") + // check referenced elem for i := offset; i < length; i++ { // XXX, difference between them? ee := oo.(*ArrayValue).List[i] e := fillValueTV(store, &ee) - //e := oo.(*ArrayValue).GetPointerAtIndexInt2(store, i, nil).Deref() + fmt.Printf("---e[%d]: %v\n", i, e) fmt.Printf("---type of e[%d].V: %v\n", i, reflect.TypeOf(e.V)) + if eo, ok := e.V.(Object); ok { checkCrossRealm(store, eo, nil) } else { // reference to object @@ -359,9 +354,12 @@ func checkCrossRealm(store Store, oo Object, refValue Value) { case *SliceValue, PointerValue: // if reference object from external realm refValue = rv // TODO: consider pkgId here, A -> B - > A?... - // yes, check PkgId per object - reo, _ = e.GetFirstObject2(store) - fmt.Println("---reo: ", reo) + var pkgId PkgID + reo, pkgId = e.GetFirstObject2(store) + // TODO: simplify + if !pkgId.IsZero() { + reo.SetOriginRealm(pkgId) + } // XXX, if elem of array is slice?, GetFirstObject2?... checkCrossRealm(store, reo, refValue) } @@ -375,19 +373,20 @@ func checkCrossRealm(store Store, oo Object, refValue Value) { // escaped realm should be reference object func (rlm *Realm) MarkNewEscapedCheckCrossRealm(store Store, oo Object, refValue Value) { - fmt.Println("---MarkNewEscapedCheckCrossRealm") - fmt.Println("---refValue: ", refValue) - //fmt.Println("---rlm.ID: ", rlm.ID) - //fmt.Println("---oo.GetRefCount(): ", oo.GetRefCount()) - //fmt.Println("---oo.lastNewRealEscapedRealm: ", oo.GetLastNewEscapedRealm()) - //fmt.Println("---oo.GetIsReal: ", oo.GetIsReal()) + debug2.Println2("MarkNewEscapedCheckCrossRealm") + debug2.Println2("---refValue: ", refValue) + + // mark escaped + if !oo.GetIsEscaped() { + rlm.MarkNewEscaped(oo) + } if oo.GetOriginRealm() == rlm.ID { return } - fmt.Println("---oo.GetLastNewEscapedRealm(): ", oo.GetOriginRealm()) - fmt.Println("---rlm.ID: ", rlm.ID) + debug2.Println2("---oo.GetLastNewEscapedRealm(): ", oo.GetOriginRealm()) + debug2.Println2("---rlm.ID: ", rlm.ID) if oo.GetOriginRealm() != rlm.ID { // crossing realm if refValue != nil { // is reference object from external realm checkCrossRealm(store, oo, refValue) @@ -395,10 +394,6 @@ func (rlm *Realm) MarkNewEscapedCheckCrossRealm(store Store, oo Object, refValue panic("cannot attach objects by value from external realm") } } - - if !oo.GetIsEscaped() { - rlm.MarkNewEscaped(oo) - } } func (rlm *Realm) MarkNewReal(oo Object) { @@ -615,11 +610,9 @@ func (rlm *Realm) processNewCreatedMarks(store Store) { // oo must be marked new-real, and ref-count already incremented. func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { - //fmt.Println("---incRefCreatedDescendants, rlm.ID: ", rlm.ID) fmt.Println("---incRefCreatedDescendants from oo: ", oo) fmt.Println("---oo.GetOriginRealm: ", oo.GetOriginRealm()) fmt.Println("---oo.GetRefCount: ", oo.GetRefCount()) - //fmt.Println("---incRefCreatedDescendants, oo.GetObjectID: ", oo.GetObjectID()) if debug { if oo.GetIsDirty() { @@ -634,8 +627,6 @@ func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { // if it's reference, all right fmt.Println("---oo.GetIsRef: ", oo.GetIsRef()) if !oo.GetOriginRealm().IsZero() && oo.GetOriginRealm() != rlm.ID { - //fmt.Println("---oo.GetLastNewEscapedRealm: ", oo.GetLastNewEscapedRealm()) - //fmt.Println("---rlm.ID: ", rlm.ID) if oo.GetIsRef() { panic("cannot attach a reference to an unreal object from an external realm") } else { @@ -656,11 +647,8 @@ func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { // recurse for children. more := getChildObjects2(store, oo) - //fmt.Println("---incRefCreatedDescendants, more: ", more) - //fmt.Println("---len of more: ", len(more)) for _, child := range more { - //fmt.Printf("---[%d]child: %v, type of child: %v \n", i, child, reflect.TypeOf(child)) - //fmt.Printf("---child addr: %p\n", child) + //debug2.Printf2("---[%d]child: %v, type of child: %v \n", i, child, reflect.TypeOf(child)) if _, ok := child.(*PackageValue); ok { if debug { if child.GetRefCount() < 1 { @@ -680,7 +668,6 @@ func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { child.SetOwner(oo) rlm.MarkDirty(child) } else { - //fmt.Println("---child NOT real, child: ", child) // a (possibly pre-existing) new object // became real (again). // NOTE: may already be marked for first gen @@ -693,7 +680,6 @@ func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { } } else if rc > 1 { if child.GetIsEscaped() { - //fmt.Println("---child is escaped, child: ", child) // already escaped, do nothing. } else { // NOTE: do not unset owner here, diff --git a/gnovm/pkg/gnolang/uverse.go b/gnovm/pkg/gnolang/uverse.go index b13bd1a4317..525374ea4b1 100644 --- a/gnovm/pkg/gnolang/uverse.go +++ b/gnovm/pkg/gnolang/uverse.go @@ -303,6 +303,7 @@ func UverseNode() *PackageNode { newElem := arg1Base.List[arg1Offset+i].unrefCopy(m.Alloc, m.Store) list[arg0Offset+arg0Length+i] = newElem + // TODO: xxx // XXX, DidUpdate2? m.Realm.DidUpdate( arg0Base, diff --git a/gnovm/pkg/gnolang/values.go b/gnovm/pkg/gnolang/values.go index 9951a4fb6a7..b091ecda405 100644 --- a/gnovm/pkg/gnolang/values.go +++ b/gnovm/pkg/gnolang/values.go @@ -211,8 +211,10 @@ func (pv *PointerValue) GetBase(store Store) Object { // TODO: document as something that enables into-native assignment. // TODO: maybe consider this as entrypoint for DataByteValue too? func (pv PointerValue) Assign2(alloc *Allocator, store Store, rlm *Realm, tv2 TypedValue, cu bool) { - fmt.Println("---Assign2, pv: ", pv) - fmt.Println("---tv2: ", tv2) + debug2.Println2("Assign2, pv: ", pv) + debug2.Println2("tv2: ", tv2) + debug2.Printf2("addr of tv2: %p \n", &tv2) + // Special cases. if pv.Index == PointerIndexNative { // Special case if extended object && native. @@ -287,21 +289,25 @@ func (pv PointerValue) Assign2(alloc *Allocator, store Store, rlm *Realm, tv2 Ty if rlm != nil && pv.Base != nil { oo1 := pv.TV.GetFirstObject(store) fmt.Println("---oo1: ", oo1) + + // get origin pkgId + _, pkgId := tv2.GetFirstObject2(store) + debug2.Println2("pkgId ", pkgId) + pv.TV.Assign(alloc, tv2, cu) - oo2, pkgId := pv.TV.GetFirstObject2(store) + oo2 := pv.TV.GetFirstObject(store) // TODO: move to GetFirstObject2 var refValue Value switch rv := pv.TV.V.(type) { case *SliceValue, PointerValue: refValue = rv } - fmt.Println("---oo2: ", oo2) - fmt.Println("---oo2 pkgId: ", pkgId) - if oo2 != nil { // cross realm + debug2.Println2("oo2: ", oo2) + debug2.Println2("pkgId: ", pkgId) + if oo2 != nil && !pkgId.IsZero() { // cross realm oo2.SetOriginRealm(pkgId) // attach origin package info } - // TODO: make check happens in here? rlm.DidUpdate2(store, pv.Base.(Object), oo1, oo2, refValue) } else { pv.TV.Assign(alloc, tv2, cu) @@ -400,6 +406,7 @@ func (av *ArrayValue) GetPointerAtIndexInt2(store Store, ii int, et Type) Pointe } func (av *ArrayValue) Copy(alloc *Allocator) *ArrayValue { + debug2.Println2("Array copy, av: ", av) /* TODO: consider second ref count field. if av.GetRefCount() == 0 { return av @@ -1046,7 +1053,8 @@ func (tv *TypedValue) ClearNum() { } func (tv TypedValue) Copy(alloc *Allocator) (cp TypedValue) { - //fmt.Println("---Copy, type of tv.V: ", reflect.TypeOf(tv.V)) + debug2.Println2("Copy, tv: ", tv) + debug2.Println2("Copy, type of tv.V: ", reflect.TypeOf(tv.V)) switch cv := tv.V.(type) { case BigintValue: cp.T = tv.T @@ -1699,6 +1707,7 @@ func (tv *TypedValue) ComputeMapKey(store Store, omitType bool) MapKey { // cu: convert untyped after assignment. pass false // for const definitions, but true for all else. func (tv *TypedValue) Assign(alloc *Allocator, tv2 TypedValue, cu bool) { + debug2.Println2("Assign, tv2: ", tv2) if debug { if tv.T == DataByteType { // assignment to data byte types should only diff --git a/gnovm/tests/files/zrealm_crossrealm24.gno b/gnovm/tests/files/zrealm_crossrealm24.gno index 9b46421f253..00cd3942254 100644 --- a/gnovm/tests/files/zrealm_crossrealm24.gno +++ b/gnovm/tests/files/zrealm_crossrealm24.gno @@ -44,7 +44,7 @@ func main() { // ], // "ObjectInfo": { // "ID": "5965ae851c02ab677bc8394b408535c1db9b2635:4", -// "ModTime": "10", +// "ModTime": "11", // "OwnerID": "5965ae851c02ab677bc8394b408535c1db9b2635:3", // "RefCount": "1" // } diff --git a/gnovm/tests/files/zrealm_crossrealm24d.gno b/gnovm/tests/files/zrealm_crossrealm24d.gno index 43d40d5b7a1..8103f13f80d 100644 --- a/gnovm/tests/files/zrealm_crossrealm24d.gno +++ b/gnovm/tests/files/zrealm_crossrealm24d.gno @@ -43,7 +43,7 @@ func main() { // ], // "ObjectInfo": { // "ID": "5965ae851c02ab677bc8394b408535c1db9b2635:4", -// "ModTime": "10", +// "ModTime": "11", // "OwnerID": "5965ae851c02ab677bc8394b408535c1db9b2635:3", // "RefCount": "1" // } diff --git a/gnovm/tests/files/zrealm_crossrealm24e.gno b/gnovm/tests/files/zrealm_crossrealm24e.gno new file mode 100644 index 00000000000..ce98a25eac7 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm24e.gno @@ -0,0 +1,18 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + crossrealm "gno.land/r/demo/tests/crossrealm/struct" +) + +// TODO: should panic at once +// var b0 crossrealm.Bar = crossrealm.Bar3 +var root interface{} + +func main() { + root = crossrealm.Bar3 + println("ok") +} + +// Error: +// cannot attach objects by value from external realm diff --git a/gnovm/tests/files/zrealm_crossrealm32.gno b/gnovm/tests/files/zrealm_crossrealm32.gno index e8ec8b0e2a7..3ebceef83de 100644 --- a/gnovm/tests/files/zrealm_crossrealm32.gno +++ b/gnovm/tests/files/zrealm_crossrealm32.gno @@ -19,7 +19,7 @@ func main() { // Realm: // switchrealm["gno.land/r/demo/tests/crossrealm/slice"] -// c[ff34c6500d0daee58e4ac9899c0e7ecc131db63e:25]={ +// c[ff34c6500d0daee58e4ac9899c0e7ecc131db63e:26]={ // "Fields": [ // { // "T": { @@ -33,13 +33,13 @@ func main() { // } // ], // "ObjectInfo": { -// "ID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:25", +// "ID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:26", // "ModTime": "0", -// "OwnerID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:24", +// "OwnerID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:25", // "RefCount": "1" // } // } -// c[ff34c6500d0daee58e4ac9899c0e7ecc131db63e:24]={ +// c[ff34c6500d0daee58e4ac9899c0e7ecc131db63e:25]={ // "Data": null, // "List": [ // { @@ -50,7 +50,7 @@ func main() { // "V": { // "@type": "/gno.RefValue", // "Escaped": true, -// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:14" +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:15" // } // }, // { @@ -60,13 +60,13 @@ func main() { // }, // "V": { // "@type": "/gno.RefValue", -// "Hash": "d0a7406378470009aced840189d7ac80419e2b2b", -// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:25" +// "Hash": "14593ec2b92fe8a53780cf8a6c430a6526f05283", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:26" // } // } // ], // "ObjectInfo": { -// "ID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:24", +// "ID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:25", // "ModTime": "0", // "OwnerID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:2", // "RefCount": "1" @@ -77,7 +77,7 @@ func main() { // "ObjectInfo": { // "ID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:2", // "IsEscaped": true, -// "ModTime": "23", +// "ModTime": "24", // "RefCount": "2" // }, // "Parent": null, @@ -172,7 +172,7 @@ func main() { // "Location": { // "Column": "1", // "File": "crossrealm_slice.gno", -// "Line": "7", +// "Line": "9", // "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, @@ -239,8 +239,8 @@ func main() { // "@type": "/gno.SliceValue", // "Base": { // "@type": "/gno.RefValue", -// "Hash": "1b66d81a105bccbb2c1cb48b5826de001451c4f4", -// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:10" +// "Hash": "0934dceb3731dd613f35a5e4a4a82396f3dc474e", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:11" // }, // "Length": "2", // "Maxcap": "2", @@ -260,8 +260,8 @@ func main() { // "@type": "/gno.SliceValue", // "Base": { // "@type": "/gno.RefValue", -// "Hash": "4e2c5feb184ed4c3756c8662f4849b05e55b510a", -// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:24" +// "Hash": "51b5198111d9cdcf7c980e3816d111cfbe0b7cc4", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:25" // }, // "Length": "2", // "Maxcap": "2", @@ -281,8 +281,8 @@ func main() { // "@type": "/gno.SliceValue", // "Base": { // "@type": "/gno.RefValue", -// "Hash": "f6278e80ac84fd1944704d0ab55f4ba1b01e76f1", -// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:15" +// "Hash": "9073c630fa09e61b0e3b824056c022eebe7bd86b", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:16" // }, // "Length": "1", // "Maxcap": "1", @@ -305,8 +305,8 @@ func main() { // "@type": "/gno.SliceValue", // "Base": { // "@type": "/gno.RefValue", -// "Hash": "875dcfc247f2beb0db7a9556971202d5f83953a7", -// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:17" +// "Hash": "088eb6ee7e7fe1c5e10101801be9e64ac6794e29", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:18" // }, // "Length": "1", // "Maxcap": "1", @@ -329,7 +329,7 @@ func main() { // "@type": "/gno.SliceValue", // "Base": { // "@type": "/gno.RefValue", -// "Hash": "df881fbce43e93be6a59fa06c45b5b9959c2d597", +// "Hash": "3450ddb4764c2026edd313f230c633e0af6cd8ed", // "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:4" // }, // "Length": "2", @@ -349,7 +349,7 @@ func main() { // }, // "V": { // "@type": "/gno.RefValue", -// "Hash": "719153550186d4f8347763b1c1ffcbb9b62a967f", +// "Hash": "e03c7067902bb4b3c2aa477a27d6abfcd51ce3a6", // "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:5" // } // }, @@ -378,7 +378,7 @@ func main() { // "Location": { // "Column": "1", // "File": "crossrealm_slice.gno", -// "Line": "25", +// "Line": "27", // "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, @@ -428,7 +428,7 @@ func main() { // "Location": { // "Column": "1", // "File": "crossrealm_slice.gno", -// "Line": "40", +// "Line": "42", // "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, @@ -514,7 +514,7 @@ func main() { // "Location": { // "Column": "1", // "File": "crossrealm_slice.gno", -// "Line": "48", +// "Line": "50", // "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, @@ -578,7 +578,7 @@ func main() { // "Location": { // "Column": "1", // "File": "crossrealm_slice.gno", -// "Line": "56", +// "Line": "58", // "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, @@ -653,7 +653,7 @@ func main() { // "Location": { // "Column": "1", // "File": "crossrealm_slice.gno", -// "Line": "61", +// "Line": "63", // "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, @@ -731,7 +731,7 @@ func main() { // "Location": { // "Column": "1", // "File": "crossrealm_slice.gno", -// "Line": "66", +// "Line": "68", // "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, @@ -812,7 +812,7 @@ func main() { // "Location": { // "Column": "1", // "File": "crossrealm_slice.gno", -// "Line": "70", +// "Line": "72", // "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, @@ -902,7 +902,7 @@ func main() { // "Location": { // "Column": "1", // "File": "crossrealm_slice.gno", -// "Line": "75", +// "Line": "77", // "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, @@ -938,11 +938,199 @@ func main() { // "Results": [] // } // } +// }, +// { +// "T": { +// "@type": "/gno.ArrayType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/tests/p_crossrealm.Stringer" +// }, +// "Len": "1", +// "Vrd": false +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "ed9761e4c90097cbcf3d55a627ab1b7c65ff8a62", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:10" +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/tests/p_crossrealm.Stringer" +// } +// } +// ], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.ArrayType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/tests/p_crossrealm.Stringer" +// }, +// "Len": "1", +// "Vrd": false +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:3" +// }, +// "FileName": "crossrealm_slice.gno", +// "IsMethod": false, +// "Name": "GetSlice8", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_slice.gno", +// "Line": "84", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/tests/p_crossrealm.Stringer" +// } +// } +// ], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.ArrayType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/tests/p_crossrealm.Stringer" +// }, +// "Len": "1", +// "Vrd": false +// } +// } +// ] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/tests/p_crossrealm.Stringer" +// } +// } +// ], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.ArrayType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/tests/p_crossrealm.Stringer" +// }, +// "Len": "1", +// "Vrd": false +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:3" +// }, +// "FileName": "crossrealm_slice.gno", +// "IsMethod": false, +// "Name": "GetSlice9", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_slice.gno", +// "Line": "89", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/tests/p_crossrealm.Stringer" +// } +// } +// ], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.ArrayType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/tests/p_crossrealm.Stringer" +// }, +// "Len": "1", +// "Vrd": false +// } +// } +// ] +// } +// } // } // ] // } -// d[ff34c6500d0daee58e4ac9899c0e7ecc131db63e:13] // d[ff34c6500d0daee58e4ac9899c0e7ecc131db63e:14] +// d[ff34c6500d0daee58e4ac9899c0e7ecc131db63e:15] // switchrealm["gno.land/r/crossrealm_test"] // u[f5a516808f8976c33939133293d598ce3bca4e8d:2]={ // "Blank": {}, @@ -978,7 +1166,7 @@ func main() { // "Base": { // "@type": "/gno.RefValue", // "Escaped": true, -// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:24" +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:25" // }, // "Length": "2", // "Maxcap": "2", @@ -1123,7 +1311,7 @@ func main() { // "Location": { // "Column": "1", // "File": "crossrealm_slice.gno", -// "Line": "7", +// "Line": "9", // "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, @@ -1190,8 +1378,8 @@ func main() { // "@type": "/gno.SliceValue", // "Base": { // "@type": "/gno.RefValue", -// "Hash": "1b66d81a105bccbb2c1cb48b5826de001451c4f4", -// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:10" +// "Hash": "0934dceb3731dd613f35a5e4a4a82396f3dc474e", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:11" // }, // "Length": "2", // "Maxcap": "2", @@ -1212,7 +1400,7 @@ func main() { // "Base": { // "@type": "/gno.RefValue", // "Escaped": true, -// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:24" +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:25" // }, // "Length": "2", // "Maxcap": "2", @@ -1232,8 +1420,8 @@ func main() { // "@type": "/gno.SliceValue", // "Base": { // "@type": "/gno.RefValue", -// "Hash": "f6278e80ac84fd1944704d0ab55f4ba1b01e76f1", -// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:15" +// "Hash": "9073c630fa09e61b0e3b824056c022eebe7bd86b", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:16" // }, // "Length": "1", // "Maxcap": "1", @@ -1256,8 +1444,8 @@ func main() { // "@type": "/gno.SliceValue", // "Base": { // "@type": "/gno.RefValue", -// "Hash": "875dcfc247f2beb0db7a9556971202d5f83953a7", -// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:17" +// "Hash": "088eb6ee7e7fe1c5e10101801be9e64ac6794e29", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:18" // }, // "Length": "1", // "Maxcap": "1", @@ -1280,7 +1468,7 @@ func main() { // "@type": "/gno.SliceValue", // "Base": { // "@type": "/gno.RefValue", -// "Hash": "df881fbce43e93be6a59fa06c45b5b9959c2d597", +// "Hash": "3450ddb4764c2026edd313f230c633e0af6cd8ed", // "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:4" // }, // "Length": "2", @@ -1300,7 +1488,7 @@ func main() { // }, // "V": { // "@type": "/gno.RefValue", -// "Hash": "719153550186d4f8347763b1c1ffcbb9b62a967f", +// "Hash": "e03c7067902bb4b3c2aa477a27d6abfcd51ce3a6", // "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:5" // } // }, @@ -1329,7 +1517,7 @@ func main() { // "Location": { // "Column": "1", // "File": "crossrealm_slice.gno", -// "Line": "25", +// "Line": "27", // "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, @@ -1379,7 +1567,7 @@ func main() { // "Location": { // "Column": "1", // "File": "crossrealm_slice.gno", -// "Line": "40", +// "Line": "42", // "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, @@ -1465,7 +1653,7 @@ func main() { // "Location": { // "Column": "1", // "File": "crossrealm_slice.gno", -// "Line": "48", +// "Line": "50", // "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, @@ -1529,7 +1717,7 @@ func main() { // "Location": { // "Column": "1", // "File": "crossrealm_slice.gno", -// "Line": "56", +// "Line": "58", // "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, @@ -1604,7 +1792,7 @@ func main() { // "Location": { // "Column": "1", // "File": "crossrealm_slice.gno", -// "Line": "61", +// "Line": "63", // "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, @@ -1682,7 +1870,7 @@ func main() { // "Location": { // "Column": "1", // "File": "crossrealm_slice.gno", -// "Line": "66", +// "Line": "68", // "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, @@ -1763,7 +1951,7 @@ func main() { // "Location": { // "Column": "1", // "File": "crossrealm_slice.gno", -// "Line": "70", +// "Line": "72", // "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, @@ -1853,7 +2041,7 @@ func main() { // "Location": { // "Column": "1", // "File": "crossrealm_slice.gno", -// "Line": "75", +// "Line": "77", // "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, @@ -1889,6 +2077,194 @@ func main() { // "Results": [] // } // } +// }, +// { +// "T": { +// "@type": "/gno.ArrayType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/tests/p_crossrealm.Stringer" +// }, +// "Len": "1", +// "Vrd": false +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "ed9761e4c90097cbcf3d55a627ab1b7c65ff8a62", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:10" +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/tests/p_crossrealm.Stringer" +// } +// } +// ], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.ArrayType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/tests/p_crossrealm.Stringer" +// }, +// "Len": "1", +// "Vrd": false +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:3" +// }, +// "FileName": "crossrealm_slice.gno", +// "IsMethod": false, +// "Name": "GetSlice8", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_slice.gno", +// "Line": "84", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/tests/p_crossrealm.Stringer" +// } +// } +// ], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.ArrayType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/tests/p_crossrealm.Stringer" +// }, +// "Len": "1", +// "Vrd": false +// } +// } +// ] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/tests/p_crossrealm.Stringer" +// } +// } +// ], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.ArrayType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/tests/p_crossrealm.Stringer" +// }, +// "Len": "1", +// "Vrd": false +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:3" +// }, +// "FileName": "crossrealm_slice.gno", +// "IsMethod": false, +// "Name": "GetSlice9", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "crossrealm_slice.gno", +// "Line": "89", +// "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "f", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/tests/p_crossrealm.Stringer" +// } +// } +// ], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.ArrayType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/tests/p_crossrealm.Stringer" +// }, +// "Len": "1", +// "Vrd": false +// } +// } +// ] +// } +// } // } // ] // } diff --git a/gnovm/tests/files/zrealm_crossrealm34.gno b/gnovm/tests/files/zrealm_crossrealm34.gno index bee619ecbcb..0875ef6a92a 100644 --- a/gnovm/tests/files/zrealm_crossrealm34.gno +++ b/gnovm/tests/files/zrealm_crossrealm34.gno @@ -57,7 +57,7 @@ func main() { // "Base": { // "@type": "/gno.RefValue", // "Escaped": true, -// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:17" +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:18" // }, // "Length": "1", // "Maxcap": "1", diff --git a/gnovm/tests/files/zrealm_crossrealm35.gno b/gnovm/tests/files/zrealm_crossrealm35.gno new file mode 100644 index 00000000000..d187ea285bc --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm35.gno @@ -0,0 +1,26 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "std" + + crossrealm "gno.land/r/demo/tests/crossrealm/slice" +) + +type foo struct { + name string +} + +func (*foo) String() string { return std.CurrentRealm().PkgPath() } + +var f = &foo{"foo"} + +var arr interface{} + +func main() { + arr = crossrealm.GetSlice8(f) + println(".") +} + +// Error: +// cannot attach a value of a type defined by another realm diff --git a/gnovm/tests/files/zrealm_crossrealm35a.gno b/gnovm/tests/files/zrealm_crossrealm35a.gno new file mode 100644 index 00000000000..425308042fd --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm35a.gno @@ -0,0 +1,261 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "std" + + crossrealm "gno.land/r/demo/tests/crossrealm/slice" +) + +type foo struct { + name string +} + +func (*foo) String() string { return std.CurrentRealm().PkgPath() } + +var f = &foo{"foo"} + +var arr interface{} + +func main() { + arr = crossrealm.GetSlice9(f) + println(".") +} + +// Output: +// . + +// Realm: +// switchrealm["gno.land/r/demo/tests/crossrealm/slice"] +// switchrealm["gno.land/r/crossrealm_test"] +// c[f5a516808f8976c33939133293d598ce3bca4e8d:6]={ +// "Data": null, +// "List": [ +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/crossrealm_test.foo" +// } +// }, +// "V": { +// "@type": "/gno.PointerValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "f5a516808f8976c33939133293d598ce3bca4e8d:3" +// }, +// "Index": "0", +// "TV": null +// } +// } +// ], +// "ObjectInfo": { +// "ID": "f5a516808f8976c33939133293d598ce3bca4e8d:6", +// "ModTime": "0", +// "OwnerID": "f5a516808f8976c33939133293d598ce3bca4e8d:2", +// "RefCount": "1" +// } +// } +// u[f5a516808f8976c33939133293d598ce3bca4e8d:2]={ +// "Blank": {}, +// "ObjectInfo": { +// "ID": "f5a516808f8976c33939133293d598ce3bca4e8d:2", +// "IsEscaped": true, +// "ModTime": "5", +// "RefCount": "2" +// }, +// "Parent": null, +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "0", +// "File": "", +// "Line": "0", +// "PkgPath": "gno.land/r/crossrealm_test" +// } +// }, +// "Values": [ +// { +// "T": { +// "@type": "/gno.TypeType" +// }, +// "V": { +// "@type": "/gno.TypeValue", +// "Type": { +// "@type": "/gno.DeclaredType", +// "Base": { +// "@type": "/gno.StructType", +// "Fields": [ +// { +// "Embedded": false, +// "Name": "name", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// } +// ], +// "PkgPath": "gno.land/r/crossrealm_test" +// }, +// "Methods": [ +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": ".recv", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/crossrealm_test.foo" +// } +// } +// } +// ], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": null, +// "FileName": "main.gno", +// "IsMethod": true, +// "Name": "String", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/crossrealm_test", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "main.gno", +// "Line": "14", +// "PkgPath": "gno.land/r/crossrealm_test" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": ".recv", +// "Tag": "", +// "Type": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/crossrealm_test.foo" +// } +// } +// } +// ], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// } +// } +// ] +// } +// } +// } +// ], +// "Name": "foo", +// "PkgPath": "gno.land/r/crossrealm_test" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/crossrealm_test.foo" +// } +// }, +// "V": { +// "@type": "/gno.PointerValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "f5a516808f8976c33939133293d598ce3bca4e8d:3" +// }, +// "Index": "0", +// "TV": null +// } +// }, +// { +// "T": { +// "@type": "/gno.ArrayType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/p/demo/tests/p_crossrealm.Stringer" +// }, +// "Len": "1", +// "Vrd": false +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "2dcefa704545dfed35968f0cca05d38a6a01caf5", +// "ObjectID": "f5a516808f8976c33939133293d598ce3bca4e8d:6" +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "f5a516808f8976c33939133293d598ce3bca4e8d:5" +// }, +// "FileName": "main.gno", +// "IsMethod": false, +// "Name": "main", +// "NativeName": "", +// "NativePkg": "", +// "PkgPath": "gno.land/r/crossrealm_test", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "Column": "1", +// "File": "main.gno", +// "Line": "20", +// "PkgPath": "gno.land/r/crossrealm_test" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// } +// } +// } +// ] +// } From 30883f08a030bb0008b73fc94511442cb4dda0b9 Mon Sep 17 00:00:00 2001 From: ltzMaxwell Date: Sat, 4 Jan 2025 23:25:48 +0800 Subject: [PATCH 37/40] debug --- examples/gno.land/p/demo/tests/tests.gno | 74 ---------------- examples/gno.land/p/demo/tests/tests2.gno | 5 ++ .../crossrealm/slice/crossrealm_slice.gno | 10 ++- .../slice/crossrealm_slice.gno.bak2 | 14 +++ .../crossrealm/struct/crossrealm_struct.gno | 8 ++ gnovm/pkg/gnolang/machine.go | 14 ++- gnovm/pkg/gnolang/op_call.go | 3 +- gnovm/pkg/gnolang/ownership.go | 12 ++- gnovm/pkg/gnolang/realm.go | 87 ++++++++++++------- gnovm/pkg/gnolang/uverse.go | 6 ++ gnovm/pkg/gnolang/values.go | 22 ++++- gnovm/tests/files/zrealm_crossrealm24.gno | 2 +- gnovm/tests/files/zrealm_crossrealm24d.gno | 2 +- gnovm/tests/files/zrealm_crossrealm24e.gno | 2 +- gnovm/tests/files/zrealm_crossrealm24f.gno | 16 ++++ gnovm/tests/files/zrealm_crossrealm24g.gno | 15 ++++ gnovm/tests/files/zrealm_crossrealm25.gno | 2 +- gnovm/tests/files/zrealm_crossrealm25c.gno | 2 +- gnovm/tests/files/zrealm_crossrealm25d.gno | 2 +- gnovm/tests/files/zrealm_crossrealm25e.gno | 2 +- gnovm/tests/files/zrealm_crossrealm25f.gno | 28 ++++++ gnovm/tests/files/zrealm_crossrealm32.gno | 32 +++++-- gnovm/tests/files/zrealm_crossrealm33.gno | 2 +- gnovm/tests/files/zrealm_crossrealm36.gno | 2 +- gnovm/tests/files/zrealm_crossrealm36a.gno | 17 ++++ 25 files changed, 250 insertions(+), 131 deletions(-) delete mode 100644 examples/gno.land/p/demo/tests/tests.gno create mode 100644 examples/gno.land/p/demo/tests/tests2.gno create mode 100644 examples/gno.land/r/demo/tests/crossrealm/slice/crossrealm_slice.gno.bak2 create mode 100644 gnovm/tests/files/zrealm_crossrealm24f.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm24g.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm25f.gno create mode 100644 gnovm/tests/files/zrealm_crossrealm36a.gno diff --git a/examples/gno.land/p/demo/tests/tests.gno b/examples/gno.land/p/demo/tests/tests.gno deleted file mode 100644 index 43732d82dac..00000000000 --- a/examples/gno.land/p/demo/tests/tests.gno +++ /dev/null @@ -1,74 +0,0 @@ -package tests - -import ( - "std" - - psubtests "gno.land/p/demo/tests/subtests" - "gno.land/r/demo/tests" - rtests "gno.land/r/demo/tests" -) - -const World = "world" - -// IncCounter demonstrates that it's possible to call a realm function from -// a package. So a package can potentially write into the store, by calling -// an other realm. -func IncCounter() { - tests.IncCounter() -} - -func CurrentRealmPath() string { - return std.CurrentRealm().PkgPath() -} - -//---------------------------------------- -// cross realm test vars - -type TestRealmObject2 struct { - Field string -} - -func (o2 *TestRealmObject2) Modify() { - o2.Field = "modified" -} - -var ( - somevalue1 TestRealmObject2 - SomeValue2 TestRealmObject2 - SomeValue3 *TestRealmObject2 -) - -func init() { - somevalue1 = TestRealmObject2{Field: "init"} - SomeValue2 = TestRealmObject2{Field: "init"} - SomeValue3 = &TestRealmObject2{Field: "init"} -} - -func ModifyTestRealmObject2a() { - somevalue1.Field = "modified" -} - -func ModifyTestRealmObject2b() { - SomeValue2.Field = "modified" -} - -func ModifyTestRealmObject2c() { - SomeValue3.Field = "modified" -} - -func GetPrevRealm() std.Realm { - return std.PrevRealm() -} - -func GetPSubtestsPrevRealm() std.Realm { - return psubtests.GetPrevRealm() -} - -func GetRTestsGetPrevRealm() std.Realm { - return rtests.GetPrevRealm() -} - -// Warning: unsafe pattern. -func Exec(fn func()) { - fn() -} diff --git a/examples/gno.land/p/demo/tests/tests2.gno b/examples/gno.land/p/demo/tests/tests2.gno new file mode 100644 index 00000000000..eeb3fe0ffa5 --- /dev/null +++ b/examples/gno.land/p/demo/tests/tests2.gno @@ -0,0 +1,5 @@ +package tests + +type Foo struct{ name string } + +var F = Foo{"p"} diff --git a/examples/gno.land/r/demo/tests/crossrealm/slice/crossrealm_slice.gno b/examples/gno.land/r/demo/tests/crossrealm/slice/crossrealm_slice.gno index 4185d8c020d..446ff265ab4 100644 --- a/examples/gno.land/r/demo/tests/crossrealm/slice/crossrealm_slice.gno +++ b/examples/gno.land/r/demo/tests/crossrealm/slice/crossrealm_slice.gno @@ -18,7 +18,12 @@ type XYZ struct{ name string } var s1 []XYZ var s3 []XYZ -var s4 []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) @@ -29,7 +34,8 @@ func init() { s1 = append(s1, XYZ{"2"}) s3 = append(s3, XYZ{"3"}) - s4 = append(s4, XYZ{"4"}) + //s4 = append(s4, XYZ{"4"}) + s4[0] = XYZ{"4"} s5 = append(s5, &XYZ{"5"}) diff --git a/examples/gno.land/r/demo/tests/crossrealm/slice/crossrealm_slice.gno.bak2 b/examples/gno.land/r/demo/tests/crossrealm/slice/crossrealm_slice.gno.bak2 new file mode 100644 index 00000000000..48ef3dbdbc7 --- /dev/null +++ b/examples/gno.land/r/demo/tests/crossrealm/slice/crossrealm_slice.gno.bak2 @@ -0,0 +1,14 @@ +package crossrealm_slice + +type XYZ struct{ name string } + +var s4 = make([]XYZ, 1) + +func init() { + s4[0] = XYZ{"4"} // TODO; is it owned by array +} + +func GetSlice4(f func(s []XYZ)) { + s4 = append(s4, XYZ{"0"}) // this is real after this function + f(s4) // XYZ{"0"} is floating +} diff --git a/examples/gno.land/r/demo/tests/crossrealm/struct/crossrealm_struct.gno b/examples/gno.land/r/demo/tests/crossrealm/struct/crossrealm_struct.gno index 6f6e8cb798d..4a9fb22289e 100644 --- a/examples/gno.land/r/demo/tests/crossrealm/struct/crossrealm_struct.gno +++ b/examples/gno.land/r/demo/tests/crossrealm/struct/crossrealm_struct.gno @@ -63,3 +63,11 @@ func GetStruct(cb func(v *C)) *C { cb(c) return c } + +func GetStruct2(cb func(v *C)) *C { + var e = &C{} + e.A = a + e.B = b + cb(e) + return e +} diff --git a/gnovm/pkg/gnolang/machine.go b/gnovm/pkg/gnolang/machine.go index 1ee97a52775..5720766ca28 100644 --- a/gnovm/pkg/gnolang/machine.go +++ b/gnovm/pkg/gnolang/machine.go @@ -325,6 +325,9 @@ func (m *Machine) runMemPackage(memPkg *std.MemPackage, save, overrides bool) (* // store mempackage m.Store.AddMemPackage(memPkg) if throwaway != nil { + debug2.Println2("m.Realm: ", m.Realm) + debug2.Println2("m.Realm created: ", m.Realm.created) + debug2.Println2("m.Realm updated: ", m.Realm.updated) m.Realm = nil } } @@ -750,16 +753,18 @@ func (m *Machine) runInitFromUpdates(pv *PackageValue, updates []TypedValue) { // Returns a throwaway realm package is not a realm, // such as stdlibs or /p/ packages. func (m *Machine) saveNewPackageValuesAndTypes() (throwaway *Realm) { - //fmt.Println("---saveNewPackageValuesAndTypes") + debug2.Println2("saveNewPackageValuesAndTypes") // save package value and dependencies. pv := m.Package if pv.IsRealm() { + debug2.Println2("pv is realm") rlm := pv.Realm rlm.MarkNewReal(pv) rlm.FinalizeRealmTransaction(m.ReadOnly, m.Store) // save package realm info. m.Store.SetPackageRealm(rlm) } else { // use a throwaway realm. + debug2.Println2("pv not realm") rlm := NewRealm(pv.PkgPath) rlm.MarkNewReal(pv) rlm.FinalizeRealmTransaction(m.ReadOnly, m.Store) @@ -782,11 +787,12 @@ func (m *Machine) saveNewPackageValuesAndTypes() (throwaway *Realm) { // Pass in the realm from m.saveNewPackageValuesAndTypes() // in case a throwaway was created. func (m *Machine) resavePackageValues(rlm *Realm) { + debug2.Println2("resavePackageValues, rlm: ", rlm) // save package value and dependencies. pv := m.Package if pv.IsRealm() { rlm = pv.Realm - //fmt.Println("---rlm: ", rlm) + debug2.Println2("rlm.ID: ", rlm.ID) rlm.FinalizeRealmTransaction(m.ReadOnly, m.Store) // re-save package realm info. m.Store.SetPackageRealm(rlm) @@ -1849,9 +1855,9 @@ func (m *Machine) PushFrameBasic(s Stmt) { // ensure the counts are consistent, otherwise we mask // bugs with frame pops. func (m *Machine) PushFrameCall(cx *CallExpr, fv *FuncValue, recv TypedValue) { - //fmt.Println("---PushFrameCall, cx: ", cx) + debug2.Println2("PushFrameCall, cx: ", cx) //fmt.Println("---fv: ", fv) - //fmt.Println("---m.Realm: ", m.Realm) + debug2.Println2("m.Realm: ", m.Realm) fr := &Frame{ Source: cx, NumOps: m.NumOps, diff --git a/gnovm/pkg/gnolang/op_call.go b/gnovm/pkg/gnolang/op_call.go index d2e5c02df8d..c7cbe5e176d 100644 --- a/gnovm/pkg/gnolang/op_call.go +++ b/gnovm/pkg/gnolang/op_call.go @@ -202,7 +202,7 @@ func (m *Machine) doOpReturn() { finalize = true } if finalize { - debug2.Println2("finalizing") + debug2.Println2("doOpReturn, finalizing") // Finalize realm updates! // NOTE: This is a resource intensive undertaking. crlm.FinalizeRealmTransaction(m.ReadOnly, m.Store) @@ -239,6 +239,7 @@ func (m *Machine) doOpReturnFromBlock() { finalize = true } if finalize { + debug2.Println2("doOpReturnFromBlock, finalizing") // Finalize realm updates! // NOTE: This is a resource intensive undertaking. crlm.FinalizeRealmTransaction(m.ReadOnly, m.Store) diff --git a/gnovm/pkg/gnolang/ownership.go b/gnovm/pkg/gnolang/ownership.go index afed6aa0e8c..9c51d6ce76a 100644 --- a/gnovm/pkg/gnolang/ownership.go +++ b/gnovm/pkg/gnolang/ownership.go @@ -322,7 +322,7 @@ func (oi *ObjectInfo) GetOriginRealm() PkgID { } func (oi *ObjectInfo) SetOriginRealm(pkgId PkgID) { - fmt.Println("---SetLastNewEscapedRealm") + debug2.Println2("SetOriginRealm: ", pkgId) oi.lastNewRealEscapedRealm = pkgId } @@ -390,14 +390,22 @@ func (tv *TypedValue) GetFirstObject(store Store) Object { } // also get pkgId of the object, so it's clear where the object is from +// TODO, just return isRealm func (tv *TypedValue) GetFirstObject2(store Store) (obj Object, pkgId PkgID) { fmt.Println("---GetFirstObject2---, tv: ", tv, reflect.TypeOf(tv.V)) // get first object obj = tv.GetFirstObject(store) fmt.Println("---obj: ", obj) + if obj != nil { - pkgId = obj.GetObjectID().PkgID + + pkgId = obj.GetOriginRealm() + if pkgId.IsZero() { + pkgId = obj.GetObjectID().PkgID + } + debug2.Println2("obj.GetObjectInfo(): ", obj.GetObjectInfo()) + debug2.Println2("obj.GetObjectID.PkgID: ", pkgId) } if pkgId.IsZero() { diff --git a/gnovm/pkg/gnolang/realm.go b/gnovm/pkg/gnolang/realm.go index 7605877caac..5b8f43fcfc4 100644 --- a/gnovm/pkg/gnolang/realm.go +++ b/gnovm/pkg/gnolang/realm.go @@ -282,13 +282,26 @@ func (rlm *Realm) DidUpdate2(store Store, po, xo, co Object, refValue Value) { // XXX, oo here must be referenced type, since they already escaped. // XXX, so oo has been persisted, thus fillValueTV -func checkCrossRealm(store Store, oo Object, refValue Value) { +func checkCrossRealm(rlm *Realm, store Store, oo Object, refValue Value) { debug2.Println2("checkCrossRealm, oo: ", oo, reflect.TypeOf(oo)) + debug2.Println2("oo.GetRefCount: ", oo.GetRefCount()) + debug2.Println2("oo.GetObjectInfo: ", oo.GetObjectInfo()) switch v := oo.(type) { case *StructValue: - // TODO: rm this + + //debug2.Println2("oo.GetOriginRealm: ", oo.GetOriginRealm()) + //if refValue == nil { // not ref + // if rlm.ID != oo.GetOriginRealm() { + // panic("cannot attach object from external realm") + // } + //} + + // ref, check real + //if oo.GetObjectID().IsZero() { + //} + //// TODO: rm this if !v.GetIsReal() { - panic(fmt.Sprintf("should not happen, %v is not real\n", v)) + panic(fmt.Sprintf("cannot attach un-real object from external realm: %v", v)) } // check fields for _, fv := range v.Fields { @@ -297,7 +310,7 @@ func checkCrossRealm(store Store, oo Object, refValue Value) { debug2.Println2("---rfv: ", rfv) if fo, ok := rfv.V.(Object); ok { - checkCrossRealm(store, fo, nil) + checkCrossRealm(rlm, store, fo, nil) } else { // reference to object var reo Object switch rv := rfv.V.(type) { @@ -313,7 +326,7 @@ func checkCrossRealm(store Store, oo Object, refValue Value) { } fmt.Println("---reo: ", reo) // XXX, if elem of array is slice?, GetFirstObject2?... - checkCrossRealm(store, reo, refValue) + checkCrossRealm(rlm, store, reo, refValue) } } } @@ -325,7 +338,7 @@ func checkCrossRealm(store Store, oo Object, refValue Value) { r := fillValueTV(store, &v.Value) fmt.Println("---r: ", r) - checkCrossRealm(store, v.Value.V.(Object), refValue) + checkCrossRealm(rlm, store, v.Value.V.(Object), refValue) case *ArrayValue: if sv, ok := refValue.(*SliceValue); !ok { panic("should be slice value") @@ -339,15 +352,17 @@ func checkCrossRealm(store Store, oo Object, refValue Value) { // check referenced elem for i := offset; i < length; i++ { // XXX, difference between them? - ee := oo.(*ArrayValue).List[i] + ee := v.List[i] e := fillValueTV(store, &ee) //e := oo.(*ArrayValue).GetPointerAtIndexInt2(store, i, nil).Deref() fmt.Printf("---e[%d]: %v\n", i, e) fmt.Printf("---type of e[%d].V: %v\n", i, reflect.TypeOf(e.V)) + debug2.Println2("e...GetOriginRealm: ", e.V.(Object).GetOriginRealm()) + debug2.Println2("e....GetObjectInfo: ", e.V.(Object).GetObjectInfo()) if eo, ok := e.V.(Object); ok { - checkCrossRealm(store, eo, nil) + checkCrossRealm(rlm, store, eo, refValue) } else { // reference to object var reo Object switch rv := e.V.(type) { @@ -361,7 +376,7 @@ func checkCrossRealm(store Store, oo Object, refValue Value) { reo.SetOriginRealm(pkgId) } // XXX, if elem of array is slice?, GetFirstObject2?... - checkCrossRealm(store, reo, refValue) + checkCrossRealm(rlm, store, reo, refValue) } } } @@ -376,12 +391,10 @@ func (rlm *Realm) MarkNewEscapedCheckCrossRealm(store Store, oo Object, refValue debug2.Println2("MarkNewEscapedCheckCrossRealm") debug2.Println2("---refValue: ", refValue) - // mark escaped - if !oo.GetIsEscaped() { - rlm.MarkNewEscaped(oo) - } - if oo.GetOriginRealm() == rlm.ID { + //if !oo.GetIsEscaped() { + // rlm.MarkNewEscaped(oo) + //} return } @@ -389,14 +402,19 @@ func (rlm *Realm) MarkNewEscapedCheckCrossRealm(store Store, oo Object, refValue debug2.Println2("---rlm.ID: ", rlm.ID) if oo.GetOriginRealm() != rlm.ID { // crossing realm if refValue != nil { // is reference object from external realm - checkCrossRealm(store, oo, refValue) + checkCrossRealm(rlm, store, oo, refValue) } else { panic("cannot attach objects by value from external realm") } } + // mark escaped + if !oo.GetIsEscaped() { + rlm.MarkNewEscaped(oo) + } } func (rlm *Realm) MarkNewReal(oo Object) { + debug2.Println2("MarkNewReal, oo:", oo) if debug { if pv, ok := oo.(*PackageValue); ok { // packages should have no owner. @@ -425,9 +443,9 @@ func (rlm *Realm) MarkNewReal(oo Object) { if rlm.newCreated == nil { rlm.newCreated = make([]Object, 0, 256) } - //fmt.Println("---append oo to newCreated object: ", oo) + debug2.Println2("---append oo to newCreated object: ", oo) rlm.newCreated = append(rlm.newCreated, oo) - //fmt.Println("---len of new created: ", len(rlm.newCreated)) + debug2.Println2("---len of new created: ", len(rlm.newCreated)) } // mark dirty == updated @@ -504,7 +522,7 @@ func (rlm *Realm) MarkNewEscaped(oo Object) { // to a realm gets attached here, which should panic. // OpReturn calls this when exiting a realm transaction. func (rlm *Realm) FinalizeRealmTransaction(readonly bool, store Store) { - fmt.Println("-------------FinalizeRealmTransaction---------------") + debug2.Println2("FinalizeRealmTransaction, rlm.ID: ", rlm.ID) defer func() { fmt.Println("================done FinalizeRealmTransaction==================") }() @@ -610,9 +628,10 @@ func (rlm *Realm) processNewCreatedMarks(store Store) { // oo must be marked new-real, and ref-count already incremented. func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { - fmt.Println("---incRefCreatedDescendants from oo: ", oo) - fmt.Println("---oo.GetOriginRealm: ", oo.GetOriginRealm()) - fmt.Println("---oo.GetRefCount: ", oo.GetRefCount()) + debug2.Println2("---incRefCreatedDescendants from oo: ", oo) + debug2.Println2("---oo.GetOriginRealm: ", oo.GetOriginRealm()) + debug2.Println2("---oo.GetRefCount: ", oo.GetRefCount()) + debug2.Println2("---oo.GetObjectID: ", oo.GetObjectInfo()) if debug { if oo.GetIsDirty() { @@ -634,11 +653,13 @@ func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { } } + debug2.Println2("oo.GetObjectID(): ", oo.GetObjectID()) // RECURSE GUARD // if id already set, skip. // this happens when a node marked created was already // visited via recursion from a prior marked created. if !oo.GetObjectID().IsZero() { + debug2.Println2("not zero, do nothing, return") return } rlm.assignNewObjectID(oo) @@ -647,8 +668,8 @@ func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { // recurse for children. more := getChildObjects2(store, oo) - for _, child := range more { - //debug2.Printf2("---[%d]child: %v, type of child: %v \n", i, child, reflect.TypeOf(child)) + for i, child := range more { + debug2.Printf2("---[%d]child: %v, type of child: %v \n", i, child, reflect.TypeOf(child)) if _, ok := child.(*PackageValue); ok { if debug { if child.GetRefCount() < 1 { @@ -906,7 +927,9 @@ func (rlm *Realm) markDirtyAncestors(store Store) { // Saves .created and .updated objects. func (rlm *Realm) saveUnsavedObjects(store Store) { + debug2.Println2("saveUnsavedObjects") for _, co := range rlm.created { + debug2.Println2("co: ", co) // for i := len(rlm.created) - 1; i >= 0; i-- { // co := rlm.created[i] if !co.GetIsNewReal() { @@ -918,6 +941,7 @@ func (rlm *Realm) saveUnsavedObjects(store Store) { } } for _, uo := range rlm.updated { + debug2.Println2("uo: ", uo) // uo := rlm.updated[i] if !uo.GetIsDirty() { // might have happened already as child @@ -1591,7 +1615,9 @@ func fillTypesTV(store Store, tv *TypedValue) { // Partially fills loaded objects shallowly, similarly to // getUnsavedTypes. Replaces all RefTypes with corresponding types. func fillTypesOfValue(store Store, val Value) Value { - fmt.Println("---fillTypesOfValue, val: ", val) + debug2.Println2("fillTypesOfValue, val: ", val) + debug2.Println2("type of val: ", reflect.TypeOf(val)) + defer println("---done FillTypesOfValue") switch cv := val.(type) { case nil: // do nothing return cv @@ -1622,7 +1648,9 @@ func fillTypesOfValue(store Store, val Value) Value { fillTypesOfValue(store, cv.Base) return cv case *StructValue: - println("struct value") + debug2.Println2("struct value") + debug2.Println2("cv.GetOriginRealm: ", cv.GetOriginRealm()) + debug2.Println2("cv.GetObjectInfo: ", cv.GetObjectInfo()) for i := 0; i < len(cv.Fields); i++ { ctv := &cv.Fields[i] fillTypesTV(store, ctv) @@ -1691,14 +1719,14 @@ func (rlm *Realm) nextObjectID() ObjectID { // Object gets its id set (panics if already set), and becomes // marked as new and real. func (rlm *Realm) assignNewObjectID(oo Object) ObjectID { - //fmt.Printf("---assignNewObjectID, rlm: %v, oo: %v, oo: %p\n", rlm, oo, oo) + debug2.Printf2("assignNewObjectID, rlm: %v, oo: %v, oo: %p\n", rlm, oo, oo) oid := oo.GetObjectID() - //fmt.Println("---oid: ", oid) + debug2.Println2("oid: ", oid) if !oid.IsZero() { panic("unexpected non-zero object id") } noid := rlm.nextObjectID() - //fmt.Println("---noid: ", noid) + debug2.Println2("noid: ", noid) oo.SetObjectID(noid) return noid } @@ -1714,11 +1742,12 @@ func toRefNode(bn BlockNode) RefNode { } func toRefValue(val Value) RefValue { - //fmt.Println("---toRefValue", val) + debug2.Println2("toRefValue, val: ", val) // TODO use type switch stmt. if ref, ok := val.(RefValue); ok { return ref } else if oo, ok := val.(Object); ok { + debug2.Println2("oo: ", oo) if pv, ok := val.(*PackageValue); ok { if pv.GetIsDirty() { panic("unexpected dirty package " + pv.PkgPath) diff --git a/gnovm/pkg/gnolang/uverse.go b/gnovm/pkg/gnolang/uverse.go index 525374ea4b1..e7729204ab1 100644 --- a/gnovm/pkg/gnolang/uverse.go +++ b/gnovm/pkg/gnolang/uverse.go @@ -143,6 +143,7 @@ func UverseNode() *PackageNode { "res", GenT("X", nil), // res ), func(m *Machine) { + debug2.Println2("append") arg0, arg1 := m.LastBlock().GetParams2() // As a special case, if arg1 is a string type, first convert it into // a data slice type. @@ -269,6 +270,7 @@ func UverseNode() *PackageNode { // ---------------------------------------------------------------- // append(*SliceValue, ???) case *SliceValue: + debug2.Println2("SliceValue, ???") arg0Length := arg0Value.Length arg0Offset := arg0Value.Offset arg0Capacity := arg0Value.Maxcap @@ -286,9 +288,12 @@ func UverseNode() *PackageNode { // ------------------------------------------------------------ // append(*SliceValue, *SliceValue) case *SliceValue: + debug2.Println2("arg1 slice value") arg1Length := arg1Value.Length arg1Offset := arg1Value.Offset arg1Base := arg1Value.GetBase(m.Store) + debug2.Println2("arg1Base: ", arg1Base) + debug2.Println2("arg1Base.List: ", arg1Base.List) if arg0Length+arg1Length <= arg0Capacity { // append(*SliceValue, *SliceValue) w/i capacity ----- if 0 < arg1Length { // implies 0 < xvc @@ -376,6 +381,7 @@ func UverseNode() *PackageNode { return } else { // append(*SliceValue, *SliceValue) new list --------- + debug2.Println2("new list") list := make([]TypedValue, arg0Length+arg1Length) if 0 < arg0Length { if arg0Base.Data == nil { diff --git a/gnovm/pkg/gnolang/values.go b/gnovm/pkg/gnolang/values.go index b091ecda405..53137a75496 100644 --- a/gnovm/pkg/gnolang/values.go +++ b/gnovm/pkg/gnolang/values.go @@ -214,6 +214,7 @@ func (pv PointerValue) Assign2(alloc *Allocator, store Store, rlm *Realm, tv2 Ty debug2.Println2("Assign2, pv: ", pv) debug2.Println2("tv2: ", tv2) debug2.Printf2("addr of tv2: %p \n", &tv2) + debug2.Println2("rlm: ", rlm) // Special cases. if pv.Index == PointerIndexNative { @@ -292,7 +293,7 @@ func (pv PointerValue) Assign2(alloc *Allocator, store Store, rlm *Realm, tv2 Ty // get origin pkgId _, pkgId := tv2.GetFirstObject2(store) - debug2.Println2("pkgId ", pkgId) + debug2.Println2("pkgId: ", pkgId) pv.TV.Assign(alloc, tv2, cu) @@ -305,6 +306,7 @@ func (pv PointerValue) Assign2(alloc *Allocator, store Store, rlm *Realm, tv2 Ty } debug2.Println2("oo2: ", oo2) debug2.Println2("pkgId: ", pkgId) + if oo2 != nil && !pkgId.IsZero() { // cross realm oo2.SetOriginRealm(pkgId) // attach origin package info } @@ -525,7 +527,7 @@ func (sv *StructValue) GetSubrefPointerTo(store Store, st *StructType, path Valu } func (sv *StructValue) Copy(alloc *Allocator) *StructValue { - //fmt.Println("---StructValue copy, sv: ", sv) + debug2.Println2("StructValue copy, sv: ", sv) /* TODO consider second refcount field if sv.GetRefCount() == 0 { return sv @@ -542,8 +544,18 @@ func (sv *StructValue) Copy(alloc *Allocator) *StructValue { } nsv := alloc.NewStruct(fields) - fmt.Println("---sv.ObjectInfo", sv.ObjectInfo) - nsv.ObjectInfo = sv.ObjectInfo.Copy() + //debug2.Println2("sv.ObjectInfo", sv.ObjectInfo) + //nsv.ObjectInfo = sv.ObjectInfo.Copy() + debug2.Println2("sv.GetOriginRealm: ", sv.GetOriginRealm()) + debug2.Println2("sv.GetObjectID(): ", sv.GetObjectID()) + debug2.Println2("sv.GetRefCount: ", sv.GetRefCount()) + debug2.Println2("sv...OwneID: ", sv.GetObjectInfo().OwnerID) + // append, unref copy... + //pkgId := sv.GetOriginRealm() + //if pkgId.IsZero() { + // pkgId = sv.GetObjectID().PkgID + //} + //nsv.SetOriginRealm(pkgId) return nsv //return alloc.NewStruct(fields) } @@ -1069,6 +1081,7 @@ func (tv TypedValue) Copy(alloc *Allocator) (cp TypedValue) { cp.T = tv.T cp.V = cv.Copy(alloc) default: + println("---default") cp = tv } return @@ -1077,6 +1090,7 @@ func (tv TypedValue) Copy(alloc *Allocator) (cp TypedValue) { // unrefCopy makes a copy of the underlying value in the case of reference values. // It copies other values as expected using the normal Copy method. func (tv TypedValue) unrefCopy(alloc *Allocator, store Store) (cp TypedValue) { + debug2.Println2("UnrefCopy, tv: ", tv) switch tv.V.(type) { case RefValue: cp.T = tv.T diff --git a/gnovm/tests/files/zrealm_crossrealm24.gno b/gnovm/tests/files/zrealm_crossrealm24.gno index 00cd3942254..09d0d761abc 100644 --- a/gnovm/tests/files/zrealm_crossrealm24.gno +++ b/gnovm/tests/files/zrealm_crossrealm24.gno @@ -44,7 +44,7 @@ func main() { // ], // "ObjectInfo": { // "ID": "5965ae851c02ab677bc8394b408535c1db9b2635:4", -// "ModTime": "11", +// "ModTime": "13", // "OwnerID": "5965ae851c02ab677bc8394b408535c1db9b2635:3", // "RefCount": "1" // } diff --git a/gnovm/tests/files/zrealm_crossrealm24d.gno b/gnovm/tests/files/zrealm_crossrealm24d.gno index 8103f13f80d..29c8719fa93 100644 --- a/gnovm/tests/files/zrealm_crossrealm24d.gno +++ b/gnovm/tests/files/zrealm_crossrealm24d.gno @@ -43,7 +43,7 @@ func main() { // ], // "ObjectInfo": { // "ID": "5965ae851c02ab677bc8394b408535c1db9b2635:4", -// "ModTime": "11", +// "ModTime": "13", // "OwnerID": "5965ae851c02ab677bc8394b408535c1db9b2635:3", // "RefCount": "1" // } diff --git a/gnovm/tests/files/zrealm_crossrealm24e.gno b/gnovm/tests/files/zrealm_crossrealm24e.gno index ce98a25eac7..b5d60e3dcf3 100644 --- a/gnovm/tests/files/zrealm_crossrealm24e.gno +++ b/gnovm/tests/files/zrealm_crossrealm24e.gno @@ -15,4 +15,4 @@ func main() { } // Error: -// cannot attach objects by value from external realm +// cannot attach a value of a type defined by another realm diff --git a/gnovm/tests/files/zrealm_crossrealm24f.gno b/gnovm/tests/files/zrealm_crossrealm24f.gno new file mode 100644 index 00000000000..4be67555c6c --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm24f.gno @@ -0,0 +1,16 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "gno.land/p/demo/tests" +) + +var root interface{} + +func main() { + root = tests.F + println("done") +} + +// Error: +// cannot attach a value of a type defined by another realm diff --git a/gnovm/tests/files/zrealm_crossrealm24g.gno b/gnovm/tests/files/zrealm_crossrealm24g.gno new file mode 100644 index 00000000000..3c308fc8fe2 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm24g.gno @@ -0,0 +1,15 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "gno.land/p/demo/tests" +) + +var root = tests.Foo{"p"} + +func main() { + println("done") +} + +// Output: +// done diff --git a/gnovm/tests/files/zrealm_crossrealm25.gno b/gnovm/tests/files/zrealm_crossrealm25.gno index 4b856ac244f..d0b3a3aa273 100644 --- a/gnovm/tests/files/zrealm_crossrealm25.gno +++ b/gnovm/tests/files/zrealm_crossrealm25.gno @@ -23,4 +23,4 @@ func main() { } // Error: -// cannot attach objects by value from external realm +// cannot attach a value of a type defined by another realm diff --git a/gnovm/tests/files/zrealm_crossrealm25c.gno b/gnovm/tests/files/zrealm_crossrealm25c.gno index 3ed3a1871ba..e647eaa6e1e 100644 --- a/gnovm/tests/files/zrealm_crossrealm25c.gno +++ b/gnovm/tests/files/zrealm_crossrealm25c.gno @@ -30,4 +30,4 @@ func main() { } // Error: -// cannot attach objects by value from external realm +// cannot attach a value of a type defined by another realm diff --git a/gnovm/tests/files/zrealm_crossrealm25d.gno b/gnovm/tests/files/zrealm_crossrealm25d.gno index 8c2f1990d13..eba4ee7de76 100644 --- a/gnovm/tests/files/zrealm_crossrealm25d.gno +++ b/gnovm/tests/files/zrealm_crossrealm25d.gno @@ -31,4 +31,4 @@ func main() { } // Error: -// cannot attach objects by value from external realm +// cannot attach a value of a type defined by another realm diff --git a/gnovm/tests/files/zrealm_crossrealm25e.gno b/gnovm/tests/files/zrealm_crossrealm25e.gno index 7e0f8d29a2c..8e48b45a391 100644 --- a/gnovm/tests/files/zrealm_crossrealm25e.gno +++ b/gnovm/tests/files/zrealm_crossrealm25e.gno @@ -29,4 +29,4 @@ func main() { } // Error: -// cannot attach objects by value from external realm +// cannot attach a value of a type defined by another realm diff --git a/gnovm/tests/files/zrealm_crossrealm25f.gno b/gnovm/tests/files/zrealm_crossrealm25f.gno new file mode 100644 index 00000000000..dc12a9de4e8 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm25f.gno @@ -0,0 +1,28 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import ( + "std" + + crossrealm "gno.land/r/demo/tests/crossrealm/iface" +) + +type fooer struct{ name string } + +func (fooer) Foo() { println("hello " + std.CurrentRealm().PkgPath()) } + +var f fooer +var root interface{} + +func init() { + f = fooer{name: "local fooer"} + g := f + root = g +} + +func main() { + print(".") +} + +// Output: +// . diff --git a/gnovm/tests/files/zrealm_crossrealm32.gno b/gnovm/tests/files/zrealm_crossrealm32.gno index 3ebceef83de..f3f4e1243e9 100644 --- a/gnovm/tests/files/zrealm_crossrealm32.gno +++ b/gnovm/tests/files/zrealm_crossrealm32.gno @@ -28,7 +28,7 @@ func main() { // }, // "V": { // "@type": "/gno.StringValue", -// "value": "0" +// "value": "3" // } // } // ], @@ -39,6 +39,26 @@ func main() { // "RefCount": "1" // } // } +// c[ff34c6500d0daee58e4ac9899c0e7ecc131db63e:27]={ +// "Fields": [ +// { +// "T": { +// "@type": "/gno.PrimitiveType", +// "value": "16" +// }, +// "V": { +// "@type": "/gno.StringValue", +// "value": "0" +// } +// } +// ], +// "ObjectInfo": { +// "ID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:27", +// "ModTime": "0", +// "OwnerID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:25", +// "RefCount": "1" +// } +// } // c[ff34c6500d0daee58e4ac9899c0e7ecc131db63e:25]={ // "Data": null, // "List": [ @@ -49,8 +69,8 @@ func main() { // }, // "V": { // "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:15" +// "Hash": "47bf5eb54da0545110d6486001609dc4203f61b0", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:26" // } // }, // { @@ -60,8 +80,8 @@ func main() { // }, // "V": { // "@type": "/gno.RefValue", -// "Hash": "14593ec2b92fe8a53780cf8a6c430a6526f05283", -// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:26" +// "Hash": "eaa3017cfcfafd8f8217ee1df0afdac5e4ad12a9", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:27" // } // } // ], @@ -260,7 +280,7 @@ func main() { // "@type": "/gno.SliceValue", // "Base": { // "@type": "/gno.RefValue", -// "Hash": "51b5198111d9cdcf7c980e3816d111cfbe0b7cc4", +// "Hash": "fcdb6b41091d087be521ae9be69b8328ac495677", // "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:25" // }, // "Length": "2", diff --git a/gnovm/tests/files/zrealm_crossrealm33.gno b/gnovm/tests/files/zrealm_crossrealm33.gno index 87f5da43bdd..4fe559f0ae9 100644 --- a/gnovm/tests/files/zrealm_crossrealm33.gno +++ b/gnovm/tests/files/zrealm_crossrealm33.gno @@ -19,4 +19,4 @@ func main() { } // Error: -// should not happen, struct{("0" string)} is not real +// cannot attach un-real object from external realm: struct{("0" string)} diff --git a/gnovm/tests/files/zrealm_crossrealm36.gno b/gnovm/tests/files/zrealm_crossrealm36.gno index b707faca7dc..028e023d934 100644 --- a/gnovm/tests/files/zrealm_crossrealm36.gno +++ b/gnovm/tests/files/zrealm_crossrealm36.gno @@ -14,4 +14,4 @@ func main() { } // Error: -// should not happen, struct{("d" string)} is not real +// cannot attach un-real object from external realm: struct{("d" string)} diff --git a/gnovm/tests/files/zrealm_crossrealm36a.gno b/gnovm/tests/files/zrealm_crossrealm36a.gno new file mode 100644 index 00000000000..18ef893e307 --- /dev/null +++ b/gnovm/tests/files/zrealm_crossrealm36a.gno @@ -0,0 +1,17 @@ +// PKGPATH: gno.land/r/crossrealm_test +package crossrealm_test + +import crossrealm "gno.land/r/demo/tests/crossrealm/struct" + +var s *crossrealm.C + +func cb(c *crossrealm.C) { + s = c +} +func main() { + crossrealm.GetStruct2(cb) + println(s) +} + +// Error: +// cannot attach a reference to an unreal object from an external realm From b0241aa237d47e9d9a13ca3b6f16390a7fdc252b Mon Sep 17 00:00:00 2001 From: ltzMaxwell Date: Sun, 5 Jan 2025 22:50:52 +0800 Subject: [PATCH 38/40] fixup --- examples/gno.land/p/demo/tests/tests.gno | 74 +++++++ gnovm/pkg/gnolang/debug_false.go | 2 +- gnovm/pkg/gnolang/machine.go | 14 +- gnovm/pkg/gnolang/op_assign.go | 6 +- gnovm/pkg/gnolang/op_decl.go | 4 +- gnovm/pkg/gnolang/op_eval.go | 3 +- gnovm/pkg/gnolang/ownership.go | 27 ++- gnovm/pkg/gnolang/realm.go | 124 ++++++------ gnovm/pkg/gnolang/store.go | 12 +- gnovm/pkg/gnolang/values.go | 20 +- gnovm/tests/files/heap_item_value_init.gno | 4 +- gnovm/tests/files/zrealm_crossrealm24f.gno | 2 +- gnovm/tests/files/zrealm_crossrealm32.gno | 146 +++++++------- gnovm/tests/files/zrealm_crossrealm34.gno | 2 +- gnovm/tests/files/zrealm_crossrealm34a.gno | 2 +- gnovm/tests/files/zrealm_natbind0_stdlibs.gno | 180 ------------------ gnovm/tests/files/zrealm_tests0_stdlibs.gno | 3 - 17 files changed, 250 insertions(+), 375 deletions(-) create mode 100644 examples/gno.land/p/demo/tests/tests.gno delete mode 100644 gnovm/tests/files/zrealm_natbind0_stdlibs.gno diff --git a/examples/gno.land/p/demo/tests/tests.gno b/examples/gno.land/p/demo/tests/tests.gno new file mode 100644 index 00000000000..43732d82dac --- /dev/null +++ b/examples/gno.land/p/demo/tests/tests.gno @@ -0,0 +1,74 @@ +package tests + +import ( + "std" + + psubtests "gno.land/p/demo/tests/subtests" + "gno.land/r/demo/tests" + rtests "gno.land/r/demo/tests" +) + +const World = "world" + +// IncCounter demonstrates that it's possible to call a realm function from +// a package. So a package can potentially write into the store, by calling +// an other realm. +func IncCounter() { + tests.IncCounter() +} + +func CurrentRealmPath() string { + return std.CurrentRealm().PkgPath() +} + +//---------------------------------------- +// cross realm test vars + +type TestRealmObject2 struct { + Field string +} + +func (o2 *TestRealmObject2) Modify() { + o2.Field = "modified" +} + +var ( + somevalue1 TestRealmObject2 + SomeValue2 TestRealmObject2 + SomeValue3 *TestRealmObject2 +) + +func init() { + somevalue1 = TestRealmObject2{Field: "init"} + SomeValue2 = TestRealmObject2{Field: "init"} + SomeValue3 = &TestRealmObject2{Field: "init"} +} + +func ModifyTestRealmObject2a() { + somevalue1.Field = "modified" +} + +func ModifyTestRealmObject2b() { + SomeValue2.Field = "modified" +} + +func ModifyTestRealmObject2c() { + SomeValue3.Field = "modified" +} + +func GetPrevRealm() std.Realm { + return std.PrevRealm() +} + +func GetPSubtestsPrevRealm() std.Realm { + return psubtests.GetPrevRealm() +} + +func GetRTestsGetPrevRealm() std.Realm { + return rtests.GetPrevRealm() +} + +// Warning: unsafe pattern. +func Exec(fn func()) { + fn() +} diff --git a/gnovm/pkg/gnolang/debug_false.go b/gnovm/pkg/gnolang/debug_false.go index 015ef2d088d..8252bde3abf 100644 --- a/gnovm/pkg/gnolang/debug_false.go +++ b/gnovm/pkg/gnolang/debug_false.go @@ -4,4 +4,4 @@ package gnolang const debug debugging = false -const debug2 debugging = true +const debug2 debugging = false diff --git a/gnovm/pkg/gnolang/machine.go b/gnovm/pkg/gnolang/machine.go index 5720766ca28..6b21798de87 100644 --- a/gnovm/pkg/gnolang/machine.go +++ b/gnovm/pkg/gnolang/machine.go @@ -315,7 +315,7 @@ func (m *Machine) runMemPackage(memPkg *std.MemPackage, save, overrides bool) (* if throwaway != nil { m.Realm = throwaway } - //fmt.Println("---save, throwaway: ", throwaway) + debug2.Println2("save, throwaway: ", throwaway) } // run init functions m.runInitFromUpdates(pv, updates) @@ -787,7 +787,7 @@ func (m *Machine) saveNewPackageValuesAndTypes() (throwaway *Realm) { // Pass in the realm from m.saveNewPackageValuesAndTypes() // in case a throwaway was created. func (m *Machine) resavePackageValues(rlm *Realm) { - debug2.Println2("resavePackageValues, rlm: ", rlm) + debug2.Println2("resavePackageValues, throwaway: ", rlm) // save package value and dependencies. pv := m.Package if pv.IsRealm() { @@ -978,7 +978,7 @@ func (m *Machine) RunDeclaration(d Decl) { // package level, for which evaluations happen during // preprocessing). func (m *Machine) runDeclaration(d Decl) { - fmt.Println("---run declaration, d: ", d) + debug2.Println2("run declaration, d: ", d) switch d := d.(type) { case *FuncDecl: // nothing to do. @@ -1896,11 +1896,11 @@ func (m *Machine) PushFrameCall(cx *CallExpr, fv *FuncValue, recv TypedValue) { m.setCurrentPackage(pv) // maybe new realm } else { recvOID := obj.GetObjectInfo().ID - fmt.Println("---recvOID is: ", recvOID) + debug2.Println2("---recvOID is: ", recvOID) if recvOID.IsZero() { - fmt.Println("!!! recvOID is ZERO!!!") - fmt.Println("---recv is ZERO, it's not owned, recv: ", recv) - fmt.Println("---recv is ZERO, m.realm: ", m.Realm) + debug2.Println2("!!! recvOID is ZERO!!!") + debug2.Println2("---recv is ZERO, it's not owned, recv: ", recv) + debug2.Println2("---recv is ZERO, m.realm: ", m.Realm) // receiver isn't owned yet. // just continue with current package and realm. diff --git a/gnovm/pkg/gnolang/op_assign.go b/gnovm/pkg/gnolang/op_assign.go index 41d210df3ee..234b1debf01 100644 --- a/gnovm/pkg/gnolang/op_assign.go +++ b/gnovm/pkg/gnolang/op_assign.go @@ -1,10 +1,8 @@ package gnolang -import "fmt" - func (m *Machine) doOpDefine() { s := m.PopStmt().(*AssignStmt) - fmt.Println("---doOpDefine, s: ", s) + debug2.Println2("---doOpDefine, s: ", s) // Define each value evaluated for Lhs. // NOTE: PopValues() returns a slice in // forward order, not the usual reverse. @@ -29,7 +27,7 @@ func (m *Machine) doOpDefine() { func (m *Machine) doOpAssign() { s := m.PopStmt().(*AssignStmt) - fmt.Println("---doOpAssign, s: ", s) + debug2.Println2("doOpAssign, s: ", s) // Assign each value evaluated for Lhs. // NOTE: PopValues() returns a slice in // forward order, not the usual reverse. diff --git a/gnovm/pkg/gnolang/op_decl.go b/gnovm/pkg/gnolang/op_decl.go index a17b95935b7..13ad455fc53 100644 --- a/gnovm/pkg/gnolang/op_decl.go +++ b/gnovm/pkg/gnolang/op_decl.go @@ -6,7 +6,7 @@ import ( func (m *Machine) doOpValueDecl() { s := m.PopStmt().(*ValueDecl) - fmt.Println("---doOpValueDecl, s: ", s) + debug2.Println2("doOpValueDecl, s: ", s) lb := m.LastBlock() nt := Type(nil) if s.Type != nil { @@ -19,7 +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") + debug2.Println2("rvs is nil, using default value") // NOTE: Go/Gno wart. // implicit interface casting could // requiring the consideration of the typed-nil case. diff --git a/gnovm/pkg/gnolang/op_eval.go b/gnovm/pkg/gnolang/op_eval.go index 8aaffa074c4..6bf5e54a24f 100644 --- a/gnovm/pkg/gnolang/op_eval.go +++ b/gnovm/pkg/gnolang/op_eval.go @@ -23,7 +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) + debug2.Printf2("EVAL: (%T) %v\n", x, x) // This case moved out of switch for performance. // TODO: understand this better. if nx, ok := x.(*NameExpr); ok { @@ -38,7 +38,6 @@ 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 } diff --git a/gnovm/pkg/gnolang/ownership.go b/gnovm/pkg/gnolang/ownership.go index 9c51d6ce76a..f10543cdfa0 100644 --- a/gnovm/pkg/gnolang/ownership.go +++ b/gnovm/pkg/gnolang/ownership.go @@ -256,7 +256,6 @@ func (oi *ObjectInfo) GetModTime() uint64 { } func (oi *ObjectInfo) IncRefCount() int { - fmt.Println("---IncRefCount") oi.RefCount++ return oi.RefCount } @@ -392,11 +391,11 @@ func (tv *TypedValue) GetFirstObject(store Store) Object { // also get pkgId of the object, so it's clear where the object is from // TODO, just return isRealm func (tv *TypedValue) GetFirstObject2(store Store) (obj Object, pkgId PkgID) { - fmt.Println("---GetFirstObject2---, tv: ", tv, reflect.TypeOf(tv.V)) + debug2.Println2("GetFirstObject2---, tv: ", tv, reflect.TypeOf(tv.V)) // get first object obj = tv.GetFirstObject(store) - fmt.Println("---obj: ", obj) + debug2.Println2("obj: ", obj) if obj != nil { @@ -411,7 +410,7 @@ func (tv *TypedValue) GetFirstObject2(store Store) (obj Object, pkgId PkgID) { if pkgId.IsZero() { switch cv := obj.(type) { case *ArrayValue: - fmt.Println("---array value, T: ", tv.T) + debug2.Println2("array value, T: ", tv.T) debug2.Println2("objectInfo: ", cv.GetObjectInfo()) if IsRealmPath(tv.T.Elem().GetPkgPath()) { // TODO: func type don't have pkgpath, retrieve from clo @@ -425,10 +424,10 @@ func (tv *TypedValue) GetFirstObject2(store Store) (obj Object, pkgId PkgID) { debug2.Println2("heapItemValue: ", cv) debug2.Println2("heapItemValue.Value.T: ", cv.Value.T) if dt, ok := cv.Value.T.(*DeclaredType); ok { - fmt.Printf("---dt: %v\n", dt) - fmt.Println("---dt.base: ", dt.Base) + debug2.Printf2("---dt: %v\n", dt) + debug2.Println2("---dt.base: ", dt.Base) if _, ok := dt.Base.(*FuncType); !ok { - fmt.Println("---dt.base.PkgPath: ", dt.Base.GetPkgPath()) + debug2.Println2("---dt.base.PkgPath: ", dt.Base.GetPkgPath()) if IsRealmPath(dt.Base.GetPkgPath()) { pkgId = PkgIDFromPkgPath(dt.Base.GetPkgPath()) } @@ -436,10 +435,10 @@ func (tv *TypedValue) GetFirstObject2(store Store) (obj Object, pkgId PkgID) { } return case *BoundMethodValue: - fmt.Println("---BoundMethodValue, recv: ", cv.Receiver) - fmt.Println("---type of T: ", reflect.TypeOf(cv.Receiver.T)) + debug2.Println2("BoundMethodValue, recv: ", cv.Receiver) + debug2.Println2("---type of T: ", reflect.TypeOf(cv.Receiver.T)) if pv, ok := cv.Receiver.V.(PointerValue); ok { - println("---pointer value") + debug2.Println2("---pointer value") // TODO: check this if dt, ok := pv.TV.T.(*DeclaredType); ok { fmt.Println("---2, dt: ", dt) @@ -447,15 +446,15 @@ func (tv *TypedValue) GetFirstObject2(store Store) (obj Object, pkgId PkgID) { pkgId = PkgIDFromPkgPath(dt.PkgPath) } } - fmt.Println("---pkgId; ", pkgId) + debug2.Println2("---pkgId; ", pkgId) } return case *MapValue, *StructValue: if dt, ok := tv.T.(*DeclaredType); ok { - fmt.Printf("---dt: %v\n", dt) - fmt.Println("---dt.base: ", dt.Base) + debug2.Printf2("---dt: %v\n", dt) + debug2.Println2("---dt.base: ", dt.Base) if _, ok := dt.Base.(*FuncType); !ok { - fmt.Println("---dt.base.PkgPath: ", dt.Base.GetPkgPath()) + debug2.Println2("---dt.base.PkgPath: ", dt.Base.GetPkgPath()) if IsRealmPath(dt.Base.GetPkgPath()) { pkgId = PkgIDFromPkgPath(dt.Base.GetPkgPath()) } diff --git a/gnovm/pkg/gnolang/realm.go b/gnovm/pkg/gnolang/realm.go index 5b8f43fcfc4..a7dffcdd8e6 100644 --- a/gnovm/pkg/gnolang/realm.go +++ b/gnovm/pkg/gnolang/realm.go @@ -197,13 +197,13 @@ func (rlm *Realm) DidUpdate(po, xo, co Object) { // ref value is the derived value from co, like a slice. func (rlm *Realm) DidUpdate2(store Store, po, xo, co Object, refValue Value) { - fmt.Printf("---DidUpdate2, po: %v, type of po: %v\n", po, reflect.TypeOf(po)) - fmt.Printf("---xo: %v, type of xo: %v\n", xo, reflect.TypeOf(xo)) - fmt.Printf("---co: %v, type of co: %v\n", co, reflect.TypeOf(co)) + debug2.Printf2("DidUpdate2, po: %v, type of po: %v\n", po, reflect.TypeOf(po)) + debug2.Printf2("xo: %v, type of xo: %v\n", xo, reflect.TypeOf(xo)) + debug2.Printf2("co: %v, type of co: %v\n", co, reflect.TypeOf(co)) if co != nil { - fmt.Println("co.GetOriginRealm: ", co.GetOriginRealm()) + debug2.Println2("co.GetOriginRealm: ", co.GetOriginRealm()) } - fmt.Println("---rlm.ID: ", rlm.ID) + debug2.Println2("---rlm.ID: ", rlm.ID) if rlm == nil { return @@ -220,17 +220,18 @@ func (rlm *Realm) DidUpdate2(store Store, po, xo, co Object, refValue Value) { } } + // if oo.GetRefCount() > 0 if refValue != nil { co.SetIsRef(true) } if po == nil || !po.GetIsReal() { // XXX, make sure po is attached - fmt.Println("---po(Base) not real, do nothing!!!") + debug2.Println2("po not real, do nothing!!!") return // do nothing. } // TODO: check not real external here, if po is real, association is invalid - fmt.Println("---po.GetObjectID().PkgID: ", po.GetObjectID().PkgID) + debug2.Println2("po.GetObjectID().PkgID: ", po.GetObjectID().PkgID) if po.GetObjectID().PkgID != rlm.ID { panic("cannot modify external-realm or non-realm object") } @@ -249,15 +250,17 @@ func (rlm *Realm) DidUpdate2(store Store, po, xo, co Object, refValue Value) { //fmt.Println("---co.GetRefCount: ", co.GetRefCount()) // XXX, inc ref count everytime assignment happens co.IncRefCount() - fmt.Println("---after inc, co.GetRefCount: ", co.GetRefCount()) + debug2.Println2("after inc, co.GetRefCount: ", co.GetRefCount()) if co.GetRefCount() > 1 { - if co.GetIsEscaped() { - println("---already escaped, should check cross realm?") - // already escaped - rlm.MarkNewEscapedCheckCrossRealm(store, co, refValue) - } else { - rlm.MarkNewEscapedCheckCrossRealm(store, co, refValue) - } + //if co.GetIsEscaped() { + // debug2.Println2("already escaped, should check cross realm?") + // // already escaped in current realm, can also be escaped to other realm + // rlm.MarkNewEscapedCheckCrossRealm(store, co, refValue) + //} else { + // rlm.MarkNewEscapedCheckCrossRealm(store, co, refValue) + //} + // debug2.Println2("already escaped, should check cross realm?") + rlm.MarkNewEscapedCheckCrossRealm(store, co, refValue) } else if co.GetIsReal() { rlm.MarkDirty(co) } else { @@ -268,7 +271,6 @@ func (rlm *Realm) DidUpdate2(store Store, po, xo, co Object, refValue Value) { if xo != nil { xo.DecRefCount() - fmt.Printf("---xo: %v refCount after dec: %v\n", xo, xo.GetRefCount()) if xo.GetRefCount() == 0 { if xo.GetIsReal() { rlm.MarkNewDeleted(xo) @@ -324,7 +326,7 @@ func checkCrossRealm(rlm *Realm, store Store, oo Object, refValue Value) { if !pkgId.IsZero() { reo.SetOriginRealm(pkgId) } - fmt.Println("---reo: ", reo) + debug2.Println2("reo: ", reo) // XXX, if elem of array is slice?, GetFirstObject2?... checkCrossRealm(rlm, store, reo, refValue) } @@ -334,9 +336,9 @@ func checkCrossRealm(rlm *Realm, store Store, oo Object, refValue Value) { println("---mapValue...") // TODO: check elem? case *HeapItemValue: - fmt.Println("---heapItemValue: ", v) + debug2.Println2("---heapItemValue: ", v) r := fillValueTV(store, &v.Value) - fmt.Println("---r: ", r) + debug2.Println2("---r: ", r) checkCrossRealm(rlm, store, v.Value.V.(Object), refValue) case *ArrayValue: @@ -356,10 +358,10 @@ func checkCrossRealm(rlm *Realm, store Store, oo Object, refValue Value) { e := fillValueTV(store, &ee) //e := oo.(*ArrayValue).GetPointerAtIndexInt2(store, i, nil).Deref() - fmt.Printf("---e[%d]: %v\n", i, e) - fmt.Printf("---type of e[%d].V: %v\n", i, reflect.TypeOf(e.V)) - debug2.Println2("e...GetOriginRealm: ", e.V.(Object).GetOriginRealm()) - debug2.Println2("e....GetObjectInfo: ", e.V.(Object).GetObjectInfo()) + debug2.Printf2("---e[%d]: %v\n", i, e) + debug2.Printf2("---type of e[%d].V: %v\n", i, reflect.TypeOf(e.V)) + //debug2.Println2("e...GetOriginRealm: ", e.V.(Object).GetOriginRealm()) + //debug2.Println2("e....GetObjectInfo: ", e.V.(Object).GetObjectInfo()) if eo, ok := e.V.(Object); ok { checkCrossRealm(rlm, store, eo, refValue) @@ -388,18 +390,16 @@ func checkCrossRealm(rlm *Realm, store Store, oo Object, refValue Value) { // escaped realm should be reference object func (rlm *Realm) MarkNewEscapedCheckCrossRealm(store Store, oo Object, refValue Value) { - debug2.Println2("MarkNewEscapedCheckCrossRealm") - debug2.Println2("---refValue: ", refValue) + //fmt.Println("MarkNewEscapedCheckCrossRealm, oo: ", oo) + //fmt.Println("refValue: ", refValue) + //fmt.Println("oo.GetOriginRealm(): ", oo.GetOriginRealm()) + //fmt.Println("rlm.ID: ", rlm.ID) if oo.GetOriginRealm() == rlm.ID { - //if !oo.GetIsEscaped() { - // rlm.MarkNewEscaped(oo) - //} + // do nothing return } - debug2.Println2("---oo.GetLastNewEscapedRealm(): ", oo.GetOriginRealm()) - debug2.Println2("---rlm.ID: ", rlm.ID) if oo.GetOriginRealm() != rlm.ID { // crossing realm if refValue != nil { // is reference object from external realm checkCrossRealm(rlm, store, oo, refValue) @@ -435,7 +435,6 @@ func (rlm *Realm) MarkNewReal(oo Object) { } } if oo.GetIsNewReal() { - println("---isNewReal---, oo: ", oo) return // already marked. } oo.SetIsNewReal(true) @@ -443,9 +442,7 @@ func (rlm *Realm) MarkNewReal(oo Object) { if rlm.newCreated == nil { rlm.newCreated = make([]Object, 0, 256) } - debug2.Println2("---append oo to newCreated object: ", oo) rlm.newCreated = append(rlm.newCreated, oo) - debug2.Println2("---len of new created: ", len(rlm.newCreated)) } // mark dirty == updated @@ -524,17 +521,17 @@ func (rlm *Realm) MarkNewEscaped(oo Object) { func (rlm *Realm) FinalizeRealmTransaction(readonly bool, store Store) { debug2.Println2("FinalizeRealmTransaction, rlm.ID: ", rlm.ID) defer func() { - fmt.Println("================done FinalizeRealmTransaction==================") + debug2.Println2("================done FinalizeRealmTransaction==================") }() if readonly { if true || - len(rlm.newCreated) > 0 || - len(rlm.newEscaped) > 0 || - len(rlm.newDeleted) > 0 || - len(rlm.created) > 0 || - len(rlm.updated) > 0 || - len(rlm.deleted) > 0 || - len(rlm.escaped) > 0 { + len(rlm.newCreated) > 0 || + len(rlm.newEscaped) > 0 || + len(rlm.newDeleted) > 0 || + len(rlm.created) > 0 || + len(rlm.updated) > 0 || + len(rlm.deleted) > 0 || + len(rlm.escaped) > 0 { panic("realm updates in readonly transaction") } return @@ -549,9 +546,9 @@ func (rlm *Realm) FinalizeRealmTransaction(readonly bool, store Store) { ensureUniq(rlm.newDeleted) ensureUniq(rlm.updated) if false || - rlm.created != nil || - rlm.deleted != nil || - rlm.escaped != nil { + rlm.created != nil || + rlm.deleted != nil || + rlm.escaped != nil { panic("realm should not have created, deleted, or escaped marks before beginning finalization") } } @@ -591,13 +588,13 @@ func (rlm *Realm) FinalizeRealmTransaction(readonly bool, store Store) { // All newly created objects become appended to .created, // and get assigned ids. func (rlm *Realm) processNewCreatedMarks(store Store) { - fmt.Println("---processNewCreatedMarks---") + debug2.Println2("processNewCreatedMarks") //fmt.Println("---len of newCreated objects:", len(rlm.newCreated)) // Create new objects and their new descendants. //for _, oo := range rlm.newCreated { for i := 0; i < len(rlm.newCreated); i++ { oo := rlm.newCreated[i] - fmt.Printf("---oo[%d] is %v:\n", i, oo) + debug2.Printf2("---oo[%d] is %v:\n", i, oo) //if _, ok := oo.(*BoundMethodValue); ok { // panic("should not happen persist bound method") //} @@ -626,6 +623,7 @@ func (rlm *Realm) processNewCreatedMarks(store Store) { } } +// XXX, unreal oo check happens in here // oo must be marked new-real, and ref-count already incremented. func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { debug2.Println2("---incRefCreatedDescendants from oo: ", oo) @@ -644,7 +642,7 @@ func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { // XXX, oo must be new real here, it's not escaped // if it's reference, all right - fmt.Println("---oo.GetIsRef: ", oo.GetIsRef()) + debug2.Println2("oo.GetIsRef: ", oo.GetIsRef()) if !oo.GetOriginRealm().IsZero() && oo.GetOriginRealm() != rlm.ID { if oo.GetIsRef() { panic("cannot attach a reference to an unreal object from an external realm") @@ -681,7 +679,7 @@ func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { } child.IncRefCount() rc := child.GetRefCount() - fmt.Println("---rc after inc: ", rc) + debug2.Println2("---rc after inc: ", rc) if rc == 1 { if child.GetIsReal() { //fmt.Println("---child is real, child: ", child) @@ -965,9 +963,9 @@ func (rlm *Realm) saveUnsavedObjectRecursively(store Store, oo Object) { } // deleted objects should not have gotten here. if false || - oo.GetRefCount() <= 0 || - oo.GetIsNewDeleted() || - oo.GetIsDeleted() { + oo.GetRefCount() <= 0 || + oo.GetIsNewDeleted() || + oo.GetIsDeleted() { panic("cannot save deleted objects") } } @@ -1009,10 +1007,10 @@ func (rlm *Realm) saveUnsavedObjectRecursively(store Store, oo Object) { } func (rlm *Realm) saveObject(store Store, oo Object) { - fmt.Println("---saveObject: ", oo) + debug2.Println2("saveObject: ", oo) oid := oo.GetObjectID() - fmt.Println("---oid: ", oid) - fmt.Println("---oo.GetRefCount: ", oo.GetRefCount()) + debug2.Println2("---oid: ", oid) + debug2.Println2("---oo.GetRefCount: ", oo.GetRefCount()) if oid.IsZero() { panic("unexpected zero object id") } @@ -1229,12 +1227,10 @@ func copyMethods(methods []TypedValue) []TypedValue { } func refOrCopyType(typ Type) Type { - fmt.Println("---refOrCopyType, typ: ", typ) + debug2.Println2("refOrCopyType, typ: ", typ) if dt, ok := typ.(*DeclaredType); ok { - fmt.Println("---declared type: ", dt) return RefType{ID: dt.TypeID()} } else { - println("---else") return copyTypeWithRefs(typ) } } @@ -1255,7 +1251,7 @@ func copyFieldsWithRefs(fields []FieldType) []FieldType { // Copies type but with references to dependant types; // the result is suitable for persistence bytes serialization. func copyTypeWithRefs(typ Type) Type { - fmt.Println("---copyTypeWithRefs, typ: ", typ) + debug2.Println2("copyTypeWithRefs, typ: ", typ) switch ct := typ.(type) { case nil: panic("cannot copy nil types") @@ -1346,7 +1342,7 @@ func copyTypeWithRefs(typ Type) Type { // Also checks for integrity of immediate children -- they must already be // persistent (real), and not dirty, or else this function panics. func copyValueWithRefs(val Value) Value { - fmt.Println("---copyValueWithRefs, val: ", val) + debug2.Println2("-copyValueWithRefs, val: ", val) switch cv := val.(type) { case nil: return nil @@ -1397,7 +1393,6 @@ func copyValueWithRefs(val Value) Value { Maxcap: cv.Maxcap, } case *StructValue: - println("---struct value") fields := make([]TypedValue, len(cv.Fields)) for i, ftv := range cv.Fields { fields[i] = refOrCopyValue(ftv) @@ -1522,7 +1517,7 @@ func copyValueWithRefs(val Value) Value { // (fully) fills the type. func fillType(store Store, typ Type) Type { - fmt.Println("---fillType, typ: ", typ) + debug2.Println2("fillType, typ: ", typ) switch ct := typ.(type) { case nil: return nil @@ -1598,7 +1593,6 @@ func fillType(store Store, typ Type) Type { } return ct case RefType: - println("---ref type") return store.GetType(ct.TypeID()) default: panic(fmt.Sprintf( @@ -1607,7 +1601,7 @@ func fillType(store Store, typ Type) Type { } func fillTypesTV(store Store, tv *TypedValue) { - fmt.Println("---fillTypesTV, tv: ", tv) + debug2.Println2("fillTypesTV, tv: ", tv) tv.T = fillType(store, tv.T) tv.V = fillTypesOfValue(store, tv.V) } @@ -1617,7 +1611,6 @@ func fillTypesTV(store Store, tv *TypedValue) { func fillTypesOfValue(store Store, val Value) Value { debug2.Println2("fillTypesOfValue, val: ", val) debug2.Println2("type of val: ", reflect.TypeOf(val)) - defer println("---done FillTypesOfValue") switch cv := val.(type) { case nil: // do nothing return cv @@ -1817,11 +1810,10 @@ func ensureUniq(oozz ...[]Object) { } func refOrCopyValue(tv TypedValue) TypedValue { - fmt.Println("---refOrCopyValue:", tv) + debug2.Println2("refOrCopyValue:", tv) if tv.T != nil { tv.T = refOrCopyType(tv.T) } - fmt.Println("---Tv.T: ", tv.T) if obj, ok := tv.V.(Object); ok { tv.V = toRefValue(obj) return tv diff --git a/gnovm/pkg/gnolang/store.go b/gnovm/pkg/gnolang/store.go index e2dea647ae2..afabd70987b 100644 --- a/gnovm/pkg/gnolang/store.go +++ b/gnovm/pkg/gnolang/store.go @@ -299,7 +299,7 @@ func (ds *defaultStore) GetObjectSafe(oid ObjectID) Object { // loads and caches an object. // CONTRACT: object isn't already in the cache. func (ds *defaultStore) loadObjectSafe(oid ObjectID) Object { - fmt.Println("---loadObjectSafe, oid: ", oid) + debug2.Println2("loadObjectSafe, oid: ", oid) key := backendObjectKey(oid) hashbz := ds.baseStore.Get([]byte(key)) if hashbz != nil { @@ -325,11 +325,11 @@ func (ds *defaultStore) loadObjectSafe(oid ObjectID) Object { // NOTE: unlike GetObject(), SetObject() is also used to persist updated // package values. func (ds *defaultStore) SetObject(oo Object) { - fmt.Println("---SetObject: ", oo) + debug2.Println2("SetObject: ", oo) oid := oo.GetObjectID() // replace children/fields with Ref. o2 := copyValueWithRefs(oo) - fmt.Println("---o2: ", o2) + debug2.Println2("---o2: ", o2) // marshal to binary. bz := amino.MustMarshalAny(o2) // set hash. @@ -400,9 +400,9 @@ func (ds *defaultStore) DelObject(oo Object) { // NOTE: The implementation matches that of GetObject() in anticipation of what // the persistent type system might work like. func (ds *defaultStore) GetType(tid TypeID) Type { - fmt.Println("---GetType: ", tid) + debug2.Println2("GetType: ", tid) tt := ds.GetTypeSafe(tid) - fmt.Println("---tt: ", tt) + debug2.Println2("tt: ", tt) if tt == nil { ds.Print() panic(fmt.Sprintf("unexpected type with id %s", tid.String())) @@ -411,7 +411,7 @@ func (ds *defaultStore) GetType(tid TypeID) Type { } func (ds *defaultStore) GetTypeSafe(tid TypeID) Type { - fmt.Println("---GetTypeSafe: ", tid) + debug2.Println2("GetTypeSafe: ", tid) // check cache. if tt, exists := ds.cacheTypes[tid]; exists { return tt diff --git a/gnovm/pkg/gnolang/values.go b/gnovm/pkg/gnolang/values.go index 53137a75496..8c1cef6c5f5 100644 --- a/gnovm/pkg/gnolang/values.go +++ b/gnovm/pkg/gnolang/values.go @@ -289,7 +289,7 @@ func (pv PointerValue) Assign2(alloc *Allocator, store Store, rlm *Realm, tv2 Ty // General case if rlm != nil && pv.Base != nil { oo1 := pv.TV.GetFirstObject(store) - fmt.Println("---oo1: ", oo1) + debug2.Println2("---oo1: ", oo1) // get origin pkgId _, pkgId := tv2.GetFirstObject2(store) @@ -551,11 +551,11 @@ func (sv *StructValue) Copy(alloc *Allocator) *StructValue { debug2.Println2("sv.GetRefCount: ", sv.GetRefCount()) debug2.Println2("sv...OwneID: ", sv.GetObjectInfo().OwnerID) // append, unref copy... - //pkgId := sv.GetOriginRealm() - //if pkgId.IsZero() { - // pkgId = sv.GetObjectID().PkgID - //} - //nsv.SetOriginRealm(pkgId) + pkgId := sv.GetOriginRealm() + if pkgId.IsZero() { + pkgId = sv.GetObjectID().PkgID + } + nsv.SetOriginRealm(pkgId) return nsv //return alloc.NewStruct(fields) } @@ -1081,7 +1081,7 @@ func (tv TypedValue) Copy(alloc *Allocator) (cp TypedValue) { cp.T = tv.T cp.V = cv.Copy(alloc) default: - println("---default") + debug2.Println2("---default") cp = tv } return @@ -2669,20 +2669,16 @@ func typedString(s string) TypedValue { } func fillValueTV(store Store, tv *TypedValue) *TypedValue { - fmt.Println("---fillValueTV, tv: ", tv) + debug2.Println2("fillValueTV, tv: ", tv) switch cv := tv.V.(type) { case RefValue: - println("---tv.V RefValue") - fmt.Println("---cv: ", cv) if cv.PkgPath != "" { // load package tv.V = store.GetPackage(cv.PkgPath, false) } else { // load object // XXX XXX allocate object. tv.V = store.GetObject(cv.ObjectID) - fmt.Println("---tv.V: ", tv.V) } case PointerValue: - fmt.Println("---PointerValue") // As a special case, cv.Base is filled // and cv.TV set appropriately. // Alternatively, could implement diff --git a/gnovm/tests/files/heap_item_value_init.gno b/gnovm/tests/files/heap_item_value_init.gno index 72f065326f1..152f5ab2784 100644 --- a/gnovm/tests/files/heap_item_value_init.gno +++ b/gnovm/tests/files/heap_item_value_init.gno @@ -83,7 +83,7 @@ func main() { // "@type": "/gno.PointerValue", // "Base": { // "@type": "/gno.RefValue", -// "Escaped": true, +// "Hash": "4f679d9dc2ea37d8f31b020193e7afae0236c97c", // "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:4" // }, // "Index": "0", @@ -102,7 +102,7 @@ func main() { // "@type": "/gno.PointerValue", // "Base": { // "@type": "/gno.RefValue", -// "Escaped": true, +// "Hash": "4f679d9dc2ea37d8f31b020193e7afae0236c97c", // "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:4" // }, // "Index": "0", diff --git a/gnovm/tests/files/zrealm_crossrealm24f.gno b/gnovm/tests/files/zrealm_crossrealm24f.gno index 4be67555c6c..23049563511 100644 --- a/gnovm/tests/files/zrealm_crossrealm24f.gno +++ b/gnovm/tests/files/zrealm_crossrealm24f.gno @@ -8,7 +8,7 @@ import ( var root interface{} func main() { - root = tests.F + root = tests.F // already attached in p println("done") } diff --git a/gnovm/tests/files/zrealm_crossrealm32.gno b/gnovm/tests/files/zrealm_crossrealm32.gno index f3f4e1243e9..f2909115100 100644 --- a/gnovm/tests/files/zrealm_crossrealm32.gno +++ b/gnovm/tests/files/zrealm_crossrealm32.gno @@ -19,7 +19,7 @@ func main() { // Realm: // switchrealm["gno.land/r/demo/tests/crossrealm/slice"] -// c[ff34c6500d0daee58e4ac9899c0e7ecc131db63e:26]={ +// c[ff34c6500d0daee58e4ac9899c0e7ecc131db63e:28]={ // "Fields": [ // { // "T": { @@ -33,13 +33,13 @@ func main() { // } // ], // "ObjectInfo": { -// "ID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:26", +// "ID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:28", // "ModTime": "0", -// "OwnerID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:25", +// "OwnerID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:27", // "RefCount": "1" // } // } -// c[ff34c6500d0daee58e4ac9899c0e7ecc131db63e:27]={ +// c[ff34c6500d0daee58e4ac9899c0e7ecc131db63e:29]={ // "Fields": [ // { // "T": { @@ -53,13 +53,13 @@ func main() { // } // ], // "ObjectInfo": { -// "ID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:27", +// "ID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:29", // "ModTime": "0", -// "OwnerID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:25", +// "OwnerID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:27", // "RefCount": "1" // } // } -// c[ff34c6500d0daee58e4ac9899c0e7ecc131db63e:25]={ +// c[ff34c6500d0daee58e4ac9899c0e7ecc131db63e:27]={ // "Data": null, // "List": [ // { @@ -69,8 +69,8 @@ func main() { // }, // "V": { // "@type": "/gno.RefValue", -// "Hash": "47bf5eb54da0545110d6486001609dc4203f61b0", -// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:26" +// "Hash": "c6f0c0407c9697a6a91451eb572489913de89e71", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:28" // } // }, // { @@ -80,13 +80,13 @@ func main() { // }, // "V": { // "@type": "/gno.RefValue", -// "Hash": "eaa3017cfcfafd8f8217ee1df0afdac5e4ad12a9", -// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:27" +// "Hash": "2a99f0d55ccbad80a109cecd6fa9a0dece4df7cc", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:29" // } // } // ], // "ObjectInfo": { -// "ID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:25", +// "ID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:27", // "ModTime": "0", // "OwnerID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:2", // "RefCount": "1" @@ -97,7 +97,7 @@ func main() { // "ObjectInfo": { // "ID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:2", // "IsEscaped": true, -// "ModTime": "24", +// "ModTime": "26", // "RefCount": "2" // }, // "Parent": null, @@ -259,8 +259,8 @@ func main() { // "@type": "/gno.SliceValue", // "Base": { // "@type": "/gno.RefValue", -// "Hash": "0934dceb3731dd613f35a5e4a4a82396f3dc474e", -// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:11" +// "Hash": "63edd934ae4e6e1adfa3e8ccaec695d037023467", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:14" // }, // "Length": "2", // "Maxcap": "2", @@ -280,8 +280,8 @@ func main() { // "@type": "/gno.SliceValue", // "Base": { // "@type": "/gno.RefValue", -// "Hash": "fcdb6b41091d087be521ae9be69b8328ac495677", -// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:25" +// "Hash": "c1cb1b78808a97bdeb22bdb8fe51cbc5ebe27c15", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:27" // }, // "Length": "2", // "Maxcap": "2", @@ -301,11 +301,11 @@ func main() { // "@type": "/gno.SliceValue", // "Base": { // "@type": "/gno.RefValue", -// "Hash": "9073c630fa09e61b0e3b824056c022eebe7bd86b", -// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:16" +// "Hash": "5b15d0ddccc7056f8a23f92113551faf3458362a", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:4" // }, // "Length": "1", -// "Maxcap": "1", +// "Maxcap": "2", // "Offset": "0" // } // }, @@ -325,8 +325,8 @@ func main() { // "@type": "/gno.SliceValue", // "Base": { // "@type": "/gno.RefValue", -// "Hash": "088eb6ee7e7fe1c5e10101801be9e64ac6794e29", -// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:18" +// "Hash": "c4c833f476004da7b523986bfc338fcd6e2259cc", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:20" // }, // "Length": "1", // "Maxcap": "1", @@ -349,8 +349,8 @@ func main() { // "@type": "/gno.SliceValue", // "Base": { // "@type": "/gno.RefValue", -// "Hash": "3450ddb4764c2026edd313f230c633e0af6cd8ed", -// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:4" +// "Hash": "47988816818ccc2d075b63242db659eaceb17c09", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:7" // }, // "Length": "2", // "Maxcap": "2", @@ -369,8 +369,8 @@ func main() { // }, // "V": { // "@type": "/gno.RefValue", -// "Hash": "e03c7067902bb4b3c2aa477a27d6abfcd51ce3a6", -// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:5" +// "Hash": "2120aae986302ac34c4d0215158d9bb3aa8e5234", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:8" // } // }, // { @@ -398,7 +398,7 @@ func main() { // "Location": { // "Column": "1", // "File": "crossrealm_slice.gno", -// "Line": "27", +// "Line": "32", // "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, @@ -448,7 +448,7 @@ func main() { // "Location": { // "Column": "1", // "File": "crossrealm_slice.gno", -// "Line": "42", +// "Line": "48", // "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, @@ -480,8 +480,8 @@ func main() { // }, // "V": { // "@type": "/gno.RefValue", -// "Hash": "d10003fa5a9ebd5bb30cadd5e11bd5aad76ec9f4", -// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:8" +// "Hash": "ee138dfe6fb2fb9d6702fd4a426d40a2ca55e022", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:11" // } // }, // { @@ -491,8 +491,8 @@ func main() { // }, // "V": { // "@type": "/gno.RefValue", -// "Hash": "8a2889ef5ccf6c7e4ec0c59ed627267fa3a51026", -// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:9" +// "Hash": "af3ef02e37f329c151774dc9a73c38f2bd8b5c15", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:12" // } // }, // { @@ -534,7 +534,7 @@ func main() { // "Location": { // "Column": "1", // "File": "crossrealm_slice.gno", -// "Line": "50", +// "Line": "56", // "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, @@ -598,7 +598,7 @@ func main() { // "Location": { // "Column": "1", // "File": "crossrealm_slice.gno", -// "Line": "58", +// "Line": "64", // "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, @@ -673,7 +673,7 @@ func main() { // "Location": { // "Column": "1", // "File": "crossrealm_slice.gno", -// "Line": "63", +// "Line": "69", // "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, @@ -751,7 +751,7 @@ func main() { // "Location": { // "Column": "1", // "File": "crossrealm_slice.gno", -// "Line": "68", +// "Line": "74", // "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, @@ -832,7 +832,7 @@ func main() { // "Location": { // "Column": "1", // "File": "crossrealm_slice.gno", -// "Line": "72", +// "Line": "78", // "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, @@ -922,7 +922,7 @@ func main() { // "Location": { // "Column": "1", // "File": "crossrealm_slice.gno", -// "Line": "77", +// "Line": "83", // "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, @@ -971,8 +971,8 @@ func main() { // }, // "V": { // "@type": "/gno.RefValue", -// "Hash": "ed9761e4c90097cbcf3d55a627ab1b7c65ff8a62", -// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:10" +// "Hash": "fc759b6634b8975a76435bc16085d82c322842ae", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:13" // } // }, // { @@ -1025,7 +1025,7 @@ func main() { // "Location": { // "Column": "1", // "File": "crossrealm_slice.gno", -// "Line": "84", +// "Line": "90", // "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, @@ -1111,7 +1111,7 @@ func main() { // "Location": { // "Column": "1", // "File": "crossrealm_slice.gno", -// "Line": "89", +// "Line": "95", // "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, @@ -1149,8 +1149,8 @@ func main() { // } // ] // } -// d[ff34c6500d0daee58e4ac9899c0e7ecc131db63e:14] -// d[ff34c6500d0daee58e4ac9899c0e7ecc131db63e:15] +// d[ff34c6500d0daee58e4ac9899c0e7ecc131db63e:17] +// d[ff34c6500d0daee58e4ac9899c0e7ecc131db63e:18] // switchrealm["gno.land/r/crossrealm_test"] // u[f5a516808f8976c33939133293d598ce3bca4e8d:2]={ // "Blank": {}, @@ -1186,7 +1186,7 @@ func main() { // "Base": { // "@type": "/gno.RefValue", // "Escaped": true, -// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:25" +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:27" // }, // "Length": "2", // "Maxcap": "2", @@ -1398,8 +1398,8 @@ func main() { // "@type": "/gno.SliceValue", // "Base": { // "@type": "/gno.RefValue", -// "Hash": "0934dceb3731dd613f35a5e4a4a82396f3dc474e", -// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:11" +// "Hash": "63edd934ae4e6e1adfa3e8ccaec695d037023467", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:14" // }, // "Length": "2", // "Maxcap": "2", @@ -1420,7 +1420,7 @@ func main() { // "Base": { // "@type": "/gno.RefValue", // "Escaped": true, -// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:25" +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:27" // }, // "Length": "2", // "Maxcap": "2", @@ -1440,11 +1440,11 @@ func main() { // "@type": "/gno.SliceValue", // "Base": { // "@type": "/gno.RefValue", -// "Hash": "9073c630fa09e61b0e3b824056c022eebe7bd86b", -// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:16" +// "Hash": "5b15d0ddccc7056f8a23f92113551faf3458362a", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:4" // }, // "Length": "1", -// "Maxcap": "1", +// "Maxcap": "2", // "Offset": "0" // } // }, @@ -1464,8 +1464,8 @@ func main() { // "@type": "/gno.SliceValue", // "Base": { // "@type": "/gno.RefValue", -// "Hash": "088eb6ee7e7fe1c5e10101801be9e64ac6794e29", -// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:18" +// "Hash": "c4c833f476004da7b523986bfc338fcd6e2259cc", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:20" // }, // "Length": "1", // "Maxcap": "1", @@ -1488,8 +1488,8 @@ func main() { // "@type": "/gno.SliceValue", // "Base": { // "@type": "/gno.RefValue", -// "Hash": "3450ddb4764c2026edd313f230c633e0af6cd8ed", -// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:4" +// "Hash": "47988816818ccc2d075b63242db659eaceb17c09", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:7" // }, // "Length": "2", // "Maxcap": "2", @@ -1508,8 +1508,8 @@ func main() { // }, // "V": { // "@type": "/gno.RefValue", -// "Hash": "e03c7067902bb4b3c2aa477a27d6abfcd51ce3a6", -// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:5" +// "Hash": "2120aae986302ac34c4d0215158d9bb3aa8e5234", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:8" // } // }, // { @@ -1537,7 +1537,7 @@ func main() { // "Location": { // "Column": "1", // "File": "crossrealm_slice.gno", -// "Line": "27", +// "Line": "32", // "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, @@ -1587,7 +1587,7 @@ func main() { // "Location": { // "Column": "1", // "File": "crossrealm_slice.gno", -// "Line": "42", +// "Line": "48", // "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, @@ -1619,8 +1619,8 @@ func main() { // }, // "V": { // "@type": "/gno.RefValue", -// "Hash": "d10003fa5a9ebd5bb30cadd5e11bd5aad76ec9f4", -// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:8" +// "Hash": "ee138dfe6fb2fb9d6702fd4a426d40a2ca55e022", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:11" // } // }, // { @@ -1630,8 +1630,8 @@ func main() { // }, // "V": { // "@type": "/gno.RefValue", -// "Hash": "8a2889ef5ccf6c7e4ec0c59ed627267fa3a51026", -// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:9" +// "Hash": "af3ef02e37f329c151774dc9a73c38f2bd8b5c15", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:12" // } // }, // { @@ -1673,7 +1673,7 @@ func main() { // "Location": { // "Column": "1", // "File": "crossrealm_slice.gno", -// "Line": "50", +// "Line": "56", // "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, @@ -1737,7 +1737,7 @@ func main() { // "Location": { // "Column": "1", // "File": "crossrealm_slice.gno", -// "Line": "58", +// "Line": "64", // "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, @@ -1812,7 +1812,7 @@ func main() { // "Location": { // "Column": "1", // "File": "crossrealm_slice.gno", -// "Line": "63", +// "Line": "69", // "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, @@ -1890,7 +1890,7 @@ func main() { // "Location": { // "Column": "1", // "File": "crossrealm_slice.gno", -// "Line": "68", +// "Line": "74", // "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, @@ -1971,7 +1971,7 @@ func main() { // "Location": { // "Column": "1", // "File": "crossrealm_slice.gno", -// "Line": "72", +// "Line": "78", // "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, @@ -2061,7 +2061,7 @@ func main() { // "Location": { // "Column": "1", // "File": "crossrealm_slice.gno", -// "Line": "77", +// "Line": "83", // "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, @@ -2110,8 +2110,8 @@ func main() { // }, // "V": { // "@type": "/gno.RefValue", -// "Hash": "ed9761e4c90097cbcf3d55a627ab1b7c65ff8a62", -// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:10" +// "Hash": "fc759b6634b8975a76435bc16085d82c322842ae", +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:13" // } // }, // { @@ -2164,7 +2164,7 @@ func main() { // "Location": { // "Column": "1", // "File": "crossrealm_slice.gno", -// "Line": "84", +// "Line": "90", // "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, @@ -2250,7 +2250,7 @@ func main() { // "Location": { // "Column": "1", // "File": "crossrealm_slice.gno", -// "Line": "89", +// "Line": "95", // "PkgPath": "gno.land/r/demo/tests/crossrealm/slice" // } // }, diff --git a/gnovm/tests/files/zrealm_crossrealm34.gno b/gnovm/tests/files/zrealm_crossrealm34.gno index 0875ef6a92a..75abe495d4d 100644 --- a/gnovm/tests/files/zrealm_crossrealm34.gno +++ b/gnovm/tests/files/zrealm_crossrealm34.gno @@ -57,7 +57,7 @@ func main() { // "Base": { // "@type": "/gno.RefValue", // "Escaped": true, -// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:18" +// "ObjectID": "ff34c6500d0daee58e4ac9899c0e7ecc131db63e:20" // }, // "Length": "1", // "Maxcap": "1", diff --git a/gnovm/tests/files/zrealm_crossrealm34a.gno b/gnovm/tests/files/zrealm_crossrealm34a.gno index 85a55301ebd..faace075600 100644 --- a/gnovm/tests/files/zrealm_crossrealm34a.gno +++ b/gnovm/tests/files/zrealm_crossrealm34a.gno @@ -19,4 +19,4 @@ func main() { } // Error: -// should not happen, struct{("6.1" string)} is not real +// cannot attach un-real object from external realm: struct{("6.1" string)} diff --git a/gnovm/tests/files/zrealm_natbind0_stdlibs.gno b/gnovm/tests/files/zrealm_natbind0_stdlibs.gno deleted file mode 100644 index c852f4a09f7..00000000000 --- a/gnovm/tests/files/zrealm_natbind0_stdlibs.gno +++ /dev/null @@ -1,180 +0,0 @@ -// PKGPATH: gno.land/r/test -package test - -import ( - "std" -) - -var node interface{} - -func init() { - node = std.GetHeight -} - -func main() { - // NOTE: this test uses GetHeight and GetChainID, which are "pure" - // natively bound functions (ie. not indirections through a wrapper fn, - // to convert the types to builtin go/gno identifiers). - f := node.(func() int64) - println(f()) - node = std.GetChainID - g := node.(func() string) - println(g()) -} - -// Output: -// 123 -// dev - -// Realm: -// switchrealm["gno.land/r/test"] -// u[a8ada09dee16d791fd406d629fe29bb0ed084a30:2]={ -// "Blank": {}, -// "ObjectInfo": { -// "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:2", -// "IsEscaped": true, -// "ModTime": "3", -// "RefCount": "2" -// }, -// "Parent": null, -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "0", -// "File": "", -// "Line": "0", -// "PkgPath": "gno.land/r/test" -// } -// }, -// "Values": [ -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// } -// } -// ] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "a7f5397443359ea76c50be82c77f1f893a060925:8" -// }, -// "FileName": "native.gno", -// "IsMethod": false, -// "Name": "GetChainID", -// "NativeName": "GetChainID", -// "NativePkg": "std", -// "PkgPath": "std", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "native.gno", -// "Line": "13", -// "PkgPath": "std" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [ -// { -// "Embedded": false, -// "Name": "", -// "Tag": "", -// "Type": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// } -// } -// ] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:3" -// }, -// "FileName": "main.gno", -// "IsMethod": false, -// "Name": "init.1", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/test", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "main.gno", -// "Line": "10", -// "PkgPath": "gno.land/r/test" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:3" -// }, -// "FileName": "main.gno", -// "IsMethod": false, -// "Name": "main", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/test", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "main.gno", -// "Line": "14", -// "PkgPath": "gno.land/r/test" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// } -// } -// } -// ] -// } diff --git a/gnovm/tests/files/zrealm_tests0_stdlibs.gno b/gnovm/tests/files/zrealm_tests0_stdlibs.gno index d11701505e5..b6b15229457 100644 --- a/gnovm/tests/files/zrealm_tests0_stdlibs.gno +++ b/gnovm/tests/files/zrealm_tests0_stdlibs.gno @@ -1760,8 +1760,5 @@ func main() { // } // d[0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:13] // switchrealm["gno.land/r/demo/tests_foo"] -// switchrealm["gno.land/r/demo/tests_foo"] -// switchrealm["gno.land/r/demo/tests_foo"] -// switchrealm["gno.land/r/demo/tests_foo"] // switchrealm["gno.land/r/demo/tests"] // switchrealm["gno.land/r/demo/tests_test"] From 926e6e91d8d05d2ac71e601c70b1e79c4c8412b2 Mon Sep 17 00:00:00 2001 From: ltzMaxwell Date: Mon, 6 Jan 2025 16:35:39 +0800 Subject: [PATCH 39/40] fixup --- gnovm/pkg/gnolang/ownership.go | 44 +- gnovm/pkg/gnolang/realm.go | 203 +++------ gnovm/pkg/gnolang/values.go | 19 +- gnovm/tests/files/zrealm6.gno | 324 +------------ gnovm/tests/files/zrealm7.gno | 427 +----------------- gnovm/tests/files/zrealm_natbind0_stdlibs.gno | 26 ++ 6 files changed, 125 insertions(+), 918 deletions(-) create mode 100644 gnovm/tests/files/zrealm_natbind0_stdlibs.gno diff --git a/gnovm/pkg/gnolang/ownership.go b/gnovm/pkg/gnolang/ownership.go index f10543cdfa0..4aa7fe22f1f 100644 --- a/gnovm/pkg/gnolang/ownership.go +++ b/gnovm/pkg/gnolang/ownership.go @@ -388,37 +388,33 @@ func (tv *TypedValue) GetFirstObject(store Store) Object { } } -// also get pkgId of the object, so it's clear where the object is from -// TODO, just return isRealm -func (tv *TypedValue) GetFirstObject2(store Store) (obj Object, pkgId PkgID) { - debug2.Println2("GetFirstObject2---, tv: ", tv, reflect.TypeOf(tv.V)) - +// GetOriginPkg get origin pkg for real or unreal object +func (tv *TypedValue) GetOriginPkg(store Store) (originPkg PkgID) { + debug2.Println2("GetOriginPkg, tv: ", tv, reflect.TypeOf(tv.V)) // get first object - obj = tv.GetFirstObject(store) + obj := tv.GetFirstObject(store) debug2.Println2("obj: ", obj) - if obj != nil { - - pkgId = obj.GetOriginRealm() - if pkgId.IsZero() { - pkgId = obj.GetObjectID().PkgID + originPkg = obj.GetOriginRealm() + if originPkg.IsZero() { + originPkg = obj.GetObjectID().PkgID } debug2.Println2("obj.GetObjectInfo(): ", obj.GetObjectInfo()) - debug2.Println2("obj.GetObjectID.PkgID: ", pkgId) + debug2.Println2("obj.originPkg: ", originPkg) } - if pkgId.IsZero() { + // if still zero + if originPkg.IsZero() { switch cv := obj.(type) { case *ArrayValue: debug2.Println2("array value, T: ", tv.T) debug2.Println2("objectInfo: ", cv.GetObjectInfo()) if IsRealmPath(tv.T.Elem().GetPkgPath()) { - // TODO: func type don't have pkgpath, retrieve from clo - pkgId = PkgIDFromPkgPath(tv.T.Elem().GetPkgPath()) + originPkg = PkgIDFromPkgPath(tv.T.Elem().GetPkgPath()) } return case *Block: - pkgId = PkgIDFromPkgPath(cv.Source.GetLocation().PkgPath) + originPkg = PkgIDFromPkgPath(cv.Source.GetLocation().PkgPath) return case *HeapItemValue: debug2.Println2("heapItemValue: ", cv) @@ -429,24 +425,24 @@ func (tv *TypedValue) GetFirstObject2(store Store) (obj Object, pkgId PkgID) { if _, ok := dt.Base.(*FuncType); !ok { debug2.Println2("---dt.base.PkgPath: ", dt.Base.GetPkgPath()) if IsRealmPath(dt.Base.GetPkgPath()) { - pkgId = PkgIDFromPkgPath(dt.Base.GetPkgPath()) + originPkg = PkgIDFromPkgPath(dt.Base.GetPkgPath()) } } } return case *BoundMethodValue: + debug2.Println2("boundMethodValue: ", cv) debug2.Println2("BoundMethodValue, recv: ", cv.Receiver) - debug2.Println2("---type of T: ", reflect.TypeOf(cv.Receiver.T)) + debug2.Println2("type of T: ", reflect.TypeOf(cv.Receiver.T)) if pv, ok := cv.Receiver.V.(PointerValue); ok { - debug2.Println2("---pointer value") - // TODO: check this + debug2.Println2("pointer value, pv: ", pv) if dt, ok := pv.TV.T.(*DeclaredType); ok { - fmt.Println("---2, dt: ", dt) + debug2.Println2("---2, dt: ", dt) if IsRealmPath(dt.PkgPath) { - pkgId = PkgIDFromPkgPath(dt.PkgPath) + originPkg = PkgIDFromPkgPath(dt.PkgPath) } } - debug2.Println2("---pkgId; ", pkgId) + debug2.Println2("originPkg; ", originPkg) } return case *MapValue, *StructValue: @@ -456,7 +452,7 @@ func (tv *TypedValue) GetFirstObject2(store Store) (obj Object, pkgId PkgID) { if _, ok := dt.Base.(*FuncType); !ok { debug2.Println2("---dt.base.PkgPath: ", dt.Base.GetPkgPath()) if IsRealmPath(dt.Base.GetPkgPath()) { - pkgId = PkgIDFromPkgPath(dt.Base.GetPkgPath()) + originPkg = PkgIDFromPkgPath(dt.Base.GetPkgPath()) } } } diff --git a/gnovm/pkg/gnolang/realm.go b/gnovm/pkg/gnolang/realm.go index a7dffcdd8e6..74e991b1d6c 100644 --- a/gnovm/pkg/gnolang/realm.go +++ b/gnovm/pkg/gnolang/realm.go @@ -138,9 +138,6 @@ func (rlm *Realm) DidUpdate(po, xo, co Object) { return } if debug { - if co != nil && co.GetIsDeleted() { - panic("cannot attach a deleted object") - } if po != nil && po.GetIsTransient() { panic("cannot attach to a transient object") } @@ -166,25 +163,6 @@ func (rlm *Realm) DidUpdate(po, xo, co Object) { // More appends happen during FinalizeRealmTransactions(). (second+ gen) rlm.MarkDirty(po) - if co != nil { - // XXX, inc ref count everytime assignment happens - co.IncRefCount() - if co.GetRefCount() > 1 { - if co.GetIsEscaped() { - // XXX, why packageBlock is automatically escaped? - // already escaped - } else { - // XXX, just mark - rlm.MarkNewEscaped(co) - } - } else if co.GetIsReal() { - rlm.MarkDirty(co) - } else { - co.SetOwner(po) - rlm.MarkNewReal(co) // co will be attached when finalize - } - } - if xo != nil { xo.DecRefCount() if xo.GetRefCount() == 0 { @@ -200,10 +178,10 @@ func (rlm *Realm) DidUpdate2(store Store, po, xo, co Object, refValue Value) { debug2.Printf2("DidUpdate2, po: %v, type of po: %v\n", po, reflect.TypeOf(po)) debug2.Printf2("xo: %v, type of xo: %v\n", xo, reflect.TypeOf(xo)) debug2.Printf2("co: %v, type of co: %v\n", co, reflect.TypeOf(co)) + debug2.Println2("---rlm.ID: ", rlm.ID) if co != nil { debug2.Println2("co.GetOriginRealm: ", co.GetOriginRealm()) } - debug2.Println2("---rlm.ID: ", rlm.ID) if rlm == nil { return @@ -220,17 +198,13 @@ func (rlm *Realm) DidUpdate2(store Store, po, xo, co Object, refValue Value) { } } - // if oo.GetRefCount() > 0 - if refValue != nil { - co.SetIsRef(true) - } - if po == nil || !po.GetIsReal() { // XXX, make sure po is attached debug2.Println2("po not real, do nothing!!!") return // do nothing. } - // TODO: check not real external here, if po is real, association is invalid + // TODO: check unreal external here, if po is real, association is invalid, panic + // else, defer to finalize??? debug2.Println2("po.GetObjectID().PkgID: ", po.GetObjectID().PkgID) if po.GetObjectID().PkgID != rlm.ID { panic("cannot modify external-realm or non-realm object") @@ -250,16 +224,7 @@ func (rlm *Realm) DidUpdate2(store Store, po, xo, co Object, refValue Value) { //fmt.Println("---co.GetRefCount: ", co.GetRefCount()) // XXX, inc ref count everytime assignment happens co.IncRefCount() - debug2.Println2("after inc, co.GetRefCount: ", co.GetRefCount()) if co.GetRefCount() > 1 { - //if co.GetIsEscaped() { - // debug2.Println2("already escaped, should check cross realm?") - // // already escaped in current realm, can also be escaped to other realm - // rlm.MarkNewEscapedCheckCrossRealm(store, co, refValue) - //} else { - // rlm.MarkNewEscapedCheckCrossRealm(store, co, refValue) - //} - // debug2.Println2("already escaped, should check cross realm?") rlm.MarkNewEscapedCheckCrossRealm(store, co, refValue) } else if co.GetIsReal() { rlm.MarkDirty(co) @@ -282,113 +247,73 @@ func (rlm *Realm) DidUpdate2(store Store, po, xo, co Object, refValue Value) { //---------------------------------------- // mark* -// XXX, oo here must be referenced type, since they already escaped. -// XXX, so oo has been persisted, thus fillValueTV +func checkCrossRealm2(rlm *Realm, store Store, tv *TypedValue) { + debug2.Printf2("checkCrossRealm2, tv: %v\n", tv) + if fo, ok := tv.V.(Object); ok { + checkCrossRealm(rlm, store, fo, nil) + } else { // reference to object + //var reo Object + switch rv := tv.V.(type) { + case *SliceValue, PointerValue: // if reference object from external realm + // XXX: consider pkgId here, A -> B - > A?... + reo := tv.GetFirstObject(store) + debug2.Println2("reo: ", reo) + checkCrossRealm(rlm, store, reo, rv) + } + } +} + +// checkCrossRealm check cross realm recursively func checkCrossRealm(rlm *Realm, store Store, oo Object, refValue Value) { - debug2.Println2("checkCrossRealm, oo: ", oo, reflect.TypeOf(oo)) + fmt.Println("checkCrossRealm, oo: ", oo, reflect.TypeOf(oo)) debug2.Println2("oo.GetRefCount: ", oo.GetRefCount()) debug2.Println2("oo.GetObjectInfo: ", oo.GetObjectInfo()) switch v := oo.(type) { case *StructValue: - - //debug2.Println2("oo.GetOriginRealm: ", oo.GetOriginRealm()) - //if refValue == nil { // not ref - // if rlm.ID != oo.GetOriginRealm() { - // panic("cannot attach object from external realm") - // } - //} - - // ref, check real - //if oo.GetObjectID().IsZero() { - //} - //// TODO: rm this if !v.GetIsReal() { - panic(fmt.Sprintf("cannot attach un-real object from external realm: %v", v)) + if rlm.ID != oo.GetOriginRealm() { // it's ok for un-real object from same realm + panic(fmt.Sprintf("cannot attach un-real object from external realm: %v", v)) + } } // check fields for _, fv := range v.Fields { - debug2.Println2("fv: ", fv) rfv := fillValueTV(store, &fv) - debug2.Println2("---rfv: ", rfv) - - if fo, ok := rfv.V.(Object); ok { - checkCrossRealm(rlm, store, fo, nil) - } else { // reference to object - var reo Object - switch rv := rfv.V.(type) { - case *SliceValue, PointerValue: // if reference object from external realm - refValue = rv - // TODO: consider pkgId here, A -> B - > A?... - // yes, check PkgId per object - var pkgId PkgID - reo, pkgId = rfv.GetFirstObject2(store) - // TODO: simplify - if !pkgId.IsZero() { - reo.SetOriginRealm(pkgId) - } - debug2.Println2("reo: ", reo) - // XXX, if elem of array is slice?, GetFirstObject2?... - checkCrossRealm(rlm, store, reo, refValue) - } - } + checkCrossRealm2(rlm, store, rfv) } case *MapValue: - println("---mapValue...") - // TODO: check elem? + // TODO: check recursively + case *BoundMethodValue: + // TODO: check recursively + case *Block: + // XXX, can this happen? + if !v.GetIsRef() { + panic("should not happen, block is not real") + } case *HeapItemValue: - debug2.Println2("---heapItemValue: ", v) - r := fillValueTV(store, &v.Value) - debug2.Println2("---r: ", r) - - checkCrossRealm(rlm, store, v.Value.V.(Object), refValue) + // TODO: is it necessary? + // if heapItem, the embedded should be all real now??? + fillValueTV(store, &v.Value) + checkCrossRealm2(rlm, store, &v.Value) case *ArrayValue: - if sv, ok := refValue.(*SliceValue); !ok { - panic("should be slice value") - } else { - offset := sv.Offset - length := sv.Length + if sv, ok := refValue.(*SliceValue); ok { debug2.Println2("ArrayValue: ", v) - debug2.Printf2("offset: %d, length: %d \n", offset, length) - debug2.Println2("escaped array, check if elements are real") - - // check referenced elem - for i := offset; i < length; i++ { - // XXX, difference between them? - ee := v.List[i] - e := fillValueTV(store, &ee) - //e := oo.(*ArrayValue).GetPointerAtIndexInt2(store, i, nil).Deref() - - debug2.Printf2("---e[%d]: %v\n", i, e) - debug2.Printf2("---type of e[%d].V: %v\n", i, reflect.TypeOf(e.V)) - //debug2.Println2("e...GetOriginRealm: ", e.V.(Object).GetOriginRealm()) - //debug2.Println2("e....GetObjectInfo: ", e.V.(Object).GetObjectInfo()) - - if eo, ok := e.V.(Object); ok { - checkCrossRealm(rlm, store, eo, refValue) - } else { // reference to object - var reo Object - switch rv := e.V.(type) { - case *SliceValue, PointerValue: // if reference object from external realm - refValue = rv - // TODO: consider pkgId here, A -> B - > A?... - var pkgId PkgID - reo, pkgId = e.GetFirstObject2(store) - // TODO: simplify - if !pkgId.IsZero() { - reo.SetOriginRealm(pkgId) - } - // XXX, if elem of array is slice?, GetFirstObject2?... - checkCrossRealm(rlm, store, reo, refValue) - } - } + debug2.Println2("SliceValue: ", sv) + // only check referenced elem + for i := sv.Offset; i < sv.Length; i++ { + e := fillValueTV(store, &v.List[i]) + debug2.Printf2("e[%d]: %v\n", i, e) + debug2.Printf2("type of e[%d].V: %v\n", i, reflect.TypeOf(e.V)) + checkCrossRealm2(rlm, store, e) } + } else { + panic("should be slice value") } default: - //fmt.Println("---v :", v) + panic("should not happen, oo is not object") } } -// escaped realm should be reference object +// MarkNewEscapedCheckCrossRealm check for escaped object func (rlm *Realm) MarkNewEscapedCheckCrossRealm(store Store, oo Object, refValue Value) { //fmt.Println("MarkNewEscapedCheckCrossRealm, oo: ", oo) //fmt.Println("refValue: ", refValue) @@ -447,8 +372,8 @@ func (rlm *Realm) MarkNewReal(oo Object) { // mark dirty == updated func (rlm *Realm) MarkDirty(oo Object) { - //fmt.Printf("---current rlm: %v: \n", rlm) - //fmt.Printf("---Mark Dirty %v: \n", oo) + //debug2.Printf2("---current rlm: %v: \n", rlm) + //debug2.Printf2("---Mark Dirty %v: \n", oo) if debug { if !oo.GetIsReal() && !oo.GetIsNewReal() { panic("cannot mark unreal object as dirty") @@ -525,13 +450,13 @@ func (rlm *Realm) FinalizeRealmTransaction(readonly bool, store Store) { }() if readonly { if true || - len(rlm.newCreated) > 0 || - len(rlm.newEscaped) > 0 || - len(rlm.newDeleted) > 0 || - len(rlm.created) > 0 || - len(rlm.updated) > 0 || - len(rlm.deleted) > 0 || - len(rlm.escaped) > 0 { + len(rlm.newCreated) > 0 || + len(rlm.newEscaped) > 0 || + len(rlm.newDeleted) > 0 || + len(rlm.created) > 0 || + len(rlm.updated) > 0 || + len(rlm.deleted) > 0 || + len(rlm.escaped) > 0 { panic("realm updates in readonly transaction") } return @@ -546,9 +471,9 @@ func (rlm *Realm) FinalizeRealmTransaction(readonly bool, store Store) { ensureUniq(rlm.newDeleted) ensureUniq(rlm.updated) if false || - rlm.created != nil || - rlm.deleted != nil || - rlm.escaped != nil { + rlm.created != nil || + rlm.deleted != nil || + rlm.escaped != nil { panic("realm should not have created, deleted, or escaped marks before beginning finalization") } } @@ -963,9 +888,9 @@ func (rlm *Realm) saveUnsavedObjectRecursively(store Store, oo Object) { } // deleted objects should not have gotten here. if false || - oo.GetRefCount() <= 0 || - oo.GetIsNewDeleted() || - oo.GetIsDeleted() { + oo.GetRefCount() <= 0 || + oo.GetIsNewDeleted() || + oo.GetIsDeleted() { panic("cannot save deleted objects") } } diff --git a/gnovm/pkg/gnolang/values.go b/gnovm/pkg/gnolang/values.go index 8c1cef6c5f5..3ab0e700ec7 100644 --- a/gnovm/pkg/gnolang/values.go +++ b/gnovm/pkg/gnolang/values.go @@ -292,23 +292,27 @@ func (pv PointerValue) Assign2(alloc *Allocator, store Store, rlm *Realm, tv2 Ty debug2.Println2("---oo1: ", oo1) // get origin pkgId - _, pkgId := tv2.GetFirstObject2(store) - debug2.Println2("pkgId: ", pkgId) + originPkg := tv2.GetOriginPkg(store) + debug2.Println2("originPkg: ", originPkg) pv.TV.Assign(alloc, tv2, cu) + // get origin pkgId, this should happen before assign, + // because assign will discard original object info + oo2 := pv.TV.GetFirstObject(store) - // TODO: move to GetFirstObject2 + debug2.Println2("oo2: ", oo2) + + // refValue checks for embedded values in the base var refValue Value switch rv := pv.TV.V.(type) { case *SliceValue, PointerValue: refValue = rv + oo2.SetIsRef(true) } - debug2.Println2("oo2: ", oo2) - debug2.Println2("pkgId: ", pkgId) - if oo2 != nil && !pkgId.IsZero() { // cross realm - oo2.SetOriginRealm(pkgId) // attach origin package info + if oo2 != nil && !originPkg.IsZero() { + oo2.SetOriginRealm(originPkg) // attach origin package info } rlm.DidUpdate2(store, pv.Base.(Object), oo1, oo2, refValue) } else { @@ -2707,7 +2711,6 @@ func fillValueTV(store Store, tv *TypedValue) *TypedValue { vpv := cb.GetPointerToInt(store, cv.Index) cv.TV = vpv.TV // TODO optimize? case *HeapItemValue: - //fmt.Println("---HeapItemValue: ", cb.Value) cv.TV = &cb.Value default: panic("should not happen") diff --git a/gnovm/tests/files/zrealm6.gno b/gnovm/tests/files/zrealm6.gno index 9fb36c64a14..3fb348cb4cd 100644 --- a/gnovm/tests/files/zrealm6.gno +++ b/gnovm/tests/files/zrealm6.gno @@ -19,325 +19,5 @@ func main() { println(updated, tree.Size()) } -// Output: -// false 3 - -// Realm: -// switchrealm["gno.land/r/test"] -// c[a8ada09dee16d791fd406d629fe29bb0ed084a30:9]={ -// "Fields": [ -// { -// "T": { -// "@type": "/gno.RefType", -// "ID": "github.com/gnolang/gno/_test/timtadh/data_structures/types.String" -// }, -// "V": { -// "@type": "/gno.StringValue", -// "value": "key3" -// } -// }, -// { -// "T": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// }, -// "V": { -// "@type": "/gno.StringValue", -// "value": "value3" -// } -// }, -// { -// "N": "AQAAAAAAAAA=", -// "T": { -// "@type": "/gno.PrimitiveType", -// "value": "32" -// } -// }, -// { -// "T": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "github.com/gnolang/gno/_test/timtadh/data_structures/tree/avl.AvlNode" -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "github.com/gnolang/gno/_test/timtadh/data_structures/tree/avl.AvlNode" -// } -// } -// } -// ], -// "ObjectInfo": { -// "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:9", -// "ModTime": "0", -// "OwnerID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:8", -// "RefCount": "1" -// } -// } -// c[a8ada09dee16d791fd406d629fe29bb0ed084a30:8]={ -// "ObjectInfo": { -// "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:8", -// "ModTime": "0", -// "OwnerID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:7", -// "RefCount": "1" -// }, -// "Value": { -// "T": { -// "@type": "/gno.RefType", -// "ID": "github.com/gnolang/gno/_test/timtadh/data_structures/tree/avl.AvlNode" -// }, -// "V": { -// "@type": "/gno.RefValue", -// "Hash": "34a46349a2bc1b58591d0222a145b585452683be", -// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:9" -// } -// } -// } -// u[a8ada09dee16d791fd406d629fe29bb0ed084a30:7]={ -// "Fields": [ -// { -// "T": { -// "@type": "/gno.RefType", -// "ID": "github.com/gnolang/gno/_test/timtadh/data_structures/types.String" -// }, -// "V": { -// "@type": "/gno.StringValue", -// "value": "key1" -// } -// }, -// { -// "T": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// }, -// "V": { -// "@type": "/gno.StringValue", -// "value": "value1" -// } -// }, -// { -// "N": "AgAAAAAAAAA=", -// "T": { -// "@type": "/gno.PrimitiveType", -// "value": "32" -// } -// }, -// { -// "T": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "github.com/gnolang/gno/_test/timtadh/data_structures/tree/avl.AvlNode" -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "github.com/gnolang/gno/_test/timtadh/data_structures/tree/avl.AvlNode" -// } -// }, -// "V": { -// "@type": "/gno.PointerValue", -// "Base": { -// "@type": "/gno.RefValue", -// "Hash": "81074f5da453299a913435a2ddd05248ee012f8c", -// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:8" -// }, -// "Index": "0", -// "TV": null -// } -// } -// ], -// "ObjectInfo": { -// "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:7", -// "ModTime": "7", -// "OwnerID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:6", -// "RefCount": "1" -// } -// } -// u[a8ada09dee16d791fd406d629fe29bb0ed084a30:5]={ -// "Fields": [ -// { -// "T": { -// "@type": "/gno.RefType", -// "ID": "github.com/gnolang/gno/_test/timtadh/data_structures/types.String" -// }, -// "V": { -// "@type": "/gno.StringValue", -// "value": "key0" -// } -// }, -// { -// "T": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// }, -// "V": { -// "@type": "/gno.StringValue", -// "value": "value0" -// } -// }, -// { -// "N": "AwAAAAAAAAA=", -// "T": { -// "@type": "/gno.PrimitiveType", -// "value": "32" -// } -// }, -// { -// "T": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "github.com/gnolang/gno/_test/timtadh/data_structures/tree/avl.AvlNode" -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "github.com/gnolang/gno/_test/timtadh/data_structures/tree/avl.AvlNode" -// } -// }, -// "V": { -// "@type": "/gno.PointerValue", -// "Base": { -// "@type": "/gno.RefValue", -// "Hash": "7c63a8fd451cd7c470c1851f1ead037246422ded", -// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:6" -// }, -// "Index": "0", -// "TV": null -// } -// } -// ], -// "ObjectInfo": { -// "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:5", -// "ModTime": "7", -// "OwnerID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:4", -// "RefCount": "1" -// } -// } -// u[a8ada09dee16d791fd406d629fe29bb0ed084a30:2]={ -// "Blank": {}, -// "ObjectInfo": { -// "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:2", -// "IsEscaped": true, -// "ModTime": "7", -// "RefCount": "2" -// }, -// "Parent": null, -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "0", -// "File": "", -// "Line": "0", -// "PkgPath": "gno.land/r/test" -// } -// }, -// "Values": [ -// { -// "T": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "github.com/gnolang/gno/_test/timtadh/data_structures/tree/avl.AvlNode" -// } -// }, -// "V": { -// "@type": "/gno.PointerValue", -// "Base": { -// "@type": "/gno.RefValue", -// "Hash": "ade9fce2a987ef1924040a1d75c0172410c66952", -// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:4" -// }, -// "Index": "0", -// "TV": null -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:3" -// }, -// "FileName": "main.gno", -// "IsMethod": false, -// "Name": "init.1", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/test", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "main.gno", -// "Line": "11", -// "PkgPath": "gno.land/r/test" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:3" -// }, -// "FileName": "main.gno", -// "IsMethod": false, -// "Name": "main", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/test", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "main.gno", -// "Line": "16", -// "PkgPath": "gno.land/r/test" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// } -// } -// } -// ] -// } +// Error: +// cannot attach un-real object from external realm: struct{("key0" github.com/gnolang/gno/_test/timtadh/data_structures/types.String),("value0" string),(2 int),(nil *github.com/gnolang/gno/_test/timtadh/data_structures/tree/avl.AvlNode),(&(struct{("key1" github.com/gnolang/gno/_test/timtadh/data_structures/types.String),("value1" string),(1 int),(nil *github.com/gnolang/gno/_test/timtadh/data_structures/tree/avl.AvlNode),(nil *github.com/gnolang/gno/_test/timtadh/data_structures/tree/avl.AvlNode)} github.com/gnolang/gno/_test/timtadh/data_structures/tree/avl.AvlNode) *github.com/gnolang/gno/_test/timtadh/data_structures/tree/avl.AvlNode)} diff --git a/gnovm/tests/files/zrealm7.gno b/gnovm/tests/files/zrealm7.gno index 7e19851cd13..f7707024bad 100644 --- a/gnovm/tests/files/zrealm7.gno +++ b/gnovm/tests/files/zrealm7.gno @@ -20,428 +20,5 @@ func main() { println(updated, tree.Size()) } -// Output: -// false 4 - -// Realm: -// switchrealm["gno.land/r/test"] -// c[a8ada09dee16d791fd406d629fe29bb0ed084a30:11]={ -// "Fields": [ -// { -// "T": { -// "@type": "/gno.RefType", -// "ID": "github.com/gnolang/gno/_test/timtadh/data_structures/types.String" -// }, -// "V": { -// "@type": "/gno.StringValue", -// "value": "key3" -// } -// }, -// { -// "T": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// }, -// "V": { -// "@type": "/gno.StringValue", -// "value": "value3" -// } -// }, -// { -// "N": "AQAAAAAAAAA=", -// "T": { -// "@type": "/gno.PrimitiveType", -// "value": "32" -// } -// }, -// { -// "T": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "github.com/gnolang/gno/_test/timtadh/data_structures/tree/avl.AvlNode" -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "github.com/gnolang/gno/_test/timtadh/data_structures/tree/avl.AvlNode" -// } -// } -// } -// ], -// "ObjectInfo": { -// "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:11", -// "ModTime": "0", -// "OwnerID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:10", -// "RefCount": "1" -// } -// } -// c[a8ada09dee16d791fd406d629fe29bb0ed084a30:10]={ -// "ObjectInfo": { -// "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:10", -// "ModTime": "0", -// "OwnerID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:9", -// "RefCount": "1" -// }, -// "Value": { -// "T": { -// "@type": "/gno.RefType", -// "ID": "github.com/gnolang/gno/_test/timtadh/data_structures/tree/avl.AvlNode" -// }, -// "V": { -// "@type": "/gno.RefValue", -// "Hash": "42cd813e173ad23c7873e9605901e8bea1176c96", -// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:11" -// } -// } -// } -// u[a8ada09dee16d791fd406d629fe29bb0ed084a30:9]={ -// "Fields": [ -// { -// "T": { -// "@type": "/gno.RefType", -// "ID": "github.com/gnolang/gno/_test/timtadh/data_structures/types.String" -// }, -// "V": { -// "@type": "/gno.StringValue", -// "value": "key2" -// } -// }, -// { -// "T": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// }, -// "V": { -// "@type": "/gno.StringValue", -// "value": "value2" -// } -// }, -// { -// "N": "AgAAAAAAAAA=", -// "T": { -// "@type": "/gno.PrimitiveType", -// "value": "32" -// } -// }, -// { -// "T": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "github.com/gnolang/gno/_test/timtadh/data_structures/tree/avl.AvlNode" -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "github.com/gnolang/gno/_test/timtadh/data_structures/tree/avl.AvlNode" -// } -// }, -// "V": { -// "@type": "/gno.PointerValue", -// "Base": { -// "@type": "/gno.RefValue", -// "Hash": "4f88fcdc73a4a94905e8e4044aa50c2ec7bf2227", -// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:10" -// }, -// "Index": "0", -// "TV": null -// } -// } -// ], -// "ObjectInfo": { -// "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:9", -// "ModTime": "9", -// "OwnerID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:8", -// "RefCount": "1" -// } -// } -// u[a8ada09dee16d791fd406d629fe29bb0ed084a30:8]={ -// "ObjectInfo": { -// "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:8", -// "ModTime": "9", -// "OwnerID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:7", -// "RefCount": "1" -// }, -// "Value": { -// "T": { -// "@type": "/gno.RefType", -// "ID": "github.com/gnolang/gno/_test/timtadh/data_structures/tree/avl.AvlNode" -// }, -// "V": { -// "@type": "/gno.RefValue", -// "Hash": "2c172bbe0183ccc73c59d9acb196c45b0331c39e", -// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:9" -// } -// } -// } -// u[a8ada09dee16d791fd406d629fe29bb0ed084a30:7]={ -// "Fields": [ -// { -// "T": { -// "@type": "/gno.RefType", -// "ID": "github.com/gnolang/gno/_test/timtadh/data_structures/types.String" -// }, -// "V": { -// "@type": "/gno.StringValue", -// "value": "key1" -// } -// }, -// { -// "T": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// }, -// "V": { -// "@type": "/gno.StringValue", -// "value": "value1" -// } -// }, -// { -// "N": "AwAAAAAAAAA=", -// "T": { -// "@type": "/gno.PrimitiveType", -// "value": "32" -// } -// }, -// { -// "T": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "github.com/gnolang/gno/_test/timtadh/data_structures/tree/avl.AvlNode" -// } -// }, -// "V": { -// "@type": "/gno.PointerValue", -// "Base": { -// "@type": "/gno.RefValue", -// "Hash": "a4fa9bdf45caf8c6b5be7a3752704423817b3ef2", -// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:4" -// }, -// "Index": "0", -// "TV": null -// } -// }, -// { -// "T": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "github.com/gnolang/gno/_test/timtadh/data_structures/tree/avl.AvlNode" -// } -// }, -// "V": { -// "@type": "/gno.PointerValue", -// "Base": { -// "@type": "/gno.RefValue", -// "Hash": "43f69f24b7827a331921b4af0f667346d186e0c3", -// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:8" -// }, -// "Index": "0", -// "TV": null -// } -// } -// ], -// "ObjectInfo": { -// "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:7", -// "ModTime": "9", -// "OwnerID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:6", -// "RefCount": "1" -// } -// } -// u[a8ada09dee16d791fd406d629fe29bb0ed084a30:5]={ -// "Fields": [ -// { -// "T": { -// "@type": "/gno.RefType", -// "ID": "github.com/gnolang/gno/_test/timtadh/data_structures/types.String" -// }, -// "V": { -// "@type": "/gno.StringValue", -// "value": "key0" -// } -// }, -// { -// "T": { -// "@type": "/gno.PrimitiveType", -// "value": "16" -// }, -// "V": { -// "@type": "/gno.StringValue", -// "value": "value0" -// } -// }, -// { -// "N": "AQAAAAAAAAA=", -// "T": { -// "@type": "/gno.PrimitiveType", -// "value": "32" -// } -// }, -// { -// "T": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "github.com/gnolang/gno/_test/timtadh/data_structures/tree/avl.AvlNode" -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "github.com/gnolang/gno/_test/timtadh/data_structures/tree/avl.AvlNode" -// } -// } -// } -// ], -// "ObjectInfo": { -// "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:5", -// "ModTime": "9", -// "OwnerID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:4", -// "RefCount": "1" -// } -// } -// u[a8ada09dee16d791fd406d629fe29bb0ed084a30:6]={ -// "ObjectInfo": { -// "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:6", -// "ModTime": "9", -// "OwnerID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:5", -// "RefCount": "1" -// }, -// "Value": { -// "T": { -// "@type": "/gno.RefType", -// "ID": "github.com/gnolang/gno/_test/timtadh/data_structures/tree/avl.AvlNode" -// }, -// "V": { -// "@type": "/gno.RefValue", -// "Hash": "f56fbd9c8db299689cc0cf806fe741b6a6e641e6", -// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:7" -// } -// } -// } -// u[a8ada09dee16d791fd406d629fe29bb0ed084a30:2]={ -// "Blank": {}, -// "ObjectInfo": { -// "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:2", -// "IsEscaped": true, -// "ModTime": "9", -// "RefCount": "2" -// }, -// "Parent": null, -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "0", -// "File": "", -// "Line": "0", -// "PkgPath": "gno.land/r/test" -// } -// }, -// "Values": [ -// { -// "T": { -// "@type": "/gno.PointerType", -// "Elt": { -// "@type": "/gno.RefType", -// "ID": "github.com/gnolang/gno/_test/timtadh/data_structures/tree/avl.AvlNode" -// } -// }, -// "V": { -// "@type": "/gno.PointerValue", -// "Base": { -// "@type": "/gno.RefValue", -// "Hash": "450aef9858564ed4ec1c418f1e8dac828079016b", -// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:6" -// }, -// "Index": "0", -// "TV": null -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:3" -// }, -// "FileName": "main.gno", -// "IsMethod": false, -// "Name": "init.1", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/test", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "main.gno", -// "Line": "11", -// "PkgPath": "gno.land/r/test" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// } -// } -// }, -// { -// "T": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// }, -// "V": { -// "@type": "/gno.FuncValue", -// "Closure": { -// "@type": "/gno.RefValue", -// "Escaped": true, -// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:3" -// }, -// "FileName": "main.gno", -// "IsMethod": false, -// "Name": "main", -// "NativeName": "", -// "NativePkg": "", -// "PkgPath": "gno.land/r/test", -// "Source": { -// "@type": "/gno.RefNode", -// "BlockNode": null, -// "Location": { -// "Column": "1", -// "File": "main.gno", -// "Line": "17", -// "PkgPath": "gno.land/r/test" -// } -// }, -// "Type": { -// "@type": "/gno.FuncType", -// "Params": [], -// "Results": [] -// } -// } -// } -// ] -// } +// Error: +// cannot attach un-real object from external realm: struct{("key0" github.com/gnolang/gno/_test/timtadh/data_structures/types.String),("value0" string),(2 int),(nil *github.com/gnolang/gno/_test/timtadh/data_structures/tree/avl.AvlNode),(&(struct{("key1" github.com/gnolang/gno/_test/timtadh/data_structures/types.String),("value1" string),(1 int),(nil *github.com/gnolang/gno/_test/timtadh/data_structures/tree/avl.AvlNode),(nil *github.com/gnolang/gno/_test/timtadh/data_structures/tree/avl.AvlNode)} github.com/gnolang/gno/_test/timtadh/data_structures/tree/avl.AvlNode) *github.com/gnolang/gno/_test/timtadh/data_structures/tree/avl.AvlNode)} diff --git a/gnovm/tests/files/zrealm_natbind0_stdlibs.gno b/gnovm/tests/files/zrealm_natbind0_stdlibs.gno new file mode 100644 index 00000000000..6ff1737e565 --- /dev/null +++ b/gnovm/tests/files/zrealm_natbind0_stdlibs.gno @@ -0,0 +1,26 @@ +// PKGPATH: gno.land/r/test +package test + +import ( + "std" +) + +var node interface{} + +func init() { + node = std.GetHeight +} + +func main() { + // NOTE: this test uses GetHeight and GetChainID, which are "pure" + // natively bound functions (ie. not indirections through a wrapper fn, + // to convert the types to builtin go/gno identifiers). + f := node.(func() int64) + println(f()) + node = std.GetChainID + g := node.(func() string) + println(g()) +} + +// Error: +// cannot attach objects by value from external realm From bff5b19be97a4db8372e6550c3e6aae599a6184f Mon Sep 17 00:00:00 2001 From: ltzMaxwell Date: Wed, 8 Jan 2025 17:59:48 +0800 Subject: [PATCH 40/40] fixup --- gnovm/pkg/gnolang/machine.go | 9 ++-- gnovm/pkg/gnolang/op_eval.go | 2 +- gnovm/pkg/gnolang/ownership.go | 91 ++++++++++++++-------------------- gnovm/pkg/gnolang/realm.go | 12 ++--- gnovm/pkg/gnolang/values.go | 15 ++---- 5 files changed, 52 insertions(+), 77 deletions(-) diff --git a/gnovm/pkg/gnolang/machine.go b/gnovm/pkg/gnolang/machine.go index 6b21798de87..3cbc6f3a864 100644 --- a/gnovm/pkg/gnolang/machine.go +++ b/gnovm/pkg/gnolang/machine.go @@ -2003,11 +2003,10 @@ func (m *Machine) PopFrameAndReturn() { if res.IsUndefined() && rtypes[i].Type.Kind() != InterfaceKind { res.T = rtypes[i].Type } - debug2.Println2("res: ", res) - debug2.Printf2("addr of res: %p \n", &res) - if oo, ok := res.V.(Object); ok { - debug2.Println2("oo.GetObjectInfo(): ", oo.GetObjectInfo()) - } + //debug2.Println2("res: ", res) + //if oo, ok := res.V.(Object); ok { + // debug2.Println2("oo.GetObjectInfo(): ", oo.GetObjectInfo()) + //} m.Values[fr.NumValues+i] = res } m.NumValues = fr.NumValues + numRes diff --git a/gnovm/pkg/gnolang/op_eval.go b/gnovm/pkg/gnolang/op_eval.go index 6bf5e54a24f..189a959aa02 100644 --- a/gnovm/pkg/gnolang/op_eval.go +++ b/gnovm/pkg/gnolang/op_eval.go @@ -21,7 +21,7 @@ func (m *Machine) doOpEval() { x := m.PeekExpr(1) if debug { debug.Printf("EVAL: (%T) %v\n", x, x) - fmt.Println(m.String()) + //fmt.Println(m.String()) } debug2.Printf2("EVAL: (%T) %v\n", x, x) // This case moved out of switch for performance. diff --git a/gnovm/pkg/gnolang/ownership.go b/gnovm/pkg/gnolang/ownership.go index 4aa7fe22f1f..18d3d1c2a0e 100644 --- a/gnovm/pkg/gnolang/ownership.go +++ b/gnovm/pkg/gnolang/ownership.go @@ -145,13 +145,13 @@ type ObjectInfo struct { RefCount int // for persistence. deleted/gc'd if 0. IsEscaped bool `json:",omitempty"` // hash in iavl. // MemRefCount int // consider for optimizations. - isDirty bool - isDeleted bool - isNewReal bool - isRef bool - isNewEscaped bool - isNewDeleted bool - lastNewRealEscapedRealm PkgID + isDirty bool + isDeleted bool + isNewReal bool + isRef bool + isNewEscaped bool + isNewDeleted bool + originRealm PkgID // realm where object is from // XXX huh? owner Object // mem reference to owner. @@ -160,13 +160,13 @@ type ObjectInfo struct { // Note that "owner" is nil. func (oi *ObjectInfo) Copy() ObjectInfo { return ObjectInfo{ - ID: oi.ID, - Hash: oi.Hash.Copy(), - OwnerID: oi.OwnerID, - ModTime: oi.ModTime, - RefCount: oi.RefCount, - IsEscaped: oi.IsEscaped, - lastNewRealEscapedRealm: oi.lastNewRealEscapedRealm, + ID: oi.ID, + Hash: oi.Hash.Copy(), + OwnerID: oi.OwnerID, + ModTime: oi.ModTime, + RefCount: oi.RefCount, + IsEscaped: oi.IsEscaped, + originRealm: oi.originRealm, /* // XXX do the following need copying too? isDirty: oi.isDirty, @@ -174,7 +174,7 @@ func (oi *ObjectInfo) Copy() ObjectInfo { isNewReal: oi.isNewReal, isNewEscaped: oi.isNewEscaped, isNewDeleted: oi.isNewDeleted, - lastNewRealEscapedRealm: oi.lastNewRealEscapedRealm, + originRealm: oi.originRealm, */ } } @@ -317,12 +317,12 @@ func (oi *ObjectInfo) SetIsNewReal(x bool) { } func (oi *ObjectInfo) GetOriginRealm() PkgID { - return oi.lastNewRealEscapedRealm + return oi.originRealm } func (oi *ObjectInfo) SetOriginRealm(pkgId PkgID) { debug2.Println2("SetOriginRealm: ", pkgId) - oi.lastNewRealEscapedRealm = pkgId + oi.originRealm = pkgId } func (oi *ObjectInfo) GetIsRef() bool { @@ -393,22 +393,36 @@ func (tv *TypedValue) GetOriginPkg(store Store) (originPkg PkgID) { debug2.Println2("GetOriginPkg, tv: ", tv, reflect.TypeOf(tv.V)) // get first object obj := tv.GetFirstObject(store) - debug2.Println2("obj: ", obj) + debug2.Println2("obj: ", obj, reflect.TypeOf(obj)) if obj != nil { originPkg = obj.GetOriginRealm() if originPkg.IsZero() { originPkg = obj.GetObjectID().PkgID } debug2.Println2("obj.GetObjectInfo(): ", obj.GetObjectInfo()) - debug2.Println2("obj.originPkg: ", originPkg) + } + debug2.Println2("obj.originPkg: ", originPkg) + + // get pkgId from type + getPkgId := func(t Type) (pkgId PkgID) { + defer debug2.Println2("getPkgId: ", pkgId) + if dt, ok := t.(*DeclaredType); ok { + debug2.Printf2("dt: %v, dt.Base: \n", dt, dt.Base) + if _, ok := dt.Base.(*FuncType); !ok { + debug2.Println2("---dt.base.PkgPath: ", dt.Base.GetPkgPath()) + if IsRealmPath(dt.Base.GetPkgPath()) { + pkgId = PkgIDFromPkgPath(dt.Base.GetPkgPath()) + return + } + } + } + return } // if still zero if originPkg.IsZero() { switch cv := obj.(type) { case *ArrayValue: - debug2.Println2("array value, T: ", tv.T) - debug2.Println2("objectInfo: ", cv.GetObjectInfo()) if IsRealmPath(tv.T.Elem().GetPkgPath()) { originPkg = PkgIDFromPkgPath(tv.T.Elem().GetPkgPath()) } @@ -417,45 +431,16 @@ func (tv *TypedValue) GetOriginPkg(store Store) (originPkg PkgID) { originPkg = PkgIDFromPkgPath(cv.Source.GetLocation().PkgPath) return case *HeapItemValue: - debug2.Println2("heapItemValue: ", cv) - debug2.Println2("heapItemValue.Value.T: ", cv.Value.T) - if dt, ok := cv.Value.T.(*DeclaredType); ok { - debug2.Printf2("---dt: %v\n", dt) - debug2.Println2("---dt.base: ", dt.Base) - if _, ok := dt.Base.(*FuncType); !ok { - debug2.Println2("---dt.base.PkgPath: ", dt.Base.GetPkgPath()) - if IsRealmPath(dt.Base.GetPkgPath()) { - originPkg = PkgIDFromPkgPath(dt.Base.GetPkgPath()) - } - } - } + originPkg = getPkgId(cv.Value.T) return case *BoundMethodValue: - debug2.Println2("boundMethodValue: ", cv) debug2.Println2("BoundMethodValue, recv: ", cv.Receiver) - debug2.Println2("type of T: ", reflect.TypeOf(cv.Receiver.T)) if pv, ok := cv.Receiver.V.(PointerValue); ok { - debug2.Println2("pointer value, pv: ", pv) - if dt, ok := pv.TV.T.(*DeclaredType); ok { - debug2.Println2("---2, dt: ", dt) - if IsRealmPath(dt.PkgPath) { - originPkg = PkgIDFromPkgPath(dt.PkgPath) - } - } - debug2.Println2("originPkg; ", originPkg) + originPkg = getPkgId(pv.TV.T) } return case *MapValue, *StructValue: - if dt, ok := tv.T.(*DeclaredType); ok { - debug2.Printf2("---dt: %v\n", dt) - debug2.Println2("---dt.base: ", dt.Base) - if _, ok := dt.Base.(*FuncType); !ok { - debug2.Println2("---dt.base.PkgPath: ", dt.Base.GetPkgPath()) - if IsRealmPath(dt.Base.GetPkgPath()) { - originPkg = PkgIDFromPkgPath(dt.Base.GetPkgPath()) - } - } - } + originPkg = getPkgId(tv.T) return default: // do nothing diff --git a/gnovm/pkg/gnolang/realm.go b/gnovm/pkg/gnolang/realm.go index 74e991b1d6c..c3949682852 100644 --- a/gnovm/pkg/gnolang/realm.go +++ b/gnovm/pkg/gnolang/realm.go @@ -265,9 +265,11 @@ func checkCrossRealm2(rlm *Realm, store Store, tv *TypedValue) { // checkCrossRealm check cross realm recursively func checkCrossRealm(rlm *Realm, store Store, oo Object, refValue Value) { - fmt.Println("checkCrossRealm, oo: ", oo, reflect.TypeOf(oo)) + debug2.Println2("checkCrossRealm, oo: ", oo, reflect.TypeOf(oo)) + debug2.Println2("refValue: ", refValue) debug2.Println2("oo.GetRefCount: ", oo.GetRefCount()) debug2.Println2("oo.GetObjectInfo: ", oo.GetObjectInfo()) + switch v := oo.(type) { case *StructValue: if !v.GetIsReal() { @@ -283,7 +285,7 @@ func checkCrossRealm(rlm *Realm, store Store, oo Object, refValue Value) { case *MapValue: // TODO: check recursively case *BoundMethodValue: - // TODO: check recursively + // TODO: check case *Block: // XXX, can this happen? if !v.GetIsRef() { @@ -315,8 +317,7 @@ func checkCrossRealm(rlm *Realm, store Store, oo Object, refValue Value) { // MarkNewEscapedCheckCrossRealm check for escaped object func (rlm *Realm) MarkNewEscapedCheckCrossRealm(store Store, oo Object, refValue Value) { - //fmt.Println("MarkNewEscapedCheckCrossRealm, oo: ", oo) - //fmt.Println("refValue: ", refValue) + debug2.Println2("MarkNewEscapedCheckCrossRealm, oo: ", oo) //fmt.Println("oo.GetOriginRealm(): ", oo.GetOriginRealm()) //fmt.Println("rlm.ID: ", rlm.ID) @@ -555,6 +556,7 @@ func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { debug2.Println2("---oo.GetOriginRealm: ", oo.GetOriginRealm()) debug2.Println2("---oo.GetRefCount: ", oo.GetRefCount()) debug2.Println2("---oo.GetObjectID: ", oo.GetObjectInfo()) + debug2.Println2("oo.GetIsRef: ", oo.GetIsRef()) if debug { if oo.GetIsDirty() { @@ -567,7 +569,6 @@ func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { // XXX, oo must be new real here, it's not escaped // if it's reference, all right - debug2.Println2("oo.GetIsRef: ", oo.GetIsRef()) if !oo.GetOriginRealm().IsZero() && oo.GetOriginRealm() != rlm.ID { if oo.GetIsRef() { panic("cannot attach a reference to an unreal object from an external realm") @@ -576,7 +577,6 @@ func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { } } - debug2.Println2("oo.GetObjectID(): ", oo.GetObjectID()) // RECURSE GUARD // if id already set, skip. // this happens when a node marked created was already diff --git a/gnovm/pkg/gnolang/values.go b/gnovm/pkg/gnolang/values.go index 3ab0e700ec7..4c9ea8ae85d 100644 --- a/gnovm/pkg/gnolang/values.go +++ b/gnovm/pkg/gnolang/values.go @@ -213,7 +213,6 @@ func (pv *PointerValue) GetBase(store Store) Object { func (pv PointerValue) Assign2(alloc *Allocator, store Store, rlm *Realm, tv2 TypedValue, cu bool) { debug2.Println2("Assign2, pv: ", pv) debug2.Println2("tv2: ", tv2) - debug2.Printf2("addr of tv2: %p \n", &tv2) debug2.Println2("rlm: ", rlm) // Special cases. @@ -291,15 +290,13 @@ func (pv PointerValue) Assign2(alloc *Allocator, store Store, rlm *Realm, tv2 Ty oo1 := pv.TV.GetFirstObject(store) debug2.Println2("---oo1: ", oo1) - // get origin pkgId + // get origin pkgId, this should happen before assign, + // because assign will discard original object info originPkg := tv2.GetOriginPkg(store) debug2.Println2("originPkg: ", originPkg) pv.TV.Assign(alloc, tv2, cu) - // get origin pkgId, this should happen before assign, - // because assign will discard original object info - oo2 := pv.TV.GetFirstObject(store) debug2.Println2("oo2: ", oo2) @@ -548,8 +545,6 @@ func (sv *StructValue) Copy(alloc *Allocator) *StructValue { } nsv := alloc.NewStruct(fields) - //debug2.Println2("sv.ObjectInfo", sv.ObjectInfo) - //nsv.ObjectInfo = sv.ObjectInfo.Copy() debug2.Println2("sv.GetOriginRealm: ", sv.GetOriginRealm()) debug2.Println2("sv.GetObjectID(): ", sv.GetObjectID()) debug2.Println2("sv.GetRefCount: ", sv.GetRefCount()) @@ -1085,7 +1080,6 @@ func (tv TypedValue) Copy(alloc *Allocator) (cp TypedValue) { cp.T = tv.T cp.V = cv.Copy(alloc) default: - debug2.Println2("---default") cp = tv } return @@ -2673,7 +2667,7 @@ func typedString(s string) TypedValue { } func fillValueTV(store Store, tv *TypedValue) *TypedValue { - debug2.Println2("fillValueTV, tv: ", tv) + debug2.Println2("fillValueTV, tv: ", tv, reflect.TypeOf(tv.V)) switch cv := tv.V.(type) { case RefValue: if cv.PkgPath != "" { // load package @@ -2690,14 +2684,11 @@ func fillValueTV(store Store, tv *TypedValue) *TypedValue { // but for execution speed traded off for // loading speed, we do the following for now: if ref, ok := cv.Base.(RefValue); ok { - //fmt.Println("---cv.Base: ", ref) base := store.GetObject(ref.ObjectID).(Value) - //fmt.Println("---base: ", base) cv.Base = base switch cb := base.(type) { case *ArrayValue: et := baseOf(tv.T).(*PointerType).Elt - fmt.Println("---et: ", et) epv := cb.GetPointerAtIndexInt2(store, cv.Index, et) cv.TV = epv.TV // TODO optimize? (epv.* ignored) case *StructValue: