Skip to content

Commit

Permalink
build(gnovm): improve code generation (#3595)
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
thehowl authored Feb 10, 2025
1 parent 0f5b64d commit 03a8b55
Show file tree
Hide file tree
Showing 14 changed files with 477 additions and 516 deletions.
14 changes: 1 addition & 13 deletions gnovm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -125,27 +125,15 @@ _test.filetest:;

########################################
# Code gen
# TODO: move _dev.stringer to go:generate instructions, simplify generate
# to just go generate.
.PHONY: generate
generate: _dev.stringer _dev.generate _dev.docs fmt imports
generate: _dev.generate _dev.docs fmt imports

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

stringer_cmd=$(rundep) golang.org/x/tools/cmd/stringer
.PHONY: _dev.stringer
_dev.stringer:
$(stringer_cmd) -type=Kind ./pkg/gnolang
$(stringer_cmd) -type=Op ./pkg/gnolang
$(stringer_cmd) -type=TransCtrl ./pkg/gnolang
$(stringer_cmd) -type=TransField ./pkg/gnolang
$(stringer_cmd) -type=VPType ./pkg/gnolang
$(stringer_cmd) -type=Word ./pkg/gnolang

.PHONY: _dev.generate
_dev.generate:
go generate -x ./...
Expand Down
5 changes: 5 additions & 0 deletions gnovm/pkg/gnolang/doc.go
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
// SPDX-License-Identifier: GNO License Version 1.0

// Package gnolang contains the implementation of the Gno Virtual Machine.
package gnolang

//go:generate -command stringer go run -modfile ../../../misc/devdeps/go.mod golang.org/x/tools/cmd/stringer
//go:generate stringer -type=Kind,Op,TransCtrl,TransField,VPType,Word -output string_methods.go .
53 changes: 0 additions & 53 deletions gnovm/pkg/gnolang/kind_string.go

This file was deleted.

2 changes: 0 additions & 2 deletions gnovm/pkg/gnolang/machine.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package gnolang

// XXX rename file to machine.go.

import (
"fmt"
"io"
Expand Down
178 changes: 0 additions & 178 deletions gnovm/pkg/gnolang/op_string.go

This file was deleted.

Loading

0 comments on commit 03a8b55

Please sign in to comment.