Skip to content

Commit

Permalink
fix makefile generate, fix ref of ref case
Browse files Browse the repository at this point in the history
  • Loading branch information
ldemailly committed Sep 3, 2024
1 parent 2a94511 commit 02582c5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
11 changes: 4 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ run: grol
# Interactive debug run: use logger with file and line numbers
LOGGER_IGNORE_CLI_MODE=true GOMEMLIMIT=1GiB ./grol -panic -parse -loglevel debug

GEN:=object/type_string.go parser/priority_string.go token/type_string.go
GEN:=object/type_string.go ast/priority_string.go token/type_string.go

grol: Makefile *.go */*.go $(GEN)
CGO_ENABLED=0 go build -trimpath -ldflags="-w -s" -tags "$(GO_BUILD_TAGS)" .
Expand Down Expand Up @@ -79,16 +79,13 @@ test: grol
check: grol
./check_samples_double_format.sh examples/*.gr

generate:
go generate ./... # if this fails go install golang.org/x/tools/cmd/stringer@latest

generate: $(GEN)

object/type_string.go: object/object.go
go generate ./object
go generate ./object # if this fails go install golang.org/x/tools/cmd/stringer@latest

parser/priority_string.go: parser/parser.go
go generate ./parser
ast/priority_string.go: ast/ast.go
go generate ./ast

token/type_string.go: token/token.go
go generate ./token
Expand Down
11 changes: 4 additions & 7 deletions object/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,11 @@ func (e *Environment) makeRef(name string) (*Reference, bool) {
e = e.outer
continue
}
for {
o, ok := obj.(Reference)
if !ok {
break
}
obj = o.Value()
}
ref := Reference{Name: name, RefEnv: e.outer}
if r, isRef := obj.(Reference); isRef {
log.Debugf("makeRef(%s) found ref %s in %d", name, r.Name, r.RefEnv.depth)
ref = r // set and return the original ref instead of ref of ref.
}
orig.store[name] = ref
orig.getMiss++ // creating a ref is a miss.
return &ref, true
Expand Down

0 comments on commit 02582c5

Please sign in to comment.