Wild Life: bi_type.c File Reference

Wild Life 2.30

- Main Page
- Data Structures
- Files

- File List
- Globals

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

Builtins for doing type heierachy stuff. More...

Go to the source code of this file.

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

## Detailed Description

Builtins for doing type heierachy stuff.

Definition in file bi_type.c.

## Function Documentation

static long c_children | ( |  | ) |
| static

c_children

Return a list of roots of the children types of T (except bottom).

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

31 {
32 long success=TRUE;
33 ptr_psi_term funct,result,arg1,arg2,t,p1;
34 ptr_int_list p;
35
36 funct=aim->aaaa_1;
37 deref_ptr(funct);
38 result=aim->bbbb_1;
39 get_two_args(funct->attr_list,&arg1,&arg2);
40
41 if (!arg1) {
42 curry();
43 return success;
44 }
45
46 deref(arg1);
47 deref_args(funct,set_1);
48 resid_aim=NULL;
49
50 if (arg1->type==top)
51 t=collect_symbols(greatest_sel); /* RM: Feb 3 1993 */
52 else {
53 p=arg1->type->children;
54
55 /* Hack: check there's enough memory to build the list */
56 /* RM: Jul 22 1993 */
57 /*
58 { int count=0;
59 while(p) {
60 count++;
61 p=p->next;
62 }
63 if (heap_pointer-stack_pointer < 3*count*sizeof(psi_term)) {
64 goal_stack=aim;
65 garbage();
66 return success;
67 }
68 */
69
70 t=stack_nil();
71 if (!(arg1->type==real && arg1->value_3)) /* PVR 15.2.94 */
72 while (p) {
73 ptr_definition ptype;
74
75 ptype = (ptr_definition) p->value_1;
76 if (hidden_type(ptype)) { p=p->next; continue; }
77 p1 = stack_psi_term(0);
78 p1->type = ptype;
79 t=stack_cons(p1,t);
80 p = p->next;
81 }
82 }
83 push_goal(unify,result,t,NULL);
84
85 return success;
86 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:239
get_two_args
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
stack_cons
ptr_psi_term stack_cons(ptr_psi_term head, ptr_psi_term tail)
stack_cons
Definition: built_ins.c:46
push_goal
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
wl_psi_term
Definition: def_struct.h:177
set_1
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
curry
void curry()
curry
Definition: lefun.c:174
NULL
#define NULL
Definition: def_const.h:533
resid_aim
ptr_goal resid_aim
Definition: def_glob.h:865
wl_int_list
Definition: def_struct.h:84
real
ptr_definition real
symbol in bi module
Definition: def_glob.h:375
greatest_sel
#define greatest_sel
used by collect_symbols in built_ins.c
Definition: def_const.h:18
deref_ptr
#define deref_ptr(P)
Definition: def_macro.h:100
TRUE
#define TRUE
Standard boolean.
Definition: def_const.h:268
deref
#define deref(P)
Definition: def_macro.h:147
ptr_definition
struct wl_definition * ptr_definition
Definition: def_struct.h:59
stack_psi_term
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
wl_psi_term::value_3
GENERIC value_3
Definition: def_struct.h:186
stack_nil
ptr_psi_term stack_nil()
stack_nil
Definition: built_ins.c:26
aim
ptr_goal aim
Definition: def_glob.h:1024
unify
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
wl_definition
Definition: def_struct.h:145
top
ptr_definition top
symbol in syntax module
Definition: def_glob.h:403
deref_args
#define deref_args(P, S)
Definition: def_macro.h:150
collect_symbols
ptr_psi_term collect_symbols(long sel)
collect_symbols
Definition: built_ins.c:3699
wl_psi_term::type
ptr_definition type
Definition: def_struct.h:181
wl_int_list::value_1
GENERIC value_1
Definition: def_struct.h:85
wl_goal::bbbb_1
ptr_psi_term bbbb_1
Definition: def_struct.h:240
hidden_type
long hidden_type(ptr_definition t)
hidden_type
Definition: built_ins.c:3672
wl_definition::children
ptr_int_list children
Definition: def_struct.h:152
wl_psi_term::attr_list
ptr_node attr_list
Definition: def_struct.h:187
wl_int_list::next
ptr_int_list next
Definition: def_struct.h:86

long c_glb | ( |  | ) |

long c_glb

greatest lower bound (djd)

C_GLB(A,B) Return glb(A,B). Continued calls will return each following type in the disjunction of the glb of A,B.

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

710 {
711 ptr_psi_term func,arg1,arg2, result, other;
712 ptr_definition ans;
713 ptr_int_list complexType;
714 ptr_int_list decodedType = NULL;
715 long ret;
716
717 func=aim->aaaa_1;
718 deref_ptr(func);
719 get_two_args(func->attr_list,&arg1,&arg2);
720
721 if ((!arg1) || (!arg2)) {
722 curry();
723 return TRUE;
724 }
725 result = aim->bbbb_1;
726 deref(result);
727 deref(arg1);
728 deref(arg2);
729 deref_args(func, set_1_2);
730
731 if ((ret=glb(arg1->type, arg2->type, &ans, &complexType)) == 0)
732 return FALSE;
733
734 if ((ret != 4)&&(isValue(arg1)||isValue(arg2))) {
735 /* glb is one of arg1->type or arg2->type AND at least one is a value */
736 if (!isSubTypeValue(arg1, arg2) && !isSubTypeValue(arg2, arg1))
737 return FALSE;
738 }
739 if (!ans) {
740 decodedType = decode(complexType);
741 ans = (ptr_definition)decodedType->value_1;
742 decodedType = decodedType->next;
743 }
744 other=makePsiTerm(ans);
745
746 if (isValue(arg1)) other->value_3=arg1->value_3;
747 if (isValue(arg2)) other->value_3=arg2->value_3;
748
749 if (isValue(arg1) || isValue(arg2)) {
750 if (decodedType) {
751 Errorline("glb of multiple-inheritance value sorts not yet implemented.\n");
752 return FALSE;
753 }
754 }
755
756 if (decodedType)
757 push_choice_point(type_disj, result,(ptr_psi_term) decodedType,(GENERIC) NULL);
758
759 resid_aim = NULL;
760 push_goal(unify,result,other,NULL);
761 return TRUE;
762 }
makePsiTerm
ptr_psi_term makePsiTerm(ptr_definition x)
ptr_psi_term makePsiTerm
Definition: bi_sys.c:573
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:239
get_two_args
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
isSubTypeValue
int isSubTypeValue(ptr_psi_term arg1, ptr_psi_term arg2)
isSubTypeValue
Definition: bi_type.c:180
glb
long glb(ptr_definition t1, ptr_definition t2, ptr_definition *t3, ptr_int_list *c3)
glb
Definition: types.c:1481
push_choice_point
void push_choice_point(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_choice_point
Definition: login.c:638
push_goal
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
decode
ptr_int_list decode(ptr_int_list c)
decode
Definition: types.c:1784
wl_psi_term
Definition: def_struct.h:177
curry
void curry()
curry
Definition: lefun.c:174
NULL
#define NULL
Definition: def_const.h:533
resid_aim
ptr_goal resid_aim
Definition: def_glob.h:865
wl_int_list
Definition: def_struct.h:84
Errorline
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
GENERIC
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
set_1_2
#define set_1_2
Set constants for deref_args in lefun.c.
Definition: def_const.h:514
deref_ptr
#define deref_ptr(P)
Definition: def_macro.h:100
TRUE
#define TRUE
Standard boolean.
Definition: def_const.h:268
FALSE
#define FALSE
Standard boolean.
Definition: def_const.h:275
deref
#define deref(P)
Definition: def_macro.h:147
ptr_definition
struct wl_definition * ptr_definition
Definition: def_struct.h:59
wl_psi_term::value_3
GENERIC value_3
Definition: def_struct.h:186
aim
ptr_goal aim
Definition: def_glob.h:1024
unify
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
wl_definition
Definition: def_struct.h:145
deref_args
#define deref_args(P, S)
Definition: def_macro.h:150
type_disj
#define type_disj
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1128
isValue
long isValue(ptr_psi_term p)
isValue(p)
Definition: bi_type.c:694
wl_psi_term::type
ptr_definition type
Definition: def_struct.h:181
wl_int_list::value_1
GENERIC value_1
Definition: def_struct.h:85
wl_goal::bbbb_1
ptr_psi_term bbbb_1
Definition: def_struct.h:240
wl_psi_term::attr_list
ptr_node attr_list
Definition: def_struct.h:187
wl_int_list::next
ptr_int_list next
Definition: def_struct.h:86

static long c_is_function | ( |  | ) |
| static

c_is_function

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

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

501 {
502 int success=TRUE,ans;
503 ptr_psi_term arg1,funct,result;
504
505 funct=aim->aaaa_1;
506 deref_ptr(funct);
507 result=aim->bbbb_1;
508 get_one_arg(funct->attr_list,&arg1);
509 if (arg1) {
510 deref(arg1);
511 deref_args(funct,set_1);
512 ans=(arg1->type->type_def==(def_type)function_it);
513 unify_bool_result(result,ans);
514 }
515 else curry();
516
517 return success;
518 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:239
function_it
#define function_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1408
def_type
struct wl_definition * def_type
Definition: def_struct.h:60
unify_bool_result
void unify_bool_result(ptr_psi_term t, long v)
unify_bool_result
Definition: built_ins.c:344
wl_definition::type_def
def_type type_def
Definition: def_struct.h:153
wl_psi_term
Definition: def_struct.h:177
get_one_arg
void get_one_arg(ptr_node t, ptr_psi_term *a)
get_one_arg
Definition: login.c:99
set_1
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
curry
void curry()
curry
Definition: lefun.c:174
deref_ptr
#define deref_ptr(P)
Definition: def_macro.h:100
TRUE
#define TRUE
Standard boolean.
Definition: def_const.h:268
deref
#define deref(P)
Definition: def_macro.h:147
aim
ptr_goal aim
Definition: def_glob.h:1024
deref_args
#define deref_args(P, S)
Definition: def_macro.h:150
wl_psi_term::type
ptr_definition type
Definition: def_struct.h:181
wl_goal::bbbb_1
ptr_psi_term bbbb_1
Definition: def_struct.h:240
wl_psi_term::attr_list
ptr_node attr_list
Definition: def_struct.h:187

static long c_is_number | ( |  | ) |
| static

static long c_is_number

Return true iff argument is an actual number.

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

637 {
638 long success=TRUE,ans;
639 ptr_psi_term arg1,arg2,funct,result;
640
641 funct=aim->aaaa_1;
642 deref_ptr(funct);
643 result=aim->bbbb_1;
644 get_two_args(funct->attr_list,&arg1,&arg2);
645 if (arg1) {
646 deref(arg1);
647 deref_args(funct,set_1);
648 ans=sub_type(arg1->type,real) && (arg1->value_3!=NULL);
649 unify_bool_result(result,ans);
650 }
651 else curry();
652
653 return success;
654 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:239
get_two_args
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
unify_bool_result
void unify_bool_result(ptr_psi_term t, long v)
unify_bool_result
Definition: built_ins.c:344
wl_psi_term
Definition: def_struct.h:177
set_1
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
curry
void curry()
curry
Definition: lefun.c:174
NULL
#define NULL
Definition: def_const.h:533
sub_type
long sub_type(ptr_definition t1, ptr_definition t2)
sub_type
Definition: types.c:1642
real
ptr_definition real
symbol in bi module
Definition: def_glob.h:375
deref_ptr
#define deref_ptr(P)
Definition: def_macro.h:100
TRUE
#define TRUE
Standard boolean.
Definition: def_const.h:268
deref
#define deref(P)
Definition: def_macro.h:147
wl_psi_term::value_3
GENERIC value_3
Definition: def_struct.h:186
aim
ptr_goal aim
Definition: def_glob.h:1024
deref_args
#define deref_args(P, S)
Definition: def_macro.h:150
wl_psi_term::type
ptr_definition type
Definition: def_struct.h:181
wl_goal::bbbb_1
ptr_psi_term bbbb_1
Definition: def_struct.h:240
wl_psi_term::attr_list
ptr_node attr_list
Definition: def_struct.h:187

static long c_is_persistent | ( |  | ) |
| static

c_is_persistent

Succeed iff argument is a quoted persistent or on the heap.

Definition at line 526 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_it, wl_definition::global_value, heap_pointer, set_1, TRUE, wl_psi_term::type, wl_definition::type_def, and unify_bool_result().

527 {
528 int success=TRUE,ans;
529 ptr_psi_term arg1,glob,result;
530
531 glob=aim->aaaa_1;
532 deref_ptr(glob);
533 result=aim->bbbb_1;
534 get_one_arg(glob->attr_list,&arg1);
535 if (arg1) {
536 deref(arg1);
537 deref_args(glob,set_1);
538 ans=(
539 arg1->type->type_def==(def_type)global_it &&
540 (GENERIC)arg1->type->global_value>=heap_pointer
541 ) ||
542 (GENERIC)arg1>=heap_pointer;
543 unify_bool_result(result,ans);
544 }
545 else curry();
546
547 return success;
548 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:239
heap_pointer
GENERIC heap_pointer
used to allocate from heap - size allocated subtracted - adj for alignment
Definition: def_glob.h:55
def_type
struct wl_definition * def_type
Definition: def_struct.h:60
unify_bool_result
void unify_bool_result(ptr_psi_term t, long v)
unify_bool_result
Definition: built_ins.c:344
wl_definition::type_def
def_type type_def
Definition: def_struct.h:153
wl_psi_term
Definition: def_struct.h:177
get_one_arg
void get_one_arg(ptr_node t, ptr_psi_term *a)
get_one_arg
Definition: login.c:99
set_1
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
global_it
#define global_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1422
curry
void curry()
curry
Definition: lefun.c:174
GENERIC
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
deref_ptr
#define deref_ptr(P)
Definition: def_macro.h:100
TRUE
#define TRUE
Standard boolean.
Definition: def_const.h:268
wl_definition::global_value
ptr_psi_term global_value
Definition: def_struct.h:159
deref
#define deref(P)
Definition: def_macro.h:147
aim
ptr_goal aim
Definition: def_glob.h:1024
deref_args
#define deref_args(P, S)
Definition: def_macro.h:150
wl_psi_term::type
ptr_definition type
Definition: def_struct.h:181
wl_goal::bbbb_1
ptr_psi_term bbbb_1
Definition: def_struct.h:240
wl_psi_term::attr_list
ptr_node attr_list
Definition: def_struct.h:187

static long c_is_predicate | ( |  | ) |
| static

c_is_predicate

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

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

557 {
558 int success=TRUE,ans;
559 ptr_psi_term arg1,funct,result;
560
561 funct=aim->aaaa_1;
562 deref_ptr(funct);
563 result=aim->bbbb_1;
564 get_one_arg(funct->attr_list,&arg1);
565 if (arg1) {
566 deref(arg1);
567 deref_args(funct,set_1);
568 ans=(arg1->type->type_def==(def_type)predicate_it);
569 unify_bool_result(result,ans);
570 }
571 else curry();
572
573 return success;
574 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:239
def_type
struct wl_definition * def_type
Definition: def_struct.h:60
unify_bool_result
void unify_bool_result(ptr_psi_term t, long v)
unify_bool_result
Definition: built_ins.c:344
wl_definition::type_def
def_type type_def
Definition: def_struct.h:153
predicate_it
#define predicate_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1401
wl_psi_term
Definition: def_struct.h:177
get_one_arg
void get_one_arg(ptr_node t, ptr_psi_term *a)
get_one_arg
Definition: login.c:99
set_1
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
curry
void curry()
curry
Definition: lefun.c:174
deref_ptr
#define deref_ptr(P)
Definition: def_macro.h:100
TRUE
#define TRUE
Standard boolean.
Definition: def_const.h:268
deref
#define deref(P)
Definition: def_macro.h:147
aim
ptr_goal aim
Definition: def_glob.h:1024
deref_args
#define deref_args(P, S)
Definition: def_macro.h:150
wl_psi_term::type
ptr_definition type
Definition: def_struct.h:181
wl_goal::bbbb_1
ptr_psi_term bbbb_1
Definition: def_struct.h:240
wl_psi_term::attr_list
ptr_node attr_list
Definition: def_struct.h:187

static long c_is_sort | ( |  | ) |
| static

c_is_sort

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

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

583 {
584 int success=TRUE,ans;
585 ptr_psi_term arg1,funct,result;
586
587 funct=aim->aaaa_1;
588 deref_ptr(funct);
589 result=aim->bbbb_1;
590 get_one_arg(funct->attr_list,&arg1);
591 if (arg1) {
592 deref(arg1);
593 deref_args(funct,set_1);
594 ans=(arg1->type->type_def==(def_type)type_it);
595 unify_bool_result(result,ans);
596 }
597 else curry();
598
599 return success;
600 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:239
def_type
struct wl_definition * def_type
Definition: def_struct.h:60
unify_bool_result
void unify_bool_result(ptr_psi_term t, long v)
unify_bool_result
Definition: built_ins.c:344
wl_definition::type_def
def_type type_def
Definition: def_struct.h:153
wl_psi_term
Definition: def_struct.h:177
get_one_arg
void get_one_arg(ptr_node t, ptr_psi_term *a)
get_one_arg
Definition: login.c:99
set_1
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
curry
void curry()
curry
Definition: lefun.c:174
type_it
#define type_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1415
deref_ptr
#define deref_ptr(P)
Definition: def_macro.h:100
TRUE
#define TRUE
Standard boolean.
Definition: def_const.h:268
deref
#define deref(P)
Definition: def_macro.h:147
aim
ptr_goal aim
Definition: def_glob.h:1024
deref_args
#define deref_args(P, S)
Definition: def_macro.h:150
wl_psi_term::type
ptr_definition type
Definition: def_struct.h:181
wl_goal::bbbb_1
ptr_psi_term bbbb_1
Definition: def_struct.h:240
wl_psi_term::attr_list
ptr_node attr_list
Definition: def_struct.h:187

static long c_is_value | ( |  | ) |
| static

c_is_value

Return true iff argument has a value, i.e. if it is implemented in a quirky way in Wild_Life. This is true for integers, reals, strings (which are potentially infinite sets of objects), and list objects.

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

611 {
612 long success=TRUE,ans;
613 ptr_psi_term arg1,arg2,funct,result;
614
615 funct=aim->aaaa_1;
616 deref_ptr(funct);
617 result=aim->bbbb_1;
618 get_two_args(funct->attr_list,&arg1,&arg2);
619 if (arg1) {
620 deref(arg1);
621 deref_args(funct,set_1);
622 ans=(arg1->value_3!=NULL);
623 unify_bool_result(result,ans);
624 }
625 else curry();
626
627 return success;
628 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:239
get_two_args
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
unify_bool_result
void unify_bool_result(ptr_psi_term t, long v)
unify_bool_result
Definition: built_ins.c:344
wl_psi_term
Definition: def_struct.h:177
set_1
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
curry
void curry()
curry
Definition: lefun.c:174
NULL
#define NULL
Definition: def_const.h:533
deref_ptr
#define deref_ptr(P)
Definition: def_macro.h:100
TRUE
#define TRUE
Standard boolean.
Definition: def_const.h:268
deref
#define deref(P)
Definition: def_macro.h:147
wl_psi_term::value_3
GENERIC value_3
Definition: def_struct.h:186
aim
ptr_goal aim
Definition: def_glob.h:1024
deref_args
#define deref_args(P, S)
Definition: def_macro.h:150
wl_goal::bbbb_1
ptr_psi_term bbbb_1
Definition: def_struct.h:240
wl_psi_term::attr_list
ptr_node attr_list
Definition: def_struct.h:187

static long c_isa_cmp | ( |  | ) |
| static

c_isa_cmp

Definition at line 480 of file bi_type.c.

References c_isa_main(), and isa_cmp_sel.

481 {
482 return c_isa_main(isa_cmp_sel);
483 }
isa_cmp_sel
#define isa_cmp_sel
a value used in case satement in isa_select function in bi_type.c
Definition: def_const.h:1266
c_isa_main
static long c_isa_main(long sel)
c_isa_main
Definition: bi_type.c:295

static long c_isa_eq | ( |  | ) |
| static

c_isa_eq

Type t1 equals t2 in the hierarchy, i.e. t1 is equal to t2. This boolean function requires two arguments and never residuates. It will curry if insufficient arguments are given. It works correctly on the 'value' types, i.e. on integers, reals, strings, and lists. For lists, it looks only at the top level, i.e. whether the object is nil or a cons cell.

Definition at line 391 of file bi_type.c.

References c_isa_main(), and isa_eq_sel.

392 {
393 return c_isa_main(isa_eq_sel);
394 }
isa_eq_sel
#define isa_eq_sel
a value used in case satement in isa_select function in bi_type.c
Definition: def_const.h:1224
c_isa_main
static long c_isa_main(long sel)
c_isa_main
Definition: bi_type.c:295

static long c_isa_ge | ( |  | ) |
| static

c_isa_ge

Type t2 isa t1 in the hierarchy, i.e. t2 is less than or equal to t1. This boolean function requires two arguments and never residuates. It will curry if insufficient arguments are given. It works correctly on the 'value' types, i.e. on integers, reals, strings, and lists. For lists, it looks only at the top level, i.e. whether the object is nil or a cons cell.

Definition at line 359 of file bi_type.c.

References c_isa_main(), and isa_ge_sel.

360 {
361 return c_isa_main(isa_ge_sel);
362 }
isa_ge_sel
#define isa_ge_sel
a value used in case satement in isa_select function in bi_type.c
Definition: def_const.h:1210
c_isa_main
static long c_isa_main(long sel)
c_isa_main
Definition: bi_type.c:295

static long c_isa_gt | ( |  | ) |
| static

c_isa_gt

Type t2 is lt t1 in the hierarchy, i.e. t2 is less than to t1. This boolean function requires two arguments and never residuates. It will curry if insufficient arguments are given. It works correctly on the 'value' types, i.e. on integers, reals, strings, and lists. For lists, it looks only at the top level, i.e. whether the object is nil or a cons cell.

Definition at line 375 of file bi_type.c.

References c_isa_main(), and isa_gt_sel.

376 {
377 return c_isa_main(isa_gt_sel);
378 }
c_isa_main
static long c_isa_main(long sel)
c_isa_main
Definition: bi_type.c:295
isa_gt_sel
#define isa_gt_sel
a value used in case satement in isa_select function in bi_type.c
Definition: def_const.h:1217

static long c_isa_le | ( |  | ) |
| static

c_isa_le

Type t1 isa t2 in the hierarchy, i.e. t1 is less than or equal to t2. This boolean function requires two arguments and never residuates. It will curry if insufficient arguments are given. It works correctly on the 'value' types, i.e. on integers, reals, strings, and lists. For lists, it looks only at the top level, i.e. whether the object is nil or a cons cell.

Definition at line 327 of file bi_type.c.

References c_isa_main(), and isa_le_sel.

328 {
329 return c_isa_main(isa_le_sel);
330 }
isa_le_sel
#define isa_le_sel
a value used in case satement in isa_select function in bi_type.c
Definition: def_const.h:1196
c_isa_main
static long c_isa_main(long sel)
c_isa_main
Definition: bi_type.c:295

static long c_isa_lt | ( |  | ) |
| static

c_isa_lt

Type t1 is lt t2 in the hierarchy, i.e. t1 is less than t2. This boolean function requires two arguments and never residuates. It will curry if insufficient arguments are given. It works correctly on the 'value' types, i.e. on integers, reals, strings, and lists. For lists, it looks only at the top level, i.e. whether the object is nil or a cons cell.

Definition at line 343 of file bi_type.c.

References c_isa_main(), and isa_lt_sel.

344 {
345 return c_isa_main(isa_lt_sel);
346 }
c_isa_main
static long c_isa_main(long sel)
c_isa_main
Definition: bi_type.c:295
isa_lt_sel
#define isa_lt_sel
a value used in case satement in isa_select function in bi_type.c
Definition: def_const.h:1203

static long c_isa_main | ( | long | sel | ) |
| static

c_isa_main

Parameters

  sel | - long sel

Main routine to handle all the isa built-in functions.

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

296 {
297 long success=TRUE,ans;
298 ptr_psi_term arg1,arg2,funct,result;
299
300 funct=aim->aaaa_1;
301 deref_ptr(funct);
302 result=aim->bbbb_1;
303 get_two_args(funct->attr_list,&arg1,&arg2);
304 if (arg1 && arg2) {
305 deref(arg1);
306 deref(arg2);
307 deref_args(funct,set_1_2);
308 ans=isa_select(arg1,arg2,sel);
309 unify_bool_result(result,ans);
310 }
311 else curry();
312
313 return success;
314 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:239
get_two_args
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
unify_bool_result
void unify_bool_result(ptr_psi_term t, long v)
unify_bool_result
Definition: built_ins.c:344
wl_psi_term
Definition: def_struct.h:177
curry
void curry()
curry
Definition: lefun.c:174
set_1_2
#define set_1_2
Set constants for deref_args in lefun.c.
Definition: def_const.h:514
deref_ptr
#define deref_ptr(P)
Definition: def_macro.h:100
TRUE
#define TRUE
Standard boolean.
Definition: def_const.h:268
deref
#define deref(P)
Definition: def_macro.h:147
aim
ptr_goal aim
Definition: def_glob.h:1024
deref_args
#define deref_args(P, S)
Definition: def_macro.h:150
isa_select
static long isa_select(ptr_psi_term arg1, ptr_psi_term arg2, long sel)
isa_select
Definition: bi_type.c:253
wl_goal::bbbb_1
ptr_psi_term bbbb_1
Definition: def_struct.h:240
wl_psi_term::attr_list
ptr_node attr_list
Definition: def_struct.h:187

static long c_isa_ncmp | ( |  | ) |
| static

c_isa_ncmp

Definition at line 489 of file bi_type.c.

References c_isa_main(), and isa_ncmp_sel.

490 {
491 return c_isa_main(isa_ncmp_sel);
492 }
c_isa_main
static long c_isa_main(long sel)
c_isa_main
Definition: bi_type.c:295
isa_ncmp_sel
#define isa_ncmp_sel
a value used in case satement in isa_select function in bi_type.c
Definition: def_const.h:1273

static long c_isa_neq | ( |  | ) |
| static

c_isa_neq

Type t1 is not eq t2 in the hierarchy, i.e. t1 is not equal to t2. This boolean function requires two arguments and never residuates. It will curry if insufficient arguments are given. It works correctly on the 'value' types, i.e. on integers, reals, strings, and lists. For lists, it looks only at the top level, i.e. whether the object is nil or a cons cell.

Definition at line 471 of file bi_type.c.

References c_isa_main(), and isa_neq_sel.

472 {
473 return c_isa_main(isa_neq_sel);
474 }
isa_neq_sel
#define isa_neq_sel
a value used in case satement in isa_select function in bi_type.c
Definition: def_const.h:1259
c_isa_main
static long c_isa_main(long sel)
c_isa_main
Definition: bi_type.c:295

static long c_isa_nge | ( |  | ) |
| static

c_isa_nge

Type t2 is not lt t1 in the hierarchy, i.e. t2 is not less than or equal to t1. This boolean function requires two arguments and never residuates. It will curry if insufficient arguments are given. It works correctly on the 'value' types, i.e. on integers, reals, strings, and lists. For lists, it looks only at the top level, i.e. whether the object is nil or a cons cell.

Definition at line 439 of file bi_type.c.

References c_isa_main(), and isa_nge_sel.

440 {
441 return c_isa_main(isa_nge_sel);
442 }
isa_nge_sel
#define isa_nge_sel
a value used in case satement in isa_select function in bi_type.c
Definition: def_const.h:1245
c_isa_main
static long c_isa_main(long sel)
c_isa_main
Definition: bi_type.c:295

static long c_isa_ngt | ( |  | ) |
| static

c_isa_ngt

Type t2 is not t1 in the hierarchy, i.e. t2 is not less than t1. This boolean function requires two arguments and never residuates. It will curry if insufficient arguments are given. It works correctly on the 'value' types, i.e. on integers, reals, strings, and lists. For lists, it looks only at the top level, i.e. whether the object is nil or a cons cell.

Definition at line 455 of file bi_type.c.

References c_isa_main(), and isa_ngt_sel.

456 {
457 return c_isa_main(isa_ngt_sel);
458 }
isa_ngt_sel
#define isa_ngt_sel
a value used in case satement in isa_select function in bi_type.c
Definition: def_const.h:1252
c_isa_main
static long c_isa_main(long sel)
c_isa_main
Definition: bi_type.c:295

static long c_isa_nle | ( |  | ) |
| static

c_isa_nle

Type t1 is not a t2 in the hierarchy, i.e. t1 is not less than or equal to t2. This boolean function requires two arguments and never residuates. It will curry if insufficient arguments are given. It works correctly on the 'value' types, i.e. on integers, reals, strings, and lists. For lists, it looks only at the top level, i.e. whether the object is nil or a cons cell.

Definition at line 407 of file bi_type.c.

References c_isa_main(), and isa_nle_sel.

408 {
409 return c_isa_main(isa_nle_sel);
410 }
isa_nle_sel
#define isa_nle_sel
a value used in case satement in isa_select function in bi_type.c
Definition: def_const.h:1231
c_isa_main
static long c_isa_main(long sel)
c_isa_main
Definition: bi_type.c:295

static long c_isa_nlt | ( |  | ) |
| static

c_isa_nlt

Type t1 is not lt t2 in the hierarchy, i.e. t1 is not less than to t2. This boolean function requires two arguments and never residuates. It will curry if insufficient arguments are given. It works correctly on the 'value' types, i.e. on integers, reals, strings, and lists. For lists, it looks only at the top level, i.e. whether the object is nil or a cons cell.

Definition at line 423 of file bi_type.c.

References c_isa_main(), and isa_nlt_sel.

424 {
425 return c_isa_main(isa_nlt_sel);
426 }
isa_nlt_sel
#define isa_nlt_sel
a value used in case satement in isa_select function in bi_type.c
Definition: def_const.h:1238
c_isa_main
static long c_isa_main(long sel)
c_isa_main
Definition: bi_type.c:295

long c_isa_subsort | ( |  | ) |

long c_isa_subsort

C_ISA_SUBSORT(A,B) if A is a subsort of B => succeed and residuate on B else => fail

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

665 {
666 ptr_psi_term pred,arg1,arg2;
667
668 pred=aim->aaaa_1;
669 deref_ptr(pred);
670 get_two_args(pred->attr_list,&arg1,&arg2);
671
672 if (!arg1) (void)reportAndAbort(pred,"no first argument");
673 deref(arg1);
674
675 if (!arg2) (void)reportAndAbort(pred,"no second argument");
676 deref(arg2);
677
678 deref_args(pred, set_1_2);
679
680 if (isa(arg1, arg2))
681 {
682 residuate(arg2);
683 return TRUE;
684 }
685 return FALSE;
686 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:239
get_two_args
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
residuate
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
isa
static long isa(ptr_psi_term arg1, ptr_psi_term arg2)
isa
Definition: bi_type.c:219
reportAndAbort
long reportAndAbort(ptr_psi_term g, char *s)
reportAndAbort
Definition: error.c:872
wl_psi_term
Definition: def_struct.h:177
set_1_2
#define set_1_2
Set constants for deref_args in lefun.c.
Definition: def_const.h:514
deref_ptr
#define deref_ptr(P)
Definition: def_macro.h:100
TRUE
#define TRUE
Standard boolean.
Definition: def_const.h:268
FALSE
#define FALSE
Standard boolean.
Definition: def_const.h:275
deref
#define deref(P)
Definition: def_macro.h:147
aim
ptr_goal aim
Definition: def_glob.h:1024
deref_args
#define deref_args(P, S)
Definition: def_macro.h:150
wl_psi_term::attr_list
ptr_node attr_list
Definition: def_struct.h:187

long c_lub | ( |  | ) |

long c_lub

least upper bound (djd) C_LUB(A,B) Return lub(A,B). Continued calls will return each following type in the disjunction of the lub of A,B.

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

774 {
775 ptr_psi_term func,arg1,arg2, result, other;
776 ptr_definition ans=NULL;
777 ptr_int_list decodedType = NULL;
778
779 func=aim->aaaa_1;
780 deref_ptr(func);
781 get_two_args(func->attr_list,&arg1,&arg2);
782
783 if ((!arg1) || (!arg2))
784 {
785 curry();
786 return TRUE;
787 }
788 result = aim->bbbb_1;
789 deref(result);
790 deref(arg1);
791 deref(arg2);
792 deref_args(func, set_1_2);
793
794 /* now lets find the list of types that is the lub */
795
796 decodedType = lub(arg1, arg2, &other);
797
798 if (decodedType) {
799 ans = (ptr_definition)decodedType->value_1;
800 decodedType = decodedType->next;
801 other = makePsiTerm(ans);
802 }
803
804 if (decodedType)
805 push_choice_point(type_disj, result,(ptr_psi_term) decodedType,(GENERIC) NULL);
806
807 resid_aim = NULL;
808 push_goal(unify,result,other,NULL);
809 return TRUE;
810 }
makePsiTerm
ptr_psi_term makePsiTerm(ptr_definition x)
ptr_psi_term makePsiTerm
Definition: bi_sys.c:573
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:239
get_two_args
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
push_choice_point
void push_choice_point(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_choice_point
Definition: login.c:638
push_goal
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
wl_psi_term
Definition: def_struct.h:177
curry
void curry()
curry
Definition: lefun.c:174
NULL
#define NULL
Definition: def_const.h:533
resid_aim
ptr_goal resid_aim
Definition: def_glob.h:865
wl_int_list
Definition: def_struct.h:84
GENERIC
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
set_1_2
#define set_1_2
Set constants for deref_args in lefun.c.
Definition: def_const.h:514
deref_ptr
#define deref_ptr(P)
Definition: def_macro.h:100
TRUE
#define TRUE
Standard boolean.
Definition: def_const.h:268
deref
#define deref(P)
Definition: def_macro.h:147
lub
ptr_int_list lub(ptr_psi_term a, ptr_psi_term b, ptr_psi_term *pp)
Definition: lub.c:173
ptr_definition
struct wl_definition * ptr_definition
Definition: def_struct.h:59
aim
ptr_goal aim
Definition: def_glob.h:1024
unify
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
wl_definition
Definition: def_struct.h:145
deref_args
#define deref_args(P, S)
Definition: def_macro.h:150
type_disj
#define type_disj
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1128
wl_int_list::value_1
GENERIC value_1
Definition: def_struct.h:85
wl_goal::bbbb_1
ptr_psi_term bbbb_1
Definition: def_struct.h:240
wl_psi_term::attr_list
ptr_node attr_list
Definition: def_struct.h:187
wl_int_list::next
ptr_int_list next
Definition: def_struct.h:86

static long c_parents | ( |  | ) |
| static

c_parents

Return a list of roots of the parent types of T.

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

97 {
98 long success=TRUE;
99 ptr_psi_term funct,result,arg1,arg2,t,p1;
100 ptr_int_list p;
101
102 funct=aim->aaaa_1;
103 deref_ptr(funct);
104 result=aim->bbbb_1;
105 get_two_args(funct->attr_list,&arg1,&arg2);
106 if (arg1) {
107 deref(arg1);
108 deref_args(funct,set_1);
109 resid_aim=NULL;
110 t=stack_nil(); /* RM: Dec 14 1992 */
111 p = arg1->type->parents;
112 if (arg1->type!=top && p==NULL) {
113 /* Top is the only parent */
114 p1 = stack_psi_term(4);
115 p1->type = (ptr_definition) top;
116 t=stack_cons(p1,t); /* RM: Dec 14 1992 */
117 }
118 else {
119 if ((arg1->type==quoted_string || arg1->type==integer ||
120 arg1->type==real) && arg1->value_3!=NULL) {
121 /* arg1 is a string, long or real: return a list with arg1 as
122 argument, where arg1->value_2 = NULL, MH */
123 p1 = stack_psi_term(4);
124 p1->type = arg1->type;
125 t=stack_cons(p1,t); /* RM: Dec 14 1992 */
126 }
127 else {
128 /* Look at the parents list */
129 while (p) {
130 ptr_definition ptype;
131
132 ptype = (ptr_definition) p->value_1;
133 if (hidden_type(ptype)) { p=p->next; continue; }
134 p1 = stack_psi_term(4);
135 p1->type = ptype;
136 t=stack_cons(p1,t); /* RM: Dec 14 1992 */
137 p = p->next;
138 }
139 }
140 }
141 push_goal(unify,result,t,NULL);
142 }
143 else
144 curry();
145
146 return success;
147 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:239
get_two_args
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
stack_cons
ptr_psi_term stack_cons(ptr_psi_term head, ptr_psi_term tail)
stack_cons
Definition: built_ins.c:46
integer
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
push_goal
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
wl_psi_term
Definition: def_struct.h:177
set_1
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
curry
void curry()
curry
Definition: lefun.c:174
NULL
#define NULL
Definition: def_const.h:533
resid_aim
ptr_goal resid_aim
Definition: def_glob.h:865
wl_int_list
Definition: def_struct.h:84
real
ptr_definition real
symbol in bi module
Definition: def_glob.h:375
deref_ptr
#define deref_ptr(P)
Definition: def_macro.h:100
TRUE
#define TRUE
Standard boolean.
Definition: def_const.h:268
deref
#define deref(P)
Definition: def_macro.h:147
ptr_definition
struct wl_definition * ptr_definition
Definition: def_struct.h:59
stack_psi_term
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
wl_psi_term::value_3
GENERIC value_3
Definition: def_struct.h:186
stack_nil
ptr_psi_term stack_nil()
stack_nil
Definition: built_ins.c:26
aim
ptr_goal aim
Definition: def_glob.h:1024
unify
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
wl_definition
Definition: def_struct.h:145
top
ptr_definition top
symbol in syntax module
Definition: def_glob.h:403
deref_args
#define deref_args(P, S)
Definition: def_macro.h:150
wl_psi_term::type
ptr_definition type
Definition: def_struct.h:181
wl_int_list::value_1
GENERIC value_1
Definition: def_struct.h:85
wl_goal::bbbb_1
ptr_psi_term bbbb_1
Definition: def_struct.h:240
hidden_type
long hidden_type(ptr_definition t)
hidden_type
Definition: built_ins.c:3672
wl_psi_term::attr_list
ptr_node attr_list
Definition: def_struct.h:187
quoted_string
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
wl_int_list::next
ptr_int_list next
Definition: def_struct.h:86
wl_definition::parents
ptr_int_list parents
Definition: def_struct.h:151

static long c_smallest | ( |  | ) |
| static

c_smallest

Return the parents of bottom. This function has no arguments.

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

160 {
161 long success=TRUE;
162 ptr_psi_term result, g, t;
163
164 g=aim->aaaa_1;
165 deref_args(g,set_empty);
166 result=aim->bbbb_1;
167 t=collect_symbols(least_sel); /* RM: Feb 3 1993 */
168 push_goal(unify,result,t,NULL);
169
170 return success;
171 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:239
least_sel
#define least_sel
used by collect_symbols in built_ins.c
Definition: def_const.h:11
push_goal
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
wl_psi_term
Definition: def_struct.h:177
set_empty
#define set_empty
Set constants for deref_args in lefun.c.
Definition: def_const.h:493
NULL
#define NULL
Definition: def_const.h:533
TRUE
#define TRUE
Standard boolean.
Definition: def_const.h:268
aim
ptr_goal aim
Definition: def_glob.h:1024
unify
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
deref_args
#define deref_args(P, S)
Definition: def_macro.h:150
collect_symbols
ptr_psi_term collect_symbols(long sel)
collect_symbols
Definition: built_ins.c:3699
wl_goal::bbbb_1
ptr_psi_term bbbb_1
Definition: def_struct.h:240

void insert_type_builtins | ( |  | ) |

void insert_type_builtins

Definition at line 817 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_it, and syntax_module.

818 {
819 /* Sort comparisons */
820 new_built_in(syntax_module,":=<",(def_type)function_it,c_isa_le);
821 new_built_in(syntax_module,":<",(def_type)function_it,c_isa_lt);
822 new_built_in(syntax_module,":>=",(def_type)function_it,c_isa_ge);
823 new_built_in(syntax_module,":>",(def_type)function_it,c_isa_gt);
824 new_built_in(syntax_module,":==",(def_type)function_it,c_isa_eq);
825 new_built_in(syntax_module,":><",(def_type)function_it,c_isa_cmp);
826 new_built_in(syntax_module,":\\=<",(def_type)function_it,c_isa_nle);
827 new_built_in(syntax_module,":\\<",(def_type)function_it,c_isa_nlt);
828 new_built_in(syntax_module,":\\>=",(def_type)function_it,c_isa_nge);
829 new_built_in(syntax_module,":\\>",(def_type)function_it,c_isa_ngt);
830 new_built_in(syntax_module,":\\==",(def_type)function_it,c_isa_neq);
831 new_built_in(syntax_module,":\\><",(def_type)function_it,c_isa_ncmp);
832
833 /* Type checks */
834 new_built_in(bi_module,"is_value",(def_type)function_it,c_is_value);
835 new_built_in(bi_module,"is_number",(def_type)function_it,c_is_number);
836 new_built_in(bi_module,"is_function",(def_type)function_it,c_is_function);
837 new_built_in(bi_module,"is_predicate",(def_type)function_it,c_is_predicate);
838 new_built_in(bi_module,"is_sort",(def_type)function_it,c_is_sort);
839 new_built_in(bi_module,"is_persistent",(def_type)function_it,c_is_persistent);
840
841 /* Sort hierarchy maneuvering */
842 new_built_in(bi_module,"children",(def_type)function_it,c_children);
843 new_built_in(bi_module,"parents",(def_type)function_it,c_parents);
844 new_built_in(bi_module,"least_sorts",(def_type)function_it,c_smallest);
845 new_built_in(bi_module,"subsort",(def_type)predicate_it,c_isa_subsort);
846 new_built_in(bi_module,"glb",(def_type)function_it,c_glb);
847 new_built_in(bi_module,"lub",(def_type)function_it,c_lub);
848 }
new_built_in
void new_built_in(ptr_module m, char *s, def_type t, long(*r)())
new_built_in
Definition: built_ins.c:5375
c_isa_cmp
static long c_isa_cmp()
c_isa_cmp
Definition: bi_type.c:480
function_it
#define function_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1408
c_smallest
static long c_smallest()
c_smallest
Definition: bi_type.c:159
c_lub
long c_lub()
long c_lub
Definition: bi_type.c:773
c_is_number
static long c_is_number()
static long c_is_number
Definition: bi_type.c:636
c_is_predicate
static long c_is_predicate()
c_is_predicate
Definition: bi_type.c:556
c_isa_lt
static long c_isa_lt()
c_isa_lt
Definition: bi_type.c:343
c_isa_ncmp
static long c_isa_ncmp()
c_isa_ncmp
Definition: bi_type.c:489
c_glb
long c_glb()
long c_glb
Definition: bi_type.c:709
syntax_module
ptr_module syntax_module
Module for minimal Prolog syntax.
Definition: def_glob.h:715
predicate_it
#define predicate_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1401
c_children
static long c_children()
c_children
Definition: bi_type.c:30
c_isa_nle
static long c_isa_nle()
c_isa_nle
Definition: bi_type.c:407
c_isa_ge
static long c_isa_ge()
c_isa_ge
Definition: bi_type.c:359
c_isa_subsort
long c_isa_subsort()
long c_isa_subsort
Definition: bi_type.c:664
c_isa_nlt
static long c_isa_nlt()
c_isa_nlt
Definition: bi_type.c:423
c_isa_ngt
static long c_isa_ngt()
c_isa_ngt
Definition: bi_type.c:455
c_isa_gt
static long c_isa_gt()
c_isa_gt
Definition: bi_type.c:375
c_is_value
static long c_is_value()
c_is_value
Definition: bi_type.c:610
c_isa_nge
static long c_isa_nge()
c_isa_nge
Definition: bi_type.c:439
wl_definition
Definition: def_struct.h:145
bi_module
ptr_module bi_module
Module for public built-ins.
Definition: def_glob.h:687
c_parents
static long c_parents()
c_parents
Definition: bi_type.c:96
c_is_sort
static long c_is_sort()
c_is_sort
Definition: bi_type.c:582
c_is_function
static long c_is_function()
c_is_function
Definition: bi_type.c:500
c_isa_eq
static long c_isa_eq()
c_isa_eq
Definition: bi_type.c:391
c_isa_le
static long c_isa_le()
c_isa_le
Definition: bi_type.c:327
c_is_persistent
static long c_is_persistent()
c_is_persistent
Definition: bi_type.c:526
c_isa_neq
static long c_isa_neq()
c_isa_neq
Definition: bi_type.c:471

static static long isa | ( | ptr_psi_term | arg1,
|  | ptr_psi_term | arg2
| ) |  |
| static

isa

Parameters

  arg1 | - ptr_psi_term arg1
  arg2 | - ptr_psi_term arg2

Boolean utility function that implements isa

Definition at line 219 of file bi_type.c.

References cut, integer, isSubTypeValue(), matches(), real, TRUE, wl_psi_term::type, and wl_psi_term::value_3.

220 {
221 long ans;
222
223 if ( arg1->type==arg2->type
224 || ( (arg1->type==real || arg1->type==integer)
225 && (arg2->type==real || arg2->type==integer)
226 && (arg1->value_3 || arg2->value_3)
227 )
228 ) {
229
230 if(arg1->type==cut) /* RM: Jan 21 1993 */
231 ans=TRUE;
232 else
233 ans=isSubTypeValue(arg1, arg2);
234 }
235 else {
236 (void)matches(arg1->type, arg2->type, &ans);
237 }
238
239 /*Errorline("isa %P %P -> %d\n",arg1,arg2,ans);*/
240
241 return ans;
242 }
isSubTypeValue
int isSubTypeValue(ptr_psi_term arg1, ptr_psi_term arg2)
isSubTypeValue
Definition: bi_type.c:180
integer
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
cut
ptr_definition cut
symbol in syntax module
Definition: def_glob.h:242
matches
long matches(ptr_definition t1, ptr_definition t2, long *smaller)
matches
Definition: types.c:1666
real
ptr_definition real
symbol in bi module
Definition: def_glob.h:375
TRUE
#define TRUE
Standard boolean.
Definition: def_const.h:268
wl_psi_term::value_3
GENERIC value_3
Definition: def_struct.h:186
wl_psi_term::type
ptr_definition type
Definition: def_struct.h:181

static long isa_select | ( | ptr_psi_term | arg1,
|  | ptr_psi_term | arg2,
|  | long | sel
| ) |  |
| static

isa_select

Parameters

  arg1 | - ptr_psi_term arg1
  arg2 | - ptr_psi_term arg2
  sel | - long sel - one of several values defined in def_const.h

Utility that selects one of several isa functions

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

254 {
255 long ans;
256
257 switch (sel) {
258 case isa_le_sel: ans=isa(arg1,arg2);
259 break;
260 case isa_lt_sel: ans=isa(arg1,arg2) && !isa(arg2,arg1);
261 break;
262 case isa_ge_sel: ans=isa(arg2,arg1);
263 break;
264 case isa_gt_sel: ans=isa(arg2,arg1) && !isa(arg1,arg2);
265 break;
266 case isa_eq_sel: ans=isa(arg1,arg2) && isa(arg2,arg1);
267 break;
268
269 case isa_nle_sel: ans= !isa(arg1,arg2);
270 break;
271 case isa_nlt_sel: ans= !(isa(arg1,arg2) && !isa(arg2,arg1));
272 break;
273 case isa_nge_sel: ans= !isa(arg2,arg1);
274 break;
275 case isa_ngt_sel: ans= !(isa(arg2,arg1) && !isa(arg1,arg2));
276 break;
277 case isa_neq_sel: ans= !(isa(arg1,arg2) && isa(arg2,arg1));
278 break;
279
280 case isa_cmp_sel: ans=isa(arg1,arg2) || isa(arg2,arg1);
281 break;
282 case isa_ncmp_sel: ans= !(isa(arg1,arg2) || isa(arg2,arg1));
283 break;
284 }
285 return ans;
286 }
isa_nlt_sel
#define isa_nlt_sel
a value used in case satement in isa_select function in bi_type.c
Definition: def_const.h:1238
isa_eq_sel
#define isa_eq_sel
a value used in case satement in isa_select function in bi_type.c
Definition: def_const.h:1224
isa
static long isa(ptr_psi_term arg1, ptr_psi_term arg2)
isa
Definition: bi_type.c:219
isa_le_sel
#define isa_le_sel
a value used in case satement in isa_select function in bi_type.c
Definition: def_const.h:1196
isa_nge_sel
#define isa_nge_sel
a value used in case satement in isa_select function in bi_type.c
Definition: def_const.h:1245
isa_ngt_sel
#define isa_ngt_sel
a value used in case satement in isa_select function in bi_type.c
Definition: def_const.h:1252
isa_neq_sel
#define isa_neq_sel
a value used in case satement in isa_select function in bi_type.c
Definition: def_const.h:1259
isa_cmp_sel
#define isa_cmp_sel
a value used in case satement in isa_select function in bi_type.c
Definition: def_const.h:1266
isa_nle_sel
#define isa_nle_sel
a value used in case satement in isa_select function in bi_type.c
Definition: def_const.h:1231
isa_ge_sel
#define isa_ge_sel
a value used in case satement in isa_select function in bi_type.c
Definition: def_const.h:1210
isa_gt_sel
#define isa_gt_sel
a value used in case satement in isa_select function in bi_type.c
Definition: def_const.h:1217
isa_lt_sel
#define isa_lt_sel
a value used in case satement in isa_select function in bi_type.c
Definition: def_const.h:1203
isa_ncmp_sel
#define isa_ncmp_sel
a value used in case satement in isa_select function in bi_type.c
Definition: def_const.h:1273

int isSubTypeValue | ( | ptr_psi_term | arg1,
|  | ptr_psi_term | arg2
| ) |  |

isSubTypeValue

Parameters

  arg1 | - ptr_psi_term arg1
  arg2 | - ptr_psi_term arg2

Definition at line 180 of file bi_type.c.

References FALSE, integer, quoted_string, REAL, real, TRUE, wl_psi_term::type, and wl_psi_term::value_3.

181 {
182 long ans=TRUE;
183
184 /* we already know that either arg1->type == arg2->type or that at both
185 * of the two are either long or real
186 */
187
188 if (arg2->value_3) {
189 if (arg1->value_3) {
190 if (arg1->type==real || arg1->type==integer) {
191 ans=( *(REAL *)arg1->value_3 == *(REAL *)arg2->value_3);
192 }
193 else if (arg1->type==quoted_string) {
194 ans=(strcmp((char *)arg1->value_3,(char *)arg2->value_3)==0);
195 }
196 }
197 else
198 ans=FALSE;
199 }
200 else {
201 if (arg1->value_3 && (arg1->type==real || arg1->type==integer)) {
202 if (arg2->type==integer)
203 ans=(*(REAL *)arg1->value_3 == floor(*(REAL *)arg1->value_3));
204 else
205 ans=TRUE;
206 }
207 }
208 return ans;
209 }
integer
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
REAL
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
real
ptr_definition real
symbol in bi module
Definition: def_glob.h:375
TRUE
#define TRUE
Standard boolean.
Definition: def_const.h:268
FALSE
#define FALSE
Standard boolean.
Definition: def_const.h:275
wl_psi_term::value_3
GENERIC value_3
Definition: def_struct.h:186
wl_psi_term::type
ptr_definition type
Definition: def_struct.h:181
quoted_string
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368

long isValue | ( | ptr_psi_term | p | ) |

isValue(p)

Parameters

  p | - ptr_psi_term p

Definition at line 694 of file bi_type.c.

References NULL, and wl_psi_term::value_3.

695 {
696 return (p->value_3 != NULL);
697 }
NULL
#define NULL
Definition: def_const.h:533
wl_psi_term::value_3
GENERIC value_3
Definition: def_struct.h:186