@@ -4,13 +4,12 @@ import java.nio.file.Paths
4
4
import java .io .File
5
5
import scala .scalanative .util .Scope
6
6
import scala .scalanative .cli .options ._
7
- import scala .scalanative .nir .Global
7
+ import scala .scalanative .nir ._
8
8
import scala .scalanative .build .Config
9
9
import scala .scalanative .linker .ClassLoader
10
10
import java .nio .file .Path
11
11
import scala .scalanative .io .VirtualDirectory
12
12
import scala .scalanative .nir .serialization .deserializeBinary
13
- import scala .scalanative .nir .Defn
14
13
import scala .annotation .tailrec
15
14
import java .nio .ByteBuffer
16
15
@@ -66,13 +65,13 @@ object ScalaNativeP {
66
65
System .err.println(s " Ignoring non existing path: $path" )
67
66
}
68
67
69
- if (options.fromPath) printFromFiles(classpath, options.classNames )
70
- else printFromNames(classpath, options.classNames )
68
+ if (options.fromPath) printFromFiles(classpath, options)
69
+ else printFromNames(classpath, options)
71
70
}
72
71
73
72
private def printFromNames (
74
73
classpath : List [Path ],
75
- args : Seq [ String ]
74
+ options : PrinterOptions
76
75
): Unit = {
77
76
Scope { implicit scope =>
78
77
val classLoader =
@@ -81,10 +80,10 @@ object ScalaNativeP {
81
80
}
82
81
83
82
for {
84
- className <- args
83
+ className <- options.classNames
85
84
} {
86
85
classLoader.load(Global .Top (className)) match {
87
- case Some (defns) => printNIR(defns)
86
+ case Some (defns) => printNIR(defns, options.verbose )
88
87
case None => fail(s " Not found class/object with name ` ${className}` " )
89
88
}
90
89
}
@@ -93,7 +92,7 @@ object ScalaNativeP {
93
92
94
93
private def printFromFiles (
95
94
classpath : List [Path ],
96
- args : Seq [ String ]
95
+ options : PrinterOptions
97
96
): Unit = {
98
97
99
98
Scope { implicit scope =>
@@ -122,19 +121,24 @@ object ScalaNativeP {
122
121
}
123
122
}
124
123
for {
125
- fileName <- args
124
+ fileName <- options.classNames
126
125
path = Paths .get(fileName).normalize()
127
126
content <- findAndRead(cp, path)
128
127
.orElse(fail(s " Not found file with name ` ${fileName}` " ))
129
128
} {
130
129
val defns = deserializeBinary(content, fileName)
131
- printNIR(defns)
130
+ printNIR(defns, options.verbose )
132
131
}
133
132
}
134
133
}
135
134
136
- private def printNIR (defns : Seq [Defn ]) =
135
+ private def printNIR (defns : Seq [Defn ], verbose : Boolean ) =
137
136
defns
137
+ .map {
138
+ case defn @ Defn .Define (attrs, name, ty, _) if ! verbose =>
139
+ Defn .Declare (attrs, name, ty)(defn.pos)
140
+ case defn => defn
141
+ }
138
142
.sortBy(_.name.mangle)
139
143
.foreach { d =>
140
144
println(d.show)
0 commit comments