Wild Life  2.29
 All Data Structures Files Functions Variables Typedefs Macros
Macros | Functions | Variables
modules.c File Reference

Go to the source code of this file.

Macros

#define MAKE_PUBLIC   1
 
#define MAKE_PRIVATE   2
 
#define MAKE_FEATURE_PRIVATE   3
 

Functions

void init_modules ()
 
ptr_module find_module (char *module)
 
ptr_module create_module (char *module)
 
ptr_module set_current_module (ptr_module module)
 
ptr_module extract_module_from_name (char *str)
 
char * strip_module_name (char *str)
 
char * string_val (ptr_psi_term term)
 
char * make_module_token (ptr_module module, char *str)
 
ptr_definition new_definition (ptr_keyword key)
 
ptr_definition update_symbol (ptr_module module, char *symbol)
 
char * print_symbol (ptr_keyword k)
 
void pretty_symbol (ptr_keyword k)
 
void pretty_quote_symbol (ptr_keyword k)
 
long c_set_module ()
 
long c_open_module ()
 
void open_module_tree (ptr_node n, int *onefailed)
 
void open_module_one (ptr_psi_term t, int *onefailed)
 
long make_public (ptr_psi_term term, long bool)
 
void traverse_tree (ptr_node n, int flag)
 
long c_public ()
 
long c_private ()
 
long c_display_modules ()
 
long c_display_persistent ()
 
long c_trace_input ()
 
void rec_replace (ptr_definition, ptr_definition, ptr_psi_term)
 
void replace_attr (ptr_node, ptr_psi_term, ptr_definition, ptr_definition)
 
void replace (ptr_definition old, ptr_definition new, ptr_psi_term term)
 
long c_replace ()
 
long c_current_module ()
 
long c_module_access ()
 
int global_unify_attr (ptr_node, ptr_node)
 
int global_unify (ptr_psi_term u, ptr_psi_term v)
 
long c_alias ()
 
int get_module (ptr_psi_term psi, ptr_module *module)
 
int make_feature_private (ptr_psi_term term)
 
long c_private_feature ()
 
ptr_definition update_feature (ptr_module module, char *feature)
 
long all_public_symbols ()
 

Variables

ptr_node module_table =NULL
 
ptr_module current_module =NULL
 
ptr_module no_module =NULL
 
ptr_module bi_module =NULL
 
ptr_module syntax_module =NULL
 
ptr_module sys_module =NULL
 
ptr_module user_module =NULL
 
ptr_module x_module = NULL
 
long display_modules =TRUE
 

Macro Definition Documentation

#define MAKE_FEATURE_PRIVATE   3

Definition at line 635 of file modules.c.

#define MAKE_PRIVATE   2

Definition at line 634 of file modules.c.

#define MAKE_PUBLIC   1

Definition at line 633 of file modules.c.

Function Documentation

long all_public_symbols ( )

Definition at line 1349 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.

1350 {
1351  ptr_psi_term arg1,arg2,funct,result;
1352  ptr_psi_term list;
1353  ptr_psi_term car;
1354  ptr_module module=NULL;
1355  ptr_definition d;
1356 
1357  funct=aim->aaaa_1;
1358  deref_ptr(funct);
1359  result=aim->bbbb_1;
1360  get_two_args(funct->attr_list,(ptr_psi_term *)&arg1,(ptr_psi_term *)&arg2);
1361 
1362  if(arg1) {
1363  deref_ptr(arg1);
1364  (void)get_module(arg1,&module);
1365  }
1366  else
1367  module=NULL;
1368 
1369  list=stack_nil();
1370 
1371  for(d=first_definition;d;d=d->next)
1372  if(d->keyword->public && (!module || d->keyword->module==module)) {
1373  car=stack_psi_term(4);
1374  car->type=d;
1375  list=stack_cons(car,list);
1376  }
1377 
1378  push_goal(unify,result,list,NULL);
1379 
1380  return TRUE;
1381 }
ptr_psi_term aaaa_1
Definition: def_struct.h:224
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
Definition: login.c:37
ptr_psi_term stack_cons(ptr_psi_term head, ptr_psi_term tail)
Definition: built_ins.c:47
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
Definition: login.c:555
ptr_keyword keyword
Definition: def_struct.h:124
#define NULL
Definition: def_const.h:203
ptr_definition next
Definition: def_struct.h:148
#define deref_ptr(P)
Definition: def_macro.h:95
#define TRUE
Definition: def_const.h:127
ptr_definition first_definition
Definition: def_glob.h:3
ptr_psi_term stack_psi_term(long stat)
Definition: lefun.c:15
ptr_psi_term stack_nil()
Definition: built_ins.c:29
ptr_goal aim
Definition: def_glob.h:49
#define unify
Definition: def_const.h:274
ptr_module module
Definition: def_struct.h:90
int public
Definition: def_struct.h:94
ptr_definition type
Definition: def_struct.h:165
int get_module(ptr_psi_term psi, ptr_module *module)
Definition: modules.c:1207
ptr_psi_term bbbb_1
Definition: def_struct.h:225
ptr_node attr_list
Definition: def_struct.h:171
long c_alias ( )

Definition at line 1164 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().

