Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat: Initialize static blocks before preprocess #2418

Merged
merged 21 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions examples/gno.land/p/demo/avl/z_0_filetest.gno
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,25 @@ func main() {
// "Values": [
// {
// "T": {
// "@type": "/gno.PointerType",
// "Elt": {
// "@type": "/gno.RefType",
// "ID": "gno.land/p/demo/avl.Node"
// }
// },
// "V": {
// "@type": "/gno.PointerValue",
// "Base": {
// "@type": "/gno.RefValue",
// "Hash": "ae86874f9b47fa5e64c30b3e92e9d07f2ec967a4",
// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:6"
// },
// "Index": "0",
// "TV": null
// }
// },
// {
// "T": {
// "@type": "/gno.FuncType",
// "Params": [],
// "Results": []
Expand All @@ -250,7 +269,7 @@ func main() {
// },
// "FileName": "main.gno",
// "IsMethod": false,
// "Name": "init.0",
// "Name": "init.1",
// "NativeName": "",
// "NativePkg": "",
// "PkgPath": "gno.land/r/test",
Expand Down Expand Up @@ -306,25 +325,6 @@ func main() {
// "Results": []
// }
// }
// },
// {
// "T": {
// "@type": "/gno.PointerType",
// "Elt": {
// "@type": "/gno.RefType",
// "ID": "gno.land/p/demo/avl.Node"
// }
// },
// "V": {
// "@type": "/gno.PointerValue",
// "Base": {
// "@type": "/gno.RefValue",
// "Hash": "ae86874f9b47fa5e64c30b3e92e9d07f2ec967a4",
// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:6"
// },
// "Index": "0",
// "TV": null
// }
// }
// ]
// }
40 changes: 20 additions & 20 deletions examples/gno.land/p/demo/avl/z_1_filetest.gno
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,25 @@ func main() {
// "Values": [
// {
// "T": {
// "@type": "/gno.PointerType",
// "Elt": {
// "@type": "/gno.RefType",
// "ID": "gno.land/p/demo/avl.Node"
// }
// },
// "V": {
// "@type": "/gno.PointerValue",
// "Base": {
// "@type": "/gno.RefValue",
// "Hash": "1faa9fa4ba1935121a6d3f0a623772e9d4499b0a",
// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:10"
// },
// "Index": "0",
// "TV": null
// }
// },
// {
// "T": {
// "@type": "/gno.FuncType",
// "Params": [],
// "Results": []
Expand All @@ -323,7 +342,7 @@ func main() {
// },
// "FileName": "main.gno",
// "IsMethod": false,
// "Name": "init.0",
// "Name": "init.1",
// "NativeName": "",
// "NativePkg": "",
// "PkgPath": "gno.land/r/test",
Expand Down Expand Up @@ -379,25 +398,6 @@ func main() {
// "Results": []
// }
// }
// },
// {
// "T": {
// "@type": "/gno.PointerType",
// "Elt": {
// "@type": "/gno.RefType",
// "ID": "gno.land/p/demo/avl.Node"
// }
// },
// "V": {
// "@type": "/gno.PointerValue",
// "Base": {
// "@type": "/gno.RefValue",
// "Hash": "1faa9fa4ba1935121a6d3f0a623772e9d4499b0a",
// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:10"
// },
// "Index": "0",
// "TV": null
// }
// }
// ]
// }
Expand Down
8 changes: 4 additions & 4 deletions examples/gno.land/p/demo/avl/z_2_filetest.gno
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ func main() {
// "ObjectInfo": {
// "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:11",
// "ModTime": "0",
// "OwnerID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:4",
// "OwnerID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:3",
// "RefCount": "1"
// },
// "Value": {
Expand All @@ -287,7 +287,7 @@ func main() {
// }
// }
// }
// u[a8ada09dee16d791fd406d629fe29bb0ed084a30:4]={
// u[a8ada09dee16d791fd406d629fe29bb0ed084a30:3]={
// "Fields": [
// {
// "T": {
Expand All @@ -301,7 +301,7 @@ func main() {
// "@type": "/gno.PointerValue",
// "Base": {
// "@type": "/gno.RefValue",
// "Hash": "425bc3bff1f4c36b175d055ed8b2c289123fcca1",
// "Hash": "d31c7e797793e03ffe0bbcb72f963264f8300d22",
// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:11"
// },
// "Index": "0",
Expand All @@ -310,7 +310,7 @@ func main() {
// }
// ],
// "ObjectInfo": {
// "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:4",
// "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:3",
// "ModTime": "10",
// "OwnerID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:2",
// "RefCount": "1"
Expand Down
10 changes: 5 additions & 5 deletions examples/gno.land/r/demo/boards/z_4_filetest.gno
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ func main() {
// "Escaped": true,
// "ObjectID": "336074805fc853987abe6f7fe3ad97a6a6f3077a:2"
// },
// "Index": "192",
// "Index": "182",
// "TV": null
// }
// }
Expand Down Expand Up @@ -497,7 +497,7 @@ func main() {
// },
// "V": {
// "@type": "/gno.RefValue",
// "Hash": "f56a463a97d103e183f1f368bf00a2ce99d4de88",
// "Hash": "0fd3352422af0a56a77ef2c9e88f479054e3d51f",
// "ObjectID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:131"
// }
// },
Expand Down Expand Up @@ -534,7 +534,7 @@ func main() {
// },
// "V": {
// "@type": "/gno.RefValue",
// "Hash": "0651ea376feea18422dbe079f9d7fcbe3dfd32ad",
// "Hash": "c45bbd47a46681a63af973db0ec2180922e4a8ae",
// "ObjectID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:127"
// }
// }
Expand Down Expand Up @@ -785,7 +785,7 @@ func main() {
// },
// "V": {
// "@type": "/gno.RefValue",
// "Hash": "1d70015c486ccc9bfb7c425152605fabc78be1dd",
// "Hash": "a416a751c3a45a1e5cba11e737c51340b081e372",
// "ObjectID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:86"
// }
// },
Expand All @@ -803,7 +803,7 @@ func main() {
// },
// "V": {
// "@type": "/gno.RefValue",
// "Hash": "b8ee1687a4f45886912ba624c8513a2a1526b94c",
// "Hash": "36299fccbc13f2a84c4629fad4cb940f0bd4b1c6",
// "ObjectID": "f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:87"
// }
// },
Expand Down
24 changes: 12 additions & 12 deletions examples/gno.land/r/demo/nft/z_0_filetest.gno
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func main() {
// "ObjectInfo": {
// "ID": "67c479d3d51d4056b2f4111d5352912a00be311e:8",
// "ModTime": "0",
// "OwnerID": "67c479d3d51d4056b2f4111d5352912a00be311e:6",
// "OwnerID": "67c479d3d51d4056b2f4111d5352912a00be311e:5",
// "RefCount": "1"
// },
// "Value": {
Expand All @@ -176,7 +176,7 @@ func main() {
// }
// }
// }
// u[67c479d3d51d4056b2f4111d5352912a00be311e:6]={
// u[67c479d3d51d4056b2f4111d5352912a00be311e:5]={
// "Fields": [
// {
// "T": {
Expand All @@ -190,7 +190,7 @@ func main() {
// "@type": "/gno.PointerValue",
// "Base": {
// "@type": "/gno.RefValue",
// "Hash": "75850e56fa2c3c8b6d6814b1f150919b75355752",
// "Hash": "b229b824842ec3e7f2341e33d0fa0ca77af2f480",
// "ObjectID": "67c479d3d51d4056b2f4111d5352912a00be311e:8"
// },
// "Index": "0",
Expand All @@ -199,13 +199,13 @@ func main() {
// }
// ],
// "ObjectInfo": {
// "ID": "67c479d3d51d4056b2f4111d5352912a00be311e:6",
// "ID": "67c479d3d51d4056b2f4111d5352912a00be311e:5",
// "ModTime": "7",
// "OwnerID": "67c479d3d51d4056b2f4111d5352912a00be311e:5",
// "OwnerID": "67c479d3d51d4056b2f4111d5352912a00be311e:4",
// "RefCount": "1"
// }
// }
// u[67c479d3d51d4056b2f4111d5352912a00be311e:5]={
// u[67c479d3d51d4056b2f4111d5352912a00be311e:4]={
// "Fields": [
// {},
// {
Expand All @@ -222,8 +222,8 @@ func main() {
// },
// "V": {
// "@type": "/gno.RefValue",
// "Hash": "700d932c087f30499941de2b589867dc17aaea5a",
// "ObjectID": "67c479d3d51d4056b2f4111d5352912a00be311e:6"
// "Hash": "1e0b9dddb406b4f50500a022266a4cb8a4ea38c6",
// "ObjectID": "67c479d3d51d4056b2f4111d5352912a00be311e:5"
// }
// },
// {
Expand All @@ -233,15 +233,15 @@ func main() {
// },
// "V": {
// "@type": "/gno.RefValue",
// "Hash": "e06585aff551113920c929453ea40250f3cc01bc",
// "ObjectID": "67c479d3d51d4056b2f4111d5352912a00be311e:7"
// "Hash": "05ab6746ea84b55ca133806af215d99a1c4b045e",
// "ObjectID": "67c479d3d51d4056b2f4111d5352912a00be311e:6"
// }
// }
// ],
// "ObjectInfo": {
// "ID": "67c479d3d51d4056b2f4111d5352912a00be311e:5",
// "ID": "67c479d3d51d4056b2f4111d5352912a00be311e:4",
// "ModTime": "7",
// "OwnerID": "67c479d3d51d4056b2f4111d5352912a00be311e:4",
// "OwnerID": "67c479d3d51d4056b2f4111d5352912a00be311e:3",
// "RefCount": "1"
// }
// }
Expand Down
14 changes: 7 additions & 7 deletions gnovm/cmd/gno/testdata/gno_test/realm_correct.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ func main() {
// },
// "Values": [
// {
// "N": "AQAAAAAAAAA=",
// "T": {
// "@type": "/gno.PrimitiveType",
// "value": "32"
// }
// },
// {
// "T": {
// "@type": "/gno.FuncType",
// "Params": [],
Expand Down Expand Up @@ -74,13 +81,6 @@ func main() {
// "Results": []
// }
// }
// },
// {
// "N": "AQAAAAAAAAA=",
// "T": {
// "@type": "/gno.PrimitiveType",
// "value": "32"
// }
// }
// ]
// }
Expand Down
14 changes: 7 additions & 7 deletions gnovm/cmd/gno/testdata/gno_test/realm_sync.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ func main() {
// },
// "Values": [
// {
// "N": "AQAAAAAAAAA=",
// "T": {
// "@type": "/gno.PrimitiveType",
// "value": "32"
// }
// },
// {
// "T": {
// "@type": "/gno.FuncType",
// "Params": [],
Expand Down Expand Up @@ -89,13 +96,6 @@ func main() {
// "Results": []
// }
// }
// },
// {
// "N": "AQAAAAAAAAA=",
// "T": {
// "@type": "/gno.PrimitiveType",
// "value": "32"
// }
// }
// ]
// }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

! stdout .+
stderr 'panic: unknown import path net \[recovered\]'
stderr ' panic: gno.land/r/\w{8}/contract.gno:3:8: unknown import path net'
stderr ' panic: gno.land/r/\w{8}/contract.gno:3:1: unknown import path net'

gno test -v --with-native-fallback .

Expand Down
4 changes: 2 additions & 2 deletions gnovm/cmd/gno/testdata/gno_test/unknow_lib.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

! stdout .+
stderr 'panic: unknown import path foobarbaz \[recovered\]'
stderr ' panic: gno.land/r/\w{8}/contract.gno:3:8: unknown import path foobarbaz'
stderr ' panic: gno.land/r/\w{8}/contract.gno:3:1: unknown import path foobarbaz'

! gno test -v --with-native-fallback .

! stdout .+
stderr 'panic: unknown import path foobarbaz \[recovered\]'
stderr ' panic: gno.land/r/\w{8}/contract.gno:3:8: unknown import path foobarbaz'
stderr ' panic: gno.land/r/\w{8}/contract.gno:3:1: unknown import path foobarbaz'

-- contract.gno --
package contract
Expand Down
2 changes: 1 addition & 1 deletion gnovm/pkg/gnolang/debugger.go
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ func debugLookup(m *Machine, name string) (tv TypedValue, ok bool) {
}
}
// Fallback: search a global value.
if v := sblocks[0].Source.GetValueRef(m.Store, Name(name)); v != nil {
if v := sblocks[0].Source.GetValueRef(m.Store, Name(name), true); v != nil {
return *v, true
}
return tv, false
Expand Down
2 changes: 1 addition & 1 deletion gnovm/pkg/gnolang/gonative_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestGoNativeDefine(t *testing.T) {
pkg := NewPackageNode("foo", "test.foo", nil)
rt := reflect.TypeOf(Foo{})
pkg.DefineGoNativeType(rt)
nt := pkg.GetValueRef(nil, Name("Foo")).GetType().(*NativeType)
nt := pkg.GetValueRef(nil, Name("Foo"), true).GetType().(*NativeType)
assert.Equal(t, rt, nt.Type)
path := pkg.GetPathForName(nil, Name("Foo"))
assert.Equal(t, uint8(1), path.Depth)
Expand Down
Loading
Loading