Graphviz code: nxdump.pal

From PROSE Programming Language - Wiki
Revision as of 09:51, 22 June 2018 by Cambridge (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% nxdump.pal
% Author: Mark R. Bannister
% Date: 17/Feb/2007
% Updated 31/Jan/2013 to accept one argument (start node)
% Modified 20/Apr/2017 for graphviz demo
%
% Creates the system function tools.nxdump() for dumping all nodes in nexus
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

~Module
EQUS {[sys.tools]}

._init
func/def	[nxdump], &[.dump], NULL, [psPointer], [start_node]
local/rtn

.dump
stack/lock
var/addr        PUSH, [start_node]
attr/addr       PUSH, PULL, [psPointer]
reg/jmpeq       &[.invalid], PEEK, NULL

% --------------------------------------------------
%obj/dump        PEEK
func/bcall      NULL, [tools.gv_add_node], PEEK
% --------------------------------------------------

reg/load        PUSH, (PULL)
reg/jmpeq       &[.rtn], PEEK, NULL

.loop
reg/load	P0, (PEEK)
reg/jmpeq	&[.loop_next], P0, NULL

% --------------------------------------------------
%obj/dump	P0
func/bcall      NULL, [tools.gv_add_node], P0
% --------------------------------------------------

reg/load	P1, (P0)
reg/jmpeq	&[.loop], P1, NULL

stack/push	P1
local/jmp	&[.loop]

.loop_next
reg/clr		PULL
reg/jmpne	&[.loop], PEEK, LOCK
stack/unlock

.rtn
func/rtn

.invalid
error/now       ![.prose.error.sys.BadAddress],
                    [Pointer argument contained invalid object address]