File tree 5 files changed +33
-8
lines changed
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 {
96
96
val YnoPatmatOpt = BooleanSetting (" -Yno-patmat-opt" , " disable all pattern matching optimizations." )
97
97
val YplainPrinter = BooleanSetting (" -Yplain-printer" , " Pretty-print using a plain printer." )
98
98
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." )
99
100
val YprintDebug = BooleanSetting (" -Yprint-debug" , " when printing trees, print some extra information useful for debugging." )
100
101
val YtestPickler = BooleanSetting (" -Ytest-pickler" , " self-test for pickling functionality; should be used with -Ystop-after:pickler" )
101
102
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) {
192
192
}
193
193
194
194
def blockText [T >: Untyped ](trees : List [Tree [T ]]): Text =
195
- (" {" ~ toText(trees, " \n " ) ~ " }" ).close
195
+ (" {" ~ toText(trees.filter(t => ! t.symbol.isPrivate) , " \n " ) ~ " }" ).close
196
196
197
197
override def toText [T >: Untyped ](tree : Tree [T ]): Text = controlled {
198
198
@@ -318,6 +318,8 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
318
318
case _ => false
319
319
}
320
320
params ::: rest
321
+ } else if (ctx.settings.YprintNoPrivate .value) {
322
+ impl.body.filter(t => ! t.symbol.isPrivate && ! t.symbol.is(Protected ))
321
323
} else impl.body
322
324
323
325
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 {
13
13
new TASTYDecompiler
14
14
}
15
15
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)
19
39
}
20
40
}
Original file line number Diff line number Diff line change @@ -36,8 +36,9 @@ mkdir out/scriptedtest2
36
36
37
37
# check that `dotp` runs
38
38
echo " 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
41
42
echo " output ok"
42
43
else
43
44
echo " failed output check"
Original file line number Diff line number Diff line change 30
30
31
31
# check that `sbt dotp` runs
32
32
echo " 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
35
36
echo " output ok"
36
37
else
37
38
echo " failed output check"
You can’t perform that action at this time.
0 commit comments