;;;-*- Mode: Lisp; Package: XLE -*- (in-package :XLE) #|| /* (c) 2002 by the Palo Alto Research Center. All rights reserved */ /* (c) 1996-1999 by the Xerox Corporation. All rights reserved */ #ifndef VALUES_H #define VALUES_H #include "clause.h" ||# ;, /* ------------------------------------------------------------------------- */ ;; enum ValueType { (defconstant +VT_NULL+ 0) ; /* no value */ (defconstant +VT_STR+ 1) ; /* string */ (defconstant +VT_NUM+ 2) ; /* number */ (defconstant +VT_AVP+ 3) ; /* AVPair */ (defconstant +VT_EDGE+ 4) ; (defconstant +VT_ATTR_ID+ 5) ; /* used by GGFS relation */ (defconstant +VT_REL_ID+ 6) ; /* a relation id. used by REL_MISSING. */ (defconstant +VT_GENSYM+ 7) ; /* unique ID+ ) ; regenerated across edges to handle */ ; /* generation correctly */ (defconstant +VT_NETWORK+ 8) ; /* c-fsm NETptr (used for functional uncertainty) */ (defconstant +VT_STATE+ 9) ; /* c-fsm STATEptr (used for functional uncertainty) */ (defconstant +VT_ARC+ 10) ; /* c-fsm ARCptr (used for functional uncertainty) */ (defconstant +VT_CVPAIR+ 11) ; /* the typical fact type (used in justifications) */ (defconstant +VT_CONTEXTS+ 12) ; /* used by conjoin_facts2 (used in justifications) */ (defconstant +VT_CLAUSE+ 13) ; /* for FALSE and incomplete nogoods (ditto) */ (defconstant +VT_TRUE+ 14) ; /* always evaluates to true (ditto) */ (defconstant +VT_LAZY+ 15) ; /* for lazy links (used in justifications) */ (defconstant +VT_COPYEDGE+ 16) ; /* the edge that this fact was copied from */ (defconstant +VT_OPAQUE1+ 17) ; /* user defined opaque values */ (defconstant +VT_OPAQUE2+ 18) ; /* use get_next_opaque_type_id */ (defconstant +VT_BASE_MAX+ 50) ; /* boundary between opaque types and tuple types */ (defconstant +VT_SEMFORM+ 51) ; /* semantic form type */ (defconstant +VT_ISYM+ 52) ; /* instantiated symbol type */ (defconstant +VT_SUBSUMPTION+ 53) ; /* an AVPair plus generation number */ (defconstant +VT_USER1+ 54) ; /* user defined tuple types. first slot gives size */ (defconstant +VT_USER2+ 55) ; /* use get_next_user_type_id */ (defconstant +VT_USER3+ 56) ; (defconstant +VT_USER_MAX+ 100) ; /* last user-defined tuple type */ (defconstant +VT_TUPLE+ 101) ; /* generic tuple types. size given in type name */ (defconstant +VT_1_TUPLE+ 102) ; /* VT_1_TUPLE used in arglist of intransitive verbs */ (defconstant +VT_2_TUPLE+ 103) ; (defconstant +VT_3_TUPLE+ 104) ; (defconstant +VT_4_TUPLE+ 105) ; (defconstant +VT_5_TUPLE+ 106) ; (defconstant +VT_MAX+ 200) ; /* so that the compiler knows how much storage to allocate */ ;; /* ------------------------------------------------------------------------- */ ;; struct TypedValue { (define-foreign-type TypedValue ;; ValueType type ; /* the type of the value */ (type :unsigned-int) ;; void *value ; /* the value itself */ (value :unsigned-long)) #|| /* ------------------------------------------------------------------------- */ enum CVProps { SUBC = 1, /* The constraint f =c a is satisfied only if there is */ /* another constraint f = a. This type of constraint is */ /* called a subc constraint because of the c that follows */ /* the equality sign. */ NEGATED = 2, /* For constraints like f ~= a. */ LAZY = 4, /* Used for lazy equality links, both vertical copy links, */ /* and horizontal re-entrancy links. */ }; enum Completed { UNCHECKED = 0, /* hasn't been checked for completeness */ NEVER_COMPLETED = 1, COMPLETED_OUT_OF_CONTEXT = 2, /* there was a completing fact, but it */ /* was in a disjoint context */ COMPLETED = 3, /* eventually completed */ }; ||# ;; /* ------------------------------------------------------------------------ */ ;; /* A CVPair represents a contexted value plus some properties of the */ ;; /* relation. The relation and one of its arguments is implicit in the */ ;; /* location of the CVPair. For instance, if a CVPair is under the RVPair */ ;; /* of a particular AVPair, then the RVPair gives the relation, the AVPair */ ;; /* one of its arguments, and the remainder of the arguments are given by */ ;; /* the value (it may be a tuple of values). Whether this instance of the */ ;; /* relation is negated, subc, or lazy is stored on the CVPair. This allows */ ;; /* us to store negated and non-negated values together, as well as subc and */ ;; /* non-subc values. */ ;; /* ------------------------------------------------------------------------ */ ;; struct CVPair { (define-foreign-type CVPair ;; Clause *contexts[2] ; /* old and new contexts (used by */ ; /* process_new_facts to make sure that */ ; /* deductions are only made once. */ (contexts #+allegro(:array :unsigned-long 2) #+sbcl(array :unsigned-long 2)) ;; TypedValue value ; /* the typed value (may be a tuple of values) */ (value TypedValue) ;; unsigned short freed : 1 ; /* for debugging. */ (freed (#+allegro :bit #+sbcl integer 1)) ;; unsigned short solutioncontext : 1 ; /* contexts[0] is a RestrictedSolution */ ; /* instead of a Clause */ (solutioncontext (#+allegro :bit #+sbcl integer 1)) ;; unsigned short bypass : 1 ; /* This is the current bypass link. */ (bypass (#+allegro :bit #+sbcl integer 1)) ;; unsigned short discharged : 1 ; /* This lazy link has been discharged. */ (discharged (#+allegro :bit #+sbcl integer 1)) ;; unsigned short backlink : 1 ; /* This lazy link was added as a backlink. */ (backlink (#+allegro :bit #+sbcl integer 1)) ;; unsigned short recopy : 1 ; /* This equality link needs to be recopied. */ (recopy (#+allegro :bit #+sbcl integer 1)) ;; unsigned short props : 5 ; /* same as CVProps, but saves storage */ (props (#+allegro :bit #+sbcl integer 5)) ;; unsigned short completed : 2 ; /* same as Completed, but saves storage */ (completed (#+allegro :bit #+sbcl integer 2)) ;; CVPair *next ; /* next cvpair in the list */ (next :unsigned-long)) #|| /* fields of instantiated symbol */ #define IS_LENGTH 0 #define IS_GENSYM 1 #define IS_BASESYMBOL 2 #define coerce_to_avpair(tv) \ ((tv).type == VT_AVP ? (AVPair *)(tv).value : \ (AVPair *)printf("Type fault at %s:%d\n", __FILE__, __LINE__)) #endif ||# :EOF