Section "embedding"
We do not combine the head instruction stream with the body
instruction stream into one chunk. Instead, the host language
object for Prolog clauses had two array pointer fields. The host
language objects record further attributes to be able to assert or
execute. The embedding host language API then allow passing these
objects to the Dogelog player.
The host language routine make_special() yields an anonymous
built-in predicate from a func-tion pointer. Clauses or specials
can then be used as an argument to add() so that a named predicate
in the knowledge base results. Finally, we also provide a host
language object for Prolog goals, this can be used to execute
directives.
The cross-compiler and runtime generate the following calls:
- new Clause(S, H, B, R, K): host language
- The constructor creates an object representing a clause with
variable count S, head in-structions H, body instructions B, cut
variable index R and index key K.
- add(F, A, C): host language
- The function adds the clause or anonymous predicate C to the
knowledge base for the predicate indicator F/A.
- make_special(P): host language
- The function returns an anonymous predicate for the special P.
- new Goal(S, B): host language
- The constructor creates an object representing a goal with
variable count S, body in-structions B.
- run(G): host language
- The function executes the goal G, cuts away its choice points
and undoes its bindings. If the goal fails, it throws a new
error. If the goal throws an error, it re-throws this error. If
the goal succeeds, the built-in succeeds.