This commit is contained in:
parent
cfc0f87c49
commit
bdb1b9595f
2 changed files with 7 additions and 18 deletions
|
@ -2,7 +2,6 @@ package compiler
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"git.urbach.dev/cli/q/src/core"
|
||||
"git.urbach.dev/go/color/ansi"
|
||||
|
@ -11,26 +10,16 @@ import (
|
|||
// showSSA shows the SSA IR.
|
||||
func showSSA(root *core.Function) {
|
||||
root.EachDependency(make(map[*core.Function]bool), func(f *core.Function) {
|
||||
fmt.Print("# ")
|
||||
ansi.Green.Print(f.UniqueName)
|
||||
fmt.Print("\n\n")
|
||||
ansi.Yellow.Println(f.UniqueName + ":")
|
||||
|
||||
for _, block := range f.Blocks {
|
||||
ansi.Dim.Printf("| %-3s | %-30s | %-30s | %-4s |\n", "ID", "Raw", "Type", "Uses")
|
||||
ansi.Dim.Printf("| %s | %s | %s | %s |\n", strings.Repeat("-", 3), strings.Repeat("-", 30), strings.Repeat("-", 30), strings.Repeat("-", 4))
|
||||
// ansi.Dim.Printf("| %-3s | %-30s | %-30s | %-4s |\n", "ID", "Raw", "Type", "Uses")
|
||||
// ansi.Dim.Printf("| %s | %s | %s | %s |\n", strings.Repeat("-", 3), strings.Repeat("-", 30), strings.Repeat("-", 30), strings.Repeat("-", 4))
|
||||
|
||||
for i, instr := range block.Instructions {
|
||||
ansi.Dim.Printf("| %%%-2d | ", i)
|
||||
|
||||
if instr.IsConst() {
|
||||
fmt.Printf("%-30s ", instr.Debug())
|
||||
} else {
|
||||
ansi.Yellow.Printf("%-30s ", instr.Debug())
|
||||
}
|
||||
|
||||
ansi.Dim.Print("|")
|
||||
ansi.Dim.Printf(" %-30s |", instr.Type().Name())
|
||||
ansi.Dim.Printf(" %-4d |", instr.CountUsers())
|
||||
ansi.Dim.Printf("%%%-1d = ", i)
|
||||
fmt.Printf("%-30s ", instr.Debug())
|
||||
ansi.Dim.Printf(" %-30s", instr.Type().Name())
|
||||
fmt.Println()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ func (v *Parameter) Debug() string {
|
|||
}
|
||||
|
||||
func (v *Parameter) String() string {
|
||||
return fmt.Sprintf("in[%d]", v.Index)
|
||||
return fmt.Sprintf("args[%d]", v.Index)
|
||||
}
|
||||
|
||||
func (v *Parameter) Type() types.Type {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue