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(transpiler): transpile gno standard libraries #1695

Merged
merged 105 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
85f62ba
refactor(gnovm): rename precompiler to transpiler, move to own package
thehowl Feb 22, 2024
9409285
move transpiler to pkg
thehowl Feb 22, 2024
209a233
part 1: precompile also standard libraries
thehowl Feb 22, 2024
cb63cf5
Merge branch 'master' into dev/morgan/precompile-refactor
thehowl Feb 22, 2024
072c9a8
begin removing support for linked identifiers
thehowl Feb 22, 2024
3710ded
Merge branch 'dev/morgan/precompile-refactor' of github.com:gnolang/g…
thehowl Feb 22, 2024
37c9e66
fixup
thehowl Feb 22, 2024
34133bd
convert native bindings to never use linked types
thehowl Feb 23, 2024
c0535a8
remove InjectNativeMappings
thehowl Feb 23, 2024
231cf9e
correctly handle native functions in transpiler
thehowl Feb 26, 2024
17e2005
fixes to transpiler
thehowl Feb 26, 2024
3d5ffef
remove stdshim, remove StaticCheck
thehowl Feb 26, 2024
e278598
make code compile
thehowl Feb 26, 2024
59c5bb1
Merge branch 'master' of github.com:gnolang/gno into dev/morgan/preco…
thehowl Feb 26, 2024
3a3ec02
Merge branch 'dev/morgan/precompile-refactor' into dev/morgan/precomp…
thehowl Feb 27, 2024
e47ff20
move type checker to its own function
thehowl Feb 27, 2024
2156609
improve build
thehowl Feb 27, 2024
d778788
lint fix
thehowl Feb 27, 2024
d39292b
Merge branch 'master' into dev/morgan/precompile-refactor
thehowl Feb 27, 2024
1a61b6b
fix errors in genstd
thehowl Feb 27, 2024
93a99a3
fixup
thehowl Feb 27, 2024
b4e0dd0
address linter
thehowl Feb 27, 2024
a25d076
Merge branch 'master' of github.com:gnolang/gno into dev/morgan/preco…
thehowl Feb 28, 2024
0047d3e
Merge branch 'dev/morgan/precompile-refactor' into dev/morgan/precomp…
thehowl Feb 28, 2024
a889dea
begin removing support for linked identifiers
thehowl Feb 22, 2024
aae89db
convert native bindings to never use linked types
thehowl Feb 23, 2024
fd2722e
remove InjectNativeMappings
thehowl Feb 23, 2024
8856225
fix errors in genstd
thehowl Feb 27, 2024
d6955d0
remove AddGo2GnoMapping, nolint on btReadonly
thehowl Feb 28, 2024
c3e8ff8
Merge branch 'master' of github.com:gnolang/gno into dev/morgan/preco…
thehowl Feb 28, 2024
1de00fa
Merge branch 'dev/morgan/precompile-refactor' into dev/morgan/natbind…
thehowl Feb 28, 2024
c0581dd
Merge branch 'master' of github.com:gnolang/gno into dev/morgan/natbi…
thehowl Feb 28, 2024
1c1cda4
Merge branch 'dev/morgan/natbind-no-linkedtype' into dev/morgan/preco…
thehowl Feb 28, 2024
b3c7adb
fmt + bugfix
thehowl Feb 28, 2024
250e292
feat(gno.land): add go type checking to keeper
thehowl Feb 28, 2024
f277e3e
Merge branch 'dev/morgan/go-types-typecheck' into dev/morgan/precompi…
thehowl Feb 28, 2024
0d8596d
lint + test fixes
thehowl Feb 28, 2024
9702dcb
Merge branch 'dev/morgan/go-types-typecheck' into dev/morgan/precompi…
thehowl Feb 28, 2024
10c0434
Merge branch 'master' of github.com:gnolang/gno into dev/morgan/natbi…
thehowl Mar 3, 2024
f641c58
Merge branch 'dev/morgan/natbind-no-linkedtype' into dev/morgan/go-ty…
thehowl Mar 3, 2024
9779ff3
use custom type instead of any in importer
thehowl Mar 3, 2024
7b239df
support multiple errors in type checker
thehowl Mar 3, 2024
1b323a2
correctly return error in vm keeper
thehowl Mar 3, 2024
df1679c
add tests to type checker
thehowl Mar 3, 2024
ee0448e
fixup
thehowl Mar 3, 2024
a169800
add integration test for gno.land
thehowl Mar 3, 2024
e53aa22
Merge branch 'master' into dev/morgan/go-types-typecheck
thehowl Mar 20, 2024
172e4ae
Merge branch 'master' of github.com:gnolang/gno into dev/morgan/go-ty…
thehowl Mar 27, 2024
0fa34fa
remove newMemPackage
thehowl Mar 27, 2024
8688167
Merge branch 'dev/morgan/go-types-typecheck' of github.com:gnolang/gn…
thehowl Mar 27, 2024
89d9887
remove unused var
thehowl Mar 27, 2024
ccf0ba9
Merge branch 'master' into dev/morgan/go-types-typecheck
thehowl Apr 15, 2024
338454f
remove other usage in gnoclient
thehowl Apr 15, 2024
6b4ed9e
remove unused import in test
thehowl Apr 15, 2024
a9d44ea
Merge branch 'dev/morgan/go-types-typecheck' into dev/morgan/precompi…
thehowl Apr 15, 2024
0a40b46
fix some tests
thehowl Apr 15, 2024
4c7596e
add tests for transpiler changes
thehowl Apr 15, 2024
e89a7c1
create makefile rule to simplify coverage in cmd/gno
thehowl Apr 16, 2024
86abc8c
dont use sequential numbering
thehowl Apr 16, 2024
ead5877
fix tests, add more tests, cry in go build
thehowl Apr 16, 2024
261b576
very confused by this gnomod code
thehowl Apr 16, 2024
0007e73
Merge branch 'master' of github.com:gnolang/gno into dev/morgan/go-ty…
thehowl Apr 17, 2024
2c2612b
Merge branch 'dev/morgan/go-types-typecheck' into dev/morgan/precompi…
thehowl Apr 17, 2024
e2e2e3a
add tests for -output
thehowl Apr 17, 2024
dd370ae
move IsStdlib to gnolang
thehowl Apr 17, 2024
360dac2
bump limits for issue-1786 test
thehowl Apr 17, 2024
9ccb5ee
bump limits for issue-1786 test
thehowl Apr 17, 2024
9115997
Merge branch 'dev/morgan/go-types-typecheck' into dev/morgan/precompi…
thehowl Apr 17, 2024
e20ebbe
bump up to 4M
thehowl Apr 17, 2024
f4e6ede
Merge branch 'dev/morgan/go-types-typecheck' into dev/morgan/precompi…
thehowl Apr 17, 2024
ad2f0b1
Merge branch 'master' of github.com:gnolang/gno into dev/morgan/go-ty…
thehowl May 6, 2024
66fb953
changes from code review
thehowl May 6, 2024
38cba04
fix gas numbers
thehowl May 7, 2024
bee0f30
add transaction simulation in gnokey
thehowl May 7, 2024
3a82a98
fixup lint
thehowl May 7, 2024
39ae304
update docs
thehowl May 7, 2024
b73f835
Merge branch 'dev/morgan/go-types-typecheck' into dev/morgan/precompi…
thehowl May 7, 2024
5aa3ce5
genstd
thehowl May 7, 2024
dbde296
partial revert of store changes
thehowl May 9, 2024
9ee3cc6
Merge branch 'master' of github.com:gnolang/gno into dev/morgan/go-ty…
thehowl May 9, 2024
f843acb
fixup
thehowl May 9, 2024
2558b09
Revert "fixup"
thehowl May 10, 2024
cc9d45e
Revert "partial revert of store changes"
thehowl May 10, 2024
09f081c
fixup
thehowl May 10, 2024
38719cd
update docs
thehowl May 10, 2024
815c573
Merge branch 'master' of github.com:gnolang/gno into dev/morgan/go-ty…
thehowl May 13, 2024
db07b34
Merge branch 'dev/morgan/go-types-typecheck' into dev/morgan/precompi…
thehowl May 13, 2024
8103ac0
Merge branch 'master' of github.com:gnolang/gno into dev/morgan/preco…
thehowl May 13, 2024
06cbed9
Merge branch 'master' into dev/morgan/precompile-refactor-2
thehowl May 14, 2024
0254beb
Merge branch 'master' into dev/morgan/precompile-refactor-2
thehowl May 24, 2024
39f7a58
Merge branch 'master' of github.com:gnolang/gno into dev/morgan/preco…
thehowl May 29, 2024
91a63f2
Merge branch 'master' of github.com:gnolang/gno into dev/morgan/preco…
thehowl Jun 3, 2024
b894b45
Merge branch 'master' of github.com:gnolang/gno into dev/morgan/preco…
thehowl Jun 18, 2024
0305e33
Update gnovm/cmd/gno/transpile.go
thehowl Jun 18, 2024
1213900
code review changes
thehowl Jun 18, 2024
d89a538
Merge branch 'dev/morgan/precompile-refactor-2' of github.com:gnolang…
thehowl Jun 18, 2024
79fd65f
Update gnovm/cmd/gno/transpile.go
thehowl Jun 18, 2024
f8b0e9b
different system for FindNative
thehowl Jun 18, 2024
2934dde
Merge branch 'dev/morgan/precompile-refactor-2' of github.com:gnolang…
thehowl Jun 18, 2024
dd29804
parallel
thehowl Jun 18, 2024
e3dff75
commands.IO
thehowl Jun 19, 2024
d1b1ca2
return error
thehowl Jun 19, 2024
4c8eca0
add milos refactor
thehowl Jun 19, 2024
afc957b
better error support
thehowl Jun 19, 2024
ced8ae8
Merge branch 'master' into dev/morgan/precompile-refactor-2
thehowl Jun 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions examples/gno.land/r/demo/art/gnoface/gno.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Draft
thehowl marked this conversation as resolved.
Show resolved Hide resolved

module gno.land/r/demo/art/gnoface

require (
Expand Down
2 changes: 2 additions & 0 deletions examples/gno.land/r/x/manfred_outfmt/gno.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Draft
thehowl marked this conversation as resolved.
Show resolved Hide resolved

module gno.land/r/x/manfred_outfmt

require (
Expand Down
23 changes: 22 additions & 1 deletion gnovm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ GNOROOT_DIR ?= $(abspath $(lastword $(MAKEFILE_LIST))/../../)
# We can't use '-trimpath' yet as amino use absolute path from call stack
# to find some directory: see #1236
GOBUILD_FLAGS ?= -ldflags "-X github.com/gnolang/gno/gnovm/pkg/gnoenv._GNOROOT=$(GNOROOT_DIR)"
# file where to place cover profile; used for coverage commands which are
# more complex than adding -coverprofile, like test.cmd.coverage.
GOTEST_COVER_PROFILE ?= cmd-profile.out

########################################
# Dev tools
Expand Down Expand Up @@ -66,6 +69,24 @@ test: _test.cmd _test.pkg _test.gnolang
_test.cmd:
go test ./cmd/... $(GOTEST_FLAGS)

# Run tests on ./cmd/, saving the result of the coverage in
# GOTEST_COVER_PROFILE.
.PHONY: test.cmd.coverage
test.cmd.coverage:
$(eval export TXTARCOVERDIR := $(shell mktemp -d --tmpdir gnovm-make.XXXXXXX))
go test ./cmd/... -covermode atomic -test.gocoverdir='$(TXTARCOVERDIR)' $(GOTEST_FLAGS)
@echo "coverage results:"
go tool covdata percent -i="$(TXTARCOVERDIR)"
go tool covdata textfmt -v 1 -i="$(TXTARCOVERDIR)" -o '$(GOTEST_COVER_PROFILE)'
rm -rf "$(TXTARCOVERDIR)"

# Run test.cmd.coverage, then view the result in the HTML browser render
# and delete the original file.
.PHONY: test.cmd.coverage_view
test.cmd.coverage_view: test.cmd.coverage
go tool cover -html='$(GOTEST_COVER_PROFILE)'
rm '$(GOTEST_COVER_PROFILE)'

.PHONY: _test.pkg
_test.pkg:
go test ./pkg/... $(GOTEST_FLAGS)
Expand All @@ -74,7 +95,7 @@ _test.pkg:
_test.gnolang: _test.gnolang.native _test.gnolang.stdlibs _test.gnolang.realm _test.gnolang.pkg0 _test.gnolang.pkg1 _test.gnolang.pkg2 _test.gnolang.other
_test.gnolang.other:; go test tests/*.go -run "(TestFileStr|TestSelectors)" $(GOTEST_FLAGS)
_test.gnolang.realm:; go test tests/*.go -run "TestFiles/^zrealm" $(GOTEST_FLAGS)
_test.gnolang.pkg0:; go test tests/*.go -run "TestStdlibs/(bufio|crypto|encoding|errors|internal|io|math|sort|std|stdshim|strconv|strings|testing|unicode)" $(GOTEST_FLAGS)
_test.gnolang.pkg0:; go test tests/*.go -run "TestStdlibs/(bufio|crypto|encoding|errors|internal|io|math|sort|std|strconv|strings|testing|unicode)" $(GOTEST_FLAGS)
_test.gnolang.pkg1:; go test tests/*.go -run "TestStdlibs/regexp" $(GOTEST_FLAGS)
_test.gnolang.pkg2:; go test tests/*.go -run "TestStdlibs/bytes" $(GOTEST_FLAGS)
_test.gnolang.native:; go test tests/*.go -test.short -run "TestFilesNative/" $(GOTEST_FLAGS)
Expand Down
3 changes: 1 addition & 2 deletions gnovm/cmd/gno/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"github.com/gnolang/gno/gnovm/pkg/gnoenv"
gno "github.com/gnolang/gno/gnovm/pkg/gnolang"
"github.com/gnolang/gno/gnovm/pkg/gnomod"
"github.com/gnolang/gno/gnovm/pkg/transpiler"
"github.com/gnolang/gno/gnovm/tests"
"github.com/gnolang/gno/tm2/pkg/commands"
"github.com/gnolang/gno/tm2/pkg/errors"
Expand Down Expand Up @@ -259,7 +258,7 @@
if gnoPkgPath == "" {
// unable to read pkgPath from gno.mod, generate a random realm path
io.ErrPrintfln("--- WARNING: unable to read package path from gno.mod or gno root directory; try creating a gno.mod file")
gnoPkgPath = transpiler.GnoRealmPkgsPrefixBefore + random.RandStr(8)
gnoPkgPath = gno.RealmPathPrefix + random.RandStr(8)

Check warning on line 261 in gnovm/cmd/gno/test.go

View check run for this annotation

Codecov / codecov/patch

gnovm/cmd/gno/test.go#L261

Added line #L261 was not covered by tests
}
}
memPkg := gno.ReadMemPackage(pkgPath, gnoPkgPath)
Expand Down
36 changes: 0 additions & 36 deletions gnovm/cmd/gno/testdata/gno_transpile/05_skip_fmt_flag.txtar

This file was deleted.

38 changes: 0 additions & 38 deletions gnovm/cmd/gno/testdata/gno_transpile/06_build_flag.txtar

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Run gno transpile with gno files with whitelist errors
# Run gno transpile with gno files with an invalid import path

! gno transpile .

! stdout .+
stderr '^main.gno:5:2: import "xxx" is not in the whitelist$'
stderr '^sub/sub.gno:3:8: import "xxx" is not in the whitelist$'
stderr '^main.gno:5:2: import "xxx" does not exist$'
stderr '^sub/sub.gno:3:8: import "xxx" does not exist$'
stderr '^2 transpile error\(s\)$'

# no *.gen.go files are created
Expand Down
31 changes: 31 additions & 0 deletions gnovm/cmd/gno/testdata/gno_transpile/valid_gobuild_file.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Run gno transpile with -gobuild flag on an individual file

gno transpile -gobuild -v main.gno

! stdout .+
cmp stderr stderr.golden

cmp main.gno.gen.go main.gno.gen.go.golden

-- stderr.golden --
main.gno
main.gno [build]
-- main.gno --
package main

func main() {
var x = 1
_=x
}
-- main.gno.gen.go.golden --
// Code generated by github.com/gnolang/gno. DO NOT EDIT.

//go:build gno

//line main.gno:1:1
package main

func main() {
var x = 1
_ = x
}
72 changes: 72 additions & 0 deletions gnovm/cmd/gno/testdata/gno_transpile/valid_gobuild_flag.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Run gno transpile with -gobuild flag

gno transpile -gobuild -v .

! stdout .+
cmp stderr stderr.golden

# The test file will be excluded from transpilation unless we pass it explicitly.
cmp main.gno.gen.go main.gno.gen.go.golden
! exists .main_test.gno.gen_test.go
cmp sub/sub.gno.gen.go sub/sub.gno.gen.go.golden
rm mai.gno.gen.gosub/sub.gno.gen.go

# Re-try, but use an absolute path.
gno transpile -gobuild -v $WORK

! stdout .+
cmpenv stderr stderr2.golden

cmp main.gno.gen.go main.gno.gen.go.golden
! exists .main_test.gno.gen_test.go
cmp sub/sub.gno.gen.go sub/sub.gno.gen.go.golden

-- stderr.golden --
.
sub
. [build]
sub [build]
-- stderr2.golden --
$WORK
$WORK/sub
$WORK [build]
$WORK/sub [build]
-- main.gno --
package main

func main() {
var x = 1
_=x
}
-- main.gno.gen.go.golden --
// Code generated by github.com/gnolang/gno. DO NOT EDIT.

//go:build gno

//line main.gno:1:1
package main

func main() {
var x = 1
_ = x
}
-- main_test.gno --
package main

import (
"testing"
"badimport"
)

func TestMain(t *testing.T) {
badimport.DoesNotExist()
}
-- sub/sub.gno --
package sub
-- sub/sub.gno.gen.go.golden --
// Code generated by github.com/gnolang/gno. DO NOT EDIT.

//go:build gno

//line sub.gno:1:1
package sub
41 changes: 41 additions & 0 deletions gnovm/cmd/gno/testdata/gno_transpile/valid_output_flag.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Run gno transpile with valid gno files, using the -output flag.

gno transpile -v -output directory/hello/ .
! stdout .+
cmp stderr stderr1.golden

exists directory/hello/main.gno.gen.go
! exists main.gno.gen.go
rm directory

# Try running using the absolute path to the directory.
gno transpile -v -output directory/hello $WORK
! stdout .+
cmpenv stderr stderr2.golden

exists directory/hello$WORK/main.gno.gen.go
! exists directory/hello/main.gno.gen.go
rm directory

# Try running in subdirectory, using a "relative non-local path." (ie. has "../")
mkdir subdir
cd subdir
gno transpile -v -output hello ..
! stdout .+
cmpenv stderr ../stderr3.golden

exists hello$WORK/main.gno.gen.go
! exists main.gno.gen.go

-- stderr1.golden --
.
-- stderr2.golden --
$WORK
-- stderr3.golden --
..
-- main.gno --
package main

func main() {
println("hello")
}
44 changes: 44 additions & 0 deletions gnovm/cmd/gno/testdata/gno_transpile/valid_output_gobuild.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Run gno transpile with valid gno files, using the -output and -gobuild flags together.

gno transpile -v -output directory/hello/ -gobuild .
! stdout .+
cmp stderr stderr1.golden

exists directory/hello/main.gno.gen.go
! exists main.gno.gen.go
rm directory

# Try running using the absolute path to the directory.
gno transpile -v -output directory/hello -gobuild $WORK
! stdout .+
cmpenv stderr stderr2.golden

exists directory/hello$WORK/main.gno.gen.go
! exists directory/hello/main.gno.gen.go
rm directory

# Try running in subdirectory, using a "relative non-local path." (ie. has "../")
mkdir subdir
cd subdir
gno transpile -v -output hello -gobuild ..
! stdout .+
cmpenv stderr ../stderr3.golden

exists hello$WORK/main.gno.gen.go
! exists main.gno.gen.go

-- stderr1.golden --
.
directory/hello [build]
-- stderr2.golden --
$WORK
directory/hello$WORK [build]
-- stderr3.golden --
..
hello$WORK [build]
-- main.gno --
package main

func main() {
println("hello")
}
Loading
Loading