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

Go to the source code of this file.

Functions

static long c_children ()
 
static long c_parents ()
 
static long c_smallest ()
 
int isSubTypeValue (ptr_psi_term arg1, ptr_psi_term arg2)
 
static long isa (ptr_psi_term arg1, ptr_psi_term arg2)
 
static long isa_select (ptr_psi_term arg1, ptr_psi_term arg2, long sel)
 
static long c_isa_main (long sel)
 
static long c_isa_le ()
 
static long c_isa_lt ()
 
static long c_isa_ge ()
 
static long c_isa_gt ()
 
static long c_isa_eq ()
 
static long c_isa_nle ()
 
static long c_isa_nlt ()
 
static long c_isa_nge ()
 
static long c_isa_ngt ()
 
static long c_isa_neq ()
 
static long c_isa_cmp ()
 
static long c_isa_ncmp ()
 
static long c_is_function ()
 
static long c_is_persistent ()
 
static long c_is_predicate ()
 
static long c_is_sort ()
 
static long c_is_value ()
 
static long c_is_number ()
 
long c_isa_subsort ()
 
long isValue (ptr_psi_term p)
 
long c_glb ()
 
long c_lub ()
 
void insert_type_builtins ()
 

Function Documentation

static long c_children ( )
static

Definition at line 26 of file bi_type.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, wl_definition::children, collect_symbols(), curry(), deref, deref_args, deref_ptr, get_two_args(), greatest_sel, hidden_type(), wl_int_list::next, NULL, push_goal(), real, resid_aim, set_1, stack_cons(), stack_nil(), stack_psi_term(), top, TRUE, wl_psi_term::type, unify, wl_int_list::value_1, and wl_psi_term::value_3.

27 {
28  long success=TRUE;
29  ptr_psi_term funct,result,arg1,arg2,t,p1;
30  ptr_int_list p;
31 
32  funct=aim->aaaa_1;
33  deref_ptr(funct);
34  result=aim->bbbb_1;
35  get_two_args(funct->attr_list,&arg1,&arg2);
36 
37  if (!arg1) {
38  curry();
39  return success;
40  }
41 
42  deref(arg1);
43  deref_args(funct,set_1);
45 
46  if (arg1->type==top)
47  t=collect_symbols(greatest_sel); /* RM: Feb 3 1993 */
48  else {
49  p=arg1->type->children;
50 
51  /* Hack: check there's enough memory to build the list */
52  /* RM: Jul 22 1993 */
53  /*
54  { int count=0;
55  while(p) {
56  count++;
57  p=p->next;
58  }
59  if (heap_pointer-stack_pointer < 3*count*sizeof(psi_term)) {
60  goal_stack=aim;
61  garbage();
62  return success;
63  }
64  */
65 
66  t=stack_nil();
67  if (!(arg1->type==real && arg1->value_3)) /* PVR 15.2.94 */
68  while (p) {
69  ptr_definition ptype;
70 
71  ptype = (ptr_definition) p->value_1;
72  if (hidden_type(ptype)) { p=p->next; continue; }
73  p1 = stack_psi_term(0);
74  p1->type = ptype;
75  t=stack_cons(p1,t);
76  p = p->next;
77  }
78  }
79  push_goal(unify,result,t,NULL);
80 
81  return success;
82 }
ptr_psi_term aaaa_1
Definition: def_struct.h:224
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
Definition: login.c:37
ptr_psi_term stack_cons(ptr_psi_term head, ptr_psi_term tail)
Definition: built_ins.c:47
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
Definition: login.c:555
#define set_1
Definition: def_const.h:194
ptr_definition top
Definition: def_glob.h:106
void curry()
Definition: lefun.c:157
#define NULL
Definition: def_const.h:203
ptr_goal resid_aim
Definition: def_glob.h:220
ptr_definition real
Definition: def_glob.h:102
#define greatest_sel
Definition: def_const.h:7
#define deref_ptr(P)
Definition: def_macro.h:95
#define TRUE
Definition: def_const.h:127
#define deref(P)
Definition: def_macro.h:142
struct wl_definition * ptr_definition
Definition: def_struct.h:31
ptr_psi_term stack_psi_term(long stat)
Definition: lefun.c:15
GENERIC value_3
Definition: def_struct.h:170
ptr_psi_term stack_nil()
Definition: built_ins.c:29
ptr_goal aim
Definition: def_glob.h:49
#define unify
Definition: def_const.h:274
#define deref_args(P, S)
Definition: def_macro.h:145
ptr_psi_term collect_symbols(long sel)
Definition: built_ins.c:3446
ptr_definition type
Definition: def_struct.h:165
GENERIC value_1
Definition: def_struct.h:54
ptr_psi_term bbbb_1
Definition: def_struct.h:225
long hidden_type(ptr_definition t)
Definition: built_ins.c:3421
ptr_int_list children
Definition: def_struct.h:131
ptr_node attr_list
Definition: def_struct.h:171
ptr_int_list next
Definition: def_struct.h:55
long c_glb ( )

Definition at line 553 of file bi_type.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), decode(), deref, deref_args, deref_ptr, Errorline(), FALSE, get_two_args(), glb(), isSubTypeValue(), isValue(), makePsiTerm(), wl_int_list::next, NULL, push_choice_point(), push_goal(), resid_aim, set_1_2, TRUE, wl_psi_term::type, type_disj, unify, wl_int_list::value_1, and wl_psi_term::value_3.

