modules More...
Go to the source code of this file.
Macros | |
#define | MAKE_PUBLIC 1 |
#define | MAKE_PRIVATE 2 |
#define | MAKE_FEATURE_PRIVATE 3 |
modules
RM: Jan 7 1993
This file implements a variation of the LIFE module system as specified by Dinesh Katiyar.
Definition in file modules.c.
long all_public_symbols | ( | ) |
all_public_symbols
ALL_PUBLIC_SYMBOLS Returns all public symbols from all modules or a specific module.
Definition at line 1363 of file modules.c.
References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, deref_ptr, first_definition, get_module(), get_two_args(), wl_definition::keyword, wl_keyword::module, wl_definition::next, NULL, wl_keyword::public, push_goal(), stack_cons(), stack_nil(), stack_psi_term(), TRUE, wl_psi_term::type, and unify.
long c_alias | ( | ) |
c_alias
C_ALIAS Alias one keyword to another.
Definition at line 1180 of file modules.c.
References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_keyword::combined_name, wl_keyword::definition, deref_ptr, Errorline(), FALSE, get_two_args(), hash_lookup(), wl_definition::keyword, wl_module::module_name, wl_keyword::symbol, wl_module::symbol_table, TRUE, wl_psi_term::type, and warningline().
long c_current_module | ( | ) |
c_current_module
C_CURRENT_MODULE Return the current module.
Definition at line 974 of file modules.c.
References wl_goal::aaaa_1, aim, wl_goal::bbbb_1, deref_ptr, heap_copy_string(), wl_module::module_name, NULL, push_goal(), quoted_string, resid_aim, stack_psi_term(), TRUE, wl_psi_term::type, unify, and wl_psi_term::value_3.
long c_display_modules | ( | ) |
c_display_modules
C_DISPLAY_MODULES(); Set the display modules switch.
Definition at line 739 of file modules.c.
References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, deref_ptr, display_modules, Errorline(), FALSE, get_two_args(), lf_false, lf_true, TRUE, and wl_psi_term::type.
long c_display_persistent | ( | ) |
c_display_persistent
C_DISPLAY_PERSISTENT(); Set the display persistent switch.
Definition at line 775 of file modules.c.
References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, deref_ptr, display_persistent, Errorline(), FALSE, get_two_args(), lf_false, lf_true, TRUE, and wl_psi_term::type.
long c_module_access | ( | ) |
c_module_access
C_MODULE_ACCESS Return the psi-term Module::Symbol
Definition at line 1008 of file modules.c.
References wl_goal::aaaa_1, aim, deref_ptr, FALSE, and warningline().
long c_open_module | ( | ) |
c_open_module
C_OPEN_MODULE() Open one or more modules, that is, alias all the public words in the current module to the definitions in the argument. An error message is printed for each module that is not successfully opened. If at least one module was not successfully opened, the routine fails.
Definition at line 519 of file modules.c.
References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, deref_ptr, Errorline(), FALSE, and open_module_tree().
long c_private | ( | ) |
c_private
C_PRIVATE() The argument is a single symbol or a list of symbols. Make them private in the current module if they belong to it.
Definition at line 714 of file modules.c.
References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, deref_ptr, Errorline(), FALSE, MAKE_PRIVATE, traverse_tree(), and TRUE.
long c_private_feature | ( | ) |
c_private_feature
C_PRIVATE_FEATURE() The argument is a single symbol or a list of symbols. Make this feature private to the current module.
Definition at line 1302 of file modules.c.
References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, deref_ptr, Errorline(), FALSE, MAKE_FEATURE_PRIVATE, traverse_tree(), and TRUE.
long c_public | ( | ) |
c_public
C_PUBLIC() The argument(s) are symbols. Make them public in the current module if they belong to it.
Definition at line 687 of file modules.c.
References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, deref_ptr, Errorline(), FALSE, MAKE_PUBLIC, traverse_tree(), and TRUE.
long c_replace | ( | ) |
c_replace
C_REPLACE() Replace all occurrences of type ARG1 with ARG2 in ARG3.
Definition at line 936 of file modules.c.
References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_node::data, deref_ptr, Errorline(), FALSE, FEATCMP, find(), get_two_args(), NULL, replace(), three, TRUE, and wl_psi_term::type.
long c_set_module | ( | ) |
c_set_module
C_SET_MODULE() This routine retrieves the necessary psi-term to determine the current state of the module mechanism from the heap.
Definition at line 488 of file modules.c.
References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, create_module(), deref_ptr, Errorline(), FALSE, get_two_args(), set_current_module(), string_val(), and TRUE.
long c_trace_input | ( | ) |
c_trace_input
C_TRACE_INPUT(); Set the trace_input switch.
Definition at line 810 of file modules.c.
References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, deref_ptr, Errorline(), FALSE, get_two_args(), lf_false, lf_true, trace_input, TRUE, and wl_psi_term::type.
ptr_module create_module | ( | char * | module | ) |
ptr_module create_module(char *module)
CREATE_MODULE(module) Create a new module.
Definition at line 72 of file modules.c.
References find_module(), hash_create(), HEAP_ALLOC, heap_copy_string(), heap_insert(), input_file_name, NULL, and STRCMP.
ptr_module extract_module_from_name | ( | char * | str | ) |
extract_module_from_name
str | - char *str |
EXTRACT_MODULE_FROM_NAME Return the module corresponding to "module#symbol". Return NULL if only "#symbol".
Definition at line 116 of file modules.c.
References create_module(), legal_in_name(), and NULL.
ptr_module find_module | ( | char * | module | ) |
find_module
module | char *module |
FIND_MODULE(module) Return a module if it exists.
Definition at line 54 of file modules.c.
References wl_node::data, FEATCMP, find(), and NULL.
int get_module | ( | ptr_psi_term | psi, |
ptr_module * | module | ||
) |
get_module
psi | - ptr_psi_term psi |
module | - ptr_module *module |
GET_MODULE(psi,module,resid) Convert a psi-term to a module. The psi-term must be a string.
Definition at line 1226 of file modules.c.
References deref_ptr, Errorline(), FALSE, find_module(), wl_definition::keyword, NULL, overlap_type(), quoted_string, wl_keyword::symbol, TRUE, wl_psi_term::type, and wl_psi_term::value_3.
int global_unify | ( | ptr_psi_term | u, |
ptr_psi_term | v | ||
) |
global_unify
u | - ptr_psi_term u |
v | - ptr_psi_term v |
GLOBAL_UNIFY(u,v) Unify two psi-terms, where it is known that V is on the heap (a persistent variable).
This routine really matches U and V, it will only succeed if V is more general than U. U will then be bound to V.
Definition at line 1053 of file modules.c.
References wl_psi_term::attr_list, c_abort(), wl_psi_term::coref, deref_ptr, Errorline(), FALSE, glb(), global_unify_attr(), heap_pointer, overlap_type(), push_psi_ptr_value(), quoted_string, REAL, real, release_resid(), wl_psi_term::resid, traceline(), TRUE, wl_psi_term::type, and wl_psi_term::value_3.
global_unify_attr
u | - ptr_node u |
v | - ptr_node v |
GLOBAL_UNIFY_ATTR(u,v) Unify the attributes of two terms, one on the heap, one on the stack. This is really matching, so all features of U must appear in V.
Definition at line 1135 of file modules.c.
References wl_node::data, dummy_printf(), FALSE, featcmp(), global_unify(), wl_node::key, wl_node::left, NULL, wl_node::right, and TRUE.
void init_modules | ( | ) |
init_modules
INIT_MODULES() Initialize the module system.
Definition at line 34 of file modules.c.
References create_module(), and set_current_module().
int make_feature_private | ( | ptr_psi_term | term | ) |
make_feature_private
term | - ptr_psi_term term |
MAKE_FEATURE_PRIVATE(feature) Make a feature private.
Definition at line 1256 of file modules.c.
References wl_keyword::combined_name, wl_keyword::definition, deref_ptr, hash_lookup(), wl_definition::keyword, wl_keyword::private_feature, wl_keyword::public, wl_keyword::symbol, wl_module::symbol_table, TRUE, wl_psi_term::type, update_symbol(), and warningline().
char* make_module_token | ( | ptr_module | module, |
char * | str | ||
) |
make_module_token
module | - ptr_module module |
str | - char *str |
MAKE_MODULE_TOKEN(module,string) Write 'module::string' in module_buffer. If string is a qualified reference to a given module, then modify the calling module variable to reflect this.
The result must be immediately stored in a newly allocated string.
Definition at line 191 of file modules.c.
References extract_module_from_name(), module_buffer, and wl_module::module_name.
long make_public | ( | ptr_psi_term | term, |
long | bool | ||
) |
make_public
term | - ptr_psi_term term |
bool | - long bool |
MAKE_PUBLIC(term,bool) Make a term public.
Definition at line 613 of file modules.c.
References wl_keyword::combined_name, wl_keyword::definition, deref_ptr, hash_lookup(), wl_definition::keyword, wl_keyword::module, new_definition(), wl_keyword::public, wl_keyword::symbol, wl_module::symbol_table, TRUE, wl_psi_term::type, update_symbol(), and warningline().
ptr_definition new_definition | ( | ptr_keyword | key | ) |
new_definition
key | - ptr_keyword key |
NEW_DEFINITION(key) Create a definition for a key.
Definition at line 220 of file modules.c.
References wl_definition::already_loaded, wl_definition::always_check, wl_definition::children, wl_definition::code, wl_definition::date, wl_keyword::definition, wl_definition::evaluate_args, FALSE, first_definition, wl_definition::global_value, HEAP_ALLOC, wl_definition::init_value, wl_definition::keyword, wl_definition::next, NOT_CODED, NULL, wl_definition::op_data, wl_definition::parents, wl_definition::properties, wl_definition::protected, wl_definition::rule, TRUE, wl_definition::type_def, and undef_it.
void open_module_one | ( | ptr_psi_term | t, |
int * | onefailed | ||
) |
open_module_one
t | = ptr_psi_term t |
onefailed | - int *onefailed |
Definition at line 562 of file modules.c.
References wl_keyword::combined_name, wl_keyword::definition, Errorline(), FALSE, find_module(), hash_lookup(), HEAP_ALLOC, wl_int_list::next, wl_module::open_modules, wl_keyword::public, string_val(), wl_keyword::symbol, wl_module::symbol_table, TRUE, and wl_int_list::value_1.
void open_module_tree | ( | ptr_node | n, |
int * | onefailed | ||
) |
open_module_tree
n | - ptr_node n |
onefailed | - int *onefailed |
Definition at line 542 of file modules.c.
References wl_node::data, wl_node::left, open_module_one(), and wl_node::right.
void pretty_quote_symbol | ( | ptr_keyword | k | ) |
pretty_quote_symbol
k | - ptr_keyword k |
PRETTY_QUOTE_SYMBOL(k) Prints the string to be used to display keyword K, with quotes if required.
Definition at line 470 of file modules.c.
References wl_keyword::definition, display_modules, wl_definition::keyword, wl_keyword::module, wl_module::module_name, prettyf(), prettyf_quote(), and wl_keyword::symbol.
void pretty_symbol | ( | ptr_keyword | k | ) |
pretty_symbol
k | - ptr_keyword k |
PRETTY_SYMBOL(k) Prints the string to be used to display keyword K.
Definition at line 452 of file modules.c.
References wl_keyword::definition, display_modules, wl_definition::keyword, wl_keyword::module, wl_module::module_name, prettyf(), and wl_keyword::symbol.
char* print_symbol | ( | ptr_keyword | k | ) |
print_symbol
OBSOLETE ptr_psi_term get_function_value(module,symbol)
ptr_module module; char *symbol;
{ ptr_node n; ptr_definition def; ptr_psi_term result=NULL; ptr_pair_list rule;
n=find(STRCMP,make_module_token(module,symbol),symbol_table); if(n) def=(ptr_definition)n->data; if(def && def->type==function) { rule=def->rule; while (rule && (!rule->aaaa_1 || !rule->bbbb_1)) rule=rule->next; if(rule) { result=(ptr_psi_term)rule->bbbb_1; deref_ptr(result); } } }
if(!result) Errorline("error in definition of '%s'\n",module_buffer);
return result; }
k | - ptr_keyword k |
PRINT_SYMBOL(k) Returns the string to be used to display keyword K.
Definition at line 435 of file modules.c.
References wl_keyword::combined_name, wl_keyword::definition, display_modules, wl_definition::keyword, and wl_keyword::symbol.
void rec_replace | ( | ptr_definition | old, |
ptr_definition | new, | ||
ptr_psi_term | term | ||
) |
rec_replace
old | - ptr_definition old |
new | - ptr_definition new |
term | - ptr_psi_term term |
Definition at line 865 of file modules.c.
References wl_psi_term::attr_list, def_ptr, deref_ptr, insert_translation(), int_ptr, NULL, push_ptr_value(), replace_attr(), translate(), wl_psi_term::type, and wl_psi_term::value_3.
void replace | ( | ptr_definition | old, |
ptr_definition | new, | ||
ptr_psi_term | term | ||
) |
replace
old | - ptr_definition old |
new | - ptr_definition new |
term | - ptr_psi_term term) |
REPLACE(old,new,term) Replace all occurrences of type OLD with NEW in TERM.
Definition at line 851 of file modules.c.
References clear_copy(), and rec_replace().
void replace_attr | ( | ptr_node | old_attr, |
ptr_psi_term | term, | ||
ptr_definition | old, | ||
ptr_definition | new | ||
) |
replace_attr
old_attr | - ptr_node old_attr |
term | - ptr_psi_term term |
old | - ptr_definition old |
new | - ptr_definition new |
Definition at line 898 of file modules.c.
References wl_psi_term::attr_list, wl_keyword::combined_name, wl_node::data, FEATCMP, wl_node::key, wl_definition::keyword, wl_node::left, wl_keyword::private_feature, rec_replace(), wl_node::right, stack_insert(), and wl_keyword::symbol.
ptr_module set_current_module | ( | ptr_module | module | ) |
set_current_module
module | - ptr_module module |
SET_CURRENT_MODULE(module) Set the current module to a given string.
Definition at line 100 of file modules.c.
References current_module.
char* string_val | ( | ptr_psi_term | term | ) |
string_val
term | - ptr_psi_term term |
STRING_VAL(term) Return a string defined by a term, that is: if term is a string, return the value, otherwise return the symbol for that term.
Definition at line 169 of file modules.c.
References deref_ptr, wl_definition::keyword, quoted_string, wl_keyword::symbol, wl_psi_term::type, and wl_psi_term::value_3.
char* strip_module_name | ( | char * | str | ) |
strip_module_name
str | - char *str |
STRIP_MODULE_NAME(symbol) Return the sub-string of symbol without the module prefix.
Definition at line 144 of file modules.c.
References legal_in_name().
void traverse_tree | ( | ptr_node | n, |
int | flag | ||
) |
traverse_tree
n | - ptr_node n |
flag | - int flag |
Do for all arguments, for the built-ins c_public, c_private, and c_private_feature.
Definition at line 656 of file modules.c.
References wl_node::data, deref_ptr, FALSE, wl_node::left, MAKE_FEATURE_PRIVATE, make_feature_private(), MAKE_PRIVATE, make_public(), MAKE_PUBLIC, wl_node::right, and TRUE.
ptr_definition update_feature | ( | ptr_module | module, |
char * | feature | ||
) |
update_feature
module | - ptr_module module |
feature | - char *feature |
UPDATE_FEATURE(module,feature) Look up a FEATURE. May return NULL if the FEATURE is not visible from MODULE.
Definition at line 1331 of file modules.c.
References current_module, wl_keyword::definition, extract_module_from_name(), hash_lookup(), NULL, wl_keyword::private_feature, wl_module::symbol_table, and update_symbol().
ptr_definition update_symbol | ( | ptr_module | module, |
char * | symbol | ||
) |
update_symbol
module | - ptr_module module |
symbol | - char *symbol |
UPDATE_SYMBOL(m,s) S is a string of characters encountered during parsing, M is the module it belongs too.
if M is NULL then extract the module name from S. If that fails then use the current module.
Then, retrieve the keyword for 'module::symbol'. Then find the correct definition by scanning the opened modules.
Definition at line 270 of file modules.c.
References wl_keyword::combined_name, current_module, wl_keyword::definition, error_psi_term, Errorline(), extract_module_from_name(), FALSE, hash_insert(), hash_lookup(), HEAP_ALLOC, heap_copy_string(), make_module_token(), wl_keyword::module, wl_module::module_name, new_definition(), wl_int_list::next, NULL, wl_module::open_modules, wl_keyword::private_feature, wl_keyword::public, strip_module_name(), wl_keyword::symbol, wl_module::symbol_table, wl_psi_term::type, wl_int_list::value_1, and warningline().
ptr_module bi_module =NULL |
ptr_module current_module =NULL |
ptr_module no_module =NULL |
ptr_module syntax_module =NULL |
ptr_module sys_module =NULL |
ptr_module user_module =NULL |
ptr_module x_module = NULL |