The built-in Forth language decompiler can be used to recreate the source code for any previously-defined Forth word. The command:
ok see old-name
displays a listing of the source for old-name (without the source comments, of course).
A companion to see is (see) which is used to decompile the Forth word whose execution token is taken from the stack. For example:
ok ' old-name (see)
(see) produces a listing in a format identical to see.
ok see see : see ' ['] (see) catch if drop then ; ok see (see) defer (see) is : (f0018a44) 40 rmargin ! dup dup (f00189c4) dup (f0018944) (f0018980) (f0018658) ??cr ; ok f0018a44 (see) : (f0018a44) 40 rmargin ! dup dup (f00189c4) dup (f0018944) (f0018980) (f0018658) ??cr ;
The preceding listing shows that:
see itself is composed only of Forth source words that were compiled as external or as headers with fcode-debug? set to true.
(see) is a defer word. (see) also contains words that were compiled as headerless and are, consequently, displayed as hex addresses surrounded by parentheses.
Decompiling a word with(see) produces a listing identical to that produced by see.
For words implemented in Forth assembler language, see displays a Forth assembler listing. For example, decompiling dup displays:
ok see dup code dup f0008c98 sub %g7, 8, %g7 f0008c9c stx %g4, [%g0 + %g7] f0008ca0 ld [%g5], %l0 f0008ca4 jmp %l0, %g2, %g0 f0008ca8 add %g5, 4, %g5