Wild Life  2.30
 All Data Structures Files Functions Variables Typedefs Macros
Functions | Variables
built_ins.c File Reference

Built in functions. More...

Go to the source code of this file.

Functions

long all_public_symbols ()
 all_public_symbols More...
 
ptr_psi_term stack_nil ()
 stack_nil More...
 
ptr_psi_term stack_cons (ptr_psi_term head, ptr_psi_term tail)
 stack_cons More...
 
ptr_psi_term stack_pair (ptr_psi_term left, ptr_psi_term right)
 stack_pair More...
 
ptr_psi_term stack_int (long n)
 stack_int More...
 
ptr_psi_term stack_string (char *s)
 stack_string More...
 
ptr_psi_term stack_bytes (char *s, int n)
 stack_bytes More...
 
long psi_to_string (ptr_psi_term t, char **fn)
 psi_to_string More...
 
ptr_psi_term make_feature_list (ptr_node tree, ptr_psi_term tail, ptr_module module, int val)
 make_feature_list More...
 
long check_real (ptr_psi_term t, REAL *v, long *n)
 check_real More...
 
long get_real_value (ptr_psi_term t, REAL *v, long *n)
 get_real_value More...
 
static long get_bool_value (ptr_psi_term t, REAL *v, long *n)
 get_bool_value More...
 
void unify_bool_result (ptr_psi_term t, long v)
 unify_bool_result More...
 
long unify_real_result (ptr_psi_term t, REAL v)
 unify_real_result More...
 
static long c_gt ()
 c_gt More...
 
static long c_equal ()
 static long c_equal() More...
 
static long c_eval_disjunction ()
 c_eval_disjunction More...
 
static long c_lt ()
 c_lt C_LT Less than. More...
 
static long c_gtoe ()
 c_gtoe More...
 
static long c_ltoe ()
 c_ltoe More...
 
static long c_boolpred ()
 c_boolpred More...
 
static long get_bool (ptr_definition typ)
 get_bool More...
 
static void unify_bool (ptr_psi_term arg)
 unify_bool More...
 
static long c_logical_main (long sel)
 c_logical_main More...
 
static long c_and ()
 c_and More...
 
static long c_or ()
 c_or More...
 
static long c_not ()
 c_not More...
 
static long c_xor ()
 c_xor More...
 
static long c_apply ()
 c_apply More...
 
static long c_project ()
 c_project More...
 
static long c_diff ()
 c_diff More...
 
static long c_fail ()
 c_fail More...
 
static long c_succeed ()
 c_succeed More...
 
static long c_repeat ()
 c_repeat More...
 
static long c_var ()
 static long c_var() More...
 
static long c_nonvar ()
 c_nonvar More...
 
static long c_is_function ()
 c_is_function More...
 
static long c_is_predicate ()
 c_is_predicate More...
 
static long c_is_sort ()
 c_is_sort More...
 
long only_arg1 (ptr_psi_term t, ptr_psi_term *arg1)
 only_arg1 More...
 
static long c_dynamic ()
 c_dynamic More...
 
static long c_static ()
 c_static More...
 
static long c_delay_check ()
 static long c_delay_check() More...
 
static long c_non_strict ()
 c_non_strict More...
 
static long c_op ()
 c_op More...
 
long file_exists (char *s)
 file_exists More...
 
static long c_exists ()
 c_exists More...
 
static long c_load ()
 c_load More...
 
static long c_get_choice ()
 c_get_choice More...
 
static long c_set_choice ()
 c_set_choice More...
 
static long c_exists_choice ()
 c_exists_choice More...
 
static long c_print_variables ()
 c_print_variables More...
 
static void set_parse_queryflag (ptr_node thelist, long sort)
 set_parse_queryflag More...
 
static long c_parse ()
 c_parse More...
 
static long c_read (long)
 c_read More...
 
static long c_read_psi ()
 c_read_psi More...
 
static long c_read_token ()
 c_read_token More...
 
long c_halt ()
 c_halt More...
 
void exit_life (long nl_flag)
 exit_life More...
 
long c_abort ()
 c_abort More...
 
long abort_life (int nlflag)
 abort_life More...
 
static long c_not_implemented ()
 c_not_implemented More...
 
static long c_declaration ()
 c_declaration More...
 
static long c_setq ()
 c_setq More...
 
static long c_assert_first ()
 c_assert_first More...
 
static long c_assert_last ()
 c_assert_last More...
 
long pred_clause (ptr_psi_term t, long r, ptr_psi_term g)
 pred_clause More...
 
static long c_clause ()
 c_clause More...
 
static long c_retract ()
 c_retract More...
 
static long c_global ()
 c_global More...
 
void global_error_check (ptr_node n, int *error, int *eval_2)
 global_error_check More...
 
void global_tree (ptr_node n)
 global_tree More...
 
void global_one (ptr_psi_term t)
 global_one More...
 
static long c_persistent ()
 c_persistent More...
 
void persistent_error_check (ptr_node n, int *error)
 persistent_error_check More...
 
void persistent_tree (ptr_node n)
 persistent_tree More...
 
void persistent_one (ptr_psi_term t)
 persistent_one More...
 
static long c_open_in ()
 c_open_in More...
 
static long c_open_out ()
 c_open_out More...
 
static long c_set_input ()
 c_set_input More...
 
static long c_set_output ()
 c_set_output More...
 
static long c_close ()
 c_close More...
 
static long c_get ()
 c_get More...
 
static long c_put_main (long)
 c_put_main More...
 
static long c_put ()
 c_put More...
 
static long c_put_err ()
 c_put_err More...
 
static long generic_write ()
 generic_write More...
 
static long c_write_err ()
 c_write_err More...
 
static long c_writeq_err ()
 c_writeq_err More...
 
static long c_write ()
 c_write More...
 
static long c_writeq ()
 c_writeq More...
 
static long c_write_canonical ()
 c_write_canonical More...
 
static long c_pwrite ()
 c_pwrite More...
 
static long c_pwriteq ()
 c_pwriteq More...
 
static long c_page_width ()
 c_page_width More...
 
static long c_print_depth ()
 c_print_depth More...
 
static long c_rootsort ()
 c_rootsort More...
 
static long c_disj ()
 c_disj More...
 
static long c_cond ()
 c_cond More...
 
static long c_exist_feature ()
 c_exist_feature More...
 
static long c_features ()
 c_features More...
 
static long c_feature_values ()
 c_feature_values More...
 
long hidden_type (ptr_definition t)
 hidden_type More...
 
ptr_psi_term collect_symbols (long sel)
 collect_symbols More...
 
static long c_ops ()
 c_ops More...
 
static ptr_node copy_attr_list (ptr_node n)
 copy_attr_list More...
 
static long c_strip ()
 c_strip More...
 
static long c_same_address ()
 c_same_address More...
 
static long c_diff_address ()
 c_diff_address More...
 
static long c_eval ()
 c_eval More...
 
static long c_eval_inplace ()
 c_eval_inplace More...
 
static long c_quote ()
 c_quote More...
 
static long c_split_double ()
 c_split_double More...
 
static long c_string_address ()
 c_string_address More...
 
static long c_chdir ()
 c_chdir More...
 
static long c_call ()
 c_call More...
 
static long c_bk_assign ()
 c_bk_assign More...
 
static long c_assign ()
 c_assign More...
 
static long c_global_assign ()
 c_global_assign More...
 
static long c_unify_func ()
 c_unify_func More...
 
static long c_unify_pred ()
 c_unify_pred More...
 
static long c_copy_pointer ()
 c_copy_pointer More...
 
static long c_copy_term ()
 c_copy_term More...
 
static long c_undo ()
 c_undo More...
 
static long c_freeze_inner (long freeze_flag)
 c_freeze_inner More...
 
static long c_freeze ()
 c_freeze More...
 
static long c_implies ()
 c_implies More...
 
static long c_char ()
 c_char More...
 
static long c_ascii ()
 c_ascii More...
 
static long c_string2psi ()
 c_string2psi More...
 
static long c_psi2string ()
 c_psi2string More...
 
static long c_int2string ()
 c_int2string More...
 
static long c_such_that ()
 c_such_that More...
 
ptr_node one_attr ()
 one_attr More...
 
ptr_psi_term new_psi_term (long numargs, ptr_definition typ, ptr_psi_term **a1, ptr_psi_term **a2)
 new_psi_term More...
 
long has_rules (ptr_pair_list r)
 has_rules More...
 
long is_built_in (ptr_pair_list r)
 is_built_in More...
 
void list_special (ptr_psi_term t)
 list_special More...
 
static long c_listing ()
 c_listing More...
 
static long c_print_codes ()
 c_print_codes More...
 
static long c_pred ()
 c_pred More...
 
static long c_funct ()
 c_funct More...
 
void new_built_in (ptr_module m, char *s, def_type t, long(*r)())
 new_built_in More...
 
static void op_declare (long p, operator t, char *s)
 op_declare More...
 
long declare_operator (ptr_psi_term t)
 declare_operator More...
 
char * str_conc (char *s1, char *s2)
 str_conc More...
 
char * sub_str (char *s, long p, long n)
 sub_str More...
 
long append_files (char *s1, char *s2)
 append_files More...
 
long c_concatenate ()
 c_concatenate More...
 
static long c_module_name ()
 c_module_name More...
 
static long c_combined_name ()
 c_combined_name More...
 
long c_string_length ()
 c_string_length More...
 
long c_sub_string ()
 c_sub_string More...
 
long c_append_file ()
 c_append_file More...
 
long c_random ()
 c_random More...
 
long c_initrandom ()
 c_initrandom More...
 
long c_deref_length ()
 c_deref_length More...
 
long c_args ()
 c_args More...
 
void init_built_in_types ()
 init_built_in_types More...
 

Variables

static long built_in_index =0
 

Detailed Description

Built in functions.

Definition in file built_ins.c.

Function Documentation

long abort_life ( int  nlflag)

abort_life

Parameters
nlflag- int nlflag

Definition at line 2259 of file built_ins.c.

References aborthooksym, abortsym, wl_pair_list::bbbb_2, DEFRULES, FALSE, function_it, init_system(), main_loop_ok, NOTQUIET, NULL, prove, push_goal(), wl_definition::rule, stack_psi_term(), stdin_cleareof(), TRUE, wl_psi_term::type, wl_definition::type_def, undo(), and var_occurred.

2260 {
2262  !aborthooksym->rule->bbbb_2 ||
2264  /* Do a true abort if aborthook is not a function or is equal to 'abort'.*/
2265  main_loop_ok = FALSE;
2266  undo(NULL); /* 8.10 */
2267  if(NOTQUIET) fprintf(stderr,"\n*** Abort"); /* RM: Feb 17 1993 */
2268  if(NOTQUIET && nlflag) fprintf(stderr,"\n");/* RM: Feb 17 1993 */
2269  } else {
2270  /* Do a 'user-defined abort': initialize the system, then */
2271  /* prove the user-defined abort routine (which is set by */
2272  /* means of 'setq(aborthook,user_defined_abort)'. */
2273  ptr_psi_term aborthook;
2274 
2275  undo(NULL);
2276  init_system();
2278  stdin_cleareof();
2279  if(NOTQUIET) fprintf(stderr,"\n*** Abort"); /* RM: Feb 17 1993 */
2280  if(NOTQUIET && nlflag) fprintf(stderr,"\n");/* RM: Feb 17 1993 */
2281  aborthook=stack_psi_term(0);
2282  aborthook->type=aborthooksym;
2284  }
2285  fprintf(stderr,"\n*** END Abort");
2286  return TRUE;
2287 }
#define prove
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1051
#define function_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1408
void undo(ptr_stack limit)
undo
Definition: login.c:691
long main_loop_ok
Definition: def_glob.h:1023
#define NOTQUIET
Definition: def_macro.h:15
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
void init_system()
init_system
Definition: lib.c:83
def_type type_def
Definition: def_struct.h:153
#define DEFRULES
Must be different from NULL, a built-in index, and a pointer Used to indicate that the rules of the d...
Definition: def_const.h:302
#define NULL
Definition: def_const.h:533
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_pair_list rule
Definition: def_struct.h:148
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_definition abortsym
symbol in bi module
Definition: def_glob.h:126
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
ptr_psi_term bbbb_2
Definition: def_struct.h:206
ptr_definition type
Definition: def_struct.h:181
ptr_definition aborthooksym
symbol in bi module
Definition: def_glob.h:133
void stdin_cleareof()
stdin_cleareof
Definition: token.c:51
long var_occurred
???
Definition: def_glob.h:839
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.

1364 {
1365  ptr_psi_term arg1,arg2,funct,result;
1366  ptr_psi_term list;
1367  ptr_psi_term car;
1368  ptr_module module=NULL;
1369  ptr_definition d;
1370 
1371  funct=aim->aaaa_1;
1372  deref_ptr(funct);
1373  result=aim->bbbb_1;
1374  get_two_args(funct->attr_list,(ptr_psi_term *)&arg1,(ptr_psi_term *)&arg2);
1375 
1376  if(arg1) {
1377  deref_ptr(arg1);
1378  (void)get_module(arg1,&module);
1379  }
1380  else
1381  module=NULL;
1382 
1383  list=stack_nil();
1384 
1385  for(d=first_definition;d;d=d->next)
1386  if(d->keyword->public && (!module || d->keyword->module==module)) {
1387  car=stack_psi_term(4);
1388  car->type=d;
1389  list=stack_cons(car,list);
1390  }
1391 
1392  push_goal(unify,result,list,NULL);
1393 
1394  return TRUE;
1395 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
ptr_psi_term stack_cons(ptr_psi_term head, ptr_psi_term tail)
stack_cons
Definition: built_ins.c:46
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
ptr_definition first_definition
All definition are stores in a linked list starting at first_definition.
Definition: def_glob.h:13
ptr_keyword keyword
Definition: def_struct.h:147
#define NULL
Definition: def_const.h:533
ptr_definition next
Definition: def_struct.h:164
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
ptr_psi_term stack_nil()
stack_nil
Definition: built_ins.c:26
ptr_goal aim
Definition: def_glob.h:1024
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
ptr_module module
Definition: def_struct.h:117
ptr_definition type
Definition: def_struct.h:181
int get_module(ptr_psi_term psi, ptr_module *module)
get_module
Definition: modules.c:1226
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
long append_files ( char *  s1,
char *  s2 
)

append_files

Parameters
s1- char *s1
s2- char *s2

Definition at line 5543 of file built_ins.c.

References Errorline(), FALSE, and TRUE.

5544 {
5545  FILE *f1;
5546  FILE *f2;
5547  long result=FALSE;
5548 
5549  f1=fopen(s1,"a");
5550  if(f1) {
5551  f2=fopen(s2,"r");
5552  if(f2) {
5553  while(!feof(f2))
5554  (void)fputc(fgetc(f2),f1);
5555  (void)fclose(f2);
5556  (void)fclose(f1);
5557  result=TRUE;
5558  }
5559  else
5560  Errorline("couldn't open \"%s\"\n",f2);
5561  /* printf("*** Error: couldn't open \"%s\"\n",f2); PVR 14.9.93 */
5562  }
5563  else
5564  Errorline("couldn't open \"%s\"\n",f1);
5565  /* printf("*** Error: couldn't open \"%s\"\n",f1); PVR 14.9.93 */
5566 
5567  return result;
5568 }
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
long c_abort ( )

c_abort

C_ABORT Return to the top level of the interpreter.

Definition at line 2247 of file built_ins.c.

References abort_life(), and TRUE.

2248 {
2249  return (abort_life(TRUE));
2250 }
long abort_life(int nlflag)
abort_life
Definition: built_ins.c:2259
#define TRUE
Standard boolean.
Definition: def_const.h:268
static long c_and ( )
static

c_and

C_AND Logical and & or. These functions do all possible local propagations.

Definition at line 1000 of file built_ins.c.

References c_logical_main(), and TRUE.

1001 {
1002  return c_logical_main(TRUE);
1003 }
#define TRUE
Standard boolean.
Definition: def_const.h:268
static long c_logical_main(long sel)
c_logical_main
Definition: built_ins.c:928
long c_append_file ( )

c_append_file

C_APPEND_FILE Append the file named by argument 2 to the file named by argument 1. This predicate will not residuate; it requires string arguments.

Definition at line 5890 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_node::data, deref, deref_args, deref_ptr, Errorline(), FALSE, FEATCMP, find(), one, overlap_type(), quoted_string, set_1_2, TRUE, two, wl_psi_term::type, and wl_psi_term::value_3.

5891 {
5892  ptr_psi_term g;
5893  ptr_node n1,n2;
5894  long success=TRUE;
5895  ptr_psi_term arg1;
5896  char * c_arg1;
5897  ptr_psi_term arg2;
5898  char * c_arg2;
5899 
5900  g=aim->aaaa_1;
5901  deref_ptr(g);
5902 
5903  /* Evaluate all arguments first: */
5904  n1=find(FEATCMP,one,g->attr_list);
5905  if (n1) {
5906  arg1= (ptr_psi_term )n1->data;
5907  deref(arg1);
5908  }
5909  n2=find(FEATCMP,two,g->attr_list);
5910  if (n2) {
5911  arg2= (ptr_psi_term )n2->data;
5912  deref(arg2);
5913  }
5914  deref_args(g,set_1_2);
5915 
5916  if (success) {
5917  if (n1) {
5918  if (overlap_type(arg1->type,quoted_string))
5919  if (arg1->value_3)
5920  c_arg1= (char *)arg1->value_3;
5921  else {
5922  success=FALSE;
5923  Errorline("bad argument in %P.\n",g);
5924  }
5925  else
5926  success=FALSE;
5927  }
5928  else {
5929  success=FALSE;
5930  Errorline("bad argument in %P.\n",g);
5931  };
5932  };
5933 
5934  if (success) {
5935  if (n2) {
5936  if (overlap_type(arg2->type,quoted_string))
5937  if (arg2->value_3)
5938  c_arg2= (char *)arg2->value_3;
5939  else {
5940  success=FALSE;
5941  Errorline("bad argument in %P.\n",g);
5942  }
5943  else
5944  success=FALSE;
5945  }
5946  else {
5947  success=FALSE;
5948  Errorline("bad argument in %P.\n",g);
5949  };
5950  };
5951 
5952  if (success)
5953  success=append_files(c_arg1,c_arg2);
5954 
5955  return success;
5956 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
char * two
Definition: def_glob.h:892
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
long overlap_type(ptr_definition t1, ptr_definition t2)
overlap_type
Definition: types.c:1579
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define set_1_2
Set constants for deref_args in lefun.c.
Definition: def_const.h:514
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
long append_files(char *s1, char *s2)
append_files
Definition: built_ins.c:5543
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define deref(P)
Definition: def_macro.h:147
GENERIC value_3
Definition: def_struct.h:186
ptr_goal aim
Definition: def_glob.h:1024
char * one
Definition: def_glob.h:891
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
static long c_apply ( )
static

c_apply

C_APPLY This evaluates "apply(functor => F,Args)". If F is a known function, then it builds the psi-term F(Args), and evaluates it.

Definition at line 1160 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, clear_copy(), curry(), wl_node::data, delete_attr(), deref, deref_ptr, distinct_copy(), distinct_tree(), Errorline(), eval, FALSE, FEATCMP, find(), function_it, functor, wl_definition::keyword, merge_unify(), push_goal(), residuate(), wl_definition::rule, wl_keyword::symbol, top, TRUE, wl_psi_term::type, and wl_definition::type_def.

1161 {
1162  long success=TRUE;
1163  ptr_psi_term funct,other;
1164  ptr_node n,fattr;
1165 
1166  funct=aim->aaaa_1;
1167  deref_ptr(funct);
1169  if (n) {
1170  other=(ptr_psi_term )n->data;
1171  deref(other);
1172  if (other->type==top)
1173  residuate(other);
1174  else
1175  if(other->type && other->type->type_def!=(def_type)function_it) {
1176  success=FALSE;
1177  Errorline("argument is not a function in %P.\n",funct);
1178  }
1179  else {
1180  /* What we really want here is to merge all attributes in */
1181  /* funct->attr_list, except '*functor*', into other->attr_list. */
1182  clear_copy();
1183  other=distinct_copy(other);
1184  fattr=distinct_tree(funct->attr_list); /* Make distinct copy: PVR */
1185  push_goal(eval,other,aim->bbbb_1,(GENERIC)other->type->rule);
1186  merge_unify(&(other->attr_list),fattr);
1187  /* We don't want to remove anything from funct->attr_list here. */
1189  }
1190  }
1191  else
1192  curry();
1193 
1194  return success;
1195 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
#define function_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1408
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
void clear_copy()
clear_copy
Definition: copy.c:53
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
ptr_definition functor
symbol in bi module
Definition: def_glob.h:298
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
void merge_unify(ptr_node *u, ptr_node v)
merge_unify
Definition: login.c:1146
void delete_attr(char *s, ptr_node *n)
delete_attr
Definition: trees.c:522
def_type type_def
Definition: def_struct.h:153
ptr_keyword keyword
Definition: def_struct.h:147
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
void curry()
curry
Definition: lefun.c:174
ptr_node distinct_tree(ptr_node t)
distinct_tree
Definition: copy.c:366
char * symbol
Definition: def_struct.h:118
#define eval
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1086
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define deref_ptr(P)
Definition: def_macro.h:100
ptr_psi_term distinct_copy(ptr_psi_term t)
distinct_copy
Definition: copy.c:393
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_pair_list rule
Definition: def_struct.h:148
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define deref(P)
Definition: def_macro.h:147
ptr_goal aim
Definition: def_glob.h:1024
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
ptr_definition top
symbol in syntax module
Definition: def_glob.h:403
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
long c_args ( )

c_args

C_ARGS Return the Unix "ARGV" array as a list of strings. RM: Sep 20 1993

Definition at line 6123 of file built_ins.c.

References aim, arg_c, arg_v, wl_goal::bbbb_1, heap_copy_string(), NULL, push_goal(), quoted_string, stack_cons(), stack_nil(), stack_psi_term(), TRUE, wl_psi_term::type, unify, and wl_psi_term::value_3.

6124 {
6125  ptr_psi_term result,list,str;
6126  long success=TRUE;
6127  int i;
6128 
6129  result=aim->bbbb_1;
6130 
6131  list=stack_nil();
6132  for(i=arg_c-1; i>=0; i--) {
6133  str=stack_psi_term(0);
6134  str->type=quoted_string;
6136  list=stack_cons((ptr_psi_term)str,(ptr_psi_term)list);
6137  }
6138  push_goal(unify,result,list,NULL);
6139 
6140  return success;
6141 }
ptr_psi_term stack_cons(ptr_psi_term head, ptr_psi_term tail)
stack_cons
Definition: built_ins.c:46
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
#define NULL
Definition: def_const.h:533
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
char * heap_copy_string(char *s)
heap_copy_string
Definition: trees.c:172
int arg_c
set from argc in either life.c or lib.c
Definition: def_glob.h:20
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
GENERIC value_3
Definition: def_struct.h:186
ptr_psi_term stack_nil()
stack_nil
Definition: built_ins.c:26
ptr_goal aim
Definition: def_glob.h:1024
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
char * arg_v[ARGNN]
set from argv in either life.c or lib.c
Definition: def_glob.h:27
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
static long c_ascii ( )
static

c_ascii

C_ASCII Return the Ascii code of the first character of a string or of a psi-term's name.

Definition at line 4781 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), deref, deref_args, deref_ptr, Errorline(), FALSE, get_two_args(), matches(), quoted_string, REAL, residuate(), set_1, TRUE, wl_psi_term::type, unify_real_result(), and wl_psi_term::value_3.

4782 {
4783  long success=TRUE;
4784  ptr_psi_term arg1,arg2,funct,result;
4785  long smaller;
4786 
4787  funct=aim->aaaa_1;
4788  deref_ptr(funct);
4789  result=aim->bbbb_1;
4790  deref(result);
4791 
4792  /* success=get_real_value(result,&val1,&num1); */
4793  /* if (success) { */
4794  get_two_args(funct->attr_list,&arg1,&arg2);
4795  if (arg1) {
4796  deref(arg1);
4797  deref_args(funct,set_1);
4798  success=matches(arg1->type,quoted_string,&smaller);
4799  if (success) {
4800  if (arg1->value_3) {
4801  (void) unify_real_result(result,(REAL)(*((unsigned char *)arg1->value_3)));
4802  }
4803  else
4804  residuate(arg1);
4805  }
4806  else {/* RM: Feb 18 1994 */
4807  success=FALSE;
4808  Errorline("String argument expected in '%P'\n",funct);
4809  }
4810  /*
4811  else {
4812  success=TRUE;
4813  unify_real_result(result,(REAL)(*((unsigned char *)arg1->type->keyword->symbol)));
4814  }
4815  */
4816  }
4817  else
4818  curry();
4819  /* } */
4820 
4821  return success;
4822 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
long matches(ptr_definition t1, ptr_definition t2, long *smaller)
matches
Definition: types.c:1666
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
void curry()
curry
Definition: lefun.c:174
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define deref(P)
Definition: def_macro.h:147
GENERIC value_3
Definition: def_struct.h:186
ptr_goal aim
Definition: def_glob.h:1024
#define deref_args(P, S)
Definition: def_macro.h:150
long unify_real_result(ptr_psi_term t, REAL v)
unify_real_result
Definition: built_ins.c:386
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
static long c_assert_first ( )
static

c_assert_first

C_ASSERT_FIRST Assert a fact, inserting it as the first clause for that predicate or function.

Definition at line 2386 of file built_ins.c.

References wl_goal::aaaa_1, aim, assert_clause(), assert_first, assert_ok, wl_psi_term::attr_list, bk_mark_quote(), deref_ptr, encode_types(), Errorline(), FALSE, get_one_arg(), and TRUE.

2387 {
2388  long success=FALSE;
2389  ptr_psi_term arg1,g;
2390 
2391  g=aim->aaaa_1;
2392  bk_mark_quote(g); /* RM: Apr 7 1993 */
2393  get_one_arg(g->attr_list,&arg1);
2395  if (arg1) {
2396  deref_ptr(arg1);
2397  assert_clause(arg1);
2398  encode_types();
2399  success=assert_ok;
2400  }
2401  else {
2402  success=FALSE;
2403  Errorline("bad clause in %P.\n",g);
2404  }
2405 
2406  return success;
2407 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
long assert_first
Definition: def_glob.h:1032
void get_one_arg(ptr_node t, ptr_psi_term *a)
get_one_arg
Definition: login.c:99
long assert_ok
Definition: def_glob.h:1033
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define deref_ptr(P)
Definition: def_macro.h:100
void bk_mark_quote(ptr_psi_term t)
bk_mark_quote
Definition: copy.c:708
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_goal aim
Definition: def_glob.h:1024
void encode_types()
encode_types
Definition: types.c:1091
ptr_node attr_list
Definition: def_struct.h:187
void assert_clause(ptr_psi_term t)
assert_clause
Definition: login.c:287
static long c_assert_last ( )
static

c_assert_last

C_ASSERT_LAST Assert a fact, inserting as the last clause for that predicate or function.

Definition at line 2416 of file built_ins.c.

References wl_goal::aaaa_1, aim, assert_clause(), assert_first, assert_ok, wl_psi_term::attr_list, bk_mark_quote(), deref_ptr, encode_types(), Errorline(), FALSE, and get_one_arg().

2417 {
2418  long success=FALSE;
2419  ptr_psi_term arg1,g;
2420 
2421  g=aim->aaaa_1;
2422  bk_mark_quote(g); /* RM: Apr 7 1993 */
2423  get_one_arg(g->attr_list,&arg1);
2425  if (arg1) {
2426  deref_ptr(arg1);
2427  assert_clause(arg1);
2428  encode_types();
2429  success=assert_ok;
2430  }
2431  else {
2432  success=FALSE;
2433  Errorline("bad clause in %P.\n",g);
2434  }
2435 
2436  return success;
2437 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
long assert_first
Definition: def_glob.h:1032
void get_one_arg(ptr_node t, ptr_psi_term *a)
get_one_arg
Definition: login.c:99
long assert_ok
Definition: def_glob.h:1033
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define deref_ptr(P)
Definition: def_macro.h:100
void bk_mark_quote(ptr_psi_term t)
bk_mark_quote
Definition: copy.c:708
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_goal aim
Definition: def_glob.h:1024
void encode_types()
encode_types
Definition: types.c:1091
ptr_node attr_list
Definition: def_struct.h:187
void assert_clause(ptr_psi_term t)
assert_clause
Definition: login.c:287
static long c_assign ( )
static

c_assign

C_ASSIGN() This implements non-backtrackable assignment. It doesn't work because backtrackable unifications can have been made before this assignment was reached. It is complicated by the fact that the assigned term has to be copied into the heap as it becomes a permanent object.

Definition at line 4346 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, clear_copy(), deref_args, deref_ptr, deref_rec, Errorline(), exact_copy(), FALSE, get_two_args(), HEAP, heap_pointer, set_1_2, and TRUE.

4347 {
4348  long success=FALSE;
4349  ptr_psi_term arg1,arg2,g; // perm ,smallest;
4350 
4351  g=aim->aaaa_1;
4352  deref_ptr(g);
4353  get_two_args(g->attr_list,&arg1,&arg2);
4354  if (arg1 && arg2) {
4355  success=TRUE;
4356  deref_ptr(arg1);
4357  deref_rec(arg2); /* 17.9 */
4358  /* deref(arg2); 17.9 */
4359  deref_args(g,set_1_2);
4360  if ((GENERIC)arg1<heap_pointer || arg1!=arg2) {
4361  clear_copy();
4362  *arg1 = *exact_copy(arg2,HEAP);
4363  }
4364  }
4365  else
4366  Errorline("argument missing in %P.\n",g);
4367 
4368  return success;
4369 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
#define HEAP
Flag to indicate heap allocation.
Definition: def_const.h:324
void clear_copy()
clear_copy
Definition: copy.c:53
GENERIC heap_pointer
used to allocate from heap - size allocated subtracted - adj for alignment
Definition: def_glob.h:55
ptr_psi_term exact_copy(ptr_psi_term t, long heap_flag)
exact_copy
Definition: copy.c:176
#define deref_rec(P)
Definition: def_macro.h:149
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define set_1_2
Set constants for deref_args in lefun.c.
Definition: def_const.h:514
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_goal aim
Definition: def_glob.h:1024
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_node attr_list
Definition: def_struct.h:187
static long c_bk_assign ( )
static

c_bk_assign

C_BK_ASSIGN() This implements backtrackable assignment.

Definition at line 4287 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, c_abort(), wl_psi_term::coref, deref, deref_args, deref_ptr, deref_rec, Errorline(), FALSE, get_two_args(), heap_pointer, push_psi_ptr_value(), release_resid(), release_resid_notrail(), set_1_2, trail_condition(), and TRUE.

4288 {
4289  long success=FALSE;
4290  ptr_psi_term arg1,arg2,g;
4291 
4292  g=aim->aaaa_1;
4293  deref_ptr(g);
4294  get_two_args(g->attr_list,&arg1,&arg2);
4295  if (arg1 && arg2) {
4296  success=TRUE;
4297  deref(arg1);
4298  deref_rec(arg2); /* 17.9 */
4299  /* deref(arg2); 17.9 */
4300  deref_args(g,set_1_2);
4301  if (arg1 != arg2) {
4302 
4303  /* RM: Mar 10 1993 */
4304  if((GENERIC)arg1>=heap_pointer) {
4305  Errorline("cannot use '<-' on persistent value in %P\n",g);
4306  return c_abort();
4307  }
4308 
4309 
4310 #ifdef TS
4311  if (!trail_condition(arg1)) {
4312  /* If no trail, then can safely overwrite the psi-term */
4313  release_resid_notrail(arg1);
4314  *arg1 = *arg2;
4315  push_psi_ptr_value(arg2,(GENERIC *)&(arg2->coref)); /* 14.12 */
4316  arg2->coref=arg1; /* 14.12 */
4317  }
4318  else {
4319  push_psi_ptr_value(arg1,(GENERIC *)&(arg1->coref));
4320  arg1->coref=arg2;
4321  release_resid(arg1);
4322  }
4323 #else
4324  push_psi_ptr_value(arg1,(GENERIC *)&(arg1->coref));
4325  arg1->coref=arg2;
4326  release_resid(arg1);
4327 #endif
4328  }
4329  }
4330  else
4331  Errorline("argument missing in %P.\n",g);
4332 
4333  return success;
4334 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
long trail_condition(psi_term *Q)
trail_condition
Definition: login.c:2630
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
GENERIC heap_pointer
used to allocate from heap - size allocated subtracted - adj for alignment
Definition: def_glob.h:55
void push_psi_ptr_value(ptr_psi_term q, GENERIC *p)
push_psi_ptr_value
Definition: login.c:474
#define deref_rec(P)
Definition: def_macro.h:149
long c_abort()
c_abort
Definition: built_ins.c:2247
void release_resid(ptr_psi_term t)
release_resid
Definition: lefun.c:445
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define set_1_2
Set constants for deref_args in lefun.c.
Definition: def_const.h:514
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
void release_resid_notrail(ptr_psi_term t)
release_resid_notrail
Definition: lefun.c:456
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define deref(P)
Definition: def_macro.h:147
ptr_goal aim
Definition: def_glob.h:1024
ptr_psi_term coref
Definition: def_struct.h:188
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_node attr_list
Definition: def_struct.h:187
static long c_boolpred ( )
static

c_boolpred

C_BOOLPRED Internal built-in predicate that handles functions in predicate positions. This predicate should never be called directly by the user.

Definition at line 838 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, c_abort(), DEFRULES, deref, deref_args, deref_ptr, Errorline(), FALSE, get_one_arg(), lf_false, lf_true, matches(), NULL, predicate_it, prove, push_goal(), residuate(), set_1, sub_type(), TRUE, wl_psi_term::type, and wl_definition::type_def.

839 {
840  long success=TRUE,succ,lesseq;
841  ptr_psi_term t,arg1;
842 
843  t=aim->aaaa_1;
844  deref_ptr(t);
845  get_one_arg(t->attr_list,&arg1);
846  if (arg1) {
847  deref(arg1);
848  deref_args(t,set_1);
849  if (sub_type(boolean,arg1->type)) {
850  residuate(arg1);
851  }
852  else {
853  succ=matches(arg1->type,lf_true,&lesseq);
854  if (succ) {
855  if (lesseq) {
856  /* Function returns lf_true: success. */
857  }
858  else
859  residuate(arg1);
860  }
861  else {
862  succ=matches(arg1->type,lf_false,&lesseq);
863  if (succ) {
864  if (lesseq) {
865  /* Function returns lf_false: failure. */
866  success=FALSE;
867  }
868  else
869  residuate(arg1);
870  }
871  else {
872  /* Both lf_true and false are disentailed. */
873  if (arg1->type->type_def==(def_type)predicate_it) {
875  }
876  else {
877  Errorline("function result '%P' should be a boolean or a predicate.\n",
878  arg1);
879  return (c_abort());
880  }
881  }
882  }
883  }
884  }
885  else {
886  Errorline("missing argument to '*boolpred*'.\n");
887  return (c_abort());
888  }
889 
890  return success;
891 }
#define prove
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1051
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
ptr_definition lf_false
symbol in bi module
Definition: def_glob.h:284
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
def_type type_def
Definition: def_struct.h:153
#define predicate_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1401
long matches(ptr_definition t1, ptr_definition t2, long *smaller)
matches
Definition: types.c:1666
#define DEFRULES
Must be different from NULL, a built-in index, and a pointer Used to indicate that the rules of the d...
Definition: def_const.h:302
long c_abort()
c_abort
Definition: built_ins.c:2247
void get_one_arg(ptr_node t, ptr_psi_term *a)
get_one_arg
Definition: login.c:99
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
#define NULL
Definition: def_const.h:533
long sub_type(ptr_definition t1, ptr_definition t2)
sub_type
Definition: types.c:1642
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define deref(P)
Definition: def_macro.h:147
ptr_goal aim
Definition: def_glob.h:1024
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_definition lf_true
symbol in bi module
Definition: def_glob.h:410
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
static long c_call ( )
static

c_call

C_CALL Prove a predicate, return true or false if it succeeds or fails. No implicit cut is performed.

Definition at line 4236 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, choice_stack, curry(), DEFRULES, deref_args, deref_ptr, Errorline(), FALSE, get_two_args(), lf_false, lf_true, NULL, prove, push_choice_point(), push_goal(), resid_aim, residuate(), set_1, stack_psi_term(), top, TRUE, wl_psi_term::type, and unify.

4237 {
4238  long success=TRUE;
4239  ptr_psi_term arg1,arg2,funct,result,other;
4240  ptr_choice_point cutpt;
4241 
4242  funct=aim->aaaa_1;
4243  deref_ptr(funct);
4244  result=aim->bbbb_1;
4245  get_two_args(funct->attr_list,&arg1,&arg2);
4246  if (arg1) {
4247  deref_ptr(arg1);
4248  deref_args(funct,set_1);
4249  if(arg1->type==top)
4250  residuate(arg1);
4251  else
4252  if(FALSE /*arg1->type->type_def!=predicate_it*/) {
4253  success=FALSE;
4254  Errorline("argument of %P should be a predicate.\n",funct);
4255  }
4256  else {
4257  resid_aim=NULL;
4258  cutpt=choice_stack;
4259 
4260  /* Result is FALSE */
4261  other=stack_psi_term(0);
4262  other->type=lf_false;
4263 
4264  push_choice_point(unify,result,other,NULL);
4265 
4266  /* Result is TRUE */
4267  other=stack_psi_term(0);
4268  other->type=lf_true;
4269 
4270  push_goal(unify,result,other,NULL);
4272  }
4273  }
4274  else
4275  curry();
4276 
4277  return success;
4278 }
#define prove
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1051
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
ptr_definition lf_false
symbol in bi module
Definition: def_glob.h:284
void push_choice_point(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_choice_point
Definition: login.c:638
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
#define DEFRULES
Must be different from NULL, a built-in index, and a pointer Used to indicate that the rules of the d...
Definition: def_const.h:302
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
ptr_goal resid_aim
Definition: def_glob.h:865
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
ptr_goal aim
Definition: def_glob.h:1024
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
ptr_definition top
symbol in syntax module
Definition: def_glob.h:403
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_definition lf_true
symbol in bi module
Definition: def_glob.h:410
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
ptr_choice_point choice_stack
Definition: def_glob.h:1026
static long c_char ( )
static

c_char

C_CHAR RM: May 6 1993 Changed C_CHAR to return a string Create a 1 character string from an ASCII code.

Definition at line 4731 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), deref, deref_args, deref_ptr, Errorline(), FALSE, get_two_args(), heap_alloc(), integer, NULL, overlap_type(), push_goal(), quoted_string, REAL, residuate(), set_1, stack_psi_term(), TRUE, wl_psi_term::type, unify, and wl_psi_term::value_3.

4732 {
4733  long success=TRUE;
4734  ptr_psi_term arg1,arg2,funct,result;
4735  char *str;
4736 
4737  funct=aim->aaaa_1;
4738  deref_ptr(funct);
4739  result=aim->bbbb_1;
4740  deref(result);
4741 
4742  get_two_args(funct->attr_list,&arg1,&arg2);
4743  if (arg1) {
4744  deref(arg1);
4745  deref_args(funct,set_1);
4746  if (overlap_type(arg1->type,integer)) {
4747  if (arg1->value_3) {
4748  ptr_psi_term t;
4749 
4750  t=stack_psi_term(4);
4751  t->type=quoted_string;
4752  str=(char *)heap_alloc(2);
4753  str[0] = (unsigned char) floor(*(REAL *) arg1->value_3);
4754  str[1] = 0;
4755  t->value_3=(GENERIC)str;
4756 
4757  push_goal(unify,t,result,NULL);
4758  }
4759  else
4760  residuate(arg1);
4761  }
4762  else {
4763  Errorline("argument of %P must be an integer.\n",funct);
4764  success=FALSE;
4765  }
4766  }
4767  else
4768  curry();
4769 
4770  return success;
4771 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
long overlap_type(ptr_definition t1, ptr_definition t2)
overlap_type
Definition: types.c:1579
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define deref(P)
Definition: def_macro.h:147
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
GENERIC value_3
Definition: def_struct.h:186
ptr_goal aim
Definition: def_glob.h:1024
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
GENERIC heap_alloc(long s)
heap_alloc
Definition: memory.c:1616
static long c_chdir ( )
static

c_chdir

C_CHDIR Change the current working directory

Definition at line 4152 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, deref_ptr, Errorline(), expand_file_name(), FALSE, get_two_args(), matches(), quoted_string, wl_psi_term::type, and wl_psi_term::value_3.

4153 {
4154  long success=FALSE;
4155  ptr_psi_term arg1,arg2,funct;
4156  long smaller;
4157 
4158  funct = aim->aaaa_1;
4159  deref_ptr(funct);
4160 
4161  get_two_args(funct->attr_list, &arg1, &arg2);
4162  if(arg1) {
4163  deref_ptr(arg1);
4164  if(matches(arg1->type,quoted_string,&smaller) && arg1->value_3)
4165  success=!chdir(expand_file_name((char *)arg1->value_3));
4166  else
4167  Errorline("bad argument in %P\n",funct);
4168  }
4169  else
4170  Errorline("argument missing in %P\n",funct);
4171 
4172  return success;
4173 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
long matches(ptr_definition t1, ptr_definition t2, long *smaller)
matches
Definition: types.c:1666
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define deref_ptr(P)
Definition: def_macro.h:100
#define FALSE
Standard boolean.
Definition: def_const.h:275
char * expand_file_name(char *s)
expand_file_name
Definition: token.c:537
GENERIC value_3
Definition: def_struct.h:186
ptr_goal aim
Definition: def_glob.h:1024
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
static long c_clause ( )
static

c_clause

C_CLAUSE Find the clauses that unify with the argument in the rules. The argument must be a predicate or a function. Use PRED_CLAUSE to perform the search.

Definition at line 2519 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, FALSE, get_two_args(), and pred_clause().

2520 {
2521  long success=FALSE;
2522  ptr_psi_term arg1,arg2,g;
2523 
2524  g=aim->aaaa_1;
2525  get_two_args(g->attr_list,&arg1,&arg2);
2526  success=pred_clause(arg1,0,g);
2527  return success;
2528 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
long pred_clause(ptr_psi_term t, long r, ptr_psi_term g)
pred_clause
Definition: built_ins.c:2451
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_goal aim
Definition: def_glob.h:1024
ptr_node attr_list
Definition: def_struct.h:187
static long c_close ( )
static

c_close

C_CLOSE Close a stream.

Definition at line 2936 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_node::data, deref, deref_args, deref_ptr, equal_types, Errorline(), FALSE, FEATCMP, find(), get_two_args(), input_stream, inputfilesym, NULL, open_input_file(), open_output_file(), output_stream, set_1, stream, STREAM, TRUE, wl_psi_term::type, and wl_psi_term::value_3.

2937 {
2938  long success=FALSE;
2939  long inclose,outclose;
2940  ptr_psi_term arg1,arg2,g; // ,s;
2941 
2942  g=aim->aaaa_1;
2943  deref_ptr(g);
2944  get_two_args(g->attr_list,&arg1,&arg2);
2945  if (arg1) {
2946  deref(arg1);
2947  deref_args(g,set_1);
2948  /*
2949  if (sub_type(arg1->type,sys_stream))
2950  return sys_close(arg1);
2951  */
2952  outclose=equal_types(arg1->type,stream) && arg1->value_3;
2953  inclose=FALSE;
2954  if (equal_types(arg1->type,inputfilesym)) {
2956  if (n) {
2957  arg1=(ptr_psi_term)n->data;
2958  inclose=(arg1->value_3!=NULL);
2959  }
2960  }
2961 
2962  if (inclose || outclose) {
2963  success=TRUE;
2964  (void)fclose((FILE *)arg1->value_3);
2965 
2966  if (inclose && (FILE *)arg1->value_3==input_stream)
2967  (void)open_input_file("stdin");
2968  else if (outclose && (FILE *)arg1->value_3==output_stream)
2969  (void)open_output_file("stdout");
2970 
2971  arg1->value_3=NULL;
2972  }
2973  else
2974  Errorline("bad stream in %P.\n",g);
2975  }
2976  else
2977  Errorline("no stream in %P.\n",g);
2978 
2979  return success;
2980 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
long open_output_file(char *file)
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
ptr_definition stream
symbol in bi module
Definition: def_glob.h:382
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
#define NULL
Definition: def_const.h:533
ptr_definition inputfilesym
symbol in bi module
Definition: def_glob.h:501
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define STREAM
feature name
Definition: def_const.h:876
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define deref(P)
Definition: def_macro.h:147
FILE * input_stream
Definition: def_glob.h:1014
GENERIC value_3
Definition: def_struct.h:186
ptr_goal aim
Definition: def_glob.h:1024
#define equal_types(A, B)
Definition: def_macro.h:111
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
#define deref_args(P, S)
Definition: def_macro.h:150
FILE * output_stream
Definition: def_glob.h:1017
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
long open_input_file(char *file)
open_input_file
Definition: token.c:594
static long c_combined_name ( )
static

c_combined_name

C_COMBINED_NAME Return the string module::name for a term.

Definition at line 5693 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, wl_keyword::combined_name, curry(), deref_ptr, get_two_args(), heap_copy_string(), wl_definition::keyword, NULL, push_goal(), quoted_string, stack_psi_term(), TRUE, wl_psi_term::type, unify, and wl_psi_term::value_3.

5694 {
5695  long success=TRUE;
5696  ptr_psi_term arg1,arg2,funct,result;
5697 
5698 
5699  funct=aim->aaaa_1;
5700  result=aim->bbbb_1;
5701  deref_ptr(funct);
5702  deref_ptr(result);
5703 
5704  get_two_args(funct->attr_list,&arg1,&arg2);
5705 
5706  if (arg1) {
5707  deref_ptr(arg1);
5708  arg2=stack_psi_term(0);
5709  arg2->type=quoted_string;
5711  push_goal(unify,arg2,result,NULL);
5712  }
5713  else
5714  curry();
5715 
5716  return success;
5717 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
char * combined_name
Definition: def_struct.h:119
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
ptr_keyword keyword
Definition: def_struct.h:147
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define deref_ptr(P)
Definition: def_macro.h:100
char * heap_copy_string(char *s)
heap_copy_string
Definition: trees.c:172
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
GENERIC value_3
Definition: def_struct.h:186
ptr_goal aim
Definition: def_glob.h:1024
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
long c_concatenate ( )

c_concatenate

C_CONCATENATE Concatenate the strings in arguments 1 and 2.

Definition at line 5577 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), wl_node::data, deref, deref_args, deref_ptr, FALSE, FEATCMP, find(), one, overlap_type(), quoted_string, residuate(), set_1_2, TRUE, two, wl_psi_term::type, and wl_psi_term::value_3.

5578 {
5579  ptr_psi_term result,funct,temp_result;
5580  ptr_node n1, n2;
5581  long success=TRUE;
5582  long all_args=TRUE;
5583  char * c_result;
5584  ptr_psi_term arg1;
5585  char * c_arg1;
5586  ptr_psi_term arg2;
5587  char * c_arg2;
5588 
5589  funct=aim->aaaa_1;
5590  deref_ptr(funct);
5591  result=aim->bbbb_1;
5592 
5593  /* Evaluate all arguments first: */
5594  n1=find(FEATCMP,one,funct->attr_list);
5595  if (n1) {
5596  arg1= (ptr_psi_term )n1->data;
5597  deref(arg1);
5598  }
5599  n2=find(FEATCMP,two,funct->attr_list);
5600  if (n2) {
5601  arg2= (ptr_psi_term )n2->data;
5602  deref(arg2);
5603  }
5604  deref_args(funct,set_1_2);
5605 
5606  if (success) {
5607  if (n1) {
5608  if (overlap_type(arg1->type,quoted_string)) /* 10.8 */
5609  if (arg1->value_3)
5610  c_arg1= (char *)arg1->value_3;
5611  else {
5612  residuate(arg1);
5613  all_args=FALSE;
5614  }
5615  else
5616  success=FALSE;
5617  }
5618  else {
5619  all_args=FALSE;
5620  curry();
5621  };
5622  };
5623 
5624  if (success) {
5625  if (n2) {
5626  if (overlap_type(arg2->type,quoted_string)) /* 10.8 */
5627  if (arg2->value_3)
5628  c_arg2= (char *)arg2->value_3;
5629  else {
5630  residuate(arg2);
5631  all_args=FALSE;
5632  }
5633  else
5634  success=FALSE;
5635  }
5636  else {
5637  all_args=FALSE;
5638  curry();
5639  }
5640  }
5641 
5642  if(success && all_args) {
5643  c_result=str_conc( c_arg1, c_arg2 );
5644  temp_result=stack_psi_term(0);
5645  temp_result->type=quoted_string;
5646  temp_result->value_3= (GENERIC)c_result;
5647  push_goal(unify,temp_result,result,NULL);
5648  }
5649 
5650  return success;
5651 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
char * two
Definition: def_glob.h:892
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
long overlap_type(ptr_definition t1, ptr_definition t2)
overlap_type
Definition: types.c:1579
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define set_1_2
Set constants for deref_args in lefun.c.
Definition: def_const.h:514
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define deref(P)
Definition: def_macro.h:147
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
GENERIC value_3
Definition: def_struct.h:186
ptr_goal aim
Definition: def_glob.h:1024
char * one
Definition: def_glob.h:891
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
char * str_conc(char *s1, char *s2)
str_conc
Definition: built_ins.c:5496
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
static long c_cond ( )
static

c_cond

C_COND This implements COND(Condition,Then,Else). First Condition is evaluated. If it returns true, return the Then value. If it returns false, return the Else value. Either the Then or the Else values may be omitted, in which case they are considered to be true.

Definition at line 3422 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, calloncesym, curry(), wl_node::data, deref, deref_args, deref_ptr, Errorline(), FEATCMP, find(), get_bool_value(), get_one_arg_addr(), goal_stack, i_check_out(), wl_node::key, wl_node::left, lf_true, NULL, one, predicate_it, psi_term_ptr, push_goal(), push_ptr_value(), REAL, resid_aim, residuate(), wl_node::right, set_1_2_3, STACK_ALLOC, stack_psi_term(), three, TRUE, two, wl_psi_term::type, wl_definition::type_def, and unify.

3423 {
3424  long success=TRUE;
3425  ptr_psi_term arg1,arg2,result,g;
3426  ptr_psi_term *arg1addr;
3427  REAL val1;
3428  long num1;
3429  ptr_node n;
3430 
3431  g=aim->aaaa_1;
3432  deref_ptr(g);
3433  result=aim->bbbb_1;
3434  deref(result);
3435 
3436  get_one_arg_addr(g->attr_list,&arg1addr);
3437  if (arg1addr) {
3438  arg1= *arg1addr;
3439  deref_ptr(arg1);
3440  if (arg1->type->type_def==(def_type)predicate_it) {
3441  ptr_psi_term call_once;
3442  ptr_node ca;
3443 
3444  /* Transform cond(pred,...) into cond(call_once(pred),...) */
3445  goal_stack=aim;
3446  call_once=stack_psi_term(0);
3447  call_once->type=calloncesym;
3448  call_once->attr_list=(ca=STACK_ALLOC(node));
3449  ca->key=one;
3450  ca->left=ca->right=NULL;
3451  ca->data=(GENERIC)arg1;
3452  push_ptr_value(psi_term_ptr,(GENERIC *)arg1addr);
3453  *arg1addr=call_once;
3454  return success;
3455  }
3456  deref(arg1);
3457  deref_args(g,set_1_2_3);
3458  success=get_bool_value(arg1,&val1,&num1);
3459  if (success) {
3460  if (num1) {
3461  resid_aim=NULL;
3462  n=find(FEATCMP,(val1?two:three),g->attr_list);
3463  if (n) {
3464  arg2=(ptr_psi_term)n->data;
3465  /* mark_eval(arg2); XXX 24.8 */
3466  push_goal(unify,result,arg2,NULL);
3467  (void)i_check_out(arg2);
3468  }
3469  else {
3470  ptr_psi_term trueterm;
3471  trueterm=stack_psi_term(4);
3472  trueterm->type=lf_true;
3473  push_goal(unify,result,trueterm,NULL);
3474  }
3475  }
3476  else
3477  residuate(arg1);
3478  }
3479  else /* RM: Apr 15 1993 */
3480  Errorline("argument to cond is not boolean in %P\n",g);
3481  }
3482  else
3483  curry();
3484 
3485  return success;
3486 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void push_ptr_value(type_ptr t, GENERIC *p)
push_ptr_value
Definition: login.c:383
void get_one_arg_addr(ptr_node t, ptr_psi_term **a)
get_one_arg_addr
Definition: login.c:132
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
ptr_goal goal_stack
Definition: def_glob.h:1025
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
ptr_definition calloncesym
symbol in bi module
Definition: def_glob.h:206
char * two
Definition: def_glob.h:892
def_type type_def
Definition: def_struct.h:153
#define predicate_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1401
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
char * three
Definition: def_glob.h:893
ptr_goal resid_aim
Definition: def_glob.h:865
ptr_node left
Definition: def_struct.h:199
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define deref_ptr(P)
Definition: def_macro.h:100
char * key
Definition: def_struct.h:198
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define deref(P)
Definition: def_macro.h:147
#define set_1_2_3
Set constants for deref_args in lefun.c.
Definition: def_const.h:521
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
ptr_goal aim
Definition: def_glob.h:1024
char * one
Definition: def_glob.h:891
#define STACK_ALLOC(A)
Definition: def_macro.h:21
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_definition lf_true
symbol in bi module
Definition: def_glob.h:410
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
static long get_bool_value(ptr_psi_term t, REAL *v, long *n)
get_bool_value
Definition: built_ins.c:300
ptr_node attr_list
Definition: def_struct.h:187
long i_check_out(ptr_psi_term t)
i_check_out
Definition: lefun.c:1033
ptr_node right
Definition: def_struct.h:200
#define psi_term_ptr
values of type_ptr
Definition: def_const.h:383
static long c_copy_pointer ( )
static

c_copy_pointer

C_COPY_POINTER Make a fresh copy of the input's sort, keeping exactly the same arguments as before (i.e., copying the sort and feature table but not the feature values).

Definition at line 4482 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, copy_attr_list(), curry(), deref, deref_args, deref_ptr, get_one_arg(), NULL, push_goal(), set_1, stack_psi_term(), TRUE, wl_psi_term::type, unify, and wl_psi_term::value_3.

4483 {
4484  long success=TRUE;
4485  ptr_psi_term funct,arg1,result,other;
4486 
4487  funct=aim->aaaa_1;
4488  deref_ptr(funct);
4489  get_one_arg(funct->attr_list,&arg1);
4490  if (arg1) {
4491  deref(arg1);
4492  deref_args(funct,set_1);
4493  other=stack_psi_term(4);
4494  other->type=arg1->type;
4495  other->value_3=arg1->value_3;
4496  other->attr_list=copy_attr_list(arg1->attr_list); /* PVR 23.2.94 */
4497  result=aim->bbbb_1;
4498  push_goal(unify,other,result,NULL);
4499  }
4500  else
4501  curry();
4502 
4503  return success;
4504 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
void get_one_arg(ptr_node t, ptr_psi_term *a)
get_one_arg
Definition: login.c:99
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define deref(P)
Definition: def_macro.h:147
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
GENERIC value_3
Definition: def_struct.h:186
ptr_goal aim
Definition: def_glob.h:1024
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
#define deref_args(P, S)
Definition: def_macro.h:150
static ptr_node copy_attr_list(ptr_node n)
copy_attr_list
Definition: built_ins.c:3806
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
static long c_copy_term ( )
static

c_copy_term

C_COPY_TERM Make a fresh copy of the input argument, keeping its structure but with no connections to the input.

Definition at line 4514 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, clear_copy(), curry(), deref, deref_args, deref_ptr, exact_copy(), get_one_arg(), NULL, push_goal(), set_1, STACK, TRUE, and unify.

4515 {
4516  long success=TRUE;
4517  ptr_psi_term funct,arg1,copy_arg1,result;
4518 
4519  funct=aim->aaaa_1;
4520  deref_ptr(funct);
4521  get_one_arg(funct->attr_list,&arg1);
4522  if (arg1) {
4523  deref(arg1);
4524  deref_args(funct,set_1);
4525  result=aim->bbbb_1;
4526  clear_copy();
4527  copy_arg1=exact_copy(arg1,STACK);
4528  push_goal(unify,copy_arg1,result,NULL);
4529  }
4530  else
4531  curry();
4532 
4533  return success;
4534 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void clear_copy()
clear_copy
Definition: copy.c:53
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
ptr_psi_term exact_copy(ptr_psi_term t, long heap_flag)
exact_copy
Definition: copy.c:176
void get_one_arg(ptr_node t, ptr_psi_term *a)
get_one_arg
Definition: login.c:99
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define deref(P)
Definition: def_macro.h:147
ptr_goal aim
Definition: def_glob.h:1024
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
#define STACK
Flag to indicate stack allocation.
Definition: def_const.h:331
static long c_declaration ( )
static

c_declaration

C_DECLARATION This function always fails, it is in fact identical to BOTTOM.

Definition at line 2313 of file built_ins.c.

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

2314 {
2315  ptr_psi_term t;
2316 
2317  t=aim->aaaa_1;
2318  deref_ptr(t);
2319  Errorline("%P is a declaration, not a query.\n",t);
2320  return FALSE;
2321 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define deref_ptr(P)
Definition: def_macro.h:100
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_goal aim
Definition: def_glob.h:1024
static long c_delay_check ( )
static

static long c_delay_check()

C_DELAY_CHECK() Mark that the properties of the types in the arguments are delay checked during unification (i.e. they are only checked when the psi-term is given attributes, and they are not checked as long as the psi-term has no attributes.)

Definition at line 1661 of file built_ins.c.

References wl_goal::aaaa_1, aim, assert_delay_check(), wl_psi_term::attr_list, deref_ptr, inherit_always_check(), and TRUE.

1662 {
1663  ptr_psi_term t=aim->aaaa_1;
1664 
1665  deref_ptr(t);
1666  /* mark_quote(t); 14.9 */
1669  return TRUE;
1670 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void assert_delay_check(ptr_node n)
assert_delay_check
Definition: types.c:326
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_goal aim
Definition: def_glob.h:1024
void inherit_always_check()
inherit_always_check
Definition: types.c:1068
ptr_node attr_list
Definition: def_struct.h:187
long c_deref_length ( )

c_deref_length

C_DEREF_LENGTH Return the length of the dereference chain for argument 1. RM: Jul 15 1993

Definition at line 6087 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, wl_psi_term::coref, curry(), wl_node::data, deref_ptr, FEATCMP, find(), one, REAL, TRUE, and unify_real_result().

6088 {
6089  ptr_psi_term result,funct;
6090  long success=TRUE;
6091  int count;
6092  ptr_psi_term arg1; // ,arg2;
6093  ptr_node n1;
6094 
6095  funct=aim->aaaa_1;
6096  deref_ptr(funct);
6097  result=aim->bbbb_1;
6098 
6099  n1=find(FEATCMP,one,funct->attr_list);
6100  if (n1) {
6101  count=0;
6102  arg1= (ptr_psi_term )n1->data;
6103  while(arg1->coref) {
6104  count++;
6105  arg1=arg1->coref;
6106  }
6107  success=unify_real_result(result,(REAL)count);
6108  }
6109  else
6110  curry();
6111 
6112  return success;
6113 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
void curry()
curry
Definition: lefun.c:174
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_goal aim
Definition: def_glob.h:1024
ptr_psi_term coref
Definition: def_struct.h:188
char * one
Definition: def_glob.h:891
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
long unify_real_result(ptr_psi_term t, REAL v)
unify_real_result
Definition: built_ins.c:386
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
static long c_diff ( )
static

c_diff

C_DIFF Arithmetic not-equal.

Definition at line 1308 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), deref, deref_args, deref_ptr, FALSE, get_bool_value(), get_real_value(), get_two_args(), nonnum_warning(), REAL, residuate(), residuate2(), set_1_2, TRUE, unify_bool_result(), and unify_real_result().

1309 {
1310  long success=TRUE;
1311  ptr_psi_term arg1,arg2,arg3,t;
1312  long num1,num2,num3;
1313  REAL val1,val2,val3;
1314 
1315  t=aim->aaaa_1;
1316  deref_ptr(t);
1317  get_two_args(t->attr_list,&arg1,&arg2);
1318  arg3=aim->bbbb_1;
1319 
1320  if(arg1) {
1321  deref(arg1);
1322  success=get_real_value(arg1,&val1,&num1);
1323  if(success && arg2) {
1324  deref(arg2);
1325  deref_args(t,set_1_2);
1326  success=get_real_value(arg2,&val2,&num2);
1327  }
1328  }
1329 
1330  if(success)
1331  if(arg1 && arg2) {
1332  deref(arg3);
1333  success=get_bool_value(arg3,&val3,&num3);
1334  if(success)
1335  switch(num1+2*num2+4*num3) {
1336  case 0:
1337  if(arg1==arg2)
1338  unify_bool_result(arg3,FALSE);
1339  else
1340  residuate2(arg1,arg2);
1341  break;
1342  case 1:
1343  residuate2(arg2,arg3);
1344  break;
1345  case 2:
1346  residuate2(arg1,arg3);
1347  break;
1348  case 3:
1349  unify_bool_result(arg3,(val1!=val2));
1350  break;
1351  case 4:
1352  if(arg1==arg2 && val3)
1353  success=FALSE;
1354  else
1355  residuate2(arg1,arg2);
1356  break;
1357  case 5:
1358  if(val3)
1359  residuate(arg2);
1360  else
1361  success=unify_real_result(arg2,val1);
1362  break;
1363  case 6:
1364  if(val3)
1365  residuate(arg1);
1366  else
1367  success=unify_real_result(arg1,val2);
1368  break;
1369  case 7:
1370  success=(val3==(REAL)(val1!=val2));
1371  break;
1372  }
1373  }
1374  else
1375  curry();
1376 
1377  nonnum_warning(t,arg1,arg2);
1378  return success;
1379 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
void unify_bool_result(ptr_psi_term t, long v)
unify_bool_result
Definition: built_ins.c:344
long get_real_value(ptr_psi_term t, REAL *v, long *n)
get_real_value
Definition: built_ins.c:261
void nonnum_warning(ptr_psi_term t, ptr_psi_term arg1, ptr_psi_term arg2)
nonnum_warning
Definition: error.c:953
void curry()
curry
Definition: lefun.c:174
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
#define set_1_2
Set constants for deref_args in lefun.c.
Definition: def_const.h:514
void residuate2(ptr_psi_term u, ptr_psi_term v)
residuate2
Definition: lefun.c:144
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define deref(P)
Definition: def_macro.h:147
ptr_goal aim
Definition: def_glob.h:1024
#define deref_args(P, S)
Definition: def_macro.h:150
long unify_real_result(ptr_psi_term t, REAL v)
unify_real_result
Definition: built_ins.c:386
ptr_psi_term bbbb_1
Definition: def_struct.h:240
static long get_bool_value(ptr_psi_term t, REAL *v, long *n)
get_bool_value
Definition: built_ins.c:300
ptr_node attr_list
Definition: def_struct.h:187
static long c_diff_address ( )
static

c_diff_address

C_DIFF_ADDRESS Return TRUE if two arguments have different addresses.

Definition at line 3901 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), deref, deref_args, deref_ptr, FALSE, get_bool_value(), get_two_args(), NULL, push_goal(), REAL, resid_aim, set_1_2, TRUE, unify, and unify_bool_result().

3902 {
3903  long success=TRUE;
3904  ptr_psi_term arg1,arg2,funct,result;
3905  REAL val3;
3906  long num3;
3907 
3908  funct=aim->aaaa_1;
3909  deref_ptr(funct);
3910  result=aim->bbbb_1;
3911  get_two_args(funct->attr_list,&arg1,&arg2);
3912 
3913  if (arg1 && arg2) {
3914  success=get_bool_value(result,&val3,&num3);
3915  resid_aim=NULL;
3916  deref(arg1);
3917  deref(arg2);
3918  deref_args(funct,set_1_2);
3919 
3920  if (num3) {
3921  if (val3)
3922  push_goal(unify,arg1,arg2,NULL);
3923  else
3924  success=(arg1==arg2);
3925  }
3926  else
3927  if (arg1==arg2)
3928  unify_bool_result(result,FALSE);
3929  else
3930  unify_bool_result(result,TRUE);
3931  }
3932  else
3933  curry();
3934 
3935  return success;
3936 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
void unify_bool_result(ptr_psi_term t, long v)
unify_bool_result
Definition: built_ins.c:344
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
ptr_goal resid_aim
Definition: def_glob.h:865
#define set_1_2
Set constants for deref_args in lefun.c.
Definition: def_const.h:514
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define deref(P)
Definition: def_macro.h:147
ptr_goal aim
Definition: def_glob.h:1024
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_psi_term bbbb_1
Definition: def_struct.h:240
static long get_bool_value(ptr_psi_term t, REAL *v, long *n)
get_bool_value
Definition: built_ins.c:300
ptr_node attr_list
Definition: def_struct.h:187
static long c_disj ( )
static

c_disj

C_DISJ This implements disjunctions (A;B). A nonexistent A or B is taken to mean 'fail'. Disjunctions should not be implemented in Life, because doing so results in both A and B being evaluated before the disjunction is. Disjunctions could be implemented in Life if there were a 'melt' predicate.

Definition at line 3391 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, DEFRULES, deref_args, deref_ptr, Errorline(), FALSE, get_two_args(), NULL, prove, push_choice_point(), push_goal(), resid_aim, set_1_2, traceline(), and TRUE.

3392 {
3393  long success=TRUE;
3394  ptr_psi_term arg1,arg2,g;
3395 
3396  g=aim->aaaa_1;
3397  resid_aim=NULL;
3398  deref_ptr(g);
3399  get_two_args(g->attr_list,&arg1,&arg2);
3400  deref_args(g,set_1_2);
3401  traceline("pushing predicate disjunction choice point for %P\n",g);
3403  if (arg1) push_goal(prove,arg1,(ptr_psi_term)DEFRULES,(GENERIC)NULL);
3404  if (!arg1 && !arg2) {
3405  success=FALSE;
3406  Errorline("neither first nor second arguments exist in %P.\n",g);
3407  }
3408 
3409  return success;
3410 }
#define prove
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1051
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
void push_choice_point(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_choice_point
Definition: login.c:638
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
#define DEFRULES
Must be different from NULL, a built-in index, and a pointer Used to indicate that the rules of the d...
Definition: def_const.h:302
#define NULL
Definition: def_const.h:533
ptr_goal resid_aim
Definition: def_glob.h:865
void traceline(char *format,...)
traceline
Definition: error.c:186
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define set_1_2
Set constants for deref_args in lefun.c.
Definition: def_const.h:514
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_goal aim
Definition: def_glob.h:1024
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_node attr_list
Definition: def_struct.h:187
static long c_dynamic ( )
static

c_dynamic

C_DYNAMIC() Mark all the arguments as 'unprotected', i.e. they may be changed by assert/retract/redefinition.

Definition at line 1625 of file built_ins.c.

References wl_goal::aaaa_1, aim, assert_protected(), wl_psi_term::attr_list, deref_ptr, FALSE, and TRUE.

1626 {
1627  ptr_psi_term t=aim->aaaa_1;
1628  deref_ptr(t);
1629  /* mark_quote(t); 14.9 */
1631  return TRUE;
1632 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void assert_protected(ptr_node n, long prot)
assert_protected
Definition: types.c:255
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_goal aim
Definition: def_glob.h:1024
ptr_node attr_list
Definition: def_struct.h:187
static long c_equal ( )
static

static long c_equal()

C_EQUAL Arithmetic equality.

Definition at line 507 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), deref, deref_args, deref_ptr, FALSE, get_bool_value(), get_real_value(), get_two_args(), nonnum_warning(), REAL, residuate(), residuate2(), set_1_2, TRUE, unify_bool_result(), and unify_real_result().

508 {
509  long success=TRUE;
510  ptr_psi_term arg1,arg2,arg3,t;
511  long num1,num2,num3;
512  REAL val1,val2,val3;
513 
514  t=aim->aaaa_1;
515  deref_ptr(t);
516  get_two_args(t->attr_list,&arg1,&arg2);
517  arg3=aim->bbbb_1;
518 
519  if(arg1) {
520  deref(arg1);
521  success=get_real_value(arg1,&val1,&num1);
522  if(success && arg2) {
523  deref(arg2);
524  deref_args(t,set_1_2);
525  success=get_real_value(arg2,&val2,&num2);
526  }
527  }
528 
529  if(success)
530  if(arg1 && arg2) {
531  deref(arg3);
532  success=get_bool_value(arg3,&val3,&num3);
533  if(success)
534  switch(num1+2*num2+4*num3) {
535  case 0:
536  if(arg1==arg2)
537  unify_bool_result(arg3,TRUE);
538  else
539  residuate2(arg1,arg2);
540  break;
541  case 1:
542  residuate2(arg2,arg3);
543  break;
544  case 2:
545  residuate2(arg1,arg3);
546  break;
547  case 3:
548  unify_bool_result(arg3,(val1==val2));
549  break;
550  case 4:
551  if(arg1==arg2 && !val3)
552  success=FALSE;
553  else
554  residuate2(arg1,arg2);
555  break;
556  case 5:
557  if(!val3)
558  residuate(arg2);
559  else
560  success=unify_real_result(arg2,val1);
561  break;
562  case 6:
563  if(!val3)
564  residuate(arg1);
565  else
566  success=unify_real_result(arg1,val2);
567  break;
568  case 7:
569  success=(val3==(REAL)(val1==val2));
570  break;
571  }
572  }
573  else
574  curry();
575 
576  nonnum_warning(t,arg1,arg2);
577  return success;
578 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
void unify_bool_result(ptr_psi_term t, long v)
unify_bool_result
Definition: built_ins.c:344
long get_real_value(ptr_psi_term t, REAL *v, long *n)
get_real_value
Definition: built_ins.c:261
void nonnum_warning(ptr_psi_term t, ptr_psi_term arg1, ptr_psi_term arg2)
nonnum_warning
Definition: error.c:953
void curry()
curry
Definition: lefun.c:174
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
#define set_1_2
Set constants for deref_args in lefun.c.
Definition: def_const.h:514
void residuate2(ptr_psi_term u, ptr_psi_term v)
residuate2
Definition: lefun.c:144
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define deref(P)
Definition: def_macro.h:147
ptr_goal aim
Definition: def_glob.h:1024
#define deref_args(P, S)
Definition: def_macro.h:150
long unify_real_result(ptr_psi_term t, REAL v)
unify_real_result
Definition: built_ins.c:386
ptr_psi_term bbbb_1
Definition: def_struct.h:240
static long get_bool_value(ptr_psi_term t, REAL *v, long *n)
get_bool_value
Definition: built_ins.c:300
ptr_node attr_list
Definition: def_struct.h:187
static long c_eval ( )
static

c_eval

C_EVAL Evaluate an expression and return its value.

Definition at line 3945 of file built_ins.c.

References wl_goal::aaaa_1, aim, assert, wl_psi_term::attr_list, wl_goal::bbbb_1, clear_copy(), curry(), deref, deref_args, deref_ptr, eval_copy(), get_two_args(), i_check_out(), NULL, push_goal(), resid_aim, set_1, STACK, TRUE, wl_psi_term::type, and unify.

3946 {
3947  long success=TRUE;
3948  ptr_psi_term arg1, copy_arg1, arg2, funct, result;
3949 
3950  funct = aim->aaaa_1;
3951  deref_ptr(funct);
3952  result = aim->bbbb_1;
3953  deref(result);
3954  get_two_args(funct->attr_list, &arg1, &arg2);
3955  if (arg1) {
3956  deref(arg1);
3957  deref_args(funct,set_1);
3958  assert((unsigned long)(arg1->type)!=4);
3959  clear_copy();
3960  copy_arg1 = eval_copy(arg1,STACK);
3961  resid_aim = NULL;
3962  push_goal(unify,copy_arg1,result,NULL);
3963  (void)i_check_out(copy_arg1);
3964  } else
3965  curry();
3966 
3967  return success;
3968 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
void clear_copy()
clear_copy
Definition: copy.c:53
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
ptr_goal resid_aim
Definition: def_glob.h:865
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define deref(P)
Definition: def_macro.h:147
ptr_goal aim
Definition: def_glob.h:1024
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_psi_term eval_copy(ptr_psi_term t, long heap_flag)
eval_copy
Definition: copy.c:196
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
long i_check_out(ptr_psi_term t)
i_check_out
Definition: lefun.c:1033
#define STACK
Flag to indicate stack allocation.
Definition: def_const.h:331
#define assert(N)
Definition: memory.c:114
static long c_eval_disjunction ( )
static

c_eval_disjunction

C_EVAL_DISJUNCTION Evaluate a disjunction.

Definition at line 589 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, c_abort(), deref_ptr, disj_nil, Errorline(), eval, get_two_args(), i_check_out(), NULL, push_choice_point(), push_goal(), resid_aim, wl_definition::rule, TRUE, wl_psi_term::type, and unify.

591 {
592  ptr_psi_term arg1,arg2,funct,result;
593 
594 
595  funct=aim->aaaa_1;
596  deref_ptr(funct);
597  result=aim->bbbb_1;
598  get_two_args(funct->attr_list,&arg1,&arg2);
599 
600  /* deref_args(funct,set_1_2); Don't know about this */
601 
602  if (arg1 && arg2) {
603  deref_ptr(arg1);
604  deref_ptr(arg2);
605 
606  resid_aim=NULL; /* Function evaluation is over */
607 
608  if(arg2->type!=disj_nil) /* RM: Feb 1 1993 */
609  /* Create the alternative */
610  push_choice_point(eval,arg2,result,(GENERIC)funct->type->rule);
611 
612  /* Unify the result with the first argument */
613  push_goal(unify,result,arg1,NULL);
614  (void)i_check_out(arg1);
615  }
616  else {
617  Errorline("malformed disjunction '%P'\n",funct);
618  return (c_abort());
619  }
620 
621  return TRUE;
622 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
void push_choice_point(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_choice_point
Definition: login.c:638
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
long c_abort()
c_abort
Definition: built_ins.c:2247
#define NULL
Definition: def_const.h:533
ptr_goal resid_aim
Definition: def_glob.h:865
#define eval
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1086
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_pair_list rule
Definition: def_struct.h:148
ptr_goal aim
Definition: def_glob.h:1024
ptr_definition disj_nil
symbol in syntax module
Definition: def_glob.h:256
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
long i_check_out(ptr_psi_term t)
i_check_out
Definition: lefun.c:1033
static long c_eval_inplace ( )
static

c_eval_inplace

C_EVAL_INPLACE Evaluate an expression and return its value.

Definition at line 3977 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), deref, deref_args, deref_ptr, get_two_args(), i_check_out(), mark_eval(), NULL, push_goal(), resid_aim, set_1, TRUE, and unify.

3978 {
3979  long success=TRUE;
3980  ptr_psi_term arg1,/* copy_arg1, */ arg2, funct, result;
3981 
3982  funct = aim->aaaa_1;
3983  deref_ptr(funct);
3984  result = aim->bbbb_1;
3985  deref(result);
3986  get_two_args(funct->attr_list, &arg1, &arg2);
3987  if (arg1) {
3988  deref(arg1);
3989  deref_args(funct,set_1);
3990  resid_aim = NULL;
3991  mark_eval(arg1);
3992  push_goal(unify,arg1,result,NULL);
3993  (void)i_check_out(arg1);
3994  } else
3995  curry();
3996 
3997  return success;
3998 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
ptr_goal resid_aim
Definition: def_glob.h:865
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
void mark_eval(ptr_psi_term t)
mark_eval
Definition: copy.c:498
#define deref(P)
Definition: def_macro.h:147
ptr_goal aim
Definition: def_glob.h:1024
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
long i_check_out(ptr_psi_term t)
i_check_out
Definition: lefun.c:1033
static long c_exist_feature ( )
static

c_exist_feature

C_EXIST_FEATURE Here we evaluate "has_feature(Label,Psi-term,Value)". This is a boolean function that returns true iff Psi-term has the feature Label.

Added optional 3rd argument which is unified with the feature value if it exists.

Definition at line 3499 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, wl_keyword::combined_name, curry(), wl_node::data, deref, deref_args, deref_ptr, FEATCMP, find(), get_two_args(), heap_copy_string(), integer, wl_definition::keyword, lf_false, lf_true, NULL, wl_keyword::private_feature, push_goal(), quoted_string, REAL, set_1_2, stack_psi_term(), sub_type(), wl_keyword::symbol, three, TRUE, wl_psi_term::type, unify, and wl_psi_term::value_3.

3500 {
3501  long success=TRUE,v;
3502  ptr_psi_term arg1,arg2,arg3,funct,result,ans;
3503  ptr_node n;
3504  char * label;
3505  /* char *thebuffer="integer"; 18.5 */
3506  char thebuffer[20]; /* Maximum number of digits in an integer */
3507  // char *np1;
3508 
3509  funct=aim->aaaa_1;
3510  deref_ptr(funct);
3511  result=aim->bbbb_1;
3512  get_two_args(funct->attr_list,&arg1,&arg2);
3513 
3514  n=find(FEATCMP,three,funct->attr_list); /* RM: Feb 10 1993 */
3515  if(n)
3516  arg3=(ptr_psi_term)n->data;
3517  else
3518  arg3=NULL;
3519 
3520  if (arg1 && arg2) {
3521  deref(arg1);
3522  deref(arg2);
3523 
3524  if(arg3) /* RM: Feb 10 1993 */
3525  deref(arg3);
3526 
3527  deref_args(funct,set_1_2);
3528  label=NULL;
3529 
3530  if (arg1->value_3 && sub_type(arg1->type,quoted_string))
3531  label=(char *)arg1->value_3;
3532  else if (arg1->value_3 && sub_type(arg1->type,integer)) {
3533  v= *(REAL *)arg1->value_3;
3534  (void)snprintf(thebuffer,20,"%ld",(long)v);
3535  label=heap_copy_string(thebuffer); /* A little voracious */
3536  } else if (arg1->type->keyword->private_feature) {
3537  label=arg1->type->keyword->combined_name;
3538  } else
3539  label=arg1->type->keyword->symbol;
3540 
3541  n=find(FEATCMP,(char *)label,arg2->attr_list);
3542  ans=stack_psi_term(4);
3543  ans->type=(n!=NULL)?lf_true:lf_false;
3544 
3545  if(arg3 && n) /* RM: Feb 10 1993 */
3547 
3548  push_goal(unify,result,ans,NULL);
3549  }
3550  else
3551  curry();
3552 
3553  return success;
3554 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
ptr_definition lf_false
symbol in bi module
Definition: def_glob.h:284
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
char * combined_name
Definition: def_struct.h:119
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
ptr_keyword keyword
Definition: def_struct.h:147
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
char * three
Definition: def_glob.h:893
char * symbol
Definition: def_struct.h:118
long sub_type(ptr_definition t1, ptr_definition t2)
sub_type
Definition: types.c:1642
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define set_1_2
Set constants for deref_args in lefun.c.
Definition: def_const.h:514
#define deref_ptr(P)
Definition: def_macro.h:100
char * heap_copy_string(char *s)
heap_copy_string
Definition: trees.c:172
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define deref(P)
Definition: def_macro.h:147
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
GENERIC value_3
Definition: def_struct.h:186
ptr_goal aim
Definition: def_glob.h:1024
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
#define deref_args(P, S)
Definition: def_macro.h:150
int private_feature
Definition: def_struct.h:121
ptr_definition lf_true
symbol in bi module
Definition: def_glob.h:410
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
static long c_exists ( )
static

c_exists

C_EXISTS Succeed iff a file can be read in (i.e. if it exists).

Definition at line 1732 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_node::data, deref, deref_args, deref_ptr, Errorline(), FALSE, FEATCMP, file_exists(), find(), one, psi_to_string(), set_1, and TRUE.

1733 {
1734  ptr_psi_term g;
1735  ptr_node n;
1736  long success=TRUE;
1737  ptr_psi_term arg1;
1738  char *c_arg1;
1739 
1740  g=aim->aaaa_1;
1741  deref_ptr(g);
1742 
1743  if (success) {
1744  n=find(FEATCMP,one,g->attr_list);
1745  if (n) {
1746  arg1= (ptr_psi_term )n->data;
1747  deref(arg1);
1748  deref_args(g,set_1);
1749  if (!psi_to_string(arg1,&c_arg1)) {
1750  success=FALSE;
1751  Errorline("bad argument in %P.\n",g);
1752  }
1753  }
1754  else {
1755  success=FALSE;
1756  Errorline("bad argument in %P.\n",g);
1757  }
1758  }
1759 
1760  if (success)
1761  success=file_exists(c_arg1);
1762 
1763  return success;
1764 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define deref(P)
Definition: def_macro.h:147
ptr_goal aim
Definition: def_glob.h:1024
char * one
Definition: def_glob.h:891
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
#define deref_args(P, S)
Definition: def_macro.h:150
long file_exists(char *s)
file_exists
Definition: built_ins.c:1711
ptr_node attr_list
Definition: def_struct.h:187
long psi_to_string(ptr_psi_term t, char **fn)
psi_to_string
Definition: built_ins.c:146
static long c_exists_choice ( )
static

c_exists_choice

C_EXISTS_CHOICE() Return true iff there exists a choice point A such that arg1 < A <= arg2, i.e. A is more recent than the choice point marked by arg1 and no more recent than the choice point marked by arg2. The two arguments to exists_choice must come from past calls to get_choice. This function allows one to check whether a choice point exists between any two arbitrary execution points of the program.

Definition at line 1910 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, choice_stack, curry(), deref, deref_args, deref_ptr, Errorline(), FALSE, get_real_value(), get_two_args(), lf_false, lf_true, wl_choice_point::next, NULL, push_goal(), REAL, set_1_2, set_empty, stack_psi_term(), wl_choice_point::time_stamp, TRUE, wl_psi_term::type, and unify.

1911 {
1912  REAL gts_r;
1913  long ans,gts1,gts2,num,success=TRUE;
1914  ptr_psi_term funct,result,arg1,arg2,ans_term;
1915  ptr_choice_point cp;
1916 
1917  funct=aim->aaaa_1;
1918  deref_ptr(funct);
1919  result=aim->bbbb_1;
1920  deref_args(funct,set_empty);
1921  get_two_args(funct->attr_list,&arg1,&arg2);
1922  if (arg1 && arg2) {
1923  deref(arg1);
1924  deref(arg2);
1925  deref_args(funct,set_1_2);
1926  success = get_real_value(arg1,&gts_r,&num);
1927  if (success && num) {
1928  gts1 = (unsigned long) gts_r;
1929  success = get_real_value(arg2,&gts_r,&num);
1930  if (success && num) {
1931  gts2 = (unsigned long) gts_r;
1932  cp = choice_stack;
1933  if (cp) {
1934  while (cp && cp->time_stamp>gts2) cp=cp->next;
1935  ans=(cp && cp->time_stamp>gts1);
1936  }
1937  else
1938  ans=FALSE;
1939  ans_term=stack_psi_term(4);
1940  ans_term->type=ans?lf_true:lf_false;
1941  push_goal(unify,result,ans_term,NULL);
1942  }
1943  else {
1944  Errorline("bad second argument to %P.\n",funct);
1945  success=FALSE;
1946  }
1947  }
1948  else {
1949  Errorline("bad first argument %P.\n",funct);
1950  success=FALSE;
1951  }
1952  }
1953  else
1954  curry();
1955 
1956  return success;
1957 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
ptr_definition lf_false
symbol in bi module
Definition: def_glob.h:284
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
long get_real_value(ptr_psi_term t, REAL *v, long *n)
get_real_value
Definition: built_ins.c:261
#define set_empty
Set constants for deref_args in lefun.c.
Definition: def_const.h:493
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
unsigned long time_stamp
Definition: def_struct.h:247
ptr_choice_point next
Definition: def_struct.h:250
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define set_1_2
Set constants for deref_args in lefun.c.
Definition: def_const.h:514
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define deref(P)
Definition: def_macro.h:147
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
ptr_goal aim
Definition: def_glob.h:1024
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_definition lf_true
symbol in bi module
Definition: def_glob.h:410
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
ptr_choice_point choice_stack
Definition: def_glob.h:1026
static long c_fail ( )
static

c_fail

C_FAIL Always fail.

Definition at line 1388 of file built_ins.c.

References FALSE.

1389 {
1390  return FALSE;
1391 }
#define FALSE
Standard boolean.
Definition: def_const.h:275
static long c_feature_values ( )
static

c_feature_values

C_FEATURES Return the list of values of the features of a term.

Definition at line 3618 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, current_module, curry(), deref, deref_args, deref_ptr, get_module(), get_two_args(), make_feature_list(), NULL, push_goal(), resid_aim, set_1, stack_nil(), TRUE, and unify.

3619 {
3620  long success=TRUE;
3621  ptr_psi_term arg1,arg2,funct,result;
3622  /* ptr_psi_term the_list; RM: Dec 9 1992
3623  Modified the routine to use 'cons'
3624  instead of the old list representation.
3625  */
3626  /* RM: Mar 11 1993 Added MODULE argument */
3627  ptr_module module=NULL;
3628  ptr_module save_current;
3629 
3630  funct=aim->aaaa_1;
3631  deref_ptr(funct);
3632  result=aim->bbbb_1;
3633  get_two_args(funct->attr_list,&arg1,&arg2);
3634 
3635  if(arg2) {
3636  deref(arg2);
3637  success=get_module(arg2,&module);
3638  }
3639  else
3640  module=current_module;
3641 
3642  if(arg1 && success) {
3643  deref(arg1);
3644  deref_args(funct,set_1);
3645  resid_aim=NULL;
3646 
3647  save_current=current_module;
3648  if(module)
3649  current_module=module;
3650 
3651  push_goal(unify,
3652  result,
3653  make_feature_list(arg1->attr_list,stack_nil(),module,1),
3654  NULL);
3655 
3656  current_module=save_current;
3657  }
3658  else
3659  curry();
3660 
3661  return success;
3662 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
ptr_module current_module
The current module for the tokenizer.
Definition: def_glob.h:729
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
ptr_goal resid_aim
Definition: def_glob.h:865
int get_module(ptr_psi_term psi, ptr_module *module)
get_module
Definition: modules.c:1226
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define deref(P)
Definition: def_macro.h:147
ptr_psi_term stack_nil()
stack_nil
Definition: built_ins.c:26
ptr_goal aim
Definition: def_glob.h:1024
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
ptr_psi_term make_feature_list(ptr_node tree, ptr_psi_term tail, ptr_module module, int val)
make_feature_list
Definition: built_ins.c:175
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
static long c_features ( )
static

c_features

C_FEATURES Convert the feature names of a psi_term into a list of psi-terms. This uses the MAKE_FEATURE_LIST routine.

Definition at line 3564 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, current_module, curry(), deref, deref_args, deref_ptr, get_module(), get_two_args(), make_feature_list(), NULL, push_goal(), resid_aim, set_1, stack_nil(), TRUE, and unify.

3565 {
3566  long success=TRUE;
3567  ptr_psi_term arg1,arg2,funct,result;
3568  /* ptr_psi_term the_list; RM: Dec 9 1992
3569  Modified the routine to use 'cons'
3570  instead of the old list representation.
3571  */
3572  /* RM: Mar 11 1993 Added MODULE argument */
3573  ptr_module module=NULL;
3574  ptr_module save_current;
3575 
3576  funct=aim->aaaa_1;
3577  deref_ptr(funct);
3578  result=aim->bbbb_1;
3579  get_two_args(funct->attr_list,&arg1,&arg2);
3580 
3581 
3582  if(arg2) {
3583  deref(arg2);
3584  success=get_module(arg2,&module);
3585  }
3586  else
3587  module=current_module;
3588 
3589  if(arg1 && success) {
3590  deref(arg1);
3591  deref_args(funct,set_1);
3592  resid_aim=NULL;
3593 
3594  save_current=current_module;
3595  if(module)
3596  current_module=module;
3597 
3598  push_goal(unify,
3599  result,
3600  make_feature_list(arg1->attr_list,stack_nil(),module,0),
3601  NULL);
3602 
3603  current_module=save_current;
3604  }
3605  else
3606  curry();
3607 
3608  return success;
3609 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
ptr_module current_module
The current module for the tokenizer.
Definition: def_glob.h:729
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
ptr_goal resid_aim
Definition: def_glob.h:865
int get_module(ptr_psi_term psi, ptr_module *module)
get_module
Definition: modules.c:1226
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define deref(P)
Definition: def_macro.h:147
ptr_psi_term stack_nil()
stack_nil
Definition: built_ins.c:26
ptr_goal aim
Definition: def_glob.h:1024
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
ptr_psi_term make_feature_list(ptr_node tree, ptr_psi_term tail, ptr_module module, int val)
make_feature_list
Definition: built_ins.c:175
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
static long c_freeze ( )
static

c_freeze

C_FREEZE() See c_freeze_inner.

Definition at line 4706 of file built_ins.c.

References c_freeze_inner(), and TRUE.

4707 {
4708  return c_freeze_inner(TRUE);
4709 }
static long c_freeze_inner(long freeze_flag)
c_freeze_inner
Definition: built_ins.c:4597
#define TRUE
Standard boolean.
Definition: def_const.h:268
static long c_freeze_inner ( long  freeze_flag)
static

c_freeze_inner

Parameters
freeze_flag- long freeze_flag

C_FREEZE_INNER This implements the freeze and implies predicates. For example:

freeze(g)

The proof will use matching on the heads of g's definition rather than unification to prove Goal. An implicit cut is put at the beginning of each clause body. Body goals are executed in the same way as without freeze. Essentially, the predicate is called as if it were a function.

implies(g)

The proof will use matching as for freeze, but there is no cut at the beginning of the clause body & no residuation is done (the clause fails if its head is not implied by the caller). Essentially, the predicate is called as before except that matching is used instead of unification to decide whether to enter a clause.

Definition at line 4597 of file built_ins.c.

References wl_goal::aaaa_1, wl_pair_list::aaaa_2, aim, wl_psi_term::attr_list, wl_pair_list::bbbb_2, can_curry, wl_goal::cccc_1, choice_stack, clear_copy(), curried, DEFRULES, deref_args, deref_ptr, Errorline(), eval_copy(), FALSE, freeze_cut, get_one_arg(), implies_cut, match, MAX_BUILT_INS, wl_pair_list::next, NULL, predicate_it, prove, push_choice_point(), push_goal(), quote_copy(), resid_aim, resid_vars, wl_definition::rule, save_resid(), set_1, STACK, STACK_ALLOC, stack_pointer, wl_psi_term::status, traceline(), TRUE, wl_psi_term::type, and wl_definition::type_def.

4598 {
4599  long success=TRUE;
4600  ptr_psi_term arg1,g;
4601  ptr_psi_term head, body;
4602  ptr_pair_list rule;
4603  /* RESID */ ptr_resid_block rb;
4604  ptr_choice_point cutpt;
4605  ptr_psi_term match_date;
4606 
4607  g=aim->aaaa_1;
4608  deref_ptr(g);
4609  get_one_arg(g->attr_list,&arg1);
4610 
4611  if (arg1) {
4612  deref_ptr(arg1);
4613  /* if (!arg1->type->evaluate_args) mark_quote(arg1); 8.9 */ /* 18.2 PVR */
4614  deref_args(g,set_1);
4615  deref_ptr(arg1);
4616 
4617  if (arg1->type->type_def!=(def_type)predicate_it) {
4618  success=FALSE;
4619  Errorline("the argument %P of freeze must be a predicate.\n",arg1);
4620  /* main_loop_ok=FALSE; 8.9 */
4621  return success;
4622  }
4623  resid_aim=aim;
4624  match_date=(ptr_psi_term)stack_pointer;
4625  cutpt=choice_stack; /* 13.6 */
4626  /* Third argument of freeze's aim is used to keep track of which */
4627  /* clause is being tried in the frozen goal. */
4628  rule=(ptr_pair_list)aim->cccc_1; /* 8.9 */ /* Isn't aim->cccc always NULL? */
4629  resid_vars=NULL;
4630  curried=FALSE;
4631  can_curry=TRUE; /* 8.9 */
4632 
4633  if (!rule) rule=arg1->type->rule; /* 8.9 */
4634  /* if ((unsigned long)rule==DEFRULES) rule=arg1->type->rule; 8.9 */
4635 
4636  if (rule) {
4637  traceline("evaluate frozen predicate %P\n",g);
4638  /* resid_limit=(ptr_goal )stack_pointer; 12.6 */
4639 
4640  if ((unsigned long)rule<=MAX_BUILT_INS) {
4641  success=FALSE; /* 8.9 */
4642  Errorline("the argument %P of freeze must be user-defined.\n",arg1); /* 8.9 */
4643  return success; /* 8.9 */
4644  /* Removed obsolete stuff here 11.9 */
4645  }
4646  else {
4647  while (rule && (rule->aaaa_2==NULL || rule->bbbb_2==NULL)) {
4648  rule=rule->next;
4649  traceline("alternative clause has been retracted\n");
4650  }
4651  if (rule) {
4652  /* RESID */ rb = STACK_ALLOC(resid_block);
4653  /* RESID */ save_resid(rb,match_date);
4654  /* RESID */ /* resid_aim = NULL; */
4655 
4656  clear_copy();
4657  if (TRUE /*arg1->type->evaluate_args 8.9 */)
4658  head=eval_copy(rule->aaaa_2,STACK);
4659  else
4660  head=quote_copy(rule->aaaa_2,STACK);
4661  body=eval_copy(rule->bbbb_2,STACK);
4662  head->status=4;
4663 
4664  if (rule->next)
4665  /* push_choice_point(prove,g,rule->next,NULL); 8.9 */
4667 
4668  push_goal(prove,body,(ptr_psi_term)DEFRULES,NULL);
4669  if (freeze_flag) /* 12.10 */
4670  push_goal(freeze_cut,body,(ptr_psi_term)cutpt,(GENERIC)rb); /* 13.6 */
4671  else
4672  push_goal(implies_cut,body,(ptr_psi_term)cutpt,(GENERIC)rb);
4673  /* RESID */ push_goal(match,arg1,head,(GENERIC)rb);
4674  /* eval_args(head->attr_list); */
4675  }
4676  else {
4677  success=FALSE;
4678  /* resid_aim=NULL; */
4679  }
4680  }
4681  }
4682  else {
4683  success=FALSE;
4684  /* resid_aim=NULL; */
4685  }
4686  resid_aim=NULL;
4687  resid_vars=NULL; /* 22.9 */
4688  }
4689  else {
4690  success=FALSE;
4691  Errorline("goal missing in %P.\n",g);
4692  }
4693 
4694  /* match_date=NULL; */ /* 13.6 */
4695  return success;
4696 }
GENERIC stack_pointer
used to allocate from stack - size allocated added - adj for alignment
Definition: def_glob.h:69
#define prove
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1051
ptr_psi_term aaaa_1
Definition: def_struct.h:239
ptr_psi_term aaaa_2
Definition: def_struct.h:205
void clear_copy()
clear_copy
Definition: copy.c:53
void push_choice_point(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_choice_point
Definition: login.c:638
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
ptr_pair_list next
Definition: def_struct.h:207
GENERIC cccc_1
Definition: def_struct.h:241
#define implies_cut
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1107
def_type type_def
Definition: def_struct.h:153
#define predicate_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1401
#define DEFRULES
Must be different from NULL, a built-in index, and a pointer Used to indicate that the rules of the d...
Definition: def_const.h:302
void get_one_arg(ptr_node t, ptr_psi_term *a)
get_one_arg
Definition: login.c:99
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
#define NULL
Definition: def_const.h:533
ptr_goal resid_aim
Definition: def_glob.h:865
ptr_resid_list resid_vars
Definition: def_glob.h:866
void traceline(char *format,...)
traceline
Definition: error.c:186
ptr_psi_term quote_copy(ptr_psi_term t, long heap_flag)
quote_copy
Definition: copy.c:186
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define deref_ptr(P)
Definition: def_macro.h:100
#define freeze_cut
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define match
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1121
ptr_pair_list rule
Definition: def_struct.h:148
#define FALSE
Standard boolean.
Definition: def_const.h:275
struct wl_pair_list * ptr_pair_list
Definition: def_struct.h:64
ptr_psi_term bbbb_2
Definition: def_struct.h:206
ptr_goal aim
Definition: def_glob.h:1024
#define STACK_ALLOC(A)
Definition: def_macro.h:21
void save_resid(ptr_resid_block rb, ptr_psi_term match_date)
save_resid
Definition: lefun.c:1398
long can_curry
Definition: def_glob.h:869
long curried
Definition: def_glob.h:868
#define deref_args(P, S)
Definition: def_macro.h:150
#define MAX_BUILT_INS
Maximum number of built_ins.
Definition: def_const.h:154
ptr_psi_term eval_copy(ptr_psi_term t, long heap_flag)
eval_copy
Definition: copy.c:196
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
ptr_choice_point choice_stack
Definition: def_glob.h:1026
#define STACK
Flag to indicate stack allocation.
Definition: def_const.h:331
static long c_funct ( )
static

c_funct

C_FUNCT Template for C built-in functions.

Definition at line 5331 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, curry(), deref_args, deref_ptr, get_two_args(), set_1_2, and TRUE.

5332 {
5333  long success=TRUE;
5334  ptr_psi_term arg1,arg2,funct;
5335 
5336 
5337  funct=aim->aaaa_1;
5338  deref_ptr(funct);
5339 
5340  get_two_args(funct->attr_list,&arg1,&arg2);
5341 
5342  if (arg1 && arg2) {
5343  deref_args(funct,set_1_2);
5344  }
5345  else
5346  curry();
5347 
5348  return success;
5349 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
void curry()
curry
Definition: lefun.c:174
#define set_1_2
Set constants for deref_args in lefun.c.
Definition: def_const.h:514
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_goal aim
Definition: def_glob.h:1024
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_node attr_list
Definition: def_struct.h:187
static long c_get ( )
static

c_get

C_GET Read the next character from the current input stream and return its Ascii code. This includes blank characters, so this predicate differs slightly from Edinburgh Prolog's get(X). At end of file, return the psi-term 'end_of_file'.

Definition at line 2992 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, deref, deref_args, deref_ptr, eof, eof_flag, Errorline(), FALSE, get_two_args(), heap_alloc(), i_check_out(), integer, NULL, prompt, push_goal(), read_char(), REAL, set_1, stack_psi_term(), TRUE, wl_psi_term::type, unify, and wl_psi_term::value_3.

2993 {
2994  long success=TRUE;
2995  ptr_psi_term arg1,arg2,g,t;
2996  long c;
2997 
2998  g=aim->aaaa_1;
2999  deref_ptr(g);
3000  get_two_args(g->attr_list,&arg1,&arg2);
3001  if (arg1) {
3002  deref(arg1);
3003  deref_args(g,set_1);
3004 
3005  if (eof_flag) {
3006  success=FALSE;
3007  }
3008  else {
3009  prompt="";
3010  c=read_char();
3011  t=stack_psi_term(0);
3012  if (c==EOF) {
3013  t->type=eof;
3014  eof_flag=TRUE;
3015  }
3016  else {
3017  t->type=integer;
3018  t->value_3=heap_alloc(sizeof(REAL)); /* 12.5 */
3019  * (REAL *)t->value_3 = (REAL) c;
3020  }
3021  }
3022 
3023  if (success) {
3024  push_goal(unify,t,arg1,NULL);
3025  (void)i_check_out(t);
3026  }
3027  }
3028  else {
3029  Errorline("argument missing in %P.\n",g);
3030  success=FALSE;
3031  }
3032 
3033  return success;
3034 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
long eof_flag
Definition: def_glob.h:853
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
#define NULL
Definition: def_const.h:533
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_definition eof
symbol in syntax module
Definition: def_glob.h:263
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define deref(P)
Definition: def_macro.h:147
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
GENERIC value_3
Definition: def_struct.h:186
ptr_goal aim
Definition: def_glob.h:1024
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
#define deref_args(P, S)
Definition: def_macro.h:150
char * prompt
Definition: def_glob.h:1018
long read_char()
read_char
Definition: token.c:680
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
long i_check_out(ptr_psi_term t)
i_check_out
Definition: lefun.c:1033
GENERIC heap_alloc(long s)
heap_alloc
Definition: memory.c:1616
static long c_get_choice ( )
static

c_get_choice

C_GET_CHOICE() Return the current state of the choice point stack (i.e., the time stamp of the current choice point).

Definition at line 1814 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_goal::bbbb_1, choice_stack, deref_args, deref_ptr, global_time_stamp, NULL, push_goal(), REAL, real_stack_psi_term(), set_empty, wl_choice_point::time_stamp, TRUE, and unify.

1815 {
1816  long gts,success=TRUE;
1817  ptr_psi_term funct,result;
1818 
1819  funct=aim->aaaa_1;
1820  deref_ptr(funct);
1821  result=aim->bbbb_1;
1822  deref_args(funct,set_empty);
1823  if (choice_stack)
1824  gts=choice_stack->time_stamp;
1825  else
1826  gts=global_time_stamp-1;
1827  /* gts=INIT_TIME_STAMP; PVR 11.2.94 */
1828  push_goal(unify,result,real_stack_psi_term(4,(REAL)gts),NULL);
1829 
1830  return success;
1831 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
ptr_psi_term real_stack_psi_term(long stat, REAL thereal)
real_stack_psi_term
Definition: lefun.c:48
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
#define set_empty
Set constants for deref_args in lefun.c.
Definition: def_const.h:493
#define NULL
Definition: def_const.h:533
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
unsigned long time_stamp
Definition: def_struct.h:247
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_goal aim
Definition: def_glob.h:1024
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
#define deref_args(P, S)
Definition: def_macro.h:150
unsigned long global_time_stamp
Definition: login.c:28
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_choice_point choice_stack
Definition: def_glob.h:1026
static long c_global ( )
static

c_global

C_GLOBAL Declare that a symbol is a global variable. Handle multiple arguments and initialization (the initialization term is evaluated). If there is an error anywhere in the declaration, then evaluate and declare nothing.

Definition at line 2561 of file built_ins.c.

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

2562 {
2563  int error=FALSE;
2564  int eval_2=FALSE;
2565  ptr_psi_term g;
2566 
2567  g=aim->aaaa_1;
2568  deref_ptr(g);
2569  if (g->attr_list) {
2570  /* Do error check of all arguments first: */
2571  global_error_check(g->attr_list, &error, &eval_2);
2572  if (eval_2) return !error;
2573  /* If no errors, then make the arguments global: */
2574  if (!error)
2575  global_tree(g->attr_list);
2576  } else {
2577  Errorline("argument(s) missing in %P\n",g);
2578  }
2579 
2580  return !error;
2581 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void global_error_check(ptr_node n, int *error, int *eval_2)
global_error_check
Definition: built_ins.c:2591
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define deref_ptr(P)
Definition: def_macro.h:100
void global_tree(ptr_node n)
global_tree
Definition: built_ins.c:2631
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_goal aim
Definition: def_glob.h:1024
ptr_node attr_list
Definition: def_struct.h:187
static long c_global_assign ( )
static

c_global_assign

C_GLOBAL_ASSIGN() This implements non-backtrackable assignment on global variables.

Closely modelled on 'c_assign', except that pointers to the heap are not copied again onto the heap.

Definition at line 4383 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, clear_copy(), wl_psi_term::coref, deref_args, deref_ptr, deref_rec, Errorline(), FALSE, get_two_args(), heap_pointer, inc_heap_copy(), push_psi_ptr_value(), set_1_2, and TRUE.

4384 {
4385  long success=FALSE;
4386  ptr_psi_term arg1,arg2,g; // ,perm,smallest;
4387  ptr_psi_term new;
4388 
4389  g=aim->aaaa_1;
4390  deref_ptr(g);
4391  get_two_args(g->attr_list,&arg1,&arg2);
4392  if (arg1 && arg2) {
4393  success=TRUE;
4394  deref_rec(arg1);
4395  deref_rec(arg2);
4396  deref_args(g,set_1_2);
4397  if (arg1!=arg2) {
4398 
4399  clear_copy();
4400  new=inc_heap_copy(arg2);
4401 
4402  if((GENERIC)arg1<heap_pointer) {
4403  push_psi_ptr_value(arg1,(GENERIC *)&(arg1->coref));
4404  arg1->coref= new;
4405  }
4406  else {
4407  *arg1= *new; /* Overwrite in-place */
4408  new->coref=arg1;
4409  }
4410  }
4411  }
4412  else
4413  Errorline("argument missing in %P.\n",g);
4414 
4415  return success;
4416 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
void clear_copy()
clear_copy
Definition: copy.c:53
GENERIC heap_pointer
used to allocate from heap - size allocated subtracted - adj for alignment
Definition: def_glob.h:55
void push_psi_ptr_value(ptr_psi_term q, GENERIC *p)
push_psi_ptr_value
Definition: login.c:474
#define deref_rec(P)
Definition: def_macro.h:149
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define set_1_2
Set constants for deref_args in lefun.c.
Definition: def_const.h:514
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_goal aim
Definition: def_glob.h:1024
ptr_psi_term coref
Definition: def_struct.h:188
ptr_psi_term inc_heap_copy(ptr_psi_term t)
inc_heap_copy
Definition: copy.c:206
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_node attr_list
Definition: def_struct.h:187
static long c_gt ( )
static

c_gt

C_GT Greater than.

Definition at line 439 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), deref, deref_args, deref_ptr, get_bool_value(), get_real_value(), get_two_args(), nonnum_warning(), REAL, residuate(), residuate2(), set_1_2, TRUE, and unify_bool_result().

440 {
441  long success=TRUE;
442  ptr_psi_term arg1,arg2,arg3,t;
443  long num1,num2,num3;
444  REAL val1,val2,val3;
445 
446  t=aim->aaaa_1;
447  deref_ptr(t);
448  get_two_args(t->attr_list,&arg1,&arg2);
449  arg3=aim->bbbb_1;
450 
451  if (arg1) {
452  deref(arg1);
453  success=get_real_value(arg1,&val1,&num1);
454  if(success && arg2) {
455  deref(arg2);
456  deref_args(t,set_1_2);
457  success=get_real_value(arg2,&val2,&num2);
458  }
459  }
460 
461  if(success)
462  if(arg1 && arg2) {
463  deref(arg3);
464  success=get_bool_value(arg3,&val3,&num3);
465  if(success)
466  switch(num1+num2*2+num3*4) {
467  case 0:
468  residuate2(arg1,arg2);
469  break;
470  case 1:
471  residuate(arg2);
472  break;
473  case 2:
474  residuate(arg1);
475  break;
476  case 3:
477  unify_bool_result(arg3,(val1>val2));
478  break;
479  case 4:
480  residuate2(arg1,arg2);
481  break;
482  case 5:
483  residuate(arg2);
484  break;
485  case 6:
486  residuate(arg1);
487  break;
488  case 7:
489  success=(val3==(REAL)(val1>val2));
490  break;
491  }
492  }
493  else
494  curry();
495 
496  nonnum_warning(t,arg1,arg2);
497  return success;
498 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
void unify_bool_result(ptr_psi_term t, long v)
unify_bool_result
Definition: built_ins.c:344
long get_real_value(ptr_psi_term t, REAL *v, long *n)
get_real_value
Definition: built_ins.c:261
void nonnum_warning(ptr_psi_term t, ptr_psi_term arg1, ptr_psi_term arg2)
nonnum_warning
Definition: error.c:953
void curry()
curry
Definition: lefun.c:174
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
#define set_1_2
Set constants for deref_args in lefun.c.
Definition: def_const.h:514
void residuate2(ptr_psi_term u, ptr_psi_term v)
residuate2
Definition: lefun.c:144
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define deref(P)
Definition: def_macro.h:147
ptr_goal aim
Definition: def_glob.h:1024
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_psi_term bbbb_1
Definition: def_struct.h:240
static long get_bool_value(ptr_psi_term t, REAL *v, long *n)
get_bool_value
Definition: built_ins.c:300
ptr_node attr_list
Definition: def_struct.h:187
static long c_gtoe ( )
static

c_gtoe

C_GTOE Greater than or equal.

Definition at line 701 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), deref, deref_args, deref_ptr, get_bool_value(), get_real_value(), get_two_args(), nonnum_warning(), REAL, residuate(), residuate2(), set_1_2, TRUE, and unify_bool_result().

702 {
703  long success=TRUE;
704  ptr_psi_term arg1,arg2,arg3,t;
705  long num1,num2,num3;
706  REAL val1,val2,val3;
707 
708  t=aim->aaaa_1;
709  deref_ptr(t);
710  get_two_args(t->attr_list,&arg1,&arg2);
711  arg3=aim->bbbb_1;
712 
713  if(arg1) {
714  deref(arg1);
715  success=get_real_value(arg1,&val1,&num1);
716  if(success && arg2) {
717  deref(arg2);
718  deref_args(t,set_1_2);
719  success=get_real_value(arg2,&val2,&num2);
720  }
721  }
722 
723  if(success)
724  if(arg1 && arg2) {
725  deref(arg3);
726  success=get_bool_value(arg3,&val3,&num3);
727  if(success)
728  switch(num1+num2*2+num3*4) {
729  case 0:
730  residuate2(arg1,arg2);
731  break;
732  case 1:
733  residuate(arg2);
734  break;
735  case 2:
736  residuate(arg1);
737  break;
738  case 3:
739  unify_bool_result(arg3,(val1>=val2));
740  break;
741  case 4:
742  residuate2(arg1,arg2);
743  break;
744  case 5:
745  residuate(arg2);
746  break;
747  case 6:
748  residuate(arg1);
749  break;
750  case 7:
751  success=(val3==(REAL)(val1>=val2));
752  break;
753  }
754  }
755  else
756  curry();
757 
758  nonnum_warning(t,arg1,arg2);
759  return success;
760 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
void unify_bool_result(ptr_psi_term t, long v)
unify_bool_result
Definition: built_ins.c:344
long get_real_value(ptr_psi_term t, REAL *v, long *n)
get_real_value
Definition: built_ins.c:261
void nonnum_warning(ptr_psi_term t, ptr_psi_term arg1, ptr_psi_term arg2)
nonnum_warning
Definition: error.c:953
void curry()
curry
Definition: lefun.c:174
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
#define set_1_2
Set constants for deref_args in lefun.c.
Definition: def_const.h:514
void residuate2(ptr_psi_term u, ptr_psi_term v)
residuate2
Definition: lefun.c:144
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define deref(P)
Definition: def_macro.h:147
ptr_goal aim
Definition: def_glob.h:1024
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_psi_term bbbb_1
Definition: def_struct.h:240
static long get_bool_value(ptr_psi_term t, REAL *v, long *n)
get_bool_value
Definition: built_ins.c:300
ptr_node attr_list
Definition: def_struct.h:187
long c_halt ( )

c_halt

C_HALT Exit the Wild_Life interpreter.

Definition at line 2208 of file built_ins.c.

References exit_life(), and TRUE.

2209 {
2210  exit_life(TRUE);
2211 }
void exit_life(long nl_flag)
exit_life
Definition: built_ins.c:2219
#define TRUE
Standard boolean.
Definition: def_const.h:268
static long c_implies ( )
static

c_implies

C_IMPLIES() See c_freeze_inner.

Definition at line 4718 of file built_ins.c.

References c_freeze_inner(), and FALSE.

4719 {
4720  return c_freeze_inner(FALSE);
4721 }
static long c_freeze_inner(long freeze_flag)
c_freeze_inner
Definition: built_ins.c:4597
#define FALSE
Standard boolean.
Definition: def_const.h:275
long c_initrandom ( )

c_initrandom

C_INITRANDOM Uses its integer argument to initialize the random number generator, which is the Unix random() function.

Definition at line 6032 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_node::data, deref, deref_args, deref_ptr, FALSE, FEATCMP, find(), integer, one, overlap_type(), residuate(), set_1, TRUE, wl_psi_term::type, and wl_psi_term::value_3.

6033 {
6034  ptr_psi_term t;
6035  ptr_node n1;
6036  long success=TRUE;
6037  long all_args=TRUE;
6038  // long c_result;
6039  ptr_psi_term arg1;
6040  long c_arg1;
6041 
6042  t=aim->aaaa_1;
6043  deref_ptr(t);
6044 
6045  /* Evaluate all arguments first: */
6046  n1=find(FEATCMP,one,t->attr_list);
6047  if (n1) {
6048  arg1= (ptr_psi_term )n1->data;
6049  deref(arg1);
6050  }
6051  deref_args(t,set_1);
6052 
6053  if (success) {
6054  if (n1) {
6055  if (overlap_type(arg1->type,integer))
6056  if (arg1->value_3)
6057  c_arg1= (long)(* (double *)(arg1->value_3));
6058  else {
6059  residuate(arg1);
6060  all_args=FALSE;
6061  }
6062  else
6063  success=FALSE;
6064  }
6065  else {
6066  all_args=FALSE;
6067  }
6068  }
6069 
6070 #ifdef SOLARIS
6071  if (success && all_args) randomseed=c_arg1;
6072 #else
6073  if (success && all_args) srandom(c_arg1);
6074 #endif
6075 
6076  return success;
6077 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
long overlap_type(ptr_definition t1, ptr_definition t2)
overlap_type
Definition: types.c:1579
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define deref(P)
Definition: def_macro.h:147
GENERIC value_3
Definition: def_struct.h:186
ptr_goal aim
Definition: def_glob.h:1024
char * one
Definition: def_glob.h:891
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
static long c_int2string ( )
static

c_int2string

C_INT2STRING(P) Convert an integer psi-term into a string representing its value.

Definition at line 4943 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), deref, deref_args, deref_ptr, Errorline(), FALSE, get_one_arg(), heap_copy_string(), integer, NULL, overlap_type(), push_goal(), quoted_string, REAL, residuate(), set_1, stack_psi_term(), STRLEN, TRUE, wl_psi_term::type, unify, and wl_psi_term::value_3.

4944 {
4945  char val[STRLEN]; /* Big enough for a _long_ number */
4946  long success=TRUE,i;
4947  ptr_psi_term arg1, /* arg3, */ funct,result,t;
4948  REAL the_int,next,neg;
4949 
4950  funct=aim->aaaa_1;
4951  deref_ptr(funct);
4952  result=aim->bbbb_1;
4953  deref(result);
4954 
4955  get_one_arg(funct->attr_list,&arg1);
4956  if (arg1) {
4957  deref(arg1);
4958  deref_args(funct,set_1);
4959  if (overlap_type(arg1->type,integer)) {
4960  if (arg1->value_3) {
4961  the_int = *(REAL *)arg1->value_3;
4962 
4963  if (the_int!=floor(the_int)) return FALSE;
4964 
4965  neg = (the_int<0.0);
4966  if (neg) the_int = -the_int;
4967  i=STRLEN;
4968  i--;
4969  val[i]=0;
4970  do {
4971  i--;
4972  if (i<=0) {
4973  Errorline("internal buffer too small for int2str(%P).\n",arg1);
4974  return FALSE;
4975  }
4976  next = floor(the_int/10);
4977  val[i]= '0' + (unsigned long) (the_int-next*10);
4978  the_int = next;
4979  } while (the_int);
4980 
4981  if (neg) { i--; val[i]='-'; }
4982  t=stack_psi_term(0);
4983  t->type=quoted_string;
4984  t->value_3=(GENERIC)heap_copy_string(&val[i]);
4985  push_goal(unify,t,result,NULL);
4986  }
4987  else
4988  residuate(arg1);
4989  }
4990  else
4991  success=FALSE;
4992  }
4993  else
4994  curry();
4995 
4996  return success;
4997 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
void get_one_arg(ptr_node t, ptr_psi_term *a)
get_one_arg
Definition: login.c:99
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
long overlap_type(ptr_definition t1, ptr_definition t2)
overlap_type
Definition: types.c:1579
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define deref_ptr(P)
Definition: def_macro.h:100
char * heap_copy_string(char *s)
heap_copy_string
Definition: trees.c:172
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define deref(P)
Definition: def_macro.h:147
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
GENERIC value_3
Definition: def_struct.h:186
ptr_goal aim
Definition: def_glob.h:1024
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
#define deref_args(P, S)
Definition: def_macro.h:150
#define STRLEN
Maximum size of file names and input tokens (which includes input strings) (Note: calculated tokens c...
Definition: def_const.h:162
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
static long c_is_function ( )
static

c_is_function

C_IS_FUNCTION Succeed iff argument is a function (built-in or user-defined).

Definition at line 1501 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), deref, deref_args, deref_ptr, function_it, get_one_arg(), lf_false, lf_true, NULL, push_goal(), resid_aim, set_1, stack_psi_term(), TRUE, wl_psi_term::type, wl_definition::type_def, and unify.

1502 {
1503  long success=TRUE;
1504  ptr_psi_term arg1,result,g,other;
1505 
1506  g=aim->aaaa_1;
1507  deref_ptr(g);
1508  result=aim->bbbb_1;
1509  deref(result);
1510  get_one_arg(g->attr_list,&arg1);
1511  if (arg1) {
1512  deref(arg1);
1513  deref_args(g,set_1);
1514  other=stack_psi_term(4); /* 19.11 */
1516  resid_aim=NULL;
1517  push_goal(unify,result,other,NULL);
1518  }
1519  else {
1520  curry();
1521  /* Errorline("argument missing in %P.\n",t); */
1522  /* return c_abort(); */
1523  }
1524 
1525  return success;
1526 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
#define function_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1408
struct wl_definition * def_type
Definition: def_struct.h:60
ptr_definition lf_false
symbol in bi module
Definition: def_glob.h:284
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
def_type type_def
Definition: def_struct.h:153
void get_one_arg(ptr_node t, ptr_psi_term *a)
get_one_arg
Definition: login.c:99
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
ptr_goal resid_aim
Definition: def_glob.h:865
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define deref(P)
Definition: def_macro.h:147
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
ptr_goal aim
Definition: def_glob.h:1024
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_definition lf_true
symbol in bi module
Definition: def_glob.h:410
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
static long c_is_predicate ( )
static

c_is_predicate

C_IS_PREDICATE Succeed iff argument is a predicate (built-in or user-defined).

Definition at line 1536 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), deref, deref_args, deref_ptr, get_one_arg(), lf_false, lf_true, NULL, predicate_it, push_goal(), resid_aim, set_1, stack_psi_term(), TRUE, wl_psi_term::type, wl_definition::type_def, and unify.

1537 {
1538  long success=TRUE;
1539  ptr_psi_term arg1,result,g,other;
1540 
1541  g=aim->aaaa_1;
1542  deref_ptr(g);
1543  result=aim->bbbb_1;
1544  deref(result);
1545  get_one_arg(g->attr_list,&arg1);
1546  if (arg1) {
1547  deref(arg1);
1548  deref_args(g,set_1);
1549  other=stack_psi_term(4); /* 19.11 */
1551  resid_aim=NULL;
1552  push_goal(unify,result,other,NULL);
1553  }
1554  else {
1555  curry();
1556  /* Errorline("argument missing in %P.\n",t); */
1557  /* return c_abort(); */
1558  }
1559 
1560  return success;
1561 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
struct wl_definition * def_type
Definition: def_struct.h:60
ptr_definition lf_false
symbol in bi module
Definition: def_glob.h:284
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
def_type type_def
Definition: def_struct.h:153
#define predicate_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1401
void get_one_arg(ptr_node t, ptr_psi_term *a)
get_one_arg
Definition: login.c:99
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
ptr_goal resid_aim
Definition: def_glob.h:865
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define deref(P)
Definition: def_macro.h:147
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
ptr_goal aim
Definition: def_glob.h:1024
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_definition lf_true
symbol in bi module
Definition: def_glob.h:410
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
static long c_is_sort ( )
static

c_is_sort

C_IS_SORT Succeed iff argument is a sort (built-in or user-defined).

Definition at line 1570 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), deref, deref_args, deref_ptr, get_one_arg(), lf_false, lf_true, NULL, push_goal(), resid_aim, set_1, stack_psi_term(), TRUE, wl_psi_term::type, wl_definition::type_def, type_it, and unify.

1571 {
1572  long success=TRUE;
1573  ptr_psi_term arg1,result,g,other;
1574 
1575  g=aim->aaaa_1;
1576  deref_ptr(g);
1577  result=aim->bbbb_1;
1578  deref(result);
1579  get_one_arg(g->attr_list,&arg1);
1580  if (arg1) {
1581  deref(arg1);
1582  deref_args(g,set_1);
1583  other=stack_psi_term(4); /* 19.11 */
1584  other->type=(arg1->type->type_def==(def_type)type_it)?lf_true:lf_false;
1585  resid_aim=NULL;
1586  push_goal(unify,result,other,NULL);
1587  }
1588  else {
1589  curry();
1590  /* Errorline("argument missing in %P.\n",t); */
1591  /* return c_abort(); */
1592  }
1593 
1594  return success;
1595 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
struct wl_definition * def_type
Definition: def_struct.h:60
ptr_definition lf_false
symbol in bi module
Definition: def_glob.h:284
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
def_type type_def
Definition: def_struct.h:153
void get_one_arg(ptr_node t, ptr_psi_term *a)
get_one_arg
Definition: login.c:99
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
ptr_goal resid_aim
Definition: def_glob.h:865
#define type_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1415
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define deref(P)
Definition: def_macro.h:147
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
ptr_goal aim
Definition: def_glob.h:1024
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_definition lf_true
symbol in bi module
Definition: def_glob.h:410
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
static long c_listing ( )
static

c_listing

C_LISTING List the definition of a predicate or a function, and the own constraints of a type (i.e. the non-inherited constraints).

Definition at line 5172 of file built_ins.c.

References wl_goal::aaaa_1, wl_pair_list::aaaa_2, aim, wl_psi_term::attr_list, wl_pair_list::bbbb_2, wl_node::data, deref_ptr, display_psi_stream(), Errorline(), FALSE, funcsym, function_it, get_two_args(), global_it, wl_definition::global_value, has_rules(), is_built_in(), wl_definition::keyword, list_special(), listing_pred_write(), new_psi_term(), wl_pair_list::next, NULL, one_attr(), output_stream, outputline(), predicate_it, predsym, quoted_string, wl_definition::rule, such_that, wl_keyword::symbol, TRUE, wl_psi_term::type, wl_definition::type_def, type_it, typesym, and wl_psi_term::value_3.

5173 {
5174  long success=TRUE;
5175  ptr_psi_term arg1,arg2,g;
5176  def_type fp;
5177  ptr_pair_list r;
5178  ptr_node n;
5179  ptr_psi_term t, t2, *a1, *a2, *a3;
5180  char *s1,*s2;
5181 
5182  g=aim->aaaa_1;
5183  deref_ptr(g);
5184  get_two_args(g->attr_list,&arg1,&arg2);
5185  if (arg1) {
5186  deref_ptr(arg1);
5187  list_special(arg1);
5188  fp=arg1->type->type_def;
5189  r=arg1->type->rule;
5190  if (is_built_in(r) || !has_rules(r)) {
5191 
5192  if (is_built_in(r)) {
5193  s1="built-in ";
5194  s2="";
5195  }
5196  else {
5197  s1="user-defined ";
5198  s2=" with an empty definition";
5199  }
5200  switch ((long)fp) {
5201  case (long)function_it:
5202  fprintf(output_stream,"%% '%s' is a %sfunction%s.\n",
5203  arg1->type->keyword->symbol,s1,s2);
5204  break;
5205  case (long)predicate_it:
5206  fprintf(output_stream,"%% '%s' is a %spredicate%s.\n",
5207  arg1->type->keyword->symbol,s1,s2);
5208  break;
5209  case (long)type_it:
5210  if (arg1->value_3) {
5211  fprintf(output_stream,"%% ");
5212  if (arg1->type!=quoted_string) fprintf(output_stream,"'");
5213  display_psi_stream(arg1);
5214  if (arg1->type!=quoted_string) fprintf(output_stream,"'");
5215  fprintf(output_stream," is a value of sort '%s'.\n",
5216  arg1->type->keyword->symbol);
5217  }
5218  break;
5219 
5220  case (long)global_it: /* RM: Feb 9 1993 */
5221  fprintf(output_stream,"%% ");
5222  outputline("'%s' is a %sglobal variable worth %P.\n",
5223  arg1->type->keyword->symbol,
5224  s1,
5225  arg1->type->global_value);
5226  break;
5227 
5228 #ifdef CLIFE
5229  case (long)block: /* AA: Mar 10 1993 */
5230  fprintf(output_stream,"%% '%s' is a %block.\n",
5231  arg1->type->keyword->symbol,"","");
5232 #endif
5233 
5234  default:
5235  fprintf(output_stream,"%% '%s' is undefined.\n", arg1->type->keyword->symbol);
5236  }
5237  }
5238  else {
5239  if (fp==(def_type)type_it || fp==(def_type)function_it || fp==(def_type)predicate_it) {
5240  n = one_attr();
5241  if (fp==(def_type)function_it)
5242  t = new_psi_term(2, funcsym, &a1, &a2);
5243  else if (fp==(def_type)predicate_it)
5244  t = new_psi_term(2, predsym, &a1, &a2);
5245  else { /* fp==type */
5246  t = new_psi_term(1, typesym, &a3, &a2); /* a2 is a dummy */
5247  t2 = new_psi_term(2, such_that, &a1, &a2);
5248  }
5249  n->data = (GENERIC) t;
5250  while (r) {
5251  *a1 = r->aaaa_2; /* Func, pred, or type */
5252  *a2 = r->bbbb_2;
5253  if (r->aaaa_2) {
5254  /* Handle an attribute constraint with no predicate: */
5255  if (fp==(def_type)type_it) { if (r->bbbb_2==NULL) *a3 = r->aaaa_2; else *a3 = t2; }
5256  listing_pred_write(n, (fp==(def_type)function_it)||(fp==(def_type)type_it));
5257  fprintf(output_stream,".\n");
5258  }
5259  r = r->next;
5260  }
5261  /* fprintf(output_stream,"\n"); */
5262  /* fflush(output_stream); */
5263  }
5264  else {
5265  success=FALSE;
5266  Errorline("argument of %P must be a predicate, function, or sort.\n",g);
5267  }
5268  }
5269  }
5270  else {
5271  success=FALSE;
5272  Errorline("argument missing in %P.\n",g);
5273  }
5274 
5275  return success;
5276 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
ptr_psi_term aaaa_2
Definition: def_struct.h:205
#define function_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1408
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
void listing_pred_write(ptr_node n, long fflag)
listing_pred_write
Definition: print.c:1438
void list_special(ptr_psi_term t)
list_special
Definition: built_ins.c:5131
ptr_pair_list next
Definition: def_struct.h:207
void display_psi_stream(ptr_psi_term t)
display_psi_stream
Definition: print.c:1564
ptr_psi_term new_psi_term(long numargs, ptr_definition typ, ptr_psi_term **a1, ptr_psi_term **a2)
new_psi_term
Definition: built_ins.c:5064
def_type type_def
Definition: def_struct.h:153
#define predicate_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1401
ptr_keyword keyword
Definition: def_struct.h:147
#define global_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1422
GENERIC data
Definition: def_struct.h:201
#define NULL
Definition: def_const.h:533
char * symbol
Definition: def_struct.h:118
ptr_definition funcsym
symbol in syntax module
Definition: def_glob.h:291
#define type_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1415
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
long has_rules(ptr_pair_list r)
has_rules
Definition: built_ins.c:5101
ptr_pair_list rule
Definition: def_struct.h:148
ptr_psi_term global_value
Definition: def_struct.h:159
#define FALSE
Standard boolean.
Definition: def_const.h:275
long is_built_in(ptr_pair_list r)
is_built_in
Definition: built_ins.c:5118
ptr_definition such_that
symbol in syntax module
Definition: def_glob.h:396
ptr_definition typesym
symbol in syntax module
Definition: def_glob.h:431
GENERIC value_3
Definition: def_struct.h:186
ptr_psi_term bbbb_2
Definition: def_struct.h:206
ptr_goal aim
Definition: def_glob.h:1024
void outputline(char *format,...)
void outputline(char *format,...)
Definition: error.c:101
ptr_node one_attr()
one_attr
Definition: built_ins.c:5042
FILE * output_stream
Definition: def_glob.h:1017
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
ptr_definition predsym
symbol in syntax module
Definition: def_glob.h:354
static long c_load ( )
static

c_load

C_LOAD Load a file. This load accepts and executes any queries in the loaded file, including calls to user-defined predicates and other load predicates.

Definition at line 1774 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, deref, deref_args, deref_ptr, Errorline(), FALSE, file_date, get_two_args(), input_state, load, open_input_file(), psi_to_string(), push_goal(), and set_1.

1775 {
1776  long success=FALSE;
1777  ptr_psi_term arg1,arg2,t;
1778  char *fn;
1779  t=aim->aaaa_1;
1780  deref_ptr(t);
1781  get_two_args(t->attr_list,&arg1,&arg2);
1782  if(arg1) {
1783  deref(arg1);
1784  deref_args(t,set_1);
1785  if (psi_to_string(arg1,&fn)) {
1786  success=open_input_file(fn);
1787  if (success) {
1788  file_date+=2;
1790  file_date+=2;
1791  }
1792  }
1793  else {
1794  Errorline("bad file name in %P.\n",t);
1795  success=FALSE;
1796  }
1797  }
1798  else {
1799  Errorline("no file name in %P.\n",t);
1800  success=FALSE;
1801  }
1802 
1803  return success;
1804 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
long file_date
Definition: def_glob.h:1034
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
ptr_psi_term input_state
Definition: def_glob.h:856
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define deref_ptr(P)
Definition: def_macro.h:100
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define deref(P)
Definition: def_macro.h:147
ptr_goal aim
Definition: def_glob.h:1024
#define load
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1156
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_node attr_list
Definition: def_struct.h:187
long open_input_file(char *file)
open_input_file
Definition: token.c:594
long psi_to_string(ptr_psi_term t, char **fn)
psi_to_string
Definition: built_ins.c:146
static long c_logical_main ( long  sel)
static

c_logical_main

Parameters
sel- long sel

Main routine to handle the and & or functions. sel = TRUE (for and) or FALSE (for or)

Definition at line 928 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), deref, deref_args, deref_ptr, Errorline(), FALSE, get_bool(), get_two_args(), matches(), NULL, push_goal(), residuate(), set_1_2, TRUE, wl_psi_term::type, UNDEF, unify, unify_bool(), and unify_bool_result().

929 {
930  long success=TRUE;
931  ptr_psi_term funct,arg1,arg2,arg3;
932  long sm1, sm2, sm3;
933  long a1comp, a2comp, a3comp;
934  long a1, a2, a3;
935 
936  funct=aim->aaaa_1;
937  deref_ptr(funct);
938  get_two_args(funct->attr_list,&arg1,&arg2);
939  if (arg1 && arg2) {
940  deref(arg1);
941  deref(arg2);
942  deref_args(funct,set_1_2);
943  arg3=aim->bbbb_1;
944  deref(arg3);
945 
946  a1comp = matches(arg1->type,boolean,&sm1);
947  a2comp = matches(arg2->type,boolean,&sm2);
948  a3comp = matches(arg3->type,boolean,&sm3);
949  if (a1comp && a2comp && a3comp) {
950  a1 = get_bool(arg1->type);
951  a2 = get_bool(arg2->type);
952  a3 = get_bool(arg3->type);
953  if (a1== !sel || a2== !sel) {
954  unify_bool_result(arg3,!sel);
955  } else if (a1==sel) {
956  /* tmp=stack_psi_term(4); */
957  /* tmp->type=boolean; */
958  /* push_goal(unify,tmp,arg3,NULL); */
959  push_goal(unify,arg2,arg3,(GENERIC)NULL);
960  } else if (a2==sel) {
961  /* tmp=stack_psi_term(4); */
962  /* tmp->type=boolean; */
963  /* push_goal(unify,tmp,arg3,NULL); */
964  push_goal(unify,arg1,arg3,(GENERIC)NULL);
965  } else if (a3==sel) {
966  unify_bool_result(arg1,sel);
967  unify_bool_result(arg2,sel);
968  } else if (arg1==arg2) {
969  /* tmp=stack_psi_term(4); */
970  /* tmp->type=boolean; */
971  /* push_goal(unify,tmp,arg3,NULL); */
972  push_goal(unify,arg1,arg3,(GENERIC)NULL);
973  } else {
974  if (a1==UNDEF) residuate(arg1);
975  if (a2==UNDEF) residuate(arg2);
976  if (a3==UNDEF) residuate(arg3);
977  }
978  if (!sm1) unify_bool(arg1);
979  if (!sm2) unify_bool(arg2);
980  if (!sm3) unify_bool(arg3);
981  }
982  else {
983  success=FALSE;
984  Errorline("Non-boolean argument or result in '%P'.\n",funct);
985  }
986  }
987  else
988  curry();
989 
990  return success;
991 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
void unify_bool_result(ptr_psi_term t, long v)
unify_bool_result
Definition: built_ins.c:344
static void unify_bool(ptr_psi_term arg)
unify_bool
Definition: built_ins.c:911
long matches(ptr_definition t1, ptr_definition t2, long *smaller)
matches
Definition: types.c:1666
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define set_1_2
Set constants for deref_args in lefun.c.
Definition: def_const.h:514
#define UNDEF
For LIFE boolean calculation built-in.
Definition: def_const.h:288
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define deref(P)
Definition: def_macro.h:147
ptr_goal aim
Definition: def_glob.h:1024
static long get_bool(ptr_definition typ)
get_bool
Definition: built_ins.c:898
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
static long c_lt ( )
static

c_lt C_LT Less than.

Definition at line 633 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), deref, deref_args, deref_ptr, get_bool_value(), get_real_value(), get_two_args(), nonnum_warning(), REAL, residuate(), residuate2(), set_1_2, TRUE, and unify_bool_result().

634 {
635  long success=TRUE;
636  ptr_psi_term arg1,arg2,arg3,t;
637  long num1,num2,num3;
638  REAL val1,val2,val3;
639 
640  t=aim->aaaa_1;
641  deref_ptr(t);
642  get_two_args(t->attr_list,&arg1,&arg2);
643  arg3=aim->bbbb_1;
644 
645  if(arg1) {
646  deref(arg1);
647  success=get_real_value(arg1,&val1,&num1);
648  if(success && arg2) {
649  deref(arg2);
650  deref_args(t,set_1_2);
651  success=get_real_value(arg2,&val2,&num2);
652  }
653  }
654 
655  if(success)
656  if(arg1 && arg2) {
657  deref(arg3);
658  success=get_bool_value(arg3,&val3,&num3);
659  if(success)
660  switch(num1+num2*2+num3*4) {
661  case 0:
662  residuate2(arg1,arg2);
663  break;
664  case 1:
665  residuate(arg2);
666  break;
667  case 2:
668  residuate(arg1);
669  break;
670  case 3:
671  unify_bool_result(arg3,(val1<val2));
672  break;
673  case 4:
674  residuate2(arg1,arg2);
675  break;
676  case 5:
677  residuate(arg2);
678  break;
679  case 6:
680  residuate(arg1);
681  break;
682  case 7:
683  success=(val3==(REAL)(val1<val2));
684  break;
685  }
686  }
687  else
688  curry();
689 
690  nonnum_warning(t,arg1,arg2);
691  return success;
692 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
void unify_bool_result(ptr_psi_term t, long v)
unify_bool_result
Definition: built_ins.c:344
long get_real_value(ptr_psi_term t, REAL *v, long *n)
get_real_value
Definition: built_ins.c:261
void nonnum_warning(ptr_psi_term t, ptr_psi_term arg1, ptr_psi_term arg2)
nonnum_warning
Definition: error.c:953
void curry()
curry
Definition: lefun.c:174
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
#define set_1_2
Set constants for deref_args in lefun.c.
Definition: def_const.h:514
void residuate2(ptr_psi_term u, ptr_psi_term v)
residuate2
Definition: lefun.c:144
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define deref(P)
Definition: def_macro.h:147
ptr_goal aim
Definition: def_glob.h:1024
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_psi_term bbbb_1
Definition: def_struct.h:240
static long get_bool_value(ptr_psi_term t, REAL *v, long *n)
get_bool_value
Definition: built_ins.c:300
ptr_node attr_list
Definition: def_struct.h:187
static long c_ltoe ( )
static

c_ltoe

C_LTOE Less than or equal.

Definition at line 769 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), deref, deref_args, deref_ptr, get_bool_value(), get_real_value(), get_two_args(), nonnum_warning(), REAL, residuate(), residuate2(), set_1_2, TRUE, and unify_bool_result().

770 {
771  long success=TRUE;
772  ptr_psi_term arg1,arg2,arg3,t;
773  long num1,num2,num3;
774  REAL val1,val2,val3;
775 
776  t=aim->aaaa_1;
777  deref_ptr(t);
778  get_two_args(t->attr_list,&arg1,&arg2);
779  arg3=aim->bbbb_1;
780 
781  if(arg1) {
782  deref(arg1);
783  success=get_real_value(arg1,&val1,&num1);
784  if(success && arg2) {
785  deref(arg2);
786  deref_args(t,set_1_2);
787  success=get_real_value(arg2,&val2,&num2);
788  }
789  }
790 
791  if(success)
792  if(arg1 && arg2) {
793  deref(arg3);
794  success=get_bool_value(arg3,&val3,&num3);
795  if(success)
796  switch(num1+num2*2+num3*4) {
797  case 0:
798  residuate2(arg1,arg2);
799  break;
800  case 1:
801  residuate(arg2);
802  break;
803  case 2:
804  residuate(arg1);
805  break;
806  case 3:
807  unify_bool_result(arg3,(val1<=val2));
808  break;
809  case 4:
810  residuate2(arg1,arg2);
811  break;
812  case 5:
813  residuate(arg2);
814  break;
815  case 6:
816  residuate(arg1);
817  break;
818  case 7:
819  success=(val3==(REAL)(val1<=val2));
820  break;
821  }
822  }
823  else
824  curry();
825 
826  nonnum_warning(t,arg1,arg2);
827  return success;
828 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
void unify_bool_result(ptr_psi_term t, long v)
unify_bool_result
Definition: built_ins.c:344
long get_real_value(ptr_psi_term t, REAL *v, long *n)
get_real_value
Definition: built_ins.c:261
void nonnum_warning(ptr_psi_term t, ptr_psi_term arg1, ptr_psi_term arg2)
nonnum_warning
Definition: error.c:953
void curry()
curry
Definition: lefun.c:174
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
#define set_1_2
Set constants for deref_args in lefun.c.
Definition: def_const.h:514
void residuate2(ptr_psi_term u, ptr_psi_term v)
residuate2
Definition: lefun.c:144
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define deref(P)
Definition: def_macro.h:147
ptr_goal aim
Definition: def_glob.h:1024
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_psi_term bbbb_1
Definition: def_struct.h:240
static long get_bool_value(ptr_psi_term t, REAL *v, long *n)
get_bool_value
Definition: built_ins.c:300
ptr_node attr_list
Definition: def_struct.h:187
static long c_module_name ( )
static

c_module_name

C_MODULE_NAME Return the module in which a term resides.

Definition at line 5660 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), deref_ptr, get_two_args(), heap_copy_string(), wl_definition::keyword, wl_keyword::module, wl_module::module_name, NULL, push_goal(), quoted_string, stack_psi_term(), TRUE, wl_psi_term::type, unify, and wl_psi_term::value_3.

5661 {
5662  long success=TRUE;
5663  ptr_psi_term arg1,arg2,funct,result;
5664 
5665 
5666  funct=aim->aaaa_1;
5667  result=aim->bbbb_1;
5668  deref_ptr(funct);
5669  deref_ptr(result);
5670 
5671  get_two_args(funct->attr_list,&arg1,&arg2);
5672 
5673  if (arg1) {
5674  deref_ptr(arg1);
5675  arg2=stack_psi_term(0);
5676  arg2->type=quoted_string;
5678  push_goal(unify,arg2,result,NULL);
5679  }
5680  else
5681  curry();
5682 
5683  return success;
5684 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
ptr_keyword keyword
Definition: def_struct.h:147
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define deref_ptr(P)
Definition: def_macro.h:100
char * heap_copy_string(char *s)
heap_copy_string
Definition: trees.c:172
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
GENERIC value_3
Definition: def_struct.h:186
ptr_goal aim
Definition: def_glob.h:1024
char * module_name
Definition: def_struct.h:106
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
ptr_module module
Definition: def_struct.h:117
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
static long c_non_strict ( )
static

c_non_strict

C_NON_STRICT() Mark that the function or predicate's arguments are not evaluated when the function or predicate is called.

Definition at line 1680 of file built_ins.c.

References wl_goal::aaaa_1, aim, assert_args_not_eval(), wl_psi_term::attr_list, deref_ptr, and TRUE.

1681 {
1682  ptr_psi_term t=aim->aaaa_1;
1683 
1684  deref_ptr(t);
1685  /* mark_quote(t); 14.9 */
1687  return TRUE;
1688 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_goal aim
Definition: def_glob.h:1024
ptr_node attr_list
Definition: def_struct.h:187
void assert_args_not_eval(ptr_node n)
assert_args_not_eval
Definition: types.c:294
static long c_nonvar ( )
static

c_nonvar

C_NONVAR Return lf_true/false iff argument is not/is '@' (top with no attributes).

Definition at line 1467 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), deref, deref_args, deref_ptr, get_one_arg(), lf_false, lf_true, NULL, push_goal(), resid_aim, set_1, stack_psi_term(), top, TRUE, wl_psi_term::type, and unify.

1468 {
1469  long success=TRUE;
1470  ptr_psi_term arg1,result,g,other;
1471 
1472  g=aim->aaaa_1;
1473  deref_ptr(g);
1474  result=aim->bbbb_1;
1475  deref(result);
1476  get_one_arg(g->attr_list,&arg1);
1477  if (arg1) {
1478  deref(arg1);
1479  deref_args(g,set_1);
1480  other=stack_psi_term(4); /* 19.11 */
1481  other->type=((arg1->type==top)&&(arg1->attr_list==NULL))?lf_false:lf_true;
1482  resid_aim=NULL;
1483  push_goal(unify,result,other,NULL);
1484  }
1485  else {
1486  curry();
1487  /* Errorline("argument missing in %P.\n",t); */
1488  /* return c_abort(); */
1489  }
1490 
1491  return success;
1492 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
ptr_definition lf_false
symbol in bi module
Definition: def_glob.h:284
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
void get_one_arg(ptr_node t, ptr_psi_term *a)
get_one_arg
Definition: login.c:99
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
ptr_goal resid_aim
Definition: def_glob.h:865
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define deref(P)
Definition: def_macro.h:147
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
ptr_goal aim
Definition: def_glob.h:1024
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
ptr_definition top
symbol in syntax module
Definition: def_glob.h:403
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_definition lf_true
symbol in bi module
Definition: def_glob.h:410
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
static long c_not ( )
static

c_not

C_NOT Logical not. This function does all possible local propagations.

Definition at line 1026 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), deref, deref_args, deref_ptr, Errorline(), FALSE, get_bool(), get_one_arg(), matches(), residuate(), set_1, TRUE, wl_psi_term::type, UNDEF, unify_bool(), and unify_bool_result().

1027 {
1028  long success=TRUE;
1029  ptr_psi_term funct,arg1,arg2;
1030  long sm1, sm2;
1031  long a1comp, a2comp;
1032  long a1, a2;
1033 
1034  funct=aim->aaaa_1;
1035  deref_ptr(funct);
1036  get_one_arg(funct->attr_list,&arg1);
1037  if (arg1) {
1038  deref(arg1);
1039  deref_args(funct,set_1);
1040  arg2=aim->bbbb_1;
1041  deref(arg2);
1042 
1043  a1comp = matches(arg1->type,boolean,&sm1);
1044  a2comp = matches(arg2->type,boolean,&sm2);
1045  if (a1comp && a2comp) {
1046  a1 = get_bool(arg1->type);
1047  a2 = get_bool(arg2->type);
1048  if (a1==TRUE || a1==FALSE) {
1049  unify_bool_result(arg2,!a1);
1050  } else if (a2==TRUE || a2==FALSE) {
1051  unify_bool_result(arg1,!a2);
1052  } else if (arg1==arg2) {
1053  success=FALSE;
1054  } else {
1055  if (a1==UNDEF) residuate(arg1);
1056  if (a2==UNDEF) residuate(arg2);
1057  }
1058  if (!sm1) unify_bool(arg1);
1059  if (!sm2) unify_bool(arg2);
1060  }
1061  else {
1062  success=FALSE;
1063  Errorline("Non-boolean argument or result in '%P'.\n",funct);
1064  }
1065  }
1066  else
1067  curry();
1068 
1069  return success;
1070 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
void unify_bool_result(ptr_psi_term t, long v)
unify_bool_result
Definition: built_ins.c:344
static void unify_bool(ptr_psi_term arg)
unify_bool
Definition: built_ins.c:911
long matches(ptr_definition t1, ptr_definition t2, long *smaller)
matches
Definition: types.c:1666
void get_one_arg(ptr_node t, ptr_psi_term *a)
get_one_arg
Definition: login.c:99
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
void curry()
curry
Definition: lefun.c:174
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define UNDEF
For LIFE boolean calculation built-in.
Definition: def_const.h:288
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define deref(P)
Definition: def_macro.h:147
ptr_goal aim
Definition: def_glob.h:1024
static long get_bool(ptr_definition typ)
get_bool
Definition: built_ins.c:898
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
static long c_not_implemented ( )
static

c_not_implemented

C_NOT_IMPLEMENTED This function always fails, it is in fact identical to BOTTOM.

Definition at line 2296 of file built_ins.c.

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

2297 {
2298  ptr_psi_term t;
2299 
2300  t=aim->aaaa_1;
2301  deref_ptr(t);
2302  Errorline("built-in %P is not implemented yet.\n",t);
2303  return FALSE;
2304 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define deref_ptr(P)
Definition: def_macro.h:100
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_goal aim
Definition: def_glob.h:1024
static long c_op ( )
static

c_op

C_OP() Declare an operator.

Definition at line 1697 of file built_ins.c.

References wl_goal::aaaa_1, aim, and declare_operator().

1698 {
1699  // long declare_operator();
1700  ptr_psi_term t=aim->aaaa_1;
1701 
1702  return declare_operator(t);
1703 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
ptr_goal aim
Definition: def_glob.h:1024
long declare_operator(ptr_psi_term t)
declare_operator
Definition: built_ins.c:5436
static long c_open_in ( )
static

c_open_in

C_OPEN_IN Create a stream for input from the specified file.

Definition at line 2773 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_psi_term::coref, deref, deref_args, deref_ptr, Errorline(), FALSE, get_two_args(), input_state, is_top, open_input_file(), psi_to_string(), push_psi_ptr_value(), set_1_2, and TRUE.

2774 {
2775  long success=FALSE;
2776  ptr_psi_term arg1,arg2,g;
2777  char *fn;
2778 
2779  g=aim->aaaa_1;
2780  deref_ptr(g);
2781  get_two_args(g->attr_list,&arg1,&arg2);
2782  if(arg1) {
2783  deref(arg1);
2784  if (psi_to_string(arg1,&fn))
2785  if (arg2) {
2786  deref(arg2);
2787  deref_args(g,set_1_2);
2788  if (is_top(arg2)) {
2789  if (open_input_file(fn)) {
2790  /* push_ptr_value(psi_term_ptr,&(arg2->coref)); 9.6 */
2791  push_psi_ptr_value(arg2,(GENERIC *)&(arg2->coref));
2792  arg2->coref=input_state;
2793  success=TRUE;
2794  }
2795  else
2796  success=FALSE;
2797  }
2798  else
2799  Errorline("bad input stream in %P.\n",g);
2800  }
2801  else
2802  Errorline("no stream in %P.\n",g);
2803  else
2804  Errorline("bad file name in %P.\n",g);
2805  }
2806  else
2807  Errorline("no file name in %P.\n",g);
2808 
2809  return success;
2810 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
#define is_top(T)
Definition: def_macro.h:113
void push_psi_ptr_value(ptr_psi_term q, GENERIC *p)
push_psi_ptr_value
Definition: login.c:474
ptr_psi_term input_state
Definition: def_glob.h:856
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define set_1_2
Set constants for deref_args in lefun.c.
Definition: def_const.h:514
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define deref(P)
Definition: def_macro.h:147
ptr_goal aim
Definition: def_glob.h:1024
ptr_psi_term coref
Definition: def_struct.h:188
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_node attr_list
Definition: def_struct.h:187
long open_input_file(char *file)
open_input_file
Definition: token.c:594
long psi_to_string(ptr_psi_term t, char **fn)
psi_to_string
Definition: built_ins.c:146
static long c_open_out ( )
static

c_open_out

C_OPEN_OUT Create a stream for output from the specified file.

Definition at line 2819 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_psi_term::coref, deref, deref_ptr, Errorline(), FALSE, get_two_args(), open_output_file(), output_stream, overlap_type(), psi_to_string(), push_psi_ptr_value(), stack_psi_term(), stream, TRUE, wl_psi_term::type, and wl_psi_term::value_3.

2820 {
2821  long success=FALSE;
2822  ptr_psi_term arg1,arg2,arg3,g;
2823  char *fn;
2824 
2825  g=aim->aaaa_1;
2826  deref_ptr(g);
2827  get_two_args(g->attr_list,&arg1,&arg2);
2828  if(arg1) {
2829  deref(arg1);
2830  if (psi_to_string(arg1,&fn))
2831  if (arg2) {
2832  deref(arg2);
2833  deref(g);
2834  if (overlap_type(arg2->type,stream)) /* 10.8 */
2835  if (open_output_file(fn)) {
2836  arg3=stack_psi_term(4);
2837  arg3->type=stream;
2838  arg3->value_3=(GENERIC)output_stream;
2839  /* push_ptr_value(psi_term_ptr,&(arg2->coref)); 9.6 */
2840  push_psi_ptr_value(arg2,(GENERIC *)&(arg2->coref));
2841  arg2->coref=arg3;
2842  success=TRUE;
2843  }
2844  else
2845  success=FALSE;
2846  else
2847  Errorline("bad stream in %P.\n",g);
2848  }
2849  else
2850  Errorline("no stream in %P.\n",g);
2851  else
2852  Errorline("bad file name in %P.\n",g);
2853  }
2854  else
2855  Errorline("no file name in %P.\n",g);
2856 
2857  return success;
2858 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
long open_output_file(char *file)
void push_psi_ptr_value(ptr_psi_term q, GENERIC *p)
push_psi_ptr_value
Definition: login.c:474
ptr_definition stream
symbol in bi module
Definition: def_glob.h:382
long overlap_type(ptr_definition t1, ptr_definition t2)
overlap_type
Definition: types.c:1579
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define deref(P)
Definition: def_macro.h:147
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
GENERIC value_3
Definition: def_struct.h:186
ptr_goal aim
Definition: def_glob.h:1024
ptr_psi_term coref
Definition: def_struct.h:188
FILE * output_stream
Definition: def_glob.h:1017
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
long psi_to_string(ptr_psi_term t, char **fn)
psi_to_string
Definition: built_ins.c:146
static long c_ops ( )
static

c_ops

C_OPS Return a list of all operators (represented as 3-tuples op(prec,type,atom)). This function has no arguments.

Definition at line 3784 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_goal::bbbb_1, collect_symbols(), deref_args, NULL, op_sel, push_goal(), set_empty, TRUE, and unify.

3785 {
3786  long success=TRUE;
3787  ptr_psi_term result, g, t;
3788 
3789  g=aim->aaaa_1;
3790  deref_args(g,set_empty);
3791  result=aim->bbbb_1;
3792  t=collect_symbols(op_sel); /* RM: Feb 3 1993 */
3793  push_goal(unify,result,t,NULL);
3794 
3795  return success;
3796 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
#define set_empty
Set constants for deref_args in lefun.c.
Definition: def_const.h:493
#define NULL
Definition: def_const.h:533
#define op_sel
used by collect_symbols in built_ins.c
Definition: def_const.h:25
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_goal aim
Definition: def_glob.h:1024
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_psi_term collect_symbols(long sel)
collect_symbols
Definition: built_ins.c:3699
ptr_psi_term bbbb_1
Definition: def_struct.h:240
static long c_or ( )
static

c_or

C_OR Logical and & or. These functions do all possible local propagations.

Definition at line 1013 of file built_ins.c.

References c_logical_main(), and FALSE.

1014 {
1015  return c_logical_main(FALSE);
1016 }
static long c_logical_main(long sel)
c_logical_main
Definition: built_ins.c:928
#define FALSE
Standard boolean.
Definition: def_const.h:275
static long c_page_width ( )
static

c_page_width

C_PAGE_WIDTH Set the page width.

Definition at line 3271 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, deref, deref_args, deref_ptr, equal_types, Errorline(), FALSE, get_two_args(), integer, NULL, page_width, push_goal(), REAL, real_stack_psi_term(), set_1, sub_type(), TRUE, wl_psi_term::type, unify, and wl_psi_term::value_3.

3272 {
3273  long success=FALSE;
3274  ptr_psi_term arg1,arg2,g;
3275  long pw;
3276 
3277  g=aim->aaaa_1;
3278  deref_ptr(g);
3279  get_two_args(g->attr_list,&arg1,&arg2);
3280  if(arg1) {
3281  deref(arg1);
3282  deref_args(g,set_1);
3283  if (equal_types(arg1->type,integer) && arg1->value_3) {
3284  pw = *(REAL *)arg1->value_3;
3285  if (pw>0)
3286  page_width=pw;
3287  else
3288  Errorline("argument in %P must be positive.\n",g);
3289  success=TRUE;
3290  }
3291  else if (sub_type(integer,arg1->type)) {
3293  success=TRUE;
3294  }
3295  else
3296  Errorline("bad argument in %P.\n",g);
3297  }
3298  else
3299  Errorline("argument missing in %P.\n",g);
3300 
3301  return success;
3302 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
ptr_psi_term real_stack_psi_term(long stat, REAL thereal)
real_stack_psi_term
Definition: lefun.c:48
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
#define NULL
Definition: def_const.h:533
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
long page_width
Definition: def_glob.h:1019
long sub_type(ptr_definition t1, ptr_definition t2)
sub_type
Definition: types.c:1642
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define deref(P)
Definition: def_macro.h:147
GENERIC value_3
Definition: def_struct.h:186
ptr_goal aim
Definition: def_glob.h:1024
#define equal_types(A, B)
Definition: def_macro.h:111
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
static long c_parse ( )
static

c_parse

C_PARSE Parse a string and return a quoted psi-term. The global variable names are recognized (see the built-in print_variables). All variables in the parsed string are added to the set of global variables.

Definition at line 2012 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, bi_module, curry(), wl_node::data, deref, deref_args, deref_ptr, FACT, FALSE, FEATCMP, find(), get_one_arg(), init_parse_state(), lf_false, lf_true, mark_quote(), matches(), NULL, parse(), push_goal(), QUERY, quoted_string, residuate(), restore_parse_state(), save_parse_state(), set_1, stack_copy_psi_term(), stack_psi_term(), stringinput, stringparse, three, TRUE, two, wl_psi_term::type, unify, update_symbol(), wl_psi_term::value_3, and var_occurred.

2013 {
2014  long success=TRUE;
2015  ptr_psi_term arg1,arg2,arg3,funct,result;
2016  long smaller,sort,old_var_occurred;
2017  ptr_node n;
2018  parse_block pb;
2019 
2020  funct=aim->aaaa_1;
2021  deref_ptr(funct);
2022  result=aim->bbbb_1;
2023  get_one_arg(funct->attr_list,&arg1);
2024  if (arg1) {
2025  deref(arg1);
2026  deref_args(funct,set_1);
2027  success=matches(arg1->type,quoted_string,&smaller);
2028  if (success) {
2029  if (arg1->value_3) {
2030  ptr_psi_term t;
2031 
2032  /* Parse the string in its own state */
2033  save_parse_state(&pb);
2034  init_parse_state();
2035  stringparse=TRUE;
2036  stringinput=(char*)arg1->value_3;
2037 
2038  old_var_occurred=var_occurred;
2040  t=stack_copy_psi_term(parse(&sort));
2041 
2042  /* Optional second argument returns 'query', 'declaration', or 'error'. */
2043  n=find(FEATCMP,two,funct->attr_list);
2044  if (n) {
2045  ptr_psi_term queryflag;
2046  arg2=(ptr_psi_term)n->data;
2047  queryflag=stack_psi_term(4);
2048  queryflag->type=
2050  ((sort==QUERY)?"query":((sort==FACT)?"declaration":"error"))
2051  );
2052  push_goal(unify,queryflag,arg2,NULL);
2053  }
2054 
2055  /* Optional third argument returns true or false if the psi-term
2056  contains a variable or not. */
2057  n=find(FEATCMP,three,funct->attr_list);
2058  if (n) {
2059  ptr_psi_term varflag;
2060  arg3=(ptr_psi_term)n->data;
2061  varflag=stack_psi_term(4);
2062  varflag->type=var_occurred?lf_true:lf_false;
2063  push_goal(unify,varflag,arg3,NULL);
2064  }
2065 
2066  var_occurred = var_occurred || old_var_occurred;
2068  restore_parse_state(&pb);
2069 
2070  /* parse_ok flag says whether there was a syntax error. */
2071  if (TRUE /*parse_ok*/) {
2072  mark_quote(t);
2073  push_goal(unify,t,result,NULL);
2074  }
2075  else
2076  success=FALSE;
2077  }
2078  else
2079  residuate(arg1);
2080  }
2081  else
2082  success=FALSE;
2083  }
2084  else
2085  curry();
2086 
2087  return success;
2088 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
ptr_definition lf_false
symbol in bi module
Definition: def_glob.h:284
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
psi_term parse(long *q)
parse
Definition: parser.c:907
void save_parse_state(ptr_parse_block pb)
save_parse_state
Definition: token.c:425
char * two
Definition: def_glob.h:892
void restore_parse_state(ptr_parse_block pb)
restore_parse_state
Definition: token.c:444
long matches(ptr_definition t1, ptr_definition t2, long *smaller)
matches
Definition: types.c:1666
#define FACT
Fact Kind of user input.
Definition: def_const.h:338
void get_one_arg(ptr_node t, ptr_psi_term *a)
get_one_arg
Definition: login.c:99
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
char * three
Definition: def_glob.h:893
#define QUERY
Query Kind of user input.
Definition: def_const.h:345
ptr_definition update_symbol(ptr_module module, char *symbol)
update_symbol
Definition: modules.c:270
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define deref(P)
Definition: def_macro.h:147
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
GENERIC value_3
Definition: def_struct.h:186
void init_parse_state()
init_parse_state
Definition: token.c:464
ptr_goal aim
Definition: def_glob.h:1024
void mark_quote(ptr_psi_term t)
mark_quote
Definition: copy.c:674
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
ptr_psi_term stack_copy_psi_term(psi_term t)
stack_copy_psi_term
Definition: parser.c:205
ptr_module bi_module
Module for public built-ins.
Definition: def_glob.h:687
#define deref_args(P, S)
Definition: def_macro.h:150
long stringparse
Definition: def_glob.h:859
char * stringinput
Definition: def_glob.h:860
ptr_definition lf_true
symbol in bi module
Definition: def_glob.h:410
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
long var_occurred
???
Definition: def_glob.h:839
ptr_node attr_list
Definition: def_struct.h:187
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
static long c_persistent ( )
static

c_persistent

C_PERSISTENT Declare that a symbol is a persistent variable.

Definition at line 2687 of file built_ins.c.

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

2688 {
2689  int error=FALSE;
2690  ptr_psi_term g;
2691 
2692  g=aim->aaaa_1;
2693  deref_ptr(g);
2694  if (g->attr_list) {
2695  /* Do error check of all arguments first: */
2696  persistent_error_check(g->attr_list, &error);
2697  /* If no errors, then make the arguments persistent: */
2698  if (!error)
2700  } else {
2701  Errorline("argument(s) missing in %P\n",g);
2702  }
2703 
2704  return !error;
2705 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void persistent_error_check(ptr_node n, int *error)
persistent_error_check
Definition: built_ins.c:2714
void persistent_tree(ptr_node n)
persistent_tree
Definition: built_ins.c:2739
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define deref_ptr(P)
Definition: def_macro.h:100
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_goal aim
Definition: def_glob.h:1024
ptr_node attr_list
Definition: def_struct.h:187
static long c_pred ( )
static

c_pred

C_PRED Template for C built-in predicates.

Definition at line 5305 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, deref_args, deref_ptr, Errorline(), FALSE, get_two_args(), set_1_2, and TRUE.

5306 {
5307  long success=TRUE;
5308  ptr_psi_term arg1,arg2,g;
5309 
5310  g=aim->aaaa_1;
5311  deref_ptr(g);
5312  get_two_args(g->attr_list,&arg1,&arg2);
5313  if (arg1 && arg2) {
5314  deref_args(g,set_1_2);
5315  }
5316  else {
5317  success=FALSE;
5318  Errorline("argument(s) missing in %P.\n",g);
5319  }
5320 
5321  return success;
5322 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define set_1_2
Set constants for deref_args in lefun.c.
Definition: def_const.h:514
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_goal aim
Definition: def_glob.h:1024
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_node attr_list
Definition: def_struct.h:187
static long c_print_codes ( )
static

c_print_codes

C_print_codes Print the codes of all the sorts.

Definition at line 5285 of file built_ins.c.

References wl_goal::aaaa_1, aim, deref_args, outputline(), print_codes(), set_empty, TRUE, and type_count.

5286 {
5287  ptr_psi_term t;
5288 
5289  t=aim->aaaa_1;
5290  deref_args(t,set_empty);
5291  outputline("There are %d sorts.\n",type_count);
5292  print_codes();
5293  return TRUE;
5294 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
long type_count
Definition: def_glob.h:1021
#define set_empty
Set constants for deref_args in lefun.c.
Definition: def_const.h:493
void print_codes()
print_codes
Definition: types.c:1256
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_goal aim
Definition: def_glob.h:1024
void outputline(char *format,...)
void outputline(char *format,...)
Definition: error.c:101
#define deref_args(P, S)
Definition: def_macro.h:150
static long c_print_depth ( )
static

c_print_depth

C_PRINT_DEPTH Set the depth limit of printing.

Definition at line 3311 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, deref, deref_args, deref_ptr, equal_types, Errorline(), FALSE, get_two_args(), integer, NULL, PRINT_DEPTH, print_depth, push_goal(), REAL, real_stack_psi_term(), set_1, sub_type(), TRUE, wl_psi_term::type, unify, and wl_psi_term::value_3.

3312 {
3313  long success=FALSE;
3314  ptr_psi_term arg1,arg2,g;
3315  long dl;
3316 
3317  g=aim->aaaa_1;
3318  deref_ptr(g);
3319  get_two_args(g->attr_list,&arg1,&arg2);
3320  if (arg1) {
3321  deref(arg1);
3322  deref_args(g,set_1);
3323  if (equal_types(arg1->type,integer) && arg1->value_3) {
3324  dl = *(REAL *)arg1->value_3;
3325  if (dl>=0)
3326  print_depth=dl;
3327  else
3328  Errorline("argument in %P must be positive or zero.\n",g);
3329  success=TRUE;
3330  }
3331  else if (sub_type(integer,arg1->type)) {
3333  success=TRUE;
3334  }
3335  else
3336  Errorline("bad argument in %P.\n",g);
3337  }
3338  else {
3339  /* No arguments: reset print depth to default value */
3341  success=TRUE;
3342  }
3343 
3344  return success;
3345 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
ptr_psi_term real_stack_psi_term(long stat, REAL thereal)
real_stack_psi_term
Definition: lefun.c:48
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
long print_depth
Global flag that modifies how writing is done.
Definition: def_glob.h:787
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
#define NULL
Definition: def_const.h:533
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
long sub_type(ptr_definition t1, ptr_definition t2)
sub_type
Definition: types.c:1642
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define deref(P)
Definition: def_macro.h:147
GENERIC value_3
Definition: def_struct.h:186
ptr_goal aim
Definition: def_glob.h:1024
#define equal_types(A, B)
Definition: def_macro.h:111
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
#define PRINT_DEPTH
Initial depth limit for printing.
Definition: def_const.h:176
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
static long c_print_variables ( )
static

c_print_variables

C_PRINT_VARIABLES Print the global variables and their values, in the same way as is done in the user interface.

Definition at line 1967 of file built_ins.c.

References print_variables(), and TRUE.

1968 {
1969  long success=TRUE;
1970 
1971  (void)print_variables(TRUE); /* 21.1 */
1972 
1973  return success;
1974 }
#define TRUE
Standard boolean.
Definition: def_const.h:268
long print_variables(long printflag)
print_variables
Definition: print.c:1368
static long c_project ( )
static

c_project

C_PROJECT RM: Jan 7 1993 Here we evaluate "project(Psi-term,Label)". This returns the psi-term associated to label Label in Psi-term. It is identical to C_PROJECT except that the order of the arguments is inversed.

Definition at line 1207 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_definition::always_check, wl_psi_term::attr_list, wl_goal::bbbb_1, bk_stack_insert(), clear_copy(), wl_keyword::combined_name, wl_psi_term::coref, curry(), wl_node::data, deref, deref_args, deref_ptr, Errorline(), FALSE, FEATCMP, fetch_def_lazy(), find(), wl_psi_term::flags, function_it, get_two_args(), heap_copy_string(), heap_insert(), heap_pointer, inc_heap_copy(), integer, wl_definition::keyword, NULL, wl_keyword::private_feature, push_goal(), push_psi_ptr_value(), quoted_string, QUOTED_TRUE, REAL, release_resid(), wl_psi_term::resid, residuate(), set_1_2, sub_type(), wl_keyword::symbol, top, TRUE, wl_psi_term::type, wl_definition::type_def, unify, and wl_psi_term::value_3.

1209 {
1210  long success=TRUE;
1211  ptr_psi_term arg1,arg2,funct,result;
1212  ptr_node n;
1213  char *label;
1214  double v;
1215 
1216  /* char *thebuffer="integer"; 18.5 */
1217  char thebuffer[20]; /* Maximum number of digits in an integer */
1218 
1219  funct=aim->aaaa_1;
1220  deref_ptr(funct);
1221  result=aim->bbbb_1;
1222  get_two_args(funct->attr_list,&arg1,&arg2);
1223  if (arg2 && arg1) {
1224  deref(arg1);
1225  deref(arg2);
1226  deref_args(funct,set_1_2);
1227 
1228  label=NULL;
1229 
1230  /* RM: Jul 20 1993: Don't residuate on 'string' etc... */
1231  if(arg2->type!=top) {
1232  if(arg2->value_3 && sub_type(arg2->type,quoted_string)) /* 10.8 */
1233  label=(char *)arg2->value_3;
1234  else
1235  if(arg2->value_3 && sub_type(arg2->type,integer)) { /* 10.8 */
1236  v= *(REAL *)arg2->value_3;
1237  if(v==floor(v)) {
1238  (void)snprintf(thebuffer,20,"%ld",(long)v);
1239  label=heap_copy_string(thebuffer); /* A little voracious */
1240  }
1241  else { /* RM: Jul 28 1993 */
1242  Errorline("non-integer numeric feature in %P\n",funct);
1243  return FALSE;
1244  }
1245  }
1246  else {
1247  if(arg2->type->keyword->private_feature) /* RM: Mar 12 1993 */
1248  label=arg2->type->keyword->combined_name;
1249  else
1250  label=arg2->type->keyword->symbol;
1251  }
1252  }
1253 
1254  if (label) {
1255  n=find(FEATCMP,(char *)label,arg1->attr_list);
1256 
1257  if (n)
1259  else if (arg1->type->type_def==(def_type)function_it && !(arg1->flags&QUOTED_TRUE)) {
1260  Errorline("attempt to add a feature to curried function %P\n",
1261  arg1);
1262  return FALSE;
1263  }
1264  else {
1265  deref_ptr(result);
1266  if((GENERIC)arg1>=heap_pointer) { /* RM: Feb 9 1993 */
1267  if((GENERIC)result<heap_pointer)
1268  push_psi_ptr_value(result,(GENERIC *)&(result->coref));
1269  clear_copy();
1270  result->coref=inc_heap_copy(result);
1271  (void)heap_insert(FEATCMP,label,&(arg1->attr_list),(GENERIC)result->coref);
1272  }
1273  else {
1274 
1275 #ifdef ARITY /* RM: Mar 29 1993 */
1276  arity_add(arg1,label);
1277 #endif
1278 
1279  /* RM: Mar 25 1993 */
1280  if(arg1->type->always_check || arg1->attr_list)
1281  (void)bk_stack_insert(FEATCMP,label,&(arg1->attr_list),(GENERIC)result);
1282  else {
1283  (void)bk_stack_insert(FEATCMP,label,&(arg1->attr_list),(GENERIC)result);
1284  fetch_def_lazy(arg1, arg1->type,arg1->type,NULL,NULL,0,0); // djd added zeros
1285  }
1286 
1287  if (arg1->resid)
1288  release_resid(arg1);
1289  }
1290  }
1291  }
1292  else
1293  residuate(arg2);
1294  }
1295  else
1296  curry();
1297 
1298  return success;
1299 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
ptr_residuation resid
Definition: def_struct.h:189
#define function_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1408
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
void clear_copy()
clear_copy
Definition: copy.c:53
GENERIC heap_pointer
used to allocate from heap - size allocated subtracted - adj for alignment
Definition: def_glob.h:55
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
char * combined_name
Definition: def_struct.h:119
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
ptr_node bk_stack_insert(long comp, char *keystr, ptr_node *tree, GENERIC info)
bk_stack_insert
Definition: trees.c:357
void push_psi_ptr_value(ptr_psi_term q, GENERIC *p)
push_psi_ptr_value
Definition: login.c:474
def_type type_def
Definition: def_struct.h:153
ptr_keyword keyword
Definition: def_struct.h:147
GENERIC data
Definition: def_struct.h:201
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
char * symbol
Definition: def_struct.h:118
ptr_node heap_insert(long comp, char *keystr, ptr_node *tree, GENERIC info)
heap_insert
Definition: trees.c:320
char always_check
Definition: def_struct.h:154
void release_resid(ptr_psi_term t)
release_resid
Definition: lefun.c:445
long sub_type(ptr_definition t1, ptr_definition t2)
sub_type
Definition: types.c:1642
void fetch_def_lazy(ptr_psi_term u, ptr_definition old1, ptr_definition old2, ptr_node old1attr, ptr_node old2attr, long old1stat, long old2stat)
fetch_def_lazy
Definition: login.c:1276
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define set_1_2
Set constants for deref_args in lefun.c.
Definition: def_const.h:514
#define deref_ptr(P)
Definition: def_macro.h:100
char * heap_copy_string(char *s)
heap_copy_string
Definition: trees.c:172
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define deref(P)
Definition: def_macro.h:147
GENERIC value_3
Definition: def_struct.h:186
ptr_goal aim
Definition: def_glob.h:1024
ptr_psi_term coref
Definition: def_struct.h:188
ptr_psi_term inc_heap_copy(ptr_psi_term t)
inc_heap_copy
Definition: copy.c:206
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
ptr_definition top
symbol in syntax module
Definition: def_glob.h:403
#define deref_args(P, S)
Definition: def_macro.h:150
int private_feature
Definition: def_struct.h:121
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
#define QUOTED_TRUE
True flags for the flags field of psi-terms.
Definition: def_const.h:254
ptr_node attr_list
Definition: def_struct.h:187
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
static long c_psi2string ( )
static

c_psi2string

C_PSI2STRING(P) Convert a psi-term's name into a string with the name as value.

Definition at line 4898 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), deref, deref_args, deref_ptr, get_one_arg(), heap_copy_string(), wl_definition::keyword, NULL, push_goal(), quoted_string, real, set_1, stack_psi_term(), sub_type(), wl_keyword::symbol, TRUE, wl_psi_term::type, unify, and wl_psi_term::value_3.

4899 {
4900  long success=TRUE;
4901  ptr_psi_term arg1, /* arg3, */ funct,result,t;
4902  char buf[100]; /* RM: Mar 10 1993 */
4903 
4904  funct=aim->aaaa_1;
4905  deref_ptr(funct);
4906  result=aim->bbbb_1;
4907  deref(result);
4908 
4909  get_one_arg(funct->attr_list,&arg1);
4910  if (arg1) {
4911  deref(arg1);
4912  deref_args(funct,set_1);
4913  t=stack_psi_term(0);
4914  t->type=quoted_string;
4915 
4916  /* RM: Mar 10 1993 */
4917  if(arg1->value_3 && sub_type(arg1->type,real)) {
4918  (void)snprintf(buf,100,"%g", *((double *)(arg1->value_3)));
4919  t->value_3=(GENERIC)heap_copy_string(buf);
4920  }
4921  else
4922  if(arg1->value_3 && sub_type(arg1->type,quoted_string)) {
4923  t->value_3=(GENERIC)heap_copy_string((char *)arg1->value_3);
4924  }
4925  else
4927 
4928  push_goal(unify,t,result,NULL);
4929  }
4930  else
4931  curry();
4932 
4933  return success;
4934 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
void get_one_arg(ptr_node t, ptr_psi_term *a)
get_one_arg
Definition: login.c:99
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
ptr_keyword keyword
Definition: def_struct.h:147
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
char * symbol
Definition: def_struct.h:118
long sub_type(ptr_definition t1, ptr_definition t2)
sub_type
Definition: types.c:1642
ptr_definition real
symbol in bi module
Definition: def_glob.h:375
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define deref_ptr(P)
Definition: def_macro.h:100
char * heap_copy_string(char *s)
heap_copy_string
Definition: trees.c:172
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define deref(P)
Definition: def_macro.h:147
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
GENERIC value_3
Definition: def_struct.h:186
ptr_goal aim
Definition: def_glob.h:1024
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
static long c_put ( )
static

c_put

C_PUT Write the root of a psi-term to the current output stream. This routine accepts the string type (which is written without quotes), a number type (whose integer part is considered an Ascii code if it is in the range 0..255), and any other psi-term (in which case its name is written).

Definition at line 3049 of file built_ins.c.

References c_put_main(), and FALSE.

3050 {
3051  return c_put_main(FALSE);
3052 }
static long c_put_main(long)
c_put_main
Definition: built_ins.c:3076
#define FALSE
Standard boolean.
Definition: def_const.h:275
static long c_put_err ( )
static

c_put_err

C_PUT_ERR Write the root of a psi-term to stderr. This routine accepts the string type (which is written without quotes), a number type (whose integer part is considered an Ascii code if it is in the range 0..255), and any other psi-term (in which case its name is written).

Definition at line 3065 of file built_ins.c.

References c_put_main(), and TRUE.

3066 {
3067  return c_put_main(TRUE);
3068 }
static long c_put_main(long)
c_put_main
Definition: built_ins.c:3076
#define TRUE
Standard boolean.
Definition: def_const.h:268
static long c_put_main ( long  to_stderr)
static

c_put_main

Parameters
to_stderr- long to_stderr if TRUE stderr otherwise current output

Definition at line 3076 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, deref, deref_args, deref_ptr, equal_types, Errorline(), FALSE, get_two_args(), integer, output_stream, psi_to_string(), REAL, real, set_1, TRUE, wl_psi_term::type, and wl_psi_term::value_3.

3077 {
3078  long i,success=FALSE;
3079  ptr_psi_term arg1,arg2,g;
3080  char tstr[2], *str=tstr;
3081 
3082  g=aim->aaaa_1;
3083  deref_ptr(g);
3084  get_two_args(g->attr_list,&arg1,&arg2);
3085  if (arg1) {
3086  deref(arg1);
3087  deref_args(g,set_1);
3088  if ((equal_types(arg1->type,integer) || equal_types(arg1->type,real))
3089  && arg1->value_3) {
3090  i = (unsigned long) floor(*(REAL *) arg1->value_3);
3091  if (i==(unsigned long)(unsigned char)i) {
3092  str[0] = i; str[1] = 0;
3093  success=TRUE;
3094  }
3095  else {
3096  Errorline("out-of-range character value in %P.\n",g);
3097  }
3098  }
3099  else if (psi_to_string(arg1,&str)) {
3100  success=TRUE;
3101  }
3102  if (success)
3103  fprintf((to_stderr?stderr:output_stream),"%s",str);
3104  }
3105  else
3106  Errorline("argument missing in %P.\n",g);
3107 
3108  return success;
3109 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
ptr_definition real
symbol in bi module
Definition: def_glob.h:375
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define deref(P)
Definition: def_macro.h:147
GENERIC value_3
Definition: def_struct.h:186
ptr_goal aim
Definition: def_glob.h:1024
#define equal_types(A, B)
Definition: def_macro.h:111
#define deref_args(P, S)
Definition: def_macro.h:150
FILE * output_stream
Definition: def_glob.h:1017
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
long psi_to_string(ptr_psi_term t, char **fn)
psi_to_string
Definition: built_ins.c:146
static long c_pwrite ( )
static

c_pwrite

C_PRETTY_WRITE The same as write, only indenting if output is wider than PAGEWIDTH.

Definition at line 3235 of file built_ins.c.

References const_quote, FALSE, generic_write(), indent, TRUE, write_canon, write_corefs, write_resids, and write_stderr.

3236 {
3237  indent=TRUE;
3243  return generic_write();
3244 }
long indent
Global flag that modifies how writing is done.
Definition: def_glob.h:793
long write_corefs
Global flag that modifies how writing is done.
Definition: def_glob.h:811
static long generic_write()
generic_write
Definition: built_ins.c:3118
long write_resids
Global flag that modifies how writing is done.
Definition: def_glob.h:817
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
long const_quote
Global flag that modifies how writing is done.
Definition: def_glob.h:799
long write_stderr
Global flag that modifies how writing is done.
Definition: def_glob.h:805
long write_canon
Global flag that modifies how writing is done.
Definition: def_glob.h:823
static long c_pwriteq ( )
static

c_pwriteq

C_PRETTY_WRITEQ The same as writeq, only indenting if output is wider than PAGEWIDTH.

Definition at line 3253 of file built_ins.c.

References const_quote, FALSE, generic_write(), indent, TRUE, write_canon, write_corefs, write_resids, and write_stderr.

3254 {
3255  indent=TRUE;
3256  const_quote=TRUE;
3261  return generic_write();
3262 }
long indent
Global flag that modifies how writing is done.
Definition: def_glob.h:793
long write_corefs
Global flag that modifies how writing is done.
Definition: def_glob.h:811
static long generic_write()
generic_write
Definition: built_ins.c:3118
long write_resids
Global flag that modifies how writing is done.
Definition: def_glob.h:817
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
long const_quote
Global flag that modifies how writing is done.
Definition: def_glob.h:799
long write_stderr
Global flag that modifies how writing is done.
Definition: def_glob.h:805
long write_canon
Global flag that modifies how writing is done.
Definition: def_glob.h:823
static long c_quote ( )
static

c_quote

C_QUOTE Quote an expression, i.e. do not evaluate it but mark it as completely evaluated. This works if the function is declared as non_strict.

Definition at line 4009 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), deref, deref_ptr, get_two_args(), NULL, push_goal(), TRUE, and unify.

4010 {
4011  long success=TRUE;
4012  ptr_psi_term arg1,arg2,funct,result;
4013 
4014  funct = aim->aaaa_1;
4015  deref_ptr(funct);
4016  result = aim->bbbb_1;
4017  deref(result);
4018  get_two_args(funct->attr_list, &arg1, &arg2);
4019  if (arg1) {
4020  push_goal(unify,arg1,result,NULL);
4021  } else
4022  curry();
4023 
4024  return success;
4025 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define deref(P)
Definition: def_macro.h:147
ptr_goal aim
Definition: def_glob.h:1024
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
long c_random ( )

c_random

C_RANDOM Return an integer random number between 0 and abs(argument1). Uses the Unix random() function (rand_r(&seed) for Solaris).

Definition at line 5966 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), wl_node::data, deref, deref_args, deref_ptr, FALSE, FEATCMP, find(), integer, NULL, one, overlap_type(), push_goal(), REAL, real_stack_psi_term(), residuate(), set_1, TRUE, wl_psi_term::type, unify, and wl_psi_term::value_3.

5967 {
5968  ptr_psi_term result,funct;
5969  ptr_node n1;
5970  long success=TRUE;
5971  long all_args=TRUE;
5972  long c_result;
5973  ptr_psi_term arg1;
5974  long c_arg1;
5975 
5976  funct=aim->aaaa_1;
5977  deref_ptr(funct);
5978  result=aim->bbbb_1;
5979 
5980  /* Evaluate all arguments first: */
5981  n1=find(FEATCMP,one,funct->attr_list);
5982  if (n1) {
5983  arg1= (ptr_psi_term )n1->data;
5984  deref(arg1);
5985  }
5986  deref_args(funct,set_1);
5987 
5988  if (success) {
5989  if (n1) {
5990  if (overlap_type(arg1->type,integer))
5991  if (arg1->value_3)
5992  c_arg1= (long)(* (double *)(arg1->value_3));
5993  else {
5994  residuate(arg1);
5995  all_args=FALSE;
5996  }
5997  else
5998  success=FALSE;
5999  }
6000  else {
6001  all_args=FALSE;
6002  curry();
6003  }
6004  }
6005 
6006  if (success && all_args) {
6007  if (c_arg1) {
6008 #ifdef SOLARIS
6009  c_result=(rand_r(&randomseed)<<15) + rand_r(&randomseed);
6010 #else
6011  c_result=random();
6012 #endif
6013  c_result=c_result-(c_result/c_arg1)*c_arg1;
6014  }
6015  else
6016  c_result=0;
6017 
6018  push_goal(unify,real_stack_psi_term(0,(REAL)c_result),result,NULL);
6019  }
6020 
6021  return success;
6022 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
ptr_psi_term real_stack_psi_term(long stat, REAL thereal)
real_stack_psi_term
Definition: lefun.c:48
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
long overlap_type(ptr_definition t1, ptr_definition t2)
overlap_type
Definition: types.c:1579
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define deref(P)
Definition: def_macro.h:147
GENERIC value_3
Definition: def_struct.h:186
ptr_goal aim
Definition: def_glob.h:1024
char * one
Definition: def_glob.h:891
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
static long c_read ( long  psi_flag)
static

c_read

Parameters
psi_flag- long psi_flag

C_READ Read a psi_term or a token from the current input stream. The variables in the object read are not added to the set of global variables.

Definition at line 2122 of file built_ins.c.

References wl_goal::aaaa_1, abort_life(), aim, wl_psi_term::attr_list, bi_module, wl_node::data, deref_args, deref_ptr, eof, eof_flag, Errorline(), FACT, FALSE, FEATCMP, find(), get_one_arg(), heap_alloc(), integer, line_count, mark_quote(), NULL, parse(), prompt, push_goal(), QUERY, read_token_b(), REAL, set_1, stack_copy_psi_term(), stack_psi_term(), three, TRUE, two, wl_psi_term::type, unify, update_symbol(), wl_psi_term::value_3, and var_tree.

2123 {
2124  long success=TRUE;
2125  long sort;
2126  ptr_psi_term arg1,arg2,arg3,g,t;
2127  ptr_node old_var_tree;
2128  ptr_node n;
2129  int line=line_count+1;
2130 
2131  g=aim->aaaa_1;
2132  deref_ptr(g);
2133  get_one_arg(g->attr_list,&arg1);
2134  if (arg1) {
2135  deref_args(g,set_1);
2136  if (eof_flag) {
2137  Errorline("attempt to read past end of file (%E).\n");
2138  return (abort_life(TRUE));
2139  }
2140  else {
2141  prompt="";
2142  old_var_tree=var_tree;
2143  var_tree=NULL;
2144  if (psi_flag) {
2145 
2146  t=stack_copy_psi_term(parse(&sort));
2147 
2148 
2149  /* Optional second argument returns 'query', 'declaration', or
2150  'error'. */
2151  n=find(FEATCMP,two,g->attr_list); /* RM: Jun 8 1993 */
2152  if (n) {
2153  ptr_psi_term queryflag;
2154  arg2=(ptr_psi_term)n->data;
2155  queryflag=stack_psi_term(4);
2156  queryflag->type=
2158  ((sort==QUERY)?"query":((sort==FACT)?"declaration":"error"))
2159  );
2160  push_goal(unify,queryflag,arg2,NULL);
2161  }
2162 
2163 
2164  /* Optional third argument returns the starting line number */
2165  /* RM: Oct 11 1993 */
2166  n=find(FEATCMP,three,g->attr_list);
2167  if (n) {
2168  arg3=(ptr_psi_term)n->data;
2169  g=stack_psi_term(4);
2170  g->type=integer;
2171  g->value_3=heap_alloc(sizeof(REAL));
2172  *(REAL *)g->value_3=line;
2173  push_goal(unify,g,arg3,NULL);
2174  }
2175 
2176  }
2177  else {
2178  t=stack_psi_term(0);
2179  read_token_b(t);
2180  /* RM: Jan 5 1993 removed spurious argument: &quot (??) */
2181 
2182  }
2183  if (t->type==eof) eof_flag=TRUE;
2184  var_tree=old_var_tree;
2185  }
2186 
2187  if (success) {
2188  mark_quote(t);
2189  push_goal(unify,t,arg1,NULL);
2190  /* i_check_out(t); */
2191  }
2192  }
2193  else {
2194  Errorline("argument missing in %P.\n",g);
2195  success=FALSE;
2196  }
2197 
2198  return success;
2199 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
psi_term parse(long *q)
parse
Definition: parser.c:907
long eof_flag
Definition: def_glob.h:853
char * two
Definition: def_glob.h:892
#define FACT
Fact Kind of user input.
Definition: def_const.h:338
void get_one_arg(ptr_node t, ptr_psi_term *a)
get_one_arg
Definition: login.c:99
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
#define NULL
Definition: def_const.h:533
ptr_node var_tree
Definition: def_glob.h:1005
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
char * three
Definition: def_glob.h:893
#define QUERY
Query Kind of user input.
Definition: def_const.h:345
ptr_definition update_symbol(ptr_module module, char *symbol)
update_symbol
Definition: modules.c:270
long abort_life(int nlflag)
abort_life
Definition: built_ins.c:2259
long line_count
Definition: def_glob.h:1015
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_definition eof
symbol in syntax module
Definition: def_glob.h:263
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
GENERIC value_3
Definition: def_struct.h:186
ptr_goal aim
Definition: def_glob.h:1024
void mark_quote(ptr_psi_term t)
mark_quote
Definition: copy.c:674
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
ptr_psi_term stack_copy_psi_term(psi_term t)
stack_copy_psi_term
Definition: parser.c:205
ptr_module bi_module
Module for public built-ins.
Definition: def_glob.h:687
#define deref_args(P, S)
Definition: def_macro.h:150
void read_token_b(ptr_psi_term tok)
read_token_b
Definition: token.c:1197
char * prompt
Definition: def_glob.h:1018
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
GENERIC heap_alloc(long s)
heap_alloc
Definition: memory.c:1616
static long c_read_psi ( )
static

c_read_psi

Definition at line 2097 of file built_ins.c.

References c_read(), and TRUE.

2098 {
2099  return (c_read(TRUE));
2100 }
static long c_read(long)
c_read
Definition: built_ins.c:2122
#define TRUE
Standard boolean.
Definition: def_const.h:268
static long c_read_token ( )
static

c_read_token

Definition at line 2107 of file built_ins.c.

References c_read(), and FALSE.

2108 {
2109  return (c_read(FALSE));
2110 }
static long c_read(long)
c_read
Definition: built_ins.c:2122
#define FALSE
Standard boolean.
Definition: def_const.h:275
static long c_repeat ( )
static

c_repeat

C_REPEAT Succeed indefinitely on backtracking.

Definition at line 1416 of file built_ins.c.

References wl_goal::aaaa_1, aim, DEFRULES, deref_args, NULL, prove, push_choice_point(), set_empty, and TRUE.

1417 {
1418  ptr_psi_term t;
1419 
1420  t=aim->aaaa_1;
1421  deref_args(t,set_empty);
1423  return TRUE;
1424 }
#define prove
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1051
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void push_choice_point(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_choice_point
Definition: login.c:638
#define set_empty
Set constants for deref_args in lefun.c.
Definition: def_const.h:493
#define DEFRULES
Must be different from NULL, a built-in index, and a pointer Used to indicate that the rules of the d...
Definition: def_const.h:302
#define NULL
Definition: def_const.h:533
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_goal aim
Definition: def_glob.h:1024
#define deref_args(P, S)
Definition: def_macro.h:150
static long c_retract ( )
static

c_retract

C_RETRACT Retract the first clause that unifies with the argument. Use PRED_CLAUSE to perform the search.

Definition at line 2538 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, FALSE, get_two_args(), and pred_clause().

2539 {
2540  long success=FALSE;
2541  ptr_psi_term arg1,arg2,g;
2542 
2543  g=aim->aaaa_1;
2544  get_two_args(g->attr_list,&arg1,&arg2);
2545  success=pred_clause(arg1,1,g);
2546 
2547  return success;
2548 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
long pred_clause(ptr_psi_term t, long r, ptr_psi_term g)
pred_clause
Definition: built_ins.c:2451
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_goal aim
Definition: def_glob.h:1024
ptr_node attr_list
Definition: def_struct.h:187
static long c_rootsort ( )
static

c_rootsort

C_ROOTSORT Return the principal sort of the argument == create a copy with the attributes detached.

Definition at line 3355 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), deref, deref_args, deref_ptr, get_two_args(), NULL, push_goal(), resid_aim, set_1, stack_psi_term(), TRUE, wl_psi_term::type, unify, and wl_psi_term::value_3.

3356 {
3357  long success=TRUE;
3358  ptr_psi_term arg1,arg2,arg3,g,other;
3359 
3360  g=aim->aaaa_1;
3361  deref_ptr(g);
3362  arg3=aim->bbbb_1;
3363  deref(arg3);
3364  get_two_args(g->attr_list,&arg1,&arg2);
3365  if(arg1) {
3366  deref(arg1);
3367  deref_args(g,set_1);
3368  other=stack_psi_term(4); /* 19.11 */
3369  other->type=arg1->type;
3370  other->value_3=arg1->value_3;
3371  resid_aim=NULL;
3372  push_goal(unify,arg3,other,NULL);
3373  }
3374  else
3375  curry();
3376 
3377  return success;
3378 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
ptr_goal resid_aim
Definition: def_glob.h:865
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define deref(P)
Definition: def_macro.h:147
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
GENERIC value_3
Definition: def_struct.h:186
ptr_goal aim
Definition: def_glob.h:1024
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
static long c_same_address ( )
static

c_same_address

C_SAME_ADDRESS Return TRUE if two arguments share the same address.

Definition at line 3857 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), deref, deref_args, deref_ptr, FALSE, get_bool_value(), get_two_args(), NULL, push_goal(), REAL, resid_aim, set_1_2, TRUE, unify, and unify_bool_result().

3858 {
3859  long success=TRUE;
3860  ptr_psi_term arg1,arg2,funct,result;
3861  REAL val3;
3862  long num3;
3863 
3864  funct=aim->aaaa_1;
3865  deref_ptr(funct);
3866  result=aim->bbbb_1;
3867  get_two_args(funct->attr_list,&arg1,&arg2);
3868 
3869  if (arg1 && arg2) {
3870  success=get_bool_value(result,&val3,&num3);
3871  resid_aim=NULL;
3872  deref(arg1);
3873  deref(arg2);
3874  deref_args(funct,set_1_2);
3875 
3876  if (num3) {
3877  if (val3)
3878  push_goal(unify,arg1,arg2,NULL);
3879  else
3880  success=(arg1!=arg2);
3881  }
3882  else
3883  if (arg1==arg2)
3884  unify_bool_result(result,TRUE);
3885  else
3886  unify_bool_result(result,FALSE);
3887  }
3888  else
3889  curry();
3890 
3891  return success;
3892 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
void unify_bool_result(ptr_psi_term t, long v)
unify_bool_result
Definition: built_ins.c:344
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
ptr_goal resid_aim
Definition: def_glob.h:865
#define set_1_2
Set constants for deref_args in lefun.c.
Definition: def_const.h:514
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define deref(P)
Definition: def_macro.h:147
ptr_goal aim
Definition: def_glob.h:1024
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_psi_term bbbb_1
Definition: def_struct.h:240
static long get_bool_value(ptr_psi_term t, REAL *v, long *n)
get_bool_value
Definition: built_ins.c:300
ptr_node attr_list
Definition: def_struct.h:187
static long c_set_choice ( )
static

c_set_choice

C_SET_CHOICE() Set the choice point stack to a state no later than (i.e. the same or earlier than) the state of the first argument (i.e., remove all choice points up to the first one whose time stamp is =< the first argument). This predicate will remove zero or more choice points, never add them. The first argument must come from a past call to get_choice. Together, get_choice and set_choice allow one to implement an "ancestor cut" that removes all choice points created between the current execution point and an execution point arbitarily remote in the past. The built-ins get_choice, set_choice, and exists_choice are implemented using the timestamping mechanism in the interpreter. The two relevant properties of the timestamping mechanism are that each choice point is identified by an integer and that the integers are in increasing order (but not necessarily consecutive) from the bottom to the top of the choice point stack.

Definition at line 1853 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, choice_stack, clean_trail(), curry(), deref, deref_args, deref_ptr, Errorline(), FALSE, get_one_arg(), get_real_value(), wl_choice_point::next, REAL, set_1, wl_choice_point::time_stamp, and TRUE.

1854 {
1855  REAL gts_r;
1856  long gts;
1857  long num,success=TRUE;
1858  ptr_psi_term t,arg1;
1859  ptr_choice_point cutpt;
1860 
1861  t=aim->aaaa_1;
1862  deref_ptr(t);
1863  get_one_arg(t->attr_list,&arg1);
1864  if (arg1) {
1865  deref(arg1);
1866  deref_args(t,set_1);
1867  success = get_real_value(arg1,&gts_r,&num);
1868  if (success) {
1869  if (num) {
1870  gts=(unsigned long)gts_r;
1871  if (choice_stack) {
1872  cutpt=choice_stack;
1873  while (cutpt && cutpt->time_stamp>gts) cutpt=cutpt->next;
1874  if (choice_stack!=cutpt) {
1875  choice_stack=cutpt;
1876 #ifdef CLEAN_TRAIL
1878 #endif
1879  }
1880  }
1881  }
1882  else {
1883  Errorline("bad argument to %P.\n",t);
1884  success=FALSE;
1885  }
1886  }
1887  else {
1888  Errorline("bad argument %P.\n",t);
1889  success=FALSE;
1890  }
1891  }
1892  else
1893  curry();
1894 
1895  return success;
1896 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
long get_real_value(ptr_psi_term t, REAL *v, long *n)
get_real_value
Definition: built_ins.c:261
void get_one_arg(ptr_node t, ptr_psi_term *a)
get_one_arg
Definition: login.c:99
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
void curry()
curry
Definition: lefun.c:174
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
unsigned long time_stamp
Definition: def_struct.h:247
ptr_choice_point next
Definition: def_struct.h:250
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
static void clean_trail(ptr_choice_point cutpt)
clean_trail
Definition: login.c:810
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define deref(P)
Definition: def_macro.h:147
ptr_goal aim
Definition: def_glob.h:1024
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_node attr_list
Definition: def_struct.h:187
ptr_choice_point choice_stack
Definition: def_glob.h:1026
static long c_set_input ( )
static

c_set_input

C_SET_INPUT Set the current input stream to a given stream. If the given stream is closed, then do nothing.

Definition at line 2868 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, deref, deref_args, deref_ptr, equal_types, Errorline(), FALSE, get_stream(), get_two_args(), input_state, inputfilesym, NULL, restore_state(), save_state(), set_1, TRUE, and wl_psi_term::type.

2869 {
2870  long success=FALSE;
2871  ptr_psi_term arg1,arg2,g;
2872  FILE *thestream;
2873 
2874  g=aim->aaaa_1;
2875  deref_ptr(g);
2876  get_two_args(g->attr_list,&arg1,&arg2);
2877  if (arg1) {
2878  deref(arg1);
2879  deref_args(g,set_1);
2880  if (equal_types(arg1->type,inputfilesym)) {
2881  success=TRUE;
2883  thestream=get_stream(arg1);
2884  if (thestream!=NULL) {
2885  input_state=arg1;
2887  }
2888  }
2889  else
2890  Errorline("bad stream in %P.\n",g);
2891  }
2892  else
2893  Errorline("no stream in %P.\n",g);
2894 
2895  return success;
2896 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
FILE * get_stream(ptr_psi_term t)
get_stream
Definition: token.c:278
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
#define NULL
Definition: def_const.h:533
ptr_psi_term input_state
Definition: def_glob.h:856
ptr_definition inputfilesym
symbol in bi module
Definition: def_glob.h:501
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define deref(P)
Definition: def_macro.h:147
ptr_goal aim
Definition: def_glob.h:1024
#define equal_types(A, B)
Definition: def_macro.h:111
void restore_state(ptr_psi_term t)
restore_state
Definition: token.c:334
#define deref_args(P, S)
Definition: def_macro.h:150
void save_state(ptr_psi_term t)
save_state
Definition: token.c:293
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
static long c_set_output ( )
static

c_set_output

C_SET_OUTPUT Set the current output stream.

Definition at line 2905 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, deref, deref_args, deref_ptr, equal_types, Errorline(), FALSE, get_two_args(), output_stream, set_1, stream, TRUE, wl_psi_term::type, and wl_psi_term::value_3.

2906 {
2907  long success=FALSE;
2908  ptr_psi_term arg1,arg2,g;
2909 
2910  g=aim->aaaa_1;
2911  deref_ptr(g);
2912  get_two_args(g->attr_list,&arg1,&arg2);
2913  if(arg1) {
2914  deref(arg1);
2915  deref_args(g,set_1);
2916  if(equal_types(arg1->type,stream) && arg1->value_3) {
2917  success=TRUE;
2918  output_stream=(FILE *)arg1->value_3;
2919  }
2920  else
2921  Errorline("bad stream in %P.\n",g);
2922  }
2923  else
2924  Errorline("no stream in %P.\n",g);
2925 
2926  return success;
2927 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
ptr_definition stream
symbol in bi module
Definition: def_glob.h:382
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define deref(P)
Definition: def_macro.h:147
GENERIC value_3
Definition: def_struct.h:186
ptr_goal aim
Definition: def_glob.h:1024
#define equal_types(A, B)
Definition: def_macro.h:111
#define deref_args(P, S)
Definition: def_macro.h:150
FILE * output_stream
Definition: def_glob.h:1017
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
static long c_setq ( )
static

c_setq

C_SETQ

Create a function with one rule F -> X, where F and X are the arguments of setq. Setq evaluates its first argument and quotes the first. away any previous definition of F. F must be undefined or a function, there is an error if F is a sort or a predicate. This gives an error for a static function, but none for an undefined (i.e. uninterpreted) psi-term, which is made dynamic.

Definition at line 2336 of file built_ins.c.

References wl_goal::aaaa_1, wl_pair_list::aaaa_2, aim, wl_psi_term::attr_list, wl_pair_list::bbbb_2, clear_copy(), deref_ptr, deref_rec, Errorline(), FALSE, function_it, get_two_args(), HEAP, HEAP_ALLOC, heap_psi_term(), wl_pair_list::next, NULL, wl_definition::protected, quote_copy(), wl_definition::rule, TRUE, wl_psi_term::type, wl_definition::type_def, and undef_it.

2337 {
2338  long success=FALSE;
2339  ptr_psi_term arg1,arg2,g;
2340  ptr_pair_list p;
2341  ptr_definition d;
2342 
2343  g=aim->aaaa_1;
2344  get_two_args(g->attr_list,&arg1,&arg2);
2345  if (arg1 && arg2) {
2346  deref_rec(arg2); /* RM: Jan 6 1993 */
2347  deref_ptr(arg1);
2348  d=arg1->type;
2350  if (d->type_def==(def_type)undef_it || !d->protected) {
2351  if (!arg1->attr_list) {
2353  d->protected=FALSE;
2354  p=HEAP_ALLOC(pair_list);
2355  p->aaaa_2=heap_psi_term(4);
2356  p->aaaa_2->type=d;
2357  clear_copy();
2358  p->bbbb_2=quote_copy(arg2,HEAP);
2359  p->next=NULL;
2360  d->rule=p;
2361  success=TRUE;
2362  }
2363  else
2364  Errorline("%P may not have arguments in %P.\n",arg1,g);
2365  }
2366  else
2367  Errorline("%P should be dynamic in %P.\n",arg1,g);
2368  }
2369  else
2370  Errorline("%P should be a function or uninterpreted in %P.\n",arg1,g);
2371  }
2372  else
2373  Errorline("%P is missing one or both arguments.\n",g);
2374 
2375  return success;
2376 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
ptr_psi_term aaaa_2
Definition: def_struct.h:205
#define function_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1408
#define undef_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1394
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
#define HEAP
Flag to indicate heap allocation.
Definition: def_const.h:324
void clear_copy()
clear_copy
Definition: copy.c:53
struct wl_definition * def_type
Definition: def_struct.h:60
ptr_pair_list next
Definition: def_struct.h:207
ptr_psi_term heap_psi_term(long stat)
heap_psi_term
Definition: lefun.c:75
def_type type_def
Definition: def_struct.h:153
#define deref_rec(P)
Definition: def_macro.h:149
#define NULL
Definition: def_const.h:533
ptr_psi_term quote_copy(ptr_psi_term t, long heap_flag)
quote_copy
Definition: copy.c:186
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_pair_list rule
Definition: def_struct.h:148
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_psi_term bbbb_2
Definition: def_struct.h:206
ptr_goal aim
Definition: def_glob.h:1024
ptr_definition type
Definition: def_struct.h:181
#define HEAP_ALLOC(A)
Definition: def_macro.h:20
ptr_node attr_list
Definition: def_struct.h:187
static long c_split_double ( )
static

c_split_double

C_SPLIT_DOUBLE Split a double into two 32-bit words.

Definition at line 4034 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), deref_ptr, Errorline(), FALSE, get_real_value(), get_two_args(), REAL, residuate(), residuate2(), TRUE, and unify_real_result().

4035 {
4036  long success=FALSE;
4037  ptr_psi_term arg1,arg2,funct,result;
4038  long n;
4039  union {
4040  double d;
4041  struct {
4042  int hi;
4043  int lo;
4044  } w2;
4045  }hack;
4046  double hi,lo;
4047  long n1,n2;
4048 
4049  funct = aim->aaaa_1;
4050  deref_ptr(funct);
4051  result=aim->bbbb_1;
4052 
4053  get_two_args(funct->attr_list, &arg1, &arg2);
4054  if(arg1 && arg2) {
4055  deref_ptr(arg1);
4056  deref_ptr(arg2);
4057  deref_ptr(result);
4058  if(get_real_value(result,(REAL *)&(hack.d),&n) &&
4059  get_real_value(arg1 ,(REAL *)&hi ,&n1) &&
4060  get_real_value(arg2 ,(REAL *)&lo ,&n2)) {
4061 
4062 
4063  if(n) {
4064 
4065  (void)unify_real_result(arg1,(REAL)hack.w2.hi);
4066  (void)unify_real_result(arg2,(REAL)hack.w2.lo);
4067  success=TRUE;
4068  }
4069  else
4070  if(n1 && n2) {
4071 
4072  hack.w2.hi=(int)hi;
4073  hack.w2.lo=(int)lo;
4074  (void)unify_real_result(result,hack.d);
4075  success=TRUE;
4076  }
4077  else {
4078 
4079  residuate(result);
4080  residuate2(arg1,arg2);
4081  }
4082  }
4083  else
4084  Errorline("non-numeric arguments in %P\n",funct);
4085  }
4086  else
4087  curry();
4088 
4089  return success;
4090 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
long get_real_value(ptr_psi_term t, REAL *v, long *n)
get_real_value
Definition: built_ins.c:261
void curry()
curry
Definition: lefun.c:174
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
void residuate2(ptr_psi_term u, ptr_psi_term v)
residuate2
Definition: lefun.c:144
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_goal aim
Definition: def_glob.h:1024
long unify_real_result(ptr_psi_term t, REAL v)
unify_real_result
Definition: built_ins.c:386
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
static long c_static ( )
static

c_static

C_STATIC() Mark all the arguments as 'protected', i.e. they may not be changed by assert/retract/redefinition.

Definition at line 1642 of file built_ins.c.

References wl_goal::aaaa_1, aim, assert_protected(), wl_psi_term::attr_list, deref_ptr, and TRUE.

1643 {
1644  ptr_psi_term t=aim->aaaa_1;
1645  deref_ptr(t);
1646  /* mark_quote(t); 14.9 */
1648  return TRUE;
1649 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void assert_protected(ptr_node n, long prot)
assert_protected
Definition: types.c:255
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_goal aim
Definition: def_glob.h:1024
ptr_node attr_list
Definition: def_struct.h:187
static long c_string2psi ( )
static

c_string2psi

C_STRING2PSI(P) Convert a string to a psi-term whose name is the string's value.

Definition at line 4831 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, current_module, curry(), deref, deref_args, deref_ptr, error_psi_term, Errorline(), FALSE, get_module(), get_two_args(), NULL, overlap_type(), push_goal(), quoted_string, residuate(), set_1_2, stack_psi_term(), TRUE, wl_psi_term::type, unify, update_symbol(), wl_psi_term::value_3, and warningline().

4832 {
4833  long success=TRUE;
4834  ptr_psi_term arg1,arg2, funct,result,t;
4835  ptr_module mod=NULL; /* RM: Mar 11 1993 */
4836  ptr_module save_current; /* RM: Mar 12 1993 */
4837 
4838 
4839  funct=aim->aaaa_1;
4840  deref_ptr(funct);
4841  result=aim->bbbb_1;
4842  deref(result);
4843 
4844  get_two_args(funct->attr_list,&arg1,&arg2);
4845  if(arg1)
4846  deref(arg1);
4847  if(arg2)
4848  deref(arg2);
4849  deref_args(funct,set_1_2);
4850 
4851  if (arg1) {
4852  success=overlap_type(arg1->type,quoted_string);
4853  if(success) {
4854 
4855  /* RM: Mar 11 1993 */
4856  if(arg2)
4857  success=get_module(arg2,&mod);
4858 
4859  if (success) {
4860  if(!arg1->value_3)
4861  residuate(arg1);
4862  else {
4863  t=stack_psi_term(4);
4864  save_current=current_module;
4865  if(mod)
4866  current_module=mod;
4867  t->type=update_symbol(mod,(char *)arg1->value_3);
4868  current_module=save_current;
4869  if(t->type==error_psi_term->type)
4870  success=FALSE;
4871  else
4872  push_goal(unify,t,result,NULL);
4873  }
4874  }
4875  }
4876  else {
4877  success=FALSE;
4878  warningline("argument of '%P' is not a string.\n",funct);
4879  /* report_warning(funct,"argument is not a string"); 9.9 */
4880  }
4881  }
4882  else
4883  curry();
4884 
4885  if(!success)
4886  Errorline("error occurred in '%P'\n",funct);
4887 
4888  return success;
4889 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
ptr_module current_module
The current module for the tokenizer.
Definition: def_glob.h:729
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
long overlap_type(ptr_definition t1, ptr_definition t2)
overlap_type
Definition: types.c:1579
ptr_definition update_symbol(ptr_module module, char *symbol)
update_symbol
Definition: modules.c:270
int get_module(ptr_psi_term psi, ptr_module *module)
get_module
Definition: modules.c:1226
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define set_1_2
Set constants for deref_args in lefun.c.
Definition: def_const.h:514
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define deref(P)
Definition: def_macro.h:147
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
GENERIC value_3
Definition: def_struct.h:186
ptr_goal aim
Definition: def_glob.h:1024
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
ptr_psi_term error_psi_term
symbol in bi module
Definition: def_glob.h:118
#define deref_args(P, S)
Definition: def_macro.h:150
void warningline(char *format,...)
warningline
Definition: error.c:371
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
static long c_string_address ( )
static

c_string_address

C_STRING_ADDRESS Return the address of a string.

Definition at line 4099 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), deref_ptr, Errorline(), FALSE, get_real_value(), get_two_args(), matches(), NULL, push_goal(), quoted_string, REAL, residuate2(), stack_psi_term(), wl_psi_term::type, unify, unify_real_result(), and wl_psi_term::value_3.

4100 {
4101  long success=FALSE;
4102  ptr_psi_term arg1,arg2,funct,result,t;
4103  REAL val;
4104  long num;
4105  long smaller;
4106 
4107  funct = aim->aaaa_1;
4108  deref_ptr(funct);
4109  result=aim->bbbb_1;
4110 
4111  get_two_args(funct->attr_list, &arg1, &arg2);
4112  if(arg1) {
4113  deref_ptr(arg1);
4114  deref_ptr(result);
4115  success=matches(arg1->type,quoted_string,&smaller);
4116  if (success) {
4117  if (arg1->value_3) {
4118  (void)unify_real_result(result,(REAL)(long)(arg1->value_3));
4119  }
4120  else {
4121  if((success=get_real_value(result,&val,&num))) {
4122  if(num) {
4123  t=stack_psi_term(4);
4124  t->type=quoted_string;
4125  t->value_3=(GENERIC)&val; // changed to addr djd
4126  push_goal(unify,t,arg1,NULL);
4127  }
4128  else
4129  residuate2(arg1,result);
4130 
4131  }
4132  else
4133  Errorline("result is not a real in %P\n",funct);
4134  }
4135  }
4136  else
4137  Errorline("argument is not a string in %P\n",funct);
4138  }
4139  else
4140  curry();
4141 
4142  return success;
4143 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
long get_real_value(ptr_psi_term t, REAL *v, long *n)
get_real_value
Definition: built_ins.c:261
long matches(ptr_definition t1, ptr_definition t2, long *smaller)
matches
Definition: types.c:1666
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
void residuate2(ptr_psi_term u, ptr_psi_term v)
residuate2
Definition: lefun.c:144
#define deref_ptr(P)
Definition: def_macro.h:100
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
GENERIC value_3
Definition: def_struct.h:186
ptr_goal aim
Definition: def_glob.h:1024
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
long unify_real_result(ptr_psi_term t, REAL v)
unify_real_result
Definition: built_ins.c:386
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
long c_string_length ( )

c_string_length

C_STRING_LENGTH Return the length of the string in argument 1.

Definition at line 5726 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), wl_node::data, deref, deref_args, deref_ptr, FALSE, FEATCMP, find(), one, overlap_type(), quoted_string, residuate(), set_1, TRUE, wl_psi_term::type, and wl_psi_term::value_3.

5727 {
5728  ptr_psi_term result,funct;
5729  ptr_node n1;
5730  long success=TRUE;
5731  long all_args=TRUE;
5732  long c_result;
5733  ptr_psi_term arg1;
5734  char * c_arg1;
5735 
5736  funct=aim->aaaa_1;
5737  deref_ptr(funct);
5738  result=aim->bbbb_1;
5739 
5740  /* Evaluate all arguments first: */
5741  n1=find(FEATCMP,one,funct->attr_list);
5742  if (n1) {
5743  arg1= (ptr_psi_term )n1->data;
5744  deref(arg1);
5745  }
5746  deref_args(funct,set_1);
5747 
5748  if (success) {
5749  if (n1) {
5750  if (overlap_type(arg1->type,quoted_string)) /* 10.8 */
5751  if (arg1->value_3)
5752  c_arg1= (char *)arg1->value_3;
5753  else {
5754  residuate(arg1);
5755  all_args=FALSE;
5756  }
5757  else
5758  success=FALSE;
5759  }
5760  else {
5761  all_args=FALSE;
5762  curry();
5763  };
5764  };
5765 
5766  if (success && all_args) {
5767  c_result=strlen(c_arg1);
5768  push_goal(unify,real_stack_psi_term(0,(REAL)c_result),result,NULL);
5769  };
5770 
5771  return success;
5772 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
ptr_psi_term real_stack_psi_term(long stat, REAL thereal)
real_stack_psi_term
Definition: lefun.c:48
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
long overlap_type(ptr_definition t1, ptr_definition t2)
overlap_type
Definition: types.c:1579
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define deref(P)
Definition: def_macro.h:147
GENERIC value_3
Definition: def_struct.h:186
ptr_goal aim
Definition: def_glob.h:1024
char * one
Definition: def_glob.h:891
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
static long c_strip ( )
static

c_strip

C_STRIP Return the attributes of a psi-term, that is, a psi-term of type @ but with all the attributes of the argument.

Definition at line 3828 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, copy_attr_list(), curry(), deref, deref_args, deref_ptr, get_two_args(), merge_unify(), NULL, resid_aim, set_1, and TRUE.

3829 {
3830  long success=TRUE;
3831  ptr_psi_term arg1,arg2,funct,result;
3832 
3833  funct=aim->aaaa_1;
3834  deref_ptr(funct);
3835  result=aim->bbbb_1;
3836  get_two_args(funct->attr_list,&arg1,&arg2);
3837  if(arg1) {
3838  deref(arg1);
3839  deref_args(funct,set_1);
3840  resid_aim=NULL;
3841  /* PVR 23.2.94 */
3842  merge_unify(&(result->attr_list),copy_attr_list(arg1->attr_list));
3843  }
3844  else
3845  curry();
3846 
3847  return success;
3848 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
void merge_unify(ptr_node *u, ptr_node v)
merge_unify
Definition: login.c:1146
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
ptr_goal resid_aim
Definition: def_glob.h:865
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define deref(P)
Definition: def_macro.h:147
ptr_goal aim
Definition: def_glob.h:1024
#define deref_args(P, S)
Definition: def_macro.h:150
static ptr_node copy_attr_list(ptr_node n)
copy_attr_list
Definition: built_ins.c:3806
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
long c_sub_string ( )

c_sub_string

C_SUB_STRING Return the substring of argument 1 from position argument 2 for a length of argument 3 characters.

Definition at line 5781 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), wl_node::data, deref, deref_args, deref_ptr, FALSE, FEATCMP, find(), one, overlap_type(), quoted_string, residuate(), set_1_2_3, three, TRUE, two, wl_psi_term::type, and wl_psi_term::value_3.

5782 {
5783  ptr_psi_term result,funct,temp_result;
5784  ptr_node n1,n2,n3;
5785  long success=TRUE;
5786  long all_args=TRUE;
5787  char * c_result;
5788  ptr_psi_term arg1;
5789  char * c_arg1;
5790  ptr_psi_term arg2;
5791  long c_arg2;
5792  ptr_psi_term arg3;
5793  long c_arg3;
5794 
5795  funct=aim->aaaa_1;
5796  deref_ptr(funct);
5797  result=aim->bbbb_1;
5798 
5799  /* Evaluate all arguments first: */
5800  n1=find(FEATCMP,one,funct->attr_list);
5801  if (n1) {
5802  arg1= (ptr_psi_term )n1->data;
5803  deref(arg1);
5804  }
5805  n2=find(FEATCMP,two,funct->attr_list);
5806  if (n2) {
5807  arg2= (ptr_psi_term )n2->data;
5808  deref(arg2);
5809  }
5810  n3=find(FEATCMP,three,funct->attr_list);
5811  if (n3) {
5812  arg3= (ptr_psi_term )n3->data;
5813  deref(arg3);
5814  }
5815  deref_args(funct,set_1_2_3);
5816 
5817  if (success) {
5818  if (n1) {
5819  if (overlap_type(arg1->type,quoted_string)) /* 10.8 */
5820  if (arg1->value_3)
5821  c_arg1= (char *)arg1->value_3;
5822  else {
5823  residuate(arg1);
5824  all_args=FALSE;
5825  }
5826  else
5827  success=FALSE;
5828  }
5829  else {
5830  all_args=FALSE;
5831  curry();
5832  };
5833  };
5834 
5835  if (success) {
5836  if (n2) {
5837  if (overlap_type(arg2->type,integer)) /* 10.8 */
5838  if (arg2->value_3)
5839  c_arg2= (long)(* (double *)(arg2->value_3));
5840  else {
5841  residuate(arg2);
5842  all_args=FALSE;
5843  }
5844  else
5845  success=FALSE;
5846  }
5847  else {
5848  all_args=FALSE;
5849  curry();
5850  };
5851  };
5852 
5853  if (success) {
5854  if (n3) {
5855  if (overlap_type(arg3->type,integer)) /* 10.8 */
5856  if (arg3->value_3)
5857  c_arg3= (long)(* (double *)(arg3->value_3));
5858  else {
5859  residuate(arg3);
5860  all_args=FALSE;
5861  }
5862  else
5863  success=FALSE;
5864  }
5865  else {
5866  all_args=FALSE;
5867  curry();
5868  };
5869  };
5870 
5871  if (success && all_args) {
5872  c_result=sub_str(c_arg1,c_arg2,c_arg3);
5873  temp_result=stack_psi_term(0);
5874  temp_result->type=quoted_string;
5875  temp_result->value_3=(GENERIC)c_result;
5876  push_goal(unify,temp_result,result,NULL);
5877  };
5878 
5879  return success;
5880 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
char * two
Definition: def_glob.h:892
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
char * three
Definition: def_glob.h:893
long overlap_type(ptr_definition t1, ptr_definition t2)
overlap_type
Definition: types.c:1579
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
char * sub_str(char *s, long p, long n)
sub_str
Definition: built_ins.c:5514
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define deref(P)
Definition: def_macro.h:147
#define set_1_2_3
Set constants for deref_args in lefun.c.
Definition: def_const.h:521
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
GENERIC value_3
Definition: def_struct.h:186
ptr_goal aim
Definition: def_glob.h:1024
char * one
Definition: def_glob.h:891
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
static long c_succeed ( )
static

c_succeed

C_SUCCEED Always succeed.

Definition at line 1400 of file built_ins.c.

References wl_goal::aaaa_1, aim, deref_args, set_empty, and TRUE.

1401 {
1402  ptr_psi_term t;
1403 
1404  t=aim->aaaa_1;
1405  deref_args(t,set_empty);
1406  return TRUE;
1407 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
#define set_empty
Set constants for deref_args in lefun.c.
Definition: def_const.h:493
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_goal aim
Definition: def_glob.h:1024
#define deref_args(P, S)
Definition: def_macro.h:150
static long c_such_that ( )
static

c_such_that

C_SUCH_THAT This implements 'Value | Goal'. First it unifies Value with the result, then it proves Goal.

This routine is different than the straight-forward implementation in Life which would have been: "V|G => cond(G,V,{})" because V is evaluated and unified before G is proved.

Definition at line 5011 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), DEFRULES, deref_args, deref_ptr, get_two_args(), i_check_out(), NULL, prove, push_goal(), resid_aim, set_1_2, TRUE, and unify.

5012 {
5013  long success=TRUE;
5014  ptr_psi_term arg1,arg2,funct,result;
5015 
5016  funct=aim->aaaa_1;
5017  deref_ptr(funct);
5018  result=aim->bbbb_1;
5019  get_two_args(funct->attr_list,&arg1,&arg2);
5020  if (arg1 && arg2) {
5021  deref_ptr(arg1);
5022  deref_ptr(arg2);
5023  deref_args(funct,set_1_2);
5024  resid_aim=NULL;
5026  push_goal(unify,arg1,result,NULL);
5027  (void)i_check_out(arg1);
5028  }
5029  else
5030  curry();
5031 
5032  return success;
5033 }
#define prove
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1051
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
#define DEFRULES
Must be different from NULL, a built-in index, and a pointer Used to indicate that the rules of the d...
Definition: def_const.h:302
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
ptr_goal resid_aim
Definition: def_glob.h:865
#define set_1_2
Set constants for deref_args in lefun.c.
Definition: def_const.h:514
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_goal aim
Definition: def_glob.h:1024
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
long i_check_out(ptr_psi_term t)
i_check_out
Definition: lefun.c:1033
static long c_undo ( )
static

c_undo

C_UNDO This will prove a goal on backtracking. This is a completely uninteresting implmentation which is equivalent to:

undo. undo(G) :- G.

The problem is that it can be affected by CUT. A correct implementation would be very simple: stack the pair (ADDRESS=NULL, VALUE=GOAL) onto the trail and when undoing push the goal onto the goal-stack.

Definition at line 4552 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, DEFRULES, deref_args, deref_ptr, Errorline(), FALSE, get_two_args(), NULL, prove, push_choice_point(), set_1, and TRUE.

4553 {
4554  long success=TRUE;
4555  ptr_psi_term arg1,arg2,g;
4556 
4557  g=aim->aaaa_1;
4558  deref_ptr(g);
4559  get_two_args(g->attr_list,&arg1,&arg2);
4560  if (arg1) {
4561  deref_args(g,set_1);
4563  }
4564  else {
4565  success=FALSE;
4566  Errorline("argument missing in %P.\n",g);
4567  }
4568 
4569  return success;
4570 }
#define prove
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1051
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
void push_choice_point(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_choice_point
Definition: login.c:638
#define DEFRULES
Must be different from NULL, a built-in index, and a pointer Used to indicate that the rules of the d...
Definition: def_const.h:302
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
#define NULL
Definition: def_const.h:533
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_goal aim
Definition: def_glob.h:1024
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_node attr_list
Definition: def_struct.h:187
static long c_unify_func ( )
static

c_unify_func

C_UNIFY_FUNC An explicit unify function that curries on its two arguments.

Definition at line 4425 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), deref, deref_args, deref_ptr, get_two_args(), NULL, push_goal(), set_1_2, TRUE, and unify.

4426 {
4427  long success=TRUE;
4428  ptr_psi_term funct,arg1,arg2,result;
4429 
4430  funct=aim->aaaa_1;
4431  deref_ptr(funct);
4432  get_two_args(funct->attr_list,&arg1,&arg2);
4433  if (arg1 && arg2) {
4434  deref(arg1);
4435  deref(arg2);
4436  deref_args(funct,set_1_2);
4437  result=aim->bbbb_1;
4438  push_goal(unify,arg1,result,NULL);
4439  push_goal(unify,arg1,arg2,NULL);
4440  }
4441  else
4442  curry();
4443 
4444  return success;
4445 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
#define set_1_2
Set constants for deref_args in lefun.c.
Definition: def_const.h:514
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define deref(P)
Definition: def_macro.h:147
ptr_goal aim
Definition: def_glob.h:1024
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
static long c_unify_pred ( )
static

c_unify_pred

C_UNIFY_PRED() This unifies its two arguments (i.e. implements the predicate A=B).

Definition at line 4454 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, deref_args, deref_ptr, Errorline(), FALSE, get_two_args(), NULL, push_goal(), set_1_2, TRUE, and unify.

4455 {
4456  long success=FALSE;
4457  ptr_psi_term arg1,arg2,g;
4458 
4459  g=aim->aaaa_1;
4460  deref_ptr(g);
4461  get_two_args(g->attr_list,&arg1,&arg2);
4462  if (arg1 && arg2) {
4463  deref_args(g,set_1_2);
4464  success=TRUE;
4465  push_goal(unify,arg1,arg2,NULL);
4466  }
4467  else
4468  Errorline("argument missing in %P.\n",g);
4469 
4470  return success;
4471 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
#define NULL
Definition: def_const.h:533
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define set_1_2
Set constants for deref_args in lefun.c.
Definition: def_const.h:514
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_goal aim
Definition: def_glob.h:1024
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_node attr_list
Definition: def_struct.h:187
static long c_var ( )
static

static long c_var()

C_VAR Return lf_true/lf_false iff argument is/is not '@' (top with no attributes).

Definition at line 1433 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), deref, deref_args, deref_ptr, get_one_arg(), lf_false, lf_true, NULL, push_goal(), resid_aim, set_1, stack_psi_term(), top, TRUE, wl_psi_term::type, and unify.

1434 {
1435  long success=TRUE;
1436  ptr_psi_term arg1,result,g,other;
1437 
1438  g=aim->aaaa_1;
1439  deref_ptr(g);
1440  result=aim->bbbb_1;
1441  deref(result);
1442  get_one_arg(g->attr_list,&arg1);
1443  if (arg1) {
1444  deref(arg1);
1445  deref_args(g,set_1);
1446  other=stack_psi_term(4); /* 19.11 */
1447  other->type=((arg1->type==top)&&(arg1->attr_list==NULL))?lf_true:lf_false;
1448  resid_aim=NULL;
1449  push_goal(unify,result,other,NULL);
1450  }
1451  else {
1452  curry();
1453  /* Errorline("argument missing in %P.\n",t); */
1454  /* return c_abort(); */
1455  }
1456 
1457  return success;
1458 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
ptr_definition lf_false
symbol in bi module
Definition: def_glob.h:284
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
void get_one_arg(ptr_node t, ptr_psi_term *a)
get_one_arg
Definition: login.c:99
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
ptr_goal resid_aim
Definition: def_glob.h:865
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define deref(P)
Definition: def_macro.h:147
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
ptr_goal aim
Definition: def_glob.h:1024
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
ptr_definition top
symbol in syntax module
Definition: def_glob.h:403
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_definition lf_true
symbol in bi module
Definition: def_glob.h:410
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
static long c_write ( )
static

c_write

C_WRITE Write a list of arguments. Print cyclical terms correctly, but don't use the pretty printer indentation.

Definition at line 3177 of file built_ins.c.

References const_quote, FALSE, generic_write(), indent, write_canon, write_corefs, write_resids, and write_stderr.

3178 {
3179  indent=FALSE;
3185  return generic_write();
3186 }
long indent
Global flag that modifies how writing is done.
Definition: def_glob.h:793
long write_corefs
Global flag that modifies how writing is done.
Definition: def_glob.h:811
static long generic_write()
generic_write
Definition: built_ins.c:3118
long write_resids
Global flag that modifies how writing is done.
Definition: def_glob.h:817
#define FALSE
Standard boolean.
Definition: def_const.h:275
long const_quote
Global flag that modifies how writing is done.
Definition: def_glob.h:799
long write_stderr
Global flag that modifies how writing is done.
Definition: def_glob.h:805
long write_canon
Global flag that modifies how writing is done.
Definition: def_glob.h:823
static long c_write_canonical ( )
static

c_write_canonical

C_WRITE_CANONICAL Write a list of arguments in a form that allows them to be read in again. Print cyclical terms correctly, but don't use the pretty printer indentation.

Definition at line 3217 of file built_ins.c.

References const_quote, FALSE, generic_write(), indent, TRUE, write_canon, write_corefs, write_resids, and write_stderr.

3218 {
3219  indent=FALSE;
3220  const_quote=TRUE;
3224  write_canon=TRUE;
3225  return generic_write();
3226 }
long indent
Global flag that modifies how writing is done.
Definition: def_glob.h:793
long write_corefs
Global flag that modifies how writing is done.
Definition: def_glob.h:811
static long generic_write()
generic_write
Definition: built_ins.c:3118
long write_resids
Global flag that modifies how writing is done.
Definition: def_glob.h:817
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
long const_quote
Global flag that modifies how writing is done.
Definition: def_glob.h:799
long write_stderr
Global flag that modifies how writing is done.
Definition: def_glob.h:805
long write_canon
Global flag that modifies how writing is done.
Definition: def_glob.h:823
static long c_write_err ( )
static

c_write_err

C_WRITE_ERR Write a list of arguments to stderr. Print cyclical terms correctly, but don't use the pretty printer indentation.

Definition at line 3138 of file built_ins.c.

References const_quote, FALSE, generic_write(), indent, TRUE, write_canon, write_corefs, write_resids, and write_stderr.

3139 {
3140  indent=FALSE;
3146  return generic_write();
3147 }
long indent
Global flag that modifies how writing is done.
Definition: def_glob.h:793
long write_corefs
Global flag that modifies how writing is done.
Definition: def_glob.h:811
static long generic_write()
generic_write
Definition: built_ins.c:3118
long write_resids
Global flag that modifies how writing is done.
Definition: def_glob.h:817
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
long const_quote
Global flag that modifies how writing is done.
Definition: def_glob.h:799
long write_stderr
Global flag that modifies how writing is done.
Definition: def_glob.h:805
long write_canon
Global flag that modifies how writing is done.
Definition: def_glob.h:823
static long c_writeq ( )
static

c_writeq

C_WRITEQ Write a list of arguments in a form that allows them to be read in again. Print cyclical terms correctly, but don't use the pretty printer indentation.

Definition at line 3197 of file built_ins.c.

References const_quote, FALSE, generic_write(), indent, TRUE, write_canon, write_corefs, write_resids, and write_stderr.

3198 {
3199  indent=FALSE;
3200  const_quote=TRUE;
3205  return generic_write();
3206 }
long indent
Global flag that modifies how writing is done.
Definition: def_glob.h:793
long write_corefs
Global flag that modifies how writing is done.
Definition: def_glob.h:811
static long generic_write()
generic_write
Definition: built_ins.c:3118
long write_resids
Global flag that modifies how writing is done.
Definition: def_glob.h:817
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
long const_quote
Global flag that modifies how writing is done.
Definition: def_glob.h:799
long write_stderr
Global flag that modifies how writing is done.
Definition: def_glob.h:805
long write_canon
Global flag that modifies how writing is done.
Definition: def_glob.h:823
static long c_writeq_err ( )
static

c_writeq_err

C_WRITEQ_ERR Write a list of arguments to stderr in a form that allows them to be read in again. Print cyclical terms correctly, but don't use the pretty printer indentation.

Definition at line 3158 of file built_ins.c.

References const_quote, FALSE, generic_write(), indent, TRUE, write_canon, write_corefs, write_resids, and write_stderr.

3159 {
3160  indent=FALSE;
3161  const_quote=TRUE;
3166  return generic_write();
3167 }
long indent
Global flag that modifies how writing is done.
Definition: def_glob.h:793
long write_corefs
Global flag that modifies how writing is done.
Definition: def_glob.h:811
static long generic_write()
generic_write
Definition: built_ins.c:3118
long write_resids
Global flag that modifies how writing is done.
Definition: def_glob.h:817
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
long const_quote
Global flag that modifies how writing is done.
Definition: def_glob.h:799
long write_stderr
Global flag that modifies how writing is done.
Definition: def_glob.h:805
long write_canon
Global flag that modifies how writing is done.
Definition: def_glob.h:823
static long c_xor ( )
static

c_xor

C_XOR Logical exclusive or. This function does all possible local propagations.

Definition at line 1080 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), deref, deref_args, deref_ptr, Errorline(), FALSE, get_bool(), get_two_args(), matches(), NULL, push_goal(), residuate(), set_1_2, TRUE, wl_psi_term::type, UNDEF, unify, unify_bool(), and unify_bool_result().

1081 {
1082  long success=TRUE;
1083  ptr_psi_term funct,arg1,arg2,arg3;
1084  long sm1, sm2, sm3;
1085  long a1comp, a2comp, a3comp;
1086  long a1, a2, a3;
1087 
1088  funct=aim->aaaa_1;
1089  deref_ptr(funct);
1090  get_two_args(funct->attr_list,&arg1,&arg2);
1091  if (arg1 && arg2) {
1092  deref(arg1);
1093  deref(arg2);
1094  deref_args(funct,set_1_2);
1095  arg3=aim->bbbb_1;
1096  deref(arg3);
1097 
1098  a1comp = matches(arg1->type,boolean,&sm1);
1099  a2comp = matches(arg2->type,boolean,&sm2);
1100  a3comp = matches(arg3->type,boolean,&sm3);
1101  if (a1comp && a2comp && a3comp) {
1102  a1 = get_bool(arg1->type);
1103  a2 = get_bool(arg2->type);
1104  a3 = get_bool(arg3->type);
1105  if ((a1==TRUE || a1==FALSE) && (a2==TRUE || a2==FALSE)) {
1106  unify_bool_result(arg3, a1^a2);
1107  } else if ((a1==TRUE || a1==FALSE) && (a3==TRUE || a3==FALSE)) {
1108  unify_bool_result(arg2, a1^a3);
1109  } else if ((a3==TRUE || a3==FALSE) && (a2==TRUE || a2==FALSE)) {
1110  unify_bool_result(arg1, a3^a2);
1111 
1112  } else if (a1==TRUE && arg3==arg2) {
1113  success=FALSE;
1114  } else if (a2==TRUE && arg3==arg2) {
1115  success=FALSE;
1116  } else if (a3==TRUE && arg1==arg2) {
1117  success=FALSE;
1118 
1119  } else if (a1==FALSE) {
1120  push_goal(unify,arg2,arg3,(GENERIC)NULL);
1121  } else if (a2==FALSE) {
1122  push_goal(unify,arg1,arg3,(GENERIC)NULL);
1123  } else if (a3==FALSE) {
1124  push_goal(unify,arg1,arg2,(GENERIC)NULL);
1125 
1126  } else if (arg1==arg2) {
1127  unify_bool_result(arg3,FALSE);
1128  } else if (arg1==arg3) {
1129  unify_bool_result(arg2,FALSE);
1130  } else if (arg3==arg2) {
1131  unify_bool_result(arg1,FALSE);
1132  } else {
1133  if (a1==UNDEF) residuate(arg1);
1134  if (a2==UNDEF) residuate(arg2);
1135  if (a3==UNDEF) residuate(arg3);
1136  }
1137  if (!sm1) unify_bool(arg1);
1138  if (!sm2) unify_bool(arg2);
1139  if (!sm3) unify_bool(arg3);
1140  }
1141  else {
1142  success=FALSE;
1143  Errorline("Non-boolean argument or result in '%P'.\n",funct);
1144  }
1145  }
1146  else
1147  curry();
1148 
1149  return success;
1150 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
void unify_bool_result(ptr_psi_term t, long v)
unify_bool_result
Definition: built_ins.c:344
static void unify_bool(ptr_psi_term arg)
unify_bool
Definition: built_ins.c:911
long matches(ptr_definition t1, ptr_definition t2, long *smaller)
matches
Definition: types.c:1666
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define set_1_2
Set constants for deref_args in lefun.c.
Definition: def_const.h:514
#define UNDEF
For LIFE boolean calculation built-in.
Definition: def_const.h:288
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define deref(P)
Definition: def_macro.h:147
ptr_goal aim
Definition: def_glob.h:1024
static long get_bool(ptr_definition typ)
get_bool
Definition: built_ins.c:898
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
long check_real ( ptr_psi_term  t,
REAL v,
long *  n 
)

check_real

Parameters
t- ptr_psi_term t
v- REAL *v
n- long *n

CHECK_REAL(t,v,n) Like get_real_value, but does not force the type of T to be real.

Definition at line 231 of file built_ins.c.

References FALSE, matches(), REAL, real, TRUE, wl_psi_term::type, and wl_psi_term::value_3.

232 {
233  long success=FALSE;
234  long smaller;
235 
236  if (t) {
237  success=matches(t->type,real,&smaller);
238  if (success) {
239  *n=FALSE;
240  if (smaller && t->value_3) {
241  *v= *(REAL *)t->value_3;
242  *n=TRUE;
243  }
244  }
245  }
246  return success;
247 }
long matches(ptr_definition t1, ptr_definition t2, long *smaller)
matches
Definition: types.c:1666
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
ptr_definition real
symbol in bi module
Definition: def_glob.h:375
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
GENERIC value_3
Definition: def_struct.h:186
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term collect_symbols ( long  sel)

collect_symbols

Parameters
sel- long sel

Collect properties of the symbols in the symbol table, and make a psi-term list of them. This routine is parameterized (by sel) to collect three properties:

  1. All symbols that are types with no parents.
  2. All symbols that are of 'undef' type.
  3. The operator triples of all operators.

Note the similarity between this routine and a tree-to-list routine in Prolog. The pointer manipulations are simpler in Prolog, though.

If the number of symbols is very large, this routine may run out of space before garbage collection.

Definition at line 3699 of file built_ins.c.

References wl_definition::children, first_definition, fx, fx_sym, fy, fy_sym, greatest_sel, hidden_type(), least_sel, wl_operator_data::next, wl_definition::next, nothing, NULL, one, wl_definition::op_data, op_sel, opsym, wl_definition::parents, wl_operator_data::precedence, stack_add_int_attr(), stack_add_psi_attr(), stack_cons(), stack_nil(), stack_psi_term(), three, top, two, wl_psi_term::type, wl_definition::type_def, type_it, undef_it, xf, xf_sym, xfx, xfx_sym, xfy, xfy_sym, yf, yf_sym, yfx, and yfx_sym.

3700 {
3701  ptr_psi_term new;
3702  ptr_definition def;
3703  long botflag;
3704  ptr_psi_term result;
3705 
3706 
3707  result=stack_nil();
3708 
3709  for(def=first_definition;def;def=def->next) {
3710 
3711  if (sel==least_sel || sel==greatest_sel) {
3712  botflag=(sel==least_sel);
3713 
3714  /* Insert the node if it's a good one */
3715  if (((botflag?def->children:def->parents)==NULL &&
3716  def!=top && def!=nothing &&
3717  def->type_def==(def_type)type_it ||
3718  def->type_def==(def_type)undef_it)
3719  && !hidden_type(def)) {
3720  /* Create the node that will be inserted */
3721  new=stack_psi_term(4);
3722  new->type=def;
3723  result=stack_cons((ptr_psi_term)new,(ptr_psi_term)result);
3724  }
3725  }
3726  else if (sel==op_sel) {
3727  ptr_operator_data od=def->op_data;
3728 
3729  while (od) {
3730  ptr_psi_term name_loc,type;
3731 
3732  new=stack_psi_term(4);
3733  new->type=opsym;
3734  result=stack_cons((ptr_psi_term)new,(ptr_psi_term)result);
3735 
3737 
3738  type=stack_psi_term(4);
3739  switch (od->type) {
3740  case xf:
3741  type->type=xf_sym;
3742  break;
3743  case yf:
3744  type->type=yf_sym;
3745  break;
3746  case fx:
3747  type->type=fx_sym;
3748  break;
3749  case fy:
3750  type->type=fy_sym;
3751  break;
3752  case xfx:
3753  type->type=xfx_sym;
3754  break;
3755  case xfy:
3756  type->type=xfy_sym;
3757  break;
3758  case yfx:
3759  type->type=yfx_sym;
3760  break;
3761  }
3762  stack_add_psi_attr(new,two,type);
3763 
3764  name_loc=stack_psi_term(4);
3765  name_loc->type=def;
3766  stack_add_psi_attr(new,three,name_loc);
3767 
3768  od=od->next;
3769  }
3770  }
3771  }
3772 
3773  return result;
3774 }
#define undef_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1394
#define yfx
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:1037
ptr_definition xf_sym
symbol in bi module
Definition: def_glob.h:515
ptr_psi_term stack_cons(ptr_psi_term head, ptr_psi_term tail)
stack_cons
Definition: built_ins.c:46
#define least_sel
used by collect_symbols in built_ins.c
Definition: def_const.h:11
ptr_definition nothing
symbol in bi module
Definition: def_glob.h:347
#define xfx
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:1021
ptr_definition first_definition
All definition are stores in a linked list starting at first_definition.
Definition: def_glob.h:13
char * two
Definition: def_glob.h:892
ptr_operator_data next
Definition: def_struct.h:76
#define fx
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:1000
def_type type_def
Definition: def_struct.h:153
ptr_definition fx_sym
symbol in bi module
Definition: def_glob.h:522
ptr_definition opsym
symbol in bi module
Definition: def_glob.h:445
#define NULL
Definition: def_const.h:533
#define xfy
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:1030
char * three
Definition: def_glob.h:893
#define op_sel
used by collect_symbols in built_ins.c
Definition: def_const.h:25
void stack_add_psi_attr(ptr_psi_term t, char *attrname, ptr_psi_term g)
stack_add_psi_attr
Definition: token.c:239
#define type_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1415
ptr_definition yf_sym
symbol in bi module
Definition: def_glob.h:529
ptr_definition next
Definition: def_struct.h:164
void stack_add_int_attr(ptr_psi_term t, char *attrname, long value)
stack_add_int_attr
Definition: token.c:94
#define greatest_sel
used by collect_symbols in built_ins.c
Definition: def_const.h:18
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
ptr_definition xfy_sym
symbol in bi module
Definition: def_glob.h:550
ptr_psi_term stack_nil()
stack_nil
Definition: built_ins.c:26
char * one
Definition: def_glob.h:891
#define xf
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:993
#define yf
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:1007
ptr_definition top
symbol in syntax module
Definition: def_glob.h:403
ptr_definition yfx_sym
symbol in bi module
Definition: def_glob.h:557
ptr_definition fy_sym
symbol in bi module
Definition: def_glob.h:536
ptr_definition type
Definition: def_struct.h:181
ptr_definition xfx_sym
symbol in bi module
Definition: def_glob.h:543
long hidden_type(ptr_definition t)
hidden_type
Definition: built_ins.c:3672
ptr_int_list children
Definition: def_struct.h:152
ptr_operator_data op_data
Definition: def_struct.h:158
#define fy
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:1014
ptr_int_list parents
Definition: def_struct.h:151
static ptr_node copy_attr_list ( ptr_node  n)
static

copy_attr_list

Parameters
n- ptr_node n

PVR 23.2.94 – Added this to fix c_strip and c_copy_pointer Make a copy of an attr_list structure, keeping the same leaf pointers

Definition at line 3806 of file built_ins.c.

References wl_node::data, wl_node::key, wl_node::left, NULL, wl_node::right, and STACK_ALLOC.

3807 {
3808  ptr_node m;
3809 
3810  if (n==NULL) return NULL;
3811 
3812  m = STACK_ALLOC(node);
3813  m->key = n->key;
3814  m->data = n->data;
3815  m->left = copy_attr_list(n->left);
3816  m->right = copy_attr_list(n->right);
3817  return m;
3818 }
GENERIC data
Definition: def_struct.h:201
#define NULL
Definition: def_const.h:533
ptr_node left
Definition: def_struct.h:199
char * key
Definition: def_struct.h:198
#define STACK_ALLOC(A)
Definition: def_macro.h:21
static ptr_node copy_attr_list(ptr_node n)
copy_attr_list
Definition: built_ins.c:3806
ptr_node right
Definition: def_struct.h:200
long declare_operator ( ptr_psi_term  t)

declare_operator

Parameters
t- ptr_psi_term t

DECLARE_OPERATOR(t) Declare a new operator or change a pre-existing one.

For example: 'op'(3,xfx,+)? T is the OP declaration.

Definition at line 5436 of file built_ins.c.

References wl_psi_term::attr_list, wl_node::data, deref_ptr, Errorline(), FALSE, FEATCMP, find(), fx, fx_sym, fy, fy_sym, get_two_args(), integer, wl_definition::keyword, MAX_PRECEDENCE, nop, op_declare(), REAL, sub_type(), wl_keyword::symbol, three, TRUE, wl_psi_term::type, wl_psi_term::value_3, xf, xf_sym, xfx, xfx_sym, xfy, xfy_sym, yf, yf_sym, yfx, and yfx_sym.

5437 {
5438  ptr_psi_term prec,type,atom;
5439  ptr_node n;
5440  char *s;
5441  long p;
5442  operator kind=nop;
5443  long success=FALSE;
5444 
5445  deref_ptr(t);
5446  n=t->attr_list;
5447  get_two_args(n,&prec,&type);
5448  n=find(FEATCMP,three,n);
5449  if (n && prec && type) {
5450  atom=(ptr_psi_term )n->data;
5451  deref_ptr(prec);
5452  deref_ptr(type);
5453  deref_ptr(atom);
5454  if (!atom->value_3) {
5455  s=atom->type->keyword->symbol;
5456  if (sub_type(prec->type,integer) && prec->value_3) { /* 10.8 */
5457  p = * (REAL *)prec->value_3;
5458  if (p>0 && p<=MAX_PRECEDENCE) {
5459 
5460  if (type->type == xf_sym) kind=xf;
5461  else if (type->type == yf_sym) kind=yf;
5462  else if (type->type == fx_sym) kind=fx;
5463  else if (type->type == fy_sym) kind=fy;
5464  else if (type->type == xfx_sym) kind=xfx;
5465  else if (type->type == xfy_sym) kind=xfy;
5466  else if (type->type == yfx_sym) kind=yfx;
5467  else
5468  Errorline("bad operator kind '%s'.\n",type->type->keyword->symbol);
5469 
5470  if (kind!=nop) {
5471  op_declare(p,kind,s);
5472  success=TRUE;
5473  }
5474  }
5475  else
5476  Errorline("precedence must range from 1 to 1200 in %P.\n",t);
5477  }
5478  else
5479  Errorline("precedence must be a positive integer in %P.\n",t);
5480  }
5481  else
5482  Errorline("numbers or strings may not be operators in %P.\n",t);
5483  }
5484  else
5485  Errorline("argument missing in %P.\n",t);
5486 
5487  return success;
5488 }
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
#define yfx
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:1037
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
ptr_definition xf_sym
symbol in bi module
Definition: def_glob.h:515
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
#define xfx
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:1021
#define fx
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:1000
ptr_definition fx_sym
symbol in bi module
Definition: def_glob.h:522
ptr_keyword keyword
Definition: def_struct.h:147
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
#define xfy
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:1030
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
char * three
Definition: def_glob.h:893
char * symbol
Definition: def_struct.h:118
#define nop
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:986
long sub_type(ptr_definition t1, ptr_definition t2)
sub_type
Definition: types.c:1642
ptr_definition yf_sym
symbol in bi module
Definition: def_glob.h:529
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
GENERIC value_3
Definition: def_struct.h:186
ptr_definition xfy_sym
symbol in bi module
Definition: def_glob.h:550
#define xf
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:993
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
#define yf
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:1007
#define MAX_PRECEDENCE
Maximum operator precedence.
Definition: def_const.h:205
ptr_definition yfx_sym
symbol in bi module
Definition: def_glob.h:557
ptr_definition fy_sym
symbol in bi module
Definition: def_glob.h:536
static void op_declare(long p, operator t, char *s)
op_declare
Definition: built_ins.c:5404
ptr_definition type
Definition: def_struct.h:181
ptr_definition xfx_sym
symbol in bi module
Definition: def_glob.h:543
ptr_node attr_list
Definition: def_struct.h:187
#define fy
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:1014
void exit_life ( long  nl_flag)

exit_life

Parameters
nl_flag- long nl_flag

Definition at line 2219 of file built_ins.c.

References garbage_time, life_end, life_start, NOTQUIET, and open_input_file().

2220 {
2221  (void)open_input_file("stdin");
2222  (void)times(&life_end);
2223  if (NOTQUIET) { /* 21.1 */
2224  if (nl_flag) printf("\n");
2225  printf("*** Exiting Wild_Life ");
2226  printf("[%1.3fs cpu, %1.3fs gc (%2.1f%%)]\n",
2227  (life_end.tms_utime-life_start.tms_utime)/60.0,
2228  garbage_time,
2229  garbage_time*100 / ((life_end.tms_utime-life_start.tms_utime)/60.0)
2230  );
2231  }
2232 
2233 #ifdef ARITY /* RM: Mar 29 1993 */
2234  arity_end();
2235 #endif
2236 
2237  exit(EXIT_SUCCESS);
2238 }
struct tms life_end
Definition: def_glob.h:90
float garbage_time
total time on garbage collections - seconds
Definition: def_glob.h:76
#define NOTQUIET
Definition: def_macro.h:15
struct tms life_start
time life started - seconds
Definition: def_glob.h:83
long open_input_file(char *file)
open_input_file
Definition: token.c:594
long file_exists ( char *  s)

file_exists

Parameters
s- char *s

Definition at line 1711 of file built_ins.c.

References expand_file_name(), FALSE, and TRUE.

1712 {
1713  FILE *f;
1714  char *e;
1715  long success=FALSE;
1716 
1717  e=expand_file_name(s);
1718  if ((f=fopen(e,"r"))) {
1719  (void)fclose(f);
1720  success=TRUE;
1721  }
1722  return success;
1723 }
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
char * expand_file_name(char *s)
expand_file_name
Definition: token.c:537
static long generic_write ( )
static

generic_write

GENERIC_WRITE Implements write, writeq, pretty_write, pretty_writeq.

Definition at line 3118 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, deref_args, pred_write(), set_empty, and TRUE.

3119 {
3120  ptr_psi_term g;
3121 
3122  g=aim->aaaa_1;
3123  /* deref_rec(g); */
3124  deref_args(g,set_empty);
3125  pred_write(g->attr_list);
3126  /* fflush(output_stream); */
3127  return TRUE;
3128 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
#define set_empty
Set constants for deref_args in lefun.c.
Definition: def_const.h:493
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_goal aim
Definition: def_glob.h:1024
void pred_write(ptr_node n)
pred_write
Definition: print.c:1469
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_node attr_list
Definition: def_struct.h:187
static long get_bool ( ptr_definition  typ)
static

get_bool

Parameters
typ- ptr_definition typ

Definition at line 898 of file built_ins.c.

References FALSE, lf_false, lf_true, sub_type(), TRUE, and UNDEF.

899 {
900  if (sub_type(typ,lf_true)) return TRUE;
901  else if (sub_type(typ,lf_false)) return FALSE;
902  else return UNDEF;
903 }
ptr_definition lf_false
symbol in bi module
Definition: def_glob.h:284
long sub_type(ptr_definition t1, ptr_definition t2)
sub_type
Definition: types.c:1642
#define UNDEF
For LIFE boolean calculation built-in.
Definition: def_const.h:288
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_definition lf_true
symbol in bi module
Definition: def_glob.h:410
static long get_bool_value ( ptr_psi_term  t,
REAL v,
long *  n 
)
static

get_bool_value

Parameters
t- ptr_psi_term t
v- REAL *v
n- long *n

GET_BOOL_VALUE(t,v,n) This is identical in nature to GET_REAL_VALUE. The values handled here have to be booleans. Check if psi_term T is a boolean. V <- TRUE or FALSE value of T.

Definition at line 300 of file built_ins.c.

References boolean, def_ptr, FALSE, heap_pointer, i_check_out(), int_ptr, lf_false, lf_true, matches(), push_ptr_value(), wl_psi_term::status, TRUE, and wl_psi_term::type.

301 {
302  long success=FALSE;
303  long smaller;
304 
305  if(t) {
306  success=matches(t->type,boolean,&smaller);
307  if(success) {
308  *n=FALSE;
309  if(smaller) {
310  if(matches(t->type,lf_false,&smaller) && smaller) {
311  *v= 0;
312  *n=TRUE;
313  }
314  else
315  if(matches(t->type,lf_true,&smaller) && smaller) {
316  *v= 1;
317  *n=TRUE;
318  }
319  }
320  else {
321  if((GENERIC)t<heap_pointer) { /* RM: Jun 8 1993 */
324  t->type=boolean;
325  t->status=0;
326  (void)i_check_out(t);
327  }
328  }
329  }
330  }
331 
332  return success;
333 }
void push_ptr_value(type_ptr t, GENERIC *p)
push_ptr_value
Definition: login.c:383
GENERIC heap_pointer
used to allocate from heap - size allocated subtracted - adj for alignment
Definition: def_glob.h:55
ptr_definition lf_false
symbol in bi module
Definition: def_glob.h:284
#define def_ptr
values of type_ptr
Definition: def_const.h:404
long matches(ptr_definition t1, ptr_definition t2, long *smaller)
matches
Definition: types.c:1666
ptr_definition boolean
symbol in bi module
Definition: def_glob.h:185
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_definition lf_true
symbol in bi module
Definition: def_glob.h:410
ptr_definition type
Definition: def_struct.h:181
long i_check_out(ptr_psi_term t)
i_check_out
Definition: lefun.c:1033
#define int_ptr
values of type_ptr
Definition: def_const.h:397
long get_real_value ( ptr_psi_term  t,
REAL v,
long *  n 
)

get_real_value

Parameters
t- ptr_psi_term t
v- REAL *v
n- long *n

GET_REAL_VALUE(t,v,n) Check if psi_term T is a real number. Return N=TRUE iff T <| REAL. If T has a real value then set V to that value. Also force the type of T to REAL if REAL <| T. This is used in all the arithmetic built-in functions to get their arguments.

Definition at line 261 of file built_ins.c.

References def_ptr, FALSE, heap_pointer, i_check_out(), int_ptr, matches(), push_ptr_value(), REAL, real, wl_psi_term::status, TRUE, wl_psi_term::type, and wl_psi_term::value_3.

262 {
263  long success=FALSE;
264  long smaller;
265  if (t) {
266  success=matches(t->type,real,&smaller);
267  if (success) {
268  *n=FALSE;
269  if (smaller) {
270  if (t->value_3) {
271  *v= *(REAL *)t->value_3;
272  *n=TRUE;
273  }
274  }
275  else {
276  if((GENERIC)t<heap_pointer) { /* RM: Jun 8 1993 */
279  t->type=real;
280  t->status=0;
281  (void)i_check_out(t);
282  }
283  }
284  }
285  }
286  return success;
287 }
void push_ptr_value(type_ptr t, GENERIC *p)
push_ptr_value
Definition: login.c:383
GENERIC heap_pointer
used to allocate from heap - size allocated subtracted - adj for alignment
Definition: def_glob.h:55
#define def_ptr
values of type_ptr
Definition: def_const.h:404
long matches(ptr_definition t1, ptr_definition t2, long *smaller)
matches
Definition: types.c:1666
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
ptr_definition real
symbol in bi module
Definition: def_glob.h:375
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
GENERIC value_3
Definition: def_struct.h:186
ptr_definition type
Definition: def_struct.h:181
long i_check_out(ptr_psi_term t)
i_check_out
Definition: lefun.c:1033
#define int_ptr
values of type_ptr
Definition: def_const.h:397
void global_error_check ( ptr_node  n,
int *  error,
int *  eval_2 
)

global_error_check

Parameters
n- ptr_node n
error- int *error
eval_2- int *eval_2

Definition at line 2591 of file built_ins.c.

References wl_psi_term::attr_list, wl_node::data, deref_eval(), deref_ptr, error_psi_term, Errorline(), FALSE, get_two_args(), global_error_check(), global_it, wl_node::left, leftarrowsym, NULL, wl_node::right, TRUE, wl_psi_term::type, wl_definition::type_def, undef_it, and wl_psi_term::value_3.

2592 {
2593  if (n) {
2594  ptr_psi_term t,a1,a2;
2595  int bad_init=FALSE;
2596  global_error_check(n->left, error, eval_2);
2597 
2598  t=(ptr_psi_term)n->data;
2599  deref_ptr(t);
2600  if (t->type==leftarrowsym) {
2601  get_two_args(t->attr_list,&a1,&a2);
2602  if (a1==NULL || a2==NULL) {
2603  Errorline("%P is an incorrect global variable declaration (%E).\n",t);
2604  *error=TRUE;
2605  bad_init=TRUE;
2606  } else {
2607  deref_ptr(a1);
2608  deref_ptr(a2);
2609  t=a1;
2610  if (deref_eval(a2)) *eval_2=TRUE;
2611  }
2612  }
2613  if (!bad_init && t->type->type_def!=(def_type)undef_it && t->type->type_def!=(def_type)global_it) {
2614  Errorline("%T %P cannot be redeclared as a global variable (%E).\n",
2615  t->type->type_def,
2616  t);
2617  t->type=error_psi_term->type;
2618  t->value_3=NULL; /* RM: Mar 23 1993 */
2619  *error=TRUE;
2620  }
2621 
2622  global_error_check(n->right, error, eval_2);
2623  }
2624 }
#define undef_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1394
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
def_type type_def
Definition: def_struct.h:153
void global_error_check(ptr_node n, int *error, int *eval_2)
global_error_check
Definition: built_ins.c:2591
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
#define global_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1422
GENERIC data
Definition: def_struct.h:201
#define NULL
Definition: def_const.h:533
ptr_node left
Definition: def_struct.h:199
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
GENERIC value_3
Definition: def_struct.h:186
ptr_psi_term error_psi_term
symbol in bi module
Definition: def_glob.h:118
long deref_eval(ptr_psi_term t)
deref_eval
Definition: lefun.c:1180
ptr_definition leftarrowsym
symbol in syntax module
Definition: def_glob.h:277
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
ptr_node right
Definition: def_struct.h:200
void global_one ( ptr_psi_term  t)

global_one

Parameters
t- ptr_psi_term t

Definition at line 2651 of file built_ins.c.

References wl_psi_term::attr_list, clear_copy(), deref_ptr, get_two_args(), global_it, HEAP, wl_definition::init_value, leftarrowsym, quote_copy(), stack_psi_term(), wl_psi_term::type, and wl_definition::type_def.

2652 {
2653  ptr_psi_term u; // ,val;
2654 
2655  if (t->type==leftarrowsym) {
2656  get_two_args(t->attr_list,&t,&u);
2657  deref_ptr(t);
2658  deref_ptr(u);
2659  }
2660  else
2661  u=stack_psi_term(4);
2662 
2663  clear_copy();
2665  t->type->init_value=quote_copy(u,HEAP); /* RM: Mar 23 1993 */
2666 
2667  /* eval_global_var(t); RM: Feb 4 1994 */
2668 
2669  /* RM: Nov 10 1993
2670  val=t->type->global_value;
2671  if (val && (GENERIC)val<heap_pointer) {
2672  deref_ptr(val);
2673  push_psi_ptr_value(val,&(val->coref));
2674  val->coref=u;
2675  } else
2676  t->type->global_value=u;
2677  */
2678 }
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
ptr_psi_term init_value
Definition: def_struct.h:160
#define HEAP
Flag to indicate heap allocation.
Definition: def_const.h:324
void clear_copy()
clear_copy
Definition: copy.c:53
struct wl_definition * def_type
Definition: def_struct.h:60
def_type type_def
Definition: def_struct.h:153
#define global_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1422
ptr_psi_term quote_copy(ptr_psi_term t, long heap_flag)
quote_copy
Definition: copy.c:186
#define deref_ptr(P)
Definition: def_macro.h:100
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
ptr_definition leftarrowsym
symbol in syntax module
Definition: def_glob.h:277
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
void global_tree ( ptr_node  n)

global_tree

Parameters
n- ptr_node n

Definition at line 2631 of file built_ins.c.

References wl_node::data, deref_ptr, global_one(), global_tree(), wl_node::left, and wl_node::right.

2632 {
2633  if (n) {
2634  ptr_psi_term t;
2635  global_tree(n->left);
2636 
2637  t=(ptr_psi_term)n->data;
2638  deref_ptr(t);
2639  global_one(t);
2640 
2641  global_tree(n->right);
2642  }
2643 }
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
ptr_node left
Definition: def_struct.h:199
#define deref_ptr(P)
Definition: def_macro.h:100
void global_tree(ptr_node n)
global_tree
Definition: built_ins.c:2631
void global_one(ptr_psi_term t)
global_one
Definition: built_ins.c:2651
ptr_node right
Definition: def_struct.h:200
long has_rules ( ptr_pair_list  r)

has_rules

Parameters
r- ptr_pair_list r

Return TRUE iff there are some rules r This is true for a user-defined function or predicate with a definition, and for a type with constraints.

Definition at line 5101 of file built_ins.c.

References wl_pair_list::aaaa_2, FALSE, wl_pair_list::next, NULL, and TRUE.

5102 {
5103  if (r==NULL) return FALSE;
5104  while (r) {
5105  if (r->aaaa_2!=NULL) return TRUE;
5106  r=r->next;
5107  }
5108  return FALSE;
5109 }
ptr_psi_term aaaa_2
Definition: def_struct.h:205
ptr_pair_list next
Definition: def_struct.h:207
#define NULL
Definition: def_const.h:533
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
long hidden_type ( ptr_definition  t)

hidden_type

Parameters
t- ptr_definition t

Return TRUE iff T is a type that should not show up as part of the type hierarchy, i.e. it is an internal hidden type.

Definition at line 3672 of file built_ins.c.

References comment, constant, functor, and variable.

3673 {
3674  return (/* (t==conjunction) || 19.8 */
3675  /* (t==disjunction) || RM: Dec 9 1992 */
3676  (t==constant) || (t==variable) ||
3677  (t==comment) || (t==functor));
3678 }
ptr_definition functor
symbol in bi module
Definition: def_glob.h:298
ptr_definition comment
symbol in bi module
Definition: def_glob.h:227
ptr_definition variable
symbol in bi module
Definition: def_glob.h:438
ptr_definition constant
symbol in bi module
Definition: def_glob.h:235
void init_built_in_types ( )

init_built_in_types

INIT_BUILT_IN_TYPES Initialise the symbol tree with the built-in types. Declare all built-in predicates and functions. Initialise system type variables. Declare all standard operators.

Called by life.c

Definition at line 6155 of file built_ins.c.

References aborthooksym, abortsym, add_module1, add_module2, add_module3, alist, all_public_symbols(), and, apply, bi_module, boolpredsym, built_in, c_abort(), c_alias(), c_and(), c_append_file(), c_apply(), c_args(), c_ascii(), c_assert_first(), c_assert_last(), c_bk_assign(), c_boolpred(), c_char(), c_chdir(), c_clause(), c_close(), c_combined_name(), c_concatenate(), c_cond(), c_copy_pointer(), c_copy_term(), c_current_module(), c_declaration(), c_delay_check(), c_deref_length(), c_diff(), c_diff_address(), c_disj(), c_display_modules(), c_display_persistent(), c_dynamic(), c_equal(), c_eval(), c_eval_disjunction(), c_eval_inplace(), c_exist_feature(), c_exists(), c_exists_choice(), c_fail(), c_feature_values(), c_features(), c_get(), c_get_choice(), c_global(), c_global_assign(), c_gt(), c_gtoe(), c_halt(), c_implies(), c_initrandom(), c_int2string(), c_is_function(), c_is_predicate(), c_is_sort(), c_listing(), c_load(), c_lt(), c_ltoe(), c_module_name(), c_non_strict(), c_nonvar(), c_not(), c_not_implemented(), c_op(), c_open_in(), c_open_module(), c_open_out(), c_ops(), c_or(), c_page_width(), c_parse(), c_persistent(), c_print_codes(), c_print_depth(), c_print_variables(), c_private(), c_private_feature(), c_project(), c_psi2string(), c_public(), c_put(), c_put_err(), c_pwrite(), c_pwriteq(), c_random(), c_read_psi(), c_read_token(), c_repeat(), c_replace(), c_retract(), c_rootsort(), c_same_address(), c_set_choice(), c_set_input(), c_set_module(), c_set_output(), c_setq(), c_split_double(), c_static(), c_string2psi(), c_string_address(), c_string_length(), c_strip(), c_sub_string(), c_succeed(), c_such_that(), c_trace_input(), c_undo(), c_unify_func(), c_unify_pred(), c_var(), c_write(), c_write_canonical(), c_write_err(), c_writeq(), c_writeq_err(), c_xor(), call_handlersym, calloncesym, wl_definition::code, colonsym, commasym, comment, constant, cut, day_attr, delay_checksym, disj_nil, disjunction, dynamicsym, encodesym, eof, eqsym, error_psi_term, eval_argsym, final_dot, final_question, funcsym, function_it, functor, fx_sym, fy_sym, hash_lookup(), heap_psi_term(), hour_attr, iff, inputfilesym, insert_math_builtins(), insert_sys_builtins(), insert_system_builtins(), insert_type_builtins(), integer, wl_definition::keyword, leftarrowsym, lf_false, lf_true, life_or, listingsym, loadsym, minus_symbol, minute_attr, month_attr, new_built_in(), nil, no_module, NOT_CODED, nothing, null_psi_term, nullsym, one, opsym, predicate_it, predsym, wl_keyword::public, quote, quoted_string, real, second_attr, set_current_module(), staticsym, stream, succeed, such_that, wl_keyword::symbol, wl_module::symbol_table, syntax_module, three, timesym, top, tracesym, TRUE, two, wl_psi_term::type, wl_definition::type_def, type_it, typesym, update_symbol(), variable, weekday_attr, xf_sym, xfx_sym, xfy_sym, year_attr, yf_sym, and yfx_sym.

6156 {
6157  ptr_definition t;
6158 
6159  /* symbol_table=NULL; RM: Feb 3 1993 */
6160 
6161 
6162 
6163  /* RM: Jan 13 1993 */
6164  /* Initialize the minimum syntactic symbols */
6165  (void)set_current_module(syntax_module); /* RM: Feb 3 1993 */
6167  (void)update_symbol(syntax_module,"[");
6168  (void)update_symbol(syntax_module,"]");
6169  (void)update_symbol(syntax_module,"(");
6170  (void)update_symbol(syntax_module,")");
6171  (void)update_symbol(syntax_module,"{");
6172  (void)update_symbol(syntax_module,"}");
6173  (void)update_symbol(syntax_module,".");
6174  (void)update_symbol(syntax_module,"?");
6175 
6176 
6181  eof =update_symbol(syntax_module,"end_of_file");
6185  life_or =update_symbol(syntax_module,";");/* RM: Apr 6 1993 */
6186  minus_symbol =update_symbol(syntax_module,"-");/* RM: Jun 21 1993 */
6192 
6193  /* RM: Jul 7 1993 */
6196 
6197 
6198 
6199  /* RM: Feb 3 1993 */
6201  error_psi_term=heap_psi_term(4); /* 8.10 */
6202  error_psi_term->type=update_symbol(bi_module,"*** ERROR ***");
6204 
6205  apply =update_symbol(bi_module,"apply");
6206  boolean =update_symbol(bi_module,"bool");
6207  boolpredsym =update_symbol(bi_module,"bool_pred");
6208  built_in =update_symbol(bi_module,"built_in");
6209  calloncesym =update_symbol(bi_module,"call_once");
6210  /* colon sym */
6211  /* comma sym */
6212  comment =update_symbol(bi_module,"comment");
6213 
6214 
6215  /* RM: Dec 11 1992 conjunctions have been totally scrapped it seems */
6216  /* conjunction=update_symbol("*conjunction*"); 19.8 */
6217 
6218  constant =update_symbol(bi_module,"*constant*");
6219  disjunction =update_symbol(bi_module,"disj");/*RM:9 Dec 92*/
6220  lf_false =update_symbol(bi_module,"false");
6221  functor =update_symbol(bi_module,"functor");
6222  iff =update_symbol(bi_module,"cond");
6224  alist =update_symbol(bi_module,"cons");/*RM:9 Dec 92*/
6225  nothing =update_symbol(bi_module,"bottom");
6226  nil =update_symbol(bi_module,"nil");/*RM:9 Dec 92*/
6228  real =update_symbol(bi_module,"real");
6229  stream =update_symbol(bi_module,"stream");
6230  succeed =update_symbol(bi_module,"succeed");
6231  lf_true =update_symbol(bi_module,"true");
6232  timesym =update_symbol(bi_module,"time");
6233  variable =update_symbol(bi_module,"*variable*");
6234  opsym =update_symbol(bi_module,"op");
6235  loadsym =update_symbol(bi_module,"load");
6236  dynamicsym =update_symbol(bi_module,"dynamic");
6237  staticsym =update_symbol(bi_module,"static");
6238  encodesym =update_symbol(bi_module,"encode");
6239  listingsym =update_symbol(bi_module,"c_listing");
6240  /* provesym =update_symbol(bi_module,"prove"); */
6241  delay_checksym =update_symbol(bi_module,"delay_check");
6242  eval_argsym =update_symbol(bi_module,"non_strict");
6243  inputfilesym =update_symbol(bi_module,"input_file");
6244  call_handlersym =update_symbol(bi_module,"call_handler");
6252  nullsym =update_symbol(bi_module,"<NULL PSI TERM>");
6255 
6256 
6257  (void)set_current_module(no_module); /* RM: Feb 3 1993 */
6258  t=update_symbol(no_module,"1");
6259  one=t->keyword->symbol;
6260  t=update_symbol(no_module,"2");
6261  two=t->keyword->symbol;
6262  t=update_symbol(no_module,"3");
6263  three=t->keyword->symbol;
6264  (void)set_current_module(bi_module); /* RM: Feb 3 1993 */
6265  t=update_symbol(bi_module,"year");
6266  year_attr=t->keyword->symbol;
6267  t=update_symbol(bi_module,"month");
6269  t=update_symbol(bi_module,"day");
6270  day_attr=t->keyword->symbol;
6271  t=update_symbol(bi_module,"hour");
6272  hour_attr=t->keyword->symbol;
6273  t=update_symbol(bi_module,"minute");
6275  t=update_symbol(bi_module,"second");
6277  t=update_symbol(bi_module,"weekday");
6279 
6282 
6283  /* Built-in routines */
6284  // bi_list = fopen("bi_list.txt","w");
6285 
6286  /* Program database */
6296 
6297  /* File I/O */
6309 
6310  /* Term I/O */
6322  new_built_in(bi_module,"c_op",(def_type)predicate_it,c_op); /* RM: Jan 13 1993 */
6326 
6327  /* Type checks */
6333 
6338 
6339  /* RM: Dec 16 1992 So the symbol can be changed easily */
6340 
6341 
6342  /* Arithmetic */
6344 
6345  /* Comparison */
6357 
6358  /* RM: Nov 22 1993 */
6360 
6361  /* Psi-term navigation */
6363  new_built_in(bi_module,"feature_values",(def_type)function_it,c_feature_values); /* RM: Mar 3 1994 */
6364 
6365  /* RM: Jul 20 1993 */
6366 
6367  new_built_in(syntax_module,".",(def_type)function_it,c_project);/* RM: Jul 7 1993 */
6370  new_built_in(bi_module,"copy_pointer",(def_type)function_it,c_copy_pointer); /* PVR: Dec 17 1992 */
6371  new_built_in(bi_module,"has_feature",(def_type)function_it,c_exist_feature); /* PVR: Dec 17 1992 */
6372 
6373  /* Unification and assignment */
6375  /* new_built_in(syntax_module,"<<-",(def_type)predicate_it,c_assign); RM: Feb 24 1993 */
6376 
6377  /* RM: Feb 24 1993 */
6379  /* new_built_in(syntax_module,"<<<-",(def_type)predicate_it,c_global_assign); */
6380 
6381  /* RM: Feb 8 1993 */
6382  new_built_in(syntax_module,"{}",(def_type)function_it,c_fail); /* RM: Feb 16 1993 */
6386  /* UNI new_built_in(syntax_module,":",(def_type)function_it,c_unify_func); */
6387 
6388  /* Type hierarchy navigation */
6390 
6391  /* String and character utilities */
6397 
6398  /* Control */
6404  /* new_built_in(bi_module,"quote",(def_type)function_it,c_quote); */
6405  /*new_built_in(bi_module,"call_once",(def_type)function_it,c_call_once);*/ /* DENYS: Jan 25 1995 */
6406  /* new_built_in(bi_module,"call",(def_type)function_it,c_call); */
6407  /* new_built_in(bi_module,"undefined",(def_type)function_it,c_fail); */ /* RM: Jan 13 1993 */
6414 
6417  /* new_built_in(syntax_module,"::",(def_type)predicate_it,c_declaration); */
6428  /* new_built_in(bi_module,"freeze",(def_type)predicate_it,c_freeze); PVR 16.9.93 */
6433 
6434  /* System */
6436 
6443 
6444  /* RM: Jan 8 1993 */
6455  /* new_built_in(bi_module,"#",(def_type)function_it,c_module_access); */
6456 
6457  /* Hack so '.set_up' doesn't issue a Warning message */
6458  /* RM: Feb 3 1993 */
6459  hash_lookup(bi_module->symbol_table,"set_module")->public=TRUE;
6461 
6462  /* RM: Jan 29 1993 */
6463  abortsym=update_symbol(bi_module,"abort"); /* 26.1 */
6464  aborthooksym=update_symbol(bi_module,"aborthook"); /* 26.1 */
6465  tracesym=update_symbol(bi_module,"trace"); /* 26.1 */
6466 
6467 
6468  /* RM: Feb 9 1993 */
6473 
6474  /* RM: Mar 11 1993 */
6476  add_module1=update_symbol(bi_module,"features");
6477  add_module2=update_symbol(bi_module,"str2psi");
6478  add_module3=update_symbol(bi_module,"feature_values"); /* RM: Mar 3 1994 */
6479 
6480  /* RM: Jun 29 1993 */
6483 
6484  /* RM: Jul 15 1993 */
6486 
6487 
6488  /* RM: Sep 20 1993 */
6490 
6491  /* RM: Jan 28 1994 */
6493 
6494 #ifdef CLIFE
6495  life_reals();
6496 #endif /* CLIFE */
6497 
6499  // fclose(bi_list);
6500 }
static long c_diff()
c_diff
Definition: built_ins.c:1308
void new_built_in(ptr_module m, char *s, def_type t, long(*r)())
new_built_in
Definition: built_ins.c:5375
static long c_get()
c_get
Definition: built_ins.c:2992
static long c_listing()
c_listing
Definition: built_ins.c:5172
static long c_char()
c_char
Definition: built_ins.c:4731
ptr_definition disjunction
symbol in bi module
Definition: def_glob.h:249
void insert_math_builtins()
insert math builtins into table
Definition: bi_math.c:1346
static long c_is_sort()
c_is_sort
Definition: built_ins.c:1570
ptr_keyword hash_lookup(ptr_hash_table table, char *symbol)
HASH_LOOKUP.
Definition: hash_table.c:131
long c_initrandom()
c_initrandom
Definition: built_ins.c:6032
ptr_definition alist
symbol in bi module
Definition: def_glob.h:319
#define function_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1408
ptr_definition succeed
symbol in bi module
Definition: def_glob.h:389
static long c_exists()
c_exists
Definition: built_ins.c:1732
static long c_combined_name()
c_combined_name
Definition: built_ins.c:5693
static long c_exists_choice()
c_exists_choice
Definition: built_ins.c:1910
static long c_static()
c_static
Definition: built_ins.c:1642
ptr_definition xf_sym
symbol in bi module
Definition: def_glob.h:515
static long c_write()
c_write
Definition: built_ins.c:3177
static long c_pwriteq()
c_pwriteq
Definition: built_ins.c:3253
static long c_unify_func()
c_unify_func
Definition: built_ins.c:4425
static long c_clause()
c_clause
Definition: built_ins.c:2519
ptr_definition apply
symbol in bi module
Definition: def_glob.h:178
struct wl_definition * def_type
Definition: def_struct.h:60
static long c_declaration()
c_declaration
Definition: built_ins.c:2313
long c_random()
c_random
Definition: built_ins.c:5966
void insert_type_builtins()
void insert_type_builtins
Definition: bi_type.c:817
ptr_definition lf_false
symbol in bi module
Definition: def_glob.h:284
long c_public()
c_public
Definition: modules.c:687
ptr_definition nothing
symbol in bi module
Definition: def_glob.h:347
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
ptr_definition eqsym
symbol in syntax module
Definition: def_glob.h:270
ptr_definition functor
symbol in bi module
Definition: def_glob.h:298
static long c_pwrite()
c_pwrite
Definition: built_ins.c:3235
ptr_definition quote
symbol in syntax module
Definition: def_glob.h:361
static long c_ascii()
c_ascii
Definition: built_ins.c:4781
static long c_retract()
c_retract
Definition: built_ins.c:2538
long c_display_modules()
c_display_modules
Definition: modules.c:739
static long c_features()
c_features
Definition: built_ins.c:3564
ptr_definition final_question
symbol in syntax module
Definition: def_glob.h:615
static long c_delay_check()
static long c_delay_check()
Definition: built_ins.c:1661
static long c_fail()
c_fail
Definition: built_ins.c:1388
static long c_exist_feature()
c_exist_feature
Definition: built_ins.c:3499
static long c_rootsort()
c_rootsort
Definition: built_ins.c:3355
static long c_persistent()
c_persistent
Definition: built_ins.c:2687
long c_deref_length()
c_deref_length
Definition: built_ins.c:6087
#define NOT_CODED
For LIFE boolean calculation built-in.
Definition: def_const.h:294
ptr_definition calloncesym
symbol in bi module
Definition: def_glob.h:206
ptr_definition delay_checksym
symbol in bi module
Definition: def_glob.h:487
ptr_definition cut
symbol in syntax module
Definition: def_glob.h:242
char * two
Definition: def_glob.h:892
ptr_definition iff
symbol in bi module
Definition: def_glob.h:305
static long c_project()
c_project
Definition: built_ins.c:1207
static long c_int2string()
c_int2string
Definition: built_ins.c:4943
ptr_psi_term heap_psi_term(long stat)
heap_psi_term
Definition: lefun.c:75
static long c_same_address()
c_same_address
Definition: built_ins.c:3857
static long c_xor()
c_xor
Definition: built_ins.c:1080
ptr_definition timesym
symbol in bi module
Definition: def_glob.h:417
ptr_module syntax_module
Module for minimal Prolog syntax.
Definition: def_glob.h:715
ptr_definition comment
symbol in bi module
Definition: def_glob.h:227
def_type type_def
Definition: def_struct.h:153
static long c_unify_pred()
c_unify_pred
Definition: built_ins.c:4454
static long c_cond()
c_cond
Definition: built_ins.c:3422
#define predicate_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1401
long c_set_module()
c_set_module
Definition: modules.c:488
long c_append_file()
c_append_file
Definition: built_ins.c:5890
ptr_definition listingsym
symbol in bi module
Definition: def_glob.h:480
static long c_string2psi()
c_string2psi
Definition: built_ins.c:4831
static long c_read_psi()
c_read_psi
Definition: built_ins.c:2097
ptr_definition fx_sym
symbol in bi module
Definition: def_glob.h:522
static long c_lt()
c_lt C_LT Less than.
Definition: built_ins.c:633
long c_abort()
c_abort
Definition: built_ins.c:2247
static long c_boolpred()
c_boolpred
Definition: built_ins.c:838
static long c_diff_address()
c_diff_address
Definition: built_ins.c:3901
ptr_definition stream
symbol in bi module
Definition: def_glob.h:382
static long c_open_out()
c_open_out
Definition: built_ins.c:2819
static long c_print_codes()
c_print_codes
Definition: built_ins.c:5285
ptr_definition call_handlersym
symbol in bi module
Definition: def_glob.h:508
long c_args()
c_args
Definition: built_ins.c:6123
ptr_hash_table symbol_table
Definition: def_struct.h:110
ptr_keyword keyword
Definition: def_struct.h:147
ptr_definition dynamicsym
symbol in bi module
Definition: def_glob.h:459
ptr_definition opsym
symbol in bi module
Definition: def_glob.h:445
ptr_definition add_module3
symbol in bi module for feature_values
Definition: def_glob.h:157
static long c_string_address()
c_string_address
Definition: built_ins.c:4099
ptr_definition add_module2
symbol in bi module for str2psi
Definition: def_glob.h:150
static long c_op()
c_op
Definition: built_ins.c:1697
static long c_ltoe()
c_ltoe
Definition: built_ins.c:769
long c_open_module()
c_open_module
Definition: modules.c:519
char * three
Definition: def_glob.h:893
char * symbol
Definition: def_struct.h:118
ptr_definition funcsym
symbol in syntax module
Definition: def_glob.h:291
ptr_definition eval_argsym
symbol in bi module
Definition: def_glob.h:494
ptr_definition update_symbol(ptr_module module, char *symbol)
update_symbol
Definition: modules.c:270
static long c_parse()
c_parse
Definition: built_ins.c:2012
void insert_system_builtins()
insert_system_builtins
Definition: bi_sys.c:746
ptr_definition and
symbol in syntax module
Definition: def_glob.h:171
static long c_page_width()
c_page_width
Definition: built_ins.c:3271
static long c_gtoe()
c_gtoe
Definition: built_ins.c:701
ptr_psi_term null_psi_term
Used to represent an empty parse token.
Definition: def_glob.h:656
ptr_definition built_in
symbol in bi module
Definition: def_glob.h:199
static long c_psi2string()
c_psi2string
Definition: built_ins.c:4898
static long c_repeat()
c_repeat
Definition: built_ins.c:1416
ptr_definition real
symbol in bi module
Definition: def_glob.h:375
#define type_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1415
long c_display_persistent()
c_display_persistent
Definition: modules.c:775
static long c_global_assign()
c_global_assign
Definition: built_ins.c:4383
static long c_split_double()
c_split_double
Definition: built_ins.c:4034
ptr_definition inputfilesym
symbol in bi module
Definition: def_glob.h:501
ptr_definition yf_sym
symbol in bi module
Definition: def_glob.h:529
static long c_write_err()
c_write_err
Definition: built_ins.c:3138
static long c_apply()
c_apply
Definition: built_ins.c:1160
ptr_definition variable
symbol in bi module
Definition: def_glob.h:438
static long c_writeq_err()
c_writeq_err
Definition: built_ins.c:3158
static long c_global()
c_global
Definition: built_ins.c:2561
static long c_get_choice()
c_get_choice
Definition: built_ins.c:1814
ptr_definition final_dot
symbol in syntax module
Definition: def_glob.h:608
void insert_sys_builtins()
insert_sys_builtins
Definition: sys.c:2209
ptr_definition colonsym
symbol in syntax module
Definition: def_glob.h:213
static long c_writeq()
c_writeq
Definition: built_ins.c:3197
long c_sub_string()
c_sub_string
Definition: built_ins.c:5781
#define TRUE
Standard boolean.
Definition: def_const.h:268
long all_public_symbols()
all_public_symbols
Definition: modules.c:1363
static long c_open_in()
c_open_in
Definition: built_ins.c:2773
ptr_definition minus_symbol
symbol in syntax module
Definition: def_glob.h:333
static long c_dynamic()
c_dynamic
Definition: built_ins.c:1625
ptr_definition eof
symbol in syntax module
Definition: def_glob.h:263
long c_string_length()
c_string_length
Definition: built_ins.c:5726
ptr_definition constant
symbol in bi module
Definition: def_glob.h:235
static long c_non_strict()
c_non_strict
Definition: built_ins.c:1680
static long c_copy_term()
c_copy_term
Definition: built_ins.c:4514
static long c_undo()
c_undo
Definition: built_ins.c:4552
static long c_eval()
c_eval
Definition: built_ins.c:3945
static long c_nonvar()
c_nonvar
Definition: built_ins.c:1467
ptr_definition abortsym
symbol in bi module
Definition: def_glob.h:126
ptr_definition add_module1
symbol in bi module for features
Definition: def_glob.h:143
ptr_definition staticsym
symbol in bi module
Definition: def_glob.h:466
long c_halt()
c_halt
Definition: built_ins.c:2208
static long c_disj()
c_disj
Definition: built_ins.c:3391
static long c_eval_disjunction()
c_eval_disjunction
Definition: built_ins.c:589
ptr_definition such_that
symbol in syntax module
Definition: def_glob.h:396
ptr_definition typesym
symbol in syntax module
Definition: def_glob.h:431
ptr_definition nil
symbol in bi module
Definition: def_glob.h:340
ptr_definition xfy_sym
symbol in bi module
Definition: def_glob.h:550
long c_current_module()
c_current_module
Definition: modules.c:974
static long c_succeed()
c_succeed
Definition: built_ins.c:1400
static long c_and()
c_and
Definition: built_ins.c:1000
ptr_definition disj_nil
symbol in syntax module
Definition: def_glob.h:256
static long c_implies()
c_implies
Definition: built_ins.c:4718
char * weekday_attr
Definition: def_glob.h:900
static long c_strip()
c_strip
Definition: built_ins.c:3828
char * one
Definition: def_glob.h:891
static long c_put_err()
c_put_err
Definition: built_ins.c:3065
long c_private_feature()
c_private_feature
Definition: modules.c:1302
ptr_definition commasym
symbol in syntax module
Definition: def_glob.h:220
static long c_or()
c_or
Definition: built_ins.c:1013
static long c_assert_last()
c_assert_last
Definition: built_ins.c:2416
static long c_close()
c_close
Definition: built_ins.c:2936
static long c_read_token()
c_read_token
Definition: built_ins.c:2107
static long c_not()
c_not
Definition: built_ins.c:1026
long c_trace_input()
c_trace_input
Definition: modules.c:810
ptr_module bi_module
Module for public built-ins.
Definition: def_glob.h:687
static long c_is_predicate()
c_is_predicate
Definition: built_ins.c:1536
static long c_var()
static long c_var()
Definition: built_ins.c:1433
long c_alias()
c_alias
Definition: modules.c:1180
ptr_psi_term error_psi_term
symbol in bi module
Definition: def_glob.h:118
ptr_definition top
symbol in syntax module
Definition: def_glob.h:403
long c_concatenate()
c_concatenate
Definition: built_ins.c:5577
ptr_definition yfx_sym
symbol in bi module
Definition: def_glob.h:557
static long c_is_function()
c_is_function
Definition: built_ins.c:1501
static long c_put()
c_put
Definition: built_ins.c:3049
static long c_eval_inplace()
c_eval_inplace
Definition: built_ins.c:3977
ptr_definition loadsym
symbol in bi module
Definition: def_glob.h:452
long c_private()
c_private
Definition: modules.c:714
char * minute_attr
Definition: def_glob.h:898
static long c_not_implemented()
c_not_implemented
Definition: built_ins.c:2296
ptr_definition leftarrowsym
symbol in syntax module
Definition: def_glob.h:277
ptr_definition nullsym
symbol in bi module
Definition: def_glob.h:564
long c_replace()
c_replace
Definition: modules.c:936
ptr_module no_module
???
Definition: def_glob.h:701
static long c_chdir()
c_chdir
Definition: built_ins.c:4152
char * year_attr
Definition: def_glob.h:894
ptr_definition encodesym
symbol in bi module
Definition: def_glob.h:473
ptr_definition fy_sym
symbol in bi module
Definition: def_glob.h:536
static long c_bk_assign()
c_bk_assign
Definition: built_ins.c:4287
ptr_int_list code
Definition: def_struct.h:150
char * second_attr
Definition: def_glob.h:899
char * day_attr
Definition: def_glob.h:896
static long c_ops()
c_ops
Definition: built_ins.c:3784
ptr_definition lf_true
symbol in bi module
Definition: def_glob.h:410
static long c_set_input()
c_set_input
Definition: built_ins.c:2868
static long c_equal()
static long c_equal()
Definition: built_ins.c:507
ptr_definition type
Definition: def_struct.h:181
char * hour_attr
Definition: def_glob.h:897
ptr_definition aborthooksym
symbol in bi module
Definition: def_glob.h:133
ptr_definition boolpredsym
symbol in bi module
Definition: def_glob.h:192
static long c_setq()
c_setq
Definition: built_ins.c:2336
static long c_module_name()
c_module_name
Definition: built_ins.c:5660
static long c_write_canonical()
c_write_canonical
Definition: built_ins.c:3217
static long c_gt()
c_gt
Definition: built_ins.c:439
ptr_definition xfx_sym
symbol in bi module
Definition: def_glob.h:543
static long c_load()
c_load
Definition: built_ins.c:1774
static long c_print_depth()
c_print_depth
Definition: built_ins.c:3311
static long c_copy_pointer()
c_copy_pointer
Definition: built_ins.c:4482
static long c_feature_values()
c_feature_values
Definition: built_ins.c:3618
ptr_module set_current_module(ptr_module module)
set_current_module
Definition: modules.c:100
static long c_assert_first()
c_assert_first
Definition: built_ins.c:2386
static long c_print_variables()
c_print_variables
Definition: built_ins.c:1967
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
static long c_set_choice()
c_set_choice
Definition: built_ins.c:1853
static long c_set_output()
c_set_output
Definition: built_ins.c:2905
ptr_definition predsym
symbol in syntax module
Definition: def_glob.h:354
char * month_attr
Definition: def_glob.h:895
static long c_such_that()
c_such_that
Definition: built_ins.c:5011
ptr_definition tracesym
symbol in bi module
Definition: def_glob.h:424
ptr_definition life_or
symbol in syntax module
Definition: def_glob.h:326
long is_built_in ( ptr_pair_list  r)

is_built_in

Parameters
r- ptr_pair_list r

Return TRUE if rules r are for a built-in

Definition at line 5118 of file built_ins.c.

References MAX_BUILT_INS.

5119 {
5120  return ((unsigned long)r>0 && (unsigned long)r<MAX_BUILT_INS);
5121 }
#define MAX_BUILT_INS
Maximum number of built_ins.
Definition: def_const.h:154
void list_special ( ptr_psi_term  t)

list_special

Parameters
t- ptr_psi_term t

List the characteristics (delay_check, dynamic/static, non_strict) in such a way that they can be immediately read in.

Definition at line 5131 of file built_ins.c.

References wl_definition::always_check, display_psi_stream(), wl_definition::evaluate_args, FALSE, is_built_in(), output_stream, wl_definition::protected, wl_definition::rule, TRUE, wl_psi_term::type, wl_definition::type_def, and type_it.

5132 {
5133  ptr_definition d = t->type;
5134  ptr_pair_list r = t->type->rule;
5135  long prflag=FALSE;
5136 
5137  if (t->type->type_def==(def_type)type_it) {
5138  if (!d->always_check) {
5139  if (is_built_in(r)) fprintf(output_stream,"%% ");
5140  fprintf(output_stream,"delay_check(");
5141  display_psi_stream(t);
5142  fprintf(output_stream,")?\n");
5143  prflag=TRUE;
5144  }
5145  } else {
5146  if (!d->protected) {
5147  if (is_built_in(r)) fprintf(output_stream,"%% ");
5148  fprintf(output_stream,"%s(",(d->protected?"static":"dynamic"));
5149  display_psi_stream(t);
5150  fprintf(output_stream,")?\n");
5151  prflag=TRUE;
5152  }
5153  }
5154  if (!d->evaluate_args) {
5155  if (is_built_in(r)) fprintf(output_stream,"%% ");
5156  fprintf(output_stream,"non_strict(");
5157  display_psi_stream(t);
5158  fprintf(output_stream,")?\n");
5159  prflag=TRUE;
5160  }
5161  /* if (prflag) fprintf(output_stream,"\n"); */
5162 }
char evaluate_args
Definition: def_struct.h:156
void display_psi_stream(ptr_psi_term t)
display_psi_stream
Definition: print.c:1564
def_type type_def
Definition: def_struct.h:153
char always_check
Definition: def_struct.h:154
#define type_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1415
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_pair_list rule
Definition: def_struct.h:148
#define FALSE
Standard boolean.
Definition: def_const.h:275
long is_built_in(ptr_pair_list r)
is_built_in
Definition: built_ins.c:5118
FILE * output_stream
Definition: def_glob.h:1017
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term make_feature_list ( ptr_node  tree,
ptr_psi_term  tail,
ptr_module  module,
int  val 
)

make_feature_list

Parameters
tree- ptr_node tree
tail- ptr_psi_term tail
module- ptr_module module
val- int val

Definition at line 175 of file built_ins.c.

References wl_node::data, heap_alloc(), integer, wl_node::key, wl_node::left, make_feature_list(), REAL, real, wl_node::right, stack_cons(), stack_psi_term(), str_to_int(), and update_feature().

176 {
177  ptr_psi_term new;
178  ptr_definition def;
179  double d; // strtod();
180 
181 
182  if(tree) {
183  if(tree->right)
184  tail=make_feature_list(tree->right,tail,module,val);
185 
186  /* Insert the feature name into the list */
187 
188  d=str_to_int(tree->key);
189  if (d== -1) { /* Feature is not a number */
190  def=update_feature(module,tree->key); /* Extract module RM: Feb 3 1993 */
191  if(def) {
192  if(val) /* RM: Mar 3 1994 Distinguish between features & values */
193  tail=stack_cons((ptr_psi_term)tree->data,(ptr_psi_term)tail);
194  else {
195  new=stack_psi_term(4);
196  new->type=def;
197  tail=stack_cons((ptr_psi_term)new,(ptr_psi_term)tail);
198  }
199  }
200  }
201  else { /* Feature is a number */
202  if(val) /* RM: Mar 3 1994 Distinguish between features & values */
203  tail=stack_cons((ptr_psi_term)tree->data,(ptr_psi_term)tail);
204  else {
205  new=stack_psi_term(4);
206  new->type=(d==floor(d))?integer:real;
207  new->value_3=heap_alloc(sizeof(REAL));
208  *(REAL *)new->value_3=(REAL)d;
209  tail=stack_cons((ptr_psi_term)new,(ptr_psi_term)tail);
210  }
211  }
212 
213  if(tree->left)
214  tail=make_feature_list(tree->left,tail,module,val);
215  }
216 
217  return tail;
218 }
ptr_psi_term stack_cons(ptr_psi_term head, ptr_psi_term tail)
stack_cons
Definition: built_ins.c:46
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
GENERIC data
Definition: def_struct.h:201
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
ptr_node left
Definition: def_struct.h:199
ptr_definition real
symbol in bi module
Definition: def_glob.h:375
char * key
Definition: def_struct.h:198
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
long str_to_int(char *s)
str_to_int
Definition: print.c:118
ptr_psi_term make_feature_list(ptr_node tree, ptr_psi_term tail, ptr_module module, int val)
make_feature_list
Definition: built_ins.c:175
ptr_definition update_feature(ptr_module module, char *feature)
update_feature
Definition: modules.c:1331
GENERIC heap_alloc(long s)
heap_alloc
Definition: memory.c:1616
ptr_node right
Definition: def_struct.h:200
void new_built_in ( ptr_module  m,
char *  s,
def_type  t,
long(*)()  r 
)

new_built_in

Parameters
m- ptr_module m
s- char *s
t- def_type t
r- long (*r)()

NEW_BUILT_IN(m,s,t,r) Add a new built-in predicate or function. Used also in x_pred.c

M=module. S=string. T=type (function or predicate). R=address of C routine to call.

Definition at line 5375 of file built_ins.c.

References built_in_index, c_rule, current_module, MAX_BUILT_INS, wl_definition::rule, set_current_module(), wl_definition::type_def, and update_symbol().

5376 {
5377  ptr_definition d;
5378  if (built_in_index >= MAX_BUILT_INS) {
5379  fprintf(stderr,"Too many primitives, increase MAX_BUILT_INS in extern.h\n");
5380  exit(EXIT_FAILURE);
5381  }
5382 
5383  if(m!=current_module) /* RM: Jan 13 1993 */
5384  (void)set_current_module(m);
5385 
5386  d=update_symbol(m,s); /* RM: Jan 8 1993 */
5387  d->type_def=t;
5388  built_in_index++;
5391 }
static long built_in_index
Definition: built_ins.c:16
ptr_module current_module
The current module for the tokenizer.
Definition: def_glob.h:729
long(* c_rule[MAX_BUILT_INS])()
Definition: def_glob.h:888
def_type type_def
Definition: def_struct.h:153
ptr_definition update_symbol(ptr_module module, char *symbol)
update_symbol
Definition: modules.c:270
ptr_pair_list rule
Definition: def_struct.h:148
struct wl_pair_list * ptr_pair_list
Definition: def_struct.h:64
#define MAX_BUILT_INS
Maximum number of built_ins.
Definition: def_const.h:154
ptr_module set_current_module(ptr_module module)
set_current_module
Definition: modules.c:100
ptr_psi_term new_psi_term ( long  numargs,
ptr_definition  typ,
ptr_psi_term **  a1,
ptr_psi_term **  a2 
)

new_psi_term

Parameters
numargs- long numargs
typ- ptr_definition typ
a1- ptr_psi_term **a1
a2- ptr_psi_term **a2

Return a psi term with one or two args, and the addresses of the args

Definition at line 5064 of file built_ins.c.

References wl_psi_term::attr_list, wl_node::data, wl_node::key, wl_node::left, NULL, one, wl_node::right, STACK_ALLOC, stack_psi_term(), two, and wl_psi_term::type.

5065 {
5066  ptr_psi_term t;
5067  ptr_node n1, n2;
5068 
5069  if (numargs==2) {
5070  n2 = STACK_ALLOC(node);
5071  n2->key = two;
5072  *a2 = (ptr_psi_term *) &(n2->data);
5073  n2->left = NULL;
5074  n2->right = NULL;
5075  }
5076  else
5077  n2=NULL;
5078 
5079  n1 = STACK_ALLOC(node);
5080  n1->key = one;
5081  *a1 = (ptr_psi_term *) &(n1->data);
5082  n1->left = NULL;
5083  n1->right = n2;
5084 
5085  t=stack_psi_term(4);
5086  t->type = typ;
5087  t->attr_list = n1;
5088 
5089  return t;
5090 }
char * two
Definition: def_glob.h:892
GENERIC data
Definition: def_struct.h:201
#define NULL
Definition: def_const.h:533
ptr_node left
Definition: def_struct.h:199
char * key
Definition: def_struct.h:198
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
char * one
Definition: def_glob.h:891
#define STACK_ALLOC(A)
Definition: def_macro.h:21
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
ptr_node right
Definition: def_struct.h:200
ptr_node one_attr ( )

one_attr

Return an attr_list with one argument

Definition at line 5042 of file built_ins.c.

References wl_node::data, wl_node::key, wl_node::left, NULL, one, wl_node::right, and STACK_ALLOC.

5043 {
5044  ptr_node n;
5045 
5046  n = STACK_ALLOC(node);
5047  n->key = one;
5048  n->data = NULL; /* To be filled in later */
5049  n->left = NULL;
5050  n->right = NULL;
5051 
5052  return n;
5053 }
GENERIC data
Definition: def_struct.h:201
#define NULL
Definition: def_const.h:533
ptr_node left
Definition: def_struct.h:199
char * key
Definition: def_struct.h:198
char * one
Definition: def_glob.h:891
#define STACK_ALLOC(A)
Definition: def_macro.h:21
ptr_node right
Definition: def_struct.h:200
long only_arg1 ( ptr_psi_term  t,
ptr_psi_term arg1 
)

only_arg1

Parameters
t- ptr_psi_term t
arg1- ptr_psi_term * arg1

Return TRUE iff t has only argument "1", and return the argument.

Definition at line 1605 of file built_ins.c.

References wl_psi_term::attr_list, wl_node::data, FALSE, featcmp(), wl_node::key, wl_node::left, NULL, one, wl_node::right, and TRUE.

1606 {
1607  ptr_node n=t->attr_list;
1608 
1609  if (n && n->left==NULL && n->right==NULL && !featcmp(n->key,one)) {
1610  *arg1=(ptr_psi_term)n->data;
1611  return TRUE;
1612  }
1613  else
1614  return FALSE;
1615 }
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
#define NULL
Definition: def_const.h:533
ptr_node left
Definition: def_struct.h:199
char * key
Definition: def_struct.h:198
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
char * one
Definition: def_glob.h:891
long featcmp(char *str1, char *str2)
featcmp
Definition: trees.c:106
ptr_node attr_list
Definition: def_struct.h:187
ptr_node right
Definition: def_struct.h:200
static void op_declare ( long  p,
operator  t,
char *  s 
)
static

op_declare

Parameters
p- long p
t- operator t
s- char *s

OP_DECLARE(p,t,s) Declare that string S is an operator of precedence P and of type T where T=xf, fx, yf, fy, xfx etc...

Definition at line 5404 of file built_ins.c.

References Errorline(), heap_alloc(), MAX_PRECEDENCE, wl_operator_data::next, NULL, wl_definition::op_data, wl_operator_data::precedence, and update_symbol().

5405 {
5406  ptr_definition d;
5407  ptr_operator_data od;
5408 
5409  if (p>MAX_PRECEDENCE || p<0) {
5410  Errorline("operator precedence must be in the range 0..%d.\n",
5411  MAX_PRECEDENCE);
5412  return;
5413  }
5414  d=update_symbol(NULL,s);
5415 
5416  od= (ptr_operator_data) heap_alloc (sizeof(operator_data));
5417  /* od= (ptr_operator_data) malloc (sizeof(operator_data)); 12.6 */
5418 
5419  od->precedence=p;
5420  od->type=t;
5421  od->next=d->op_data;
5422  d->op_data=od;
5423 }
ptr_operator_data next
Definition: def_struct.h:76
#define NULL
Definition: def_const.h:533
ptr_definition update_symbol(ptr_module module, char *symbol)
update_symbol
Definition: modules.c:270
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
struct wl_operator_data * ptr_operator_data
Definition: def_struct.h:56
#define MAX_PRECEDENCE
Maximum operator precedence.
Definition: def_const.h:205
ptr_operator_data op_data
Definition: def_struct.h:158
GENERIC heap_alloc(long s)
heap_alloc
Definition: memory.c:1616
void persistent_error_check ( ptr_node  n,
int *  error 
)

persistent_error_check

Parameters
n- ptr_node n
error- int *error

Definition at line 2714 of file built_ins.c.

References wl_node::data, deref_ptr, error_psi_term, Errorline(), global_it, wl_node::left, persistent_error_check(), wl_node::right, TRUE, wl_psi_term::type, wl_definition::type_def, and undef_it.

2715 {
2716  if (n) {
2717  ptr_psi_term t;
2718  persistent_error_check(n->left, error);
2719 
2720  t=(ptr_psi_term)n->data;
2721  deref_ptr(t);
2723  Errorline("%T %P cannot be redeclared persistent (%E).\n",
2724  t->type->type_def,
2725  t);
2726  t->type=error_psi_term->type;
2727  *error=TRUE;
2728  }
2729 
2730  persistent_error_check(n->right, error);
2731  }
2732 }
#define undef_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1394
struct wl_definition * def_type
Definition: def_struct.h:60
void persistent_error_check(ptr_node n, int *error)
persistent_error_check
Definition: built_ins.c:2714
def_type type_def
Definition: def_struct.h:153
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
#define global_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1422
GENERIC data
Definition: def_struct.h:201
ptr_node left
Definition: def_struct.h:199
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_psi_term error_psi_term
symbol in bi module
Definition: def_glob.h:118
ptr_definition type
Definition: def_struct.h:181
ptr_node right
Definition: def_struct.h:200
void persistent_one ( ptr_psi_term  t)

persistent_one

Parameters
t- ptr_psi_term t

Definition at line 2759 of file built_ins.c.

References global_it, wl_definition::global_value, heap_pointer, heap_psi_term(), wl_psi_term::type, and wl_definition::type_def.

2760 {
2764 }
GENERIC heap_pointer
used to allocate from heap - size allocated subtracted - adj for alignment
Definition: def_glob.h:55
struct wl_definition * def_type
Definition: def_struct.h:60
ptr_psi_term heap_psi_term(long stat)
heap_psi_term
Definition: lefun.c:75
def_type type_def
Definition: def_struct.h:153
#define global_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1422
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
ptr_psi_term global_value
Definition: def_struct.h:159
ptr_definition type
Definition: def_struct.h:181
void persistent_tree ( ptr_node  n)

persistent_tree

Parameters
n- ptr_node n

Definition at line 2739 of file built_ins.c.

References wl_node::data, deref_ptr, wl_node::left, persistent_one(), persistent_tree(), and wl_node::right.

2740 {
2741  if (n) {
2742  ptr_psi_term t;
2743  persistent_tree(n->left);
2744 
2745  t=(ptr_psi_term)n->data;
2746  deref_ptr(t);
2747  persistent_one(t);
2748 
2749  persistent_tree(n->right);
2750  }
2751 }
void persistent_tree(ptr_node n)
persistent_tree
Definition: built_ins.c:2739
void persistent_one(ptr_psi_term t)
persistent_one
Definition: built_ins.c:2759
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
ptr_node left
Definition: def_struct.h:199
#define deref_ptr(P)
Definition: def_macro.h:100
ptr_node right
Definition: def_struct.h:200
long pred_clause ( ptr_psi_term  t,
long  r,
ptr_psi_term  g 
)

pred_clause

Parameters
t- ptr_psi_term t
r- long r
g- ptr_psi_term g

PRED_CLAUSE(ptr_psi_term t,long r,ptr_psi_term g) Set about finding a clause that unifies with psi_term T. This routine is used both for CLAUSE and RETRACT. If R==TRUE then delete the first clause which unifies with T.

Definition at line 2451 of file built_ins.c.

References wl_psi_term::attr_list, bk_mark_quote(), clause, del_clause, deref_ptr, Errorline(), FALSE, function_it, get_two_args(), wl_definition::keyword, predicate_it, push_goal(), redefine(), wl_definition::rule, stack_psi_term(), succeed, wl_keyword::symbol, TRUE, wl_psi_term::type, wl_definition::type_def, and undef_it.

2452 {
2453  long success=FALSE;
2454  ptr_psi_term head,body;
2455 
2456  bk_mark_quote(g); /* RM: Apr 7 1993 */
2457  if (t) {
2458  deref_ptr(t);
2459 
2460  if (!strcmp(t->type->keyword->symbol,"->")) {
2461  get_two_args(t->attr_list,&head,&body);
2462  if (head) {
2463  deref_ptr(head);
2464  if (head && body &&
2466  success=TRUE;
2467  }
2468  }
2469  else if (!strcmp(t->type->keyword->symbol,":-")) {
2470  get_two_args(t->attr_list,&head,&body);
2471  if (head) {
2472  deref_ptr(head);
2473  if (head &&
2474  (head->type->type_def==(def_type)predicate_it || head->type->type_def==(def_type)undef_it)) {
2475  success=TRUE;
2476  if (!body) {
2477  body=stack_psi_term(4);
2478  body->type=succeed;
2479  }
2480  }
2481  }
2482  }
2483  /* There is no body, so t is a fact */
2484  else if (t->type->type_def==(def_type)predicate_it || t->type->type_def==(def_type)undef_it) {
2485  head=t;
2486  body=stack_psi_term(4);
2487  body->type=succeed;
2488  success=TRUE;
2489  }
2490  }
2491 
2492  if (success) {
2493  if (r) {
2494  if (redefine(head))
2495  push_goal(del_clause,head,body,(GENERIC)&(head->type->rule));
2496  else
2497  success=FALSE;
2498  }
2499  else
2500  push_goal(clause,head,body,(GENERIC)&(head->type->rule));
2501  }
2502  else
2503  Errorline("bad argument in %s.\n", (r?"retract":"clause"));
2504 
2505  return success;
2506 }
#define function_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1408
#define undef_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1394
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
ptr_definition succeed
symbol in bi module
Definition: def_glob.h:389
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
long redefine(ptr_psi_term t)
redefine
Definition: types.c:104
def_type type_def
Definition: def_struct.h:153
#define predicate_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1401
ptr_keyword keyword
Definition: def_struct.h:147
char * symbol
Definition: def_struct.h:118
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define deref_ptr(P)
Definition: def_macro.h:100
void bk_mark_quote(ptr_psi_term t)
bk_mark_quote
Definition: copy.c:708
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_pair_list rule
Definition: def_struct.h:148
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define clause
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1135
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
#define del_clause
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1142
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
long psi_to_string ( ptr_psi_term  t,
char **  fn 
)

psi_to_string

Parameters
t- ptr_psi_term t
fn- char ** fn

PSI_TO_STRING(t,fn) Get the value of a Life string, or the name of a non-string psi-term. Return TRUE iff a valid string is found.

Definition at line 146 of file built_ins.c.

References equal_types, wl_definition::keyword, quoted_string, wl_keyword::symbol, TRUE, wl_psi_term::type, and wl_psi_term::value_3.

147 {
148  if (equal_types(t->type,quoted_string)) {
149  if (t->value_3) {
150  *fn = (char *) t->value_3;
151  return TRUE;
152  }
153  else {
154  *fn = quoted_string->keyword->symbol;
155  return TRUE;
156  }
157  }
158  else {
159  *fn = t->type->keyword->symbol;
160  return TRUE;
161  }
162 }
ptr_keyword keyword
Definition: def_struct.h:147
char * symbol
Definition: def_struct.h:118
#define TRUE
Standard boolean.
Definition: def_const.h:268
GENERIC value_3
Definition: def_struct.h:186
#define equal_types(A, B)
Definition: def_macro.h:111
ptr_definition type
Definition: def_struct.h:181
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
static void set_parse_queryflag ( ptr_node  thelist,
long  sort 
)
static

set_parse_queryflag

Parameters
thelist- ptr_node thelist
sort- long sort

Definition at line 1983 of file built_ins.c.

References bi_module, wl_node::data, FACT, FEATCMP, find(), NULL, push_goal(), QUERY, stack_psi_term(), two, wl_psi_term::type, unify, and update_symbol().

1984 {
1985  ptr_node n; /* node pointing to argument 2 */
1986  ptr_psi_term arg; /* argumenrt 2 psi-term */
1987  ptr_psi_term queryflag; /* query term created by this function */
1988 
1989  n=find(FEATCMP,two,thelist);
1990  if (n) {
1991  /* there was a second argument */
1992  arg=(ptr_psi_term)n->data;
1993  queryflag=stack_psi_term(4);
1994  queryflag->type =
1996  ((sort==QUERY)?"query":
1997  ((sort==FACT)?"declaration":"error")));
1998  push_goal(unify,queryflag,arg,NULL);
1999  }
2000 }
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
char * two
Definition: def_glob.h:892
#define FACT
Fact Kind of user input.
Definition: def_const.h:338
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
#define NULL
Definition: def_const.h:533
#define QUERY
Query Kind of user input.
Definition: def_const.h:345
ptr_definition update_symbol(ptr_module module, char *symbol)
update_symbol
Definition: modules.c:270
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
ptr_module bi_module
Module for public built-ins.
Definition: def_glob.h:687
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term stack_bytes ( char *  s,
int  n 
)

stack_bytes

Parameters
s- char *s
n- int n

STACK_BYTES(s,n) create a STRING object given a sequence of bytes

Definition at line 128 of file built_ins.c.

References heap_ncopy_string(), quoted_string, stack_psi_term(), wl_psi_term::type, and wl_psi_term::value_3.

129 {
131  t->type = quoted_string;
133  return t;
134 }
char * heap_ncopy_string(char *s, int n)
heap_ncopy_string
Definition: trees.c:150
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
GENERIC value_3
Definition: def_struct.h:186
ptr_definition type
Definition: def_struct.h:181
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
ptr_psi_term stack_cons ( ptr_psi_term  head,
ptr_psi_term  tail 
)

stack_cons

Parameters
head- ptr_psi_term head
tail- ptr_psi_term tail

STACK_CONS(head,tail) Create a CONS object.

Definition at line 46 of file built_ins.c.

References alist, wl_psi_term::attr_list, cons(), FEATCMP, one, stack_insert(), stack_psi_term(), two, and wl_psi_term::type.

47 {
49 
50  cons=stack_psi_term(4);
51  cons->type=alist;
52  if(head)
53  (void)stack_insert(FEATCMP,one,&(cons->attr_list),(GENERIC)head);
54  if(tail)
55  (void)stack_insert(FEATCMP,two,&(cons->attr_list),(GENERIC)tail);
56 
57  return cons;
58 }
ptr_definition alist
symbol in bi module
Definition: def_glob.h:319
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
char * two
Definition: def_glob.h:892
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
ptr_int_list cons(GENERIC v, ptr_int_list l)
cons
Definition: types.c:179
ptr_node stack_insert(long comp, char *keystr, ptr_node *tree, GENERIC info)
stack_insert
Definition: trees.c:337
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
char * one
Definition: def_glob.h:891
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
ptr_psi_term stack_int ( long  n)

stack_int

Parameters
n- long n

STACK_INT(n) create an INT object

Definition at line 91 of file built_ins.c.

References heap_alloc(), integer, REAL, stack_psi_term(), wl_psi_term::type, and wl_psi_term::value_3.

92 {
93  ptr_psi_term m;
94  m=stack_psi_term(4);
95  m->type=integer;
96  m->value_3= heap_alloc(sizeof(REAL));
97  *(REAL *)m->value_3=(REAL)n;
98  return m;
99 }
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
GENERIC value_3
Definition: def_struct.h:186
ptr_definition type
Definition: def_struct.h:181
GENERIC heap_alloc(long s)
heap_alloc
Definition: memory.c:1616
ptr_psi_term stack_nil ( )

stack_nil

Create the NIL object on the stack.

Definition at line 26 of file built_ins.c.

References nil, stack_psi_term(), and wl_psi_term::type.

28 {
29  ptr_psi_term empty;
30 
31  empty=stack_psi_term(4);
32  empty->type=nil;
33 
34  return empty;
35 }
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
ptr_definition nil
symbol in bi module
Definition: def_glob.h:340
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term stack_pair ( ptr_psi_term  left,
ptr_psi_term  right 
)

stack_pair

Parameters
left- ptr_psi_term left
right- ptr_psi_term right

STACK_PAIR(left,right) create a PAIR object.

Definition at line 69 of file built_ins.c.

References and, wl_psi_term::attr_list, FEATCMP, one, stack_insert(), stack_psi_term(), two, and wl_psi_term::type.

70 {
71  ptr_psi_term pair;
72 
73  pair=stack_psi_term(4);
74  pair->type=and;
75  if(left)
76  (void)stack_insert(FEATCMP,one,&(pair->attr_list),(GENERIC)left);
77  if(right)
78  (void)stack_insert(FEATCMP,two,&(pair->attr_list),(GENERIC)right);
79 
80  return pair;
81 }
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
char * two
Definition: def_glob.h:892
ptr_definition and
symbol in syntax module
Definition: def_glob.h:171
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
ptr_node stack_insert(long comp, char *keystr, ptr_node *tree, GENERIC info)
stack_insert
Definition: trees.c:337
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
char * one
Definition: def_glob.h:891
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
ptr_psi_term stack_string ( char *  s)

stack_string

Parameters
s- char *s

STACK_STRING(s) create a STRING object

Definition at line 109 of file built_ins.c.

References heap_copy_string(), quoted_string, stack_psi_term(), wl_psi_term::type, and wl_psi_term::value_3.

110 {
112  t->type = quoted_string;
114  return t;
115 }
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
char * heap_copy_string(char *s)
heap_copy_string
Definition: trees.c:172
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
GENERIC value_3
Definition: def_struct.h:186
ptr_definition type
Definition: def_struct.h:181
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
char * str_conc ( char *  s1,
char *  s2 
)

str_conc

Parameters
s1- char *s1
s2- char *s2

Definition at line 5496 of file built_ins.c.

References heap_alloc().

5497 {
5498  char *result;
5499 
5500  result=(char *)heap_alloc(strlen(s1)+strlen(s2)+1);
5501  sprintf(result,"%s%s",s1,s2);
5502 
5503  return result;
5504 }
GENERIC heap_alloc(long s)
heap_alloc
Definition: memory.c:1616
char * sub_str ( char *  s,
long  p,
long  n 
)

sub_str

Parameters
s- char *s
p- long p
n- long n

Definition at line 5514 of file built_ins.c.

References heap_alloc().

5515 {
5516  char *result;
5517  long i;
5518  long l;
5519 
5520  l=strlen(s);
5521  if(p>l || p<0 || n<0)
5522  n=0;
5523  else
5524  if(p+n-1>l)
5525  n=l-p+1;
5526 
5527  result=(char *)heap_alloc(n+1);
5528  for(i=0;i<n;i++)
5529  *(result+i)= *(s+p+i-1);
5530 
5531  *(result+n)=0;
5532 
5533  return result;
5534 }
GENERIC heap_alloc(long s)
heap_alloc
Definition: memory.c:1616
static void unify_bool ( ptr_psi_term  arg)
static

unify_bool

Parameters
arg- ptr_psi_term arg

Definition at line 911 of file built_ins.c.

References boolean, NULL, push_goal(), stack_psi_term(), wl_psi_term::type, and unify.

912 {
913  ptr_psi_term tmp;
914 
915  tmp=stack_psi_term(4);
916  tmp->type=boolean;
917  push_goal(unify,tmp,arg,(GENERIC)NULL);
918 }
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
#define NULL
Definition: def_const.h:533
ptr_definition boolean
symbol in bi module
Definition: def_glob.h:185
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
ptr_definition type
Definition: def_struct.h:181
void unify_bool_result ( ptr_psi_term  t,
long  v 
)

unify_bool_result

Parameters
t- ptr_psi_term t
v- long v

UNIFY_BOOL_RESULT(t,v) Unify psi_term T to the boolean value V = TRUE or FALSE. This is used by built-in logical functions to return their result.

Definition at line 344 of file built_ins.c.

References lf_false, lf_true, NULL, push_goal(), stack_psi_term(), wl_psi_term::type, and unify.

345 {
346  ptr_psi_term u;
347 
348  u=stack_psi_term(4);
349  u->type=v?lf_true:lf_false;
350  push_goal(unify,t,u,NULL);
351 
352  /* Completely commented out by Richard on Nov 25th 1993
353  What's *your* Birthday? Maybe you'd like a Birthday-Bug-Card!
354  tried restoring 2.07 DJD no effect on test suite - removed again 2.14 DJD
355 
356  if((GENERIC)t<heap_pointer) {
357  push_ptr_value(def_ptr,&(t->type));
358  if (v) {
359  t->type=lf_true;
360  t->status=0;
361  }
362  else {
363  t->type=lf_false;
364  t->status=0;
365  }
366 
367  i_check_out(t);
368  if (t->resid)
369  release_resid(t);
370  }
371  else {
372  warningline("the persistent term '%P' appears in a boolean constraint and cannot be refined\n",t);
373  }
374  / */
375 }
ptr_definition lf_false
symbol in bi module
Definition: def_glob.h:284
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
#define NULL
Definition: def_const.h:533
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
ptr_definition lf_true
symbol in bi module
Definition: def_glob.h:410
ptr_definition type
Definition: def_struct.h:181
long unify_real_result ( ptr_psi_term  t,
REAL  v 
)

unify_real_result

Parameters
t- ptr_psi_term t
v- REAL v

UNIFY_REAL_RESULT(t,v) Unify psi_term T to the real value V. This is used by built-in arithmetic functions to return their result.

Definition at line 386 of file built_ins.c.

References assert, def_ptr, deref_ptr, FALSE, heap_alloc(), heap_pointer, i_check_out(), int_ptr, integer, matches(), NULL, push_ptr_value(), REAL, release_resid(), wl_psi_term::resid, wl_psi_term::status, TRUE, wl_psi_term::type, wl_psi_term::value_3, and warningline().

387 {
388  long smaller;
389  long success=TRUE;
390 
391 #ifdef prlDEBUG
392  if (t->value_3) {
393  printf("*** BUG: value already present in UNIFY_REAL_RESULT\n");
394  }
395 #endif
396 
397  if((GENERIC)t<heap_pointer) { /* RM: Jun 8 1993 */
398  deref_ptr(t);
399  assert(t->value_3==NULL); /* 10.6 */
401  t->value_3=heap_alloc(sizeof(REAL)); /* 12.5 */
402  *(REAL *)t->value_3 = v;
403 
404  (void)matches(t->type,integer,&smaller);
405 
406  if (v==floor(v)){
407  if (!smaller) {
409  t->type=integer;
410  t->status=0;
411  }
412  }
413  else
414  if (smaller)
415  success=FALSE;
416 
417  if (success) {
418  (void)i_check_out(t);
419  if (t->resid)
420  release_resid(t);
421  }
422  }
423  else {
424  warningline("the persistent term '%P' appears in an arithmetic constraint and cannot be refined\n",t);
425  }
426 
427  return success;
428 }
ptr_residuation resid
Definition: def_struct.h:189
void push_ptr_value(type_ptr t, GENERIC *p)
push_ptr_value
Definition: login.c:383
GENERIC heap_pointer
used to allocate from heap - size allocated subtracted - adj for alignment
Definition: def_glob.h:55
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
#define def_ptr
values of type_ptr
Definition: def_const.h:404
long matches(ptr_definition t1, ptr_definition t2, long *smaller)
matches
Definition: types.c:1666
#define NULL
Definition: def_const.h:533
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
void release_resid(ptr_psi_term t)
release_resid
Definition: lefun.c:445
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
GENERIC value_3
Definition: def_struct.h:186
void warningline(char *format,...)
warningline
Definition: error.c:371
ptr_definition type
Definition: def_struct.h:181
long i_check_out(ptr_psi_term t)
i_check_out
Definition: lefun.c:1033
GENERIC heap_alloc(long s)
heap_alloc
Definition: memory.c:1616
#define assert(N)
Definition: memory.c:114
#define int_ptr
values of type_ptr
Definition: def_const.h:397

Variable Documentation

long built_in_index =0
static

Definition at line 16 of file built_ins.c.