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
parent
b418b434fa
commit
f0834e7b36
|
@ -81,10 +81,3 @@ M: insn insn. tuple>array but-last [
|
||||||
: ssa. ( quot/word -- ) test-ssa cfgs. ;
|
: ssa. ( quot/word -- ) test-ssa cfgs. ;
|
||||||
: flat. ( quot/word -- ) test-flat cfgs. ;
|
: flat. ( quot/word -- ) test-flat cfgs. ;
|
||||||
: regs. ( quot/word -- ) test-regs 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 ;
|
|
||||||
|
|
|
@ -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
|
|
@ -20,7 +20,7 @@ HELP: height-state>insns
|
||||||
{ $examples
|
{ $examples
|
||||||
"In this example the datastacks height is increased by 4 and the retainstacks decreased by 2."
|
"In this example the datastacks height is increased by 4 and the retainstacks decreased by 2."
|
||||||
{ $example
|
{ $example
|
||||||
"USING: compiler.cfg.debugger compiler.cfg.stacks.local prettyprint ;"
|
"USING: compiler.cfg.stacks.local prettyprint ;"
|
||||||
"{ { 0 4 } { 0 -2 } } height-state>insns ."
|
"{ { 0 4 } { 0 -2 } } height-state>insns ."
|
||||||
"{ T{ ##inc { loc D: 4 } } T{ ##inc { loc R: -2 } } }"
|
"{ 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." }
|
{ $description "Translates an absolute stack location to one that is relative to the given height state." }
|
||||||
{ $examples
|
{ $examples
|
||||||
{ $example
|
{ $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: 7 { { 3 0 } { 0 0 } } translate-local-loc ."
|
||||||
"D: 4"
|
"D: 4"
|
||||||
}
|
}
|
||||||
|
|
|
@ -170,13 +170,11 @@ M: optimizing-compiler to-recompile ( -- words )
|
||||||
M: optimizing-compiler process-forgotten-words
|
M: optimizing-compiler process-forgotten-words
|
||||||
[ delete-compiled-xref ] each ;
|
[ delete-compiled-xref ] each ;
|
||||||
|
|
||||||
: with-optimizer ( quot -- )
|
|
||||||
[ optimizing-compiler compiler-impl ] dip with-variable ; inline
|
|
||||||
|
|
||||||
: enable-optimizer ( -- )
|
: enable-optimizer ( -- )
|
||||||
optimizing-compiler compiler-impl set-global ;
|
optimizing-compiler compiler-impl set-global ;
|
||||||
|
|
||||||
: disable-optimizer ( -- )
|
: disable-optimizer ( -- )
|
||||||
f compiler-impl set-global ;
|
f compiler-impl set-global ;
|
||||||
|
|
||||||
|
{ "prettyprint" "compiler" } "compiler.prettyprint" require-when
|
||||||
{ "threads" "compiler" } "compiler.threads" require-when
|
{ "threads" "compiler" } "compiler.threads" require-when
|
||||||
|
|
|
@ -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 ;
|
Loading…
Reference in New Issue