Download ciao Reference Manual - pdf

Transcript
Chapter 79: Code translation utilities
349
79 Code translation utilities
Author(s): Angel Fernandez Pineda.
Version: 1.10#6 (2004/8/7, 21:46:39 CEST)
Version of last change: 1.7#40 (2001/1/5, 19:7:40 CET)
This library offers a general way to perform clause body expansions. Goal, fact and spec translation predicates are authomatically called when needed, while this utility navigates through the
meta-argument specification of the body itself. All predicates within this library must be called
at second-pass expansions, since it uses information stored at c_itf library.
79.1 Usage and interface (expansion_tools)
®
©
• Library usage:
This library is provided as a tool for those modules which performs source-to-source code
translation, usually known as code expanders. It may be loaded as other modules using a
use_module/1. Nothing special needs to be done.
• Exports:
− Predicates:
imports_meta_pred/3, body_expander/6, arg_expander/6.
• Other modules used:
− System library modules:
compiler/c_itf.
­
ª
79.2 Documentation on exports (expansion_tools)
imports meta pred/3:
PREDICATE
Macro provided in order to know meta-predicate specifications accessible from a module.
Usage: imports_meta_pred(Module, MetaSpec, AccessibleAt)
− Description: Tells whether MetaSpec meta-predicate specification is accessible from
Module. AccessibleAt will be binded to ’-’ whether meta-predicate is a builtin one.
If not, it will be unified with the module which defines the meta-predicate.
− The following properties should hold at call time:
Module is an atom.
(basic_props:atm/1)
MetaSpec is any term.
(basic_props:term/1)
AccessibleAt is a free variable.
(term_typing:var/1)
body expander/6:
PREDICATE
This predicate is the main translation tool. It navigates through a clause body, when a
single goal appears, user-code is called in order to perform a translation. Whether usercode fails to translate the involved goal, it remains the same. Regardless that goal is
translated or not, an argument expansion will be performed over all goals if applicable
(see arg_expander/6 predicate).
Variable (unknown at compile time) goals will also be attempt to translate.