Wild Life: bi_sys.c File Reference

Wild Life 2.29

- Main Page
- Data Structures
- Files

- File List
- Globals

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

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 ()
long | c_tprove ()
static long | c_step ()
static long | c_verbose ()
static long | c_warning ()
static long | c_maxint ()
long | c_quiet ()
static long | c_cputime ()
static long | c_realtime ()
static long | c_localtime ()
static long | c_statistics ()
static long | c_garbage ()
static long | c_getenv ()
static long | c_system ()
static long | c_encode ()
void | setUnitList (GENERIC x)
ptr_psi_term | unitListValue ()
GENERIC | unitListNext ()
ptr_psi_term | intListValue (ptr_int_list p)
GENERIC | intListNext (ptr_int_list p)
ptr_psi_term | quotedStackCopy (psi_term p)
ptr_psi_term | residListGoalQuote (ptr_residuation p)
GENERIC | residListNext (ptr_residuation p)
ptr_psi_term | makePsiTerm (ptr_definition x)
ptr_psi_term | makePsiList (GENERIC head, ptr_psi_term(*valueFunc)(), GENERIC(*nextFunc)())
static long | c_residList ()
ptr_goal | makeGoal (ptr_psi_term p)
static long | c_residuate ()
static long | c_mresiduate ()
void | insert_system_builtins ()

## Variables
static GENERIC | unitListElement

## Macro Definition Documentation

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

Definition at line 8 of file bi_sys.c.

## Function Documentation

static long c_cputime | ( |  | ) |
| static

Definition at line 175 of file bi_sys.c.

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

