add wam_instructions/2 to render predicate instructions as lists of functors

This commit is contained in:
Mark Thom
2019-09-22 16:06:50 -06:00
parent 4cfab7aff8
commit 380aae85bd
12 changed files with 594 additions and 24 deletions

14
src/prolog/lib/diag.pl Normal file
View File

@@ -0,0 +1,14 @@
:- module(diag, [wam_instructions/2]).
:- use_module('src/prolog/lib/error').
wam_instructions(Clause, Listing) :-
( nonvar(Clause) ->
Clause = Name / Arity,
must_be(atom, Name),
must_be(integer, Arity),
( Arity >= 0 -> '$wam_instructions'(Name, Arity, Listing)
; throw(error(domain_error(not_less_than_zero, Arity), wam_instructions/2))
)
; throw(error(instantiation_error, wam_instructions/2))
).