554 {
555  ptr_psi_term func,arg1,arg2, result, other;
556  ptr_definition ans;
557  ptr_int_list complexType;
558  ptr_int_list decodedType = NULL;
559  long ret;
560 
561  func=aim->aaaa_1;
562  deref_ptr(func);
563  get_two_args(func->attr_list,&arg1,&arg2);
564 
565  if ((!arg1) || (!arg2)) {
566  curry();
567  return TRUE;
568  }
569  result = aim->bbbb_1;
570  deref(result);
571  deref(arg1);
572  deref(arg2);
573  deref_args(func, set_1_2);
574 
575  if ((ret=glb(arg1->type, arg2->type, &ans, &complexType)) == 0)
576  return FALSE;
577 
578  if ((ret != 4)&&(isValue(arg1)||isValue(arg2))) {
579  /* glb is one of arg1->type or arg2->type AND at least one is a value */
580  if (!isSubTypeValue(arg1, arg2) && !isSubTypeValue(arg2, arg1))
581  return FALSE;
582  }
583  if (!ans) {
584  decodedType = decode(complexType);
585  ans = (ptr_definition)decodedType->value_1;
586  decodedType = decodedType->next;
587  }
588  other=makePsiTerm(ans);
589 
590  if (isValue(arg1)) other->value_3=arg1->value_3;
591  if (isValue(arg2)) other->value_3=arg2->value_3;
592 
593  if (isValue(arg1) || isValue(arg2)) {
594  if (decodedType) {
595  Errorline("glb of multiple-inheritance value sorts not yet implemented.\n");
596  return FALSE;
597  }
598  }
599 
600  if (decodedType)
601  push_choice_point(type_disj, result,(ptr_psi_term) decodedType,(GENERIC) NULL);
602 
603  resid_aim = NULL;
604  push_goal(unify,result,other,NULL);
605  return TRUE;
606 }
ptr_psi_term makePsiTerm(ptr_definition x)
Definition: bi_sys.c:468
ptr_psi_term aaaa_1
Definition: def_struct.h:224
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
Definition: login.c:37
int isSubTypeValue(ptr_psi_term arg1, ptr_psi_term arg2)
Definition: bi_type.c:163
long glb(ptr_definition t1, ptr_definition t2, ptr_definition *t3, ptr_int_list *c3)
Definition: types.c:1388
void push_choice_point(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
Definition: login.c:591
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
Definition: login.c:555
ptr_int_list decode(ptr_int_list c)
Definition: types.c:1678
void curry()
Definition: lefun.c:157
#define NULL
Definition: def_const.h:203
ptr_goal resid_aim
Definition: def_glob.h:220
void Errorline(char *format,...)
Definition: error.c:414
#define set_1_2
Definition: def_const.h:196
#define deref_ptr(P)
Definition: def_macro.h:95
#define TRUE
Definition: def_const.h:127
#define FALSE
Definition: def_const.h:128
#define deref(P)
Definition: def_macro.h:142
struct wl_definition * ptr_definition
Definition: def_struct.h:31
GENERIC value_3
Definition: def_struct.h:170
ptr_goal aim
Definition: def_glob.h:49
#define unify
Definition: def_const.h:274
#define deref_args(P, S)
Definition: def_macro.h:145
#define type_disj
Definition: def_const.h:284
long isValue(ptr_psi_term p)
Definition: bi_type.c:541
ptr_definition type
Definition: def_struct.h:165
GENERIC value_1
Definition: def_struct.h:54
ptr_psi_term bbbb_1
Definition: def_struct.h:225
unsigned long * GENERIC
Definition: def_struct.h:17
ptr_node attr_list
Definition: def_struct.h:171
ptr_int_list next
Definition: def_struct.h:55
static long c_is_function ( )
static

Definition at line 359 of file bi_type.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(), set_1, TRUE, wl_psi_term::type, wl_definition::type_def, and unify_bool_result().

360 {
361  int success=TRUE,ans;
362  ptr_psi_term arg1,funct,result;
363 
364  funct=aim->aaaa_1;
365  deref_ptr(funct);
366  result=aim->bbbb_1;
367  get_one_arg(funct->attr_list,&arg1);
368  if (arg1) {
369  deref(arg1);
370  deref_args(funct,set_1);
371  ans=(arg1->type->type_def==(def_type)function_it);
372  unify_bool_result(result,ans);
373  }
374  else curry();
375 
376  return success;
377 }
ptr_psi_term aaaa_1
Definition: def_struct.h:224
#define function_it
Definition: def_const.h:362
struct wl_definition * def_type
Definition: def_struct.h:32
void unify_bool_result(ptr_psi_term t, long v)
Definition: built_ins.c:329
def_type type_def
Definition: def_struct.h:133
void get_one_arg(ptr_node t, ptr_psi_term *a)
Definition: login.c:86
#define set_1
Definition: def_const.h:194
void curry()
Definition: lefun.c:157
#define deref_ptr(P)
Definition: def_macro.h:95
#define TRUE
Definition: def_const.h:127
#define deref(P)
Definition: def_macro.h:142
ptr_goal aim
Definition: def_glob.h:49
#define deref_args(P, S)
Definition: def_macro.h:145
ptr_definition type
Definition: def_struct.h:165
ptr_psi_term bbbb_1
Definition: def_struct.h:225
ptr_node attr_list
Definition: def_struct.h:171
static long c_is_number ( )
static

Definition at line 490 of file bi_type.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, real, set_1, sub_type(), TRUE, wl_psi_term::type, unify_bool_result(), and wl_psi_term::value_3.

491 {
492  long success=TRUE,ans;
493  ptr_psi_term arg1,arg2,funct,result;
494 
495  funct=aim->aaaa_1;
496  deref_ptr(funct);
497  result=aim->bbbb_1;
498  get_two_args(funct->attr_list,&arg1,&arg2);
499  if (arg1) {
500  deref(arg1);
501  deref_args(funct,set_1);
502  ans=sub_type(arg1->type,real) && (arg1->value_3!=NULL);
503  unify_bool_result(result,ans);
504  }
505  else curry();
506 
507  return success;
508 }
ptr_psi_term aaaa_1
Definition: def_struct.h:224
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
Definition: login.c:37
void unify_bool_result(ptr_psi_term t, long v)
Definition: built_ins.c:329
#define set_1
Definition: def_const.h:194
void curry()
Definition: lefun.c:157
#define NULL
Definition: def_const.h:203
long sub_type(ptr_definition t1, ptr_definition t2)
Definition: types.c:1544
ptr_definition real
Definition: def_glob.h:102
#define deref_ptr(P)
Definition: def_macro.h:95
#define TRUE
Definition: def_const.h:127
#define deref(P)
Definition: def_macro.h:142
GENERIC value_3
Definition: def_struct.h:170
ptr_goal aim
Definition: def_glob.h:49
#define deref_args(P, S)
Definition: def_macro.h:145
ptr_definition type
Definition: def_struct.h:165
ptr_psi_term bbbb_1
Definition: def_struct.h:225
ptr_node attr_list
Definition: def_struct.h:171
static long c_is_persistent ( )
static

Definition at line 384 of file bi_type.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(), global, wl_definition::global_value, heap_pointer, set_1, TRUE, wl_psi_term::type, wl_definition::type_def, and unify_bool_result().

385 {
386  int success=TRUE,ans;
387  ptr_psi_term arg1,glob,result;
388 
389  glob=aim->aaaa_1;
390  deref_ptr(glob);
391  result=aim->bbbb_1;
392  get_one_arg(glob->attr_list,&arg1);
393  if (arg1) {
394  deref(arg1);
395  deref_args(glob,set_1);
396  ans=(
397  arg1->type->type_def==(def_type)global &&
399  ) ||
400  (GENERIC)arg1>=heap_pointer;
401  unify_bool_result(result,ans);
402  }
403  else curry();
404 
405  return success;
406 }
ptr_psi_term aaaa_1
Definition: def_struct.h:224
struct wl_definition * def_type
Definition: def_struct.h:32
#define global
Definition: def_const.h:364
void unify_bool_result(ptr_psi_term t, long v)
Definition: built_ins.c:329
def_type type_def
Definition: def_struct.h:133
void get_one_arg(ptr_node t, ptr_psi_term *a)
Definition: login.c:86
#define set_1
Definition: def_const.h:194
void curry()
Definition: lefun.c:157
#define deref_ptr(P)
Definition: def_macro.h:95
#define TRUE
Definition: def_const.h:127
ptr_psi_term global_value
Definition: def_struct.h:141
#define deref(P)
Definition: def_macro.h:142
ptr_goal aim
Definition: def_glob.h:49
GENERIC heap_pointer
Definition: def_glob.h:12
#define deref_args(P, S)
Definition: def_macro.h:145
ptr_definition type
Definition: def_struct.h:165
ptr_psi_term bbbb_1
Definition: def_struct.h:225
unsigned long * GENERIC
Definition: def_struct.h:17
ptr_node attr_list
Definition: def_struct.h:171
static long c_is_predicate ( )
static

Definition at line 413 of file bi_type.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(), predicate, set_1, TRUE, wl_psi_term::type, wl_definition::type_def, and unify_bool_result().

414 {
415  int success=TRUE,ans;
416  ptr_psi_term arg1,funct,result;
417 
418  funct=aim->aaaa_1;
419  deref_ptr(funct);
420  result=aim->bbbb_1;
421  get_one_arg(funct->attr_list,&arg1);
422  if (arg1) {
423  deref(arg1);
424  deref_args(funct,set_1);
425  ans=(arg1->type->type_def==(def_type)predicate);
426  unify_bool_result(result,ans);
427  }
428  else curry();
429 
430  return success;
431 }
ptr_psi_term aaaa_1
Definition: def_struct.h:224
#define predicate
Definition: def_const.h:361
struct wl_definition * def_type
Definition: def_struct.h:32
void unify_bool_result(ptr_psi_term t, long v)
Definition: built_ins.c:329
def_type type_def
Definition: def_struct.h:133
void get_one_arg(ptr_node t, ptr_psi_term *a)
Definition: login.c:86
#define set_1
Definition: def_const.h:194
void curry()
Definition: lefun.c:157
#define deref_ptr(P)
Definition: def_macro.h:95
#define TRUE
Definition: def_const.h:127
#define deref(P)
Definition: def_macro.h:142
ptr_goal aim
Definition: def_glob.h:49
#define deref_args(P, S)
Definition: def_macro.h:145
ptr_definition type
Definition: def_struct.h:165
ptr_psi_term bbbb_1
Definition: def_struct.h:225
ptr_node attr_list
Definition: def_struct.h:171
static long c_is_sort ( )
static

Definition at line 438 of file bi_type.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(), set_1, TRUE, wl_psi_term::type, wl_definition::type_def, type_it, and unify_bool_result().

439 {
440  int success=TRUE,ans;
441  ptr_psi_term arg1,funct,result;
442 
443  funct=aim->aaaa_1;
444  deref_ptr(funct);
445  result=aim->bbbb_1;
446  get_one_arg(funct->attr_list,&arg1);
447  if (arg1) {
448  deref(arg1);
449  deref_args(funct,set_1);
450  ans=(arg1->type->type_def==(def_type)type_it);
451  unify_bool_result(result,ans);
452  }
453  else curry();
454 
455  return success;
456 }
ptr_psi_term aaaa_1
Definition: def_struct.h:224
struct wl_definition * def_type
Definition: def_struct.h:32
void unify_bool_result(ptr_psi_term t, long v)
Definition: built_ins.c:329
def_type type_def
Definition: def_struct.h:133
void get_one_arg(ptr_node t, ptr_psi_term *a)
Definition: login.c:86
#define set_1
Definition: def_const.h:194
void curry()
Definition: lefun.c:157
#define type_it
Definition: def_const.h:363
#define deref_ptr(P)
Definition: def_macro.h:95
#define TRUE
Definition: def_const.h:127
#define deref(P)
Definition: def_macro.h:142
ptr_goal aim
Definition: def_glob.h:49
#define deref_args(P, S)
Definition: def_macro.h:145
ptr_definition type
Definition: def_struct.h:165
ptr_psi_term bbbb_1
Definition: def_struct.h:225
ptr_node attr_list
Definition: def_struct.h:171
static long c_is_value ( )
static

Definition at line 465 of file bi_type.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, set_1, TRUE, unify_bool_result(), and wl_psi_term::value_3.

466 {
467  long success=TRUE,ans;
468  ptr_psi_term arg1,arg2,funct,result;
469 
470  funct=aim->aaaa_1;
471  deref_ptr(funct);
472  result=aim->bbbb_1;
473  get_two_args(funct->attr_list,&arg1,&arg2);
474  if (arg1) {
475  deref(arg1);
476  deref_args(funct,set_1);
477  ans=(arg1->value_3!=NULL);
478  unify_bool_result(result,ans);
479  }
480  else curry();
481 
482  return success;
483 }
ptr_psi_term aaaa_1
Definition: def_struct.h:224
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
Definition: login.c:37
void unify_bool_result(ptr_psi_term t, long v)
Definition: built_ins.c:329
#define set_1
Definition: def_const.h:194
void curry()
Definition: lefun.c:157
#define NULL
Definition: def_const.h:203
#define deref_ptr(P)
Definition: def_macro.h:95
#define TRUE
Definition: def_const.h:127
#define deref(P)
Definition: def_macro.h:142
GENERIC value_3
Definition: def_struct.h:170
ptr_goal aim
Definition: def_glob.h:49
#define deref_args(P, S)
Definition: def_macro.h:145
ptr_psi_term bbbb_1
Definition: def_struct.h:225
ptr_node attr_list
Definition: def_struct.h:171
static long c_isa_cmp ( )
static

Definition at line 344 of file bi_type.c.

References c_isa_main(), and isa_cmp_sel.

345 {
346  return c_isa_main(isa_cmp_sel);
347 }
#define isa_cmp_sel
Definition: def_const.h:309
static long c_isa_main(long sel)
Definition: bi_type.c:264
static long c_isa_eq ( )
static

Definition at line 314 of file bi_type.c.

References c_isa_main(), and isa_eq_sel.

315 {
316  return c_isa_main(isa_eq_sel);
317 }
#define isa_eq_sel
Definition: def_const.h:303
static long c_isa_main(long sel)
Definition: bi_type.c:264
static long c_isa_ge ( )
static

Definition at line 304 of file bi_type.c.

References c_isa_main(), and isa_ge_sel.

305 {
306  return c_isa_main(isa_ge_sel);
307 }
#define isa_ge_sel
Definition: def_const.h:301
static long c_isa_main(long sel)
Definition: bi_type.c:264
static long c_isa_gt ( )
static

Definition at line 309 of file bi_type.c.

References c_isa_main(), and isa_gt_sel.

310 {
311  return c_isa_main(isa_gt_sel);
312 }
static long c_isa_main(long sel)
Definition: bi_type.c:264
#define isa_gt_sel
Definition: def_const.h:302
static long c_isa_le ( )
static

Definition at line 294 of file bi_type.c.

References c_isa_main(), and isa_le_sel.

295 {
296  return c_isa_main(isa_le_sel);
297 }
#define isa_le_sel
Definition: def_const.h:299
static long c_isa_main(long sel)
Definition: bi_type.c:264
static long c_isa_lt ( )
static

Definition at line 299 of file bi_type.c.

References c_isa_main(), and isa_lt_sel.

300 {
301  return c_isa_main(isa_lt_sel);
302 }
static long c_isa_main(long sel)
Definition: bi_type.c:264
#define isa_lt_sel
Definition: def_const.h:300
static long c_isa_main ( long  sel)
static

Definition at line 264 of file bi_type.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(), isa_select(), set_1_2, TRUE, and unify_bool_result().

266 {
267  long success=TRUE,ans;
268  ptr_psi_term arg1,arg2,funct,result;
269 
270  funct=aim->aaaa_1;
271  deref_ptr(funct);
272  result=aim->bbbb_1;
273  get_two_args(funct->attr_list,&arg1,&arg2);
274  if (arg1 && arg2) {
275  deref(arg1);
276  deref(arg2);
277  deref_args(funct,set_1_2);
278  ans=isa_select(arg1,arg2,sel);
279  unify_bool_result(result,ans);
280  }
281  else curry();
282 
283  return success;
284 }
ptr_psi_term aaaa_1
Definition: def_struct.h:224
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
Definition: login.c:37
void unify_bool_result(ptr_psi_term t, long v)
Definition: built_ins.c:329
void curry()
Definition: lefun.c:157
#define set_1_2
Definition: def_const.h:196
#define deref_ptr(P)
Definition: def_macro.h:95
#define TRUE
Definition: def_const.h:127
#define deref(P)
Definition: def_macro.h:142
ptr_goal aim
Definition: def_glob.h:49
#define deref_args(P, S)
Definition: def_macro.h:145
static long isa_select(ptr_psi_term arg1, ptr_psi_term arg2, long sel)
Definition: bi_type.c:224
ptr_psi_term bbbb_1
Definition: def_struct.h:225
ptr_node attr_list
Definition: def_struct.h:171
static long c_isa_ncmp ( )
static

Definition at line 349 of file bi_type.c.

References c_isa_main(), and isa_ncmp_sel.

350 {
351  return c_isa_main(isa_ncmp_sel);
352 }
static long c_isa_main(long sel)
Definition: bi_type.c:264
#define isa_ncmp_sel
Definition: def_const.h:310
static long c_isa_neq ( )
static

Definition at line 339 of file bi_type.c.

References c_isa_main(), and isa_neq_sel.

340 {
341  return c_isa_main(isa_neq_sel);
342 }
#define isa_neq_sel
Definition: def_const.h:308
static long c_isa_main(long sel)
Definition: bi_type.c:264
static long c_isa_nge ( )
static

Definition at line 329 of file bi_type.c.

References c_isa_main(), and isa_nge_sel.

330 {
331  return c_isa_main(isa_nge_sel);
332 }
#define isa_nge_sel
Definition: def_const.h:306
static long c_isa_main(long sel)
Definition: bi_type.c:264
static long c_isa_ngt ( )
static

Definition at line 334 of file bi_type.c.

References c_isa_main(), and isa_ngt_sel.

335 {
336  return c_isa_main(isa_ngt_sel);
337 }
#define isa_ngt_sel
Definition: def_const.h:307
static long c_isa_main(long sel)
Definition: bi_type.c:264
static long c_isa_nle ( )
static

Definition at line 319 of file bi_type.c.

References c_isa_main(), and isa_nle_sel.

320 {
321  return c_isa_main(isa_nle_sel);
322 }
#define isa_nle_sel
Definition: def_const.h:304
static long c_isa_main(long sel)
Definition: bi_type.c:264
static long c_isa_nlt ( )
static

Definition at line 324 of file bi_type.c.

References c_isa_main(), and isa_nlt_sel.

325 {
326  return c_isa_main(isa_nlt_sel);
327 }
#define isa_nlt_sel
Definition: def_const.h:305
static long c_isa_main(long sel)
Definition: bi_type.c:264
long c_isa_subsort ( )

Definition at line 515 of file bi_type.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, deref, deref_args, deref_ptr, FALSE, get_two_args(), isa(), reportAndAbort(), residuate(), set_1_2, and TRUE.

516 {
517  ptr_psi_term pred,arg1,arg2;
518 
519  pred=aim->aaaa_1;
520  deref_ptr(pred);
521  get_two_args(pred->attr_list,&arg1,&arg2);
522 
523  if (!arg1) (void)reportAndAbort(pred,"no first argument");
524  deref(arg1);
525 
526  if (!arg2) (void)reportAndAbort(pred,"no second argument");
527  deref(arg2);
528 
529  deref_args(pred, set_1_2);
530 
531  if (isa(arg1, arg2))
532  {
533  residuate(arg2);
534  return TRUE;
535  }
536  return FALSE;
537 }
ptr_psi_term aaaa_1
Definition: def_struct.h:224
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
Definition: login.c:37
static long isa(ptr_psi_term arg1, ptr_psi_term arg2)
Definition: bi_type.c:196
void residuate(ptr_psi_term t)
Definition: lefun.c:113
long reportAndAbort(ptr_psi_term g, char *s)
Definition: error.c:732
#define set_1_2
Definition: def_const.h:196
#define deref_ptr(P)
Definition: def_macro.h:95
#define TRUE
Definition: def_const.h:127
#define FALSE
Definition: def_const.h:128
#define deref(P)
Definition: def_macro.h:142
ptr_goal aim
Definition: def_glob.h:49
#define deref_args(P, S)
Definition: def_macro.h:145
ptr_node attr_list
Definition: def_struct.h:171
long c_lub ( )

Definition at line 614 of file bi_type.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(), lub(), makePsiTerm(), wl_int_list::next, NULL, push_choice_point(), push_goal(), resid_aim, set_1_2, TRUE, type_disj, unify, and wl_int_list::value_1.

615 {
616  ptr_psi_term func,arg1,arg2, result, other;
617  ptr_definition ans=NULL;
618  ptr_int_list decodedType = NULL;
619 
620  func=aim->aaaa_1;
621  deref_ptr(func);
622  get_two_args(func->attr_list,&arg1,&arg2);
623 
624  if ((!arg1) || (!arg2))
625  {
626  curry();
627  return TRUE;
628  }
629  result = aim->bbbb_1;
630  deref(result);
631  deref(arg1);
632  deref(arg2);
633  deref_args(func, set_1_2);
634 
635  /* now lets find the list of types that is the lub */
636 
637  decodedType = lub(arg1, arg2, &other);
638 
639  if (decodedType) {
640  ans = (ptr_definition)decodedType->value_1;
641  decodedType = decodedType->next;
642  other = makePsiTerm(ans);
643  }
644 
645  if (decodedType)
646  push_choice_point(type_disj, result,(ptr_psi_term) decodedType,(GENERIC) NULL);
647 
648  resid_aim = NULL;
649  push_goal(unify,result,other,NULL);
650  return TRUE;
651 }
ptr_psi_term makePsiTerm(ptr_definition x)
Definition: bi_sys.c:468
ptr_psi_term aaaa_1
Definition: def_struct.h:224
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
Definition: login.c:37
void push_choice_point(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
Definition: login.c:591
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
Definition: login.c:555
void curry()
Definition: lefun.c:157
#define NULL
Definition: def_const.h:203
ptr_goal resid_aim
Definition: def_glob.h:220
#define set_1_2
Definition: def_const.h:196
#define deref_ptr(P)
Definition: def_macro.h:95
#define TRUE
Definition: def_const.h:127
#define deref(P)
Definition: def_macro.h:142
ptr_int_list lub(ptr_psi_term a, ptr_psi_term b, ptr_psi_term *pp)
Definition: lub.c:150
struct wl_definition * ptr_definition
Definition: def_struct.h:31
ptr_goal aim
Definition: def_glob.h:49
#define unify
Definition: def_const.h:274
#define deref_args(P, S)
Definition: def_macro.h:145
#define type_disj
Definition: def_const.h:284
GENERIC value_1
Definition: def_struct.h:54
ptr_psi_term bbbb_1
Definition: def_struct.h:225
unsigned long * GENERIC
Definition: def_struct.h:17
ptr_node attr_list
Definition: def_struct.h:171
ptr_int_list next
Definition: def_struct.h:55
static long c_parents ( )
static

Definition at line 89 of file bi_type.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(), hidden_type(), integer, wl_int_list::next, NULL, wl_definition::parents, push_goal(), quoted_string, real, resid_aim, set_1, stack_cons(), stack_nil(), stack_psi_term(), top, TRUE, wl_psi_term::type, unify, wl_int_list::value_1, and wl_psi_term::value_3.

90 {
91  long success=TRUE;
92  ptr_psi_term funct,result,arg1,arg2,t,p1;
93  ptr_int_list p;
94 
95  funct=aim->aaaa_1;
96  deref_ptr(funct);
97  result=aim->bbbb_1;
98  get_two_args(funct->attr_list,&arg1,&arg2);
99  if (arg1) {
100  deref(arg1);
101  deref_args(funct,set_1);
102  resid_aim=NULL;
103  t=stack_nil(); /* RM: Dec 14 1992 */
104  p = arg1->type->parents;
105  if (arg1->type!=top && p==NULL) {
106  /* Top is the only parent */
107  p1 = stack_psi_term(4);
108  p1->type = (ptr_definition) top;
109  t=stack_cons(p1,t); /* RM: Dec 14 1992 */
110  }
111  else {
112  if ((arg1->type==quoted_string || arg1->type==integer ||
113  arg1->type==real) && arg1->value_3!=NULL) {
114  /* arg1 is a string, long or real: return a list with arg1 as
115  argument, where arg1->value_2 = NULL, MH */
116  p1 = stack_psi_term(4);
117  p1->type = arg1->type;
118  t=stack_cons(p1,t); /* RM: Dec 14 1992 */
119  }
120  else {
121  /* Look at the parents list */
122  while (p) {
123  ptr_definition ptype;
124 
125  ptype = (ptr_definition) p->value_1;
126  if (hidden_type(ptype)) { p=p->next; continue; }
127  p1 = stack_psi_term(4);
128  p1->type = ptype;
129  t=stack_cons(p1,t); /* RM: Dec 14 1992 */
130  p = p->next;
131  }
132  }
133  }
134  push_goal(unify,result,t,NULL);
135  }
136  else
137  curry();
138 
139  return success;
140 }
ptr_psi_term aaaa_1
Definition: def_struct.h:224
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
Definition: login.c:37
ptr_psi_term stack_cons(ptr_psi_term head, ptr_psi_term tail)
Definition: built_ins.c:47
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
Definition: login.c:555
#define set_1
Definition: def_const.h:194
ptr_definition top
Definition: def_glob.h:106
void curry()
Definition: lefun.c:157
#define NULL
Definition: def_const.h:203
ptr_goal resid_aim
Definition: def_glob.h:220
ptr_definition real
Definition: def_glob.h:102
#define deref_ptr(P)
Definition: def_macro.h:95
#define TRUE
Definition: def_const.h:127
ptr_definition integer
Definition: def_glob.h:93
#define deref(P)
Definition: def_macro.h:142
ptr_definition quoted_string
Definition: def_glob.h:101
struct wl_definition * ptr_definition
Definition: def_struct.h:31
ptr_psi_term stack_psi_term(long stat)
Definition: lefun.c:15
GENERIC value_3
Definition: def_struct.h:170
ptr_psi_term stack_nil()
Definition: built_ins.c:29
ptr_goal aim
Definition: def_glob.h:49
#define unify
Definition: def_const.h:274
#define deref_args(P, S)
Definition: def_macro.h:145
ptr_definition type
Definition: def_struct.h:165
GENERIC value_1
Definition: def_struct.h:54
ptr_psi_term bbbb_1
Definition: def_struct.h:225
long hidden_type(ptr_definition t)
Definition: built_ins.c:3421
ptr_node attr_list
Definition: def_struct.h:171
ptr_int_list next
Definition: def_struct.h:55
ptr_int_list parents
Definition: def_struct.h:130
static long c_smallest ( )
static

Definition at line 149 of file bi_type.c.

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

150 {
151  long success=TRUE;
152  ptr_psi_term result, g, t;
153 
154  g=aim->aaaa_1;
156  result=aim->bbbb_1;
157  t=collect_symbols(least_sel); /* RM: Feb 3 1993 */
158  push_goal(unify,result,t,NULL);
159 
160  return success;
161 }
ptr_psi_term aaaa_1
Definition: def_struct.h:224
#define least_sel
Definition: def_const.h:6
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
Definition: login.c:555
#define set_empty
Definition: def_const.h:193
#define NULL
Definition: def_const.h:203
#define TRUE
Definition: def_const.h:127
ptr_goal aim
Definition: def_glob.h:49
#define unify
Definition: def_const.h:274
#define deref_args(P, S)
Definition: def_macro.h:145
ptr_psi_term collect_symbols(long sel)
Definition: built_ins.c:3446
ptr_psi_term bbbb_1
Definition: def_struct.h:225
void insert_type_builtins ( )

Definition at line 655 of file bi_type.c.

References bi_module, c_children(), c_glb(), c_is_function(), c_is_number(), c_is_persistent(), c_is_predicate(), c_is_sort(), c_is_value(), c_isa_cmp(), c_isa_eq(), c_isa_ge(), c_isa_gt(), c_isa_le(), c_isa_lt(), c_isa_ncmp(), c_isa_neq(), c_isa_nge(), c_isa_ngt(), c_isa_nle(), c_isa_nlt(), c_isa_subsort(), c_lub(), c_parents(), c_smallest(), function_it, new_built_in(), predicate, and syntax_module.

656 {
657  /* Sort comparisons */
670 
671 
672  /* Type checks */
679 
680  /* Sort hierarchy maneuvering */
687 }
void new_built_in(ptr_module m, char *s, def_type t, long(*r)())
Definition: built_ins.c:5054
static long c_isa_cmp()
Definition: bi_type.c:344
#define predicate
Definition: def_const.h:361
#define function_it
Definition: def_const.h:362
static long c_smallest()
Definition: bi_type.c:149
long c_lub()
Definition: bi_type.c:614
static long c_is_number()
Definition: bi_type.c:490
static long c_is_predicate()
Definition: bi_type.c:413
static long c_isa_lt()
Definition: bi_type.c:299
static long c_isa_ncmp()
Definition: bi_type.c:349
long c_glb()
Definition: bi_type.c:553
static long c_children()
Definition: bi_type.c:26
static long c_isa_nle()
Definition: bi_type.c:319
static long c_isa_ge()
Definition: bi_type.c:304
long c_isa_subsort()
Definition: bi_type.c:515
static long c_isa_nlt()
Definition: bi_type.c:324
static long c_isa_ngt()
Definition: bi_type.c:334
static long c_isa_gt()
Definition: bi_type.c:309
ptr_module syntax_module
Definition: def_glob.h:159
static long c_is_value()
Definition: bi_type.c:465
static long c_isa_nge()
Definition: bi_type.c:329
static long c_parents()
Definition: bi_type.c:89
static long c_is_sort()
Definition: bi_type.c:438
static long c_is_function()
Definition: bi_type.c:359
static long c_isa_eq()
Definition: bi_type.c:314
ptr_module bi_module
Definition: def_glob.h:155
static long c_isa_le()
Definition: bi_type.c:294
static long c_is_persistent()
Definition: bi_type.c:384
static long c_isa_neq()
Definition: bi_type.c:339
static long isa ( ptr_psi_term  arg1,
ptr_psi_term  arg2 
)
static

Definition at line 196 of file bi_type.c.

References cut, integer, isSubTypeValue(), matches(), real, and TRUE.

198 {
199  long ans;
200 
201  if ( arg1->type==arg2->type
202  || ( (arg1->type==real || arg1->type==integer)
203  && (arg2->type==real || arg2->type==integer)
204  && (arg1->value_3 || arg2->value_3)
205  )
206  ) {
207 
208  if(arg1->type==cut) /* RM: Jan 21 1993 */
209  ans=TRUE;
210  else
211  ans=isSubTypeValue(arg1, arg2);
212  }
213  else {
214  (void)matches(arg1->type, arg2->type, &ans);
215  }
216 
217  /*Errorline("isa %P %P -> %d\n",arg1,arg2,ans);*/
218 
219  return ans;
220 }
int isSubTypeValue(ptr_psi_term arg1, ptr_psi_term arg2)
Definition: bi_type.c:163
long matches(ptr_definition t1, ptr_definition t2, long *smaller)
Definition: types.c:1565
ptr_definition real
Definition: def_glob.h:102
#define TRUE
Definition: def_const.h:127
ptr_definition integer
Definition: def_glob.h:93
GENERIC value_3
Definition: def_struct.h:170
ptr_definition cut
Definition: def_glob.h:83
ptr_definition type
Definition: def_struct.h:165
static long isa_select ( ptr_psi_term  arg1,
ptr_psi_term  arg2,
long  sel 
)
static

Definition at line 224 of file bi_type.c.

References isa(), isa_cmp_sel, isa_eq_sel, isa_ge_sel, isa_gt_sel, isa_le_sel, isa_lt_sel, isa_ncmp_sel, isa_neq_sel, isa_nge_sel, isa_ngt_sel, isa_nle_sel, and isa_nlt_sel.

227 {
228  long ans;
229 
230  switch (sel) {
231  case isa_le_sel: ans=isa(arg1,arg2);
232  break;
233  case isa_lt_sel: ans=isa(arg1,arg2) && !isa(arg2,arg1);
234  break;
235  case isa_ge_sel: ans=isa(arg2,arg1);
236  break;
237  case isa_gt_sel: ans=isa(arg2,arg1) && !isa(arg1,arg2);
238  break;
239  case isa_eq_sel: ans=isa(arg1,arg2) && isa(arg2,arg1);
240  break;
241 
242  case isa_nle_sel: ans= !isa(arg1,arg2);
243  break;
244  case isa_nlt_sel: ans= !(isa(arg1,arg2) && !isa(arg2,arg1));
245  break;
246  case isa_nge_sel: ans= !isa(arg2,arg1);
247  break;
248  case isa_ngt_sel: ans= !(isa(arg2,arg1) && !isa(arg1,arg2));
249  break;
250  case isa_neq_sel: ans= !(isa(arg1,arg2) && isa(arg2,arg1));
251  break;
252 
253  case isa_cmp_sel: ans=isa(arg1,arg2) || isa(arg2,arg1);
254  break;
255  case isa_ncmp_sel: ans= !(isa(arg1,arg2) || isa(arg2,arg1));
256  break;
257  }
258  return ans;
259 }
static long isa(ptr_psi_term arg1, ptr_psi_term arg2)
Definition: bi_type.c:196
#define isa_nlt_sel
Definition: def_const.h:305
#define isa_eq_sel
Definition: def_const.h:303
#define isa_le_sel
Definition: def_const.h:299
#define isa_nge_sel
Definition: def_const.h:306
#define isa_ngt_sel
Definition: def_const.h:307
#define isa_neq_sel
Definition: def_const.h:308
#define isa_cmp_sel
Definition: def_const.h:309
#define isa_nle_sel
Definition: def_const.h:304
#define isa_ge_sel
Definition: def_const.h:301
#define isa_gt_sel
Definition: def_const.h:302
#define isa_lt_sel
Definition: def_const.h:300
#define isa_ncmp_sel
Definition: def_const.h:310
int isSubTypeValue ( ptr_psi_term  arg1,
ptr_psi_term  arg2 
)

Definition at line 163 of file bi_type.c.

References FALSE, integer, quoted_string, REAL, real, and TRUE.

165 {
166  long ans=TRUE;
167 
168  /* we already know that either arg1->type == arg2->type or that at both
169  * of the two are either long or real
170  */
171 
172  if (arg2->value_3) {
173  if (arg1->value_3) {
174  if (arg1->type==real || arg1->type==integer) {
175  ans=( *(REAL *)arg1->value_3 == *(REAL *)arg2->value_3);
176  }
177  else if (arg1->type==quoted_string) {
178  ans=(strcmp((char *)arg1->value_3,(char *)arg2->value_3)==0);
179  }
180  }
181  else
182  ans=FALSE;
183  }
184  else {
185  if (arg1->value_3 && (arg1->type==real || arg1->type==integer)) {
186  if (arg2->type==integer)
187  ans=(*(REAL *)arg1->value_3 == floor(*(REAL *)arg1->value_3));
188  else
189  ans=TRUE;
190  }
191  }
192  return ans;
193 }
#define REAL
Definition: def_const.h:72
ptr_definition real
Definition: def_glob.h:102
#define TRUE
Definition: def_const.h:127
ptr_definition integer
Definition: def_glob.h:93
#define FALSE
Definition: def_const.h:128
ptr_definition quoted_string
Definition: def_glob.h:101
GENERIC value_3
Definition: def_struct.h:170
ptr_definition type
Definition: def_struct.h:165
long isValue ( ptr_psi_term  p)

Definition at line 541 of file bi_type.c.

References NULL.

543 {
544  return (p->value_3 != NULL);
545 }
#define NULL
Definition: def_const.h:203
GENERIC value_3
Definition: def_struct.h:170