compiler.prettyprint: new vocab for prettyprinting compiler types

The require-when ensures that the prettyprint methods are loaded when
both the compiler and prettyprint is loaded.
char-rename
Björn Lindqvist 2016-08-13 16:36:57 +02:00
parent b418b434fa
commit f0834e7b36
5 changed files with 20 additions and 12 deletions

View File

@ -81,10 +81,3 @@ M: insn insn. tuple>array but-last [
: ssa. ( quot/word -- ) test-ssa cfgs. ;
: flat. ( quot/word -- ) test-flat cfgs. ;
: regs. ( quot/word -- ) test-regs cfgs. ;
! Prettyprinting
: pprint-loc ( loc word -- ) <block pprint-word n>> pprint* block> ;
M: ds-loc pprint* \ D: pprint-loc ;
M: rs-loc pprint* \ R: pprint-loc ;

View File

@ -0,0 +1,8 @@
USING: compiler.cfg.registers io.streams.string prettyprint tools.test ;
IN: compiler.cfg.registers.tests
! Ensure prettyprinting of ds/rs-loc is right
{ "D: 3\nR: -1\n" } [
[ D: 3 . R: -1 . ] with-string-writer
] unit-test

View File

@ -20,7 +20,7 @@ HELP: height-state>insns
{ $examples
"In this example the datastacks height is increased by 4 and the retainstacks decreased by 2."
{ $example
"USING: compiler.cfg.debugger compiler.cfg.stacks.local prettyprint ;"
"USING: compiler.cfg.stacks.local prettyprint ;"
"{ { 0 4 } { 0 -2 } } height-state>insns ."
"{ T{ ##inc { loc D: 4 } } T{ ##inc { loc R: -2 } } }"
}
@ -71,7 +71,7 @@ HELP: translate-local-loc
{ $description "Translates an absolute stack location to one that is relative to the given height state." }
{ $examples
{ $example
"USING: compiler.cfg.stacks.local compiler.cfg.registers compiler.cfg.debugger namespaces prettyprint ;"
"USING: compiler.cfg.stacks.local compiler.cfg.registers namespaces prettyprint ;"
"D: 7 { { 3 0 } { 0 0 } } translate-local-loc ."
"D: 4"
}

View File

@ -170,13 +170,11 @@ M: optimizing-compiler to-recompile ( -- words )
M: optimizing-compiler process-forgotten-words
[ delete-compiled-xref ] each ;
: with-optimizer ( quot -- )
[ optimizing-compiler compiler-impl ] dip with-variable ; inline
: enable-optimizer ( -- )
optimizing-compiler compiler-impl set-global ;
: disable-optimizer ( -- )
f compiler-impl set-global ;
{ "prettyprint" "compiler" } "compiler.prettyprint" require-when
{ "threads" "compiler" } "compiler.threads" require-when

View File

@ -0,0 +1,9 @@
USING: accessors compiler.cfg.registers prettyprint.backend
prettyprint.custom prettyprint.sections ;
IN: compiler.prettyprint
: pprint-loc ( loc word -- ) <block pprint-word n>> pprint* block> ;
M: ds-loc pprint* \ D: pprint-loc ;
M: rs-loc pprint* \ R: pprint-loc ;