Improved SSA and added unused value checks
All checks were successful
/ test (push) Successful in 17s

This commit is contained in:
Eduard Urbach 2025-06-23 23:11:05 +02:00
parent cc2e98ca49
commit 2b703e9af2
Signed by: akyoto
GPG key ID: 49226B848C78F6C8
25 changed files with 519 additions and 213 deletions

View file

@ -0,0 +1,50 @@
package ssa
import (
"fmt"
"git.urbach.dev/cli/q/src/expression"
"git.urbach.dev/cli/q/src/token"
)
type BinaryOperation struct {
Left Value
Right Value
Op token.Kind
Liveness
HasToken
}
func (v *BinaryOperation) Dependencies() []Value {
return []Value{v.Left, v.Right}
}
func (a *BinaryOperation) Equals(v Value) bool {
b, sameType := v.(*BinaryOperation)
if !sameType {
return false
}
if a.Source.Kind != b.Source.Kind {
return false
}
if !a.Left.Equals(b.Left) {
return false
}
if !a.Right.Equals(b.Right) {
return false
}
return true
}
func (v *BinaryOperation) IsConst() bool {
return true
}
func (v *BinaryOperation) String() string {
return fmt.Sprintf("%s %s %s", v.Left, expression.Operators[v.Op].Symbol, v.Right)
}