Improved SSA and added unused value checks
All checks were successful
/ test (push) Successful in 17s
All checks were successful
/ test (push) Successful in 17s
This commit is contained in:
parent
cc2e98ca49
commit
2b703e9af2
25 changed files with 519 additions and 213 deletions
50
src/ssa/BinaryOperation.go
Normal file
50
src/ssa/BinaryOperation.go
Normal 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)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue