I wrote this pile of predicates to use when constructing my new checks.

%% dpl/1 Prints the names for a list of opcodes. dpl([T]) :- op_name(T,N), write(N), nl. dpl([H|T]) :- op_name(H,N), write(N), write(','), dpl(T). %% curcop/2 finds the closest COP node curcop(O, Cop) :- findall(C1, (op_preceding(O,C1), op_name(C1,nextstate)), C2), last(C2,Cop). last([H|T], O) :- T = [] -> O = H; last(T,O). %% Optree primitives op_name( O, N ) :- arg( 1, O, N ). op_flags( O, F ) :- arg( 2, O, F ). op_first( O, O2 ) :- arg( 3, O, O2 ). op_sibling( O, O2 ) :- arg( 4, O, O2 ). %% Some useful optree axes op_following_siblings( Op, Sibling ) :- op_sibling( Op, Sibling ). op_following_siblings( Op, Sibling ) :- op_sibling( Op, Temp ), op_following_siblings( Temp, Sibling ). op_child( Op, Child ) :- op_first( Op, Child ). op_child( Op, Child ) :- op_first( Op, Temp ), op_following_siblings( Temp, Child ). %% op_descendant/2 op_descendant( Op, Descendant ) :- op_child( Op, Descendant ). op_descendant( Op, Descendant ) :- op_child( Op, Temp ), op_descendant( Temp, Descendant ). %% op_descendant/3 op_descendant( Op, [Op], Descendant ) :- op_child( Op, Descendant ). op_descendant( Op, [Op|Rest], Descendant ) :- op_child( Op, Temp ), op_descendant( Temp, Rest, Descendant ). %% op_descendant_or_self/2 op_descendant_or_self( Op, Op ). op_descendant_or_self( Op, Descendant ) :- op_child( Op, Descendant ). op_descendant_or_self( Op, Descendant ) :- op_child( Op, Temp ), op_descendant_or_self( Temp, Descendant ). %% op_descendant_or_self/3 op_descendant_or_self( Op, [], Op ). op_descendant_or_self( Op, [Op], Descendant ) :- op_child( Op, Descendant ). op_descendant_or_self( Op, [Op|Rest], Descendant ) :- op_child( Op, Temp ), op_descendant_or_self( Temp, Rest, Descendant ). %% op_following/2 op_following( Op, Descendant ) :- op_descendant( Op, Descendant ). op_following( Op, Sibling ) :- op_sibling( Op, Sibling ). op_following( Op, SibDesc ) :- op_sibling( Op, Sibling ), op_following( Sibling, SibDesc ). %% op_following/3 op_following( Op, Middle, Descendant ) :- op_descendant( Op, Middle, Descendant ). op_following( Op, _, Sibling ) :- op_sibling( Op, Sibling ). op_following( Op, Middle, SibDesc ) :- op_sibling( Op, Sibling ), op_following( Sibling, Middle, SibDesc ). %% op_parent/2 op_parent( Op, Parent ) :- optree( Root ), op_descendant( Root, Parent ), op_child( Parent, Op ). %% op_ancestor/2 op_ancestor( Op, Root ) :- optree( Root ), op_descendant( Root, Op ). op_ancestor( Op, Ancestor ) :- optree( Root ), op_descendant( Root, Ancestor ), op_descendant( Ancestor, Op ). %% op_ancestor/3 op_ancestor( Op, Middle, Ancestor ) :- optree( Root ), op_descendant( Root, _, Ancestor), op_descendant( Ancestor, Middle, Op ). %% op_ancestor_or_self/2 op_ancestor_or_self( Op, Op ). op_ancestor_or_self( Op, Ancestor ) :- op_ancestor( Op, Ancestor ). %% TODO: op_ancestor_or_self/3 op_ancestor_or_self( Op, [], Op ). op_ancestor_or_self( Op, Middle, Ancestor ) :- op_ancestor( Op, Middle, Ancestor ). op_preceding_sibling(Op, Sibling) :- op_parent( Op, Parent ), op_child( Parent, Sibling ), op_following_siblings( Sibling, Op ). %% op_preceding/2 op_preceding( Op, Preceding ) :- optree( Root ), op_following( Root, Preceding ), op_folowing( Preceding, Op ). %% op_preceding/3 op_preceding( Op, Middle, Preceding ) :- optree( Root ), op_following( Root, _, Preceding ), op_folowing( Preceding, Middle, Op ).

⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊


In reply to Re: B::Concise -> Prolog by diotalevi
in thread B::Concise -> Prolog by diotalevi

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.