1165 {
1166  long success=TRUE;
1167  ptr_psi_term arg1,arg2,g;
1168  ptr_keyword key;
1169 
1170  g=aim->aaaa_1;
1171 
1172  deref_ptr(g);
1173  get_two_args(g->attr_list,(ptr_psi_term *)&arg1,(ptr_psi_term *)&arg2);
1174  if (arg1 && arg2) {
1175  deref_ptr(arg1);
1176  deref_ptr(arg2);
1177 
1179  if(key) {
1180  if(key->definition!=arg2->type) {
1181  warningline("alias: '%s' has now been overwritten by '%s'\n",
1182  key->combined_name,
1183  arg2->type->keyword->combined_name);
1184 
1185  key->definition=arg2->type;
1186  }
1187  }
1188  else
1189  Errorline("module violation: cannot alias '%s' from module \"%s\"\n",
1190  key->combined_name,
1192  }
1193  else {
1194  success=FALSE;
1195  Errorline("argument(s) missing in '%P'\n",g);
1196  }
1197 
1198  return success;
1199 }
ptr_psi_term aaaa_1
Definition: def_struct.h:224
ptr_keyword hash_lookup(ptr_hash_table table, char *symbol)
Definition: hash_table.c:133
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
Definition: login.c:37
char * combined_name
Definition: def_struct.h:92
ptr_definition definition
Definition: def_struct.h:96
ptr_hash_table symbol_table
Definition: def_struct.h:79
ptr_keyword keyword
Definition: def_struct.h:124
ptr_module current_module
Definition: modules.c:13
char * symbol
Definition: def_struct.h:91
void Errorline(char *format,...)
Definition: error.c:414
#define deref_ptr(P)
Definition: def_macro.h:95
#define TRUE
Definition: def_const.h:127
#define FALSE
Definition: def_const.h:128
ptr_goal aim
Definition: def_glob.h:49
char * module_name
Definition: def_struct.h:75
void warningline(char *format,...)
Definition: error.c:327
ptr_definition type
Definition: def_struct.h:165
ptr_node attr_list
Definition: def_struct.h:171
long c_current_module ( )

Definition at line 956 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.

958 {
959  long success=TRUE;
960  ptr_psi_term result,g,other;
961 
962 
963  g=aim->aaaa_1;
964  deref_ptr(g);
965  result=aim->bbbb_1;
966  deref_ptr(result);
967 
968 
969  other=stack_psi_term(4);
970  /* PVR 24.1.94 */
971  other->type=quoted_string;
973  /*
974  update_symbol(current_module,
975  current_module->module_name)
976  ->keyword->symbol
977  );
978 */ /* RM: 2/15/1994 */
979  /* other->type=update_symbol(current_module,current_module->module_name); */
980  resid_aim=NULL;
981  push_goal(unify,result,other,NULL);
982 
983  return success;
984 }
ptr_psi_term aaaa_1
Definition: def_struct.h:224
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
Definition: login.c:555
#define NULL
Definition: def_const.h:203
ptr_module current_module
Definition: modules.c:13
ptr_goal resid_aim
Definition: def_glob.h:220
char * heap_copy_string(char *s)
Definition: trees.c:147
#define deref_ptr(P)
Definition: def_macro.h:95
#define TRUE
Definition: def_const.h:127
ptr_definition quoted_string
Definition: def_glob.h:101
ptr_psi_term stack_psi_term(long stat)
Definition: lefun.c:15
GENERIC value_3
Definition: def_struct.h:170
ptr_goal aim
Definition: def_glob.h:49
char * module_name
Definition: def_struct.h:75
#define unify
Definition: def_const.h:274
ptr_definition type
Definition: def_struct.h:165
ptr_psi_term bbbb_1
Definition: def_struct.h:225
unsigned long * GENERIC
Definition: def_struct.h:17
long c_display_modules ( )

Definition at line 723 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.

725 {
726  ptr_psi_term arg1,arg2;
727  ptr_psi_term call;
728  int success=TRUE;
729 
730 
731  call=aim->aaaa_1;
732  deref_ptr(call);
733  get_two_args(call->attr_list,(ptr_psi_term *)&arg1,(ptr_psi_term *)&arg2);
734 
735  if(arg1) {
736  deref_ptr(arg1);
737  if(arg1->type==lf_true)
739  else
740  if(arg1->type==lf_false)
742  else {
743  Errorline("argument should be boolean in '%P'\n",call);
744  success=FALSE;
745  }
746  }
747  else /* No argument: toggle */
749 
750  return success;
751 }
ptr_psi_term aaaa_1
Definition: def_struct.h:224
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
Definition: login.c:37
long display_modules
Definition: modules.c:23
void Errorline(char *format,...)
Definition: error.c:414
#define deref_ptr(P)
Definition: def_macro.h:95
#define TRUE
Definition: def_const.h:127
ptr_definition lf_true
Definition: def_glob.h:107
#define FALSE
Definition: def_const.h:128
ptr_definition lf_false
Definition: def_glob.h:89
ptr_goal aim
Definition: def_glob.h:49
ptr_definition type
Definition: def_struct.h:165
ptr_node attr_list
Definition: def_struct.h:171
long c_display_persistent ( )

Definition at line 759 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.

761 {
762  ptr_psi_term arg1,arg2;
763  ptr_psi_term call;
764  int success=TRUE;
765 
766 
767  call=aim->aaaa_1;
768  deref_ptr(call);
769  get_two_args(call->attr_list,(ptr_psi_term *)&arg1,(ptr_psi_term *)&arg2);
770 
771  if(arg1) {
772  deref_ptr(arg1);
773  if(arg1->type==lf_true)
775  else
776  if(arg1->type==lf_false)
778  else {
779  Errorline("argument should be boolean in '%P'\n",call);
780  success=FALSE;
781  }
782  }
783  else /* No argument: toggle */
785 
786  return success;
787 }
ptr_psi_term aaaa_1
Definition: def_struct.h:224
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
Definition: login.c:37
long display_persistent
Definition: def_glob.h:165
void Errorline(char *format,...)
Definition: error.c:414
#define deref_ptr(P)
Definition: def_macro.h:95
#define TRUE
Definition: def_const.h:127
ptr_definition lf_true
Definition: def_glob.h:107
#define FALSE
Definition: def_const.h:128
ptr_definition lf_false
Definition: def_glob.h:89
ptr_goal aim
Definition: def_glob.h:49
ptr_definition type
Definition: def_struct.h:165
ptr_node attr_list
Definition: def_struct.h:171
long c_module_access ( )

Definition at line 993 of file modules.c.

References wl_goal::aaaa_1, aim, deref_ptr, FALSE, and warningline().

995 {
996  long success=FALSE;
997  // ptr_psi_term result,module,symbol,call,other;
998  ptr_psi_term call;
999 
1000 
1001  call=aim->aaaa_1;
1002  deref_ptr(call);
1003 
1004  /*
1005  result=aim->bbbb_1;
1006  deref_ptr(result);
1007  get_two_args(call,(ptr_psi_term *)&module,(ptr_psi_term *)&symbol);
1008 
1009  if(module && symbol) {
1010  other=stack_psi_term(4);
1011  other->type=update_symbol(module_access,module_access->module_name);
1012  resid_aim=NULL;
1013  push_goal(unify,result,other,NULL);
1014 
1015  }
1016  */
1017 
1018  warningline("%P not implemented yet...\n",call);
1019 
1020  return success;
1021 }
ptr_psi_term aaaa_1
Definition: def_struct.h:224
#define deref_ptr(P)
Definition: def_macro.h:95
#define FALSE
Definition: def_const.h:128
ptr_goal aim
Definition: def_glob.h:49
void warningline(char *format,...)
Definition: error.c:327
long c_open_module ( )

Definition at line 514 of file modules.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, deref_ptr, Errorline(), FALSE, and open_module_tree().

516 {
517  ptr_psi_term call;
518  int onefailed=FALSE;
519  call=aim->aaaa_1;
520  deref_ptr(call);
521  if (call->attr_list) {
522  open_module_tree(call->attr_list, &onefailed);
523  }
524  else {
525  Errorline("argument missing in '%P'\n",call);
526  }
527 
528  return !onefailed;
529 }
ptr_psi_term aaaa_1
Definition: def_struct.h:224
void open_module_tree(ptr_node n, int *onefailed)
Definition: modules.c:533
void Errorline(char *format,...)
Definition: error.c:414
#define deref_ptr(P)
Definition: def_macro.h:95
#define FALSE
Definition: def_const.h:128
ptr_goal aim
Definition: def_glob.h:49
ptr_node attr_list
Definition: def_struct.h:171
long c_private ( )

Definition at line 697 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.

699 {
700  // ptr_psi_term arg1,arg2;
701  ptr_psi_term call;
702  int success;
703 
704  call=aim->aaaa_1;
705  deref_ptr(call);
706  if (call->attr_list) {
708  success=TRUE;
709  } else {
710  Errorline("argument missing in '%P'\n",call);
711  success=FALSE;
712  }
713 
714  return success;
715 }
ptr_psi_term aaaa_1
Definition: def_struct.h:224
void traverse_tree(ptr_node n, int flag)
Definition: modules.c:640
void Errorline(char *format,...)
Definition: error.c:414
#define MAKE_PRIVATE
Definition: modules.c:634
#define deref_ptr(P)
Definition: def_macro.h:95
#define TRUE
Definition: def_const.h:127
#define FALSE
Definition: def_const.h:128
ptr_goal aim
Definition: def_glob.h:49
ptr_node attr_list
Definition: def_struct.h:171
long c_private_feature ( )

Definition at line 1288 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.

1290 {
1291  // ptr_psi_term arg1,arg2;
1292  ptr_psi_term call;
1293  int success;
1294 
1295  call=aim->aaaa_1;
1296  deref_ptr(call);
1297  if (call->attr_list) {
1299  success=TRUE;
1300  } else {
1301  Errorline("argument missing in '%P'\n",call);
1302  success=FALSE;
1303  }
1304 
1305  return success;
1306 }
ptr_psi_term aaaa_1
Definition: def_struct.h:224
void traverse_tree(ptr_node n, int flag)
Definition: modules.c:640
void Errorline(char *format,...)
Definition: error.c:414
#define deref_ptr(P)
Definition: def_macro.h:95
#define TRUE
Definition: def_const.h:127
#define FALSE
Definition: def_const.h:128
ptr_goal aim
Definition: def_glob.h:49
#define MAKE_FEATURE_PRIVATE
Definition: modules.c:635
ptr_node attr_list
Definition: def_struct.h:171
long c_public ( )

Definition at line 671 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.

673 {
674  // ptr_psi_term arg1,arg2;
675  ptr_psi_term call;
676  int success;
677 
678  call=aim->aaaa_1;
679  deref_ptr(call);
680  if (call->attr_list) {
682  success=TRUE;
683  } else {
684  Errorline("argument missing in '%P'\n",call);
685  success=FALSE;
686  }
687 
688  return success;
689 }
ptr_psi_term aaaa_1
Definition: def_struct.h:224
void traverse_tree(ptr_node n, int flag)
Definition: modules.c:640
void Errorline(char *format,...)
Definition: error.c:414
#define deref_ptr(P)
Definition: def_macro.h:95
#define TRUE
Definition: def_const.h:127
#define FALSE
Definition: def_const.h:128
ptr_goal aim
Definition: def_glob.h:49
#define MAKE_PUBLIC
Definition: modules.c:633
ptr_node attr_list
Definition: def_struct.h:171
long c_replace ( )

Definition at line 917 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.

919 {
920  ptr_psi_term arg1=NULL;
921  ptr_psi_term arg2=NULL;
922  ptr_psi_term arg3=NULL;
923  ptr_psi_term call;
924  int success=FALSE;
925  ptr_node n;
926 
927  call=aim->aaaa_1;
928  deref_ptr(call);
929 
930  get_two_args(call->attr_list,(ptr_psi_term *)&arg1,(ptr_psi_term *)&arg2);
931  n=find(FEATCMP,three,call->attr_list);
932  if (n)
933  arg3=(ptr_psi_term)n->data;
934 
935  if(arg1 && arg2 && arg3) {
936  deref_ptr(arg1);
937  deref_ptr(arg2);
938  deref_ptr(arg3);
939  replace(arg1->type,arg2->type,arg3);
940  success=TRUE;
941  }
942  else {
943  Errorline("argument missing in '%P'\n",call);
944  }
945 
946  return success;
947 }
ptr_psi_term aaaa_1
Definition: def_struct.h:224
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
Definition: login.c:37
#define FEATCMP
Definition: def_const.h:257
GENERIC data
Definition: def_struct.h:185
#define NULL
Definition: def_const.h:203
char * three
Definition: def_glob.h:252
void Errorline(char *format,...)
Definition: error.c:414
#define deref_ptr(P)
Definition: def_macro.h:95
#define TRUE
Definition: def_const.h:127
void replace(ptr_definition old, ptr_definition new, ptr_psi_term term)
Definition: modules.c:834
#define FALSE
Definition: def_const.h:128
ptr_goal aim
Definition: def_glob.h:49
ptr_node find(long comp, char *keystr, ptr_node tree)
Definition: trees.c:341
struct wl_psi_term * ptr_psi_term
Definition: def_struct.h:34
ptr_definition type
Definition: def_struct.h:165
ptr_node attr_list
Definition: def_struct.h:171
long c_set_module ( )

Definition at line 483 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.

485 {
486  ptr_psi_term arg1,arg2;
487  ptr_psi_term call;
488 
489  call=aim->aaaa_1;
490  deref_ptr(call);
491  get_two_args(call->attr_list,(ptr_psi_term *)&arg1,(ptr_psi_term *)&arg2);
492 
493  if(arg1) {
495  return TRUE;
496  }
497  else {
498  Errorline("argument missing in '%P'\n",call);
499  return FALSE;
500  }
501 }
ptr_psi_term aaaa_1
Definition: def_struct.h:224
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
Definition: login.c:37
void Errorline(char *format,...)
Definition: error.c:414
#define deref_ptr(P)
Definition: def_macro.h:95
#define TRUE
Definition: def_const.h:127
#define FALSE
Definition: def_const.h:128
ptr_goal aim
Definition: def_glob.h:49
ptr_module create_module(char *module)
Definition: modules.c:67
char * string_val(ptr_psi_term term)
Definition: modules.c:164
ptr_module set_current_module(ptr_module module)
Definition: modules.c:95
ptr_node attr_list
Definition: def_struct.h:171
long c_trace_input ( )

Definition at line 795 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.

797 {
798  ptr_psi_term arg1,arg2;
799  ptr_psi_term call;
800  int success=TRUE;
801 
802 
803  call=aim->aaaa_1;
804  deref_ptr(call);
805  get_two_args(call->attr_list,(ptr_psi_term *)&arg1,(ptr_psi_term *)&arg2);
806 
807  if(arg1) {
808  deref_ptr(arg1);
809  if(arg1->type==lf_true)
811  else
812  if(arg1->type==lf_false)
814  else {
815  Errorline("argument should be boolean in '%P'\n",call);
816  success=FALSE;
817  }
818  }
819  else /* No argument: toggle */
821 
822  return success;
823 }
ptr_psi_term aaaa_1
Definition: def_struct.h:224
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
Definition: login.c:37
long trace_input
Definition: def_glob.h:167
void Errorline(char *format,...)
Definition: error.c:414
#define deref_ptr(P)
Definition: def_macro.h:95
#define TRUE
Definition: def_const.h:127
ptr_definition lf_true
Definition: def_glob.h:107
#define FALSE
Definition: def_const.h:128
ptr_definition lf_false
Definition: def_glob.h:89
ptr_goal aim
Definition: def_glob.h:49
ptr_definition type
Definition: def_struct.h:165
ptr_node attr_list
Definition: def_struct.h:171
ptr_module create_module ( char *  module)

Definition at line 67 of file modules.c.

References find_module(), hash_create(), HEAP_ALLOC, heap_copy_string(), heap_insert(), input_file_name, NULL, and STRCMP.

70 {
71  ptr_module new;
72 
73 
74  new=find_module(module);
75  if(!new) {
76  new=HEAP_ALLOC(struct wl_module);
77  new->module_name=(char *)heap_copy_string(module);
78  new->source_file=(char *)heap_copy_string(input_file_name);
79  new->open_modules=NULL;
80  new->inherited_modules=NULL;
81  new->symbol_table=hash_create(16); /* RM: Feb 3 1993 */
82 
83  (void)heap_insert(STRCMP,new->module_name,&module_table,(GENERIC)new);
84 
85  }
86  return new;
87 }
ptr_node module_table
Definition: modules.c:12
string input_file_name
Definition: def_glob.h:40
ptr_hash_table hash_create(int size)
Definition: hash_table.c:26
#define NULL
Definition: def_const.h:203
ptr_node heap_insert(long comp, char *keystr, ptr_node *tree, GENERIC info)
Definition: trees.c:276
char * heap_copy_string(char *s)
Definition: trees.c:147
#define STRCMP
Definition: def_const.h:255
ptr_module find_module(char *module)
Definition: modules.c:48
unsigned long * GENERIC
Definition: def_struct.h:17
#define HEAP_ALLOC(A)
Definition: def_macro.h:15
ptr_module extract_module_from_name ( char *  str)

Definition at line 111 of file modules.c.

References create_module(), legal_in_name(), and NULL.

114 {
115  char *s;
116  ptr_module result=NULL;
117 
118  s=str;
119  while(legal_in_name(*s))
120  s++;
121  if(s!=str && *s=='#' /* && *(s+1)!=0 */) {
122  *s=0;
123  result=create_module(str);
124  *s='#';
125  /*
126  printf("Extracted module name '%s' from '%s'\n",result->module_name,str);
127  */
128  }
129 
130  return result;
131 }
long legal_in_name(long c)
Definition: token.c:861
#define NULL
Definition: def_const.h:203
ptr_module create_module(char *module)
Definition: modules.c:67
ptr_module find_module ( char *  module)

Definition at line 48 of file modules.c.

References wl_node::data, FEATCMP, find(), and NULL.

51 {
52  ptr_node nodule;
53 
54  nodule=find(FEATCMP,(char *)module,module_table);
55  if(nodule)
56  return (ptr_module)(nodule->data);
57  else
58  return NULL;
59 }
ptr_node module_table
Definition: modules.c:12
#define FEATCMP
Definition: def_const.h:257
GENERIC data
Definition: def_struct.h:185
#define NULL
Definition: def_const.h:203
ptr_node find(long comp, char *keystr, ptr_node tree)
Definition: trees.c:341
int get_module ( ptr_psi_term  psi,
ptr_module module 
)

Definition at line 1207 of file modules.c.

References deref_ptr, Errorline(), FALSE, find_module(), NULL, overlap_type(), quoted_string, and TRUE.

1211 {
1212  int success=TRUE;
1213  char *s;
1214 
1215  *module=NULL;
1216 
1217  deref_ptr(psi);
1218  if(overlap_type(psi->type,quoted_string) && psi->value_3)
1219  s=(char *)psi->value_3;
1220  else
1221  s=psi->type->keyword->symbol;
1222 
1223  *module=find_module(s);
1224  if(!(*module)) {
1225  Errorline("undefined module \"%s\"\n",s);
1226  success=FALSE;
1227  }
1228 
1229  return success;
1230 }
ptr_keyword keyword
Definition: def_struct.h:124
#define NULL
Definition: def_const.h:203
char * symbol
Definition: def_struct.h:91
long overlap_type(ptr_definition t1, ptr_definition t2)
Definition: types.c:1486
void Errorline(char *format,...)
Definition: error.c:414
#define deref_ptr(P)
Definition: def_macro.h:95
#define TRUE
Definition: def_const.h:127
#define FALSE
Definition: def_const.h:128
ptr_definition quoted_string
Definition: def_glob.h:101
GENERIC value_3
Definition: def_struct.h:170
ptr_module find_module(char *module)
Definition: modules.c:48
ptr_definition type
Definition: def_struct.h:165
int global_unify ( ptr_psi_term  u,
ptr_psi_term  v 
)

Definition at line 1035 of file modules.c.

References wl_psi_term::attr_list, c_abort(), deref_ptr, Errorline(), FALSE, glb(), global_unify_attr(), heap_pointer, overlap_type(), push_psi_ptr_value(), quoted_string, REAL, real, release_resid(), traceline(), TRUE, wl_psi_term::type, and wl_psi_term::value_3.

1039 {
1040  int success=TRUE;
1041  int compare;
1042  ptr_definition new_type;
1043  ptr_int_list new_code;
1044 
1045  deref_ptr(u);
1046  deref_ptr(v);
1047 
1048  traceline("match persistent %P with %P\n",u,v);
1049 
1050  /* printf("u=%ld, v=%ld, heap_pointer=%ld\n",u,v,heap_pointer);*/
1051 
1052  /* printf("u=%s, v=%s\n",
1053  u->type->keyword->symbol,
1054  v->type->keyword->symbol); */
1055 
1056  if((GENERIC)u>=heap_pointer) {
1057  Errorline("cannot unify persistent values\n");
1058  return c_abort();
1059  }
1060 
1061  /**** U is on the stack, V is on the heap ****/
1062 
1063  /**** Calculate their Greatest Lower Bound and compare them ****/
1064  compare=glb(u->type,v->type,&new_type,&new_code);
1065 
1066  /* printf("compare=%d\n",compare); */
1067 
1068  if (compare==1 || compare==3) { /* Match only */
1069 
1070  /**** Check for values ****/
1071  if(v->value_3) {
1072  if(u->value_3) {
1073  if(u->value_3!=v->value_3) { /* One never knows */
1074  if (overlap_type(v->type,real))
1075  success=(*((REAL *)u->value_3)==(*((REAL *)v->value_3)));
1076  else if (overlap_type(v->type,quoted_string))
1077  success=(strcmp((char *)u->value_3,(char *)v->value_3)==0);
1078  else
1079  return FALSE; /* Don't unify CUTs and STREAMs and things */
1080  }
1081  }
1082  }
1083  else
1084  if(u->value_3)
1085  return FALSE;
1086 
1087  if(success) {
1088  /**** Bind the two psi-terms ****/
1089  push_psi_ptr_value(u,(GENERIC *)&(u->coref));
1090  u->coref=v;
1091 
1092  /**** Match the attributes ****/
1093  success=global_unify_attr(u->attr_list,v->attr_list);
1094 
1095  /*
1096  if(!success)
1097  warningline("attributes don't unify in %P and %P\n",u,v);
1098  */
1099 
1100  if(success && u->resid)
1101  release_resid(u);
1102  }
1103  }
1104  else
1105  success=FALSE;
1106 
1107  return success;
1108 }
ptr_residuation resid
Definition: def_struct.h:173
long glb(ptr_definition t1, ptr_definition t2, ptr_definition *t3, ptr_int_list *c3)
Definition: types.c:1388
int global_unify_attr(ptr_node, ptr_node)
Definition: modules.c:1117
void push_psi_ptr_value(ptr_psi_term q, GENERIC *p)
Definition: login.c:443
long c_abort()
Definition: built_ins.c:2117
long overlap_type(ptr_definition t1, ptr_definition t2)
Definition: types.c:1486
#define REAL
Definition: def_const.h:72
void release_resid(ptr_psi_term t)
Definition: lefun.c:414
void traceline(char *format,...)
Definition: error.c:157
void Errorline(char *format,...)
Definition: error.c:414
ptr_definition real
Definition: def_glob.h:102
#define deref_ptr(P)
Definition: def_macro.h:95
#define TRUE
Definition: def_const.h:127
#define FALSE
Definition: def_const.h:128
ptr_definition quoted_string
Definition: def_glob.h:101
GENERIC value_3
Definition: def_struct.h:170
ptr_psi_term coref
Definition: def_struct.h:172
GENERIC heap_pointer
Definition: def_glob.h:12
ptr_definition type
Definition: def_struct.h:165
unsigned long * GENERIC
Definition: def_struct.h:17
ptr_node attr_list
Definition: def_struct.h:171
int global_unify_attr ( ptr_node  u,
ptr_node  v 
)

Definition at line 1117 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.

1121 {
1122  int success=TRUE;
1123  ptr_node temp;
1124  long cmp;
1125 
1126  if(u)
1127  if(v) {
1128  /* RM: Feb 16 1993 Avoid C optimiser bug */
1129  (void)dummy_printf("%s %s\n",u->key,v->key);
1130 
1131  cmp=featcmp(u->key,v->key);
1132  if(cmp<0) {
1133  temp=u->right;
1134  u->right=NULL;
1135  success=global_unify_attr(u,v->left) && global_unify_attr(temp,v);
1136  u->right=temp;
1137  }
1138  else
1139  if(cmp>0) {
1140  temp=u->left;
1141  u->left=NULL;
1142  success=global_unify_attr(u,v->right) && global_unify_attr(temp,v);
1143  u->left=temp;
1144  }
1145  else {
1146  success=
1147  global_unify_attr(u->left,v->left) &&
1148  global_unify_attr(u->right,v->right) &&
1150  }
1151  }
1152  else
1153  success=FALSE;
1154 
1155  return success;
1156 }
int global_unify_attr(ptr_node, ptr_node)
Definition: modules.c:1117
int global_unify(ptr_psi_term u, ptr_psi_term v)
Definition: modules.c:1035
GENERIC data
Definition: def_struct.h:185
#define NULL
Definition: def_const.h:203
ptr_node left
Definition: def_struct.h:183
char * key
Definition: def_struct.h:182
#define TRUE
Definition: def_const.h:127
#define FALSE
Definition: def_const.h:128
int dummy_printf(char *f, char *s, char *t)
Definition: login.c:2482
long featcmp(char *str1, char *str2)
Definition: trees.c:89
ptr_node right
Definition: def_struct.h:184
void init_modules ( )

Definition at line 30 of file modules.c.

References create_module(), and set_current_module().

31 {
32  bi_module=create_module("built_ins");
33  no_module=create_module("no_module");
35  syntax_module=create_module("syntax");
36  user_module=create_module("user"); /* RM: Jan 27 1993 */
38 
40 }
ptr_module user_module
Definition: modules.c:20
ptr_module sys_module
Definition: modules.c:17
ptr_module bi_module
Definition: modules.c:15
ptr_module create_module(char *module)
Definition: modules.c:67
ptr_module x_module
Definition: modules.c:21
ptr_module no_module
Definition: modules.c:14
ptr_module set_current_module(ptr_module module)
Definition: modules.c:95
ptr_module syntax_module
Definition: modules.c:16
int make_feature_private ( ptr_psi_term  term)

Definition at line 1239 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_module::symbol_table, TRUE, update_symbol(), and warningline().

1242 {
1243  int ok=TRUE;
1244  ptr_keyword key;
1245  ptr_definition def;
1246 
1247  deref_ptr(term);
1248 
1250 
1251  if(key) {
1252  /*
1253  if(key->definition->keyword->module!=current_module) {
1254  warningline("local definition of '%s' overrides '%s'\n",
1255  key->definition->keyword->symbol,
1256  key->definition->keyword->combined_name);
1257 
1258  new_definition(key);
1259  }
1260  */
1261 
1262  key->private_feature=TRUE;
1263  def=key->definition;
1264  }
1265  else {
1268  }
1269 
1270 
1271  if(ok && def->keyword->public) {
1272  warningline("feature '%s' is now private, but was also declared public\n",
1273  def->keyword->combined_name);
1274  }
1275 
1276  return ok;
1277 }
ptr_keyword hash_lookup(ptr_hash_table table, char *symbol)
Definition: hash_table.c:133
char * combined_name
Definition: def_struct.h:92
ptr_definition definition
Definition: def_struct.h:96
ptr_hash_table symbol_table
Definition: def_struct.h:79
ptr_keyword keyword
Definition: def_struct.h:124
ptr_module current_module
Definition: modules.c:13
char * symbol
Definition: def_struct.h:91
ptr_definition update_symbol(ptr_module module, char *symbol)
Definition: modules.c:264
#define deref_ptr(P)
Definition: def_macro.h:95
#define TRUE
Definition: def_const.h:127
int private_feature
Definition: def_struct.h:95
void warningline(char *format,...)
Definition: error.c:327
int public
Definition: def_struct.h:94
ptr_definition type
Definition: def_struct.h:165
char* make_module_token ( ptr_module  module,
char *  str 
)

Definition at line 185 of file modules.c.

References extract_module_from_name(), and module_buffer.

189 {
190  ptr_module explicit;
191 
192 
193  /* Check if the string already contains a module */
194  explicit=extract_module_from_name(str);
195  if(explicit)
196  strcpy(module_buffer,str);
197  else
198  if(module!=no_module) {
199  strcpy(module_buffer,module->module_name);
200  strcat(module_buffer,"#");
201  strcat(module_buffer,str);
202  }
203  else
204  strcpy(module_buffer,str);
205 
206  return module_buffer;
207 }
string module_buffer
Definition: def_glob.h:312
char * module_name
Definition: def_struct.h:75
ptr_module no_module
Definition: modules.c:14
ptr_module extract_module_from_name(char *str)
Definition: modules.c:111
long make_public ( ptr_psi_term  term,
long  bool 
)

Definition at line 600 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, update_symbol(), and warningline().

604 {
605  int ok=TRUE;
606  ptr_keyword key;
607  ptr_definition def;
608 
609  deref_ptr(term);
610 
612  if(key) {
613 
614  if(key->definition->keyword->module!=current_module && !bool) {
615  warningline("local definition of '%s' overrides '%s'\n",
616  key->definition->keyword->symbol,
618 
619  (void)new_definition(key);
620  }
621 
622  key->public=bool;
623  }
624  else {
626  def->keyword->public=bool;
627  }
628 
629  return ok;
630 }
ptr_keyword hash_lookup(ptr_hash_table table, char *symbol)
Definition: hash_table.c:133
char * combined_name
Definition: def_struct.h:92
ptr_definition new_definition(ptr_keyword key)
Definition: modules.c:215
ptr_definition definition
Definition: def_struct.h:96
ptr_hash_table symbol_table
Definition: def_struct.h:79
ptr_keyword keyword
Definition: def_struct.h:124
ptr_module current_module
Definition: modules.c:13
char * symbol
Definition: def_struct.h:91
ptr_definition update_symbol(ptr_module module, char *symbol)
Definition: modules.c:264
#define deref_ptr(P)
Definition: def_macro.h:95
#define TRUE
Definition: def_const.h:127
ptr_module module
Definition: def_struct.h:90
void warningline(char *format,...)
Definition: error.c:327
int public
Definition: def_struct.h:94
ptr_definition type
Definition: def_struct.h:165
ptr_definition new_definition ( ptr_keyword  key)

Definition at line 215 of file modules.c.

References wl_definition::already_loaded, wl_definition::always_check, wl_definition::children, wl_definition::code, wl_definition::date, 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.

218 {
219  ptr_definition result;
220 
221 
222  /* printf("*** New definition: %s\n",key->combined_name); */
223 
224  /* Create a new definition */
225  result=HEAP_ALLOC(struct wl_definition);
226 
227  /* RM: Feb 3 1993 */
228  result->next=first_definition; /* Linked list of all definitions */
229  first_definition=result;
230 
231  result->keyword=key;
232  result->rule=NULL;
233  result->properties=NULL;
234  result->date=0;
235  result->type_def=(def_type)undef;
236  result->always_check=TRUE;
237  result->protected=TRUE;
238  result->evaluate_args=TRUE;
239  result->already_loaded=FALSE;
240  result->children=NULL;
241  result->parents=NULL;
242  result->code=NOT_CODED;
243  result->op_data=NULL;
244  result->global_value=NULL; /* RM: Feb 8 1993 */
245  result->init_value=NULL; /* RM: Mar 23 1993 */
246  key->definition=result;
247 
248  return result;
249 }
char already_loaded
Definition: def_struct.h:137
ptr_psi_term init_value
Definition: def_struct.h:142
struct wl_definition * def_type
Definition: def_struct.h:32
char evaluate_args
Definition: def_struct.h:136
#define NOT_CODED
Definition: def_const.h:134
#define undef
Definition: def_const.h:360
ptr_definition definition
Definition: def_struct.h:96
def_type type_def
Definition: def_struct.h:133
ptr_keyword keyword
Definition: def_struct.h:124
#define NULL
Definition: def_const.h:203
char always_check
Definition: def_struct.h:134
ptr_definition next
Definition: def_struct.h:148
#define TRUE
Definition: def_const.h:127
ptr_definition first_definition
Definition: def_glob.h:3
ptr_pair_list rule
Definition: def_struct.h:126
ptr_psi_term global_value
Definition: def_struct.h:141
#define FALSE
Definition: def_const.h:128
ptr_int_list code
Definition: def_struct.h:129
ptr_triple_list properties
Definition: def_struct.h:127
ptr_int_list children
Definition: def_struct.h:131
#define HEAP_ALLOC(A)
Definition: def_macro.h:15
ptr_operator_data op_data
Definition: def_struct.h:139
ptr_int_list parents
Definition: def_struct.h:130
void open_module_one ( ptr_psi_term  t,
int *  onefailed 
)

Definition at line 550 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.

553 {
554  ptr_module open_module;
555  ptr_int_list opens;
556  ptr_keyword key1,key2;
557  int i;
558  int found=FALSE;
559 
560  open_module=find_module(string_val(t));
561  if (open_module) {
562 
563  for (opens=current_module->open_modules;opens;opens=opens->next)
564  if (opens->value_1 == (GENERIC)open_module) {
565  /* warningline("module \"%s\" is already open\n",
566  open_module->module_name); */ /* RM: Jan 27 1993 */
567  found=TRUE;
568  }
569 
570  if (!found) {
571  opens=HEAP_ALLOC(struct wl_int_list);
572  opens->value_1=(GENERIC)open_module;
575 
576  /* Check for name conflicts */
577  /* RM: Feb 23 1993 */
578  for (i=0;i<open_module->symbol_table->size;i++)
579  if ((key1=open_module->symbol_table->data[i]) && key1->public) {
581  if (key2 && key1->definition!=key2->definition)
582  Errorline("symbol clash '%s' and '%s'\n",
583  key1->combined_name,
584  key2->combined_name);
585  }
586  }
587  }
588  else {
589  Errorline("module \"%s\" not found\n",string_val(t));
590  *onefailed=TRUE;
591  }
592 }
ptr_keyword hash_lookup(ptr_hash_table table, char *symbol)
Definition: hash_table.c:133
char * combined_name
Definition: def_struct.h:92
ptr_definition definition
Definition: def_struct.h:96
ptr_hash_table symbol_table
Definition: def_struct.h:79
ptr_module current_module
Definition: modules.c:13
char * symbol
Definition: def_struct.h:91
void Errorline(char *format,...)
Definition: error.c:414
#define TRUE
Definition: def_const.h:127
#define FALSE
Definition: def_const.h:128
ptr_int_list open_modules
Definition: def_struct.h:77
char * string_val(ptr_psi_term term)
Definition: modules.c:164
ptr_module find_module(char *module)
Definition: modules.c:48
int public
Definition: def_struct.h:94
GENERIC value_1
Definition: def_struct.h:54
unsigned long * GENERIC
Definition: def_struct.h:17
#define HEAP_ALLOC(A)
Definition: def_macro.h:15
ptr_int_list next
Definition: def_struct.h:55
void open_module_tree ( ptr_node  n,
int *  onefailed 
)

Definition at line 533 of file modules.c.

References open_module_one().

536 {
537  if (n) {
538  ptr_psi_term t;
539  open_module_tree(n->left,onefailed);
540 
541  t=(ptr_psi_term)n->data;
542  open_module_one(t,onefailed);
543 
544  open_module_tree(n->right,onefailed);
545  }
546 }
void open_module_tree(ptr_node n, int *onefailed)
Definition: modules.c:533
GENERIC data
Definition: def_struct.h:185
void open_module_one(ptr_psi_term t, int *onefailed)
Definition: modules.c:550
ptr_node left
Definition: def_struct.h:183
struct wl_psi_term * ptr_psi_term
Definition: def_struct.h:34
ptr_node right
Definition: def_struct.h:184
void pretty_quote_symbol ( ptr_keyword  k)

Definition at line 464 of file modules.c.

References wl_keyword::definition, display_modules, wl_definition::keyword, prettyf(), and prettyf_quote().

467 {
468  k=k->definition->keyword;
469  if(display_modules) {
471  prettyf("#");
472  }
473  prettyf_quote(k->symbol);
474 }
long display_modules
Definition: modules.c:23
ptr_definition definition
Definition: def_struct.h:96
ptr_keyword keyword
Definition: def_struct.h:124
char * symbol
Definition: def_struct.h:91
char * module_name
Definition: def_struct.h:75
ptr_module module
Definition: def_struct.h:90
void prettyf(char *s)
Definition: print.c:447
void prettyf_quote(char *s)
Definition: print.c:474
void pretty_symbol ( ptr_keyword  k)

Definition at line 446 of file modules.c.

References wl_keyword::definition, display_modules, wl_definition::keyword, and prettyf().

449 {
450  k=k->definition->keyword;
451  if(display_modules) {
453  prettyf("#");
454  }
455  prettyf(k->symbol);
456 }
long display_modules
Definition: modules.c:23
ptr_definition definition
Definition: def_struct.h:96
ptr_keyword keyword
Definition: def_struct.h:124
char * symbol
Definition: def_struct.h:91
char * module_name
Definition: def_struct.h:75
ptr_module module
Definition: def_struct.h:90
void prettyf(char *s)
Definition: print.c:447
char* print_symbol ( ptr_keyword  k)

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; }

Definition at line 429 of file modules.c.

References wl_keyword::combined_name, wl_keyword::definition, display_modules, and wl_definition::keyword.

433 {
434  k=k->definition->keyword;
435  if(display_modules)
436  return k->combined_name;
437  else
438  return k->symbol;
439 }
long display_modules
Definition: modules.c:23
char * combined_name
Definition: def_struct.h:92
ptr_definition definition
Definition: def_struct.h:96
ptr_keyword keyword
Definition: def_struct.h:124
char * symbol
Definition: def_struct.h:91
void rec_replace ( ptr_definition  old,
ptr_definition  new,
ptr_psi_term  term 
)

Definition at line 846 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.

851 {
852  ptr_psi_term done;
853  long *info; // some trouble w this - don't see
854  ptr_node old_attr;
855 
856  deref_ptr(term);
857  done=translate(term,&info);
858  if(!done) {
859  insert_translation(term,term,0);
860 
861  if(term->type==old && !term->value_3) {
862  push_ptr_value(def_ptr,(GENERIC *)&(term->type));
863  term->type=new;
864  }
865  old_attr=term->attr_list;
866  if(old_attr) {
868  term->attr_list=NULL;
869  replace_attr(old_attr,term,old,new);
870  }
871  }
872 }
ptr_psi_term translate(ptr_psi_term a, long **infoptr)
Definition: copy.c:101
void push_ptr_value(type_ptr t, GENERIC *p)
Definition: login.c:360
#define def_ptr
Definition: def_const.h:173
void replace_attr(ptr_node, ptr_psi_term, ptr_definition, ptr_definition)
Definition: modules.c:875
void insert_translation(ptr_psi_term a, ptr_psi_term b, long info)
Definition: copy.c:63
#define NULL
Definition: def_const.h:203
#define deref_ptr(P)
Definition: def_macro.h:95
GENERIC value_3
Definition: def_struct.h:170
ptr_definition type
Definition: def_struct.h:165
unsigned long * GENERIC
Definition: def_struct.h:17
ptr_node attr_list
Definition: def_struct.h:171
#define int_ptr
Definition: def_const.h:172
void replace ( ptr_definition  old,
ptr_definition  new,
ptr_psi_term  term 
)

Definition at line 834 of file modules.c.

References clear_copy(), and rec_replace().

839 {
840  clear_copy();
841  rec_replace(old,new,term);
842 }
void clear_copy()
Definition: copy.c:52
void rec_replace(ptr_definition, ptr_definition, ptr_psi_term)
Definition: modules.c:846
void replace_attr ( ptr_node  old_attr,
ptr_psi_term  term,
ptr_definition  old,
ptr_definition  new 
)

Definition at line 875 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.

881 {
882  ptr_psi_term value;
883  char *oldlabel; /* RM: Mar 12 1993 */
884  char *newlabel;
885 
886  if(old_attr->left)
887  replace_attr(old_attr->left,term,old,new);
888 
889  value=(ptr_psi_term)old_attr->data;
890  rec_replace(old,new,value);
891 
892  if(old->keyword->private_feature) /* RM: Mar 12 1993 */
893  oldlabel=old->keyword->combined_name;
894  else
895  oldlabel=old->keyword->symbol;
896 
897  if(new->keyword->private_feature) /* RM: Mar 12 1993 */
898  newlabel=new->keyword->combined_name;
899  else
900  newlabel=new->keyword->symbol;
901 
902  if(!strcmp(old_attr->key,oldlabel))
903  (void)stack_insert(FEATCMP,newlabel,&(term->attr_list),(GENERIC)value);
904  else
905  (void)stack_insert(FEATCMP,old_attr->key,&(term->attr_list),(GENERIC)value);
906 
907  if(old_attr->right)
908  replace_attr(old_attr->right,term,old,new);
909 }
#define FEATCMP
Definition: def_const.h:257
char * combined_name
Definition: def_struct.h:92
void replace_attr(ptr_node, ptr_psi_term, ptr_definition, ptr_definition)
Definition: modules.c:875
ptr_keyword keyword
Definition: def_struct.h:124
GENERIC data
Definition: def_struct.h:185
char * symbol
Definition: def_struct.h:91
ptr_node left
Definition: def_struct.h:183
ptr_node stack_insert(long comp, char *keystr, ptr_node *tree, GENERIC info)
Definition: trees.c:291
char * key
Definition: def_struct.h:182
void rec_replace(ptr_definition, ptr_definition, ptr_psi_term)
Definition: modules.c:846
struct wl_psi_term * ptr_psi_term
Definition: def_struct.h:34
int private_feature
Definition: def_struct.h:95
unsigned long * GENERIC
Definition: def_struct.h:17
ptr_node attr_list
Definition: def_struct.h:171
ptr_node right
Definition: def_struct.h:184
ptr_module set_current_module ( ptr_module  module)

Definition at line 95 of file modules.c.

References current_module.

98 {
99  current_module=module;
100  /* printf("*** Current module: '%s'\n",current_module->module_name); */
101  return current_module;
102 }
ptr_module current_module
Definition: modules.c:13
char* string_val ( ptr_psi_term  term)

Definition at line 164 of file modules.c.

References deref_ptr, and quoted_string.

167 {
168  deref_ptr(term);
169  if(term->value_3 && term->type==quoted_string)
170  return (char *)term->value_3;
171  else
172  return term->type->keyword->symbol;
173 }
ptr_keyword keyword
Definition: def_struct.h:124
char * symbol
Definition: def_struct.h:91
#define deref_ptr(P)
Definition: def_macro.h:95
ptr_definition quoted_string
Definition: def_glob.h:101
GENERIC value_3
Definition: def_struct.h:170
ptr_definition type
Definition: def_struct.h:165
char* strip_module_name ( char *  str)

Definition at line 139 of file modules.c.

References legal_in_name().

142 {
143  char *s=str;
144 
145  while(legal_in_name(*s))
146  s++;
147  if(s!=str && *s=='#' /* && *(s+1)!=0 */) {
148  s++;
149  /* printf("Stripped module from '%s' yielding '%s'\n",str,s); */
150  return s;
151  }
152  else
153  return str;
154 }
long legal_in_name(long c)
Definition: token.c:861
void traverse_tree ( ptr_node  n,
int  flag 
)

Definition at line 640 of file modules.c.

References deref_ptr, FALSE, MAKE_FEATURE_PRIVATE, make_feature_private(), MAKE_PRIVATE, make_public(), MAKE_PUBLIC, and TRUE.

643 {
644  if (n) {
645  ptr_psi_term t;
646  traverse_tree(n->left,flag);
647 
648  t=(ptr_psi_term)n->data;
649  deref_ptr(t);
650  switch (flag) {
651  case MAKE_PUBLIC:
652  (void)make_public(t,TRUE);
653  break;
654  case MAKE_PRIVATE:
655  (void)make_public(t,FALSE);
656  break;
658  (void)make_feature_private(t);
659  break;
660  }
661  traverse_tree(n->right,flag);
662  }
663 }
void traverse_tree(ptr_node n, int flag)
Definition: modules.c:640
GENERIC data
Definition: def_struct.h:185
ptr_node left
Definition: def_struct.h:183
#define MAKE_PRIVATE
Definition: modules.c:634
#define deref_ptr(P)
Definition: def_macro.h:95
#define TRUE
Definition: def_const.h:127
#define FALSE
Definition: def_const.h:128
int make_feature_private(ptr_psi_term term)
Definition: modules.c:1239
long make_public(ptr_psi_term term, long bool)
Definition: modules.c:600
struct wl_psi_term * ptr_psi_term
Definition: def_struct.h:34
#define MAKE_FEATURE_PRIVATE
Definition: modules.c:635
#define MAKE_PUBLIC
Definition: modules.c:633
ptr_node right
Definition: def_struct.h:184
ptr_definition update_feature ( ptr_module  module,
char *  feature 
)

Definition at line 1315 of file modules.c.

References current_module, wl_keyword::definition, extract_module_from_name(), hash_lookup(), NULL, wl_keyword::private_feature, and update_symbol().

1319 {
1320  ptr_keyword key;
1321  ptr_module explicit;
1322 
1323  /* Check if the feature already contains a module name */
1324 
1325  if(!module)
1326  module=current_module;
1327 
1328  explicit=extract_module_from_name(feature);
1329  if(explicit)
1330  if(explicit!=module)
1331  return NULL; /* Feature isn't visible */
1332  else
1333  return update_symbol(NULL,feature);
1334 
1335  /* Now we have a simple feature to look up */
1336  key=hash_lookup(module->symbol_table,feature);
1337  if(key && key->private_feature)
1338  return key->definition;
1339  else
1340  return update_symbol(module,feature);
1341 }
ptr_keyword hash_lookup(ptr_hash_table table, char *symbol)
Definition: hash_table.c:133
ptr_definition definition
Definition: def_struct.h:96
ptr_hash_table symbol_table
Definition: def_struct.h:79
#define NULL
Definition: def_const.h:203
ptr_module current_module
Definition: modules.c:13
ptr_definition update_symbol(ptr_module module, char *symbol)
Definition: modules.c:264
int private_feature
Definition: def_struct.h:95
ptr_module extract_module_from_name(char *str)
Definition: modules.c:111
ptr_definition update_symbol ( ptr_module  module,
char *  symbol 
)

Definition at line 264 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, new_definition(), wl_int_list::next, NULL, 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().

267 {
268  ptr_keyword key;
269  ptr_definition result=NULL;
270  ptr_int_list opens;
271  ptr_module opened;
272  ptr_keyword openkey;
273  ptr_keyword tempkey;
274 
275  /* First clean up the arguments and find out which module to use */
276 
277  if(!module) {
278  module=extract_module_from_name(symbol);
279  if(!module)
280  module=current_module;
281  symbol=strip_module_name(symbol);
282  }
283 
284  /* printf("looking up %s#%s\n",module->module_name,symbol); */
285 
286  /* Now look up 'module#symbol' in the symbol table */
287  key=hash_lookup(module->symbol_table,symbol);
288 
289  if(key)
290  if(key->public || module==current_module)
291  result=key->definition;
292  else {
293  Errorline("qualified call to private symbol '%s'\n",
294  key->combined_name);
295 
296  result=error_psi_term->type;
297  }
298  else
299  if(module!=current_module) {
300  Errorline("qualified call to undefined symbol '%s#%s'\n",
301  module->module_name,symbol);
302  result=error_psi_term->type;
303  }
304  else
305  {
306  /* Add 'module#symbol' to the symbol table */
307  key=HEAP_ALLOC(struct wl_keyword);
308  key->module=module;
309  key->symbol=(char *)heap_copy_string(symbol);
310  key->combined_name=heap_copy_string(make_module_token(module,symbol));
311  key->public=FALSE;
312  key->private_feature=FALSE; /* RM: Mar 11 1993 */
313  key->definition=NULL;
314 
315  hash_insert(module->symbol_table,key->symbol,key);
316 
317 
318  /* Search the open modules of 'module' for 'symbol' */
319  opens=module->open_modules;
320  openkey=NULL;
321  while(opens) {
322  opened=(ptr_module)(opens->value_1);
323  if(opened!=module) {
324 
325  tempkey=hash_lookup(opened->symbol_table,symbol);
326 
327  if(tempkey)
328  if(openkey && openkey->public && tempkey->public) {
329  if(openkey->definition==tempkey->definition) {
330  warningline("benign module name clash: %s and %s\n",
331  openkey->combined_name,
332  tempkey->combined_name);
333  }
334  else {
335  Errorline("serious module name clash: \"%s\" and \"%s\"\n",
336  openkey->combined_name,
337  tempkey->combined_name);
338 
339  result=error_psi_term->type;
340  }
341  }
342  else
343  if(!openkey || !openkey->public)
344  openkey=tempkey;
345  }
346 
347  opens=opens->next;
348  }
349 
350  if(!result) { /* RM: Feb 1 1993 */
351 
352  if(openkey && openkey->public) {
353  /* Found the symbol in an open module */
354 
355  if(!openkey->public)
356  warningline("implicit reference to non-public symbol: %s\n",
357  openkey->combined_name);
358 
359  result=openkey->definition;
360  key->definition=result;
361 
362  /*
363  printf("*** Aliasing %s#%s to %s#%s\n",
364  key->module->module_name,
365  key->symbol,
366  openkey->module->module_name,
367  openkey->symbol);
368  */
369 
370  }
371  else { /* Didn't find it */
372  result=new_definition(key);
373  }
374  }
375  }
376 
377  return result;
378 }
ptr_keyword hash_lookup(ptr_hash_table table, char *symbol)
Definition: hash_table.c:133
char * combined_name
Definition: def_struct.h:92
ptr_definition new_definition(ptr_keyword key)
Definition: modules.c:215
ptr_definition definition
Definition: def_struct.h:96
ptr_hash_table symbol_table
Definition: def_struct.h:79
#define NULL
Definition: def_const.h:203
ptr_module current_module
Definition: modules.c:13
char * symbol
Definition: def_struct.h:91
char * strip_module_name(char *str)
Definition: modules.c:139
struct wl_module * ptr_module
Definition: def_struct.h:83
void Errorline(char *format,...)
Definition: error.c:414
char * heap_copy_string(char *s)
Definition: trees.c:147
void hash_insert(ptr_hash_table table, char *symbol, ptr_keyword keyword)
Definition: hash_table.c:155
ptr_psi_term error_psi_term
Definition: def_glob.h:23
#define FALSE
Definition: def_const.h:128
char * module_name
Definition: def_struct.h:75
ptr_int_list open_modules
Definition: def_struct.h:77
ptr_module module
Definition: def_struct.h:90
int private_feature
Definition: def_struct.h:95
ptr_module extract_module_from_name(char *str)
Definition: modules.c:111
void warningline(char *format,...)
Definition: error.c:327
int public
Definition: def_struct.h:94
ptr_definition type
Definition: def_struct.h:165
GENERIC value_1
Definition: def_struct.h:54
#define HEAP_ALLOC(A)
Definition: def_macro.h:15
char * make_module_token(ptr_module module, char *str)
Definition: modules.c:185
ptr_int_list next
Definition: def_struct.h:55

Variable Documentation

ptr_module bi_module =NULL

Definition at line 15 of file modules.c.

ptr_module current_module =NULL

Definition at line 13 of file modules.c.

long display_modules =TRUE

Definition at line 23 of file modules.c.

ptr_node module_table =NULL

Definition at line 12 of file modules.c.

ptr_module no_module =NULL

Definition at line 14 of file modules.c.

ptr_module syntax_module =NULL

Definition at line 16 of file modules.c.

ptr_module sys_module =NULL

Definition at line 17 of file modules.c.

ptr_module user_module =NULL

Definition at line 20 of file modules.c.

ptr_module x_module = NULL

Definition at line 21 of file modules.c.