File tree Expand file tree Collapse file tree 5 files changed +33
-8
lines changed Expand file tree Collapse file tree 5 files changed +33
-8
lines changed Original file line number Diff line number Diff line change @@ -96,6 +96,7 @@ class ScalaSettings extends Settings.SettingGroup {
9696 val YnoPatmatOpt = BooleanSetting (" -Yno-patmat-opt" , " disable all pattern matching optimizations." )
9797 val YplainPrinter = BooleanSetting (" -Yplain-printer" , " Pretty-print using a plain printer." )
9898 val YprintSyms = BooleanSetting (" -Yprint-syms" , " when printing trees print info in symbols instead of corresponding info in trees." )
99+ val YprintNoPrivate = BooleanSetting (" -Yprint-no-private" , " when printing trees print do not print private/protected members." )
99100 val YprintDebug = BooleanSetting (" -Yprint-debug" , " when printing trees, print some extra information useful for debugging." )
100101 val YtestPickler = BooleanSetting (" -Ytest-pickler" , " self-test for pickling functionality; should be used with -Ystop-after:pickler" )
101102 val YcheckReentrant = BooleanSetting (" -Ycheck-reentrant" , " check that compiled program does not contain vars that can be accessed from a global root." )
Original file line number Diff line number Diff line change @@ -192,7 +192,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
192192 }
193193
194194 def blockText [T >: Untyped ](trees : List [Tree [T ]]): Text =
195- (" {" ~ toText(trees, " \n " ) ~ " }" ).close
195+ (" {" ~ toText(trees.filter(t => ! t.symbol.isPrivate) , " \n " ) ~ " }" ).close
196196
197197 override def toText [T >: Untyped ](tree : Tree [T ]): Text = controlled {
198198
@@ -318,6 +318,8 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
318318 case _ => false
319319 }
320320 params ::: rest
321+ } else if (ctx.settings.YprintNoPrivate .value) {
322+ impl.body.filter(t => ! t.symbol.isPrivate && ! t.symbol.is(Protected ))
321323 } else impl.body
322324
323325 val bodyText = " {" ~~ selfText ~~ toTextGlobal(primaryConstrs ::: body, " \n " ) ~ " }"
Original file line number Diff line number Diff line change @@ -13,8 +13,28 @@ object Main extends dotc.Driver {
1313 new TASTYDecompiler
1414 }
1515
16- override def setup (args : Array [String ], rootCtx : Context ): (List [String ], Context ) = {
17- val args1 = if (args.contains(" -tasty" )) args else args :+ " -tasty"
18- super .setup(args1, rootCtx)
16+ override def setup (args0 : Array [String ], rootCtx : Context ): (List [String ], Context ) = {
17+ var args = args0
18+ args = if (args.contains(" -tasty" )) args else args :+ " -tasty"
19+ args = if (args.exists(a => a == " -private" || a == " -p" )) args.filter(a => a != " -private" && a != " -p" ) else args :+ " -Yprint-no-private"
20+ args = if (args.exists(a => a == " -code" || a == " -c" )) args.filter(a => a != " -code" && a != " -c" ) else args :+ " -Yprint-syms"
21+
22+ if (args.contains(" -help" )) {
23+ printHelp()
24+ sys.exit(0 )
25+ } else super .setup(args, rootCtx)
26+ }
27+
28+ private def printHelp (): Unit = {
29+ val msg =
30+ """ dotp <option|class>*
31+ |
32+ |options:
33+ | -private | -p Print private and protected members
34+ | -code | -c Print implementations (code disassembly)
35+ | -classpath <path> Classpath where to find the classes
36+ | -help Print this message
37+ """ .stripMargin
38+ println(msg)
1939 }
2040}
Original file line number Diff line number Diff line change @@ -36,8 +36,9 @@ mkdir out/scriptedtest2
3636
3737# check that `dotp` runs
3838echo " testing ./bin/dotp"
39- ./bin/dotp -classpath out/scriptedtest1 dotrtest.Test > sbtdotr3.out
40- if grep -e " def main(args: Array\[String\]): Unit =" sbtdotr3.out; then
39+ ./bin/dotp -classpath out/scriptedtest1 -code dotrtest.Test > sbtdotp3.out
40+ cat sbtdotp3.out
41+ if grep -e " def main(args: Array\[String\]): Unit =" sbtdotp3.out; then
4142 echo " output ok"
4243else
4344 echo " failed output check"
Original file line number Diff line number Diff line change 3030
3131# check that `sbt dotp` runs
3232echo " testing sbt dotp"
33- ./project/scripts/sbt " ;dotp -tasty -classpath out/scriptedtest1 dotrtest.Test" > sbtdotr3.out
34- if grep -e " def main(args: Array\[String\]): Unit =" sbtdotr3.out; then
33+ ./project/scripts/sbt " ;dotp -tasty -classpath out/scriptedtest1 -code dotrtest.Test" > sbtdotp3.out
34+ cat sbtdotp3.out
35+ if grep -e " def main(args: Array\[String\]): Unit =" sbtdotp3.out; then
3536 echo " output ok"
3637else
3738 echo " failed output check"
You can’t perform that action at this time.
0 commit comments