prologgnu-prologwarren-abstract-machine

GNU Prolog: Displaying WAM code for query?


Is it possible to display the WAM code for a query using GNU Prolog?

I know I can use pl2wam to generate the WAM for the program, but what about the queries I perform on the program? Is there a way to show the WAM code for this?

I'm using version 1.4.4 for x64 Windows


Solution

  • Queries are not compiled to WAM code. They are meta-interpreted on the fly by the top-level (so no WAM code is produced). To see the WAM code which would be generated by the compiler create a file with a clause whose head contains all name variables of the query and the body corresponds to the query. For instance for the query:

    ?- append(X,Y,[a,b,c]).
    

    create a Prolog file containing

    query(X,Y) :- append(X,Y,[a,b,c]).
    

    and compile it to a WAM file to see the result.