00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #define IFTHEN_SUCCEED XSB_Next_Instr()
00030 #define IFTHEN_FAILED Fail1 ; XSB_Next_Instr();
00031
00032
00033 #define COND1 (CPtr)(op1) < hreg || (CPtr)(op1) < hfreg
00034 #define COND2 (CPtr)(op2) < hreg || (CPtr)(op2) < hfreg
00035
00036 #define attv_dbgmsg(String) xsb_dbgmsg((LOG_ATTV,String))
00037
00038 #define unify_xsb(loc) \
00039 loc##_tail_recursion: \
00040 XSB_Deref2(op1, goto loc##_label_op1_free); \
00041 XSB_Deref2(op2, goto loc##_label_op2_free); \
00042 \
00043 if (isattv(op1)) goto loc##_label_op1_attv; \
00044 if (isattv(op2)) goto loc##_label_op2_attv; \
00045 \
00046 if (isfloat(op2) && isboxedfloat(op1) ) { \
00047 if ( float_val(op2) == (float)boxedfloat_val(op1)) \
00048 {IFTHEN_SUCCEED;} \
00049 else \
00050 {IFTHEN_FAILED;} \
00051 } \
00052 if (isfloat(op1) && isboxedfloat(op2) ) { \
00053 if ( float_val(op1) == (float)boxedfloat_val(op2)) \
00054 {IFTHEN_SUCCEED;} \
00055 else \
00056 {IFTHEN_FAILED;} \
00057 } \
00058 \
00059 if (cell_tag(op1) != cell_tag(op2)) \
00060 {IFTHEN_FAILED;} \
00061 \
00062 if (isconstr(op1)) goto loc##_label_both_struct; \
00063 if (islist(op1)) goto loc##_label_both_list; \
00064 \
00065 if (op1 == op2) {IFTHEN_SUCCEED;} \
00066 IFTHEN_FAILED; \
00067 \
00068 loc##_label_op1_free: \
00069 XSB_Deref2(op2, goto loc##_label_both_free); \
00070 bind_copy((CPtr)(op1), op2); \
00071 IFTHEN_SUCCEED; \
00072 \
00073 loc##_label_op2_free: \
00074 bind_copy((CPtr)(op2), op1); \
00075 IFTHEN_SUCCEED; \
00076 \
00077 loc##_label_both_free: \
00078 if ( (CPtr)(op1) == (CPtr)(op2) ) {IFTHEN_SUCCEED;} \
00079 if ( (CPtr)(op1) < (CPtr)(op2) ) \
00080 { \
00081 if (COND1) \
00082 \
00083 { bind_ref((CPtr)(op2), (CPtr)(op1)); } \
00084 else \
00085 { bind_ref((CPtr)(op1), (CPtr)(op2)); } \
00086 } \
00087 else \
00088 { \
00089 if (COND2) \
00090 { bind_ref((CPtr)(op1), (CPtr)(op2)); } \
00091 else \
00092 { bind_ref((CPtr)(op2), (CPtr)(op1)); } \
00093 } \
00094 IFTHEN_SUCCEED; \
00095 \
00096 loc##_label_both_list: \
00097 if (op1 == op2) {IFTHEN_SUCCEED;} \
00098 \
00099 op1 = (Cell)(clref_val(op1)); \
00100 op2 = (Cell)(clref_val(op2)); \
00101 if ( !unify(CTXTc cell((CPtr)op1), cell((CPtr)op2))) \
00102 { IFTHEN_FAILED; } \
00103 op1 = (Cell)((CPtr)op1+1); \
00104 op2 = (Cell)((CPtr)op2+1); \
00105 goto loc##_tail_recursion; \
00106 \
00107 loc##_label_both_struct: \
00108 if (op1 == op2) {IFTHEN_SUCCEED;} \
00109 \
00110 \
00111 op1 = (Cell)(clref_val(op1)); \
00112 op2 = (Cell)(clref_val(op2)); \
00113 if (((Pair)(CPtr)op1)->psc_ptr!=((Pair)(CPtr)op2)->psc_ptr)\
00114 { \
00115 \
00116 IFTHEN_FAILED; \
00117 } \
00118 { \
00119 int arity = get_arity(((Pair)(CPtr)op1)->psc_ptr); \
00120 while (--arity) \
00121 { \
00122 op1 = (Cell)((CPtr)op1+1); op2 = (Cell)((CPtr)op2+1);\
00123 if (!unify(CTXTc cell((CPtr)op1), cell((CPtr)op2))) \
00124 { \
00125 IFTHEN_FAILED; \
00126 } \
00127 } \
00128 op1 = (Cell)((CPtr)op1+1); op2 = (Cell)((CPtr)op2+1); \
00129 goto loc##_tail_recursion; \
00130 } \
00131 \
00132 \
00133 \
00134 \
00135 \
00136 \
00137 \
00138 loc##_label_op1_attv: \
00139 if (isattv(op2)) goto loc##_label_both_attv; \
00140 attv_dbgmsg(">>>> ATTV = something, interrupt needed\n"); \
00141 add_interrupt(CTXTc cell(((CPtr)dec_addr(op1) + 1)),op2); \
00142 bind_copy((CPtr)dec_addr(op1), op2); \
00143 IFTHEN_SUCCEED; \
00144 \
00145 loc##_label_op2_attv: \
00146 attv_dbgmsg(">>>> something = ATTV, interrupt needed\n"); \
00147 add_interrupt(CTXTc cell(((CPtr)dec_addr(op2) + 1)),op1); \
00148 bind_copy((CPtr)dec_addr(op2), op1); \
00149 IFTHEN_SUCCEED; \
00150 \
00151 loc##_label_both_attv: \
00152 if (op1 != op2) \
00153 { \
00154 attv_dbgmsg(">>>> ATTV = ???, interrupt needed\n"); \
00155 add_interrupt(CTXTc cell(((CPtr)dec_addr(op1) + 1)),op2); \
00156 bind_copy((CPtr)dec_addr(op1), op2); \
00157 } \
00158 IFTHEN_SUCCEED
00159
00160
00161