Something went wrong. Try again.
🌱 A minimal programming language and compiler. git.urbach.dev/cli/q
high-performance programming-language compiler
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041package ssa
import ( "fmt")
// Branch is a conditional branch.type Branch struct { Void Condition Value Then *Block Else *Block}
// Equals returns true if the branches are equal.func (a *Branch) Equals(v Value) bool { b, sameType := v.(*Branch)
if !sameType { return false }
return a.Condition.Equals(b.Condition) && a.Then == b.Then && a.Else == b.Else}
// Inputs returns the condition.func (b *Branch) Inputs() []Value { return []Value{b.Condition}}
// Replace replaces the condition if it matches.func (b *Branch) Replace(old Value, new Value) { if b.Condition == old { b.Condition = new }}
// String returns a human-readable representation of the branch.func (b *Branch) String() string { return fmt.Sprintf("branch(%p, %s, %s)", b.Condition, CleanLabel(b.Then.Label), CleanLabel(b.Else.Label))}