176 {
177 ptr_psi_term result, t;
178 REAL thetime,val;
179 long num,success;
180
181 t=aim->aaaa_1;
182 deref_args(t,set_empty);
183 result=aim->bbbb_1;
184 deref_ptr(result);
185 success=get_real_value(result,&val,&num);
186 if (success) {
187 (void)times(&life_end);
188 thetime=(life_end.tms_utime-life_start.tms_utime)/60.0;
189 if (num)
190 success=(val==thetime);
191 else
192 success=unify_real_result(result,thetime);
193 }
194 return success;
195 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:224
get_real_value
long get_real_value(ptr_psi_term t, REAL *v, long *n)
Definition: built_ins.c:246
wl_psi_term
Definition: def_struct.h:161
set_empty
#define set_empty
Definition: def_const.h:193
life_end
struct tms life_start life_end
Definition: def_glob.h:17
REAL
#define REAL
Definition: def_const.h:72
deref_ptr
#define deref_ptr(P)
Definition: def_macro.h:95
aim
ptr_goal aim
Definition: def_glob.h:49
deref_args
#define deref_args(P, S)
Definition: def_macro.h:145
unify_real_result
long unify_real_result(ptr_psi_term t, REAL v)
Definition: built_ins.c:371
wl_goal::bbbb_1
ptr_psi_term bbbb_1
Definition: def_struct.h:225

static long c_encode | ( |  | ) |
| static

Definition at line 395 of file bi_sys.c.

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

396 {
397 ptr_psi_term t;
398
399 t=aim->aaaa_1;
400 deref_args(t,set_empty);
401 encode_types();
402 return TRUE;
403 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:224
wl_psi_term
Definition: def_struct.h:161
set_empty
#define set_empty
Definition: def_const.h:193
TRUE
#define TRUE
Definition: def_const.h:127
aim
ptr_goal aim
Definition: def_glob.h:49
encode_types
void encode_types()
Definition: types.c:1015
deref_args
#define deref_args(P, S)
Definition: def_macro.h:145

static long c_garbage | ( |  | ) |
| static

Definition at line 299 of file bi_sys.c.

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

300 {
301 ptr_psi_term t;
302
303 t=aim->aaaa_1;
304 deref_args(t,set_empty);
305 garbage();
306 return TRUE;
307 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:224
garbage
void garbage()
Definition: memory.c:1430
wl_psi_term
Definition: def_struct.h:161
set_empty
#define set_empty
Definition: def_const.h:193
TRUE
#define TRUE
Definition: def_const.h:127
aim
ptr_goal aim
Definition: def_glob.h:49
deref_args
#define deref_args(P, S)
Definition: def_macro.h:145

static long c_getenv | ( |  | ) |
| static

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

314 {
315 long success=FALSE;
316 ptr_psi_term arg1,arg2,funct,result,t;
317 long smaller;
318 char * s;
319
320 funct = aim->aaaa_1;
321 result=aim->bbbb_1;
322 deref_ptr(funct);
323 deref_ptr(result);
324
325 get_two_args(funct->attr_list, &arg1, &arg2);
326 if(arg1) {
327 deref_ptr(arg1);
328 if(matches(arg1->type,quoted_string,&smaller) && arg1->value_3) {
329 s=getenv((char *)arg1->value_3);
330 if(s) {
331 success=TRUE;
332 t=stack_psi_term(4);
333 t->type=quoted_string;
334 t->value_3=(GENERIC)heap_copy_string(s);
335 push_goal(unify,result,t,NULL);
336 }
337 }
338 else
339 Errorline("bad argument in %P\n",funct);
340 }
341 else
342 Errorline("argument missing in %P\n",funct);
343
344 return success;
345 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:224
get_two_args
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
Definition: login.c:37
push_goal
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
Definition: login.c:555
wl_psi_term
Definition: def_struct.h:161
matches
long matches(ptr_definition t1, ptr_definition t2, long *smaller)
Definition: types.c:1565
NULL
#define NULL
Definition: def_const.h:203
Errorline
void Errorline(char *format,...)
Definition: error.c:414
heap_copy_string
char * heap_copy_string(char *s)
Definition: trees.c:147
deref_ptr
#define deref_ptr(P)
Definition: def_macro.h:95
TRUE
#define TRUE
Definition: def_const.h:127
FALSE
#define FALSE
Definition: def_const.h:128
quoted_string
ptr_definition quoted_string
Definition: def_glob.h:101
stack_psi_term
ptr_psi_term stack_psi_term(long stat)
Definition: lefun.c:15
wl_psi_term::value_3
GENERIC value_3
Definition: def_struct.h:170
aim
ptr_goal aim
Definition: def_glob.h:49
unify
#define unify
Definition: def_const.h:274
wl_psi_term::type
ptr_definition type
Definition: def_struct.h:165
wl_goal::bbbb_1
ptr_psi_term bbbb_1
Definition: def_struct.h:225
GENERIC
unsigned long * GENERIC
Definition: def_struct.h:17
wl_psi_term::attr_list
ptr_node attr_list
Definition: def_struct.h:171

static long c_localtime | ( |  | ) |
| static

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

232 {
233 ptr_psi_term result, t, psitime;
234 long success=TRUE;
235 struct timeval tp;
236 struct timezone tzp;
237 struct tm *thetime;
238
239 t=aim->aaaa_1;
240 deref_args(t,set_empty);
241 result=aim->bbbb_1;
242 deref_ptr(result);
243
244 gettimeofday(&tp, &tzp);
245 thetime=localtime((time_t *) &(tp.tv_sec));
246
247 psitime=stack_psi_term(4);
248 psitime->type=timesym;
249 stack_add_int_attr(psitime, year_attr, thetime->tm_year+1900);
250 stack_add_int_attr(psitime, month_attr, thetime->tm_mon+1);
251 stack_add_int_attr(psitime, day_attr, thetime->tm_mday);
252 stack_add_int_attr(psitime, hour_attr, thetime->tm_hour);
253 stack_add_int_attr(psitime, minute_attr, thetime->tm_min);
254 stack_add_int_attr(psitime, second_attr, thetime->tm_sec);
255 stack_add_int_attr(psitime, weekday_attr, thetime->tm_wday);
256
257 push_goal(unify,result,psitime,NULL);
258
259 return success;
260 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:224
timesym
ptr_definition timesym
Definition: def_glob.h:108
push_goal
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
Definition: login.c:555
wl_psi_term
Definition: def_struct.h:161
set_empty
#define set_empty
Definition: def_const.h:193
NULL
#define NULL
Definition: def_const.h:203
stack_add_int_attr
void stack_add_int_attr(ptr_psi_term t, char *attrname, long value)
Definition: token.c:73
deref_ptr
#define deref_ptr(P)
Definition: def_macro.h:95
TRUE
#define TRUE
Definition: def_const.h:127
stack_psi_term
ptr_psi_term stack_psi_term(long stat)
Definition: lefun.c:15
aim
ptr_goal aim
Definition: def_glob.h:49
weekday_attr
char * weekday_attr
Definition: def_glob.h:259
unify
#define unify
Definition: def_const.h:274
deref_args
#define deref_args(P, S)
Definition: def_macro.h:145
minute_attr
char * minute_attr
Definition: def_glob.h:257
year_attr
char * year_attr
Definition: def_glob.h:253
second_attr
char * second_attr
Definition: def_glob.h:258
day_attr
char * day_attr
Definition: def_glob.h:255
wl_psi_term::type
ptr_definition type
Definition: def_struct.h:165
hour_attr
char * hour_attr
Definition: def_glob.h:256
wl_goal::bbbb_1
ptr_psi_term bbbb_1
Definition: def_struct.h:225
month_attr
char * month_attr
Definition: def_glob.h:254

static long c_maxint | ( |  | ) |
| static

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

130 {
131 ptr_psi_term t,result;
132 REAL val;
133 long num,success;
134
135 t=aim->aaaa_1;
136 deref_args(t,set_empty);
137 result=aim->bbbb_1;
138 deref_ptr(result);
139 success=get_real_value(result,&val,&num);
140 if (success) {
141 if (num)
142 success=(val==(REAL)WL_MAXINT);
143 else
144 success=unify_real_result(result,(REAL)WL_MAXINT);
145 }
146 return success;
147 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:224
get_real_value
long get_real_value(ptr_psi_term t, REAL *v, long *n)
Definition: built_ins.c:246
wl_psi_term
Definition: def_struct.h:161
set_empty
#define set_empty
Definition: def_const.h:193
REAL
#define REAL
Definition: def_const.h:72
deref_ptr
#define deref_ptr(P)
Definition: def_macro.h:95
aim
ptr_goal aim
Definition: def_glob.h:49
deref_args
#define deref_args(P, S)
Definition: def_macro.h:145
WL_MAXINT
#define WL_MAXINT
Definition: def_const.h:76
unify_real_result
long unify_real_result(ptr_psi_term t, REAL v)
Definition: built_ins.c:371
wl_goal::bbbb_1
ptr_psi_term bbbb_1
Definition: def_struct.h:225

static long c_mresiduate | ( |  | ) |
| static

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

583 {
584 long success=TRUE;
585 ptr_psi_term pred;
586 ptr_psi_term arg1, arg2, tmp, var;
587 ptr_goal g;
588
589 pred = aim->aaaa_1;
590 deref_ptr(pred);
591
592 get_two_args(pred->attr_list, &arg1, &arg2);
593 if ((!arg1)||(!arg2)) {
594 Errorline("%P requires two arguments.\n",pred);
595 return FALSE;
596 }
597
598 deref_ptr(arg1);
599 deref_ptr(arg2);
600 deref_args(pred, set_1_2);
601
602 g = makeGoal(arg2);
603
604 /* Then residuate on all the list variables: */
605 tmp=arg1;
606 while(tmp && tmp->type==alist) { /* RM: Dec 14 1992 */
607 get_two_args(tmp->attr_list,&var,&tmp);
608 if(var) {
609 deref_ptr(var);
610 (void)residuateGoalOnVar(g,var,NULL);
611 }
612 if(tmp)
613 deref_ptr(tmp);
614 }
615
616 if(!tmp || tmp->type!=nil) {
617 Errorline("%P should be a nil-terminated list in mresiduate.\n",arg1);
618 success=FALSE;
619 }
620
621 return success;
622 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:224
get_two_args
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
Definition: login.c:37
wl_goal
Definition: def_struct.h:222
wl_psi_term
Definition: def_struct.h:161
residuateGoalOnVar
long residuateGoalOnVar(ptr_goal g, ptr_psi_term var, ptr_psi_term othervar)
Definition: lefun.c:172
NULL
#define NULL
Definition: def_const.h:203
Errorline
void Errorline(char *format,...)
Definition: error.c:414
set_1_2
#define set_1_2
Definition: def_const.h:196
deref_ptr
#define deref_ptr(P)
Definition: def_macro.h:95
alist
ptr_definition alist
Definition: def_glob.h:94
TRUE
#define TRUE
Definition: def_const.h:127
FALSE
#define FALSE
Definition: def_const.h:128
aim
ptr_goal aim
Definition: def_glob.h:49
makeGoal
ptr_goal makeGoal(ptr_psi_term p)
Definition: bi_sys.c:533
deref_args
#define deref_args(P, S)
Definition: def_macro.h:145
nil
ptr_definition nil
Definition: def_glob.h:97
wl_psi_term::type
ptr_definition type
Definition: def_struct.h:165
wl_psi_term::attr_list
ptr_node attr_list
Definition: def_struct.h:171

long c_quiet | ( |  | ) |

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

156 {
157 ptr_psi_term t,result,ans;
158 long success=TRUE;
159
160 t=aim->aaaa_1;
161 deref_args(t,set_empty);
162 result=aim->bbbb_1;
163 deref_ptr(result);
164 ans=stack_psi_term(4);
165 ans->type = NOTQUIET ? lf_false : lf_true;
166 push_goal(unify,result,ans,NULL);
167 return success;
168 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:224
NOTQUIET
#define NOTQUIET
Definition: def_macro.h:10
push_goal
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
Definition: login.c:555
wl_psi_term
Definition: def_struct.h:161
set_empty
#define set_empty
Definition: def_const.h:193
NULL
#define NULL
Definition: def_const.h:203
deref_ptr
#define deref_ptr(P)
Definition: def_macro.h:95
TRUE
#define TRUE
Definition: def_const.h:127
lf_true
ptr_definition lf_true
Definition: def_glob.h:107
stack_psi_term
ptr_psi_term stack_psi_term(long stat)
Definition: lefun.c:15
lf_false
ptr_definition lf_false
Definition: def_glob.h:89
aim
ptr_goal aim
Definition: def_glob.h:49
unify
#define unify
Definition: def_const.h:274
deref_args
#define deref_args(P, S)
Definition: def_macro.h:145
wl_psi_term::type
ptr_definition type
Definition: def_struct.h:165
wl_goal::bbbb_1
ptr_psi_term bbbb_1
Definition: def_struct.h:225

static long c_realtime | ( |  | ) |
| static

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

202 {
203 ptr_psi_term result, t;
204 REAL thetime,val;
205 long num,success;
206 struct timeval tp;
207 struct timezone tzp;
208
209 t=aim->aaaa_1;
210 deref_args(t,set_empty);
211 result=aim->bbbb_1;
212 deref_ptr(result);
213 success=get_real_value(result,&val,&num);
214 if (success) {
215 gettimeofday(&tp, &tzp);
216 thetime=(REAL)tp.tv_sec + ((REAL)tp.tv_usec/1000000.0);
217 /* thetime=times(&life_end)/60.0; */
218 if (num)
219 success=(val==thetime);
220 else
221 success=unify_real_result(result,thetime);
222 }
223 return success;
224 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:224
get_real_value
long get_real_value(ptr_psi_term t, REAL *v, long *n)
Definition: built_ins.c:246
wl_psi_term
Definition: def_struct.h:161
set_empty
#define set_empty
Definition: def_const.h:193
REAL
#define REAL
Definition: def_const.h:72
deref_ptr
#define deref_ptr(P)
Definition: def_macro.h:95
aim
ptr_goal aim
Definition: def_glob.h:49
deref_args
#define deref_args(P, S)
Definition: def_macro.h:145
unify_real_result
long unify_real_result(ptr_psi_term t, REAL v)
Definition: built_ins.c:371
wl_goal::bbbb_1
ptr_psi_term bbbb_1
Definition: def_struct.h:225

static long c_residList | ( |  | ) |
| static

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

505 {
506 ptr_psi_term func;
507 ptr_psi_term result,arg1, other;
508
509 func = aim->aaaa_1;
510 deref_ptr(func);
511
512 get_one_arg(func->attr_list, &arg1);
513 if (!arg1)
514 {
515 curry();
516 return TRUE;
517 }
518
519 result = aim->bbbb_1;
520 deref(result);
521 deref_ptr(arg1);
522 deref_args(func, set_1);
523
524 other = makePsiList((void *)arg1->resid,
525 residListGoalQuote,
526 residListNext);
527 resid_aim = NULL;
528 push_goal(unify,result,other,NULL);
529 return TRUE;
530 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:224
wl_psi_term::resid
ptr_residuation resid
Definition: def_struct.h:173
push_goal
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
Definition: login.c:555
wl_psi_term
Definition: def_struct.h:161
get_one_arg
void get_one_arg(ptr_node t, ptr_psi_term *a)
Definition: login.c:86
set_1
#define set_1
Definition: def_const.h:194
curry
void curry()
Definition: lefun.c:157
NULL
#define NULL
Definition: def_const.h:203
resid_aim
ptr_goal resid_aim
Definition: def_glob.h:220
deref_ptr
#define deref_ptr(P)
Definition: def_macro.h:95
TRUE
#define TRUE
Definition: def_const.h:127
deref
#define deref(P)
Definition: def_macro.h:142
aim
ptr_goal aim
Definition: def_glob.h:49
unify
#define unify
Definition: def_const.h:274
residListNext
GENERIC residListNext(ptr_residuation p)
Definition: bi_sys.c:462
deref_args
#define deref_args(P, S)
Definition: def_macro.h:145
makePsiList
ptr_psi_term makePsiList(GENERIC head, ptr_psi_term(*valueFunc)(), GENERIC(*nextFunc)())
Definition: bi_sys.c:480
wl_goal::bbbb_1
ptr_psi_term bbbb_1
Definition: def_struct.h:225
residListGoalQuote
ptr_psi_term residListGoalQuote(ptr_residuation p)
Definition: bi_sys.c:451
wl_psi_term::attr_list
ptr_node attr_list
Definition: def_struct.h:171

static long c_residuate | ( |  | ) |
| static

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

551 {
552 ptr_psi_term pred;
553 ptr_psi_term arg1, arg2;
554 ptr_goal g;
555
556 pred = aim->aaaa_1;
557 deref_ptr(pred);
558
559 get_two_args(pred->attr_list, &arg1, &arg2);
560 if ((!arg1)||(!arg2)) {
561 Errorline("%P requires two arguments.\n",pred);
562 return FALSE;
563 }
564
565 deref_ptr(arg1);
566 deref_ptr(arg2);
567 deref_args(pred, set_1_2);
568
569 g = makeGoal(arg2);
570 (void)residuateGoalOnVar(g, arg1, NULL);
571
572 return TRUE;
573 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:224
get_two_args
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
Definition: login.c:37
wl_goal
Definition: def_struct.h:222
wl_psi_term
Definition: def_struct.h:161
residuateGoalOnVar
long residuateGoalOnVar(ptr_goal g, ptr_psi_term var, ptr_psi_term othervar)
Definition: lefun.c:172
NULL
#define NULL
Definition: def_const.h:203
Errorline
void Errorline(char *format,...)
Definition: error.c:414
set_1_2
#define set_1_2
Definition: def_const.h:196
deref_ptr
#define deref_ptr(P)
Definition: def_macro.h:95
TRUE
#define TRUE
Definition: def_const.h:127
FALSE
#define FALSE
Definition: def_const.h:128
aim
ptr_goal aim
Definition: def_glob.h:49
makeGoal
ptr_goal makeGoal(ptr_psi_term p)
Definition: bi_sys.c:533
deref_args
#define deref_args(P, S)
Definition: def_macro.h:145
wl_psi_term::attr_list
ptr_node attr_list
Definition: def_struct.h:171

static long c_statistics | ( |  | ) |
| static

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

266 {
267 ptr_psi_term t;
268 long success=TRUE;
269 long t1,t2,t3;
270
271 t=aim->aaaa_1;
272 deref_args(t,set_empty);
273
274 t1 = sizeof(mem_base)*(stack_pointer-mem_base);
275 t2 = sizeof(mem_base)*(mem_limit-heap_pointer);
276 t3 = sizeof(mem_base)*(mem_limit-mem_base);
277
278 printf("\n");
279 /* printf("************** SYSTEM< INFORMATION **************\n"); */
280 printf("Stack size : %8ld bytes (%5ldK) (%ld%%)\n",t1,t1/1024,100*t1/t3);
281 printf("Heap size : %8ld bytes (%5ldK) (%ld%%)\n",t2,t2/1024,100*t2/t3);
282 printf("Total memory: %8ld bytes (%5ldK)\n",t3,t3/1024);
283
284 #ifdef X11
285 printf("X predicates are installed.\n");
286 #else
287 printf("X predicates are not installed.\n");
288 #endif
289
290 /* printf("\n"); */
291 /* printf("************************************************\n"); */
292 return success;
293 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:224
mem_limit
GENERIC mem_limit
Definition: def_glob.h:13
wl_psi_term
Definition: def_struct.h:161
set_empty
#define set_empty
Definition: def_const.h:193
TRUE
#define TRUE
Definition: def_const.h:127
mem_base
GENERIC mem_base
Definition: def_glob.h:11
aim
ptr_goal aim
Definition: def_glob.h:49
heap_pointer
GENERIC heap_pointer
Definition: def_glob.h:12
deref_args
#define deref_args(P, S)
Definition: def_macro.h:145
stack_pointer
GENERIC stack_pointer
Definition: def_glob.h:14

static long c_step | ( |  | ) |
| static

Definition at line 79 of file bi_sys.c.

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

80 {
81 ptr_psi_term t;
82
83 t=aim->aaaa_1;
84 deref_args(t,set_empty);
85 toggle_step();
86 return TRUE;
87 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:224
wl_psi_term
Definition: def_struct.h:161
set_empty
#define set_empty
Definition: def_const.h:193
toggle_step
void toggle_step()
Definition: error.c:650
TRUE
#define TRUE
Definition: def_const.h:127
aim
ptr_goal aim
Definition: def_glob.h:49
deref_args
#define deref_args(P, S)
Definition: def_macro.h:145

static long c_system | ( |  | ) |
| static

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

350 {
351 long success=TRUE;
352 ptr_psi_term arg1,arg2,funct,result;
353 REAL value;
354 long smaller;
355
356 funct=aim->aaaa_1;
357 deref_ptr(funct);
358 result=aim->bbbb_1;
359 get_two_args(funct->attr_list,&arg1,&arg2);
360 if(arg1) {
361 deref(arg1);
362 deref_args(funct,set_1);
363 if((success=matches(arg1->type,quoted_string,&smaller)))
364 if(arg1->value_3) {
365 value=(REAL)system((char *)arg1->value_3);
366 if(value==127) {
367 success=FALSE;
368 Errorline("could not execute shell in %P.\n",funct);
369 /* report_error(funct,"couldn't execute shell"); */
370 }
371 else
372 success=unify_real_result(result,value);
373 }
374 else {
375 /* residuate(arg1); */ /* RM: Feb 10 1993 */
376 success=FALSE;
377 Errorline("bad argument in %P.\n",funct);
378 }
379 else {
380 success=FALSE;
381 Errorline("bad argument in %P.\n",funct);
382 /* report_error(funct,"bad argument"); */
383 }
384 }
385 else
386 curry();
387
388 return success;
389 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:224
get_two_args
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
Definition: login.c:37
wl_psi_term
Definition: def_struct.h:161
matches
long matches(ptr_definition t1, ptr_definition t2, long *smaller)
Definition: types.c:1565
set_1
#define set_1
Definition: def_const.h:194
curry
void curry()
Definition: lefun.c:157
REAL
#define REAL
Definition: def_const.h:72
Errorline
void Errorline(char *format,...)
Definition: error.c:414
deref_ptr
#define deref_ptr(P)
Definition: def_macro.h:95
TRUE
#define TRUE
Definition: def_const.h:127
FALSE
#define FALSE
Definition: def_const.h:128
deref
#define deref(P)
Definition: def_macro.h:142
quoted_string
ptr_definition quoted_string
Definition: def_glob.h:101
wl_psi_term::value_3
GENERIC value_3
Definition: def_struct.h:170
aim
ptr_goal aim
Definition: def_glob.h:49
deref_args
#define deref_args(P, S)
Definition: def_macro.h:145
unify_real_result
long unify_real_result(ptr_psi_term t, REAL v)
Definition: built_ins.c:371
wl_psi_term::type
ptr_definition type
Definition: def_struct.h:165
wl_goal::bbbb_1
ptr_psi_term bbbb_1
Definition: def_struct.h:225
wl_psi_term::attr_list
ptr_node attr_list
Definition: def_struct.h:171

long c_tprove | ( |  | ) |

Definition at line 65 of file bi_sys.c.

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

66 {
67 ptr_psi_term t;
68
69 t=aim->aaaa_1;
70 deref_args(t,set_empty);
71 set_trace_to_prove();
72 return TRUE;
73 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:224
wl_psi_term
Definition: def_struct.h:161
set_empty
#define set_empty
Definition: def_const.h:193
set_trace_to_prove
void set_trace_to_prove()
Definition: error.c:639
TRUE
#define TRUE
Definition: def_const.h:127
aim
ptr_goal aim
Definition: def_glob.h:49
deref_args
#define deref_args(P, S)
Definition: def_macro.h:145

long c_trace | ( |  | ) |

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

21 {
22 long success=TRUE;
23 ptr_psi_term t,arg1,arg2;
24
25 t=aim->aaaa_1;
26 deref_args(t,set_empty);
27 get_two_args(t->attr_list,&arg1,&arg2);
28 if (arg1) {
29 deref_ptr(arg1);
30 if (is_top(arg1)) {
31 unify_bool_result(arg1,trace);
32 trace=FALSE;
33 }
34 else if (arg1->type==lf_true)
35 trace=TRUE;
36 else if (arg1->type==lf_false)
37 trace=FALSE;
38 else {
39 Errorline("bad first argument in %P.\n",t);
40 /* report_error(t,"bad first argument"); */
41 success=FALSE;
42 }
43 }
44 if (arg2) {
45 deref_ptr(arg2);
46 if (is_top(arg2)) {
47 unify_bool_result(arg2,stepflag);
48 stepflag=FALSE;
49 }
50 else if (arg2->type==lf_true)
51 stepflag=TRUE;
52 else if (arg2->type==lf_false)
53 stepflag=FALSE;
54 else {
55 Errorline("bad second argument in %P.\n",t);
56 /* report_error(t,"bad second argument"); */
57 success=FALSE;
58 }
59 }
60 if (!arg1 && !arg2)
61 toggle_trace();
62 return success;
63 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:224
get_two_args
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
Definition: login.c:37
is_top
#define is_top(T)
Definition: def_macro.h:108
unify_bool_result
void unify_bool_result(ptr_psi_term t, long v)
Definition: built_ins.c:329
wl_psi_term
Definition: def_struct.h:161
set_empty
#define set_empty
Definition: def_const.h:193
trace
long trace
Definition: def_glob.h:272
Errorline
void Errorline(char *format,...)
Definition: error.c:414
deref_ptr
#define deref_ptr(P)
Definition: def_macro.h:95
TRUE
#define TRUE
Definition: def_const.h:127
lf_true
ptr_definition lf_true
Definition: def_glob.h:107
FALSE
#define FALSE
Definition: def_const.h:128
toggle_trace
void toggle_trace()
Definition: error.c:644
lf_false
ptr_definition lf_false
Definition: def_glob.h:89
stepflag
long stepflag
Definition: def_glob.h:150
aim
ptr_goal aim
Definition: def_glob.h:49
deref_args
#define deref_args(P, S)
Definition: def_macro.h:145
wl_psi_term::type
ptr_definition type
Definition: def_struct.h:165
wl_psi_term::attr_list
ptr_node attr_list
Definition: def_struct.h:171

static long c_verbose | ( |  | ) |
| static

Definition at line 93 of file bi_sys.c.

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

94 {
95 ptr_psi_term t;
96
97 t=aim->aaaa_1;
98 deref_args(t,set_empty);
99 verbose = !verbose;
100 printf("*** Verbose mode is turned ");
101 printf(verbose?"on.\n":"off.\n");
102 return TRUE;
103 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:224
verbose
long verbose
Definition: def_glob.h:273
wl_psi_term
Definition: def_struct.h:161
set_empty
#define set_empty
Definition: def_const.h:193
TRUE
#define TRUE
Definition: def_const.h:127
aim
ptr_goal aim
Definition: def_glob.h:49
deref_args
#define deref_args(P, S)
Definition: def_macro.h:145

static long c_warning | ( |  | ) |
| static

Definition at line 111 of file bi_sys.c.

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

112 {
113 ptr_psi_term t;
114
115 t=aim->aaaa_1;
116 deref_args(t,set_empty);
117 warningflag = !warningflag;
118
119 /* RM: Sep 24 1993 */
120 infoline("*** Warning messages are%s printed\n",warningflag?"":" not");
121
122 return TRUE;
123 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:224
wl_psi_term
Definition: def_struct.h:161
set_empty
#define set_empty
Definition: def_const.h:193
warningflag
long warningflag
Definition: def_glob.h:270
infoline
void infoline(char *format,...)
Definition: error.c:245
TRUE
#define TRUE
Definition: def_const.h:127
aim
ptr_goal aim
Definition: def_glob.h:49
deref_args
#define deref_args(P, S)
Definition: def_macro.h:145

void insert_system_builtins | ( |  | ) |

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

627 {
628 new_built_in(bi_module,"trace",(def_type)predicate,c_trace);
629 new_built_in(bi_module,"step",(def_type)predicate,c_step);
630 new_built_in(bi_module,"verbose",(def_type)predicate,c_verbose);
631 new_built_in(bi_module,"warning",(def_type)predicate,c_warning);
632 new_built_in(bi_module,"maxint",(def_type)function_it,c_maxint);
633 new_built_in(bi_module,"cpu_time",(def_type)function_it,c_cputime);
634 new_built_in(bi_module,"quiet",(def_type)function_it,c_quiet); /* 21.1 */
635 new_built_in(bi_module,"real_time",(def_type)function_it,c_realtime);
636 new_built_in(bi_module,"local_time",(def_type)function_it,c_localtime);
637 new_built_in(bi_module,"statistics",(def_type)predicate,c_statistics);
638 new_built_in(bi_module,"gc",(def_type)predicate,c_garbage);
639 new_built_in(bi_module,"system",(def_type)function_it,c_system);
640 new_built_in(bi_module,"getenv",(def_type)function_it,c_getenv);
641 new_built_in(bi_module,"encode",(def_type)predicate,c_encode);
642 new_built_in(bi_module,"rlist",(def_type)function_it,c_residList);
643 new_built_in(bi_module,"residuate",(def_type)predicate,c_residuate);
644 new_built_in(bi_module,"mresiduate",(def_type)predicate,c_mresiduate);
645 new_built_in(bi_module,"tprove",(def_type)predicate,c_tprove);
646 }
new_built_in
void new_built_in(ptr_module m, char *s, def_type t, long(*r)())
Definition: built_ins.c:5054
c_mresiduate
static long c_mresiduate()
Definition: bi_sys.c:581
c_garbage
static long c_garbage()
Definition: bi_sys.c:299
predicate
#define predicate
Definition: def_const.h:361
function_it
#define function_it
Definition: def_const.h:362
c_step
static long c_step()
Definition: bi_sys.c:79
c_realtime
static long c_realtime()
Definition: bi_sys.c:201
c_verbose
static long c_verbose()
Definition: bi_sys.c:93
c_residuate
static long c_residuate()
Definition: bi_sys.c:550
c_getenv
static long c_getenv()
Definition: bi_sys.c:313
c_trace
long c_trace()
Definition: bi_sys.c:20
c_warning
static long c_warning()
Definition: bi_sys.c:111
wl_definition
Definition: def_struct.h:121
c_system
static long c_system()
Definition: bi_sys.c:349
c_cputime
static long c_cputime()
Definition: bi_sys.c:175
c_residList
static long c_residList()
Definition: bi_sys.c:504
c_encode
static long c_encode()
Definition: bi_sys.c:395
c_localtime
static long c_localtime()
Definition: bi_sys.c:231
bi_module
ptr_module bi_module
Definition: def_glob.h:155
c_maxint
static long c_maxint()
Definition: bi_sys.c:129
c_statistics
static long c_statistics()
Definition: bi_sys.c:265
c_tprove
long c_tprove()
Definition: bi_sys.c:65
c_quiet
long c_quiet()
Definition: bi_sys.c:155

GENERIC intListNext | ( | ptr_int_list | p | ) |

Definition at line 430 of file bi_sys.c.

432 {
433 return (GENERIC )(p->next);
434 }
GENERIC
unsigned long * GENERIC
Definition: def_struct.h:17
wl_int_list::next
ptr_int_list next
Definition: def_struct.h:55

ptr_psi_term intListValue | ( | ptr_int_list | p | ) |

Definition at line 424 of file bi_sys.c.

References makePsiTerm().

426 {
427 return makePsiTerm((void *)p->value_1);
428 }
makePsiTerm
ptr_psi_term makePsiTerm(ptr_definition x)
Definition: bi_sys.c:468
wl_int_list::value_1
GENERIC value_1
Definition: def_struct.h:54

ptr_goal makeGoal | ( | ptr_psi_term | p | ) |

Definition at line 533 of file bi_sys.c.

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

535 {
536 ptr_goal old = goal_stack;
537 ptr_goal g;
538
539 push_goal(prove, p,(ptr_psi_term) DEFRULES,(GENERIC) NULL);
540 g = goal_stack;
541 g->next=NULL;
542 goal_stack = old;
543 return g;
544 }
prove
#define prove
Definition: def_const.h:273
goal_stack
ptr_goal goal_stack
Definition: def_glob.h:50
push_goal
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
Definition: login.c:555
wl_goal
Definition: def_struct.h:222
wl_psi_term
Definition: def_struct.h:161
DEFRULES
#define DEFRULES
Definition: def_const.h:138
NULL
#define NULL
Definition: def_const.h:203
GENERIC
unsigned long * GENERIC
Definition: def_struct.h:17
wl_goal::next
ptr_goal next
Definition: def_struct.h:227

ptr_psi_term makePsiList | ( | GENERIC | head,
|  | ptr_psi_term (*)() | valueFunc,
|  | GENERIC (*)() | nextFunc
| ) |  |

Definition at line 480 of file bi_sys.c.

References stack_cons(), and stack_nil().

485 {
486 ptr_psi_term result;
487
488
489 /* RM: Dec 14 1992: Added the new list representation */
490 result=stack_nil();
491
492 while (head) {
493 result=stack_cons((*valueFunc)(head),result);
494 head=(*nextFunc)(head);
495 }
496 return result;
497 }
stack_cons
ptr_psi_term stack_cons(ptr_psi_term head, ptr_psi_term tail)
Definition: built_ins.c:47
wl_psi_term
Definition: def_struct.h:161
stack_nil
ptr_psi_term stack_nil()
Definition: built_ins.c:29

ptr_psi_term makePsiTerm | ( | ptr_definition | x | ) |

Definition at line 468 of file bi_sys.c.

References stack_psi_term(), and wl_psi_term::type.

470 {
471 ptr_psi_term p;
472
473 p = stack_psi_term(4);
474 p->type = x;
475 return p;
476 }
wl_psi_term
Definition: def_struct.h:161
stack_psi_term
ptr_psi_term stack_psi_term(long stat)
Definition: lefun.c:15
wl_psi_term::type
ptr_definition type
Definition: def_struct.h:165

ptr_psi_term quotedStackCopy | ( | psi_term | p | ) |

Definition at line 436 of file bi_sys.c.

References mark_quote(), and stack_copy_psi_term().

438 {
439 ptr_psi_term q;
440
441 q = (ptr_psi_term) stack_copy_psi_term(p);
442 mark_quote(q);
443 return q;
444 }
wl_psi_term
Definition: def_struct.h:161
mark_quote
void mark_quote(ptr_psi_term t)
Definition: copy.c:601
stack_copy_psi_term
ptr_psi_term stack_copy_psi_term(psi_term t)
Definition: parser.c:183
ptr_psi_term
struct wl_psi_term * ptr_psi_term
Definition: def_struct.h:34

ptr_psi_term residListGoalQuote | ( | ptr_residuation | p | ) |

Definition at line 451 of file bi_sys.c.

References copyPsiTerm, stack_psi_term(), and wl_psi_term::status.

453 {
454 ptr_psi_term psi;
455
456 psi = stack_psi_term(4);
457 copyPsiTerm(psi, p->goal->aaaa_1);
458 psi->status = 4;
459 return psi;
460 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:224
wl_residuation::goal
ptr_goal goal
Definition: def_struct.h:156
copyPsiTerm
#define copyPsiTerm(a, b)
Definition: bi_sys.c:8
wl_psi_term
Definition: def_struct.h:161
stack_psi_term
ptr_psi_term stack_psi_term(long stat)
Definition: lefun.c:15
wl_psi_term::status
long status
Definition: def_struct.h:166

GENERIC residListNext | ( | ptr_residuation | p | ) |

Definition at line 462 of file bi_sys.c.

464 {
465 return (GENERIC )(p->next);
466 }
wl_residuation::next
ptr_residuation next
Definition: def_struct.h:157
GENERIC
unsigned long * GENERIC
Definition: def_struct.h:17

void setUnitList | ( | GENERIC | x | ) |

Definition at line 407 of file bi_sys.c.

References unitListElement.

409 {
410 unitListElement = x;
411 }
unitListElement
static GENERIC unitListElement
Definition: bi_sys.c:405

GENERIC unitListNext | ( |  | ) |

Definition at line 418 of file bi_sys.c.

References NULL, and unitListElement.

419 {
420 unitListElement = NULL;
421 return NULL;
422 }
NULL
#define NULL
Definition: def_const.h:203
unitListElement
static GENERIC unitListElement
Definition: bi_sys.c:405

ptr_psi_term unitListValue | ( |  | ) |

Definition at line 413 of file bi_sys.c.

References makePsiTerm(), and unitListElement.

414 {
415 return makePsiTerm((void *)unitListElement);
416 }
makePsiTerm
ptr_psi_term makePsiTerm(ptr_definition x)
Definition: bi_sys.c:468
unitListElement
static GENERIC unitListElement
Definition: bi_sys.c:405

## Variable Documentation

GENERIC unitListElement
| static

Definition at line 405 of file bi_sys.c.