|
From: | Daniel Diaz |
Subject: | Re: pl2wam documentation |
Date: | Mon, 23 Nov 2015 09:37:47 +0100 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 |
Hi Rusell,
pl2wam is a sub-compiler used internally by gplc to compile a Prolog source to the WAM. There is no official documentation about pl2wam. However, its output is a Prolog source file (even if the suffix is .wam) containing facts for each compiled predicate (basically they contain Prolog lists of WAM instructions). Some information about these instructions can be found in the gprolog source code (download the .tar.gz) in the file: src/Pl2wam/wam_emit.pl in the header comment. I copy this documentation below. Finally, you can understand the output by compiling some Prolog source examples and studying the .wam produced. If you want to learn the WAM, you can turn off for some optimizations using command-line options, e.g. --no-inline, --no-reg-opt, ... (try pl2wam -h for a complete list of options). Don't hesitate to ask me any question. Daniel /*-------------------------------------------------------------------------* * WAM Instructions * * * * get_variable(V, A) put_variable(V, A) * * put_void(A) * * get_value(V, A) put_value(V, A) * * put_unsafe_value(y(Y), A) * * get_atom(F, A) put_atom(F, A) * * get_integer(N, A) put_integer(N, A) * * get_float(D, A) put_float(D, A) * * get_nil(A) put_nil(A) * * get_list(A) put_list(A) * * get_structure(F/N, A) put_structure(F/N, A) * * * * math_load_value(V, A) * * math_fast_load_value(V, A) * * * * unify_variable(V) allocate(N) * * unify_void(N) deallocate * * unify_value(V) * * unify_local_value(V) call(F/N) * * unify_atom(F) execute(F/N) * * unify_integer(N) proceed * * unify_nil fail * * unify_list (only for the last subterm if it is a list) * * unify_structure(F/N) (only for the last subterm if it is a structure) * * * * label(L) * * * * switch_on_term(Lvar, Latm, Lint, Llst, Lstc) * * switch_on_atom([(F,L),...]) * * switch_on_integer([(N,L),...]) * * switch_on_structure([(F/N,L),...]) * * * * try_me_else(L) try(L) * * retry_me_else(L) retry(L) * * trust_me_else_fail trust(L) * * * * get_current_choice(V) pragma_arity(N) (for cut) * * cut(V) * * soft_cut(V) * * * * call_c(F, [T,...], [W,...]) * * F=FctName, T=option only these options are relevant: * * - jump/boolean/x(X) (jump at / test / move returned value) * * - set_cp (set CP before the call at the next instruction) * * - fast_call (use a fact call convention) * * - tagged (use tagged calls for atoms, integers and F/N) * * * * foreign_call_c(F, T0, P/N, K, [(M1, T1),...]) * * F=FctName, T0=Return, P/N=BipName/BipArity, K=ChcSize * * Mi=mode (in/out/in_out), Ti=type * * V : x(X) or y(Y) * * X, Y : integer >= 0 * * A : integer * * D : float * * N, K : integer * * F, T, M: atom * * W : atom or integer or float or atom/integer or x(X) * * L : integer >= 1 (with no "holes") or 'fail' inside switch_on_term * *-------------------------------------------------------------------------*/ Le 22/11/2015 22:02, Russell Bentley a écrit :
|
[Prev in Thread] | Current Thread | [Next in Thread] |