Simplified compiler package

This commit is contained in:
2025-02-12 19:05:40 +01:00
parent b7b4dad1a5
commit 0dffb79364
11 changed files with 234 additions and 201 deletions

View File

@ -0,0 +1,29 @@
package compiler
import (
"fmt"
"git.akyoto.dev/go/color/ansi"
)
// PrintStatistics shows the statistics.
func (r *Result) PrintStatistics() {
ansi.Dim.Println("╭──────────────────────────────────────────────────────────────────────────────╮")
ansi.Dim.Print("│ ")
ansi.Dim.Printf("%-44s", "Code:")
fmt.Printf("%-32s", fmt.Sprintf("%d bytes", len(r.Code)))
ansi.Dim.Print(" │\n")
ansi.Dim.Print("│ ")
ansi.Dim.Printf("%-44s", "Data:")
fmt.Printf("%-32s", fmt.Sprintf("%d bytes", len(r.Data)))
ansi.Dim.Print(" │\n")
ansi.Dim.Print("│ ")
ansi.Dim.Printf("%-44s", "Functions:")
fmt.Printf("%-32s", fmt.Sprintf("%d / %d", len(r.Traversed), len(r.Functions)))
ansi.Dim.Print(" │\n")
ansi.Dim.Println("╰──────────────────────────────────────────────────────────────────────────────╯")
}