Skip to content

Commit 03a8b55

Browse files
authored
build(gnovm): improve code generation (#3595)
- follow the standard `^// Code generated .* DO NOT EDIT\.$` syntax in genstd (see `go help generate`) - move `stringer` to `go:generate` directive, output all String methods into one single file
1 parent 0f5b64d commit 03a8b55

14 files changed

+477
-516
lines changed

gnovm/Makefile

+1-13
Original file line numberDiff line numberDiff line change
@@ -125,27 +125,15 @@ _test.filetest:;
125125

126126
########################################
127127
# Code gen
128-
# TODO: move _dev.stringer to go:generate instructions, simplify generate
129-
# to just go generate.
130128
.PHONY: generate
131-
generate: _dev.stringer _dev.generate _dev.docs fmt imports
129+
generate: _dev.generate _dev.docs fmt imports
132130

133131
.PHONY: _dev.docs
134132
_dev.docs:
135133
mkdir -p .tmp
136134
(go run ./cmd/gno -h 2>&1 || true) | grep -v "exit status 1" > .tmp/gno-help.txt
137135
$(rundep) github.com/campoy/embedmd -w `find . -name "*.md"`
138136

139-
stringer_cmd=$(rundep) golang.org/x/tools/cmd/stringer
140-
.PHONY: _dev.stringer
141-
_dev.stringer:
142-
$(stringer_cmd) -type=Kind ./pkg/gnolang
143-
$(stringer_cmd) -type=Op ./pkg/gnolang
144-
$(stringer_cmd) -type=TransCtrl ./pkg/gnolang
145-
$(stringer_cmd) -type=TransField ./pkg/gnolang
146-
$(stringer_cmd) -type=VPType ./pkg/gnolang
147-
$(stringer_cmd) -type=Word ./pkg/gnolang
148-
149137
.PHONY: _dev.generate
150138
_dev.generate:
151139
go generate -x ./...

gnovm/pkg/gnolang/doc.go

+5
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
// SPDX-License-Identifier: GNO License Version 1.0
2+
3+
// Package gnolang contains the implementation of the Gno Virtual Machine.
24
package gnolang
5+
6+
//go:generate -command stringer go run -modfile ../../../misc/devdeps/go.mod golang.org/x/tools/cmd/stringer
7+
//go:generate stringer -type=Kind,Op,TransCtrl,TransField,VPType,Word -output string_methods.go .

gnovm/pkg/gnolang/kind_string.go

-53
This file was deleted.

gnovm/pkg/gnolang/machine.go

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package gnolang
22

3-
// XXX rename file to machine.go.
4-
53
import (
64
"fmt"
75
"io"

gnovm/pkg/gnolang/op_string.go

-178
This file was deleted.

0 commit comments

Comments
 (0)