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: Use Go min/max builtins #4620

Closed
wants to merge 1 commit into from
Closed
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
19 changes: 0 additions & 19 deletions runtime/Go/antlr/v4/tokenstream_rewriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,8 @@
start := interval.Start
stop := interval.Stop
// ensure start/end are in range
stop = min(stop, tsr.tokens.Size()-1)

Check failure on line 449 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (macos-12, go)

min requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 449 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (macos-12, go)

min requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 449 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (macos-12, go)

min requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 449 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (macos-12, go)

min requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 449 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (macos-12, go)

min requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 449 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (macos-12, go)

min requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 449 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (macos-12, go)

min requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 449 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (macos-12, go)

min requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 449 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (macos-12, go)

min requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 449 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04, go)

min requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 449 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04, go)

min requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 449 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04, go)

min requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 449 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (windows-2022, go)

min requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 449 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (windows-2022, go)

min requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 449 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (windows-2022, go)

min requires go1.21 or later (-lang was set to go1.20; check go.mod)
start = max(start, 0)

Check failure on line 450 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (macos-12, go)

max requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 450 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (macos-12, go)

max requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 450 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (macos-12, go)

max requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 450 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (macos-12, go)

max requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 450 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (macos-12, go)

max requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 450 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (macos-12, go)

max requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 450 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (macos-12, go)

max requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 450 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (macos-12, go)

max requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 450 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (macos-12, go)

max requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 450 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04, go)

max requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 450 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04, go)

max requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 450 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04, go)

max requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 450 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (windows-2022, go)

max requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 450 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (windows-2022, go)

max requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 450 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (windows-2022, go)

max requires go1.21 or later (-lang was set to go1.20; check go.mod)
if len(rewrites) == 0 {
return tsr.tokens.GetTextFromInterval(interval) // no instructions to execute
}
Expand Down Expand Up @@ -577,8 +577,8 @@
// D.i-j.u D.x-y.v | boundaries overlap combine to max(min)..max(right)
if prevop.text == "" && rop.text == "" && !disjoint {
rewrites[prevop.instructionIndex] = nil
rop.index = min(prevop.index, rop.index)

Check failure on line 580 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (macos-12, go)

min requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 580 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (macos-12, go)

min requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 580 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (macos-12, go)

min requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 580 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (macos-12, go)

min requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 580 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (macos-12, go)

min requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 580 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (macos-12, go)

min requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 580 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04, go)

min requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 580 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04, go)

min requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 580 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (windows-2022, go)

min requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 580 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (windows-2022, go)

min requires go1.21 or later (-lang was set to go1.20; check go.mod)
rop.LastIndex = max(prevop.LastIndex, rop.LastIndex)

Check failure on line 581 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (macos-12, go)

max requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 581 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (macos-12, go)

max requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 581 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (macos-12, go)

max requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 581 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (macos-12, go)

max requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 581 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (macos-12, go)

max requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 581 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (macos-12, go)

max requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 581 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04, go)

max requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 581 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04, go)

max requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 581 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (windows-2022, go)

max requires go1.21 or later (-lang was set to go1.20; check go.mod)

Check failure on line 581 in runtime/Go/antlr/v4/tokenstream_rewriter.go

View workflow job for this annotation

GitHub Actions / build (windows-2022, go)

max requires go1.21 or later (-lang was set to go1.20; check go.mod)
} else if !disjoint {
panic("replace op boundaries of " + rop.String() + " overlap with previous " + prevop.String())
}
Expand Down Expand Up @@ -641,22 +641,3 @@
}
return m
}

/*
Quick fixing Go lack of overloads
*/

func max(a, b int) int {
if a > b {
return a
} else {
return b
}
}
func min(a, b int) int {
if a < b {
return a
} else {
return b
}
}
Loading