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

built in system functions More...

Go to the source code of this file.

Macros

#define copyPsiTerm(a, b)   (ptr_psi_term )memcpy(a,b,sizeof(psi_term))
 

Functions

long c_trace ()
 trace More...
 
long c_tprove ()
 c_tprove More...
 
static long c_step ()
 c_step More...
 
static long c_verbose ()
 c_verbose More...
 
static long c_warning ()
 c_warning More...
 
static long c_maxint ()
 c_maxint More...
 
long c_quiet ()
 c_quiet More...
 
static long c_cputime ()
 c_cputime More...
 
static long c_realtime ()
 c_realtime More...
 
static long c_localtime ()
 localtime More...
 
static long c_statistics ()
 c_statistics More...
 
static long c_garbage ()
 c_garbage More...
 
static long c_getenv ()
 c_getenv More...
 
static long c_system ()
 c_system More...
 
static long c_encode ()
 c_encode More...
 
void setUnitList (GENERIC x)
 setUnitList(GENERIC x) More...
 
ptr_psi_term unitListValue ()
 make psi term from unitListElement More...
 
GENERIC unitListNext ()
 set unitListElement to NULL & return NULL More...
 
ptr_psi_term intListValue (ptr_int_list p)
 ptr_psi_term intListValue More...
 
GENERIC intListNext (ptr_int_list p)
 intListNext More...
 
ptr_psi_term quotedStackCopy (psi_term p)
 
ptr_psi_term residListGoalQuote (ptr_residuation p)
 residListGoalQuote More...
 
GENERIC residListNext (ptr_residuation p)
 residListNext More...
 
ptr_psi_term makePsiTerm (ptr_definition x)
 ptr_psi_term makePsiTerm More...
 
ptr_psi_term makePsiList (GENERIC head, ptr_psi_term(*valueFunc)(), GENERIC(*nextFunc)())
 makePsiList More...
 
static long c_residList ()
 c_residList() More...
 
ptr_goal makeGoal (ptr_psi_term p)
 makeGoal More...
 
static long c_residuate ()
 c_residuate More...
 
static long c_mresiduate ()
 c_mresiduate More...
 
void insert_system_builtins ()
 insert_system_builtins More...
 

Variables

static GENERIC unitListElement
 

Detailed Description

built in system functions

Definition in file bi_sys.c.

Macro Definition Documentation

#define copyPsiTerm (   a,
 
)    (ptr_psi_term )memcpy(a,b,sizeof(psi_term))

Definition at line 10 of file bi_sys.c.

Function Documentation

static long c_cputime ( )
static

c_cputime

Return the cpu-time in seconds used by the Wild_Life interpreter.

Definition at line 207 of file bi_sys.c.

References wl_goal::aaaa_1, aim, wl_goal::bbbb_1, deref_args, deref_ptr, get_real_value(), life_end, life_start, REAL, set_empty, and unify_real_result().

208 {
209  ptr_psi_term result, t;
210  REAL thetime,val;
211  long num,success;
212 
213  t=aim->aaaa_1;
215  result=aim->bbbb_1;
216  deref_ptr(result);
217  success=get_real_value(result,&val,&num);
218  if (success) {
219  (void)times(&life_end);
220  thetime=(life_end.tms_utime-life_start.tms_utime)/60.0;
221  if (num)
222  success=(val==thetime);
223  else
224  success=unify_real_result(result,thetime);
225  }
226  return success;
227 }
struct tms life_end
Definition: def_glob.h:90
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
#define set_empty
Set constants for deref_args in lefun.c.
Definition: def_const.h:493
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
struct tms life_start
time life started - seconds
Definition: def_glob.h:83
#define deref_ptr(P)
Definition: def_macro.h:100
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 c_encode ( )
static

c_encode

Force type encoding. This need normally never be called by the user.

Definition at line 449 of file bi_sys.c.

References wl_goal::aaaa_1, aim, deref_args, encode_types(), set_empty, and TRUE.

