@@ -10,6 +10,7 @@ import TastyUnpickler._
10
10
import TastyBuffer .{Addr , NameRef }
11
11
import util .Positions .{Position , offsetToInt }
12
12
import collection .mutable
13
+ import printing .Highlighting ._
13
14
14
15
class TastyPrinter (bytes : Array [Byte ])(implicit ctx : Context ) {
15
16
@@ -22,8 +23,8 @@ class TastyPrinter(bytes: Array[Byte])(implicit ctx: Context) {
22
23
23
24
def printNames () =
24
25
for ((name, idx) <- nameAtRef.contents.zipWithIndex) {
25
- val index = " %4d: " .format(idx)
26
- println(index + nameToString(name))
26
+ val index = Magenta ( " %4d" .format(idx) )
27
+ println(index + " : " + nameToString(name))
27
28
}
28
29
29
30
def printContents (): Unit = {
@@ -41,13 +42,13 @@ class TastyPrinter(bytes: Array[Byte])(implicit ctx: Context) {
41
42
import reader ._
42
43
var indent = 0
43
44
def newLine () = {
44
- val length = " %5d: " .format(index(currentAddr) - index(startAddr))
45
- print(s " \n $length" + " " * indent)
45
+ val length = Yellow ( " %5d" .format(index(currentAddr) - index(startAddr))).show
46
+ print(s " \n $length: " + " " * indent)
46
47
}
47
- def printNat () = print(" " + readNat())
48
+ def printNat () = print(Yellow ( " " + readNat()).show )
48
49
def printName () = {
49
50
val idx = readNat()
50
- print(" " ) ;print( idx); print( " [ " ); print( nameRefToString(NameRef (idx))); print( " ]" )
51
+ print(Magenta ( " " + idx + " [ " + nameRefToString(NameRef (idx)) + " ]" ).show )
51
52
}
52
53
def printTree (): Unit = {
53
54
newLine()
@@ -56,7 +57,7 @@ class TastyPrinter(bytes: Array[Byte])(implicit ctx: Context) {
56
57
indent += 2
57
58
if (tag >= firstLengthTreeTag) {
58
59
val len = readNat()
59
- print(s " ( $len) " )
60
+ print(s " ( ${ Cyan ( len.toString).show} ) " )
60
61
val end = currentAddr + len
61
62
def printTrees () = until(end)(printTree())
62
63
tag match {
@@ -83,7 +84,7 @@ class TastyPrinter(bytes: Array[Byte])(implicit ctx: Context) {
83
84
}
84
85
else if (tag >= firstNatASTTreeTag) {
85
86
tag match {
86
- case IDENT | SELECT | TERMREF | TYPEREF | SELFDEF => printName()
87
+ case IDENT | IDENTtpt | SELECT | TERMREF | TYPEREF | SELFDEF => printName()
87
88
case _ => printNat()
88
89
}
89
90
printTree()
@@ -112,7 +113,7 @@ class TastyPrinter(bytes: Array[Byte])(implicit ctx: Context) {
112
113
val positions = new PositionUnpickler (reader).positions
113
114
println(s " position bytes: " )
114
115
val sorted = positions.toSeq.sortBy(_._1.index)
115
- for ((addr, pos) <- sorted) println(s " ${addr.index}: ${offsetToInt(pos.start)} .. ${pos.end}" )
116
+ for ((addr, pos) <- sorted) println(s " ${Yellow ( addr.index.toString).show }: ${offsetToInt(pos.start)} .. ${pos.end}" )
116
117
}
117
118
}
118
119
}
0 commit comments