@@ -4,13 +4,12 @@ import java.nio.file.Paths
44import java .io .File
55import scala .scalanative .util .Scope
66import scala .scalanative .cli .options ._
7- import scala .scalanative .nir .Global
7+ import scala .scalanative .nir ._
88import scala .scalanative .build .Config
99import scala .scalanative .linker .ClassLoader
1010import java .nio .file .Path
1111import scala .scalanative .io .VirtualDirectory
1212import scala .scalanative .nir .serialization .deserializeBinary
13- import scala .scalanative .nir .Defn
1413import scala .annotation .tailrec
1514import java .nio .ByteBuffer
1615
@@ -66,13 +65,13 @@ object ScalaNativeP {
6665 System .err.println(s " Ignoring non existing path: $path" )
6766 }
6867
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)
7170 }
7271
7372 private def printFromNames (
7473 classpath : List [Path ],
75- args : Seq [ String ]
74+ options : PrinterOptions
7675 ): Unit = {
7776 Scope { implicit scope =>
7877 val classLoader =
@@ -81,10 +80,10 @@ object ScalaNativeP {
8180 }
8281
8382 for {
84- className <- args
83+ className <- options.classNames
8584 } {
8685 classLoader.load(Global .Top (className)) match {
87- case Some (defns) => printNIR(defns)
86+ case Some (defns) => printNIR(defns, options.verbose )
8887 case None => fail(s " Not found class/object with name ` ${className}` " )
8988 }
9089 }
@@ -93,7 +92,7 @@ object ScalaNativeP {
9392
9493 private def printFromFiles (
9594 classpath : List [Path ],
96- args : Seq [ String ]
95+ options : PrinterOptions
9796 ): Unit = {
9897
9998 Scope { implicit scope =>
@@ -122,19 +121,24 @@ object ScalaNativeP {
122121 }
123122 }
124123 for {
125- fileName <- args
124+ fileName <- options.classNames
126125 path = Paths .get(fileName).normalize()
127126 content <- findAndRead(cp, path)
128127 .orElse(fail(s " Not found file with name ` ${fileName}` " ))
129128 } {
130129 val defns = deserializeBinary(content, fileName)
131- printNIR(defns)
130+ printNIR(defns, options.verbose )
132131 }
133132 }
134133 }
135134
136- private def printNIR (defns : Seq [Defn ]) =
135+ private def printNIR (defns : Seq [Defn ], verbose : Boolean ) =
137136 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+ }
138142 .sortBy(_.name.mangle)
139143 .foreach { d =>
140144 println(d.show)
0 commit comments