450 {
451  ptr_psi_term t;
452 
453  t=aim->aaaa_1;
455  encode_types();
456  return TRUE;
457 }
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 encode_types()
encode_types
Definition: types.c:1091
#define deref_args(P, S)
Definition: def_macro.h:150
static long c_garbage ( )
static

c_garbage

Force a call to the garbage collector.

Definition at line 343 of file bi_sys.c.

References wl_goal::aaaa_1, aim, deref_args, garbage(), set_empty, and TRUE.

344 {
345  ptr_psi_term t;
346 
347  t=aim->aaaa_1;
349  garbage();
350  return TRUE;
351 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void garbage()
garbage
Definition: memory.c:1530
#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_getenv ( )
static

c_getenv

Get the value of an environment variable.

Definition at line 360 of file bi_sys.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, deref_ptr, Errorline(), FALSE, get_two_args(), heap_copy_string(), matches(), NULL, push_goal(), quoted_string, stack_psi_term(), TRUE, wl_psi_term::type, unify, and wl_psi_term::value_3.

361 {
362  long success=FALSE;
363  ptr_psi_term arg1,arg2,funct,result,t;
364  long smaller;
365  char * s;
366 
367  funct = aim->aaaa_1;
368  result=aim->bbbb_1;
369  deref_ptr(funct);
370  deref_ptr(result);
371 
372  get_two_args(funct->attr_list, &arg1, &arg2);
373  if(arg1) {
374  deref_ptr(arg1);
375  if(matches(arg1->type,quoted_string,&smaller) && arg1->value_3) {
376  s=getenv((char *)arg1->value_3);
377  if(s) {
378  success=TRUE;
379  t=stack_psi_term(4);
380  t->type=quoted_string;
382  push_goal(unify,result,t,NULL);
383  }
384  }
385  else
386  Errorline("bad argument in %P\n",funct);
387  }
388  else
389  Errorline("argument missing in %P\n",funct);
390 
391  return success;
392 }
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 matches(ptr_definition t1, ptr_definition t2, long *smaller)
matches
Definition: types.c:1666
#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 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
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
static long c_localtime ( )
static

localtime

Return a psi-term containing the local time split up into year, month, day, hour, minute, second, and weekday. This is useful for building real-time applications such as clocks.

Definition at line 269 of file bi_sys.c.

References wl_goal::aaaa_1, aim, wl_goal::bbbb_1, day_attr, deref_args, deref_ptr, hour_attr, minute_attr, month_attr, NULL, push_goal(), second_attr, set_empty, stack_add_int_attr(), stack_psi_term(), timesym, TRUE, wl_psi_term::type, unify, weekday_attr, and year_attr.

270 {
271  ptr_psi_term result, t, psitime;
272  long success=TRUE;
273  struct timeval tp;
274  struct timezone tzp;
275  struct tm *thetime;
276 
277  t=aim->aaaa_1;
279  result=aim->bbbb_1;
280  deref_ptr(result);
281 
282  gettimeofday(&tp, &tzp);
283  thetime=localtime((time_t *) &(tp.tv_sec));
284 
285  psitime=stack_psi_term(4);
286  psitime->type=timesym;
287  stack_add_int_attr(psitime, year_attr, thetime->tm_year+1900);
288  stack_add_int_attr(psitime, month_attr, thetime->tm_mon+1);
289  stack_add_int_attr(psitime, day_attr, thetime->tm_mday);
290  stack_add_int_attr(psitime, hour_attr, thetime->tm_hour);
291  stack_add_int_attr(psitime, minute_attr, thetime->tm_min);
292  stack_add_int_attr(psitime, second_attr, thetime->tm_sec);
293  stack_add_int_attr(psitime, weekday_attr, thetime->tm_wday);
294 
295  push_goal(unify,result,psitime,NULL);
296 
297  return success;
298 }
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
ptr_definition timesym
symbol in bi module
Definition: def_glob.h:417
#define set_empty
Set constants for deref_args in lefun.c.
Definition: def_const.h:493
#define NULL
Definition: def_const.h:533
void stack_add_int_attr(ptr_psi_term t, char *attrname, long value)
stack_add_int_attr
Definition: token.c:94
#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_goal aim
Definition: def_glob.h:1024
char * weekday_attr
Definition: def_glob.h:900
#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 * minute_attr
Definition: def_glob.h:898
char * year_attr
Definition: def_glob.h:894
char * second_attr
Definition: def_glob.h:899
char * day_attr
Definition: def_glob.h:896
ptr_definition type
Definition: def_struct.h:181
char * hour_attr
Definition: def_glob.h:897
ptr_psi_term bbbb_1
Definition: def_struct.h:240
char * month_attr
Definition: def_glob.h:895
static long c_maxint ( )
static

c_maxint

Return the integer of greatest magnitude that guarantees exact integer arithmetic.

Definition at line 157 of file bi_sys.c.

References wl_goal::aaaa_1, aim, wl_goal::bbbb_1, deref_args, deref_ptr, get_real_value(), REAL, set_empty, unify_real_result(), and WL_MAXINT.

158 {
159  ptr_psi_term t,result;
160  REAL val;
161  long num,success;
162 
163  t=aim->aaaa_1;
165  result=aim->bbbb_1;
166  deref_ptr(result);
167  success=get_real_value(result,&val,&num);
168  if (success) {
169  if (num)
170  success=(val==(REAL)WL_MAXINT);
171  else
172  success=unify_real_result(result,(REAL)WL_MAXINT);
173  }
174  return success;
175 }
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
#define set_empty
Set constants for deref_args in lefun.c.
Definition: def_const.h:493
#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
ptr_goal aim
Definition: def_glob.h:1024
#define deref_args(P, S)
Definition: def_macro.h:150
#define WL_MAXINT
Maximum exactly representable integer (2^53-1 for double IEEE format)
Definition: def_const.h:140
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 c_mresiduate ( )
static

c_mresiduate

Multiple-variable residuation of a predicate. mresiduate(A,B) -> residuate goal B on a list of variables A, non_strict in both args. If any of the variables is bound the predicate is executed. The list must have finite length.

Definition at line 698 of file bi_sys.c.

References wl_goal::aaaa_1, aim, alist, wl_psi_term::attr_list, deref_args, deref_ptr, Errorline(), FALSE, get_two_args(), makeGoal(), nil, NULL, residuateGoalOnVar(), set_1_2, TRUE, and wl_psi_term::type.

700 {
701  long success=TRUE;
702  ptr_psi_term pred;
703  ptr_psi_term arg1, arg2, tmp, var;
704  ptr_goal g;
705 
706  pred = aim->aaaa_1;
707  deref_ptr(pred);
708 
709  get_two_args(pred->attr_list, &arg1, &arg2);
710  if ((!arg1)||(!arg2)) {
711  Errorline("%P requires two arguments.\n",pred);
712  return FALSE;
713  }
714 
715  deref_ptr(arg1);
716  deref_ptr(arg2);
717  deref_args(pred, set_1_2);
718 
719  g = makeGoal(arg2);
720 
721  /* Then residuate on all the list variables: */
722  tmp=arg1;
723  while(tmp && tmp->type==alist) { /* RM: Dec 14 1992 */
724  get_two_args(tmp->attr_list,&var,&tmp);
725  if(var) {
726  deref_ptr(var);
727  (void)residuateGoalOnVar(g,var,NULL);
728  }
729  if(tmp)
730  deref_ptr(tmp);
731  }
732 
733  if(!tmp || tmp->type!=nil) {
734  Errorline("%P should be a nil-terminated list in mresiduate.\n",arg1);
735  success=FALSE;
736  }
737 
738  return success;
739 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
ptr_definition alist
symbol in bi module
Definition: def_glob.h:319
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
long residuateGoalOnVar(ptr_goal g, ptr_psi_term var, ptr_psi_term othervar)
residuateGoalOnVar
Definition: lefun.c:192
#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_definition nil
symbol in bi module
Definition: def_glob.h:340
ptr_goal aim
Definition: def_glob.h:1024
ptr_goal makeGoal(ptr_psi_term p)
makeGoal
Definition: bi_sys.c:646
#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
long c_quiet ( )

c_quiet

Return the value of not(NOTQUIET).

Definition at line 186 of file bi_sys.c.

References wl_goal::aaaa_1, aim, wl_goal::bbbb_1, deref_args, deref_ptr, lf_false, lf_true, NOTQUIET, NULL, push_goal(), set_empty, stack_psi_term(), TRUE, wl_psi_term::type, and unify.

187 {
188  ptr_psi_term t,result,ans;
189  long success=TRUE;
190 
191  t=aim->aaaa_1;
193  result=aim->bbbb_1;
194  deref_ptr(result);
195  ans=stack_psi_term(4);
196  ans->type = NOTQUIET ? lf_false : lf_true;
197  push_goal(unify,result,ans,NULL);
198  return success;
199 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
ptr_definition lf_false
symbol in bi module
Definition: def_glob.h:284
#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
#define set_empty
Set constants for deref_args in lefun.c.
Definition: def_const.h:493
#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
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
static long c_realtime ( )
static

c_realtime

Return the time in seconds since 00:00:00 GMT, January 1, 1970. This is useful for building real-time applications such as clocks.

Definition at line 236 of file bi_sys.c.

References wl_goal::aaaa_1, aim, wl_goal::bbbb_1, deref_args, deref_ptr, get_real_value(), REAL, set_empty, and unify_real_result().

237 {
238  ptr_psi_term result, t;
239  REAL thetime,val;
240  long num,success;
241  struct timeval tp;
242  struct timezone tzp;
243 
244  t=aim->aaaa_1;
246  result=aim->bbbb_1;
247  deref_ptr(result);
248  success=get_real_value(result,&val,&num);
249  if (success) {
250  gettimeofday(&tp, &tzp);
251  thetime=(REAL)tp.tv_sec + ((REAL)tp.tv_usec/1000000.0);
252  /* thetime=times(&life_end)/60.0; */
253  if (num)
254  success=(val==thetime);
255  else
256  success=unify_real_result(result,thetime);
257  }
258  return success;
259 }
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
#define set_empty
Set constants for deref_args in lefun.c.
Definition: def_const.h:493
#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
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 c_residList ( )
static

c_residList()

rlist(A) -> list all eval/prove goals residuated on variable 'A'.

Definition at line 612 of file bi_sys.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(), makePsiList(), NULL, push_goal(), wl_psi_term::resid, resid_aim, residListGoalQuote(), residListNext(), set_1, TRUE, and unify.

613 {
614  ptr_psi_term func;
615  ptr_psi_term result,arg1, other;
616 
617  func = aim->aaaa_1;
618  deref_ptr(func);
619 
620  get_one_arg(func->attr_list, &arg1);
621  if (!arg1)
622  {
623  curry();
624  return TRUE;
625  }
626 
627  result = aim->bbbb_1;
628  deref(result);
629  deref_ptr(arg1);
630  deref_args(func, set_1);
631 
632  other = makePsiList((void *)arg1->resid,
634  residListNext);
635  resid_aim = NULL;
636  push_goal(unify,result,other,NULL);
637  return TRUE;
638 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
ptr_residuation resid
Definition: def_struct.h:189
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_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
GENERIC residListNext(ptr_residuation p)
residListNext
Definition: bi_sys.c:562
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_psi_term makePsiList(GENERIC head, ptr_psi_term(*valueFunc)(), GENERIC(*nextFunc)())
makePsiList
Definition: bi_sys.c:590
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_psi_term residListGoalQuote(ptr_residuation p)
residListGoalQuote
Definition: bi_sys.c:546
ptr_node attr_list
Definition: def_struct.h:187
static long c_residuate ( )
static

c_residuate

residuate(A,B) -> residuate goal B on variable A, non_strict in both args

Definition at line 664 of file bi_sys.c.

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

665 {
666  ptr_psi_term pred;
667  ptr_psi_term arg1, arg2;
668  ptr_goal g;
669 
670  pred = aim->aaaa_1;
671  deref_ptr(pred);
672 
673  get_two_args(pred->attr_list, &arg1, &arg2);
674  if ((!arg1)||(!arg2)) {
675  Errorline("%P requires two arguments.\n",pred);
676  return FALSE;
677  }
678 
679  deref_ptr(arg1);
680  deref_ptr(arg2);
681  deref_args(pred, set_1_2);
682 
683  g = makeGoal(arg2);
684  (void)residuateGoalOnVar(g, arg1, NULL);
685 
686  return TRUE;
687 }
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 residuateGoalOnVar(ptr_goal g, ptr_psi_term var, ptr_psi_term othervar)
residuateGoalOnVar
Definition: lefun.c:192
#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
ptr_goal makeGoal(ptr_psi_term p)
makeGoal
Definition: bi_sys.c:646
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_node attr_list
Definition: def_struct.h:187
static long c_statistics ( )
static

c_statistics

Print some information about Wild_Life: stack size, heap size, total memory.

Definition at line 306 of file bi_sys.c.

References wl_goal::aaaa_1, aim, deref_args, heap_pointer, mem_base, mem_limit, set_empty, stack_pointer, and TRUE.

307 {
308  ptr_psi_term t;
309  long success=TRUE;
310  long t1,t2,t3;
311 
312  t=aim->aaaa_1;
314 
315  t1 = sizeof(mem_base)*(stack_pointer-mem_base);
316  t2 = sizeof(mem_base)*(mem_limit-heap_pointer);
317  t3 = sizeof(mem_base)*(mem_limit-mem_base);
318 
319  printf("\n");
320  /* printf("************** SYSTEM< INFORMATION **************\n"); */
321  printf("Stack size : %8ld bytes (%5ldK) (%ld%%)\n",t1,t1/1024,100*t1/t3);
322  printf("Heap size : %8ld bytes (%5ldK) (%ld%%)\n",t2,t2/1024,100*t2/t3);
323  printf("Total memory: %8ld bytes (%5ldK)\n",t3,t3/1024);
324 
325 #ifdef X11
326  printf("X predicates are installed.\n");
327 #else
328  printf("X predicates are not installed.\n");
329 #endif
330 
331  /* printf("\n"); */
332  /* printf("************************************************\n"); */
333  return success;
334 }
GENERIC stack_pointer
used to allocate from stack - size allocated added - adj for alignment
Definition: def_glob.h:69
ptr_psi_term aaaa_1
Definition: def_struct.h:239
GENERIC heap_pointer
used to allocate from heap - size allocated subtracted - adj for alignment
Definition: def_glob.h:55
GENERIC mem_limit
starting point of heap - mem_base aligned
Definition: def_glob.h:62
#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
GENERIC mem_base
mem_size memory allocated in init_memory by malloc
Definition: def_glob.h:48
static long c_step ( )
static

c_step

Toggle the single step flag & print a message saying whether single stepping mode is on or off.

Definition at line 98 of file bi_sys.c.

References wl_goal::aaaa_1, aim, deref_args, set_empty, toggle_step(), and TRUE.

99 {
100  ptr_psi_term t;
101 
102  t=aim->aaaa_1;
104  toggle_step();
105  return TRUE;
106 }
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
void toggle_step()
toggle_step
Definition: error.c:747
#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_system ( )
static

c_system

Pass a string to shell for execution. Return the value as the result.

Definition at line 400 of file bi_sys.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, set_1, TRUE, wl_psi_term::type, unify_real_result(), and wl_psi_term::value_3.

401 {
402  long success=TRUE;
403  ptr_psi_term arg1,arg2,funct,result;
404  REAL value;
405  long smaller;
406 
407  funct=aim->aaaa_1;
408  deref_ptr(funct);
409  result=aim->bbbb_1;
410  get_two_args(funct->attr_list,&arg1,&arg2);
411  if(arg1) {
412  deref(arg1);
413  deref_args(funct,set_1);
414  if((success=matches(arg1->type,quoted_string,&smaller)))
415  if(arg1->value_3) {
416  value=(REAL)system((char *)arg1->value_3);
417  if(value==127) {
418  success=FALSE;
419  Errorline("could not execute shell in %P.\n",funct);
420  /* report_error(funct,"couldn't execute shell"); */
421  }
422  else
423  success=unify_real_result(result,value);
424  }
425  else {
426  /* residuate(arg1); */ /* RM: Feb 10 1993 */
427  success=FALSE;
428  Errorline("bad argument in %P.\n",funct);
429  }
430  else {
431  success=FALSE;
432  Errorline("bad argument in %P.\n",funct);
433  /* report_error(funct,"bad argument"); */
434  }
435  }
436  else
437  curry();
438 
439  return success;
440 }
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
#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
long c_tprove ( )

c_tprove

UNSURE

Definition at line 81 of file bi_sys.c.

References wl_goal::aaaa_1, aim, deref_args, set_empty, set_trace_to_prove(), and TRUE.

82 {
83  ptr_psi_term t;
84 
85  t=aim->aaaa_1;
88  return TRUE;
89 }
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
void set_trace_to_prove()
set_trace_to_prove
Definition: error.c:727
#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
long c_trace ( )

trace

long c_trace() turn tracing on or off

Definition at line 30 of file bi_sys.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, deref_args, deref_ptr, Errorline(), FALSE, get_two_args(), is_top, lf_false, lf_true, set_empty, stepflag, toggle_trace(), trace, TRUE, wl_psi_term::type, and unify_bool_result().

31 {
32  long success=TRUE;
33  ptr_psi_term t,arg1,arg2;
34 
35  t=aim->aaaa_1;
37  get_two_args(t->attr_list,&arg1,&arg2);
38  if (arg1) {
39  deref_ptr(arg1);
40  if (is_top(arg1)) {
42  trace=FALSE;
43  }
44  else if (arg1->type==lf_true)
45  trace=TRUE;
46  else if (arg1->type==lf_false)
47  trace=FALSE;
48  else {
49  Errorline("bad first argument in %P.\n",t);
50  /* report_error(t,"bad first argument"); */
51  success=FALSE;
52  }
53  }
54  if (arg2) {
55  deref_ptr(arg2);
56  if (is_top(arg2)) {
59  }
60  else if (arg2->type==lf_true)
61  stepflag=TRUE;
62  else if (arg2->type==lf_false)
64  else {
65  Errorline("bad second argument in %P.\n",t);
66  /* report_error(t,"bad second argument"); */
67  success=FALSE;
68  }
69  }
70  if (!arg1 && !arg2)
71  toggle_trace();
72  return success;
73 }
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
ptr_definition lf_false
symbol in bi module
Definition: def_glob.h:284
void unify_bool_result(ptr_psi_term t, long v)
unify_bool_result
Definition: built_ins.c:344
#define set_empty
Set constants for deref_args in lefun.c.
Definition: def_const.h:493
long trace
Definition: def_glob.h:913
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
void toggle_trace()
toggle_trace
Definition: error.c:737
long stepflag
Definition: def_glob.h:676
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_verbose ( )
static

c_verbose

Toggle the verbose flag & print a message saying whether verbose mode is on or off.

Definition at line 115 of file bi_sys.c.

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

116 {
117  ptr_psi_term t;
118 
119  t=aim->aaaa_1;
121  verbose = !verbose;
122  printf("*** Verbose mode is turned ");
123  printf(verbose?"on.\n":"off.\n");
124  return TRUE;
125 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
long verbose
Definition: def_glob.h:914
#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_warning ( )
static

c_warning

Toggle the warning flag & print a message saying whether warnings are printed or not. Default: print warnings. (Errors cannot be turned off.)

Definition at line 136 of file bi_sys.c.

References wl_goal::aaaa_1, aim, deref_args, infoline(), set_empty, TRUE, and warningflag.

137 {
138  ptr_psi_term t;
139 
140  t=aim->aaaa_1;
143 
144  /* RM: Sep 24 1993 */
145  infoline("*** Warning messages are%s printed\n",warningflag?"":" not");
146 
147  return TRUE;
148 }
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
long warningflag
Definition: def_glob.h:911
void infoline(char *format,...)
infoline
Definition: error.c:281
#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
void insert_system_builtins ( )

insert_system_builtins

Definition at line 746 of file bi_sys.c.

References bi_module, c_cputime(), c_encode(), c_garbage(), c_getenv(), c_localtime(), c_maxint(), c_mresiduate(), c_quiet(), c_realtime(), c_residList(), c_residuate(), c_statistics(), c_step(), c_system(), c_tprove(), c_trace(), c_verbose(), c_warning(), function_it, new_built_in(), and predicate_it.

747 {
754  new_built_in(bi_module,"quiet",(def_type)function_it,c_quiet); /* 21.1 */
766 }
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_mresiduate()
c_mresiduate
Definition: bi_sys.c:698
static long c_garbage()
c_garbage
Definition: bi_sys.c:343
#define function_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1408
static long c_step()
c_step
Definition: bi_sys.c:98
static long c_realtime()
c_realtime
Definition: bi_sys.c:236
#define predicate_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1401
static long c_verbose()
c_verbose
Definition: bi_sys.c:115
static long c_residuate()
c_residuate
Definition: bi_sys.c:664
static long c_getenv()
c_getenv
Definition: bi_sys.c:360
long c_trace()
trace
Definition: bi_sys.c:30
static long c_warning()
c_warning
Definition: bi_sys.c:136
ptr_module bi_module
Module for public built-ins.
Definition: def_glob.h:687
static long c_system()
c_system
Definition: bi_sys.c:400
static long c_cputime()
c_cputime
Definition: bi_sys.c:207
static long c_residList()
c_residList()
Definition: bi_sys.c:612
static long c_encode()
c_encode
Definition: bi_sys.c:449
static long c_localtime()
localtime
Definition: bi_sys.c:269
static long c_maxint()
c_maxint
Definition: bi_sys.c:157
static long c_statistics()
c_statistics
Definition: bi_sys.c:306
long c_tprove()
c_tprove
Definition: bi_sys.c:81
long c_quiet()
c_quiet
Definition: bi_sys.c:186
GENERIC intListNext ( ptr_int_list  p)

intListNext

Parameters
p- ptr_int_list p

not sure purpose (DJD ???)

Definition at line 515 of file bi_sys.c.

References wl_int_list::next.

516 {
517  return (GENERIC )(p->next);
518 }
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
ptr_int_list next
Definition: def_struct.h:86
ptr_psi_term intListValue ( ptr_int_list  p)

ptr_psi_term intListValue

Parameters
p- ptr_int_list p

not sure purpose (DJD ???)

Definition at line 503 of file bi_sys.c.

References makePsiTerm(), and wl_int_list::value_1.

504 {
505  return makePsiTerm((void *)p->value_1);
506 }
ptr_psi_term makePsiTerm(ptr_definition x)
ptr_psi_term makePsiTerm
Definition: bi_sys.c:573
GENERIC value_1
Definition: def_struct.h:85
ptr_goal makeGoal ( ptr_psi_term  p)

makeGoal

Parameters
p- ptr_psi_term p

Definition at line 646 of file bi_sys.c.

References DEFRULES, goal_stack, wl_goal::next, NULL, prove, and push_goal().

647 {
648  ptr_goal old = goal_stack;
649  ptr_goal g;
650 
652  g = goal_stack;
653  g->next=NULL;
654  goal_stack = old;
655  return g;
656 }
#define prove
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1051
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
#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
ptr_goal next
Definition: def_struct.h:242
ptr_psi_term makePsiList ( GENERIC  head,
ptr_psi_term(*)()  valueFunc,
GENERIC(*)()  nextFunc 
)

makePsiList

Parameters
head- GENERIC head
*valueFunc- ptr_psi_term (*valueFunc)()
nextFunc- GENERIC (*nextFunc)()

Definition at line 590 of file bi_sys.c.

References stack_cons(), and stack_nil().

591 {
592  ptr_psi_term result;
593 
594 
595  /* RM: Dec 14 1992: Added the new list representation */
596  result=stack_nil();
597 
598  while (head) {
599  result=stack_cons((*valueFunc)(head),result);
600  head=(*nextFunc)(head);
601  }
602  return result;
603 }
ptr_psi_term stack_cons(ptr_psi_term head, ptr_psi_term tail)
stack_cons
Definition: built_ins.c:46
ptr_psi_term stack_nil()
stack_nil
Definition: built_ins.c:26
ptr_psi_term makePsiTerm ( ptr_definition  x)

ptr_psi_term makePsiTerm

Parameters
x- ptr_definition x

Definition at line 573 of file bi_sys.c.

References stack_psi_term(), and wl_psi_term::type.

574 {
575  ptr_psi_term p;
576 
577  p = stack_psi_term(4);
578  p->type = x;
579  return p;
580 }
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term quotedStackCopy ( psi_term  p)

Definition at line 528 of file bi_sys.c.

References mark_quote(), and stack_copy_psi_term().

529 {
530  ptr_psi_term q;
531 
533  mark_quote(q);
534  return q;
535 }
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
void mark_quote(ptr_psi_term t)
mark_quote
Definition: copy.c:674
ptr_psi_term stack_copy_psi_term(psi_term t)
stack_copy_psi_term
Definition: parser.c:205
ptr_psi_term residListGoalQuote ( ptr_residuation  p)

residListGoalQuote

Parameters
p- ptr_residuation p

Return a ptr to a psi-term marked as evaluated. The psi-term is a copy at the top level of the goal residuated on p, with the rest of the psi-term shared.

Definition at line 546 of file bi_sys.c.

References wl_goal::aaaa_1, copyPsiTerm, wl_residuation::goal, stack_psi_term(), and wl_psi_term::status.

547 {
548  ptr_psi_term psi;
549 
550  psi = stack_psi_term(4);
551  copyPsiTerm(psi, p->goal->aaaa_1);
552  psi->status = 4;
553  return psi;
554 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
ptr_goal goal
Definition: def_struct.h:172
#define copyPsiTerm(a, b)
Definition: bi_sys.c:10
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
GENERIC residListNext ( ptr_residuation  p)

residListNext

Parameters
p- ptr_residuation p

Definition at line 562 of file bi_sys.c.

References wl_residuation::next.

563 {
564  return (GENERIC )(p->next);
565 }
ptr_residuation next
Definition: def_struct.h:173
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
void setUnitList ( GENERIC  x)

setUnitList(GENERIC x)

Parameters
x- GENERIC x what to set static unitListElement to (GENERIC)

not sure purpose (DJD ???)

Definition at line 468 of file bi_sys.c.

References unitListElement.

469 {
470  unitListElement = x;
471 }
static GENERIC unitListElement
Definition: bi_sys.c:459
GENERIC unitListNext ( )

set unitListElement to NULL & return NULL

not sure purpose (DJD ???)

Definition at line 490 of file bi_sys.c.

References NULL, and unitListElement.

491 {
493  return NULL;
494 }
#define NULL
Definition: def_const.h:533
static GENERIC unitListElement
Definition: bi_sys.c:459
ptr_psi_term unitListValue ( )

make psi term from unitListElement

not sure purpose (DJD ???)

Definition at line 479 of file bi_sys.c.

References makePsiTerm(), and unitListElement.

480 {
481  return makePsiTerm((void *)unitListElement);
482 }
ptr_psi_term makePsiTerm(ptr_definition x)
ptr_psi_term makePsiTerm
Definition: bi_sys.c:573
static GENERIC unitListElement
Definition: bi_sys.c:459

Variable Documentation

GENERIC unitListElement
static

Definition at line 459 of file bi_sys.c.