From afd8c9b9c498874e6e1706257bd12b3188d15204 Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Tue, 10 Feb 2015 00:03:02 +0000 Subject: [PATCH] blanks and backslashed strings --- C/grow.c | 82 +- C/iopreds.c | 108 +- C/parser.c | 993 +++--- C/scanner.c | 1807 ++++++----- C/write.c | 859 +++-- CMakeLists.txt | 15 +- H/ScannerTypes.h | 2 +- H/amijit.h | 2 +- H/yapio.h | 32 - JIT/CMakeLists.txt | 9 +- os/pl-prologflag.c | 7 +- os/pl-utf8.c | 44 +- os/pl-utf8.h | 4 + os/pl-write.c | 48 +- packages/clib | 2 +- packages/gecode/gecode.yap | 4859 +++++++++++++++++++++++++++- packages/odbc | 2 +- packages/python/python.c | 130 +- packages/raptor | 2 +- packages/swig/android/JavaYap.java | 32 +- 20 files changed, 6953 insertions(+), 2086 deletions(-) diff --git a/C/grow.c b/C/grow.c index a18dfc23d..0725bfb8d 100755 --- a/C/grow.c +++ b/C/grow.c @@ -168,7 +168,7 @@ SetHeapRegs(bool copying_threads USES_REGS) if (IsOldGlobalPtr(S)) S = PtoGloAdjust(S); else if (IsOldLocalPtr(S)) - S = PtoLocAdjust(S); + S = PtoLocAdjust(S); if (!copying_threads) { if (LOCAL_GlobalArena) LOCAL_GlobalArena = AbsAppl(PtoGloAdjust(RepAppl(LOCAL_GlobalArena))); @@ -262,7 +262,7 @@ RestoreTrail(int worker_p USES_REGS) *((CELL *) aux_cell) = worker_p_binding(worker_p, CellPtr(aux_cell)); #endif /* TABLING */ } -#ifdef TABLING +#ifdef TABLING } else if (IsPairTerm(aux_cell)) { /* avoid frozen segments */ aux_cell = (CELL) RepPair(aux_cell); @@ -273,7 +273,7 @@ RestoreTrail(int worker_p USES_REGS) #ifdef MULTI_ASSIGNMENT_VARIABLES } else if (IsApplTerm(aux_cell)) { CELL *cell_ptr = RepAppl(aux_cell); - if (((CELL *)aux_cell < Get_LOCAL_top_cp()->cp_h || + if (((CELL *)aux_cell < Get_LOCAL_top_cp()->cp_h || EQUAL_OR_YOUNGER_CP(Get_LOCAL_top_cp(), (choiceptr)aux_cell)) && !Yap_lookup_ma_var(cell_ptr PASS_REGS)) { /* first time we found the variable, let's put the new value */ @@ -297,9 +297,9 @@ MoveGlobal( USES_REGS1 ) { /* * cpcellsd(To,From,NOfCells) - copy the cells downwards - in - * absmi.asm + * absmi.asm */ - cpcellsd((CELL *)LOCAL_GlobalBase, (CELL *)LOCAL_OldGlobalBase, LOCAL_OldH - (CELL *)LOCAL_OldGlobalBase); + cpcellsd((CELL *)LOCAL_GlobalBase, (CELL *)LOCAL_OldGlobalBase, LOCAL_OldH - (CELL *)LOCAL_OldGlobalBase); } static void @@ -307,9 +307,9 @@ MoveExpandedGlobal( USES_REGS1 ) { /* * cpcellsd(To,From,NOfCells) - copy the cells downwards - in - * absmi.asm + * absmi.asm */ - cpcellsd((CELL *)(LOCAL_GlobalBase+(LOCAL_GDiff-LOCAL_BaseDiff)), (CELL *)LOCAL_GlobalBase, LOCAL_OldH - (CELL *)LOCAL_OldGlobalBase); + cpcellsd((CELL *)(LOCAL_GlobalBase+(LOCAL_GDiff-LOCAL_BaseDiff)), (CELL *)LOCAL_GlobalBase, LOCAL_OldH - (CELL *)LOCAL_OldGlobalBase); } static void @@ -317,12 +317,12 @@ MoveGlobalWithHole( USES_REGS1 ) { /* * cpcellsd(To,From,NOfCells) - copy the cells downwards - in - * absmi.asm + * absmi.asm */ #if USE_SYSTEM_MALLOC - cpcellsd((CELL *)((char *)LOCAL_GlobalBase+(LOCAL_GDiff0-LOCAL_BaseDiff)), (CELL *)LOCAL_GlobalBase, LOCAL_OldH - (CELL *)LOCAL_OldGlobalBase); + cpcellsd((CELL *)((char *)LOCAL_GlobalBase+(LOCAL_GDiff0-LOCAL_BaseDiff)), (CELL *)LOCAL_GlobalBase, LOCAL_OldH - (CELL *)LOCAL_OldGlobalBase); #else - cpcellsd((CELL *)((char *)LOCAL_OldGlobalBase+LOCAL_GDiff0), (CELL *)LOCAL_OldGlobalBase, LOCAL_OldH - (CELL *)LOCAL_OldGlobalBase); + cpcellsd((CELL *)((char *)LOCAL_OldGlobalBase+LOCAL_GDiff0), (CELL *)LOCAL_OldGlobalBase, LOCAL_OldH - (CELL *)LOCAL_OldGlobalBase); #endif } @@ -331,7 +331,7 @@ MoveHalfGlobal(CELL *OldPt USES_REGS) { /* * cpcellsd(To,From,NOfCells) - copy the cells downwards - in - * absmi.asm + * absmi.asm */ UInt diff = LOCAL_OldH-OldPt; CELL *NewPt = (CELL *)((char*)OldPt+LOCAL_GDiff); @@ -527,7 +527,7 @@ AdjustGlobal(Int sz, bool thread_copying USES_REGS) /* * to clean the global now that functors are just variables pointing to - * the code + * the code */ #if defined(YAPOR_THREADS) if (thread_copying == STACK_INCREMENTAL_COPYING) { @@ -673,7 +673,7 @@ AdjustRegs(int n USES_REGS) { int i; CELL reg; - + for (i = 1; i < n; ++i) { reg = (CELL) XREGS[i]; if (IsVarTerm(reg)) { @@ -734,11 +734,13 @@ AdjustScannerStacks(TokEntry **tksp, VarEntry **vep USES_REGS) if (IsApplTerm(tks->TokInfo)) { tks->TokInfo = AdjustAppl(tks->TokInfo PASS_REGS); } - break; + break; case Var_tok: case String_tok: - if (IsOldTrail(tks->TokInfo)) - tks->TokInfo = TrailAdjust(tks->TokInfo); + case WString_tok: + case StringTerm_tok: + if (IsOldTrail(tks->TokInfo)) + tks->TokInfo = TrailAdjust(tks->TokInfo); break; case Name_tok: tks->TokInfo = (Term)AtomAdjust((Atom)(tks->TokInfo)); @@ -854,7 +856,7 @@ static_growheap(size_t esize, bool fix_code, struct intermediates *cip, tr_fr_pt } AdjustRegs(MaxTemps PASS_REGS); ASP += 256; - if (minimal_request) + if (minimal_request) Yap_AllocHole(minimal_request, size); YAPLeaveCriticalSection(); growth_time = Yap_cputime()-start_growth_time; @@ -914,7 +916,7 @@ static_growglobal(size_t request, CELL **ptr, CELL *hsplit USES_REGS) if (Unsigned(HR)+size < Unsigned(ASP)-CreepFlag) { /* we can just ask for more room */ do_grow = FALSE; - } + } } if (do_grow) { if (size < YAP_ALLOC_SIZE) @@ -934,7 +936,7 @@ static_growglobal(size_t request, CELL **ptr, CELL *hsplit USES_REGS) if (!GLOBAL_AllowGlobalExpansion || !Yap_ExtendWorkSpace(size)) { /* always fails when using malloc */ LOCAL_ErrorMessage = NULL; - size += AdjustPageSize(((CELL)LOCAL_TrailTop-(CELL)LOCAL_GlobalBase)+MinHeapGap); + size += AdjustPageSize(((CELL)LOCAL_TrailTop-(CELL)LOCAL_GlobalBase)+MinHeapGap); minimal_request = size; size = Yap_ExtendWorkSpaceThroughHole(size); if (size < 0) { @@ -985,7 +987,7 @@ static_growglobal(size_t request, CELL **ptr, CELL *hsplit USES_REGS) LOCAL_LDiff = LOCAL_TrDiff = 0; LOCAL_BaseDiff = 0; } - /* now, remember we have delay -- global with a hole in delay or a + /* now, remember we have delay -- global with a hole in delay or a hole in global */ if (!hsplit) { if (!do_grow) { @@ -1251,7 +1253,7 @@ fix_compiler_instructions(PInstr *pcpc USES_REGS) #ifdef TABLING static void -fix_tabling_info( USES_REGS1 ) +fix_tabling_info( USES_REGS1 ) { /* we must fix the dependency frames and the subgoal frames, as they are pointing back to the global stack. */ @@ -1575,7 +1577,7 @@ execute_growstack(size_t esize0, bool from_trail, bool in_parser, tr_fr_ptr *old Int size0 = esize0; Int size = size0; ADDR old_LOCAL_GlobalBase = LOCAL_GlobalBase; - + if (!GLOBAL_AllowGlobalExpansion) { LOCAL_ErrorMessage = "Database crashed against stacks"; return FALSE; @@ -1583,7 +1585,7 @@ execute_growstack(size_t esize0, bool from_trail, bool in_parser, tr_fr_ptr *old if (!Yap_ExtendWorkSpace(size)) { /* make sure stacks and trail are contiguous */ - LOCAL_ErrorMessage = NULL; + LOCAL_ErrorMessage = NULL; minimal_request = AdjustPageSize(((CELL)LOCAL_TrailTop-(CELL)LOCAL_GlobalBase)+4*MinHeapGap+size0); size = Yap_ExtendWorkSpaceThroughHole(minimal_request); @@ -1667,7 +1669,7 @@ execute_growstack(size_t esize0, bool from_trail, bool in_parser, tr_fr_ptr *old } YAPLeaveCriticalSection(); ASP += 256; - if (minimal_request) + if (minimal_request) Yap_AllocHole(minimal_request, size); return TRUE; } @@ -1762,7 +1764,7 @@ static int do_growtrail(size_t esize, bool contiguous_only, bool in_parser, tr_f return FALSE; #endif /* at least 64K for trail */ - if (!size) + if (!size) size = ((ADDR)TR-LOCAL_TrailBase); size *= 2; if (size < YAP_ALLOC_SIZE) @@ -1829,7 +1831,7 @@ static int do_growtrail(size_t esize, bool contiguous_only, bool in_parser, tr_f /* Used by do_goal() when we're short of stack space */ int Yap_growtrail(size_t size, bool contiguous_only) -{ +{ int rc; CACHE_REGS rc = do_growtrail(size, contiguous_only, FALSE, NULL, NULL, NULL PASS_REGS); @@ -1839,7 +1841,7 @@ Yap_growtrail(size_t size, bool contiguous_only) /* Used by do_goal() when we're short of stack space */ int Yap_locked_growtrail(size_t size, bool contiguous_only) -{ +{ CACHE_REGS return do_growtrail(size, contiguous_only, FALSE, NULL, NULL, NULL PASS_REGS); } @@ -1871,7 +1873,7 @@ Yap_shift_visit(CELL **to_visit, CELL ***to_visit_maxp, CELL ***to_visit_base) char *newb = Yap_ExpandPreAllocCodeSpace(0, NULL, FALSE); if (newb == NULL) { - Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"cannot allocate temporary space for unification (%p)", to_visit); + Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"cannot allocate temporary space for unification (%p)", to_visit); return to_visit; } /* check new size */ @@ -1879,7 +1881,7 @@ Yap_shift_visit(CELL **to_visit, CELL ***to_visit_maxp, CELL ***to_visit_base) /* how much we grew */ dsz = totalsz-totalsz0; if (dsz == 0) { - Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"cannot allocate temporary space for unification (%p)", to_visit); + Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"cannot allocate temporary space for unification (%p)", to_visit); return to_visit; } /* copy whole block to end */ @@ -1898,7 +1900,7 @@ p_inform_trail_overflows( USES_REGS1 ) { Term tn = MkIntTerm(LOCAL_trail_overflows); Term tt = MkIntegerTerm(LOCAL_total_trail_overflow_time); - + return(Yap_unify(tn, ARG1) && Yap_unify(tt, ARG2)); } @@ -1928,7 +1930,7 @@ p_inform_heap_overflows( USES_REGS1 ) { Term tn = MkIntTerm(LOCAL_heap_overflows); Term tt = MkIntegerTerm(LOCAL_total_heap_overflow_time); - + return(Yap_unify(tn, ARG1) && Yap_unify(tt, ARG2)); } @@ -1973,13 +1975,13 @@ Yap_CopyThreadStacks(int worker_q, int worker_p, bool incremental) YAPEnterCriticalSection(); SetHeapRegs(FALSE PASS_REGS); { - choiceptr imageB; + choiceptr imageB; LOCAL_OldLCL0 = LCL0; LCL0 = REMOTE_ThreadHandle(0).current_yaam_regs->LCL0_; imageB = Get_GLOBAL_root_cp(); /* we know B */ - B->cp_tr = TR = + B->cp_tr = TR = (tr_fr_ptr)((CELL)(imageB->cp_tr)+((CELL)LOCAL_OldLCL0-(CELL)LCL0)); LCL0 = LOCAL_OldLCL0; B->cp_h = H0; @@ -2024,17 +2026,17 @@ Yap_CopyThreadStacks(int worker_q, int worker_p, bool incremental) SetHeapRegs(TRUE PASS_REGS); if (incremental) { IncrementalCopyStacksFromWorker( PASS_REGS1 ); - LOCAL_start_global_copy = + LOCAL_start_global_copy = (CELL)PtoGloAdjust((CELL *)LOCAL_start_global_copy); - LOCAL_end_global_copy = + LOCAL_end_global_copy = (CELL)PtoGloAdjust((CELL *)LOCAL_end_global_copy); - LOCAL_start_local_copy = + LOCAL_start_local_copy = (CELL)PtoLocAdjust((CELL *)LOCAL_start_local_copy); - LOCAL_end_local_copy = + LOCAL_end_local_copy = (CELL)PtoLocAdjust((CELL *)LOCAL_end_local_copy); - LOCAL_start_trail_copy = + LOCAL_start_trail_copy = (CELL)PtoTRAdjust((tr_fr_ptr)LOCAL_start_trail_copy); - LOCAL_end_trail_copy = + LOCAL_end_trail_copy = (CELL)PtoTRAdjust((tr_fr_ptr)LOCAL_end_trail_copy); AdjustStacksAndTrail(0, STACK_INCREMENTAL_COPYING PASS_REGS); RestoreTrail(worker_p PASS_REGS); @@ -2073,7 +2075,7 @@ p_inform_stack_overflows( USES_REGS1 ) { /* */ Term tn = MkIntTerm(LOCAL_stack_overflows); Term tt = MkIntegerTerm(LOCAL_total_stack_overflow_time); - + return(Yap_unify(tn, ARG1) && Yap_unify(tt, ARG2)); } diff --git a/C/iopreds.c b/C/iopreds.c index cb6561aa2..35362ae66 100644 --- a/C/iopreds.c +++ b/C/iopreds.c @@ -20,7 +20,7 @@ static char SccsId[] = "%W% %G%"; /* * This file includes the definition of a miscellania of standard predicates - * for yap refering to: Files and Streams, Simple Input/Output, + * for yap refering to: Files and Streams, Simple Input/Output, * */ @@ -51,7 +51,7 @@ static char SccsId[] = "%W% %G%"; #ifdef HAVE_SYS_STAT_H #include #endif -#if HAVE_SYS_SELECT_H && !_MSC_VER && !defined(__MINGW32__) +#if HAVE_SYS_SELECT_H && !_MSC_VER && !defined(__MINGW32__) #include #endif #ifdef HAVE_UNISTD_H @@ -79,7 +79,7 @@ static char SccsId[] = "%W% %G%"; #if !HAVE_STRNCPY #define strncpy(X,Y,Z) strcpy(X,Y) #endif -#if _MSC_VER || defined(__MINGW32__) +#if _MSC_VER || defined(__MINGW32__) #include #ifndef S_ISDIR #define S_ISDIR(x) (((x)&_S_IFDIR)==_S_IFDIR) @@ -132,7 +132,7 @@ static YP_File curfile; #ifdef MACC -static void +static void InTTYLine(char *line) { char *p = line; @@ -149,7 +149,7 @@ InTTYLine(char *line) #endif -void +void Yap_DebugSetIFile(char *fname) { if (curfile) @@ -161,14 +161,14 @@ Yap_DebugSetIFile(char *fname) } } -void +void Yap_DebugEndline() { *lp = 0; } -int +int Yap_DebugGetc() { int ch; @@ -191,7 +191,7 @@ Yap_DebugGetc() return (ch); } -int +int Yap_DebugPutc(int sno, wchar_t ch) { if (GLOBAL_Option['l' - 96]) @@ -199,7 +199,7 @@ Yap_DebugPutc(int sno, wchar_t ch) return (Sputc(ch, GLOBAL_stderr)); } -static int +static int Yap_DebugPuts(int sno, const char * s) { if (GLOBAL_Option['l' - 96]) @@ -213,14 +213,14 @@ Yap_DebugPlWrite(Term t) Yap_plwrite(t, NULL, 15, 0, 1200); } -void +void Yap_DebugErrorPutc(int c) { CACHE_REGS Yap_DebugPutc (LOCAL_c_error_stream, c); } -void +void Yap_DebugErrorPuts(const char *s) { CACHE_REGS @@ -350,19 +350,25 @@ syntax_error (TokEntry * tokptr, IOSTREAM *st, Term *outp) ts[0] = Yap_MkApplTerm(Yap_MkFunctor(AtomGVar,3),3,t); } break; - case String_tok: - { - Term t0 = Yap_CharsToListOfCodes((const char *)info PASS_REGS); - ts[0] = Yap_MkApplTerm(Yap_MkFunctor(AtomString,1),1,&t0); - } - break; - case WString_tok: - { - Term t0 = Yap_WCharsToListOfCodes((const wchar_t *)info PASS_REGS); - ts[0] = Yap_MkApplTerm(Yap_MkFunctor(AtomString,1),1,&t0); - } - break; - case Error_tok: + case String_tok: + { + Term t0 = Yap_CharsToListOfCodes((const char *)info PASS_REGS); + ts[0] = Yap_MkApplTerm(Yap_MkFunctor(AtomString,1),1,&t0); + } + break; + case StringTerm_tok: + { + Term t0 = MkStringTerm((const char *)info); + ts[0] = Yap_MkApplTerm(Yap_MkFunctor(AtomString,1),1,&t0); + } + break; + case WString_tok: + { + Term t0 = Yap_WCharsToListOfCodes((const wchar_t *)info PASS_REGS); + ts[0] = Yap_MkApplTerm(Yap_MkFunctor(AtomString,1),1,&t0); + } + break; + case Error_tok: case eot_tok: break; case Ponctuation_tok: @@ -370,7 +376,7 @@ syntax_error (TokEntry * tokptr, IOSTREAM *st, Term *outp) char s[2]; s[1] = '\0'; s[0] = (char)info; - if (s[0] == 'l') + if (s[0] == 'l') s[0] = '('; ts[0] = MkAtomTerm(Yap_LookupAtom(s)); } @@ -587,7 +593,7 @@ Yap_read_term(term_t t0, IOSTREAM *inp_stream, struct read_data_t *rd) HR = old_H; TR = (tr_fr_ptr)LOCAL_ScannerStack; - + if (!strcmp(LOCAL_ErrorMessage,"Stack Overflow")) res = Yap_growstack_in_parser(&old_TR, &tokstart, &LOCAL_VarTable); else if (!strcmp(LOCAL_ErrorMessage,"Heap Overflow")) @@ -611,7 +617,7 @@ Yap_read_term(term_t t0, IOSTREAM *inp_stream, struct read_data_t *rd) if (LOCAL_ErrorMessage == NULL) LOCAL_ErrorMessage = "SYNTAX ERROR"; GenerateSyntaxError(&terror, tokstart, inp_stream, MkAtomTerm(Yap_LookupAtom(LOCAL_ErrorMessage)) PASS_REGS); - + Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable, LOCAL_Comments); rd->has_exception = TRUE; rd->exception = Yap_InitSlot(terror PASS_REGS); @@ -745,7 +751,7 @@ p_type_of_char ( USES_REGS1 ) } -static Int +static Int p_force_char_conversion( USES_REGS1 ) { /* don't actually enable it until someone tries to add a conversion */ @@ -755,14 +761,14 @@ p_force_char_conversion( USES_REGS1 ) return(TRUE); } -static Int +static Int p_disable_char_conversion( USES_REGS1 ) { CharConversionTable = NULL; return(TRUE); } -static Int +static Int p_char_conversion( USES_REGS1 ) { Term t0 = Deref(ARG1), t1 = Deref(ARG2); @@ -770,29 +776,29 @@ p_char_conversion( USES_REGS1 ) if (IsVarTerm(t0)) { Yap_Error(INSTANTIATION_ERROR, t0, "char_conversion/2"); - return (FALSE); + return (FALSE); } if (!IsAtomTerm(t0)) { Yap_Error(REPRESENTATION_ERROR_CHARACTER, t0, "char_conversion/2"); - return (FALSE); + return (FALSE); } s0 = RepAtom(AtomOfTerm(t0))->StrOfAE; if (s0[1] != '\0') { Yap_Error(REPRESENTATION_ERROR_CHARACTER, t0, "char_conversion/2"); - return (FALSE); + return (FALSE); } if (IsVarTerm(t1)) { Yap_Error(INSTANTIATION_ERROR, t1, "char_conversion/2"); - return (FALSE); + return (FALSE); } if (!IsAtomTerm(t1)) { Yap_Error(REPRESENTATION_ERROR_CHARACTER, t1, "char_conversion/2"); - return (FALSE); + return (FALSE); } s1 = RepAtom(AtomOfTerm(t1))->StrOfAE; if (s1[1] != '\0') { Yap_Error(REPRESENTATION_ERROR_CHARACTER, t1, "char_conversion/2"); - return (FALSE); + return (FALSE); } /* check if we do have a table for converting characters */ if (CharConversionTable2 == NULL) { @@ -813,7 +819,7 @@ p_char_conversion( USES_REGS1 ) if (p_force_char_conversion( PASS_REGS1 ) == FALSE) return(FALSE); } - for (i = 0; i < NUMBER_OF_CHARS; i++) + for (i = 0; i < NUMBER_OF_CHARS; i++) CharConversionTable2[i] = i; } /* just add the new entry */ @@ -822,7 +828,7 @@ p_char_conversion( USES_REGS1 ) return(TRUE); } -static Int +static Int p_current_char_conversion( USES_REGS1 ) { Term t0, t1; @@ -834,16 +840,16 @@ p_current_char_conversion( USES_REGS1 ) t0 = Deref(ARG1); if (IsVarTerm(t0)) { Yap_Error(INSTANTIATION_ERROR, t0, "current_char_conversion/2"); - return (FALSE); + return (FALSE); } if (!IsAtomTerm(t0)) { Yap_Error(REPRESENTATION_ERROR_CHARACTER, t0, "current_char_conversion/2"); - return (FALSE); + return (FALSE); } s0 = RepAtom(AtomOfTerm(t0))->StrOfAE; if (s0[1] != '\0') { Yap_Error(REPRESENTATION_ERROR_CHARACTER, t0, "current_char_conversion/2"); - return (FALSE); + return (FALSE); } t1 = Deref(ARG2); if (IsVarTerm(t1)) { @@ -855,19 +861,19 @@ p_current_char_conversion( USES_REGS1 ) } if (!IsAtomTerm(t1)) { Yap_Error(REPRESENTATION_ERROR_CHARACTER, t1, "current_char_conversion/2"); - return (FALSE); + return (FALSE); } s1 = RepAtom(AtomOfTerm(t1))->StrOfAE; if (s1[1] != '\0') { Yap_Error(REPRESENTATION_ERROR_CHARACTER, t1, "current_char_conversion/2"); - return (FALSE); + return (FALSE); } else { return (CharConversionTable[(int)s0[0]] == '\0' && CharConversionTable[(int)s0[0]] == s1[0] ); } } -static Int +static Int p_all_char_conversions( USES_REGS1 ) { Term out = TermNil; @@ -904,7 +910,7 @@ p_float_format( USES_REGS1 ) } -static Int +static Int p_style_checker( USES_REGS1 ) { Term t = Deref( ARG1 ); @@ -940,7 +946,7 @@ p_style_checker( USES_REGS1 ) if (IsVarTerm(h)) { Yap_Error(INSTANTIATION_ERROR, t, "style_check/1"); - return (FALSE); + return (FALSE); } if (IsAtomTerm(h)) { Atom at = AtomOfTerm( h ); if (at == AtomAtom) debugstatus.styleCheck |= LONGATOM_CHECK; @@ -999,7 +1005,7 @@ Yap_InitIOPreds(void) Yap_InitCPred ("$change_type_of_char", 2, p_change_type_of_char, SafePredFlag|SyncPredFlag); Yap_InitCPred ("$type_of_char", 2, p_type_of_char, SafePredFlag|SyncPredFlag); Yap_InitCPred ("char_conversion", 2, p_char_conversion, SyncPredFlag); -/** @pred char_conversion(+ _IN_,+ _OUT_) is iso +/** @pred char_conversion(+ _IN_,+ _OUT_) is iso While reading terms convert unquoted occurrences of the character @@ -1014,7 +1020,7 @@ convert characters from the ISO-LATIN-1 character set to ASCII. If _IN_ is the same character as _OUT_, char_conversion/2 will remove this conversion from the table. - + */ Yap_InitCPred ("$current_char_conversion", 2, p_current_char_conversion, SyncPredFlag); Yap_InitCPred ("$all_char_conversions", 1, p_all_char_conversions, SyncPredFlag); @@ -1022,11 +1028,11 @@ will remove this conversion from the table. Yap_InitCPred ("$disable_char_conversion", 0, p_disable_char_conversion, SyncPredFlag); #if HAVE_SELECT // Yap_InitCPred ("stream_select", 3, p_stream_select, SafePredFlag|SyncPredFlag); -/** @pred stream_select(+ _STREAMS_,+ _TIMEOUT_,- _READSTREAMS_) +/** @pred stream_select(+ _STREAMS_,+ _TIMEOUT_,- _READSTREAMS_) Given a list of open _STREAMS_ opened in read mode and a _TIMEOUT_ -return a list of streams who are now available for reading. +return a list of streams who are now available for reading. If the _TIMEOUT_ is instantiated to `off`, stream_select/3 will wait indefinitely for a stream to become @@ -1037,7 +1043,7 @@ and `USECS` adds the number of micro-seconds. This built-in is only defined if the system call `select` is available in the system. - + */ #endif Yap_InitCPred ("$float_format", 1, p_float_format, SafePredFlag|SyncPredFlag); diff --git a/C/parser.c b/C/parser.c index 3b008aa36..fcfb87be7 100755 --- a/C/parser.c +++ b/C/parser.c @@ -93,11 +93,11 @@ Notes: +(a,b) [the same as '+'(a,b) of arity two] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - + + + In the first rule for term(0) no blank space should exist between \a atom and '('. - + + + Each term to be read by the YAP parser must end with a single dot, followed by a blank (in the sense mentioned in the previous paragraph). When a name consisting of a single dot could be taken for @@ -109,9 +109,9 @@ dot with single quotes. */ /* - * Description: + * Description: * - * parser: produces a prolog term from an array of tokens + * parser: produces a prolog term from an array of tokens * * parser usage: the parser takes its input from an array of token descriptions * addressed by the global variable 'tokptr' and produces a Term as result. A @@ -126,17 +126,16 @@ dot with single quotes. * version this auxiliary stack is assumed to grow downwards. This * assumption, however, is only relevant to routine 'ParseArgs', and to the * variable toktide. conclusion: set tokptr pointing to first token set AuxSp - * Call Parse + * Call Parse * - * VSC: Working whithout known bugs in 87/4/6 + * VSC: Working whithout known bugs in 87/4/6 * - * LD: -I or +I evaluated by parser 87/4/28 + * LD: -I or +I evaluated by parser 87/4/28 * - * LD: parser extended 87/4/28 + * LD: parser extended 87/4/28 * */ - #include "Yap.h" #include "Yatom.h" #include "YapHeap.h" @@ -151,75 +150,71 @@ dot with single quotes. #include #endif -#ifdef __STDC__XXX +#ifdef __STDC__XXX #define Volatile volatile #else #define Volatile #endif - /* weak backtraking mechanism based on long_jump */ -typedef struct jmp_buff_struct { - sigjmp_buf JmpBuff; -} JMPBUFF; +typedef struct jmp_buff_struct { sigjmp_buf JmpBuff; } JMPBUFF; -static void GNextToken( CACHE_TYPE1 ); -static void checkfor(wchar_t, JMPBUFF * CACHE_TYPE); +static void GNextToken(CACHE_TYPE1); +static void checkfor(wchar_t, JMPBUFF *CACHE_TYPE); static Term ParseArgs(read_data *, Atom, wchar_t, JMPBUFF *, Term CACHE_TYPE); -static Term ParseList(read_data *, JMPBUFF * CACHE_TYPE); -static Term ParseTerm(read_data *, int, JMPBUFF * CACHE_TYPE); +static Term ParseList(read_data *, JMPBUFF *CACHE_TYPE); +static Term ParseTerm(read_data *, int, JMPBUFF *CACHE_TYPE); +#define TRY(S, P) \ + { \ + Volatile JMPBUFF *saveenv, newenv; \ + Volatile TokEntry *saveT = LOCAL_tokptr; \ + Volatile CELL *saveH = HR; \ + Volatile int savecurprio = curprio; \ + saveenv = FailBuff; \ + if (!sigsetjmp(newenv.JmpBuff, 0)) { \ + FailBuff = &newenv; \ + S; \ + FailBuff = saveenv; \ + P; \ + } else { \ + FailBuff = saveenv; \ + HR = saveH; \ + curprio = savecurprio; \ + LOCAL_tokptr = saveT; \ + } \ + } -#define TRY(S,P) \ - { Volatile JMPBUFF *saveenv, newenv; \ - Volatile TokEntry *saveT=LOCAL_tokptr; \ - Volatile CELL *saveH=HR; \ - Volatile int savecurprio=curprio; \ - saveenv=FailBuff; \ - if(!sigsetjmp(newenv.JmpBuff, 0)) { \ - FailBuff = &newenv; \ - S; \ - FailBuff=saveenv; \ - P; \ - } \ - else { FailBuff=saveenv; \ - HR=saveH; \ - curprio = savecurprio; \ - LOCAL_tokptr=saveT; \ - } \ - } +#define TRY3(S, P, F) \ + { \ + Volatile JMPBUFF *saveenv, newenv; \ + Volatile TokEntry *saveT = LOCAL_tokptr; \ + Volatile CELL *saveH = HR; \ + saveenv = FailBuff; \ + if (!sigsetjmp(newenv.JmpBuff, 0)) { \ + FailBuff = &newenv; \ + S; \ + FailBuff = saveenv; \ + P; \ + } else { \ + FailBuff = saveenv; \ + HR = saveH; \ + LOCAL_tokptr = saveT; \ + F \ + } \ + } -#define TRY3(S,P,F) \ - { Volatile JMPBUFF *saveenv, newenv; \ - Volatile TokEntry *saveT=LOCAL_tokptr; \ - Volatile CELL *saveH=HR; \ - saveenv=FailBuff; \ - if(!sigsetjmp(newenv.JmpBuff, 0)) { \ - FailBuff = &newenv; \ - S; \ - FailBuff=saveenv; \ - P; \ - } \ - else { \ - FailBuff=saveenv; \ - HR=saveH; \ - LOCAL_tokptr=saveT; \ - F } \ - } +#define FAIL siglongjmp(FailBuff->JmpBuff, 1) - -#define FAIL siglongjmp(FailBuff->JmpBuff,1) - -VarEntry * -Yap_LookupVar(char *var) /* lookup variable in variables table */ +VarEntry *Yap_LookupVar(char *var) /* lookup variable in variables table */ { CACHE_REGS VarEntry *p; #if DEBUG if (GLOBAL_Option[4]) - fprintf(stderr,"[LookupVar %s]", var); + fprintf(stderr, "[LookupVar %s]", var); #endif if (var[0] != '_' || var[1] != '\0') { VarEntry **op = &LOCAL_VarTable; @@ -231,26 +226,26 @@ Yap_LookupVar(char *var) /* lookup variable in variables table */ while (p != NULL) { CELL hpv = p->hv; if (hv == hpv) { - Int scmp; - if ((scmp = strcmp(var, p->VarRep)) == 0) { - p->refs++; - return(p); - } else if (scmp < 0) { - op = &(p->VarLeft); - p = p->VarLeft; - } else { - op = &(p->VarRight); - p = p->VarRight; - } + Int scmp; + if ((scmp = strcmp(var, p->VarRep)) == 0) { + p->refs++; + return (p); + } else if (scmp < 0) { + op = &(p->VarLeft); + p = p->VarLeft; + } else { + op = &(p->VarRight); + p = p->VarRight; + } } else if (hv < hpv) { - op = &(p->VarLeft); - p = p->VarLeft; + op = &(p->VarLeft); + p = p->VarLeft; } else { - op = &(p->VarRight); - p = p->VarRight; + op = &(p->VarRight); + p = p->VarRight; } } - p = (VarEntry *) Yap_AllocScannerMemory(strlen(var) + sizeof(VarEntry)); + p = (VarEntry *)Yap_AllocScannerMemory(strlen(var) + sizeof(VarEntry)); *op = p; p->VarLeft = p->VarRight = NULL; p->hv = hv; @@ -258,10 +253,10 @@ Yap_LookupVar(char *var) /* lookup variable in variables table */ strcpy(p->VarRep, var); } else { /* anon var */ - p = (VarEntry *) Yap_AllocScannerMemory(sizeof(VarEntry) + 2); + p = (VarEntry *)Yap_AllocScannerMemory(sizeof(VarEntry) + 2); p->VarLeft = LOCAL_AnonVarTable; LOCAL_AnonVarTable = p; - p->VarRight = NULL; + p->VarRight = NULL; p->refs = 0L; p->hv = 1L; p->VarRep[0] = '_'; @@ -271,106 +266,94 @@ Yap_LookupVar(char *var) /* lookup variable in variables table */ return (p); } -static Term -VarNames(VarEntry *p,Term l USES_REGS) -{ +static Term VarNames(VarEntry *p, Term l USES_REGS) { if (p != NULL) { if (strcmp(p->VarRep, "_") != 0) { Term t[2]; Term o; - + t[0] = MkAtomTerm(Yap_LookupAtom(p->VarRep)); t[1] = p->VarAdr; o = Yap_MkApplTerm(FunctorEq, 2, t); o = MkPairTerm(o, VarNames(p->VarRight, - VarNames(p->VarLeft,l PASS_REGS) PASS_REGS)); - if (HR > ASP-4096) { - save_machine_regs(); - siglongjmp(LOCAL_IOBotch,1); - } - return(o); + VarNames(p->VarLeft, l PASS_REGS) PASS_REGS)); + if (HR > ASP - 4096) { + save_machine_regs(); + siglongjmp(LOCAL_IOBotch, 1); + } + return (o); } else { - return VarNames(p->VarRight,VarNames(p->VarLeft,l PASS_REGS) PASS_REGS); + return VarNames(p->VarRight, VarNames(p->VarLeft, l PASS_REGS) PASS_REGS); } } else { return (l); } } -Term -Yap_VarNames(VarEntry *p,Term l) -{ +Term Yap_VarNames(VarEntry *p, Term l) { CACHE_REGS - return VarNames(p,l PASS_REGS); + return VarNames(p, l PASS_REGS); } -static Term -Singletons(VarEntry *p,Term l USES_REGS) -{ +static Term Singletons(VarEntry *p, Term l USES_REGS) { if (p != NULL) { - if (p->VarRep && p->VarRep[0] != '_' && p->refs == 1) { + if (p->VarRep && p->VarRep[0] != '_' && p->refs == 1) { Term t[2]; Term o; - + t[0] = MkAtomTerm(Yap_LookupAtom(p->VarRep)); t[1] = p->VarAdr; o = Yap_MkApplTerm(FunctorEq, 2, t); - o = MkPairTerm(o, Singletons(p->VarRight, - Singletons(p->VarLeft,l PASS_REGS) PASS_REGS)); - if (HR > ASP-4096) { - save_machine_regs(); - siglongjmp(LOCAL_IOBotch,1); - } - return(o); + o = MkPairTerm(o, + Singletons(p->VarRight, + Singletons(p->VarLeft, l PASS_REGS) PASS_REGS)); + if (HR > ASP - 4096) { + save_machine_regs(); + siglongjmp(LOCAL_IOBotch, 1); + } + return (o); } else { - return Singletons(p->VarRight,Singletons(p->VarLeft,l PASS_REGS) PASS_REGS); + return Singletons(p->VarRight, + Singletons(p->VarLeft, l PASS_REGS) PASS_REGS); } } else { return (l); } } -Term -Yap_Singletons(VarEntry *p,Term l) -{ +Term Yap_Singletons(VarEntry *p, Term l) { CACHE_REGS - return Singletons(p,l PASS_REGS); + return Singletons(p, l PASS_REGS); } - -static Term -Variables(VarEntry *p,Term l USES_REGS) -{ +static Term Variables(VarEntry *p, Term l USES_REGS) { if (p != NULL) { Term o; - o = MkPairTerm(p->VarAdr, Variables(p->VarRight,Variables(p->VarLeft,l PASS_REGS) PASS_REGS)); - if (HR > ASP-4096) { + o = MkPairTerm( + p->VarAdr, + Variables(p->VarRight, Variables(p->VarLeft, l PASS_REGS) PASS_REGS)); + if (HR > ASP - 4096) { save_machine_regs(); - siglongjmp(LOCAL_IOBotch,1); - } - return(o); + siglongjmp(LOCAL_IOBotch, 1); + } + return (o); } else { return (l); } } -Term -Yap_Variables(VarEntry *p,Term l) -{ +Term Yap_Variables(VarEntry *p, Term l) { CACHE_REGS - return Variables(p,l PASS_REGS); + return Variables(p, l PASS_REGS); } -static int -IsPrefixOp(Atom op,int *pptr, int *rpptr USES_REGS) -{ +static int IsPrefixOp(Atom op, int *pptr, int *rpptr USES_REGS) { int p; OpEntry *opp = Yap_GetOpProp(op, PREFIX_OP PASS_REGS); if (!opp) return FALSE; - if (opp->OpModule && - opp->OpModule != CurrentModule) { + if (opp->OpModule && opp->OpModule != CurrentModule) { READ_UNLOCK(opp->OpRWLock); return FALSE; } @@ -378,7 +361,7 @@ IsPrefixOp(Atom op,int *pptr, int *rpptr USES_REGS) READ_UNLOCK(opp->OpRWLock); *pptr = *rpptr = p & MaskPrio; if (p & DcrrpFlag) - --* rpptr; + --*rpptr; return TRUE; } else { READ_UNLOCK(opp->OpRWLock); @@ -386,23 +369,18 @@ IsPrefixOp(Atom op,int *pptr, int *rpptr USES_REGS) } } -int -Yap_IsPrefixOp(Atom op,int *pptr, int *rpptr) -{ +int Yap_IsPrefixOp(Atom op, int *pptr, int *rpptr) { CACHE_REGS - return IsPrefixOp(op,pptr,rpptr PASS_REGS); + return IsPrefixOp(op, pptr, rpptr PASS_REGS); } -static int -IsInfixOp(Atom op, int *pptr, int *lpptr, int *rpptr USES_REGS) -{ +static int IsInfixOp(Atom op, int *pptr, int *lpptr, int *rpptr USES_REGS) { int p; OpEntry *opp = Yap_GetOpProp(op, INFIX_OP PASS_REGS); if (!opp) return FALSE; - if (opp->OpModule && - opp->OpModule != CurrentModule) { + if (opp->OpModule && opp->OpModule != CurrentModule) { READ_UNLOCK(opp->OpRWLock); return FALSE; } @@ -410,9 +388,9 @@ IsInfixOp(Atom op, int *pptr, int *lpptr, int *rpptr USES_REGS) READ_UNLOCK(opp->OpRWLock); *pptr = *rpptr = *lpptr = p & MaskPrio; if (p & DcrrpFlag) - --* rpptr; + --*rpptr; if (p & DcrlpFlag) - --* lpptr; + --*lpptr; return TRUE; } else { READ_UNLOCK(opp->OpRWLock); @@ -420,23 +398,18 @@ IsInfixOp(Atom op, int *pptr, int *lpptr, int *rpptr USES_REGS) } } -int -Yap_IsInfixOp(Atom op, int *pptr, int *lpptr, int *rpptr) -{ +int Yap_IsInfixOp(Atom op, int *pptr, int *lpptr, int *rpptr) { CACHE_REGS return IsInfixOp(op, pptr, lpptr, rpptr PASS_REGS); } -static int -IsPosfixOp(Atom op, int *pptr, int *lpptr USES_REGS) -{ +static int IsPosfixOp(Atom op, int *pptr, int *lpptr USES_REGS) { int p; OpEntry *opp = Yap_GetOpProp(op, POSFIX_OP PASS_REGS); if (!opp) return FALSE; - if (opp->OpModule && - opp->OpModule != CurrentModule) { + if (opp->OpModule && opp->OpModule != CurrentModule) { READ_UNLOCK(opp->OpRWLock); return FALSE; } @@ -444,7 +417,7 @@ IsPosfixOp(Atom op, int *pptr, int *lpptr USES_REGS) READ_UNLOCK(opp->OpRWLock); *pptr = *lpptr = p & MaskPrio; if (p & DcrlpFlag) - --* lpptr; + --*lpptr; return (TRUE); } else { READ_UNLOCK(opp->OpRWLock); @@ -452,128 +425,116 @@ IsPosfixOp(Atom op, int *pptr, int *lpptr USES_REGS) } } -int -Yap_IsPosfixOp(Atom op, int *pptr, int *lpptr) -{ +int Yap_IsPosfixOp(Atom op, int *pptr, int *lpptr) { CACHE_REGS return IsPosfixOp(op, pptr, lpptr PASS_REGS); } -inline static void -GNextToken( USES_REGS1 ) -{ - if (LOCAL_tokptr->Tok == Ord(eot_tok)) - return; - if (LOCAL_tokptr == LOCAL_toktide) - LOCAL_toktide = LOCAL_tokptr = LOCAL_tokptr->TokNext; - else - LOCAL_tokptr = LOCAL_tokptr->TokNext; +inline static void GNextToken(USES_REGS1) { + if (LOCAL_tokptr->Tok == Ord(eot_tok)) + return; + if (LOCAL_tokptr == LOCAL_toktide) + LOCAL_toktide = LOCAL_tokptr = LOCAL_tokptr->TokNext; + else + LOCAL_tokptr = LOCAL_tokptr->TokNext; } -inline static void -checkfor(wchar_t c, JMPBUFF *FailBuff USES_REGS) -{ - if (LOCAL_tokptr->Tok != Ord(Ponctuation_tok) - || LOCAL_tokptr->TokInfo != (Term)c) +inline static void checkfor(wchar_t c, JMPBUFF *FailBuff USES_REGS) { + if (LOCAL_tokptr->Tok != Ord(Ponctuation_tok) || + LOCAL_tokptr->TokInfo != (Term)c) FAIL; NextToken; } #ifdef O_QUASIQUOTATIONS - -static int -is_quasi_quotation_syntax(Term goal, ReadData _PL_rd, Atom *pat) -{ CACHE_REGS +static int is_quasi_quotation_syntax(Term goal, ReadData _PL_rd, Atom *pat) { + CACHE_REGS Term m = CurrentModule, t; Atom at; UInt arity; Functor f; t = Yap_StripModule(goal, &m); - f = FunctorOfTerm( t ); - *pat = at = NameOfFunctor( f ); - arity = ArityOfFunctor( f ); - if ( arity > 0 ) + f = FunctorOfTerm(t); + *pat = at = NameOfFunctor(f); + arity = ArityOfFunctor(f); + if (arity > 0) return TRUE; return FALSE; } -static int -get_quasi_quotation(term_t t, unsigned char **here, unsigned char *ein, - ReadData _PL_rd) -{ unsigned char *in, *start = *here; +static int get_quasi_quotation(term_t t, unsigned char **here, + unsigned char *ein, ReadData _PL_rd) { + unsigned char *in, *start = *here; - for(in=start; in <= ein; in++) - { if ( in[0] == '}' && - in[-1] == '|' ) - { *here = in+1; /* after } */ - in--; /* Before | */ + for (in = start; in <= ein; in++) { + if (in[0] == '}' && in[-1] == '|') { + *here = in + 1; /* after } */ + in--; /* Before | */ - if ( _PL_rd->quasi_quotations ) /* option; must return strings */ - { PL_chars_t txt; - int rc; + if (_PL_rd->quasi_quotations) /* option; must return strings */ + { + PL_chars_t txt; + int rc; - txt.text.t = (char*)start; - txt.length = in-start; - txt.storage = PL_CHARS_HEAP; - txt.encoding = ENC_UTF8; - txt.canonical = FALSE; + txt.text.t = (char *)start; + txt.length = in - start; + txt.storage = PL_CHARS_HEAP; + txt.encoding = ENC_UTF8; + txt.canonical = FALSE; - rc = PL_unify_text(t, 0, &txt, PL_CODE_LIST); - PL_free_text(&txt); + rc = PL_unify_text(t, 0, &txt, PL_CODE_LIST); + PL_free_text(&txt); - return rc; - } else - { return PL_unify_term(t, PL_FUNCTOR, FUNCTOR_dquasi_quotation3, - PL_POINTER, _PL_rd, - PL_INTPTR, (intptr_t)(start), - PL_INTPTR, (intptr_t)(in-start)); - } - } + return rc; + } else { + return PL_unify_term(t, PL_FUNCTOR, FUNCTOR_dquasi_quotation3, + PL_POINTER, _PL_rd, PL_INTPTR, (intptr_t)(start), + PL_INTPTR, (intptr_t)(in - start)); + } } + } - return FALSE; //errorWarning("end_of_file_in_quasi_quotation", 0, _PL_rd); + return FALSE; // errorWarning("end_of_file_in_quasi_quotation", 0, _PL_rd); } #endif /*O_QUASIQUOTATIONS*/ - -static Term -ParseArgs(read_data *rd, Atom a, wchar_t close, JMPBUFF *FailBuff, Term arg1 USES_REGS) -{ +static Term ParseArgs(read_data *rd, Atom a, wchar_t close, JMPBUFF *FailBuff, + Term arg1 USES_REGS) { int nargs = 0; Term *p, t; Functor func; #ifdef SFUNC - SFEntry *pe = (SFEntry *) Yap_GetAProp(a, SFProperty); + SFEntry *pe = (SFEntry *)Yap_GetAProp(a, SFProperty); #endif - + NextToken; - p = (Term *) ParserAuxSp; + p = (Term *)ParserAuxSp; if (arg1) { *p = arg1; nargs++; - ParserAuxSp = (char *)(p+1); - if (LOCAL_tokptr->Tok == Ord(Ponctuation_tok) - && LOCAL_tokptr->TokInfo == close) { + ParserAuxSp = (char *)(p + 1); + if (LOCAL_tokptr->Tok == Ord(Ponctuation_tok) && + LOCAL_tokptr->TokInfo == close) { func = Yap_MkFunctor(a, 1); if (func == NULL) { - LOCAL_ErrorMessage = "Heap Overflow"; - FAIL; + LOCAL_ErrorMessage = "Heap Overflow"; + FAIL; } t = Yap_MkApplTerm(func, nargs, p); - if (HR > ASP-4096) { - LOCAL_ErrorMessage = "Stack Overflow"; - return TermNil; - } + if (HR > ASP - 4096) { + LOCAL_ErrorMessage = "Stack Overflow"; + return TermNil; + } NextToken; return t; } } while (1) { Term *tp = (Term *)ParserAuxSp; - if (ParserAuxSp+1 > LOCAL_TrailTop) { + if (ParserAuxSp + 1 > LOCAL_TrailTop) { LOCAL_ErrorMessage = "Trail Overflow"; FAIL; } @@ -582,19 +543,19 @@ ParseArgs(read_data *rd, Atom a, wchar_t close, JMPBUFF *FailBuff, Term arg1 USE ++nargs; if (LOCAL_tokptr->Tok != Ord(Ponctuation_tok)) break; - if (((int) LOCAL_tokptr->TokInfo) != ',') + if (((int)LOCAL_tokptr->TokInfo) != ',') break; NextToken; } ParserAuxSp = (char *)p; /* * Needed because the arguments for the functor are placed in reverse - * order + * order */ - if (HR > ASP-(nargs+1)) { + if (HR > ASP - (nargs + 1)) { LOCAL_ErrorMessage = "Stack Overflow"; FAIL; - } + } func = Yap_MkFunctor(a, nargs); if (func == NULL) { LOCAL_ErrorMessage = "Heap Overflow"; @@ -606,62 +567,59 @@ ParseArgs(read_data *rd, Atom a, wchar_t close, JMPBUFF *FailBuff, Term arg1 USE else t = Yap_MkApplTerm(Yap_MkFunctor(a, nargs), nargs, p); #else - if (a == AtomDBref && nargs == 2) + if (a == AtomDBref && nargs == 2) t = MkDBRefTerm((DBRef)IntegerOfTerm(p[0])); else t = Yap_MkApplTerm(func, nargs, p); #endif - if (HR > ASP-4096) { + if (HR > ASP - 4096) { LOCAL_ErrorMessage = "Stack Overflow"; return TermNil; - } + } /* check for possible overflow against local stack */ checkfor(close, FailBuff PASS_REGS); return t; } -static Term MakeAccessor( Term t, Functor f USES_REGS ) -{ +static Term MakeAccessor(Term t, Functor f USES_REGS) { UInt arity = ArityOfFunctor(FunctorOfTerm(t)), i; - Term tf[2], tl= TermNil; - + Term tf[2], tl = TermNil; + tf[1] = ArgOfTerm(1, t); for (i = arity; i > 1; i--) { tl = MkPairTerm(ArgOfTerm(i, t), tl); } tf[0] = tl; - return Yap_MkApplTerm( f, 2, tf ); + return Yap_MkApplTerm(f, 2, tf); } -static Term -ParseList(read_data *rd, JMPBUFF *FailBuff USES_REGS) -{ +static Term ParseList(read_data *rd, JMPBUFF *FailBuff USES_REGS) { Term o; CELL *to_store; o = AbsPair(HR); - loop: +loop: to_store = HR; - HR+=2; + HR += 2; to_store[0] = ParseTerm(rd, 999, FailBuff PASS_REGS); if (LOCAL_tokptr->Tok == Ord(Ponctuation_tok)) { - if (((int) LOCAL_tokptr->TokInfo) == ',') { + if (((int)LOCAL_tokptr->TokInfo) == ',') { NextToken; - if (LOCAL_tokptr->Tok == Ord(Name_tok) - && strcmp(RepAtom((Atom)(LOCAL_tokptr->TokInfo))->StrOfAE, "..") == 0) { - NextToken; - to_store[1] = ParseTerm(rd, 999, FailBuff PASS_REGS); + if (LOCAL_tokptr->Tok == Ord(Name_tok) && + strcmp(RepAtom((Atom)(LOCAL_tokptr->TokInfo))->StrOfAE, "..") == 0) { + NextToken; + to_store[1] = ParseTerm(rd, 999, FailBuff PASS_REGS); } else { - /* check for possible overflow against local stack */ - if (HR > ASP-4096) { - to_store[1] = TermNil; - LOCAL_ErrorMessage = "Stack Overflow"; - FAIL; - } else { - to_store[1] = AbsPair(HR); - goto loop; - } + /* check for possible overflow against local stack */ + if (HR > ASP - 4096) { + to_store[1] = TermNil; + LOCAL_ErrorMessage = "Stack Overflow"; + FAIL; + } else { + to_store[1] = AbsPair(HR); + goto loop; + } } - } else if (((int) LOCAL_tokptr->TokInfo) == '|') { + } else if (((int)LOCAL_tokptr->TokInfo) == '|') { NextToken; to_store[1] = ParseTerm(rd, 999, FailBuff PASS_REGS); } else { @@ -672,9 +630,7 @@ ParseList(read_data *rd, JMPBUFF *FailBuff USES_REGS) return (o); } -static Term -ParseTerm(read_data *rd, int prio, JMPBUFF *FailBuff USES_REGS) -{ +static Term ParseTerm(read_data *rd, int prio, JMPBUFF *FailBuff USES_REGS) { /* parse term with priority prio */ Volatile Term t; Volatile Functor func; @@ -689,77 +645,72 @@ ParseTerm(read_data *rd, int prio, JMPBUFF *FailBuff USES_REGS) /* special rules apply for +1, -2.3, etc... */ if (LOCAL_tokptr->Tok == Number_tok) { if ((Atom)t == AtomMinus) { - t = LOCAL_tokptr->TokInfo; - if (IsIntTerm(t)) - t = MkIntTerm(-IntOfTerm(t)); - else if (IsFloatTerm(t)) - t = MkFloatTerm(-FloatOfTerm(t)); + t = LOCAL_tokptr->TokInfo; + if (IsIntTerm(t)) + t = MkIntTerm(-IntOfTerm(t)); + else if (IsFloatTerm(t)) + t = MkFloatTerm(-FloatOfTerm(t)); #ifdef USE_GMP - else if (IsBigIntTerm(t)) { - t = Yap_gmp_neg_big(t); - } + else if (IsBigIntTerm(t)) { + t = Yap_gmp_neg_big(t); + } #endif - else - t = MkLongIntTerm(-LongIntOfTerm(t)); - NextToken; - break; + else + t = MkLongIntTerm(-LongIntOfTerm(t)); + NextToken; + break; } } - if ((LOCAL_tokptr->Tok != Ord(Ponctuation_tok) - || Unsigned(LOCAL_tokptr->TokInfo) != 'l') - && IsPrefixOp((Atom)t, &opprio, &oprprio PASS_REGS) - ) { - if (LOCAL_tokptr->Tok == Name_tok) { - Atom at = (Atom)LOCAL_tokptr->TokInfo; + if ((LOCAL_tokptr->Tok != Ord(Ponctuation_tok) || + Unsigned(LOCAL_tokptr->TokInfo) != 'l') && + IsPrefixOp((Atom)t, &opprio, &oprprio PASS_REGS)) { + if (LOCAL_tokptr->Tok == Name_tok) { + Atom at = (Atom)LOCAL_tokptr->TokInfo; #ifndef _MSC_VER - if ((Atom)t == AtomPlus) { - if (at == AtomInf) { - t = MkFloatTerm(INFINITY); - NextToken; - break; - } else if (at == AtomNan) { - t = MkFloatTerm(NAN); - NextToken; - break; - } - } else if ((Atom)t == AtomMinus) { - if (at == AtomInf) { - t = MkFloatTerm(-INFINITY); - NextToken; - break; - } else if (at == AtomNan) { - t = MkFloatTerm(NAN); - NextToken; - break; - } - } + if ((Atom)t == AtomPlus) { + if (at == AtomInf) { + t = MkFloatTerm(INFINITY); + NextToken; + break; + } else if (at == AtomNan) { + t = MkFloatTerm(NAN); + NextToken; + break; + } + } else if ((Atom)t == AtomMinus) { + if (at == AtomInf) { + t = MkFloatTerm(-INFINITY); + NextToken; + break; + } else if (at == AtomNan) { + t = MkFloatTerm(NAN); + NextToken; + break; + } + } #endif - } + } if (opprio <= prio) { - /* try to parse as a prefix operator */ - TRY( - /* build appl on the heap */ - func = Yap_MkFunctor((Atom) t, 1); - if (func == NULL) { - LOCAL_ErrorMessage = "Heap Overflow"; - FAIL; - } - t = ParseTerm(rd, oprprio, FailBuff PASS_REGS); - t = Yap_MkApplTerm(func, 1, &t); - /* check for possible overflow against local stack */ - if (HR > ASP-4096) { - LOCAL_ErrorMessage = "Stack Overflow"; - FAIL; - } - curprio = opprio; - , - break; - ) - } + /* try to parse as a prefix operator */ + TRY( + /* build appl on the heap */ + func = Yap_MkFunctor((Atom)t, 1); + if (func == NULL) { + LOCAL_ErrorMessage = "Heap Overflow"; + FAIL; + } t = ParseTerm(rd, oprprio, FailBuff PASS_REGS); + t = Yap_MkApplTerm(func, 1, &t); + /* check for possible overflow against local stack */ + if (HR > ASP - 4096) { + LOCAL_ErrorMessage = "Stack Overflow"; + FAIL; + } curprio = opprio; + , break;) + } } - if (LOCAL_tokptr->Tok == Ord(Ponctuation_tok) - && Unsigned(LOCAL_tokptr->TokInfo) == 'l') - t = ParseArgs(rd, (Atom) t, ')', FailBuff, 0L PASS_REGS); + if (LOCAL_tokptr->Tok == Ord(Ponctuation_tok) && + Unsigned(LOCAL_tokptr->TokInfo) == 'l') + t = ParseArgs(rd, (Atom)t, ')', FailBuff, 0L PASS_REGS); else t = MkAtomTerm((Atom)t); break; @@ -769,30 +720,38 @@ ParseTerm(read_data *rd, int prio, JMPBUFF *FailBuff USES_REGS) NextToken; break; - case String_tok: /* build list on the heap */ - { - Volatile char *p = (char *) LOCAL_tokptr->TokInfo; - t = Yap_CharsToTDQ(p, CurrentModule PASS_REGS); - if (!t) { - FAIL; - } - NextToken; + case String_tok: /* build list on the heap */ + { + Volatile char *p = (char *)LOCAL_tokptr->TokInfo; + t = Yap_CharsToTDQ(p, CurrentModule PASS_REGS); + if (!t) { + FAIL; } - break; + NextToken; + } break; - case WString_tok: /* build list on the heap */ - { - Volatile wchar_t *p = (wchar_t *) LOCAL_tokptr->TokInfo; - t = Yap_WCharsToTDQ(p, CurrentModule PASS_REGS); - if (!t) { - FAIL; - } - NextToken; + case WString_tok: /* build list on the heap */ + { + Volatile wchar_t *p = (wchar_t *)LOCAL_tokptr->TokInfo; + t = Yap_WCharsToTDQ(p, CurrentModule PASS_REGS); + if (!t) { + FAIL; } - break; + NextToken; + } break; - case Var_tok: - varinfo = (VarEntry *) (LOCAL_tokptr->TokInfo); + case StringTerm_tok: /* build list on the heap */ +{ + Volatile char *p = (char *)LOCAL_tokptr->TokInfo; + t = Yap_CharsToString(p PASS_REGS); + if (!t) { + FAIL; + } + NextToken; +} break; + +case Var_tok: + varinfo = (VarEntry *)(LOCAL_tokptr->TokInfo); if ((t = varinfo->VarAdr) == TermNil) { t = varinfo->VarAdr = MkVarTerm(); } @@ -803,9 +762,9 @@ ParseTerm(read_data *rd, int prio, JMPBUFF *FailBuff USES_REGS) FAIL; case Ponctuation_tok: - switch ((int) LOCAL_tokptr->TokInfo) { + switch ((int)LOCAL_tokptr->TokInfo) { case '(': - case 'l': /* non solo ( */ + case 'l': /* non solo ( */ NextToken; t = ParseTerm(rd, 1200, FailBuff PASS_REGS); checkfor(')', FailBuff PASS_REGS); @@ -813,10 +772,10 @@ ParseTerm(read_data *rd, int prio, JMPBUFF *FailBuff USES_REGS) case '[': NextToken; if (LOCAL_tokptr->Tok == Ponctuation_tok && - (int) LOCAL_tokptr->TokInfo == ']') { - t = TermNil; - NextToken; - break; + (int)LOCAL_tokptr->TokInfo == ']') { + t = TermNil; + NextToken; + break; } t = ParseList(rd, FailBuff PASS_REGS); checkfor(']', FailBuff PASS_REGS); @@ -824,208 +783,204 @@ ParseTerm(read_data *rd, int prio, JMPBUFF *FailBuff USES_REGS) case '{': NextToken; if (LOCAL_tokptr->Tok == Ponctuation_tok && - (int) LOCAL_tokptr->TokInfo == '}') { - t = MkAtomTerm(AtomBraces); - NextToken; - break; + (int)LOCAL_tokptr->TokInfo == '}') { + t = MkAtomTerm(AtomBraces); + NextToken; + break; } t = ParseTerm(rd, 1200, FailBuff PASS_REGS); t = Yap_MkApplTerm(FunctorBraces, 1, &t); /* check for possible overflow against local stack */ - if (HR > ASP-4096) { - LOCAL_ErrorMessage = "Stack Overflow"; - FAIL; - } + if (HR > ASP - 4096) { + LOCAL_ErrorMessage = "Stack Overflow"; + FAIL; + } checkfor('}', FailBuff PASS_REGS); break; default: FAIL; } break; - - case QuasiQuotes_tok: - { - qq_t *qq = (qq_t *)(LOCAL_tokptr->TokInfo); - term_t pv, positions = rd->subtpos, to; - Atom at; - Term tn; - CELL *tnp; - // from SWI, enter the list - /* prepare (if we are the first in term) */ - if ( !rd->varnames ) - rd->varnames = PL_new_term_ref(); - if ( !rd->qq ) - { if ( rd->quasi_quotations ) - { rd->qq = rd->quasi_quotations; - } else - { if ( !(rd->qq = PL_new_term_ref()) ) - return FALSE; - } - // create positions term - if ( positions ) - { if ( !(pv = PL_new_term_refs(3)) || - !PL_unify_term(positions, - PL_FUNCTOR, FUNCTOR_quasi_quotation_position5, - PL_INTPTR, qq->start.charno, - PL_VARIABLE, - PL_TERM, pv+0, // leave three open slots - PL_TERM, pv+1, - PL_TERM, pv+2) ) - return FALSE; + case QuasiQuotes_tok: { + qq_t *qq = (qq_t *)(LOCAL_tokptr->TokInfo); + term_t pv, positions = rd->subtpos, to; + Atom at; + Term tn; + CELL *tnp; + + // from SWI, enter the list + /* prepare (if we are the first in term) */ + if (!rd->varnames) + rd->varnames = PL_new_term_ref(); + if (!rd->qq) { + if (rd->quasi_quotations) { + rd->qq = rd->quasi_quotations; + } else { + if (!(rd->qq = PL_new_term_ref())) + return FALSE; + } + // create positions term + if (positions) { + if (!(pv = PL_new_term_refs(3)) || + !PL_unify_term(positions, PL_FUNCTOR, + FUNCTOR_quasi_quotation_position5, PL_INTPTR, + qq->start.charno, PL_VARIABLE, PL_TERM, + pv + 0, // leave three open slots + PL_TERM, pv + 1, PL_TERM, pv + 2)) + return FALSE; } else - pv = 0; - /* push type */ - - if ( !(rd->qq_tail = PL_copy_term_ref(rd->qq)) ) - return FALSE; - } + pv = 0; + /* push type */ - NextToken; - t = ParseTerm(rd, 1200, FailBuff PASS_REGS); - if (LOCAL_tokptr->Tok != QuasiQuotes_tok) { - FAIL; - } - if ( !( is_quasi_quotation_syntax(t, rd, &at)) ) - FAIL; - /* Arg 2: the content */ - tn = Yap_MkNewApplTerm( SWIFunctorToFunctor(FUNCTOR_quasi_quotation4), 4 ); - tnp = RepAppl(tn)+1; - tnp[0] = MkAtomTerm(at); - if ( !get_quasi_quotation(Yap_InitSlot( ArgOfTerm(2, tn) PASS_REGS), &qq->text, qq->text+strlen((const char *)qq->text), rd) ) - FAIL; - - if ( positions ) - { intptr_t qqend = qq->end.charno; - - // set_range_position(positions, -1, qqend PASS_LD); - if ( !PL_unify_term( Yap_InitSlot( ArgOfTerm(2, t) PASS_REGS), - PL_FUNCTOR, FUNCTOR_minus2, - PL_INTPTR, qq->mid.charno+2, /* end of | token */ - PL_INTPTR, qqend-2) ) /* end minus "|}" */ - FAIL; - } - - tnp[2] = Yap_GetFromSlot(rd->varnames PASS_REGS); /* Arg 3: the var dictionary */ - /* Arg 4: the result */ - t = ArgOfTerm(4, tn); - if ( !(to = PL_new_term_ref()) || - !PL_unify_list(rd->qq_tail, to, rd->qq_tail) || - !PL_unify(to, Yap_InitSlot(tn PASS_REGS)) ) - FAIL; + if (!(rd->qq_tail = PL_copy_term_ref(rd->qq))) + return FALSE; } + + NextToken; + t = ParseTerm(rd, 1200, FailBuff PASS_REGS); + if (LOCAL_tokptr->Tok != QuasiQuotes_tok) { + FAIL; + } + if (!(is_quasi_quotation_syntax(t, rd, &at))) + FAIL; + /* Arg 2: the content */ + tn = Yap_MkNewApplTerm(SWIFunctorToFunctor(FUNCTOR_quasi_quotation4), 4); + tnp = RepAppl(tn) + 1; + tnp[0] = MkAtomTerm(at); + if (!get_quasi_quotation(Yap_InitSlot(ArgOfTerm(2, tn) PASS_REGS), + &qq->text, + qq->text + strlen((const char *)qq->text), rd)) + FAIL; + + if (positions) { + intptr_t qqend = qq->end.charno; + + // set_range_position(positions, -1, qqend PASS_LD); + if (!PL_unify_term(Yap_InitSlot(ArgOfTerm(2, t) PASS_REGS), PL_FUNCTOR, + FUNCTOR_minus2, PL_INTPTR, + qq->mid.charno + 2, /* end of | token */ + PL_INTPTR, qqend - 2)) /* end minus "|}" */ + FAIL; + } + + tnp[2] = + Yap_GetFromSlot(rd->varnames PASS_REGS); /* Arg 3: the var dictionary */ + /* Arg 4: the result */ + t = ArgOfTerm(4, tn); + if (!(to = PL_new_term_ref()) || + !PL_unify_list(rd->qq_tail, to, rd->qq_tail) || + !PL_unify(to, Yap_InitSlot(tn PASS_REGS))) + FAIL; + } NextToken; break; default: - + FAIL; } /* main loop to parse infix and posfix operators starts here */ while (TRUE) { - if (LOCAL_tokptr->Tok == Ord(Name_tok) - && Yap_HasOp((Atom)(LOCAL_tokptr->TokInfo))) { + if (LOCAL_tokptr->Tok == Ord(Name_tok) && + Yap_HasOp((Atom)(LOCAL_tokptr->TokInfo))) { Atom save_opinfo = opinfo = (Atom)(LOCAL_tokptr->TokInfo); - if (IsInfixOp(save_opinfo, &opprio, &oplprio, &oprprio PASS_REGS) - && opprio <= prio && oplprio >= curprio) { - /* try parsing as infix operator */ - Volatile int oldprio = curprio; - TRY3( - func = Yap_MkFunctor((Atom) LOCAL_tokptr->TokInfo, 2); - if (func == NULL) { - LOCAL_ErrorMessage = "Heap Overflow"; - FAIL; - } - NextToken; - { - Term args[2]; - args[0] = t; - args[1] = ParseTerm(rd, oprprio, FailBuff PASS_REGS); - t = Yap_MkApplTerm(func, 2, args); - /* check for possible overflow against local stack */ - if (HR > ASP-4096) { - LOCAL_ErrorMessage = "Stack Overflow"; - FAIL; - } - }, - curprio = opprio; - opinfo = save_opinfo; - continue; - , - opinfo = save_opinfo; - curprio = oldprio; - ) + if (IsInfixOp(save_opinfo, &opprio, &oplprio, &oprprio PASS_REGS) && + opprio <= prio && oplprio >= curprio) { + /* try parsing as infix operator */ + Volatile int oldprio = curprio; + TRY3(func = Yap_MkFunctor((Atom)LOCAL_tokptr->TokInfo, 2); + if (func == NULL) { + LOCAL_ErrorMessage = "Heap Overflow"; + FAIL; + } NextToken; + { + Term args[2]; + args[0] = t; + args[1] = ParseTerm(rd, oprprio, FailBuff PASS_REGS); + t = Yap_MkApplTerm(func, 2, args); + /* check for possible overflow against local stack */ + if (HR > ASP - 4096) { + LOCAL_ErrorMessage = "Stack Overflow"; + FAIL; + } + }, + curprio = opprio; + opinfo = save_opinfo; continue;, opinfo = save_opinfo; + curprio = oldprio;) } - if (IsPosfixOp(opinfo, &opprio, &oplprio PASS_REGS) - && opprio <= prio && oplprio >= curprio) { - /* parse as posfix operator */ - Functor func = Yap_MkFunctor((Atom) LOCAL_tokptr->TokInfo, 1); - if (func == NULL) { - LOCAL_ErrorMessage = "Heap Overflow"; - FAIL; - } - t = Yap_MkApplTerm(func, 1, &t); - /* check for possible overflow against local stack */ - if (HR > ASP-4096) { - LOCAL_ErrorMessage = "Stack Overflow"; - FAIL; - } - curprio = opprio; - NextToken; - continue; + if (IsPosfixOp(opinfo, &opprio, &oplprio PASS_REGS) && opprio <= prio && + oplprio >= curprio) { + /* parse as posfix operator */ + Functor func = Yap_MkFunctor((Atom)LOCAL_tokptr->TokInfo, 1); + if (func == NULL) { + LOCAL_ErrorMessage = "Heap Overflow"; + FAIL; + } + t = Yap_MkApplTerm(func, 1, &t); + /* check for possible overflow against local stack */ + if (HR > ASP - 4096) { + LOCAL_ErrorMessage = "Stack Overflow"; + FAIL; + } + curprio = opprio; + NextToken; + continue; } break; } if (LOCAL_tokptr->Tok == Ord(Ponctuation_tok)) { - if (Unsigned(LOCAL_tokptr->TokInfo) == ',' && - prio >= 1000 && curprio <= 999) { - Volatile Term args[2]; - NextToken; - args[0] = t; - args[1] = ParseTerm(rd, 1000, FailBuff PASS_REGS); - t = Yap_MkApplTerm(FunctorComma, 2, args); - /* check for possible overflow against local stack */ - if (HR > ASP-4096) { - LOCAL_ErrorMessage = "Stack Overflow"; - FAIL; - } - curprio = 1000; - continue; + if (Unsigned(LOCAL_tokptr->TokInfo) == ',' && prio >= 1000 && + curprio <= 999) { + Volatile Term args[2]; + NextToken; + args[0] = t; + args[1] = ParseTerm(rd, 1000, FailBuff PASS_REGS); + t = Yap_MkApplTerm(FunctorComma, 2, args); + /* check for possible overflow against local stack */ + if (HR > ASP - 4096) { + LOCAL_ErrorMessage = "Stack Overflow"; + FAIL; + } + curprio = 1000; + continue; } else if (Unsigned(LOCAL_tokptr->TokInfo) == '|' && - IsInfixOp(AtomVBar, &opprio, &oplprio, &oprprio PASS_REGS) - && opprio <= prio && oplprio >= curprio) { - Volatile Term args[2]; - NextToken; - args[0] = t; - args[1] = ParseTerm(rd, oprprio, FailBuff PASS_REGS); - t = Yap_MkApplTerm(FunctorVBar, 2, args); - /* check for possible overflow against local stack */ - if (HR > ASP-4096) { - LOCAL_ErrorMessage = "Stack Overflow"; - FAIL; - } - curprio = opprio; - continue; + IsInfixOp(AtomVBar, &opprio, &oplprio, &oprprio PASS_REGS) && + opprio <= prio && oplprio >= curprio) { + Volatile Term args[2]; + NextToken; + args[0] = t; + args[1] = ParseTerm(rd, oprprio, FailBuff PASS_REGS); + t = Yap_MkApplTerm(FunctorVBar, 2, args); + /* check for possible overflow against local stack */ + if (HR > ASP - 4096) { + LOCAL_ErrorMessage = "Stack Overflow"; + FAIL; + } + curprio = opprio; + continue; } else if (Unsigned(LOCAL_tokptr->TokInfo) == '(' && - IsPosfixOp(AtomEmptyBrackets, &opprio, &oplprio PASS_REGS) - && opprio <= prio && oplprio >= curprio) { - t = ParseArgs(rd, AtomEmptyBrackets, ')', FailBuff, t PASS_REGS); - curprio = opprio; - continue; - } else if (Unsigned(LOCAL_tokptr->TokInfo) == '[' && - IsPosfixOp(AtomEmptySquareBrackets, &opprio, &oplprio PASS_REGS) - && opprio <= prio && oplprio >= curprio) { - t = ParseArgs(rd, AtomEmptySquareBrackets, ']', FailBuff, t PASS_REGS); - t = MakeAccessor(t, FunctorEmptySquareBrackets PASS_REGS); - curprio = opprio; - continue; + IsPosfixOp(AtomEmptyBrackets, &opprio, &oplprio PASS_REGS) && + opprio <= prio && oplprio >= curprio) { + t = ParseArgs(rd, AtomEmptyBrackets, ')', FailBuff, t PASS_REGS); + curprio = opprio; + continue; + } else if (Unsigned(LOCAL_tokptr->TokInfo) == '[' && + IsPosfixOp(AtomEmptySquareBrackets, &opprio, + &oplprio PASS_REGS) && + opprio <= prio && oplprio >= curprio) { + t = ParseArgs(rd, AtomEmptySquareBrackets, ']', FailBuff, t PASS_REGS); + t = MakeAccessor(t, FunctorEmptySquareBrackets PASS_REGS); + curprio = opprio; + continue; } else if (Unsigned(LOCAL_tokptr->TokInfo) == '{' && - IsPosfixOp(AtomEmptyCurlyBrackets, &opprio, &oplprio PASS_REGS) - && opprio <= prio && oplprio >= curprio) { - t = ParseArgs(rd, AtomEmptyCurlyBrackets, '}', FailBuff, t PASS_REGS); - t = MakeAccessor(t, FunctorEmptyCurlyBrackets PASS_REGS); - curprio = opprio; - continue; + IsPosfixOp(AtomEmptyCurlyBrackets, &opprio, + &oplprio PASS_REGS) && + opprio <= prio && oplprio >= curprio) { + t = ParseArgs(rd, AtomEmptyCurlyBrackets, '}', FailBuff, t PASS_REGS); + t = MakeAccessor(t, FunctorEmptyCurlyBrackets PASS_REGS); + curprio = opprio; + continue; } } if (LOCAL_tokptr->Tok <= Ord(WString_tok)) @@ -1034,19 +989,16 @@ ParseTerm(read_data *rd, int prio, JMPBUFF *FailBuff USES_REGS) } #if DEBUG if (GLOBAL_Option['p' - 'a' + 1]) { - Yap_DebugPutc(LOCAL_c_error_stream,'['); + Yap_DebugPutc(LOCAL_c_error_stream, '['); Yap_DebugPlWrite(t); - Yap_DebugPutc(LOCAL_c_error_stream,']'); - Yap_DebugPutc(LOCAL_c_error_stream,'\n'); + Yap_DebugPutc(LOCAL_c_error_stream, ']'); + Yap_DebugPutc(LOCAL_c_error_stream, '\n'); } #endif return t; } - -Term -Yap_Parse(read_data *rd) -{ +Term Yap_Parse(read_data *rd) { CACHE_REGS Volatile Term t; JMPBUFF FailBuff; @@ -1061,4 +1013,3 @@ Yap_Parse(read_data *rd) } //! @} - diff --git a/C/scanner.c b/C/scanner.c index 9178d9d1e..e3df05820 100755 --- a/C/scanner.c +++ b/C/scanner.c @@ -1,22 +1,22 @@ /************************************************************************* -* * -* YAP Prolog * -* * -* Yap Prolog was developed at NCCUP - Universidade do Porto * -* * -* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-2003 * -* * +* * +* YAP Prolog * +* * +* Yap Prolog was developed at NCCUP - Universidade do Porto * +* * +* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-2003 * +* * ************************************************************************** -* * -* File: %W% %G% * -* Last rev: 22-1-03 * -* mods: * -* comments: Prolog's scanner * -* * +* * +* File: %W% %G% * +* Last rev: 22-1-03 * +* mods: * +* comments: Prolog's scanner * +* * *************************************************************************/ /* - * Description: + * Description: * * This module produces a list of tokens for use by the parser. The calling * program should supply a routine int nextch(charpos) int *charpos; which, @@ -28,7 +28,7 @@ * will try to find the end of the term. A function char * *AllocScannerMemory(nbytes) should be supplied for allocating (temporary) * space for strings and for the table of prolog variables occurring in the - * term. + * term. * */ @@ -104,7 +104,8 @@ Floating-point numbers are described by: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ where \a \\\ denotes the decimal-point character '.', -\a \\\ denotes one of 'e' or 'E', and \a \\\ denotes +\a \\\ denotes one of 'e' or 'E', and \a \\\ +denotes one of '+' or '-'. Examples: @@ -122,9 +123,11 @@ Strings are described by the following rules: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ string --> '"' string_quoted_characters '"' + string --> '`' string_quoted_characters '`' string_quoted_characters --> '"' '"' string_quoted_characters - string_quoted_characters --> '\' + string_quoted_characters --> '`' '`' string_quoted_characters +string_quoted_characters --> '\' escape_sequence string_quoted_characters string_quoted_characters --> string_character string_quoted_characters @@ -140,7 +143,7 @@ and escape characters. Examples: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -"" "a string" "a double-quote:""" +"" "a string" "a double-quote:""" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The first string is an empty string, the last string shows the use of @@ -159,7 +162,7 @@ either as an octal or hexadecimal number. The next examples demonstrates the use of escape sequences in YAP: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -"\x0c\" "\01\" "\f" "\\" +"\x0c\" "\01\" "\f" "\\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The first three examples return a list including only character 12 (form @@ -172,6 +175,15 @@ versions of YAP up to 4.2.0. Escape sequences can be disable by using: :- yap_flag(character_escapes,false). ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Since 6.3.4 YAP supports compact strings, that are not represented as +lists of codes, but instead as a sequence of UTF-8 encoded characters +in the execution stack. These strings do not require allocating a +symbol, as atoms do, but are much more compact than using lists of +codes. + + + + + Atoms Atoms Atoms are defined by one of the following rules: @@ -191,7 +203,7 @@ where: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ denotes one of: ! ; - denotes one of: # & * + - . / : < + denotes one of: # & * + - . / : < = > ? @ \ ^ ~ ` denotes one of: a...z denotes one of: _ a...z A...Z 0....9 @@ -230,7 +242,7 @@ If a variable is referred only once in a term, it needs not to be named and one can use the character `_` to represent the variable. These variables are known as anonymous variables. Note that different occurrences of `_` on the same term represent different -anonymous variables. +anonymous variables. + Punctuation Tokens @@ -249,7 +261,8 @@ a token are ignored. All the text appearing in a line after the character \a % is taken to be a comment and ignored (including \a %). Comments can also be inserted by using the sequence `/\*` to start the comment and -`\*` followed by `/` to finish it. In the presence of any sequence of comments or +`\*` followed by `/` to finish it. In the presence of any sequence of comments +or layout characters, the YAP parser behaves as if it had found a single blank character. The end of a file also counts as a blank character for this purpose. @@ -311,7 +324,7 @@ encoding, `open/4` when opening files or using `set_stream/2` on any open stream (not yet implemented). For Prolog source files we also provide the `encoding/1` directive that can be used to switch between encodings that are compatible to US-ASCII (`ascii`, -`iso_latin_1`, `utf8` and many locales). +`iso_latin_1`, `utf8` and many locales). @@ -388,8 +401,7 @@ available through stream_property/2. When opening a file for writing, writing a BOM can be requested using the option `bom(true)` with `open/4`. - */ - + */ #include "Yap.h" #include "Yatom.h" @@ -402,8 +414,8 @@ writing, writing a BOM can be requested using the option #include "pl-shared.h" #include "pl-read.h" #include "YapText.h" -#if _MSC_VER || defined(__MINGW32__) -#if HAVE_FINITE==1 +#if _MSC_VER || defined(__MINGW32__) +#if HAVE_FINITE == 1 #undef HAVE_FINITE #endif #include @@ -420,122 +432,136 @@ writing, writing a BOM can be requested using the option #endif /* You just can't trust some machines */ -#define my_isxdigit(C,SU,SL) (chtype(C) == NU || (C >= 'A' && \ - C <= (SU)) || (C >= 'a' && C <= (SL))) -#define my_isupper(C) ( C >= 'A' && C <= 'Z' ) -#define my_islower(C) ( C >= 'a' && C <= 'z' ) +#define my_isxdigit(C, SU, SL) \ + (chtype(C) == NU || (C >= 'A' && C <= (SU)) || (C >= 'a' && C <= (SL))) +#define my_isupper(C) (C >= 'A' && C <= 'Z') +#define my_islower(C) (C >= 'a' && C <= 'z') static Term float_send(char *, int); -static Term get_num(int *, int *, IOSTREAM *,char *,UInt,int); +static Term get_num(int *, int *, IOSTREAM *, char *, UInt, int); /* token table with some help from Richard O'Keefe's PD scanner */ -static char chtype0[NUMBER_OF_CHARS+1] = -{ -EF, -/* nul soh stx etx eot enq ack bel bs ht nl vt np cr so si */ - BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, +static char chtype0[NUMBER_OF_CHARS + 1] = { + EF, + /* nul soh stx etx eot enq ack bel bs ht nl vt np cr so si + */ + BS, BS, BS, BS, BS, BS, BS, BS, BS, + BS, BS, BS, BS, BS, BS, BS, -/* dle dc1 dc2 dc3 dc4 nak syn etb can em sub esc fs gs rs us */ - BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, + /* dle dc1 dc2 dc3 dc4 nak syn etb can em sub esc fs gs rs us + */ + BS, BS, BS, BS, BS, BS, BS, BS, BS, + BS, BS, BS, BS, BS, BS, BS, -/* sp ! " # $ % & ' ( ) * + , - . / */ - BS, SL, DC, SY, LC, CC, SY, QT, BK, BK, SY, SY, BK, SY, SY, SY, + /* sp ! " # $ % & ' ( ) * + , - . / */ + BS, SL, DC, SY, LC, CC, SY, QT, BK, + BK, SY, SY, BK, SY, SY, SY, -/* 0 1 2 3 4 5 6 7 8 9 : ; < = > ? */ - NU, NU, NU, NU, NU, NU, NU, NU, NU, NU, SY, SL, SY, SY, SY, SY, + /* 0 1 2 3 4 5 6 7 8 9 : ; < = > ? */ + NU, NU, NU, NU, NU, NU, NU, NU, NU, + NU, SY, SL, SY, SY, SY, SY, -/* @ A B C D E F G H I J K L M N O */ - SY, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, + /* @ A B C D E F G H I J K L M N O */ + SY, UC, UC, UC, UC, UC, UC, UC, UC, + UC, UC, UC, UC, UC, UC, UC, -/* P Q R S T U V W X Y Z [ \ ] ^ _ */ - UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, BK, SY, BK, SY, UL, + /* P Q R S T U V W X Y Z [ \ ] ^ _ */ + UC, UC, UC, UC, UC, UC, UC, UC, UC, + UC, UC, BK, SY, BK, SY, UL, -/* ` a b c d e f g h i j k l m n o */ - SY, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, + /* ` a b c d e f g h i j k l m n o */ + SY, LC, LC, LC, LC, LC, LC, LC, LC, + LC, LC, LC, LC, LC, LC, LC, -/* p q r s t u v w x y z { | } ~ del */ - LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, BK, BK, BK, SY, BS, + /* p q r s t u v w x y z { | } ~ del */ + LC, LC, LC, LC, LC, LC, LC, LC, LC, + LC, LC, BK, BK, BK, SY, BS, -/* 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 */ - BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, + /* 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 + */ + BS, BS, BS, BS, BS, BS, BS, BS, BS, + BS, BS, BS, BS, BS, BS, BS, -/* 144 145 ’ 147 148 149 150 151 152 153 154 155 156 157 158 159 */ - BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, BS, + /* 144 145 ’ 147 148 149 150 151 152 153 154 155 156 157 158 159 + */ + BS, BS, BS, BS, BS, BS, BS, BS, BS, + BS, BS, BS, BS, BS, BS, BS, -/*   ¡ ¢ £ ¤ ¥ ¦ § ¨ © ª « ¬ ­ ® ¯ */ - BS, SY, SY, SY, SY, SY, SY, SY, SY, SY, LC, SY, SY, SY, SY, SY, + /*   ¡ ¢ £ ¤ ¥ ¦ § ¨ © ª « ¬ ­ ® ¯ */ + BS, SY, SY, SY, SY, SY, SY, SY, SY, + SY, LC, SY, SY, SY, SY, SY, -/* ° ± ² ³ ´ µ ¶ · ¸ ¹ º » ¼ ½ ¾ ¿ */ - SY, SY, LC, LC, SY, SY, SY, SY, SY, LC, LC, SY, SY, SY, SY, SY, + /* ° ± ² ³ ´ µ ¶ · ¸ ¹ º » ¼ ½ ¾ ¿ */ + SY, SY, LC, LC, SY, SY, SY, SY, SY, + LC, LC, SY, SY, SY, SY, SY, -/* À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï */ - UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, + /* À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï */ + UC, UC, UC, UC, UC, UC, UC, UC, UC, + UC, UC, UC, UC, UC, UC, UC, /* Ð Ñ Ò Ó Ô Õ Ö × Ø Ù Ú Û Ü Ý Þ ß */ -#ifdef vms - UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, UC, LC, +#ifdef vms + UC, UC, UC, UC, UC, UC, UC, UC, UC, + UC, UC, UC, UC, UC, UC, LC, #else - UC, UC, UC, UC, UC, UC, UC, SY, UC, UC, UC, UC, UC, UC, UC, LC, + UC, UC, UC, UC, UC, UC, UC, SY, UC, + UC, UC, UC, UC, UC, UC, LC, #endif -/* à á â ã ä å æ ç è é ê ë ì í î ï */ - LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, + /* à á â ã ä å æ ç è é ê ë ì í î ï */ + LC, LC, LC, LC, LC, LC, LC, LC, LC, + LC, LC, LC, LC, LC, LC, LC, -/* ð ñ ò ó ô õ ö ÷ ø ù ú û ü cannot write the last three because of lcc */ -#ifdef vms - LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC, LC +/* ð ñ ò ó ô õ ö ÷ ø ù ú û ü cannot write the last + * three because of lcc */ +#ifdef vms + LC, LC, LC, LC, LC, LC, LC, LC, LC, + LC, LC, LC, LC, LC, LC, LC #else - LC, LC, LC, LC, LC, LC, LC, SY, LC, LC, LC, LC, LC, LC, LC, LC + LC, LC, LC, LC, LC, LC, LC, SY, LC, + LC, LC, LC, LC, LC, LC, LC #endif }; +char *Yap_chtype = chtype0 + 1; -char *Yap_chtype = chtype0+1; - -int -Yap_wide_chtype(Int ch) { +int Yap_wide_chtype(Int ch) { #if HAVE_WCTYPE_H if (iswalnum(ch)) { - if (iswlower(ch)) return LC; - if (iswdigit(ch)) return NU; + if (iswlower(ch)) + return LC; + if (iswdigit(ch)) + return NU; return UC; } - if (iswpunct(ch)) return SY; + if (iswpunct(ch)) + return SY; #endif return BS; } +static inline int getchr__(IOSTREAM *inp) { + int c = Sgetcode(inp); -static inline int -getchr__(IOSTREAM *inp) -{ int c = Sgetcode(inp); - - if ( !CharConversionTable || c < 0 || c >= 256 ) + if (!CharConversionTable || c < 0 || c >= 256) return c; return CharConversionTable[c]; } - -#define getchr(inp) getchr__(inp) +#define getchr(inp) getchr__(inp) #define getchrq(inp) Sgetcode(inp) -static int -GetCurInpPos (IOSTREAM *inp_stream) -{ +static int GetCurInpPos(IOSTREAM *inp_stream) { return inp_stream->posbuf.lineno; } - - /* in case there is an overflow */ typedef struct scanner_extra_alloc { struct scanner_extra_alloc *next; void *filler; } ScannerExtraBlock; -static char * -AllocScannerMemory(unsigned int size) -{ +static char *AllocScannerMemory(unsigned int size) { CACHE_REGS char *AuxSpScan; @@ -544,39 +570,39 @@ AllocScannerMemory(unsigned int size) if (LOCAL_ScannerExtraBlocks) { struct scanner_extra_alloc *ptr; - if (!(ptr = (struct scanner_extra_alloc *)malloc(size+sizeof(ScannerExtraBlock)))) { + if (!(ptr = (struct scanner_extra_alloc *)malloc( + size + sizeof(ScannerExtraBlock)))) { return NULL; } ptr->next = LOCAL_ScannerExtraBlocks; LOCAL_ScannerExtraBlocks = ptr; - return (char *)(ptr+1); - } else if (LOCAL_TrailTop <= AuxSpScan+size) { + return (char *)(ptr + 1); + } else if (LOCAL_TrailTop <= AuxSpScan + size) { UInt alloc_size = sizeof(CELL) * K16; - + if (size > alloc_size) alloc_size = size; - if(!Yap_growtrail(alloc_size, TRUE)) { + if (!Yap_growtrail(alloc_size, TRUE)) { struct scanner_extra_alloc *ptr; - if (!(ptr = (struct scanner_extra_alloc *)malloc(size+sizeof(ScannerExtraBlock)))) { - return NULL; + if (!(ptr = (struct scanner_extra_alloc *)malloc( + size + sizeof(ScannerExtraBlock)))) { + return NULL; } ptr->next = LOCAL_ScannerExtraBlocks; LOCAL_ScannerExtraBlocks = ptr; - return (char *)(ptr+1); + return (char *)(ptr + 1); } } - LOCAL_ScannerStack = AuxSpScan+size; + LOCAL_ScannerStack = AuxSpScan + size; return AuxSpScan; } -static void -PopScannerMemory(char *block, unsigned int size) -{ +static void PopScannerMemory(char *block, unsigned int size) { CACHE_REGS - if (block == LOCAL_ScannerStack-size) { + if (block == LOCAL_ScannerStack - size) { LOCAL_ScannerStack -= size; - } else if (block == (char *)(LOCAL_ScannerExtraBlocks+1)) { + } else if (block == (char *)(LOCAL_ScannerExtraBlocks + 1)) { struct scanner_extra_alloc *ptr = LOCAL_ScannerExtraBlocks; LOCAL_ScannerExtraBlocks = ptr->next; @@ -584,32 +610,28 @@ PopScannerMemory(char *block, unsigned int size) } } -char * -Yap_AllocScannerMemory(unsigned int size) -{ +char *Yap_AllocScannerMemory(unsigned int size) { /* I assume memory has been initialised */ return AllocScannerMemory(size); } extern double atof(const char *); -static Term -float_send(char *s, int sign) -{ +static Term float_send(char *s, int sign) { GET_LD - Float f = (Float)(sign*atof(s)); + Float f = (Float)(sign * atof(s)); #if HAVE_ISFINITE || defined(isfinite) if (truePrologFlag(PLFLAG_ISO)) { /* iso */ if (!isfinite(f)) { LOCAL_ErrorMessage = "Float overflow while scanning"; - return(MkEvalFl(f)); + return (MkEvalFl(f)); } } #elif HAVE_FINITE if (truePrologFlag(PLFLAG_ISO)) { /* iso */ if (!finite(f)) { LOCAL_ErrorMessage = "Float overflow while scanning"; - return(MkEvalFl(f)); + return (MkEvalFl(f)); } } #endif @@ -617,15 +639,13 @@ float_send(char *s, int sign) } /* we have an overflow at s */ -static Term -read_int_overflow(const char *s, Int base, Int val, int sign) -{ +static Term read_int_overflow(const char *s, Int base, Int val, int sign) { #ifdef USE_GMP /* try to scan it as a bignum */ mpz_t new; Term t; - mpz_init_set_str (new, s, base); + mpz_init_set_str(new, s, base); if (sign < 0) mpz_neg(new, new); t = Yap_MkBigIntTerm(new); @@ -635,25 +655,21 @@ read_int_overflow(const char *s, Int base, Int val, int sign) CACHE_REGS /* try to scan it as a float */ return MkIntegerTerm(val); -#endif +#endif } -static int -send_error_message(char s[]) -{ +static int send_error_message(char s[]) { CACHE_REGS LOCAL_ErrorMessage = s; return 0; } -static wchar_t -read_quoted_char(int *scan_nextp, IOSTREAM *inp_stream) -{ +static wchar_t read_quoted_char(int *scan_nextp, IOSTREAM *inp_stream) { GET_LD int ch; - /* escape sequence */ - do_switch: +/* escape sequence */ +do_switch: ch = getchrq(inp_stream); switch (ch) { case 10: @@ -665,68 +681,67 @@ read_quoted_char(int *scan_nextp, IOSTREAM *inp_stream) case 'b': return '\b'; case 'c': - while (chtype((ch = getchrq(inp_stream))) == BS); + while (chtype((ch = getchrq(inp_stream))) == BS) + ; { if (ch == '\\') { - goto do_switch; + goto do_switch; } return ch; } case 'd': return 127; case 'e': - return '\x1B'; /* , a.k.a. \e */ + return '\x1B'; /* , a.k.a. \e */ case 'f': return '\f'; case 'n': return '\n'; case 'r': return '\r'; - case 's': /* space */ + case 's': /* space */ return ' '; case 't': return '\t'; - case 'u': - { - int i; - wchar_t wc='\0'; + case 'u': { + int i; + wchar_t wc = '\0'; - for (i=0; i< 4; i++) { - ch = getchrq(inp_stream); - if (ch>='0' && ch <= '9') { - wc += (ch-'0')<<((3-i)*4); - } else if (ch>='a' && ch <= 'f') { - wc += ((ch-'a')+10)<<((3-i)*4); - } else if (ch>='A' && ch <= 'F') { - wc += ((ch-'A')+10)<<((3-i)*4); - } else { - return send_error_message("invalid escape sequence"); - } + for (i = 0; i < 4; i++) { + ch = getchrq(inp_stream); + if (ch >= '0' && ch <= '9') { + wc += (ch - '0') << ((3 - i) * 4); + } else if (ch >= 'a' && ch <= 'f') { + wc += ((ch - 'a') + 10) << ((3 - i) * 4); + } else if (ch >= 'A' && ch <= 'F') { + wc += ((ch - 'A') + 10) << ((3 - i) * 4); + } else { + return send_error_message("invalid escape sequence"); } - return wc; } - case 'U': - { - int i; - wchar_t wc='\0'; + return wc; + } + case 'U': { + int i; + wchar_t wc = '\0'; - for (i=0; i< 8; i++) { - ch = getchrq(inp_stream); - if (ch>='0' && ch <= '9') { - wc += (ch-'0')<<((7-i)*4); - } else if (ch>='a' && ch <= 'f') { - wc += ((ch-'a')+10)<<((7-i)*4); - } else if (ch>='A' && ch <= 'F') { - wc += ((ch-'A')+10)<<((7-i)*4); - } else { - return send_error_message("invalid escape sequence"); - } + for (i = 0; i < 8; i++) { + ch = getchrq(inp_stream); + if (ch >= '0' && ch <= '9') { + wc += (ch - '0') << ((7 - i) * 4); + } else if (ch >= 'a' && ch <= 'f') { + wc += ((ch - 'a') + 10) << ((7 - i) * 4); + } else if (ch >= 'A' && ch <= 'F') { + wc += ((ch - 'A') + 10) << ((7 - i) * 4); + } else { + return send_error_message("invalid escape sequence"); } - return wc; } + return wc; + } case 'v': return '\v'; - case 'z': /* Prolog end-of-file */ + case 'z': /* Prolog end-of-file */ return send_error_message("invalid escape sequence \\z"); case '\'': return '\''; @@ -739,14 +754,14 @@ read_quoted_char(int *scan_nextp, IOSTREAM *inp_stream) return send_error_message("invalid escape sequence"); } else { ch = getchrq(inp_stream); - if (ch == '?') {/* delete character */ - return 127; - } else if (ch >= 'a' && ch < 'z') {/* hexa */ - return ch - 'a'; - } else if (ch >= 'A' && ch < 'Z') {/* hexa */ - return ch - 'A'; + if (ch == '?') { /* delete character */ + return 127; + } else if (ch >= 'a' && ch < 'z') { /* hexa */ + return ch - 'a'; + } else if (ch >= 'A' && ch < 'Z') { /* hexa */ + return ch - 'A'; } else { - return '^'; + return '^'; } } case '0': @@ -760,56 +775,60 @@ read_quoted_char(int *scan_nextp, IOSTREAM *inp_stream) /* character in octal: maximum of 3 digits, terminates with \ */ /* follow ISO */ { - unsigned char so_far = ch-'0'; + unsigned char so_far = ch - '0'; ch = getchrq(inp_stream); - if (ch >= '0' && ch < '8') {/* octal */ - so_far = so_far*8+(ch-'0'); - ch = getchrq(inp_stream); - if (ch >= '0' && ch < '8') { /* octal */ - so_far = so_far*8+(ch-'0'); - ch = getchrq(inp_stream); - if (ch != '\\') { - return send_error_message("invalid octal escape sequence"); - } - return so_far; - } else if (ch == '\\') { - return so_far; - } else { - return send_error_message("invalid octal escape sequence"); - } + if (ch >= '0' && ch < '8') { /* octal */ + so_far = so_far * 8 + (ch - '0'); + ch = getchrq(inp_stream); + if (ch >= '0' && ch < '8') { /* octal */ + so_far = so_far * 8 + (ch - '0'); + ch = getchrq(inp_stream); + if (ch != '\\') { + return send_error_message("invalid octal escape sequence"); + } + return so_far; + } else if (ch == '\\') { + return so_far; + } else { + return send_error_message("invalid octal escape sequence"); + } } else if (ch == '\\') { - return so_far; + return so_far; } else { - return send_error_message("invalid octal escape sequence"); + return send_error_message("invalid octal escape sequence"); } } case 'x': /* hexadecimal character (YAP allows empty hexadecimal */ { - unsigned char so_far = 0; + unsigned char so_far = 0; ch = getchrq(inp_stream); - if (my_isxdigit(ch,'f','F')) {/* hexa */ - so_far = so_far * 16 + (chtype(ch) == NU ? ch - '0' : - (my_isupper(ch) ? ch - 'A' : ch - 'a') + 10); - ch = getchrq(inp_stream); - if (my_isxdigit(ch,'f','F')) { /* hexa */ - so_far = so_far * 16 + (chtype(ch) == NU ? ch - '0' : - (my_isupper(ch) ? ch - 'A' : ch - 'a') + 10); - ch = getchrq(inp_stream); - if (ch == '\\') { - return so_far; - } else { - return send_error_message("invalid hexadecimal escape sequence"); - } - } else if (ch == '\\') { - return so_far; - } else { - return send_error_message("invalid hexadecimal escape sequence"); - } + if (my_isxdigit(ch, 'f', 'F')) { /* hexa */ + so_far = + so_far * 16 + (chtype(ch) == NU + ? ch - '0' + : (my_isupper(ch) ? ch - 'A' : ch - 'a') + 10); + ch = getchrq(inp_stream); + if (my_isxdigit(ch, 'f', 'F')) { /* hexa */ + so_far = + so_far * 16 + (chtype(ch) == NU + ? ch - '0' + : (my_isupper(ch) ? ch - 'A' : ch - 'a') + 10); + ch = getchrq(inp_stream); + if (ch == '\\') { + return so_far; + } else { + return send_error_message("invalid hexadecimal escape sequence"); + } + } else if (ch == '\\') { + return so_far; + } else { + return send_error_message("invalid hexadecimal escape sequence"); + } } else if (ch == '\\') { - return so_far; + return so_far; } else { - return send_error_message("invalid hexadecimal escape sequence"); + return send_error_message("invalid hexadecimal escape sequence"); } } default: @@ -819,10 +838,8 @@ read_quoted_char(int *scan_nextp, IOSTREAM *inp_stream) return send_error_message("invalid escape sequence"); } } - -static int -num_send_error_message(char s[]) -{ + +static int num_send_error_message(char s[]) { CACHE_REGS LOCAL_ErrorMessage = s; return TermNil; @@ -830,10 +847,8 @@ num_send_error_message(char s[]) /* reads a number, either integer or float */ - -static Term -get_num(int *chp, int *chbuffp, IOSTREAM *inp_stream, char *s, UInt max_size, int sign) -{ +static Term get_num(int *chp, int *chbuffp, IOSTREAM *inp_stream, char *s, + UInt max_size, int sign) { GET_LD char *sp = s; int ch = *chp; @@ -845,7 +860,7 @@ get_num(int *chp, int *chbuffp, IOSTREAM *inp_stream, char *s, UInt max_size, in ch = getchr(inp_stream); /* * because of things like 00'2, 03'2 and even better 12'2, I need to - * do this (have mercy) + * do this (have mercy) */ if (chtype(ch) == NU) { *sp++ = ch; @@ -870,14 +885,14 @@ get_num(int *chp, int *chbuffp, IOSTREAM *inp_stream, char *s, UInt max_size, in int scan_extra = TRUE; if (ch == '\\' && - Yap_GetModuleEntry(CurrentModule)->flags & M_CHARESCAPE) { - ascii = read_quoted_char(&scan_extra, inp_stream); + Yap_GetModuleEntry(CurrentModule)->flags & M_CHARESCAPE) { + ascii = read_quoted_char(&scan_extra, inp_stream); } /* a quick way to represent ASCII */ if (scan_extra) - *chp = getchr(inp_stream); + *chp = getchr(inp_stream); if (sign == -1) { - return MkIntegerTerm(-ascii); + return MkIntegerTerm(-ascii); } return MkIntegerTerm(ascii); } else if (base >= 10 && base <= 36) { @@ -885,17 +900,18 @@ get_num(int *chp, int *chbuffp, IOSTREAM *inp_stream, char *s, UInt max_size, in int lower_case = 'a' - 11 + base; while (my_isxdigit(ch, upper_case, lower_case)) { - Int oval = val; - int chval = (chtype(ch) == NU ? ch - '0' : - (my_isupper(ch) ? ch - 'A' : ch - 'a') + 10); - if (--max_size == 0) { - return num_send_error_message("Number Too Long"); - } - *sp++ = ch; - val = oval * base + chval; - if (oval != (val-chval)/base) /* overflow */ - has_overflow = (has_overflow || TRUE); - ch = getchr(inp_stream); + Int oval = val; + int chval = + (chtype(ch) == NU ? ch - '0' + : (my_isupper(ch) ? ch - 'A' : ch - 'a') + 10); + if (--max_size == 0) { + return num_send_error_message("Number Too Long"); + } + *sp++ = ch; + val = oval * base + chval; + if (oval != (val - chval) / base) /* overflow */ + has_overflow = (has_overflow || TRUE); + ch = getchr(inp_stream); } } } else if (ch == 'x' && base == 0) { @@ -907,20 +923,20 @@ get_num(int *chp, int *chbuffp, IOSTREAM *inp_stream, char *s, UInt max_size, in ch = getchr(inp_stream); while (my_isxdigit(ch, 'F', 'f')) { Int oval = val; - int chval = (chtype(ch) == NU ? ch - '0' : - (my_isupper(ch) ? ch - 'A' : ch - 'a') + 10); + int chval = + (chtype(ch) == NU ? ch - '0' + : (my_isupper(ch) ? ch - 'A' : ch - 'a') + 10); if (--max_size == 0) { - return num_send_error_message("Number Too Long"); + return num_send_error_message("Number Too Long"); } *sp++ = ch; val = val * 16 + chval; - if (oval != (val-chval)/16) /* overflow */ - has_overflow = TRUE; + if (oval != (val - chval) / 16) /* overflow */ + has_overflow = TRUE; ch = getchr(inp_stream); } *chp = ch; - } - else if (ch == 'o' && base == 0) { + } else if (ch == 'o' && base == 0) { might_be_float = FALSE; base = 8; ch = getchr(inp_stream); @@ -936,120 +952,119 @@ get_num(int *chp, int *chbuffp, IOSTREAM *inp_stream, char *s, UInt max_size, in Int oval = val; if (!(val == 0 && ch == '0') || has_overflow) { if (--max_size == 0) { - return num_send_error_message("Number Too Long"); + return num_send_error_message("Number Too Long"); } *sp++ = ch; } if (ch - '0' >= base) { if (sign == -1) - return MkIntegerTerm(-val); + return MkIntegerTerm(-val); return MkIntegerTerm(val); } val = val * base + ch - '0'; - if (val/base != oval || val -oval*base != ch-'0') /* overflow */ + if (val / base != oval || val - oval * base != ch - '0') /* overflow */ has_overflow = TRUE; ch = getchr(inp_stream); } - if (might_be_float && ( ch == '.' || ch == 'e' || ch == 'E')) { - int has_dot = ( ch == '.' ); + if (might_be_float && (ch == '.' || ch == 'e' || ch == 'E')) { + int has_dot = (ch == '.'); if (has_dot) { - unsigned char * dp; + unsigned char *dp; int dc; if (chtype(ch = getchr(inp_stream)) != NU) { - if ( ch == 'e' || ch == 'E') { - if (truePrologFlag(PLFLAG_ISO)) - return num_send_error_message("Float format not allowed in ISO mode"); - } else {/* followed by a letter, end of term? */ - sp[0] = '\0'; - *chbuffp = '.'; - *chp = ch; - if (has_overflow) - return read_int_overflow(s,base,val,sign); - if (sign == -1) - return MkIntegerTerm(-val); - return MkIntegerTerm(val); - } + if (ch == 'e' || ch == 'E') { + if (truePrologFlag(PLFLAG_ISO)) + return num_send_error_message( + "Float format not allowed in ISO mode"); + } else { /* followed by a letter, end of term? */ + sp[0] = '\0'; + *chbuffp = '.'; + *chp = ch; + if (has_overflow) + return read_int_overflow(s, base, val, sign); + if (sign == -1) + return MkIntegerTerm(-val); + return MkIntegerTerm(val); + } } #if O_LOCALE - if ((decimalpoint = (unsigned char*) ( localeconv()->decimal_point )) == NULL) + if ((decimalpoint = (unsigned char *)(localeconv()->decimal_point)) == + NULL) #endif - decimalpoint = (const unsigned char*)"."; - dp =(unsigned char *)decimalpoint; + decimalpoint = (const unsigned char *)"."; + dp = (unsigned char *)decimalpoint; /* translate . to current locale */ while ((dc = *dp++) != '\0') { - *sp++ = dc; - if (--max_size == 0) { - return num_send_error_message("Number Too Long"); - } + *sp++ = dc; + if (--max_size == 0) { + return num_send_error_message("Number Too Long"); + } } /* numbers after . */ if (chtype(ch) == NU) { - do { - if (--max_size == 0) { - return num_send_error_message("Number Too Long"); - } - *sp++ = ch; - } - while (chtype(ch = getchr(inp_stream)) == NU); + do { + if (--max_size == 0) { + return num_send_error_message("Number Too Long"); + } + *sp++ = ch; + } while (chtype(ch = getchr(inp_stream)) == NU); } } if (ch == 'e' || ch == 'E') { if (--max_size == 0) { - return num_send_error_message("Number Too Long"); + return num_send_error_message("Number Too Long"); } *sp++ = ch; ch = getchr(inp_stream); if (ch == '-') { - if (--max_size == 0) { - return num_send_error_message("Number Too Long"); - } - *sp++ = '-'; - ch = getchr(inp_stream); + if (--max_size == 0) { + return num_send_error_message("Number Too Long"); + } + *sp++ = '-'; + ch = getchr(inp_stream); } else if (ch == '+') { - ch = getchr(inp_stream); + ch = getchr(inp_stream); } if (chtype(ch) != NU) { - if (has_dot) - return float_send(s,sign); - return MkIntegerTerm(sign*val); + if (has_dot) + return float_send(s, sign); + return MkIntegerTerm(sign * val); } do { - if (--max_size == 0) { - return num_send_error_message("Number Too Long"); - } - *sp++ = ch; + if (--max_size == 0) { + return num_send_error_message("Number Too Long"); + } + *sp++ = ch; } while (chtype(ch = getchr(inp_stream)) == NU); } *sp = '\0'; *chp = ch; - return float_send(s,sign); + return float_send(s, sign); } else if (has_overflow) { *sp = '\0'; /* skip base */ *chp = ch; if (s[0] == '0' && s[1] == 'x') - return read_int_overflow(s+2,16,val,sign); + return read_int_overflow(s + 2, 16, val, sign); else if (s[0] == '0' && s[1] == 'o') - return read_int_overflow(s+2,8,val,sign); + return read_int_overflow(s + 2, 8, val, sign); else if (s[0] == '0' && s[1] == 'b') - return read_int_overflow(s+2,2,val,sign); + return read_int_overflow(s + 2, 2, val, sign); if (s[1] == '\'') - return read_int_overflow(s+2,base,val,sign); + return read_int_overflow(s + 2, base, val, sign); if (s[2] == '\'') - return read_int_overflow(s+3,base,val,sign); - return read_int_overflow(s,base,val,sign); + return read_int_overflow(s + 3, base, val, sign); + return read_int_overflow(s, base, val, sign); } else { *chp = ch; - return MkIntegerTerm(val*sign); + return MkIntegerTerm(val * sign); } } /* given a function getchr scan until we either find the number or end of file */ -Term -Yap_scan_num(IOSTREAM *inp) -{ +Term Yap_scan_num(IOSTREAM *inp) { CACHE_REGS Term out; int sign = 1; @@ -1061,7 +1076,7 @@ Yap_scan_num(IOSTREAM *inp) LOCAL_ScannerExtraBlocks = NULL; if (!(ptr = AllocScannerMemory(4096))) { LOCAL_ErrorMessage = "Trail Overflow"; - LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR; + LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR; return TermNil; } ch = getchr(inp); @@ -1079,7 +1094,7 @@ Yap_scan_num(IOSTREAM *inp) return TermNil; } cherr = '\0'; - if (ASP-HR < 1024) + if (ASP - HR < 1024) return TermNil; out = get_num(&ch, &cherr, inp, ptr, 4096, sign); /* */ PopScannerMemory(ptr, 4096); @@ -1089,24 +1104,21 @@ Yap_scan_num(IOSTREAM *inp) return out; } +#define CHECK_SPACE() \ + if (ASP - HR < 1024) { \ + LOCAL_ErrorMessage = "Stack Overflow"; \ + LOCAL_Error_TYPE = OUT_OF_STACK_ERROR; \ + LOCAL_Error_Size = 0L; \ + if (p) \ + p->Tok = Ord(kind = eot_tok); \ + /* serious error now */ \ + return l; \ + } -#define CHECK_SPACE() \ - if (ASP-HR < 1024) { \ - LOCAL_ErrorMessage = "Stack Overflow"; \ - LOCAL_Error_TYPE = OUT_OF_STACK_ERROR; \ - LOCAL_Error_Size = 0L; \ - if (p) \ - p->Tok = Ord(kind = eot_tok); \ - /* serious error now */ \ - return l; \ - } - - -static void -open_comment(int ch, IOSTREAM *inp_stream USES_REGS) { +static void open_comment(int ch, IOSTREAM *inp_stream USES_REGS) { CELL *h0 = HR; HR += 5; - h0[0] = AbsAppl(h0+2); + h0[0] = AbsAppl(h0 + 2); h0[1] = TermNil; if (!LOCAL_CommentsTail) { /* first comment */ @@ -1114,31 +1126,30 @@ open_comment(int ch, IOSTREAM *inp_stream USES_REGS) { } else { /* extra comment */ *LOCAL_CommentsTail = AbsPair(h0); - } - LOCAL_CommentsTail = h0+1; + } + LOCAL_CommentsTail = h0 + 1; h0 += 2; h0[0] = (CELL)FunctorMinus; h0[1] = Yap_StreamPosition(inp_stream); h0[2] = TermNil; - LOCAL_CommentsNextChar = h0+2; - LOCAL_CommentsBuff = (wchar_t *)malloc(1024*sizeof(wchar_t)); + LOCAL_CommentsNextChar = h0 + 2; + LOCAL_CommentsBuff = (wchar_t *)malloc(1024 * sizeof(wchar_t)); LOCAL_CommentsBuffLim = 1024; LOCAL_CommentsBuff[0] = ch; LOCAL_CommentsBuffPos = 1; } -static void -extend_comment(int ch USES_REGS) { +static void extend_comment(int ch USES_REGS) { LOCAL_CommentsBuff[LOCAL_CommentsBuffPos] = ch; LOCAL_CommentsBuffPos++; - if (LOCAL_CommentsBuffPos == LOCAL_CommentsBuffLim-1) { - LOCAL_CommentsBuff = (wchar_t *)realloc(LOCAL_CommentsBuff,sizeof(wchar_t)*(LOCAL_CommentsBuffLim+4096)); + if (LOCAL_CommentsBuffPos == LOCAL_CommentsBuffLim - 1) { + LOCAL_CommentsBuff = (wchar_t *)realloc( + LOCAL_CommentsBuff, sizeof(wchar_t) * (LOCAL_CommentsBuffLim + 4096)); LOCAL_CommentsBuffLim += 4096; } } -static void -close_comment( USES_REGS1 ) { +static void close_comment(USES_REGS1) { LOCAL_CommentsBuff[LOCAL_CommentsBuffPos] = '\0'; *LOCAL_CommentsNextChar = Yap_WCharsToString(LOCAL_CommentsBuff PASS_REGS); free(LOCAL_CommentsBuff); @@ -1146,49 +1157,62 @@ close_comment( USES_REGS1 ) { LOCAL_CommentsBuffLim = 0; } -static wchar_t * -ch_to_wide(char *base, char *charp) -{ +static wchar_t *ch_to_wide(char *base, char *charp) { CACHE_REGS - int n = charp-base, i; + int n = charp - base, i; wchar_t *nb = (wchar_t *)base; - if ((nb+n) + 1024 > (wchar_t *)AuxSp) { - LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR; - LOCAL_ErrorMessage = "Heap Overflow While Scanning: please increase code space (-h)"; + if ((nb + n) + 1024 > (wchar_t *)AuxSp) { + LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR; + LOCAL_ErrorMessage = + "Heap Overflow While Scanning: please increase code space (-h)"; return NULL; } - for (i=n; i > 0; i--) { - nb[i-1] = (unsigned char)base[i-1]; + for (i = n; i > 0; i--) { + nb[i - 1] = (unsigned char)base[i - 1]; } - return nb+n; + return nb + n; } -#define add_ch_to_buff(ch) \ - if (wcharp) { *wcharp++ = (ch); if (wcharp >= (wchar_t *)AuxSp-1024) goto huge_var_error; charp = (char *)wcharp; } \ - else { \ - if (ch > MAX_ISO_LATIN1 && !wcharp) { \ - /* does not fit in ISO-LATIN */ \ - wcharp = ch_to_wide(TokImage, charp); \ - if (!wcharp) goto huge_var_error; \ - *wcharp++ = (ch); charp = (char *)wcharp; \ - } else { if (charp >= (char *)AuxSp-1024) goto huge_var_error; *charp++ = ch; } \ +#define add_ch_to_buff(ch) \ + if (wcharp) { \ + *wcharp++ = (ch); \ + if (wcharp >= (wchar_t *)AuxSp - 1024) \ + goto huge_var_error; \ + charp = (char *)wcharp; \ + } else { \ + if (ch > MAX_ISO_LATIN1 && !wcharp) { \ + /* does not fit in ISO-LATIN */ \ + wcharp = ch_to_wide(TokImage, charp); \ + if (!wcharp) \ + goto huge_var_error; \ + *wcharp++ = (ch); \ + charp = (char *)wcharp; \ + } else { \ + if (charp >= (char *)AuxSp - 1024) \ + goto huge_var_error; \ + *charp++ = ch; \ + } \ } -#define add_ch_to_utf8_buff(ch) \ - { if ( (ch &0xff) == ch) { *charp++ = ch; } else \ - { charp = _PL__utf8_put_char(charp, ch); } } +#define add_ch_to_utf8_buff(ch) \ + { \ + if ((ch & 0xff) == ch) { \ + *charp++ = ch; \ + } else { \ + charp = _PL__utf8_put_char(charp, ch); \ + } \ + } -TokEntry * -Yap_tokenizer(IOSTREAM *inp_stream, int store_comments, Term *tposp, void *rd0) -{ +TokEntry *Yap_tokenizer(IOSTREAM *inp_stream, int store_comments, Term *tposp, + void *rd0) { GET_LD TokEntry *t, *l, *p; enum TokenKinds kind; int solo_flag = TRUE; int ch; wchar_t *wcharp; - struct qq_struct_t *cur_qq = NULL; + struct qq_struct_t *cur_qq = NULL; struct read_data_t *rd = rd0; LOCAL_ErrorMessage = NULL; @@ -1198,13 +1222,13 @@ Yap_tokenizer(IOSTREAM *inp_stream, int store_comments, Term *tposp, void *rd0) LOCAL_ScannerStack = (char *)TR; LOCAL_ScannerExtraBlocks = NULL; l = NULL; - p = NULL; /* Just to make lint happy */ + p = NULL; /* Just to make lint happy */ ch = getchr(inp_stream); while (chtype(ch) == BS) { ch = getchr(inp_stream); } *tposp = Yap_StreamPosition(inp_stream); - Yap_setCurrentSourceLocation( rd ); + Yap_setCurrentSourceLocation(rd); LOCAL_StartLine = inp_stream->posbuf.lineno; do { wchar_t och; @@ -1213,14 +1237,13 @@ Yap_tokenizer(IOSTREAM *inp_stream, int store_comments, Term *tposp, void *rd0) unsigned int len; char *TokImage = NULL; - - t = (TokEntry *) AllocScannerMemory(sizeof(TokEntry)); + t = (TokEntry *)AllocScannerMemory(sizeof(TokEntry)); t->TokNext = NULL; if (t == NULL) { LOCAL_ErrorMessage = "Trail Overflow"; - LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR; + LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR; if (p) - p->Tok = Ord(kind = eot_tok); + p->Tok = Ord(kind = eot_tok); /* serious error now */ return l; } @@ -1239,40 +1262,41 @@ Yap_tokenizer(IOSTREAM *inp_stream, int store_comments, Term *tposp, void *rd0) case CC: if (store_comments) { - CHECK_SPACE(); - open_comment(ch, inp_stream PASS_REGS); + CHECK_SPACE(); + open_comment(ch, inp_stream PASS_REGS); continue_comment: - while ((ch = getchr(inp_stream)) != 10 && chtype(ch) != EF) { - CHECK_SPACE(); - extend_comment(ch PASS_REGS); - } - CHECK_SPACE(); - extend_comment(ch PASS_REGS); - if (chtype(ch) != EF) { - ch = getchr(inp_stream); - if (chtype(ch) == CC) { - extend_comment(ch PASS_REGS); - goto continue_comment; - } - } - close_comment( PASS_REGS1 ); + while ((ch = getchr(inp_stream)) != 10 && chtype(ch) != EF) { + CHECK_SPACE(); + extend_comment(ch PASS_REGS); + } + CHECK_SPACE(); + extend_comment(ch PASS_REGS); + if (chtype(ch) != EF) { + ch = getchr(inp_stream); + if (chtype(ch) == CC) { + extend_comment(ch PASS_REGS); + goto continue_comment; + } + } + close_comment(PASS_REGS1); } else { - while ((ch = getchr(inp_stream)) != 10 && chtype(ch) != EF); + while ((ch = getchr(inp_stream)) != 10 && chtype(ch) != EF) + ; } if (chtype(ch) != EF) { - /* blank space */ - if (t == l) { - /* we found a comment before reading characters */ - while (chtype(ch) == BS) { - ch = getchr(inp_stream); - } - CHECK_SPACE(); - *tposp = Yap_StreamPosition(inp_stream); - Yap_setCurrentSourceLocation( rd ); - } - goto restart; + /* blank space */ + if (t == l) { + /* we found a comment before reading characters */ + while (chtype(ch) == BS) { + ch = getchr(inp_stream); + } + CHECK_SPACE(); + *tposp = Yap_StreamPosition(inp_stream); + Yap_setCurrentSourceLocation(rd); + } + goto restart; } else { - t->Tok = Ord(kind = eot_tok); + t->Tok = Ord(kind = eot_tok); } break; @@ -1282,180 +1306,180 @@ Yap_tokenizer(IOSTREAM *inp_stream, int store_comments, Term *tposp, void *rd0) och = ch; ch = getchr(inp_stream); scan_name: - TokImage = ((AtomEntry *) ( Yap_PreAllocCodeSpace()))->StrOfAE; + TokImage = ((AtomEntry *)(Yap_PreAllocCodeSpace()))->StrOfAE; charp = TokImage; wcharp = NULL; isvar = (chtype(och) != LC); add_ch_to_buff(och); for (; chtype(ch) <= NU; ch = getchr(inp_stream)) { - if (charp == (char *)AuxSp-1024) { - huge_var_error: - /* huge atom or variable, we are in trouble */ - LOCAL_ErrorMessage = "Code Space Overflow due to huge atom"; - LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR; - Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); - if (p) - p->Tok = Ord(kind = eot_tok); - /* serious error now */ - return l; - } - add_ch_to_buff(ch); + if (charp == (char *)AuxSp - 1024) { + huge_var_error: + /* huge atom or variable, we are in trouble */ + LOCAL_ErrorMessage = "Code Space Overflow due to huge atom"; + LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR; + Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); + if (p) + p->Tok = Ord(kind = eot_tok); + /* serious error now */ + return l; + } + add_ch_to_buff(ch); } while (ch == '\'' && isvar && yap_flags[VARS_CAN_HAVE_QUOTE_FLAG]) { - if (charp == (char *)AuxSp-1024) { - goto huge_var_error; - } - add_ch_to_buff(ch); - ch = getchr(inp_stream); + if (charp == (char *)AuxSp - 1024) { + goto huge_var_error; + } + add_ch_to_buff(ch); + ch = getchr(inp_stream); } add_ch_to_buff('\0'); if (!isvar) { - Atom ae; - /* don't do this in iso */ - if (wcharp) { - ae = Yap_LookupWideAtom((wchar_t *)TokImage); - } else { - ae = Yap_LookupAtom(TokImage); - } - if (ae == NIL) { - LOCAL_Error_TYPE = OUT_OF_HEAP_ERROR; - LOCAL_ErrorMessage = "Code Space Overflow"; - if (p) - t->Tok = Ord(kind = eot_tok); - /* serious error now */ - return l; - } - t->TokInfo = Unsigned(ae); - Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); - if (ch == '(') - solo_flag = FALSE; - t->Tok = Ord(kind = Name_tok); + Atom ae; + /* don't do this in iso */ + if (wcharp) { + ae = Yap_LookupWideAtom((wchar_t *)TokImage); + } else { + ae = Yap_LookupAtom(TokImage); + } + if (ae == NIL) { + LOCAL_Error_TYPE = OUT_OF_HEAP_ERROR; + LOCAL_ErrorMessage = "Code Space Overflow"; + if (p) + t->Tok = Ord(kind = eot_tok); + /* serious error now */ + return l; + } + t->TokInfo = Unsigned(ae); + Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); + if (ch == '(') + solo_flag = FALSE; + t->Tok = Ord(kind = Name_tok); } else { - VarEntry *ve = Yap_LookupVar(TokImage); - t->TokInfo = Unsigned(ve); - if (cur_qq) { - ve->refs++; - } - Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); - t->Tok = Ord(kind = Var_tok); + VarEntry *ve = Yap_LookupVar(TokImage); + t->TokInfo = Unsigned(ve); + if (cur_qq) { + ve->refs++; + } + Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); + t->Tok = Ord(kind = Var_tok); } break; - case NU: - { - int cherr; - int cha = ch; - char *ptr; + case NU: { + int cherr; + int cha = ch; + char *ptr; - cherr = 0; - if (!(ptr = AllocScannerMemory(4096))) { - LOCAL_ErrorMessage = "Trail Overflow"; - LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR; - if (p) - t->Tok = Ord(kind = eot_tok); - /* serious error now */ - return l; - } - CHECK_SPACE(); - if ((t->TokInfo = get_num(&cha,&cherr,inp_stream,ptr,4096,1)) == 0L) { - if (p) - p->Tok = Ord(kind = eot_tok); - /* serious error now */ - return l; - } - PopScannerMemory(ptr, 4096); - ch = cha; - if (cherr) { - TokEntry *e; - t->Tok = Number_tok; - t->TokPos = GetCurInpPos(inp_stream); - e = (TokEntry *) AllocScannerMemory(sizeof(TokEntry)); - if (e == NULL) { - LOCAL_ErrorMessage = "Trail Overflow"; - LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR; - if (p) - p->Tok = Ord(kind = eot_tok); - /* serious error now */ - return l; - } else { - e->TokNext = NULL; - } - t->TokNext = e; - t = e; - p = e; - switch (cherr) { - case 'e': - case 'E': - och = cherr; - goto scan_name; - break; - case '=': - case '_': - /* handle error while parsing a float */ - { - TokEntry *e2; - - t->Tok = Ord(Var_tok); - t->TokInfo = Unsigned(Yap_LookupVar("E")); - t->TokPos = GetCurInpPos(inp_stream); - e2 = (TokEntry *) AllocScannerMemory(sizeof(TokEntry)); - if (e2 == NULL) { - LOCAL_ErrorMessage = "Trail Overflow"; - LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR; - if (p) - p->Tok = Ord(kind = eot_tok); - /* serious error now */ - return l; - } else { - e2->TokNext = NULL; - } - t->TokNext = e2; - t = e2; - p = e2; - if (cherr == '=') - och = '+'; - else - och = '-'; - } - goto enter_symbol; - case '+': - case '-': - /* handle error while parsing a float */ - { - TokEntry *e2; - - t->Tok = Name_tok; - if (ch == '(') - solo_flag = FALSE; - t->TokInfo = Unsigned(AtomE); - t->TokPos = GetCurInpPos(inp_stream); - e2 = (TokEntry *) AllocScannerMemory(sizeof(TokEntry)); - if (e2 == NULL) { - LOCAL_ErrorMessage = "Trail Overflow"; - LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR; - t->Tok = Ord(kind = eot_tok); - /* serious error now */ - return l; - } else { - e2->TokNext = NULL; - } - t->TokNext = e2; - t = e2; - p = e2; - } - default: - och = cherr; - goto enter_symbol; - } - } else { - t->Tok = Ord(kind = Number_tok); - } + cherr = 0; + if (!(ptr = AllocScannerMemory(4096))) { + LOCAL_ErrorMessage = "Trail Overflow"; + LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR; + if (p) + t->Tok = Ord(kind = eot_tok); + /* serious error now */ + return l; } - break; + CHECK_SPACE(); + if ((t->TokInfo = get_num(&cha, &cherr, inp_stream, ptr, 4096, 1)) == + 0L) { + if (p) + p->Tok = Ord(kind = eot_tok); + /* serious error now */ + return l; + } + PopScannerMemory(ptr, 4096); + ch = cha; + if (cherr) { + TokEntry *e; + t->Tok = Number_tok; + t->TokPos = GetCurInpPos(inp_stream); + e = (TokEntry *)AllocScannerMemory(sizeof(TokEntry)); + if (e == NULL) { + LOCAL_ErrorMessage = "Trail Overflow"; + LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR; + if (p) + p->Tok = Ord(kind = eot_tok); + /* serious error now */ + return l; + } else { + e->TokNext = NULL; + } + t->TokNext = e; + t = e; + p = e; + switch (cherr) { + case 'e': + case 'E': + och = cherr; + goto scan_name; + break; + case '=': + case '_': + /* handle error while parsing a float */ + { + TokEntry *e2; + + t->Tok = Ord(Var_tok); + t->TokInfo = Unsigned(Yap_LookupVar("E")); + t->TokPos = GetCurInpPos(inp_stream); + e2 = (TokEntry *)AllocScannerMemory(sizeof(TokEntry)); + if (e2 == NULL) { + LOCAL_ErrorMessage = "Trail Overflow"; + LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR; + if (p) + p->Tok = Ord(kind = eot_tok); + /* serious error now */ + return l; + } else { + e2->TokNext = NULL; + } + t->TokNext = e2; + t = e2; + p = e2; + if (cherr == '=') + och = '+'; + else + och = '-'; + } + goto enter_symbol; + case '+': + case '-': + /* handle error while parsing a float */ + { + TokEntry *e2; + + t->Tok = Name_tok; + if (ch == '(') + solo_flag = FALSE; + t->TokInfo = Unsigned(AtomE); + t->TokPos = GetCurInpPos(inp_stream); + e2 = (TokEntry *)AllocScannerMemory(sizeof(TokEntry)); + if (e2 == NULL) { + LOCAL_ErrorMessage = "Trail Overflow"; + LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR; + t->Tok = Ord(kind = eot_tok); + /* serious error now */ + return l; + } else { + e2->TokNext = NULL; + } + t->TokNext = e2; + t = e2; + p = e2; + } + default: + och = cherr; + goto enter_symbol; + } + } else { + t->Tok = Ord(kind = Number_tok); + } + } break; case QT: case DC: - TokImage = ((AtomEntry *) ( Yap_PreAllocCodeSpace()))->StrOfAE; + quoted_string: + TokImage = ((AtomEntry *)(Yap_PreAllocCodeSpace()))->StrOfAE; charp = TokImage; quote = ch; len = 0; @@ -1463,350 +1487,385 @@ Yap_tokenizer(IOSTREAM *inp_stream, int store_comments, Term *tposp, void *rd0) wcharp = NULL; while (TRUE) { - if (charp + 1024 > (char *)AuxSp) { - LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR; - LOCAL_ErrorMessage = "Heap Overflow While Scanning: please increase code space (-h)"; - break; - } - if (ch == 10 && truePrologFlag(PLFLAG_ISO)) { - /* in ISO a new line terminates a string */ - LOCAL_ErrorMessage = "layout character \n inside quotes"; - break; - } - if (ch == quote) { - ch = getchrq(inp_stream); - if (ch != quote) - break; - add_ch_to_buff(ch); - ch = getchrq(inp_stream); - } else if (ch == '\\' && Yap_GetModuleEntry(CurrentModule)->flags & M_CHARESCAPE) { - int scan_next = TRUE; - if ((ch = read_quoted_char(&scan_next, inp_stream))) { - add_ch_to_buff(ch); - } - if (scan_next) { - ch = getchrq(inp_stream); - } - } else if (chtype(ch) == EF && ch <= MAX_ISO_LATIN1) { - Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); - t->Tok = Ord(kind = eot_tok); - break; - } else { - add_ch_to_buff(ch); - ch = getchrq(inp_stream); - } - ++len; - if (charp > (char *)AuxSp - 1024) { - /* Not enough space to read in the string. */ - LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR; - LOCAL_ErrorMessage = "not enough space to read in string or quoted atom"; - /* serious error now */ - Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); - t->Tok = Ord(kind = eot_tok); - return l; - } + if (charp + 1024 > (char *)AuxSp) { + LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR; + LOCAL_ErrorMessage = + "Heap Overflow While Scanning: please increase code space (-h)"; + break; + } + if (ch == 10 && truePrologFlag(PLFLAG_ISO)) { + /* in ISO a new line terminates a string */ + LOCAL_ErrorMessage = "layout character \n inside quotes"; + break; + } + if (ch == quote) { + ch = getchrq(inp_stream); + if (ch != quote) + break; + add_ch_to_buff(ch); + ch = getchrq(inp_stream); + } else if (ch == '\\' && + Yap_GetModuleEntry(CurrentModule)->flags & M_CHARESCAPE) { + int scan_next = TRUE; + if ((ch = read_quoted_char(&scan_next, inp_stream))) { + add_ch_to_buff(ch); + } + if (scan_next) { + ch = getchrq(inp_stream); + } + } else if (chtype(ch) == EF && ch <= MAX_ISO_LATIN1) { + Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); + t->Tok = Ord(kind = eot_tok); + break; + } else { + add_ch_to_buff(ch); + ch = getchrq(inp_stream); + } + ++len; + if (charp > (char *)AuxSp - 1024) { + /* Not enough space to read in the string. */ + LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR; + LOCAL_ErrorMessage = + "not enough space to read in string or quoted atom"; + /* serious error now */ + Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); + t->Tok = Ord(kind = eot_tok); + return l; + } } if (wcharp) { - *wcharp = '\0'; - } else { - *charp = '\0'; + *wcharp = '\0'; + } else { + *charp = '\0'; } if (quote == '"') { - if (wcharp) { - mp = AllocScannerMemory(sizeof(wchar_t)*(len+1)); - } else { - mp = AllocScannerMemory(len + 1); - } - if (mp == NULL) { - LOCAL_ErrorMessage = "not enough heap space to read in string or quoted atom"; - Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); - t->Tok = Ord(kind = eot_tok); - return l; - } - if (wcharp) - wcscpy((wchar_t *)mp,(wchar_t *)TokImage); - else - strcpy(mp, TokImage); - t->TokInfo = Unsigned(mp); - Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); - if (wcharp) { - t->Tok = Ord(kind = WString_tok); - } else { - t->Tok = Ord(kind = String_tok); - } - } else { - if (wcharp) { - t->TokInfo = Unsigned(Yap_LookupWideAtom((wchar_t *)TokImage)); - } else { - t->TokInfo = Unsigned(Yap_LookupAtom(TokImage)); - } - if (!(t->TokInfo)) { - LOCAL_Error_TYPE = OUT_OF_HEAP_ERROR; - LOCAL_ErrorMessage = "Code Space Overflow"; - if (p) - t->Tok = Ord(kind = eot_tok); - /* serious error now */ - return l; - } - Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); - t->Tok = Ord(kind = Name_tok); - if (ch == '(') - solo_flag = FALSE; + if (wcharp) { + mp = AllocScannerMemory(sizeof(wchar_t) * (len + 1)); + } else { + mp = AllocScannerMemory(len + 1); + } + if (mp == NULL) { + LOCAL_ErrorMessage = + "not enough heap space to read in string or quoted atom"; + Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); + t->Tok = Ord(kind = eot_tok); + return l; + } + if (wcharp) { + wcscpy((wchar_t *)mp, (wchar_t *)TokImage); + } else { + strcpy(mp, TokImage); + } + t->TokInfo = Unsigned(mp); + Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); + if (wcharp) { + t->Tok = Ord(kind = WString_tok); + } else { + t->Tok = Ord(kind = String_tok); + } + } else if (quote == '`') { + if (wcharp) { + mp = AllocScannerMemory( utf8_strlen1(TokImage) + 1 ); + } else { + mp = AllocScannerMemory(len + 1); + } + if (mp == NULL) { + LOCAL_ErrorMessage = + "not enough heap space to read in string or quoted atom"; + Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); + t->Tok = Ord(kind = eot_tok); + return l; + } + if (wcharp) { + utf8_wcscpy(mp, (const wchar_t *)TokImage); + } else { + strcpy(mp, TokImage); + } + t->TokInfo = Unsigned(mp); + Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); + t->Tok = Ord(kind = StringTerm_tok); + } else { + if (wcharp) { + t->TokInfo = Unsigned(Yap_LookupWideAtom((wchar_t *)TokImage)); + } else { + t->TokInfo = Unsigned(Yap_LookupAtom(TokImage)); + } + if (!(t->TokInfo)) { + LOCAL_Error_TYPE = OUT_OF_HEAP_ERROR; + LOCAL_ErrorMessage = "Code Space Overflow"; + if (p) + t->Tok = Ord(kind = eot_tok); + /* serious error now */ + return l; + } + Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); + t->Tok = Ord(kind = Name_tok); + if (ch == '(') + solo_flag = FALSE; } break; case SY: + if (ch == '`' && truePrologFlag(PLFLAG_BACKQUOTED_STRING)) + goto quoted_string; och = ch; ch = getchr(inp_stream); if (och == '/' && ch == '*') { - if (store_comments) { - CHECK_SPACE(); - open_comment('/', inp_stream PASS_REGS); - while ((och != '*' || ch != '/') && chtype(ch) != EF) { - och = ch; - CHECK_SPACE(); - extend_comment(ch PASS_REGS); - ch = getchr(inp_stream); - } - if (chtype(ch) != EF) { - CHECK_SPACE(); - extend_comment(ch PASS_REGS); - } - close_comment( PASS_REGS1 ); - } else { - while ((och != '*' || ch != '/') && chtype(ch) != EF) { - och = ch; - ch = getchr(inp_stream); - } - } - if (chtype(ch) == EF) { - t->Tok = Ord(kind = eot_tok); - } else { - /* leave comments */ - ch = getchr(inp_stream); - if (t == l) { - /* we found a comment before reading characters */ - while (chtype(ch) == BS) { - ch = getchr(inp_stream); - } - CHECK_SPACE(); - *tposp = Yap_StreamPosition(inp_stream); - Yap_setCurrentSourceLocation( rd ); - } - } - goto restart; + if (store_comments) { + CHECK_SPACE(); + open_comment('/', inp_stream PASS_REGS); + while ((och != '*' || ch != '/') && chtype(ch) != EF) { + och = ch; + CHECK_SPACE(); + extend_comment(ch PASS_REGS); + ch = getchr(inp_stream); + } + if (chtype(ch) != EF) { + CHECK_SPACE(); + extend_comment(ch PASS_REGS); + } + close_comment(PASS_REGS1); + } else { + while ((och != '*' || ch != '/') && chtype(ch) != EF) { + och = ch; + ch = getchr(inp_stream); + } + } + if (chtype(ch) == EF) { + t->Tok = Ord(kind = eot_tok); + } else { + /* leave comments */ + ch = getchr(inp_stream); + if (t == l) { + /* we found a comment before reading characters */ + while (chtype(ch) == BS) { + ch = getchr(inp_stream); + } + CHECK_SPACE(); + *tposp = Yap_StreamPosition(inp_stream); + Yap_setCurrentSourceLocation(rd); + } + } + goto restart; } enter_symbol: - if (och == '.' && (chtype(ch) == BS || chtype(ch) == EF - || chtype(ch) == CC)) { - if (chtype(ch) == CC) - while ((ch = getchr(inp_stream)) != 10 && chtype(ch) != EF); - t->Tok = Ord(kind = eot_tok); + if (och == '.' && + (chtype(ch) == BS || chtype(ch) == EF || chtype(ch) == CC)) { + if (chtype(ch) == CC) + while ((ch = getchr(inp_stream)) != 10 && chtype(ch) != EF) + ; + t->Tok = Ord(kind = eot_tok); } else { - Atom ae; - TokImage = ((AtomEntry *) ( Yap_PreAllocCodeSpace()))->StrOfAE; - charp = TokImage; - wcharp = NULL; - add_ch_to_buff(och); - for (; chtype(ch) == SY; ch = getchr(inp_stream)) { - if (charp == (char *)AuxSp-1024) { - goto huge_var_error; - } - add_ch_to_buff(ch); - } - add_ch_to_buff('\0'); - if (wcharp) { - ae = Yap_LookupWideAtom((wchar_t *)TokImage); - } else { - ae = Yap_LookupAtom(TokImage); - } - if (ae == NIL) { - LOCAL_Error_TYPE = OUT_OF_HEAP_ERROR; - LOCAL_ErrorMessage = "Code Space Overflow"; - if (p) - t->Tok = Ord(kind = eot_tok); - /* serious error now */ - return l; - } - t->TokInfo = Unsigned(ae); - if (t->TokInfo == (CELL)NIL) { - LOCAL_Error_TYPE = OUT_OF_HEAP_ERROR; - LOCAL_ErrorMessage = "Code Space Overflow"; - if (p) - t->Tok = Ord(kind = eot_tok); - /* serious error now */ - return l; - } - Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); - t->Tok = Ord(kind = Name_tok); - if (ch == '(') - solo_flag = FALSE; - else - solo_flag = TRUE; - } - break; - - case SL: - { - char chs[2]; - chs[0] = ch; - chs[1] = '\0'; - ch = getchr(inp_stream); - t->TokInfo = Unsigned(Yap_LookupAtom(chs)); - t->Tok = Ord(kind = Name_tok); - if (ch == '(') - solo_flag = FALSE; + Atom ae; + TokImage = ((AtomEntry *)(Yap_PreAllocCodeSpace()))->StrOfAE; + charp = TokImage; + wcharp = NULL; + add_ch_to_buff(och); + for (; chtype(ch) == SY; ch = getchr(inp_stream)) { + if (charp == (char *)AuxSp - 1024) { + goto huge_var_error; + } + add_ch_to_buff(ch); + } + add_ch_to_buff('\0'); + if (wcharp) { + ae = Yap_LookupWideAtom((wchar_t *)TokImage); + } else { + ae = Yap_LookupAtom(TokImage); + } + if (ae == NIL) { + LOCAL_Error_TYPE = OUT_OF_HEAP_ERROR; + LOCAL_ErrorMessage = "Code Space Overflow"; + if (p) + t->Tok = Ord(kind = eot_tok); + /* serious error now */ + return l; + } + t->TokInfo = Unsigned(ae); + if (t->TokInfo == (CELL)NIL) { + LOCAL_Error_TYPE = OUT_OF_HEAP_ERROR; + LOCAL_ErrorMessage = "Code Space Overflow"; + if (p) + t->Tok = Ord(kind = eot_tok); + /* serious error now */ + return l; + } + Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); + t->Tok = Ord(kind = Name_tok); + if (ch == '(') + solo_flag = FALSE; + else + solo_flag = TRUE; } break; + case SL: { + char chs[2]; + chs[0] = ch; + chs[1] = '\0'; + ch = getchr(inp_stream); + t->TokInfo = Unsigned(Yap_LookupAtom(chs)); + t->Tok = Ord(kind = Name_tok); + if (ch == '(') + solo_flag = FALSE; + } break; + case BK: och = ch; ch = getchr(inp_stream); t->TokInfo = och; - if (och == '(') { - while (chtype(ch) == BS) { ch = getchr(inp_stream); }; - if (ch == ')') { - t->TokInfo = Unsigned(AtomEmptyBrackets); - t->Tok = Ord(kind = Name_tok); - ch = getchr(inp_stream); - solo_flag = FALSE; - break; - } else if (!solo_flag) { - t->TokInfo = 'l'; - solo_flag = TRUE; - } - } else if (och == '[') { - while (chtype(ch) == BS) { ch = getchr(inp_stream); }; - if (ch == ']') { - t->TokInfo = Unsigned(AtomNil); - t->Tok = Ord(kind = Name_tok); - ch = getchr(inp_stream); - solo_flag = FALSE; - break; - } - } else if (och == '{') { - if (ch == '|') { - qq_t *qq = (qq_t *)calloc(sizeof(qq_t), 1); - if (!qq) { - LOCAL_ErrorMessage = "not enough heap space to read in quasi quote"; - Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); - t->Tok = Ord(kind = eot_tok); - return l; - } - if (cur_qq) { - LOCAL_ErrorMessage = "quasi quote in quasi quote"; - Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); - t->Tok = Ord(kind = eot_tok); - free( qq ); - return l; - } else { - cur_qq = qq; - } - t->TokInfo = (CELL)qq; - qq->start.byteno = inp_stream->position->byteno; - qq->start.lineno = inp_stream->position->lineno; - qq->start.linepos = inp_stream->position->linepos - 1; - qq->start.charno = inp_stream->position->charno - 1; - t->Tok = Ord(kind = QuasiQuotes_tok); - ch = getchr(inp_stream); - solo_flag = FALSE; - break; - } - while (chtype(ch) == BS) { ch = getchr(inp_stream); }; - if (ch == '}') { - t->TokInfo = Unsigned(AtomBraces); - t->Tok = Ord(kind = Name_tok); - ch = getchr(inp_stream); - solo_flag = FALSE; - break; - } + if (och == '(') { + while (chtype(ch) == BS) { + ch = getchr(inp_stream); + }; + if (ch == ')') { + t->TokInfo = Unsigned(AtomEmptyBrackets); + t->Tok = Ord(kind = Name_tok); + ch = getchr(inp_stream); + solo_flag = FALSE; + break; + } else if (!solo_flag) { + t->TokInfo = 'l'; + solo_flag = TRUE; + } + } else if (och == '[') { + while (chtype(ch) == BS) { + ch = getchr(inp_stream); + }; + if (ch == ']') { + t->TokInfo = Unsigned(AtomNil); + t->Tok = Ord(kind = Name_tok); + ch = getchr(inp_stream); + solo_flag = FALSE; + break; + } + } else if (och == '{') { + if (ch == '|') { + qq_t *qq = (qq_t *)calloc(sizeof(qq_t), 1); + if (!qq) { + LOCAL_ErrorMessage = "not enough heap space to read in quasi quote"; + Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); + t->Tok = Ord(kind = eot_tok); + return l; + } + if (cur_qq) { + LOCAL_ErrorMessage = "quasi quote in quasi quote"; + Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); + t->Tok = Ord(kind = eot_tok); + free(qq); + return l; + } else { + cur_qq = qq; + } + t->TokInfo = (CELL)qq; + qq->start.byteno = inp_stream->position->byteno; + qq->start.lineno = inp_stream->position->lineno; + qq->start.linepos = inp_stream->position->linepos - 1; + qq->start.charno = inp_stream->position->charno - 1; + t->Tok = Ord(kind = QuasiQuotes_tok); + ch = getchr(inp_stream); + solo_flag = FALSE; + break; + } + while (chtype(ch) == BS) { + ch = getchr(inp_stream); + }; + if (ch == '}') { + t->TokInfo = Unsigned(AtomBraces); + t->Tok = Ord(kind = Name_tok); + ch = getchr(inp_stream); + solo_flag = FALSE; + break; + } } else if (och == '|' && ch == '|') { - qq_t *qq = cur_qq; - if (!qq) { - LOCAL_ErrorMessage = "quasi quoted's || without {|"; - Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); - free( cur_qq ); - cur_qq = NULL; - t->Tok = Ord(kind = eot_tok); - return l; - } - cur_qq = NULL; - t->TokInfo = (CELL)qq; - qq->mid.byteno = inp_stream->position->byteno; - qq->mid.lineno = inp_stream->position->lineno; - qq->mid.linepos = inp_stream->position->linepos - 1; - qq->mid.charno = inp_stream->position->charno - 1; - t->Tok = Ord(kind = QuasiQuotes_tok); - ch = getchr(inp_stream); + qq_t *qq = cur_qq; + if (!qq) { + LOCAL_ErrorMessage = "quasi quoted's || without {|"; + Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); + free(cur_qq); + cur_qq = NULL; + t->Tok = Ord(kind = eot_tok); + return l; + } + cur_qq = NULL; + t->TokInfo = (CELL)qq; + qq->mid.byteno = inp_stream->position->byteno; + qq->mid.lineno = inp_stream->position->lineno; + qq->mid.linepos = inp_stream->position->linepos - 1; + qq->mid.charno = inp_stream->position->charno - 1; + t->Tok = Ord(kind = QuasiQuotes_tok); + ch = getchr(inp_stream); - TokImage = Yap_PreAllocCodeSpace(); - if (!TokImage) { - LOCAL_ErrorMessage = "not enough heap space to read in a quasi quoted atom"; - Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); - t->Tok = Ord(kind = eot_tok); - return l; - } - charp = TokImage; - quote = ch; - len = 0; - ch = getchrq(inp_stream); - wcharp = NULL; + TokImage = Yap_PreAllocCodeSpace(); + if (!TokImage) { + LOCAL_ErrorMessage = + "not enough heap space to read in a quasi quoted atom"; + Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); + t->Tok = Ord(kind = eot_tok); + return l; + } + charp = TokImage; + quote = ch; + len = 0; + ch = getchrq(inp_stream); + wcharp = NULL; - while (TRUE) { - if (ch == '|') { - ch = getchrq(inp_stream); - if (ch != '}') { - } else { - add_ch_to_utf8_buff(och); - add_ch_to_utf8_buff(ch); - /* we're done */ - break; - } - } else if (chtype(ch) == EF) { - Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); - t->Tok = Ord(kind = eot_tok); - break; - } else { - add_ch_to_utf8_buff(ch); - ch = getchrq(inp_stream); - } - if (charp > (char *)AuxSp - 1024) { - /* Not enough space to read in the string. */ - LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR; - LOCAL_ErrorMessage = "not enough space to read in string or quoted atom"; - /* serious error now */ - Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); - t->Tok = Ord(kind = eot_tok); - return l; - } - } - len = charp-TokImage; - mp = malloc(len + 1); - if (mp == NULL) { - LOCAL_ErrorMessage = "not enough heap space to read in quasi quote"; - Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); - t->Tok = Ord(kind = eot_tok); - return l; - } - strncpy(mp, TokImage, len+1); - qq->text = (unsigned char *)mp; - Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); - qq->end.byteno = inp_stream->position->byteno; - qq->end.lineno = inp_stream->position->lineno; - qq->end.linepos = inp_stream->position->linepos - 1; - qq->end.charno = inp_stream->position->charno - 1; - if (!(t->TokInfo)) { - LOCAL_Error_TYPE = OUT_OF_HEAP_ERROR; - LOCAL_ErrorMessage = "Code Space Overflow"; - if (p) - t->Tok = Ord(kind = eot_tok); - /* serious error now */ - return l; - } - Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); - solo_flag = FALSE; - ch = getchr(inp_stream); - break; + while (TRUE) { + if (ch == '|') { + ch = getchrq(inp_stream); + if (ch != '}') { + } else { + add_ch_to_utf8_buff(och); + add_ch_to_utf8_buff(ch); + /* we're done */ + break; + } + } else if (chtype(ch) == EF) { + Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); + t->Tok = Ord(kind = eot_tok); + break; + } else { + add_ch_to_utf8_buff(ch); + ch = getchrq(inp_stream); + } + if (charp > (char *)AuxSp - 1024) { + /* Not enough space to read in the string. */ + LOCAL_Error_TYPE = OUT_OF_AUXSPACE_ERROR; + LOCAL_ErrorMessage = + "not enough space to read in string or quoted atom"; + /* serious error now */ + Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); + t->Tok = Ord(kind = eot_tok); + return l; + } + } + len = charp - TokImage; + mp = malloc(len + 1); + if (mp == NULL) { + LOCAL_ErrorMessage = "not enough heap space to read in quasi quote"; + Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); + t->Tok = Ord(kind = eot_tok); + return l; + } + strncpy(mp, TokImage, len + 1); + qq->text = (unsigned char *)mp; + Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); + qq->end.byteno = inp_stream->position->byteno; + qq->end.lineno = inp_stream->position->lineno; + qq->end.linepos = inp_stream->position->linepos - 1; + qq->end.charno = inp_stream->position->charno - 1; + if (!(t->TokInfo)) { + LOCAL_Error_TYPE = OUT_OF_HEAP_ERROR; + LOCAL_ErrorMessage = "Code Space Overflow"; + if (p) + t->Tok = Ord(kind = eot_tok); + /* serious error now */ + return l; + } + Yap_ReleasePreAllocCodeSpace((CODEADDR)TokImage); + solo_flag = FALSE; + ch = getchr(inp_stream); + break; } t->Tok = Ord(kind = Ponctuation_tok); break; @@ -1821,17 +1880,19 @@ Yap_tokenizer(IOSTREAM *inp_stream, int store_comments, Term *tposp, void *rd0) t->Tok = Ord(kind = eot_tok); } #if DEBUG - if(GLOBAL_Option[2]) fprintf(stderr,"[Token %d %ld]",Ord(kind),(unsigned long int)t->TokInfo); + if (GLOBAL_Option[2]) + fprintf(stderr, "[Token %d %ld]", Ord(kind), + (unsigned long int)t->TokInfo); #endif if (LOCAL_ErrorMessage) { /* insert an error token to inform the system of what happened */ - TokEntry *e = (TokEntry *) AllocScannerMemory(sizeof(TokEntry)); + TokEntry *e = (TokEntry *)AllocScannerMemory(sizeof(TokEntry)); if (e == NULL) { - LOCAL_ErrorMessage = "Trail Overflow"; - LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR; - p->Tok = Ord(kind = eot_tok); - /* serious error now */ - return l; + LOCAL_ErrorMessage = "Trail Overflow"; + LOCAL_Error_TYPE = OUT_OF_TRAIL_ERROR; + p->Tok = Ord(kind = eot_tok); + /* serious error now */ + return l; } p->TokNext = e; e->Tok = Error_tok; @@ -1845,9 +1906,8 @@ Yap_tokenizer(IOSTREAM *inp_stream, int store_comments, Term *tposp, void *rd0) return (l); } -void -Yap_clean_tokenizer(TokEntry *tokstart, VarEntry *vartable, VarEntry *anonvartable, Term commentable) -{ +void Yap_clean_tokenizer(TokEntry *tokstart, VarEntry *vartable, + VarEntry *anonvartable, Term commentable) { CACHE_REGS struct scanner_extra_alloc *ptr = LOCAL_ScannerExtraBlocks; while (ptr) { @@ -1864,5 +1924,4 @@ Yap_clean_tokenizer(TokEntry *tokstart, VarEntry *vartable, VarEntry *anonvartab LOCAL_CommentsBuffLim = 0; } - /// @} diff --git a/C/write.c b/C/write.c index ec7df439a..669eaff81 100644 --- a/C/write.c +++ b/C/write.c @@ -15,7 +15,7 @@ * * *************************************************************************/ #ifdef SCCS -static char SccsId[] = "%W% %G%"; +static char SccsId[] = "%W% %G%"; #endif #include @@ -43,12 +43,12 @@ static char SccsId[] = "%W% %G%"; /* describe the type of the previous term to have been written */ typedef enum { - separator, /* the previous term was a separator like ',', ')', ... */ - alphanum, /* the previous term was an atom or number */ - symbol /* the previous term was a symbol like +, -, *, .... */ + separator, /* the previous term was a separator like ',', ')', ... */ + alphanum, /* the previous term was an atom or number */ + symbol /* the previous term was a symbol like +, -, *, .... */ } wtype; -typedef void *wrf; +typedef void *wrf; typedef struct union_slots { Int old; @@ -60,8 +60,7 @@ typedef struct union_direct { CELL *ptr; } udirect; - -typedef struct rewind_term { +typedef struct rewind_term { struct rewind_term *parent; union { struct union_slots s; @@ -70,39 +69,38 @@ typedef struct rewind_term { } rwts; typedef struct write_globs { - IOSTREAM*stream; - int Quote_illegal, Ignore_ops, Handle_vars, Use_portray, Portray_delays; - int Keep_terms; - int Write_Loops; - int Write_strings; - int last_atom_minus; - UInt MaxDepth, MaxArgs; - wtype lw; + IOSTREAM *stream; + int Quote_illegal, Ignore_ops, Handle_vars, Use_portray, Portray_delays; + int Keep_terms; + int Write_Loops; + int Write_strings; + int last_atom_minus; + UInt MaxDepth, MaxArgs; + wtype lw; } wglbs; #define lastw wglb->lw #define last_minus wglb->last_atom_minus -static bool -callPortray(Term t, struct DB_TERM **old_EXp USES_REGS) -{ +static bool callPortray(Term t, struct DB_TERM **old_EXp USES_REGS) { PredEntry *pe; - Int b0 = LCL0-(CELL*)B; + Int b0 = LCL0 - (CELL *)B; EX = NULL; - if ( (pe = RepPredProp(Yap_GetPredPropByFunc(FunctorPortray, USER_MODULE) ) ) && - pe->OpcodeOfPred != FAIL_OPCODE && - pe->OpcodeOfPred != UNDEF_OPCODE && - Yap_execute_pred(pe, &t PASS_REGS) ) { - choiceptr B0 = (choiceptr)(LCL0-b0); - if (EX && !*old_EXp) *old_EXp = EX; + if ((pe = RepPredProp(Yap_GetPredPropByFunc(FunctorPortray, USER_MODULE))) && + pe->OpcodeOfPred != FAIL_OPCODE && pe->OpcodeOfPred != UNDEF_OPCODE && + Yap_execute_pred(pe, &t PASS_REGS)) { + choiceptr B0 = (choiceptr)(LCL0 - b0); + if (EX && !*old_EXp) + *old_EXp = EX; Yap_fail_all(B0 PASS_REGS); return true; } - if (EX && !*old_EXp) *old_EXp = EX; + if (EX && !*old_EXp) + *old_EXp = EX; return false; } - + static void wrputn(Int, struct write_globs *); static void wrputf(Float, struct write_globs *); static void wrputref(CODEADDR, int, struct write_globs *); @@ -111,52 +109,45 @@ static int legalAtom(unsigned char *); static int RightOpToProtect(Atom, int);*/ static wtype AtomIsSymbols(unsigned char *); static void putAtom(Atom, int, struct write_globs *); -static void writeTerm(Term, int, int, int, struct write_globs *, struct rewind_term *); +static void writeTerm(Term, int, int, int, struct write_globs *, + struct rewind_term *); -#define wrputc(X,WF) Sputcode(X,WF) /* writes a character */ +#define wrputc(X, WF) Sputcode(X, WF) /* writes a character */ /* protect bracket from merging with previoous character. avoid stuff like not (2,3) -> not(2,3) or */ -static void -wropen_bracket(struct write_globs *wglb, int protect) -{ +static void wropen_bracket(struct write_globs *wglb, int protect) { wrf stream = wglb->stream; if (lastw != separator && protect) wrputc(' ', stream); - wrputc('(', stream); + wrputc('(', stream); lastw = separator; } -static void -wrclose_bracket(struct write_globs *wglb, int protect) -{ +static void wrclose_bracket(struct write_globs *wglb, int protect) { wrf stream = wglb->stream; - wrputc(')', stream); + wrputc(')', stream); lastw = separator; } -static int -protect_open_number(struct write_globs *wglb, int lm, int minus_required) -{ +static int protect_open_number(struct write_globs *wglb, int lm, + int minus_required) { wrf stream = wglb->stream; if (lastw == symbol && lm && !minus_required) { wropen_bracket(wglb, TRUE); return TRUE; - } else if (lastw == alphanum || - (lastw == symbol && minus_required)) { - wrputc(' ', stream); - } + } else if (lastw == alphanum || (lastw == symbol && minus_required)) { + wrputc(' ', stream); + } return FALSE; } -static void -protect_close_number(struct write_globs *wglb, int used_bracket) -{ +static void protect_close_number(struct write_globs *wglb, int used_bracket) { if (used_bracket) { wrclose_bracket(wglb, TRUE); } else { @@ -165,12 +156,12 @@ protect_close_number(struct write_globs *wglb, int used_bracket) last_minus = FALSE; } -static void -wrputn(Int n, struct write_globs *wglb) /* writes an integer */ - +static void wrputn(Int n, + struct write_globs *wglb) /* writes an integer */ + { wrf stream = wglb->stream; - char s[256], *s1=s; /* that should be enough for most integers */ + char s[256], *s1 = s; /* that should be enough for most integers */ int has_minus = (n < 0); int ob; @@ -187,9 +178,7 @@ wrputn(Int n, struct write_globs *wglb) /* writes an integer */ #define wrputs(s, stream) Sfputs(s, stream) - -static void -wrputws(wchar_t *s, wrf stream) /* writes a string */ +static void wrputws(wchar_t *s, wrf stream) /* writes a string */ { while (*s) wrputc(*s++, stream); @@ -197,71 +186,69 @@ wrputws(wchar_t *s, wrf stream) /* writes a string */ #ifdef USE_GMP -static char * -ensure_space(size_t sz) { +static char *ensure_space(size_t sz) { CACHE_REGS char *s; - s = (char *) Yap_PreAllocCodeSpace(); - while (s+sz >= (char *)AuxSp) { + s = (char *)Yap_PreAllocCodeSpace(); + while (s + sz >= (char *)AuxSp) { #if USE_SYSTEM_MALLOC /* may require stack expansion */ if (!Yap_ExpandPreAllocCodeSpace(sz, NULL, TRUE)) { s = NULL; break; } - s = (char *) Yap_PreAllocCodeSpace(); + s = (char *)Yap_PreAllocCodeSpace(); #else s = NULL; #endif } if (!s) { s = (char *)TR; - while (s+sz >= LOCAL_TrailTop) { - if (!Yap_growtrail(sz/sizeof(CELL), FALSE)) { - s = NULL; - break; + while (s + sz >= LOCAL_TrailTop) { + if (!Yap_growtrail(sz / sizeof(CELL), FALSE)) { + s = NULL; + break; } s = (char *)TR; } } if (!s) { s = (char *)HR; - if (s+sz >= (char *)ASP) { - Yap_Error(OUT_OF_STACK_ERROR,TermNil,"not enough space to write bignum: it requires %d bytes", sz); + if (s + sz >= (char *)ASP) { + Yap_Error(OUT_OF_STACK_ERROR, TermNil, + "not enough space to write bignum: it requires %d bytes", sz); s = NULL; } } return s; } -static void -write_mpint(MP_INT *big, struct write_globs *wglb) { +static void write_mpint(MP_INT *big, struct write_globs *wglb) { char *s; int has_minus = mpz_sgn(big); int ob; - s = ensure_space(3+mpz_sizeinbase(big, 10)); + s = ensure_space(3 + mpz_sizeinbase(big, 10)); ob = protect_open_number(wglb, last_minus, has_minus); if (!s) { s = mpz_get_str(NULL, 10, big); if (!s) return; - wrputs(s,wglb->stream); + wrputs(s, wglb->stream); free(s); } else { mpz_get_str(s, 10, big); - wrputs(s,wglb->stream); + wrputs(s, wglb->stream); } protect_close_number(wglb, ob); } #endif - /* writes a bignum */ -static void -writebig(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, struct rewind_term *rwt) -{ - CELL *pt = RepAppl(t)+1; +/* writes a bignum */ +static void writebig(Term t, int p, int depth, int rinfixarg, + struct write_globs *wglb, struct rewind_term *rwt) { + CELL *pt = RepAppl(t) + 1; CELL big_tag = pt[0]; if (big_tag == ARRAY_INT || big_tag == ARRAY_FLOAT) { @@ -271,8 +258,7 @@ writebig(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, stru lastw = separator; return; #ifdef USE_GMP - } else if (big_tag == BIG_INT) - { + } else if (big_tag == BIG_INT) { MP_INT *big = Yap_BigIntOfTerm(t); write_mpint(big, wglb); return; @@ -287,24 +273,22 @@ writebig(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, stru blob_info = big_tag - USER_BLOB_START; if (GLOBAL_OpaqueHandlers && - (f= GLOBAL_OpaqueHandlers[blob_info].write_handler)) { + (f = GLOBAL_OpaqueHandlers[blob_info].write_handler)) { (f)(wglb->stream, big_tag, ExternalBlobFromTerm(t), 0); return; } } - wrputs("0",wglb->stream); -} + wrputs("0", wglb->stream); +} + +static void wrputf(Float f, struct write_globs *wglb) /* writes a float */ -static void -wrputf(Float f, struct write_globs *wglb) /* writes a float */ - { - char s[256]; + char s[256]; wrf stream = wglb->stream; int sgn; int ob; - #if HAVE_ISNAN || defined(__WIN32) if (isnan(f)) { wrputs("(nan)", stream); @@ -312,7 +296,7 @@ wrputf(Float f, struct write_globs *wglb) /* writes a float */ return; } #endif - sgn = (f < 0.0); + sgn = (f < 0.0); #if HAVE_ISINF || defined(_WIN32) if (isinf(f)) { if (sgn) { @@ -328,13 +312,13 @@ wrputf(Float f, struct write_globs *wglb) /* writes a float */ #if THREADS /* old style writing */ int found_dot = FALSE; - char *pt = s; + char *pt = s; int ch; - /* always use C locale for writing numbers */ +/* always use C locale for writing numbers */ #if O_LOCALE - const unsigned char *decimalpoint = (unsigned char*) - localeconv()->decimal_point; - size_t l1 = strlen((const char *)decimalpoint+1); + const unsigned char *decimalpoint = + (unsigned char *)localeconv()->decimal_point; + size_t l1 = strlen((const char *)decimalpoint + 1); #else const unsigned char decimalpoint[2] = "."; size_t l1 = 0; @@ -354,7 +338,8 @@ wrputf(Float f, struct write_globs *wglb) /* writes a float */ } while ((ch = *pt) != '\0') { // skip locale - if (ch == decimalpoint[0] && !strncmp(pt+1, (char *)decimalpoint+1, l1)) { + if (ch == decimalpoint[0] && + !strncmp(pt + 1, (char *)decimalpoint + 1, l1)) { found_dot = TRUE; pt += l1; ch = '.'; @@ -362,7 +347,7 @@ wrputf(Float f, struct write_globs *wglb) /* writes a float */ if (ch == 'e' || ch == 'E') { if (!found_dot) { found_dot = TRUE; - wrputs(".0" , stream); + wrputs(".0", stream); } found_dot = TRUE; } @@ -381,15 +366,14 @@ wrputf(Float f, struct write_globs *wglb) /* writes a float */ } /* use SWI's format_float */ buf = format_float(f, s); - if (!buf) return; + if (!buf) + return; wrputs(buf, stream); #endif protect_close_number(wglb, ob); } -int -Yap_FormatFloat( Float f, const char *s, size_t sz ) -{ +int Yap_FormatFloat(Float f, const char *s, size_t sz) { struct write_globs wglb; char *ws = (char *)s; IOSTREAM *smem = Sopenmem(&ws, &sz, "w"); @@ -397,34 +381,31 @@ Yap_FormatFloat( Float f, const char *s, size_t sz ) wglb.lw = separator; wglb.last_atom_minus = FALSE; wrputf(f, &wglb); - Sclose(smem); + Sclose(smem); return TRUE; } - /* writes a data base reference */ -static void -wrputref(CODEADDR ref, int Quote_illegal, struct write_globs *wglb) -{ - char s[256]; - wrf stream = wglb->stream; +static void wrputref(CODEADDR ref, int Quote_illegal, + struct write_globs *wglb) { + char s[256]; + wrf stream = wglb->stream; putAtom(AtomDBref, Quote_illegal, wglb); #if defined(__linux__) || defined(__APPLE__) - sprintf(s, "(%p," UInt_FORMAT ")", ref, ((LogUpdClause*)ref)->ClRefCount); + sprintf(s, "(%p," UInt_FORMAT ")", ref, ((LogUpdClause *)ref)->ClRefCount); #else - sprintf(s, "(0x%p," UInt_FORMAT ")", ref, ((LogUpdClause*)ref)->ClRefCount); + sprintf(s, "(0x%p," UInt_FORMAT ")", ref, ((LogUpdClause *)ref)->ClRefCount); #endif wrputs(s, stream); lastw = alphanum; } /* writes a blob (default) */ -static int -wrputblob(AtomEntry * ref, int Quote_illegal, struct write_globs *wglb) -{ - char s[256]; - wrf stream = wglb->stream; +static int wrputblob(AtomEntry *ref, int Quote_illegal, + struct write_globs *wglb) { + char s[256]; + wrf stream = wglb->stream; PL_blob_t *type = RepBlobProp(ref->PropsOfAE)->blob_t; if (type->write) { @@ -443,8 +424,7 @@ wrputblob(AtomEntry * ref, int Quote_illegal, struct write_globs *wglb) return 1; } -static int -legalAtom(unsigned char *s) /* Is this a legal atom ? */ +static int legalAtom(unsigned char *s) /* Is this a legal atom ? */ { wchar_t ch = *s; @@ -454,36 +434,37 @@ legalAtom(unsigned char *s) /* Is this a legal atom ? */ if (ch == '[') { return (s[1] == ']' && !s[2]); } else if (ch == '{') { - return (s[1] == '}' && !s[2]); + return (s[1] == '}' && !s[2]); } else if (Yap_chtype[ch] == SL) { return (!s[1]); } else if ((ch == ',' || ch == '.') && !s[1]) { return FALSE; } else { if (ch == '/') { - if (s[1] == '*') return FALSE; + if (s[1] == '*') + return FALSE; } while (ch) { - if (Yap_chtype[ch] != SY) { - return FALSE; - } - ch = *++s; + if (Yap_chtype[ch] != SY) { + return FALSE; + } + ch = *++s; } } return TRUE; } else while ((ch = *++s) != 0) if (Yap_chtype[ch] > NU) - return FALSE; + return FALSE; return (TRUE); } -static wtype -AtomIsSymbols(unsigned char *s) /* Is this atom just formed by symbols ? */ +static wtype +AtomIsSymbols(unsigned char *s) /* Is this atom just formed by symbols ? */ { int ch; if (Yap_chtype[(int)s[0]] == SL && s[1] == '\0') - return(separator); + return (separator); while ((ch = *s++) != '\0') { if (Yap_chtype[ch] != SY) return alphanum; @@ -491,45 +472,48 @@ AtomIsSymbols(unsigned char *s) /* Is this atom just formed by symbols ? */ return symbol; } -static void -write_quoted(wchar_t ch, wchar_t quote, wrf stream) -{ +static void write_quoted(wchar_t ch, wchar_t quote, wrf stream) { CACHE_REGS if (!(Yap_GetModuleEntry(CurrentModule)->flags & M_CHARESCAPE)) { wrputc(ch, stream); if (ch == '\'') - wrputc('\'', stream); /* be careful about quotes */ + wrputc('\'', stream); /* be careful about quotes */ return; } - if (!(ch < 0xff && chtype(ch) == BS) && ch != '\'' && ch != '\\') { + if (!(ch < 0xff && chtype(ch) == BS) && ch != '\'' && ch != '\\' && ch != '`') { wrputc(ch, stream); } else { switch (ch) { case '\\': - wrputc('\\', stream); - wrputc('\\', stream); + wrputc('\\', stream); + wrputc('\\', stream); break; case '\'': if (ch == quote) - wrputc('\\', stream); - wrputc(ch, stream); + wrputc('\\', stream); + wrputc(ch, stream); break; case '"': if (ch == quote) - wrputc('\\', stream); - wrputc(ch, stream); + wrputc('\\', stream); + wrputc(ch, stream); + break; + case '`': + if (ch == quote) + wrputc('`', stream); + wrputc(ch, stream); break; case 7: - wrputc('\\', stream); - wrputc('a', stream); + wrputc('\\', stream); + wrputc('a', stream); break; case '\b': wrputc('\\', stream); - wrputc('b', stream); + wrputc('b', stream); break; case '\t': wrputc('\\', stream); - wrputc('t', stream); + wrputc('t', stream); break; case ' ': case 160: @@ -537,75 +521,71 @@ write_quoted(wchar_t ch, wchar_t quote, wrf stream) break; case '\n': wrputc('\\', stream); - wrputc('n', stream); + wrputc('n', stream); break; case 11: wrputc('\\', stream); - wrputc('v', stream); + wrputc('v', stream); break; case '\r': wrputc('\\', stream); - wrputc('r', stream); + wrputc('r', stream); break; case '\f': wrputc('\\', stream); - wrputc('f', stream); + wrputc('f', stream); break; default: - if ( ch <= 0xff ) { - char esc[8]; - - /* last backslash in ISO mode */ - sprintf(esc, "\\%03o\\", ch); - wrputs(esc, stream); + if (ch <= 0xff) { + char esc[8]; + + /* last backslash in ISO mode */ + sprintf(esc, "\\%03o\\", ch); + wrputs(esc, stream); } } } } -static void -write_string(const char *s, struct write_globs *wglb) /* writes an integer */ +static void write_string(const char *s, + struct write_globs *wglb) /* writes an integer */ { IOSTREAM *stream = wglb->stream; - int chr; + int chr, qt; char *ptr = (char *)s; - + if (wglb->Write_strings) - wrputc('`', stream); + qt = '`'; else - wrputc('"', stream); + qt = '"'; + wrputc(qt, stream); do { ptr = utf8_get_char(ptr, &chr); - if (chr == '\0') break; - write_quoted(chr, '"', stream); + if (chr == '\0') + break; + write_quoted(chr, qt, stream); } while (TRUE); - if (wglb->Write_strings) - wrputc('`', stream); - else - wrputc('"', stream); + wrputc(qt, stream); } - /* writes an atom */ -static void -putAtom(Atom atom, int Quote_illegal, struct write_globs *wglb) -{ - unsigned char *s; - wtype atom_or_symbol; +static void putAtom(Atom atom, int Quote_illegal, struct write_globs *wglb) { + unsigned char *s; + wtype atom_or_symbol; wrf stream = wglb->stream; if (IsBlob(atom)) { - wrputblob(RepAtom(atom),Quote_illegal,wglb); + wrputblob(RepAtom(atom), Quote_illegal, wglb); return; } - if (IsWideAtom(atom) ) { + if (IsWideAtom(atom)) { wchar_t *ws = RepAtom(atom)->WStrOfAE; if (Quote_illegal) { wrputc('\'', stream); while (*ws) { - wchar_t ch = *ws++; - write_quoted(ch, '\'', stream); + wchar_t ch = *ws++; + write_quoted(ch, '\'', stream); } wrputc('\'', stream); } else { @@ -613,12 +593,13 @@ putAtom(Atom atom, int Quote_illegal, struct write_globs *wglb) } return; } - s = (unsigned char *)RepAtom(atom)->StrOfAE; - /* #define CRYPT_FOR_STEVE 1*/ + s = (unsigned char *)RepAtom(atom)->StrOfAE; +/* #define CRYPT_FOR_STEVE 1*/ #ifdef CRYPT_FOR_STEVE - if (Yap_GetValue(AtomCryptAtoms) != TermNil && Yap_GetAProp(atom, OpProperty) == NIL) { + if (Yap_GetValue(AtomCryptAtoms) != TermNil && + Yap_GetAProp(atom, OpProperty) == NIL) { char s[16]; - sprintf(s,"x%x", (CELL)s); + sprintf(s, "x%x", (CELL)s); wrputs(s, stream); return; } @@ -641,17 +622,14 @@ putAtom(Atom atom, int Quote_illegal, struct write_globs *wglb) } } -void -Yap_WriteAtom(IOSTREAM *s, Atom atom) -{ - struct write_globs wglb; - wglb.stream = s; - wglb.Quote_illegal = FALSE; - putAtom(atom, 0, &wglb); +void Yap_WriteAtom(IOSTREAM *s, Atom atom) { + struct write_globs wglb; + wglb.stream = s; + wglb.Quote_illegal = FALSE; + putAtom(atom, 0, &wglb); } -static int -IsCodesTerm(Term string) /* checks whether this is a string */ +static int IsCodesTerm(Term string) /* checks whether this is a string */ { if (IsVarTerm(string)) return FALSE; @@ -659,23 +637,26 @@ IsCodesTerm(Term string) /* checks whether this is a string */ Term hd; int ch; - if (!IsPairTerm(string)) return(FALSE); + if (!IsPairTerm(string)) + return (FALSE); hd = HeadOfTerm(string); - if (IsVarTerm(hd)) return(FALSE); - if (!IsIntTerm(hd)) return(FALSE); + if (IsVarTerm(hd)) + return (FALSE); + if (!IsIntTerm(hd)) + return (FALSE); ch = IntOfTerm(HeadOfTerm(string)); if ((ch < ' ' || ch > MAX_ISO_LATIN1) && ch != '\n' && ch != '\t') - return(FALSE); + return (FALSE); string = TailOfTerm(string); - if (IsVarTerm(string)) return(FALSE); + if (IsVarTerm(string)) + return (FALSE); } while (string != TermNil); - return(TRUE); + return (TRUE); } /* writes a string */ -static void -putString(Term string, struct write_globs *wglb) - +static void putString(Term string, struct write_globs *wglb) + { wrf stream = wglb->stream; wrputc('"', stream); @@ -689,9 +670,8 @@ putString(Term string, struct write_globs *wglb) } /* writes a string */ -static void -putUnquotedString(Term string, struct write_globs *wglb) - +static void putUnquotedString(Term string, struct write_globs *wglb) + { wrf stream = wglb->stream; while (string != TermNil) { @@ -702,10 +682,8 @@ putUnquotedString(Term string, struct write_globs *wglb) lastw = alphanum; } - -static Term -from_pointer(CELL *ptr0, struct rewind_term *rwt, struct write_globs *wglb) -{ +static Term from_pointer(CELL *ptr0, struct rewind_term *rwt, + struct write_globs *wglb) { CACHE_REGS Term t; CELL *ptr = ptr0; @@ -721,35 +699,34 @@ from_pointer(CELL *ptr0, struct rewind_term *rwt, struct write_globs *wglb) if (!IsAtomicTerm(t) && !IsVarTerm(t)) { while (x) { - if (Yap_GetDerefedFromSlot(x->u_sd.s.old PASS_REGS) == t) - return TermFoundVar; - x = x->parent; + if (Yap_GetDerefedFromSlot(x->u_sd.s.old PASS_REGS) == t) + return TermFoundVar; + x = x->parent; } } } else { rwt->u_sd.d.old = t; rwt->u_sd.d.ptr = ptr0; - if ( !IsVarTerm(t) && !IsAtomicTerm(t)) { + if (!IsVarTerm(t) && !IsAtomicTerm(t)) { struct rewind_term *x = rwt->parent; - + while (x) { - if (x->u_sd.d.old == t) - return TermFoundVar; - x = x->parent; + if (x->u_sd.d.old == t) + return TermFoundVar; + x = x->parent; } } } return t; } -static CELL * -restore_from_write(struct rewind_term *rwt, struct write_globs *wglb) -{ +static CELL *restore_from_write(struct rewind_term *rwt, + struct write_globs *wglb) { CACHE_REGS CELL *ptr; if (wglb->Keep_terms) { - ptr = (CELL*)Yap_GetPtrFromSlot(rwt->u_sd.s.ptr PASS_REGS); + ptr = (CELL *)Yap_GetPtrFromSlot(rwt->u_sd.s.ptr PASS_REGS); if (!Yap_RecoverSlots(2, rwt->u_sd.s.ptr PASS_REGS)) return NULL; } else { @@ -760,9 +737,8 @@ restore_from_write(struct rewind_term *rwt, struct write_globs *wglb) } /* writes an unbound variable */ -static void -write_var(CELL *t, struct write_globs *wglb, struct rewind_term *rwt) -{ +static void write_var(CELL *t, struct write_globs *wglb, + struct rewind_term *rwt) { CACHE_REGS if (lastw == alphanum) { wrputc(' ', wglb->stream); @@ -771,7 +747,7 @@ write_var(CELL *t, struct write_globs *wglb, struct rewind_term *rwt) /* make sure we don't get no creepy spaces where they shouldn't be */ lastw = separator; if (IsAttVar(t)) { - Int vcount = (t-H0); + Int vcount = (t - H0); if (wglb->Portray_delays) { exts ext = ExtFromCell(t); struct rewind_term nrwt; @@ -780,53 +756,51 @@ write_var(CELL *t, struct write_globs *wglb, struct rewind_term *rwt) wglb->Portray_delays = FALSE; if (ext == attvars_ext) { - attvar_record *attv = RepAttVar(t); - CELL *l = &attv->Value; /* dirty low-level hack, check atts.h */ + attvar_record *attv = RepAttVar(t); + CELL *l = &attv->Value; /* dirty low-level hack, check atts.h */ - wrputs("$AT(",wglb->stream); - write_var(t, wglb, rwt); - wrputc(',', wglb->stream); - writeTerm(from_pointer(l, &nrwt, wglb), 999, 1, FALSE, wglb, &nrwt); - l = restore_from_write(&nrwt, wglb); - wrputc(',', wglb->stream); - l ++; - writeTerm(from_pointer(l, &nrwt, wglb), 999, 1, FALSE, wglb, &nrwt); - restore_from_write(&nrwt, wglb); - wrclose_bracket(wglb, TRUE); + wrputs("$AT(", wglb->stream); + write_var(t, wglb, rwt); + wrputc(',', wglb->stream); + writeTerm(from_pointer(l, &nrwt, wglb), 999, 1, FALSE, wglb, &nrwt); + l = restore_from_write(&nrwt, wglb); + wrputc(',', wglb->stream); + l++; + writeTerm(from_pointer(l, &nrwt, wglb), 999, 1, FALSE, wglb, &nrwt); + restore_from_write(&nrwt, wglb); + wrclose_bracket(wglb, TRUE); } wglb->Portray_delays = TRUE; return; } wrputc('D', wglb->stream); - wrputn(vcount,wglb); + wrputn(vcount, wglb); } else { - wrputn(((Int) (t- H0)),wglb); + wrputn(((Int)(t - H0)), wglb); } } -static Term -check_infinite_loop(Term t, struct rewind_term *x, struct write_globs *wglb) -{ +static Term check_infinite_loop(Term t, struct rewind_term *x, + struct write_globs *wglb) { CACHE_REGS if (wglb->Keep_terms) { while (x) { if (Yap_GetFromSlot(x->u_sd.s.old PASS_REGS) == t) - return TermFoundVar; + return TermFoundVar; x = x->parent; } } else { while (x) { if (x->u_sd.d.old == t) - return TermFoundVar; - x = x->parent; + return TermFoundVar; + x = x->parent; } } return t; } -static void -write_list(Term t, int direction, int depth, struct write_globs *wglb, struct rewind_term *rwt) -{ +static void write_list(Term t, int direction, int depth, + struct write_globs *wglb, struct rewind_term *rwt) { Term ti; struct rewind_term nrwt; nrwt.parent = rwt; @@ -836,15 +810,16 @@ write_list(Term t, int direction, int depth, struct write_globs *wglb, struct re int ndirection; int do_jump; - writeTerm(from_pointer(RepPair(t), &nrwt, wglb), 999, depth+1, FALSE, wglb, &nrwt); + writeTerm(from_pointer(RepPair(t), &nrwt, wglb), 999, depth + 1, FALSE, + wglb, &nrwt); t = AbsPair(restore_from_write(&nrwt, wglb)); ti = TailOfTerm(t); if (IsVarTerm(ti)) break; if (!IsPairTerm(ti) || - !IsPairTerm((ti = check_infinite_loop(ti, rwt, wglb)))) + !IsPairTerm((ti = check_infinite_loop(ti, rwt, wglb)))) break; - ndirection = RepPair(ti)-RepPair(t); + ndirection = RepPair(ti) - RepPair(t); /* make sure we're not trapped in loops */ if (ndirection > 0) { do_jump = (direction <= 0); @@ -870,31 +845,31 @@ write_list(Term t, int direction, int depth, struct write_globs *wglb, struct re t = ti; } if (IsPairTerm(ti)) { - Term nt = from_pointer(RepPair(t)+1, &nrwt, wglb); + Term nt = from_pointer(RepPair(t) + 1, &nrwt, wglb); /* we found an infinite loop */ if (IsAtomTerm(nt)) { - wrputc('|', wglb->stream); + wrputc('|', wglb->stream); writeTerm(nt, 999, depth, FALSE, wglb, rwt); } else { /* keep going on the list */ - wrputc(',', wglb->stream); + wrputc(',', wglb->stream); write_list(nt, direction, depth, wglb, &nrwt); } restore_from_write(&nrwt, wglb); } else if (ti != MkAtomTerm(AtomNil)) { wrputc('|', wglb->stream); lastw = separator; - writeTerm(from_pointer(RepPair(t)+1, &nrwt, wglb), 999, depth, FALSE, wglb, &nrwt); + writeTerm(from_pointer(RepPair(t) + 1, &nrwt, wglb), 999, depth, FALSE, + wglb, &nrwt); restore_from_write(&nrwt, wglb); } - } +} - -static void -writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, struct rewind_term *rwt) +static void writeTerm(Term t, int p, int depth, int rinfixarg, + struct write_globs *wglb, struct rewind_term *rwt) /* term to write */ /* context priority */ - + { CACHE_REGS struct rewind_term nrwt; @@ -912,274 +887,281 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str write_var((CELL *)t, wglb, &nrwt); } else if (IsIntTerm(t)) { - wrputn((Int) IntOfTerm(t),wglb); + wrputn((Int)IntOfTerm(t), wglb); } else if (IsAtomTerm(t)) { putAtom(AtomOfTerm(t), wglb->Quote_illegal, wglb); } else if (IsPairTerm(t)) { - if (wglb->Ignore_ops) { - wrputs("'.'(",wglb->stream); + if (wglb->Ignore_ops) { + wrputs("'.'(", wglb->stream); lastw = separator; - writeTerm(from_pointer(RepPair(t), &nrwt, wglb), 999, depth + 1, FALSE, wglb, &nrwt); + writeTerm(from_pointer(RepPair(t), &nrwt, wglb), 999, depth + 1, FALSE, + wglb, &nrwt); t = AbsPair(restore_from_write(&nrwt, wglb)); - wrputs(",",wglb->stream); - writeTerm(from_pointer(RepPair(t)+1, &nrwt, wglb), 999, depth + 1, FALSE, wglb, &nrwt); + wrputs(",", wglb->stream); + writeTerm(from_pointer(RepPair(t) + 1, &nrwt, wglb), 999, depth + 1, + FALSE, wglb, &nrwt); restore_from_write(&nrwt, wglb); wrclose_bracket(wglb, TRUE); return; - } + } if (wglb->Use_portray) - if (callPortray(t, &EX PASS_REGS) ) return; + if (callPortray(t, &EX PASS_REGS)) + return; if (yap_flags[WRITE_QUOTED_STRING_FLAG] && IsCodesTerm(t)) { putString(t, wglb); } else { wrputc('[', wglb->stream); lastw = separator; - /* we assume t was already saved in the stack */ - write_list(t, 0, depth, wglb, rwt); + /* we assume t was already saved in the stack */ + write_list(t, 0, depth, wglb, rwt); wrputc(']', wglb->stream); - lastw = separator; + lastw = separator; } - } else { /* compound term */ - Functor functor = FunctorOfTerm(t); - int Arity; - Atom atom; - int op, lp, rp; + } else { /* compound term */ + Functor functor = FunctorOfTerm(t); + int Arity; + Atom atom; + int op, lp, rp; if (IsExtensionFunctor(functor)) { - switch((CELL)functor) { - case (CELL)FunctorDouble: - wrputf(FloatOfTerm(t),wglb); - return; - case (CELL)FunctorString: - write_string(StringOfTerm(t),wglb); - return; - case (CELL)FunctorAttVar: - write_var(RepAppl(t)+1, wglb, &nrwt); - return; - case (CELL)FunctorDBRef: - wrputref(RefOfTerm(t), wglb->Quote_illegal, wglb); - return; - case (CELL)FunctorLongInt: - wrputn(LongIntOfTerm(t),wglb); - return; - /* case (CELL)FunctorBigInt: */ + switch ((CELL)functor) { + case (CELL) FunctorDouble: + wrputf(FloatOfTerm(t), wglb); + return; + case (CELL) FunctorString: + write_string(StringOfTerm(t), wglb); + return; + case (CELL) FunctorAttVar: + write_var(RepAppl(t) + 1, wglb, &nrwt); + return; + case (CELL) FunctorDBRef: + wrputref(RefOfTerm(t), wglb->Quote_illegal, wglb); + return; + case (CELL) FunctorLongInt: + wrputn(LongIntOfTerm(t), wglb); + return; + /* case (CELL)FunctorBigInt: */ default: - writebig(t, p, depth, rinfixarg, wglb, rwt); - return; + writebig(t, p, depth, rinfixarg, wglb, rwt); + return; } } Arity = ArityOfFunctor(functor); atom = NameOfFunctor(functor); #ifdef SFUNC if (Arity == SFArity) { - int argno = 1; - CELL *p = ArgsOfSFTerm(t); + int argno = 1; + CELL *p = ArgsOfSFTerm(t); putAtom(atom, wglb->Quote_illegal, wglb); wropen_bracket(wglb, FALSE); lastw = separator; while (*p) { - Int sl = 0; + Int sl = 0; - while (argno < *p) { - wrputc('_', wglb->stream), wrputc(',', wglb->stream); - ++argno; - } - *p++; - lastw = separator; - /* cannot use the term directly with the SBA */ - writeTerm(from_pointer(p, &nrwt, wglb), 999, depth + 1, FALSE, wglb, &nrwt); - p = restore_from_write(&nrwt, wglb)+1; - if (*p) - wrputc(',', wglb->stream); - argno++; + while (argno < *p) { + wrputc('_', wglb->stream), wrputc(',', wglb->stream); + ++argno; + } + *p++; + lastw = separator; + /* cannot use the term directly with the SBA */ + writeTerm(from_pointer(p, &nrwt, wglb), 999, depth + 1, FALSE, wglb, + &nrwt); + p = restore_from_write(&nrwt, wglb) + 1; + if (*p) + wrputc(',', wglb->stream); + argno++; } wrclose_bracket(wglb, TRUE); return; } #endif if (wglb->Use_portray) { - if (callPortray(t, &EX PASS_REGS) ) return; + if (callPortray(t, &EX PASS_REGS)) + return; } - if (!wglb->Ignore_ops && - Arity == 1 && - Yap_IsPrefixOp(atom, &op, &rp) - ) { - Term tright = ArgOfTerm(1, t); - int bracket_right = - !IsVarTerm(tright) && IsAtomTerm(tright) && - Yap_IsOp(AtomOfTerm(tright)); + if (!wglb->Ignore_ops && Arity == 1 && Yap_IsPrefixOp(atom, &op, &rp)) { + Term tright = ArgOfTerm(1, t); + int bracket_right = !IsVarTerm(tright) && IsAtomTerm(tright) && + Yap_IsOp(AtomOfTerm(tright)); if (op > p) { - wropen_bracket(wglb, TRUE); + wropen_bracket(wglb, TRUE); } putAtom(atom, wglb->Quote_illegal, wglb); if (bracket_right) { - /* avoid stuff such as \+ (a,b) being written as \+(a,b) */ - wropen_bracket(wglb, TRUE); + /* avoid stuff such as \+ (a,b) being written as \+(a,b) */ + wropen_bracket(wglb, TRUE); } else if (atom == AtomMinus) { - last_minus = TRUE; + last_minus = TRUE; } - writeTerm(from_pointer(RepAppl(t)+1, &nrwt, wglb), rp, depth + 1, TRUE, wglb, &nrwt); + writeTerm(from_pointer(RepAppl(t) + 1, &nrwt, wglb), rp, depth + 1, TRUE, + wglb, &nrwt); restore_from_write(&nrwt, wglb); if (bracket_right) { - wrclose_bracket(wglb, TRUE); + wrclose_bracket(wglb, TRUE); } if (op > p) { - wrclose_bracket(wglb, TRUE); + wrclose_bracket(wglb, TRUE); } } else if (!wglb->Ignore_ops && - ( Arity == 1 || ((atom == AtomEmptyBrackets || atom == AtomEmptyCurlyBrackets || atom == AtomEmptySquareBrackets) && Yap_IsListTerm(ArgOfTerm(1, t)))) && - Yap_IsPosfixOp(atom, &op, &lp)) { - Term tleft = ArgOfTerm(1, t); + (Arity == 1 || + ((atom == AtomEmptyBrackets || atom == AtomEmptyCurlyBrackets || + atom == AtomEmptySquareBrackets) && + Yap_IsListTerm(ArgOfTerm(1, t)))) && + Yap_IsPosfixOp(atom, &op, &lp)) { + Term tleft = ArgOfTerm(1, t); - int bracket_left, offset; + int bracket_left, offset; if (Arity != 1) { - tleft = ArgOfTerm(1, t); - offset = 2; + tleft = ArgOfTerm(1, t); + offset = 2; } else { - tleft = ArgOfTerm(1, t); - offset = 1; + tleft = ArgOfTerm(1, t); + offset = 1; } bracket_left = - !IsVarTerm(tleft) && - IsAtomTerm(tleft) && - Yap_IsOp(AtomOfTerm(tleft)); + !IsVarTerm(tleft) && IsAtomTerm(tleft) && Yap_IsOp(AtomOfTerm(tleft)); if (op > p) { - /* avoid stuff such as \+ (a,b) being written as \+(a,b) */ - wropen_bracket(wglb, TRUE); + /* avoid stuff such as \+ (a,b) being written as \+(a,b) */ + wropen_bracket(wglb, TRUE); } if (bracket_left) { - wropen_bracket(wglb, TRUE); + wropen_bracket(wglb, TRUE); } - writeTerm(from_pointer(RepAppl(t)+offset, &nrwt, wglb), lp, depth + 1, rinfixarg, wglb, &nrwt); + writeTerm(from_pointer(RepAppl(t) + offset, &nrwt, wglb), lp, depth + 1, + rinfixarg, wglb, &nrwt); restore_from_write(&nrwt, wglb); if (bracket_left) { - wrclose_bracket(wglb, TRUE); + wrclose_bracket(wglb, TRUE); } - if (Arity > 1 ) { - if (atom == AtomEmptyBrackets) { - wrputc('(', wglb->stream); - } else if (atom == AtomEmptySquareBrackets) { - wrputc('[', wglb->stream); - } else if (atom == AtomEmptyCurlyBrackets) { - wrputc('{', wglb->stream); - } - lastw = separator; - write_list(tleft, 0, depth, wglb, rwt); - if (atom == AtomEmptyBrackets) { - wrputc(')', wglb->stream); - } else if (atom == AtomEmptySquareBrackets) { - wrputc(']', wglb->stream); - } else if (atom == AtomEmptyCurlyBrackets) { - wrputc('}', wglb->stream); - } - lastw = separator; + if (Arity > 1) { + if (atom == AtomEmptyBrackets) { + wrputc('(', wglb->stream); + } else if (atom == AtomEmptySquareBrackets) { + wrputc('[', wglb->stream); + } else if (atom == AtomEmptyCurlyBrackets) { + wrputc('{', wglb->stream); + } + lastw = separator; + write_list(tleft, 0, depth, wglb, rwt); + if (atom == AtomEmptyBrackets) { + wrputc(')', wglb->stream); + } else if (atom == AtomEmptySquareBrackets) { + wrputc(']', wglb->stream); + } else if (atom == AtomEmptyCurlyBrackets) { + wrputc('}', wglb->stream); + } + lastw = separator; } else { - putAtom(atom, wglb->Quote_illegal, wglb); + putAtom(atom, wglb->Quote_illegal, wglb); } if (op > p) { - wrclose_bracket(wglb, TRUE); + wrclose_bracket(wglb, TRUE); } - } else if (!wglb->Ignore_ops && - Arity == 2 && Yap_IsInfixOp(atom, &op, &lp, - &rp) ) { - Term tleft = ArgOfTerm(1, t); - Term tright = ArgOfTerm(2, t); - int bracket_left = - !IsVarTerm(tleft) && IsAtomTerm(tleft) && - Yap_IsOp(AtomOfTerm(tleft)); - int bracket_right = - !IsVarTerm(tright) && IsAtomTerm(tright) && - Yap_IsOp(AtomOfTerm(tright)); + } else if (!wglb->Ignore_ops && Arity == 2 && + Yap_IsInfixOp(atom, &op, &lp, &rp)) { + Term tleft = ArgOfTerm(1, t); + Term tright = ArgOfTerm(2, t); + int bracket_left = + !IsVarTerm(tleft) && IsAtomTerm(tleft) && Yap_IsOp(AtomOfTerm(tleft)); + int bracket_right = !IsVarTerm(tright) && IsAtomTerm(tright) && + Yap_IsOp(AtomOfTerm(tright)); if (op > p) { - /* avoid stuff such as \+ (a,b) being written as \+(a,b) */ - wropen_bracket(wglb, TRUE); - lastw = separator; + /* avoid stuff such as \+ (a,b) being written as \+(a,b) */ + wropen_bracket(wglb, TRUE); + lastw = separator; } if (bracket_left) { - wropen_bracket(wglb, TRUE); + wropen_bracket(wglb, TRUE); } - writeTerm(from_pointer(RepAppl(t)+1, &nrwt, wglb), lp, depth + 1, rinfixarg, wglb, &nrwt); - t = AbsAppl(restore_from_write(&nrwt, wglb)-1); + writeTerm(from_pointer(RepAppl(t) + 1, &nrwt, wglb), lp, depth + 1, + rinfixarg, wglb, &nrwt); + t = AbsAppl(restore_from_write(&nrwt, wglb) - 1); if (bracket_left) { - wrclose_bracket(wglb, TRUE); + wrclose_bracket(wglb, TRUE); } /* avoid quoting commas and bars */ - if (!strcmp(RepAtom(atom)->StrOfAE,",")) { - wrputc(',', wglb->stream); - lastw = separator; - } else if (!strcmp(RepAtom(atom)->StrOfAE,"|")) { - wrputc('|', wglb->stream); - lastw = separator; + if (!strcmp(RepAtom(atom)->StrOfAE, ",")) { + wrputc(',', wglb->stream); + lastw = separator; + } else if (!strcmp(RepAtom(atom)->StrOfAE, "|")) { + wrputc('|', wglb->stream); + lastw = separator; } else - putAtom(atom, wglb->Quote_illegal, wglb); + putAtom(atom, wglb->Quote_illegal, wglb); if (bracket_right) { - wropen_bracket(wglb, TRUE); + wropen_bracket(wglb, TRUE); } - writeTerm(from_pointer(RepAppl(t)+2, &nrwt, wglb), rp, depth + 1, TRUE, wglb, &nrwt); + writeTerm(from_pointer(RepAppl(t) + 2, &nrwt, wglb), rp, depth + 1, TRUE, + wglb, &nrwt); restore_from_write(&nrwt, wglb); if (bracket_right) { - wrclose_bracket(wglb, TRUE); + wrclose_bracket(wglb, TRUE); } if (op > p) { - wrclose_bracket(wglb, TRUE); + wrclose_bracket(wglb, TRUE); } } else if (wglb->Handle_vars && functor == LOCAL_FunctorVar) { Term ti = ArgOfTerm(1, t); if (lastw == alphanum) { - wrputc(' ', wglb->stream); + wrputc(' ', wglb->stream); } - if (!IsVarTerm(ti) && (IsIntTerm(ti) || IsCodesTerm(ti) || IsAtomTerm(ti))) { - if (IsIntTerm(ti)) { - Int k = IntOfTerm(ti); - if (k == -1) { - wrputc('_', wglb->stream); - lastw = alphanum; - return; - } else { - wrputc((k % 26) + 'A', wglb->stream); - if (k >= 26) { - /* make sure we don't get confused about our context */ - lastw = separator; - wrputn( k / 26 ,wglb); - } else - lastw = alphanum; - } - } else if (IsAtomTerm(ti)) { - putAtom(AtomOfTerm(ti), FALSE, wglb); - } else { - putUnquotedString(ti, wglb); - } + if (!IsVarTerm(ti) && + (IsIntTerm(ti) || IsCodesTerm(ti) || IsAtomTerm(ti))) { + if (IsIntTerm(ti)) { + Int k = IntOfTerm(ti); + if (k == -1) { + wrputc('_', wglb->stream); + lastw = alphanum; + return; + } else { + wrputc((k % 26) + 'A', wglb->stream); + if (k >= 26) { + /* make sure we don't get confused about our context */ + lastw = separator; + wrputn(k / 26, wglb); + } else + lastw = alphanum; + } + } else if (IsAtomTerm(ti)) { + putAtom(AtomOfTerm(ti), FALSE, wglb); + } else { + putUnquotedString(ti, wglb); + } } else { - wrputs("'$VAR'(",wglb->stream); - lastw = separator; - writeTerm(from_pointer(RepAppl(t)+1, &nrwt, wglb), 999, depth + 1, FALSE, wglb, &nrwt); - restore_from_write(&nrwt, wglb); - wrclose_bracket(wglb, TRUE); + wrputs("'$VAR'(", wglb->stream); + lastw = separator; + writeTerm(from_pointer(RepAppl(t) + 1, &nrwt, wglb), 999, depth + 1, + FALSE, wglb, &nrwt); + restore_from_write(&nrwt, wglb); + wrclose_bracket(wglb, TRUE); } } else if (!wglb->Ignore_ops && functor == FunctorBraces) { wrputc('{', wglb->stream); lastw = separator; - writeTerm(from_pointer(RepAppl(t)+1, &nrwt, wglb), 1200, depth + 1, FALSE, wglb, &nrwt); + writeTerm(from_pointer(RepAppl(t) + 1, &nrwt, wglb), 1200, depth + 1, + FALSE, wglb, &nrwt); restore_from_write(&nrwt, wglb); wrputc('}', wglb->stream); lastw = separator; - } else if (atom == AtomArray) { + } else if (atom == AtomArray) { wrputc('{', wglb->stream); lastw = separator; for (op = 1; op <= Arity; ++op) { - if (op == wglb->MaxArgs) { - wrputs("...", wglb->stream); - break; - } - writeTerm(from_pointer(RepAppl(t)+op, &nrwt, wglb), 999, depth + 1, FALSE, wglb, &nrwt); - t = AbsAppl(restore_from_write(&nrwt, wglb)-op); - if (op != Arity) { - wrputc(',', wglb->stream); - lastw = separator; - } + if (op == wglb->MaxArgs) { + wrputs("...", wglb->stream); + break; + } + writeTerm(from_pointer(RepAppl(t) + op, &nrwt, wglb), 999, depth + 1, + FALSE, wglb, &nrwt); + t = AbsAppl(restore_from_write(&nrwt, wglb) - op); + if (op != Arity) { + wrputc(',', wglb->stream); + lastw = separator; + } } wrputc('}', wglb->stream); lastw = separator; @@ -1188,29 +1170,29 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str lastw = separator; wropen_bracket(wglb, FALSE); for (op = 1; op <= Arity; ++op) { - if (op == wglb->MaxArgs) { - wrputc('.', wglb->stream); - wrputc('.', wglb->stream); - wrputc('.', wglb->stream); - break; - } - writeTerm(from_pointer(RepAppl(t)+op, &nrwt, wglb), 999, depth + 1, FALSE, wglb, &nrwt); - restore_from_write(&nrwt, wglb); - if (op != Arity) { - wrputc(',', wglb->stream); - lastw = separator; - } + if (op == wglb->MaxArgs) { + wrputc('.', wglb->stream); + wrputc('.', wglb->stream); + wrputc('.', wglb->stream); + break; + } + writeTerm(from_pointer(RepAppl(t) + op, &nrwt, wglb), 999, depth + 1, + FALSE, wglb, &nrwt); + restore_from_write(&nrwt, wglb); + if (op != Arity) { + wrputc(',', wglb->stream); + lastw = separator; + } } wrclose_bracket(wglb, TRUE); } } } -void -Yap_plwrite(Term t, void *mywrite, int max_depth, int flags, int priority) - /* term to be written */ - /* consumer */ - /* write options */ +void Yap_plwrite(Term t, void *mywrite, int max_depth, int flags, int priority) +/* term to be written */ +/* consumer */ +/* write options */ { struct write_globs wglb; struct rewind_term rwt; @@ -1230,7 +1212,7 @@ Yap_plwrite(Term t, void *mywrite, int max_depth, int flags, int priority) wglb.MaxArgs = max_depth; /* notice: we must have ASP well set when using portray, otherwise we cannot make recursive Prolog calls */ - wglb.Keep_terms = (flags & (Use_portray_f|To_heap_f)); + wglb.Keep_terms = (flags & (Use_portray_f | To_heap_f)); /* initialise wglb */ rwt.parent = NULL; wglb.Ignore_ops = flags & Ignore_ops_f; @@ -1239,4 +1221,3 @@ Yap_plwrite(Term t, void *mywrite, int max_depth, int flags, int priority) writeTerm(from_pointer(&t, &rwt, &wglb), priority, 1, FALSE, &wglb, &rwt); restore_from_write(&rwt, &wglb); } - diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ed4bbf47..72738ae51 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -509,13 +509,18 @@ ADD_SUBDIRECTORY(swi/library) # ADD_SUBDIRECTORY(os) # ADD_SUBDIRECTORY(packages) -if (BUILD_JIT) - add_definitions (-DYAP_JIT=1) - INCLUDE_DIRECTORIES(JIT JIT/HPP) - macro_optional_add_subdirectory(JIT ON) - endif() +macro_optional_find_package (LLVM ON) +macro_log_feature (LLVM_FOUND "LLVM JIT generator" + "The LLVM Compiler Infrastructure" "http://www.llvm.org") + +if (LLVM_FOUND) + add_definitions (-DYAP_JIT=1) + INCLUDE_DIRECTORIES(JIT JIT/HPP) + macro_optional_add_subdirectory(JIT) +endif() macro_optional_add_subdirectory(library/mpi) + macro_optional_add_subdirectory(library/lammpi) macro_optional_add_subdirectory (packages/gecode) diff --git a/H/ScannerTypes.h b/H/ScannerTypes.h index 79c95e047..ec5cc133c 100644 --- a/H/ScannerTypes.h +++ b/H/ScannerTypes.h @@ -4,6 +4,7 @@ typedef enum TokenKinds { Var_tok, String_tok, WString_tok, + StringTerm_tok, Ponctuation_tok, Error_tok, QuasiQuotes_tok, @@ -29,4 +30,3 @@ typedef struct VARSTRUCT { struct VARSTRUCT *VarLeft, *VarRight; char VarRep[1]; } VarEntry; - diff --git a/H/amijit.h b/H/amijit.h index cb6a45a6f..3d221329b 100644 --- a/H/amijit.h +++ b/H/amijit.h @@ -336,7 +336,7 @@ typedef struct environment { #if YAP_JIT /* Enumeration for types of basic blocks -- used on trace construction */ -typedef enum { +typedef enum block_try { NONE, // untyped SIMPLE_ENTRY, // first basic block of any yaam opcode SIMPLE, // any other basic block of any yaam opcode diff --git a/H/yapio.h b/H/yapio.h index c6c40bfa4..35c7a13a5 100644 --- a/H/yapio.h +++ b/H/yapio.h @@ -149,36 +149,6 @@ extern YP_FILE yp_iob[YP_MAX_FILES]; typedef YP_FILE *YP_File; -/* ricardo -typedef enum TokenKinds { - Name_tok, - Number_tok, - Var_tok, - String_tok, - WString_tok, - Ponctuation_tok, - Error_tok, - eot_tok -} tkinds; - -typedef struct TOKEN { - enum TokenKinds Tok; - Term TokInfo; - int TokPos; - struct TOKEN *TokNext; -} TokEntry; - -#define Ord(X) ((enum TokenKinds) (X)) - -#define NextToken GNextToken( PASS_REGS1 ) - -typedef struct VARSTRUCT { - Term VarAdr; - CELL hv; - struct VARSTRUCT *VarLeft, *VarRight; - char VarRep[1]; -} VarEntry; -*/ #ifndef _PL_WRITE_ @@ -351,5 +321,3 @@ WideHashFunction(wchar_t *CHP) #define QUIET_ON_PARSER_ERROR 1 #define CONTINUE_ON_PARSER_ERROR 2 #define EXCEPTION_ON_PARSER_ERROR 3 - - diff --git a/JIT/CMakeLists.txt b/JIT/CMakeLists.txt index 93dd865ca..d1c2ca5b4 100644 --- a/JIT/CMakeLists.txt +++ b/JIT/CMakeLists.txt @@ -10,17 +10,12 @@ set(LIBJIT_SOURCES jit_statisticpreds.c jit_codegenpreds.c jit_debugpreds.c - jit_traced.c - jit_transformpreds.c + jit_traced.c + jit_transformpreds.c JIT_Compiler.cpp JIT_Init.cpp ) -macro_optional_find_package (LLVM ON) -macro_log_feature (LLVM_FOUND "LLVM JIT generator" - "The LLVM Compiler Infrastructure" "http://www.llvm.org") - - # The following variables are defined: # LLVM_FOUND - true if LLVM was found # LLVM_CXXFLAGS - C++ compiler flags for files that include LLVM headers. diff --git a/os/pl-prologflag.c b/os/pl-prologflag.c index 09756fc59..41856cd4a 100755 --- a/os/pl-prologflag.c +++ b/os/pl-prologflag.c @@ -298,7 +298,7 @@ setUnknown(term_t value, atom_t a, Module m) return PL_error(NULL, 0, NULL, ERR_PERMISSION, ATOM_modify, ATOM_flag, key); } - + if ( !SYSTEM_MODE ) printMessage(ATOM_warning, PL_CHARS, "unknown_in_module_user"); } @@ -1074,7 +1074,7 @@ pl_prolog_flag(term_t name, term_t value, control_t h) static void initPrologFlagTable(void) { if ( !GD->prolog_flag.table ) - { + { #ifndef __YAP_PROLOG__ initPrologThreads(); /* may be called before PL_initialise() */ #endif @@ -1194,7 +1194,7 @@ initPrologFlags(void) setPrologFlag("colon_sets_calling_context", FT_BOOL|FF_READONLY, TRUE, 0); setPrologFlag("character_escapes", FT_BOOL, TRUE, PLFLAG_CHARESCAPE); setPrologFlag("char_conversion", FT_BOOL, FALSE, PLFLAG_CHARCONVERSION); - setPrologFlag("backquoted_string", FT_BOOL, FALSE, PLFLAG_BACKQUOTED_STRING); + setPrologFlag("backquoted_string", FT_BOOL, TRUE, PLFLAG_BACKQUOTED_STRING); #ifdef O_QUASIQUOTATIONS setPrologFlag("quasi_quotations", FT_BOOL, TRUE, PLFLAG_QUASI_QUOTES); #endif @@ -1329,4 +1329,3 @@ BeginPredDefs(prologflag) EndPredDefs //! @} - diff --git a/os/pl-utf8.c b/os/pl-utf8.c index d8e4a67e8..916b582df 100644 --- a/os/pl-utf8.c +++ b/os/pl-utf8.c @@ -152,27 +152,27 @@ char * _PL__utf8_skip_char(const char *in) { /* 2-byte, 0x80-0x7ff */ if ( (in[0]&0xe0) == 0xc0 && CONT(1) ) - { + { return (char *)in+2; } /* 3-byte, 0x800-0xffff */ if ( (in[0]&0xf0) == 0xe0 && CONT(1) && CONT(2) ) - { + { return (char *)in+3; } /* 4-byte, 0x10000-0x1FFFFF */ if ( (in[0]&0xf8) == 0xf0 && CONT(1) && CONT(2) && CONT(3) ) - { + { return (char *)in+4; } /* 5-byte, 0x200000-0x3FFFFFF */ if ( (in[0]&0xfc) == 0xf8 && CONT(1) && CONT(2) && CONT(3) && CONT(4) ) - { + { return (char *)in+5; } /* 6-byte, 0x400000-0x7FFFFFF */ if ( (in[0]&0xfe) == 0xfc && CONT(1) && CONT(2) && CONT(3) && CONT(4) && CONT(5) ) - { + { return (char *)in+4; } @@ -197,11 +197,11 @@ utf8_strlen(const char *s, size_t len) size_t utf8_strlen1(const char *s) -{ +{ unsigned int l = 0; while( s [0] ) - { + { s = utf8_skip_char(s); l++; } @@ -211,9 +211,9 @@ utf8_strlen1(const char *s) const char * utf8_skip(const char *s, int n) -{ +{ while(n--) - { + { if (!s[0]) return NULL; s = utf8_skip_char(s); } @@ -223,8 +223,8 @@ utf8_skip(const char *s, int n) int utf8_strncmp(const char *s1, const char *s2, size_t n) -{ - +{ + while(n-- >0) { int chr1, chr2; @@ -239,8 +239,8 @@ utf8_strncmp(const char *s1, const char *s2, size_t n) int utf8_strprefix(const char *s1, const char *s2) -{ - +{ + while(1) { int chr1, chr2; @@ -252,3 +252,21 @@ utf8_strprefix(const char *s1, const char *s2) return 0; } + +char * +utf8_wcscpy(char *sf, const wchar_t *s0) +{ + char *sf0 = sf; + while(1) + { int chr1; + + chr1 = * s0++; + if (chr1 == '\0') { + *sf++ = '\0'; + return sf0; + } + sf = utf8_put_char(sf, chr1); + } + + return NULL; +} diff --git a/os/pl-utf8.h b/os/pl-utf8.h index 9ec6c6a3c..488791db3 100644 --- a/os/pl-utf8.h +++ b/os/pl-utf8.h @@ -26,6 +26,8 @@ #ifndef UTF8_H_INCLUDED #define UTF8_H_INCLUDED +#include + #define PL_MB_LEN_MAX 16 #define UTF8_MALFORMED_REPLACEMENT 0xfffd @@ -66,6 +68,8 @@ extern size_t utf8_strlen1(const char *s); extern const char * utf8_skip(const char *s, int n); extern int utf8_strncmp(const char *s1, const char *s2, size_t n); extern int utf8_strprefix(const char *s1, const char *s2); +/// copy a wide string to an UTF-8 version. +extern char *utf8_wcscpy(char *sf, const wchar_t *s0); typedef enum { S_ASCII, diff --git a/os/pl-write.c b/os/pl-write.c index 197cc8600..eec18e0c5 100644 --- a/os/pl-write.c +++ b/os/pl-write.c @@ -95,7 +95,7 @@ pl_nl1(term_t stream) fail; } -/** @pred nl is iso +/** @pred nl is iso Outputs a new line to the current output stream. @@ -219,7 +219,7 @@ bind_varnames(term_t varnames ARG_LD) char * varName(term_t t, char *name) -{ +{ CACHE_REGS CELL *adr = (CELL *)Yap_GetFromSlot(t PASS_REGS); @@ -240,7 +240,7 @@ writeTopTerm(term_t t, int prec, write_options *options) UInt yap_flag = Use_SWI_Stream_f; int flags = options->flags; Term old_module; - + if (flags & PL_WRT_QUOTED) yap_flag |= Quote_illegal_f; if (options->flags & PL_WRT_NUMBERVARS) @@ -486,7 +486,7 @@ pl_write_term3(term_t stream, term_t term, term_t opts) options.module = lookupModule(mname); if ( charescape == TRUE || - (charescape == -1 + (charescape == -1 #ifndef __YAP_PROLOG__ && True(options.module, M_CHARESCAPE) #endif @@ -543,7 +543,7 @@ out: Displays term _T_ on the current output stream, according to the same options used by `write_term/3`. - + */ /// @memberof write_term/3 word @@ -551,7 +551,7 @@ pl_write_term(term_t term, term_t options) { return pl_write_term3(0, term, options); } -/** @pred write_term(+ _T_, + _Opts_) is iso +/** @pred write_term(+ _T_, + _Opts_) is iso Displays term _T_ on the current output stream, according to the @@ -592,7 +592,7 @@ unlimited depth. + priority(+ _Piority_) - If `Priority` is a positive integer smaller than `1200`, + If `Priority` is a positive integer smaller than `1200`, give the context priority. The default is `1200`. + cycles(+ _Bool_) @@ -628,9 +628,9 @@ do_write2(term_t stream, term_t term, int flags) options.flags = flags; options.out = s; options.module = MODULE_user; - if ( options.module + if ( options.module #ifndef __YAP_PROLOG__ - && True(options.module, M_CHARESCAPE) + && True(options.module, M_CHARESCAPE) #endif ) options.flags |= PL_WRT_CHARESCAPES; @@ -654,7 +654,7 @@ do_write2(term_t stream, term_t term, int flags) Writes term _T_ to stream _S_ instead of to the current output stream. - + */ /// @memberof write/2 word @@ -666,7 +666,7 @@ pl_write2(term_t stream, term_t term) As writeq/1, but the output is sent to the stream _S_. - + */ /// @memberof writeq/2 word @@ -679,7 +679,7 @@ pl_writeq2(term_t stream, term_t term) Prints term _T_ to the stream _S_ instead of to the current output stream. - + */ /// @memberof print/2 word @@ -693,7 +693,7 @@ pl_print2(term_t stream, term_t term) Displays term _T_ on the stream _S_. Atoms are quoted when necessary, and operators are ignored. - + */ /// @memberof write_canonical/2 word @@ -711,7 +711,7 @@ pl_write_canonical2(term_t stream, term_t term) rc = ( numberVars(term, &options, 0 PASS_LD) >= 0 && do_write2(stream, term, - PL_WRT_QUOTED|PL_WRT_IGNOREOPS|PL_WRT_NUMBERVARS) + PL_WRT_QUOTED|PL_WRT_IGNOREOPS|PL_WRT_NUMBERVARS|PLFLAG_BACKQUOTED_STRING) ); END_NUMBERVARS(TRUE); @@ -719,7 +719,7 @@ pl_write_canonical2(term_t stream, term_t term) return rc; } -/** @pred write( _T_) is iso +/** @pred write( _T_) is iso The term _T_ is written to the current output stream according to @@ -732,17 +732,17 @@ pl_write(term_t term) } word -/** @pred writeq( _T_) is iso +/** @pred writeq( _T_) is iso Writes the term _T_, quoting names to make the result acceptable to -the predicate `read` whenever necessary. +the predicate `read` whenever necessary. */ /// @memberof writeq/1 pl_writeq(term_t term) { return pl_writeq2(0, term); } -/** @pred print( _T_) +/** @pred print( _T_) Prints the term _T_ to the current output stream using write/1 @@ -750,7 +750,7 @@ unless T is bound and a call to the user-defined predicate `portray/1` succeeds. To do pretty printing of terms the user should define suitable clauses for `portray/1` and use print/1. - + */ /// @memberof print/1 word @@ -758,14 +758,14 @@ pl_print(term_t term) { return pl_print2(0, term); } -/** @pred write_canonical(+ _T_) is iso +/** @pred write_canonical(+ _T_) is iso Displays term _T_ on the current output stream. Atoms are quoted when necessary, and operators are ignored, that is, the term is written in standard parenthesized prefix notation. - + */ /// @memberof write_canonical/1 word @@ -773,13 +773,13 @@ pl_write_canonical(term_t term) { return pl_write_canonical2(0, term); } -/** @pred writeln( _T_) +/** @pred writeln( _T_) Prints the term _T_ to the current output stream using write/1, followed by a newline. - + */ /// @memberof writeln/1 word @@ -796,5 +796,3 @@ pl_writeln(term_t term) BeginPredDefs(write) EndPredDefs - - diff --git a/packages/clib b/packages/clib index 849232fea..8257467ff 160000 --- a/packages/clib +++ b/packages/clib @@ -1 +1 @@ -Subproject commit 849232fea0f549f6704b16afa1c986e0d50ec177 +Subproject commit 8257467ff9a7bb901d1688e6a75ad072e0246aba diff --git a/packages/gecode/gecode.yap b/packages/gecode/gecode.yap index f9c8a8682..575bf79f0 100644 --- a/packages/gecode/gecode.yap +++ b/packages/gecode/gecode.yap @@ -1,6 +1,4859 @@ +%% -*- prolog -*- +%%============================================================================= +%% Copyright (C) 2011 by Denys Duchier +%% +%% This program is free software: you can redistribute it and/or modify it +%% under the terms of the GNU Lesser General Public License as published by the +%% Free Software Foundation, either version 3 of the License, or (at your +%% option) any later version. +%% +%% This program is distributed in the hope that it will be useful, but WITHOUT +%% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +%% FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +%% more details. +%% +%% You should have received a copy of the GNU Lesser General Public License +%% along with this program. If not, see . +%%============================================================================= -/* just for program analysis */ +/** @defgroup Gecode Gecode Interface -:- include(gecode4_yap_hand_written). -:- include('4.2.1/gecode_yap_auto_generated.yap'). +@ingroup packages +@{ + + +The gecode library intreface was designed and implemented by Denis +Duchier, with recent work by Vítor Santos Costa to port it to version 4 +of gecode and to have an higher level interface, + + + @defgroup The_Gecode_Interface The Gecode Interface +@ingroup Gecode +@{ + +This text is due to Denys Duchier. The gecode interface requires + +~~~~~{.prolog} +:- use_module(library(gecode)). +~~~~~ +Several example programs are available with the distribution. + ++ CREATING A SPACE + +A space is gecodes data representation for a store of constraints: + +~~~~~{.prolog} + Space := space +~~~~~ + ++ CREATING VARIABLES + +Unlike in Gecode, variable objects are not bound to a specific Space. Each one +actually contains an index with which it is possible to access a Space-bound +Gecode variable. Variables can be created using the following expressions: + +~~~~~{.prolog} + IVar := intvar(Space,SPEC...) + BVar := boolvar(Space) + SVar := setvar(Space,SPEC...) +~~~~~ + +where SPEC... is the same as in Gecode. For creating lists of variables use +the following variants: + +~~~~~{.prolog} + IVars := intvars(Space,N,SPEC...) + BVars := boolvars(Space,N,SPEC...) + SVars := setvars(Space,N,SPEC...) +~~~~~ + +where N is the number of variables to create (just like for XXXVarArray in +Gecode). Sometimes an IntSet is necessary: + +~~~~~{.prolog} + ISet := intset([SPEC...]) +~~~~~ + +where each SPEC is either an integer or a pair (I,J) of integers. An IntSet +describes a set of ints by providing either intervals, or integers (which stand +for an interval of themselves). It might be tempting to simply represent an +IntSet as a list of specs, but this would be ambiguous with IntArgs which, +here, are represented as lists of ints. + +~~~~~{.prolog} + Space += keep(Var) + Space += keep(Vars) +~~~~~ + +Variables can be marked as "kept". In this case, only such variables will be +explicitly copied during search. This could bring substantial benefits in +memory usage. Of course, in a solution, you can then only look at variables +that have been "kept". If no variable is marked as "kept", then they are all +kept. Thus marking variables as "kept" is purely an optimization. + ++ CONSTRAINTS AND BRANCHINGS + +all constraint and branching posting functions are available just like in +Gecode. Wherever a XXXArgs or YYYSharedArray is expected, simply use a list. +At present, there is no support for minimodel-like constraint posting. +Constraints and branchings are added to a space using: + +~~~~~{.prolog} + Space += CONSTRAINT + Space += BRANCHING +~~~~~ + +For example: + +~~~~~{.prolog} + Space += rel(X,'IRT_EQ',Y) +~~~~~ + +arrays of variables are represented by lists of variables, and constants are +represented by atoms with the same name as the Gecode constant +(e.g. 'INT_VAR_SIZE_MIN'). + ++ SEARCHING FOR SOLUTIONS + +~~~~~{.prolog} + SolSpace := search(Space) +~~~~~ + +This is a backtrackable predicate that enumerates all solution spaces +(SolSpace). It may also take options: + +~~~~~{.prolog} + SolSpace := search(Space,Options) +~~~~~ + +Options is a list whose elements maybe: + ++ restart +to select the Restart search engine ++ threads=N +to activate the parallel search engine and control the number of +workers (see Gecode doc) ++ c_d=N +to set the commit distance for recomputation ++ a_d=N +to set the adaptive distance for recomputation + + + ++ EXTRACTING INFO FROM A SOLUTION + +An advantage of non Space-bound variables, is that you can use them both to +post constraints in the original space AND to consult their values in +solutions. Below are methods for looking up information about variables. Each +of these methods can either take a variable as argument, or a list of +variables, and returns resp. either a value, or a list of values: + +~~~~~{.prolog} + Val := assigned(Space,X) + + Val := min(Space,X) + Val := max(Space,X) + Val := med(Space,X) + Val := val(Space,X) + Val := size(Space,X) + Val := width(Space,X) + Val := regret_min(Space,X) + Val := regret_max(Space,X) + + Val := glbSize(Space,V) + Val := lubSize(Space,V) + Val := unknownSize(Space,V) + Val := cardMin(Space,V) + Val := cardMax(Space,V) + Val := lubMin(Space,V) + Val := lubMax(Space,V) + Val := glbMin(Space,V) + Val := glbMax(Space,V) + Val := glb_ranges(Space,V) + Val := lub_ranges(Space,V) + Val := unknown_ranges(Space,V) + Val := glb_values(Space,V) + Val := lub_values(Space,V) + Val := unknown_values(Space,V) +~~~~~ + ++ DISJUNCTORS + +Disjunctors provide support for disjunctions of clauses, where each clause is a +conjunction of constraints: + +~~~~~{.prolog} + C1 or C2 or ... or Cn +~~~~~ + +Each clause is executed "speculatively": this means it does not affect the main +space. When a clause becomes failed, it is discarded. When only one clause +remains, it is committed: this means that it now affects the main space. + +Example: + +Consider the problem where either X=Y=0 or X=Y+(1 or 2) for variable X and Y +that take values in 0..3. + +~~~~~{.prolog} + Space := space, + [X,Y] := intvars(Space,2,0,3), +~~~~~ + +First, we must create a disjunctor as a manager for our 2 clauses: + +~~~~~{.prolog} + Disj := disjunctor(Space), +~~~~~ + +We can now create our first clause: + +~~~~~{.prolog} + C1 := clause(Disj), +~~~~~ + +This clause wants to constrain X and Y to 0. However, since it must be +executed "speculatively", it must operate on new variables X1 and Y1 that +shadow X and Y: + +~~~~~{.prolog} + [X1,Y1] := intvars(C1,2,0,3), + C1 += forward([X,Y],[X1,Y1]), +~~~~~ + +The forward(...) stipulation indicates which global variable is shadowed by +which clause-local variable. Now we can post the speculative clause-local +constraints for X=Y=0: + +~~~~~{.prolog} + C1 += rel(X1,'IRT_EQ',0), + C1 += rel(Y1,'IRT_EQ',0), +~~~~~ + +We now create the second clause which uses X2 and Y2 to shadow X and Y: + +~~~~~{.prolog} + C2 := clause(Disj), + [X2,Y2] := intvars(C2,2,0,3), + C2 += forward([X,Y],[X2,Y2]), +~~~~~ + +However, this clause also needs a clause-local variable Z2 taking values 1 or +2 in order to post the clause-local constraint X2=Y2+Z2: + +~~~~~{.prolog} + Z2 := intvar(C2,1,2), + C2 += linear([-1,1,1],[X2,Y2,Z2],'IRT_EQ',0), +~~~~~ + +Finally, we can branch and search: + +~~~~~{.prolog} + Space += branch([X,Y],'INT_VAR_SIZE_MIN','INT_VAL_MIN'), + SolSpace := search(Space), +~~~~~ + +and lookup values of variables in each solution: + +~~~~~{.prolog} + [X_,Y_] := val(SolSpace,[X,Y]). +~~~~~ + + + + +*/ + +:- module(gecode, [(:=)/2, op(500, xfx, ':='), + (+=)/2, op(500, xfx, '+=')]). + + +:- use_module(library(debug)). + +:- op(500, xfx, ':='). +:- op(500, xfx, '+='). +:- load_foreign_files([gecode_yap],[],gecode_init). + +is_int(X,Y) :- integer(X), Y=X. +is_int(X) :- integer(X). + +is_bool_(true,true). +is_bool_(false,false). +is_bool(X,Y) :- nonvar(X), Y=X. +is_bool(X) :- is_bool(X,_). + +is_IntVar_('IntVar'(I,K),N) :- + integer(I), + integer(K), + nb_getval(gecode_space_use_keep_index,B), + (B=true -> N=K ; N=I). +is_FloatVar_('FloatVar'(I,K),N) :- + integer(I), + integer(K), + nb_getval(gecode_space_use_keep_index,B), + (B=true -> N=K ; N=I). +is_BoolVar_('BoolVar'(I,K),N) :- + integer(I), + integer(K), + nb_getval(gecode_space_use_keep_index,B), + (B=true -> N=K ; N=I). +is_SetVar_('SetVar'(I,K),N) :- + integer(I), + integer(K), + nb_getval(gecode_space_use_keep_index,B), + (B=true -> N=K ; N=I). + +is_IntVar(X,I) :- nonvar(X), is_IntVar_(X,I). +is_BoolVar(X,I) :- nonvar(X), is_BoolVar_(X,I). +is_FloatVar(X,I) :- nonvar(X), is_FloatVar_(X,I). +is_SetVar(X,I) :- nonvar(X), is_SetVar_(X,I). + +is_IntVar(X) :- is_IntVar(X,_). +is_BoolVar(X) :- is_BoolVar(X,_). +is_FloatVar(X) :- is_FloatVar(X,_). +is_SetVar(X) :- is_SetVar(X,_). + +is_IntVarArgs_([],[]). +is_IntVarArgs_([H|T],[H2|T2]) :- is_IntVar(H,H2), is_IntVarArgs(T,T2). +is_IntVarArgs(X,Y) :- nonvar(X), is_IntVarArgs_(X,Y). +is_IntVarArgs(X) :- \+ \+ is_IntVarArgs(X,_). + +is_BoolVarArgs_([],[]). +is_BoolVarArgs_([H|T],[H2|T2]) :- is_BoolVar(H,H2), is_BoolVarArgs(T,T2). +is_BoolVarArgs(X,Y) :- nonvar(X), is_BoolVarArgs_(X,Y). +is_BoolVarArgs(X) :- \+ \+ is_BoolVarArgs(X,_). + +is_FloatVarArgs_([],[]). +is_FloatVarArgs_([H|T],[H2|T2]) :- is_FloatVar(H,H2), is_FloatVarArgs(T,T2). +is_FloatVarArgs(X,Y) :- nonvar(X), is_FloatVarArgs_(X,Y). +is_FloatVarArgs(X) :- \+ \+ is_FloatVarArgs(X,_). + +is_FloatValArgs_([],[]). +is_FloatValArgs_([H|T],[H2|T2]) :- is_FloatVar(H,H2), is_FloatValArgs(T,T2). +is_FloatValArgs(X,Y) :- nonvar(X), is_FloatValArgs_(X,Y). +is_FloatValArgs(X) :- \+ \+ is_FloatValArgs(X,_). + +is_SetVarArgs_([],[]). +is_SetVarArgs_([H|T],[H2|T2]) :- is_SetVar(H,H2), is_SetVarArgs(T,T2). +is_SetVarArgs(X,Y) :- nonvar(X), is_SetVarArgs_(X,Y). +is_SetVarArgs(X) :- \+ \+ is_SetVarArgs(X,_). + +is_IntArgs_([],[]). +is_IntArgs_([H|T],[H|T2]) :- integer(H), is_IntArgs(T,T2). +is_IntArgs(X,Y) :- nonvar(X), is_IntArgs_(X,Y). +is_IntArgs(X) :- \+ \+ is_IntArgs(X,_). + +is_IntSharedArray(X) :- is_IntArgs(X). +is_IntSharedArray(X,Y) :- is_IntArgs(X,Y). + +is_TaskTypeArgs_([],[]). +is_TaskTypeArgs_([H|T],[H2|T2]) :- is_TaskType(H,H2), is_TaskTypeArgs(T,T2). +is_TaskTypeArgs(X,Y) :- nonvar(X), is_TaskTypeArgs_(X,Y). +is_TaskTypeArgs(X) :- \+ \+ is_TaskTypeArgs(X,_). + +is_IntSet_('IntSet'(L),L). +is_IntSet(X,Y) :- nonvar(X), is_IntSet_(X,Y). +is_IntSet(X) :- is_IntSet(X,_). + +is_IntSetArgs_([],[]). +is_IntSetArgs_([H|T],[H2|T2]) :- is_IntSet(H,H2), is_IntSetArgs(T,T2). +is_IntSetArgs(X,Y) :- nonvar(X), is_IntSetArgs_(X,Y). +is_IntSetArgs(X) :- \+ \+ is_IntSetArgs(X,_). + +is_TupleSet_('TupleSet'(TS),TS). +is_TupleSet(X,Y) :- nonvar(X), is_TupleSet_(X,Y). +is_TupleSet(X) :- is_TupleSet(X,_). + +is_DFA_('DFA'(TS),TS). +is_DFA(X,Y) :- nonvar(X), is_DFA_(X,Y). +is_DFA(X) :- is_DFA(X,_). + +new_intset(X,I,J) :- intset(X,I,J). +new_intset(X,L) :- intset(X,L). + +intset(X, I, J) :- + integer(I), + integer(J), + X='IntSet'([(I,J)]). +intset(X, L) :- + is_list_of_intset_specs(L,L2), + X='IntSet'(L2). + +is_list_of_intset_specs(X,Y) :- + nonvar(X), is_list_of_intset_specs_(X,Y). +is_list_of_intset_specs_([],[]). +is_list_of_intset_specs_([H|T],[H2|T2]) :- + is_intset_spec(H,H2), + is_list_of_intset_specs(T,T2). + +is_intset_spec(X,Y) :- nonvar(X), is_intset_spec_(X,Y). +is_intset_spec_((I,J),(I,J)) :- !, integer(I), integer(J). +is_intset_spec_(I,(I,I)) :- integer(I). + +assert_var(X,Y) :- + var(X) -> X=Y; throw(gecode_error(expected(var))). +assert_is_int(X,Y) :- + integer(X) -> X=Y ; throw(gecode_error(expected(int))). +assert_is_float(X,Y) :- + float(X) -> X=Y ; throw(gecode_error(expected(int))). +assert_is_Space(X,Y) :- + is_Space(X,Y) -> true ; throw(gecode_error(expected(space))). +assert_is_IntSet(X,Y) :- + is_IntSet(X,Y) -> true ; throw(gecode_error(expected(intset))). +assert_is_TupleSet(X,Y) :- + is_TupleSet(X,Y) -> true ; throw(gecode_error(expected(tupleset))). +assert_is_DFA(X,Y) :- + is_DFA(X,Y) -> true ; throw(gecode_error(expected(dfa))). +assert_is_IntVar(X,Y) :- + is_IntVar(X,Y) -> true ; throw(gecode_error(expected(intvar))). +assert_is_BoolVar(X,Y) :- + is_BoolVar(X,Y) -> true ; throw(gecode_error(expected(boolvar))). +assert_is_FloatVar(X,Y) :- + is_FloatVar(X,Y) -> true ; throw(gecode_error(expected(floatvar))). +assert_is_SetVar(X,Y) :- + is_SetVar(X,Y) -> true ; throw(gecode_error(expected(setvar))). +assert_is_IntArgs(X,Y) :- + is_IntArgs(X,Y) -> true ; throw(gecode_error(expected(intargs))). +assert_is_IntVarArgs(X,Y) :- + is_IntVarArgs(X,Y) -> true ; throw(gecode_error(expected(intvarargs))). +assert_is_BoolVarArgs(X,Y) :- + is_BoolVarArgs(X,Y) -> true ; throw(gecode_error(expected(boolvarargs))). +assert_is_FloatVarArgs(X,Y) :- + is_FloatVarArgs(X,Y) -> true ; throw(gecode_error(expected(floatvarargs))). +assert_is_FloatValArgs(X,Y) :- + is_FloatValArgs(X,Y) -> true ; throw(gecode_error(expected(floatvarargs))). +assert_is_SetVarArgs(X,Y) :- + is_SetVarArgs(X,Y) -> true ; throw(gecode_error(expected(setvarargs))). +assert_is_ReifyMode(X,Y) :- + is_ReifyMode(X,Y) -> true ; throw(gecode_error(expected(reifymode))). + +assert_var(X) :- assert_var(X,_). +assert_is_int(X) :- assert_is_int(X,_). +assert_is_float(X) :- assert_is_float(X,_). +assert_is_Space(X) :- assert_is_Space(X,_). +assert_is_IntSet(X) :- assert_is_IntSet(X,_). +assert_is_IntVar(X) :- assert_is_IntVar(X,_). +assert_is_BoolVar(X) :- assert_is_BoolVar(X,_). +assert_is_FloatVar(X) :- assert_is_FloatVar(X,_). +assert_is_SetVar(X) :- assert_is_SetVar(X,_). +assert_is_IntArgs(X) :- assert_is_IntArgs(X,_). +assert_is_IntVarArgs(X) :- assert_is_IntVarArgs(X,_). +assert_is_BoolVarArgs(X) :- assert_is_BoolVarArgs(X,_). +assert_is_FloatVarArgs(X) :- assert_is_FloatVarArgs(X,_). +assert_is_FloatValArgs(X) :- assert_is_FloatValArgs(X,_). +assert_is_SetVarArgs(X) :- assert_is_SetVarArgs(X,_). + +%% Var and Val Branching changed in Gecode 4 to be done as a set of functions, +%% not as an enum. + +is_IntVarBranch_('INT_VAR_NONE'). +is_IntVarBranch_('INT_VAR_RND'(_)). +is_IntVarBranch_('INT_VAR_MERIT_MIN'(_)). +is_IntVarBranch_('INT_VAR_MERIT_MAX'(_)). +is_IntVarBranch_('INT_VAR_DEGREE_MIN'). +is_IntVarBranch_('INT_VAR_DEGREE_MAX'). +is_IntVarBranch_('INT_VAR_AFC_MIN'(_)). +is_IntVarBranch_('INT_VAR_AFC_MAX'(_)). +is_IntVarBranch_('INT_VAR_ACTIVITY_MIN'(_)). +is_IntVarBranch_('INT_VAR_ACTIVITY_MAX'(_)). +is_IntVarBranch_('INT_VAR_MIN_MIN'). +is_IntVarBranch_('INT_VAR_MIN_MAX'). +is_IntVarBranch_('INT_VAR_MAX_MIN'). +is_IntVarBranch_('INT_VAR_MAX_MAX'). +is_IntVarBranch_('INT_VAR_SIZE_MIN'). +is_IntVarBranch_('INT_VAR_SIZE_MAX'). +is_IntVarBranch_('INT_VAR_DEGREE_SIZE_MIN'). +is_IntVarBranch_('INT_VAR_DEGREE_SIZE_MAX'). +is_IntVarBranch_('INT_VAR_AFC_SIZE_MIN'(_)). +is_IntVarBranch_('INT_VAR_AFC_SIZE_MAX'(_)). +is_IntVarBranch_('INT_VAR_ACTIVITY_SIZE_MIN'(_)). +is_IntVarBranch_('INT_VAR_ACTIVITY_SIZE_MAX'(_)). +is_IntVarBranch_('INT_VAR_REGRET_MIN_MIN'). +is_IntVarBranch_('INT_VAR_REGRET_MIN_MAX'). +is_IntVarBranch_('INT_VAR_REGRET_MAX_MIN'). +is_IntVarBranch_('INT_VAR_REGRET_MAX_MAX'). + +is_IntVarBranch_(X, X) :- + is_IntVarBranch_(X). + +is_IntVarBranch(X,Y) :- nonvar(X), is_IntVarBranch_(X,Y). +is_IntVarBranch(X) :- is_IntVarBranch(X,_). + +is_SetVarBranch_('SET_VAR_NONE'). +is_SetVarBranch_('SET_VAR_RND'(_)). +is_SetVarBranch_('SET_VAR_MERIT_MIN'(_)). +is_SetVarBranch_('SET_VAR_MERIT_MAX'(_)). +is_SetVarBranch_('SET_VAR_DEGREE_MIN'). +is_SetVarBranch_('SET_VAR_DEGREE_MAX'). +is_SetVarBranch_('SET_VAR_AFC_MIN'(_)). +is_SetVarBranch_('SET_VAR_AFC_MAX'(_)). +is_SetVarBranch_('SET_VAR_ACTIVITY_MIN'(_)). +is_SetVarBranch_('SET_VAR_ACTIVITY_MAX'(_)). +is_SetVarBranch_('SET_VAR_MIN_MIN'). +is_SetVarBranch_('SET_VAR_MIN_MAX'). +is_SetVarBranch_('SET_VAR_MAX_MIN'). +is_SetVarBranch_('SET_VAR_MAX_MAX'). +is_SetVarBranch_('SET_VAR_SIZE_MIN'). +is_SetVarBranch_('SET_VAR_SIZE_MAX'). +is_SetVarBranch_('SET_VAR_DEGREE_SIZE_MIN'). +is_SetVarBranch_('SET_VAR_DEGREE_SIZE_MAX'). +is_SetVarBranch_('SET_VAR_AFC_SIZE_MIN'(_)). +is_SetVarBranch_('SET_VAR_AFC_SIZE_MAX'(_)). +is_SetVarBranch_('SET_VAR_ACTIVITY_SIZE_MIN'(_)). +is_SetVarBranch_('SET_VAR_ACTIVITY_SIZE_MAX'(_)). + +is_SetVarBranch_(X, X) :- + is_SetVarBranch_(X). + +is_SetVarBranch(X,Y) :- nonvar(X), is_SetVarBranch_(X,Y). +is_SetVarBranch(X) :- is_SetVarBranch(X,_). + +is_FloatVarBranch_('FLOAT_VAR_NONE'). +is_FloatVarBranch_('FLOAT_VAR_RND'(_)). +is_FloatVarBranch_('FLOAT_VAR_MERIT_MIN'(_)). +is_FloatVarBranch_('FLOAT_VAR_MERIT_MAX'(_)). +is_FloatVarBranch_('FLOAT_VAR_DEGREE_MIN'). +is_FloatVarBranch_('FLOAT_VAR_DEGREE_MAX'). +is_FloatVarBranch_('FLOAT_VAR_AFC_MIN'(_)). +is_FloatVarBranch_('FLOAT_VAR_AFC_MAX'(_)). +is_FloatVarBranch_('FLOAT_VAR_ACTIVITY_MIN'(_)). +is_FloatVarBranch_('FLOAT_VAR_ACTIVITY_MAX'(_)). +is_FloatVarBranch_('FLOAT_VAR_MIN_MIN'). +is_FloatVarBranch_('FLOAT_VAR_MIN_MAX'). +is_FloatVarBranch_('FLOAT_VAR_MAX_MIN'). +is_FloatVarBranch_('FLOAT_VAR_MAX_MAX'). +is_FloatVarBranch_('FLOAT_VAR_SIZE_MIN'). +is_FloatVarBranch_('FLOAT_VAR_SIZE_MAX'). +is_FloatVarBranch_('FLOAT_VAR_DEGREE_SIZE_MIN'). +is_FloatVarBranch_('FLOAT_VAR_DEGREE_SIZE_MAX'). +is_FloatVarBranch_('FLOAT_VAR_AFC_SIZE_MIN'(_)). +is_FloatVarBranch_('FLOAT_VAR_AFC_SIZE_MAX'(_)). +is_FloatVarBranch_('FLOAT_VAR_ACTIVITY_SIZE_MIN'(_)). +is_FloatVarBranch_('FLOAT_VAR_ACTIVITY_SIZE_MAX'(_)). + +is_FloatVarBranch_(X, X) :- + is_FloatVarBranch_(X). + +is_FloatVarBranch(X,Y) :- nonvar(X), is_FloatVarBranch_(X,Y). +is_FloatVarBranch(X) :- is_FloatVarBranch(X,_). + +is_IntValBranch_('INT_VAL_RND'(_)). +is_IntValBranch_('INT_VAL'(_,_)). +is_IntValBranch_('INT_VAL_MIN'). +is_IntValBranch_('INT_VAL_MED'). +is_IntValBranch_('INT_VAL_MAX'). +is_IntValBranch_('INT_VAL_SPLIT_MIN'). +is_IntValBranch_('INT_VAL_SPLIT_MAX'). +is_IntValBranch_('INT_VAL_RANGE_MIN'). +is_IntValBranch_('INT_VAL_RANGE_MAX'). +is_IntValBranch_('INT_VALUES_MIN'). +is_IntValBranch_('INT_NEAR_MIN'(_)). +is_IntValBranch_('INT_NEAR_MAX'(_)). +is_IntValBranch_('INT_NEAR_INC'(_)). +is_IntValBranch_('INT_NEAR_DEC'(_)). + +is_IntValBranch_(X,X) :- is_IntValBranch_(X). + +is_IntValBranch(X,Y) :- nonvar(X), is_IntValBranch_(X,Y). +is_IntValBranch(X) :- is_IntValBranch(X,_). + +is_SetValBranch_('SET_VAL_RND_INC'(_)). +is_SetValBranch_('SET_VAL_RND_EXC'(_)). +is_SetValBranch_('SET_VAL'(_,_)). +is_SetValBranch_('SET_VAL_MIN_INC'). +is_SetValBranch_('SET_VAL_MIN_EXC'). +is_SetValBranch_('SET_VAL_MED_INC'). +is_SetValBranch_('SET_VAL_MED_EXC'). +is_SetValBranch_('SET_VAL_MAX_INC'). +is_SetValBranch_('SET_VAL_MAX_EXC'). + +is_SetValBranch_(X,X) :- is_SetValBranch_(X). + +is_SetValBranch(X,Y) :- nonvar(X), is_SetValBranch_(X,Y). +is_SetValBranch(X) :- is_SetValBranch(X,_). + +is_FloatValBranch_('FLOAT_VAL'(_,_)). +is_FloatValBranch_('FLOAT_VAL_SPLIT_RND'(_)). +is_FloatValBranch_('FLOAT_VAL_SPLIT_MIN'). +is_FloatValBranch_('FLOAT_VAL_SLIT_MAX'). + +is_FloatValBranch_(X,X) :- is_FloatValBranch_(X). + +is_FloatValBranch(X,Y) :- nonvar(X), is_FloatValBranch_(X,Y). +is_FloatValBranch(X) :- is_FloatValBranch(X,_). + + +new_space(Space) :- + assert_var(Space), + gecode_new_space(Space_), + Space='Space'(Space_). + +%% checking that an argument is a space sets a global variable +%% indicating whether variables need to be translated to their +%% original index or to their "keep" index. +%% +%% these bindings are going to take advantage of the fact that, +%% when a space is involved, it is checked first, thus setting +%% this global variable. subsequent accesses to variables are +%% then correctly translated. + +is_Space_('Space'(X),X) :- + gecode_space_use_keep_index(X,B), + nb_setval(gecode_space_use_keep_index,B). +is_Space(X,Y) :- nonvar(X), is_Space_(X,Y). +is_Space(X) :- is_Space(X,_). + +is_Reify_('Reify'(X),X). +is_Reify(X,Y) :- nonvar(X), is_Reify_(X,Y). +is_Reify(X) :- is_Reify(X,_). + +%% AUTOGENERATE ALL VARIANTS LATER! + +new_intvars([], _Space, _Lo, _Hi). +new_intvars([IVar|IVars], Space, Lo, Hi) :- + new_intvar(IVar, Space, Lo, Hi), + new_intvars(IVars, Space, Lo, Hi). + +new_intvars([], _Space, _IntSet). +new_intvars([IVar|IVars], Space, IntSet) :- + new_intvar(IVar, Space, IntSet), + new_intvars(IVars, Space, IntSet). + +new_boolvars([], _Space). +new_boolvars([BVar|BVars], Space) :- + new_boolvar(BVar, Space), + new_boolvars(BVars, Space). + +new_setvars([], _Space, _X1, _X2, _X3, _X4, _X5, _X6). +new_setvars([SVar|SVars], Space, X1, X2, X3, X4, X5, X6) :- + new_setvar(SVar, Space, X1, X2, X3, X4, X5, X6), + new_setvars(SVars, Space, X1, X2, X3, X4, X5, X6). + +new_setvars([], _Space, _X1, _X2, _X3, _X4, _X5). +new_setvars([SVar|SVars], Space, X1, X2, X3, X4, X5) :- + new_setvar(SVar, Space, X1, X2, X3, X4, X5), + new_setvars(SVars, Space, X1, X2, X3, X4, X5). + +new_setvars([], _Space, _X1, _X2, _X3, _X4). +new_setvars([SVar|SVars], Space, X1, X2, X3, X4) :- + new_setvar(SVar, Space, X1, X2, X3, X4), + new_setvars(SVars, Space, X1, X2, X3, X4). + +new_setvars([], _Space, _X1, _X2, _X3). +new_setvars([SVar|SVars], Space, X1, X2, X3) :- + new_setvar(SVar, Space, X1, X2, X3), + new_setvars(SVars, Space, X1, X2, X3). + +new_setvars([], _Space, _X1, _X2). +new_setvars([SVar|SVars], Space, X1, X2) :- + new_setvar(SVar, Space, X1, X2), + new_setvars(SVars, Space, X1, X2). + +%% AUTOGENERATE LATER + +assert_integer(X) :- assert_is_int(X). + +new_intvar(IVar, Space, Lo, Hi) :- !, + assert_var(IVar), + assert_is_Space_or_Clause(Space,Space_), + assert_integer(Lo), + assert_integer(Hi), + gecode_new_intvar_from_bounds(Idx,Space_,Lo,Hi), + IVar='IntVar'(Idx,-1). +new_intvar(IVar, Space, IntSet) :- !, + assert_var(IVar), + assert_is_Space_or_Clause(Space,Space_), + assert_is_IntSet(IntSet, L), + gecode_new_intvar_from_intset(Idx,Space_,L), + IVar='IntVar'(Idx,-1). + +new_floatvar(FVar, Space, Lo, Hi) :- !, + assert_var(FVar), + assert_is_Space_or_Clause(Space,Space_), + assert_float(Lo), + assert_float(Hi), + gecode_new_floatvar_from_bounds(Idx,Space_,Lo,Hi), + FVar='FloatVar'(Idx,-1). + +new_boolvar(BVar, Space) :- !, + assert_var(BVar), + assert_is_Space_or_Clause(Space,Space_), + gecode_new_boolvar(Idx,Space_), + BVar='BoolVar'(Idx,-1). + +%% (GlbMin,GlbMax,LubMin,LubMax,CardMin,CardMax) 6 new_setvar_1 +%% (GlbMin,GlbMax,LubMin,LubMax,CardMin) 5 new_setvar_2 +%% (GlbMin,GlbMax,LubMin,LubMax) 4 new_setvar_3 +%% (Glb,LubMin,LubMax,CardMin,CardMax) 5 new_setvar_4 +%% (Glb,LubMin,LubMax,CardMin) 4 new_setvar_5 +%% (Glb,LubMin,LubMax) 3 new_setvar_6 +%% (GlbMin,GlbMax,Lub,CardMin,CardMax) 5 new_setvar_7 +%% (GlbMin,GlbMax,Lub,CardMin) 4 new_setvar_8 +%% (GlbMin,GlbMax,Lub) 3 new_setvar_9 +%% (Glb,Lub,CardMin,CardMax) 4 new_setvar_10 +%% (Glb,Lub,CardMin) 3 new_setvar_11 +%% (Glb,Lub) 2 new_setvar_12 + +%% 6 arguments +%% (GlbMin,GlbMax,LubMin,LubMax,CardMin,CardMax) 6 new_setvar_1 +new_setvar(SVar, Space, GlbMin, GlbMax, LubMin, LubMax, CardMin, CardMax) :- + assert_var(SVar), + assert_is_Space_or_Clause(Space,Space_), + assert_integer(GlbMin), + assert_integer(GlbMax), + assert_integer(LubMin), + assert_integer(LubMax), + assert_integer(CardMin), + assert_integer(CardMax), + gecode_new_setvar(Idx, Space_, GlbMin, GlbMax, LubMin, LubMax, CardMin, CardMax), + SVar='SetVar'(Idx,-1). + +%% 5 arguments +%% (GlbMin,GlbMax,LubMin,LubMax,CardMin) 5 new_setvar_2 +%% (Glb,LubMin,LubMax,CardMin,CardMax) 5 new_setvar_4 +%% (GlbMin,GlbMax,Lub,CardMin,CardMax) 5 new_setvar_7 +new_setvar(SVar, Space, X1, X2, X3, X4, X5) :- + assert_var(SVar), + assert_is_Space_or_Clause(Space,Space_), + (integer(X1) + -> + assert_integer(X2), + assert_integer(X4), + assert_integer(X5), + (is_IntSet(X3,X3_) + -> gecode_new_setvar_7(Idx,Space_,X1,X2,X3_,X4,X5) + ; gecode_new_setvar_2(Idx,Space_,X1,X2,X3,X4,X5)) + ; + assert_is_IntSet(X1,X1_), + assert_integer(X2), + assert_integer(X3), + assert_integer(X4), + assert_integer(X5), + gecode_new_setvar_4(Idx,Space_,X1_,X2,X3,X4,X5)), + SVar='SetVar'(Idx,-1). + +%% 4 arguments +%% (GlbMin,GlbMax,LubMin,LubMax) 4 new_setvar_3 +%% (Glb,LubMin,LubMax,CardMin) 4 new_setvar_5 +%% (GlbMin,GlbMax,Lub,CardMin) 4 new_setvar_8 +%% (Glb,Lub,CardMin,CardMax) 4 new_setvar_10 +new_setvar(SVar,Space,X1,X2,X3,X4) :- + assert_var(SVar), + assert_is_Space_or_Clause(Space,Space_), + assert_integer(X4), + (is_IntSet(X1,X1_) + -> (is_IntSet(X2,X2_) + -> + assert_integer(X3), + gecode_new_setvar_10(Idx,Space_,X1_,X2_,X3,X4) + ; + assert_integer(X2), + assert_integer(X3), + gecode_new_setvar_5(Idx,Space_,X1_,X2,X3,X4)) + ; + assert_integer(X1), + assert_integer(X2), + (is_IntSet(X3,X3_) + -> + gecode_new_setvar_8(Idx,Space_,X1,X2,X3_,X4) + ; + assert_integer(X3), + gecode_new_setvar_3(Idx,Space_,X1,X2,X3,X4))), + SVar='SetVar'(Idx,-1). + +%% 3 arguments +%% (Glb,LubMin,LubMax) 3 new_setvar_6 +%% (GlbMin,GlbMax,Lub) 3 new_setvar_9 +%% (Glb,Lub,CardMin) 3 new_setvar_11 +new_setvar(SVar,Space,X1,X2,X3) :- + assert_var(SVar), + assert_is_Space_or_Clause(Space,Space_), + (is_IntSet(X1,X1_) + -> (is_IntSet(X2,X2_) + -> + assert_integer(X3), + gecode_new_setvar_11(Idx,Space_,X1_,X2_,X3) + ; + assert_integer(X2), + assert_integer(X3), + gecode_new_setvar_6(Idx,Space_,X1_,X2,X3)) + ; + assert_integer(X1), + assert_integer(X2), + assert_is_IntSet(X3,X3_), + gecode_new_setvar_9(Idx,Space_,X1,X2,X3_)), + SVar='SetVar'(Idx,-1). + +%% 2 arguments +%% (Glb,Lub) 2 new_setvar_12 +new_setvar(SVar,Space,X1,X2) :- + assert_var(SVar), + assert_is_Space_or_Clause(Space,Space_), + assert_is_IntSet(X1,X1_), + assert_is_IntSet(X2,X2_), + gecode_new_setvar_12(Idx,Space_,X1_,X2_), + SVar='SetVar'(Idx,-1). + +new_tupleset( TupleSet, List ) :- + gecode_new_tupleset(List, TupleSet_), + TupleSet = 'TupleSet'(TupleSet_). + +new_dfa( DFA, S0, List, Finals ) :- + gecode_new_dfa(DFA_, S0, List, Finals), + DFA = 'DFA'(DFA_). + + +minimize(Space,IVar) :- + assert_is_Space(Space,Space_), + assert_is_IntVar(IVar,IVar_), + gecode_space_minimize(Space_,IVar_). +maximize(Space,IVar) :- + assert_is_Space(Space,Space_), + assert_is_IntVar(IVar,IVar_), + gecode_space_maximize(Space_,IVar_). +minimize(Space,IVar1,IVar2) :- + assert_is_Space(Space,Space_), + assert_is_IntVar(IVar1,IVar1_), + assert_is_IntVar(IVar2,IVar2_), + gecode_space_minimize_ratio(Space_,IVar1_,IVar2_). +maximize(Space,IVar1,IVar2) :- + assert_is_Space(Space,Space_), + assert_is_IntVar(IVar1,IVar1_), + assert_is_IntVar(IVar2,IVar2_), + gecode_space_maximize_ratio(Space_,IVar1_,IVar2_). + +reify(Space,BVar,Mode,R) :- + assert_is_Space(Space,Space_), + assert_is_BoolVar(BVar,BVar_), + assert_is_ReifyMode(Mode,Mode_), + assert_var(R), + gecode_new_reify(Space_,BVar_,Mode_,R_), + R = 'Reify'(R_). + +gecode_search_options_init(search_options(0,1.0,8,2,'RM_NONE',0,1,0)). +gecode_search_options_offset(restart,1). +gecode_search_options_offset(threads,2). +gecode_search_options_offset(c_d ,3). +gecode_search_options_offset(a_d ,4). +gecode_search_options_offset(cutoff, 5). +gecode_search_options_offset(nogoods_limit, 6). +gecode_search_options_offset(clone, 7). +gecode_search_options_offset(stop, 8). % unimplemented + +gecode_search_option_set(O,V,R) :- + gecode_search_options_offset(O,I), + setarg(I,R,V). + +gecode_search_options_from_alist(L,R) :- + gecode_search_options_init(R), + gecode_search_options_process_alist(L,R). + +gecode_search_options_process_alist([], _R). +gecode_search_options_process_alist([H|T], R) :- !, + gecode_search_options_process1(H, R), + gecode_search_options_process_alist(T, R). + +gecode_search_options_process1(restart,R) :- !, + gecode_search_option_set(restart,1,R). +gecode_search_options_process1(threads=N,R) :- !, + (integer(N) -> V is float(N) + ; (float(N) -> V=N + ; throw(bad_search_option_value(threads=N)))), + gecode_search_option_set(threads,V,R). +gecode_search_options_process1(c_d=N,R) :- !, + (integer(N) -> V=N + ; throw(bad_search_option_value(c_d=N))), + gecode_search_option_set(c_d,V,R). +gecode_search_options_process1(a_d=N,R) :- !, + (integer(N) -> V=N + ; throw(bad_search_option_value(a_d=N))), + gecode_search_option_set(a_d,V,R). +gecode_search_options_process1(cutoff=C,R) :- !, + (is_RestartMode(C,C_) -> V=C_ + ; throw(bad_search_option_value(cutoff=C))), + gecode_search_option_set(cutoff,V,R). +gecode_search_options_process1(nogoods_limit=N,R) :- !, + (integer(N), N >= 0 -> V=N + ; throw(bad_search_option_value(nogoods_limit=N))), + gecode_search_option_set(nogoods_limit,V,R). +gecode_search_options_process1(clone=N,R) :- !, + ((N == 0 ; N == 1)-> V=N + ; throw(bad_search_option_value(clone=N))), + gecode_search_option_set(clone,V,R). +gecode_search_options_process1(O,_) :- + throw(gecode_error(unrecognized_search_option(O))). + +search(Space, Solution) :- + search(Space, Solution, []). + +search(Space, Solution, Alist) :- + assert_is_Space(Space,Space_), + assert_var(Solution), + gecode_search_options_from_alist(Alist,O), + gecode_new_engine(Space_,Engine_,O), + gecode_engine_search(Engine_,Solution_), + Solution='Space'(Solution_). + + +%% INSPECTING VARIABLES + +get_for_vars([],_Space,[],_F). +get_for_vars([V|Vs],Space,[V2|V2s],F) :- + call_with_args(F,V,Space,V2), + get_for_vars(Vs,Space,V2s,F). + +get_assigned(Space, Var) :- + assert_is_Space(Space,Space_), + (is_IntVar(Var,Var_) + -> gecode_intvar_assigned(Space_,Var_) + ; is_BoolVar(Var,Var_) + -> gecode_boolvar_assigned(Space_,Var_) + ; is_FloatVar(Var,Var_) + -> gecode_floatvar_assigned(Space_,Var_) + ; is_SetVar(Var,Var_) + -> gecode_setvar_assigned(Space_,Var_) + ; throw(gecode_error(expected(variable)))). + +get_min(X, Space, Var) :- + assert_is_Space(Space,Space_), + (is_IntVar(Var,Var_) + -> gecode_intvar_min(X, Space_, Var_) + ; is_BoolVar(Var,Var_) + -> gecode_boolvar_min(X, Space_, Var_) + ; is_FloatVar(Var,Var_) + -> gecode_floatvar_min(X, Space_, Var_) + ; get_for_vars(X, Space, Var, gecode:get_min)). + +get_max(X, Space, Var) :- + assert_is_Space(Space,Space_), + (is_IntVar(Var,Var_) + -> gecode_intvar_max(X, Space_, Var_) + ; is_BoolVar(Var,Var_) + -> gecode_boolvar_max(X, Space_, Var_) + ; is_FloatVar(Var,Var_) + -> gecode_floatvar_max(X, Space_, Var_) + ; get_for_vars(X, Space, Var, gecode:get_max)). + +get_med(X, Space, Var) :- + assert_is_Space(Space,Space_), + (is_IntVar(Var,Var_) + -> gecode_intvar_med(X, Space_, Var_) + ; is_BoolVar(Var,Var_) + -> gecode_boolvar_med(X, Space_, Var_) + ; is_FloatVar(Var,Var_) + -> gecode_floatvar_med(X, Space_, Var_) + ; get_for_vars(X, Space, Var, gecode:get_med)). + +get_val(X, Space, Var) :- + assert_is_Space(Space,Space_), + (is_IntVar(Var,Var_) + -> gecode_intvar_val(X, Space_, Var_) + ; is_BoolVar(Var,Var_) + -> gecode_boolvar_val(X, Space_, Var_) + ; is_FloatVar(Var,Var_) + -> gecode_floatvar_val(X, Space_, Var_) + ; get_for_vars(X, Space, Var, gecode:get_val)). + +get_size(X, Space, Var) :- + assert_is_Space(Space,Space_), + (is_IntVar(Var,Var_) + -> gecode_intvar_size(X, Space_, Var_) + ; is_BoolVar(Var,Var_) + -> gecode_boolvar_size(X, Space_, Var_) + ; get_for_vars(X, Space, Var, gecode:get_size)). + +get_width(X, Space, Var) :- + assert_is_Space(Space,Space_), + (is_IntVar(Var,Var_) + -> gecode_intvar_width(X, Space_, Var_) + ; is_BoolVar(Var,Var_) + -> gecode_boolvar_width(X, Space_, Var_) + ; get_for_vars(X, Space, Var, gecode:get_width)). + +get_regret_min(X, Space, Var) :- + assert_is_Space(Space,Space_), + (is_IntVar(Var,Var_) + -> gecode_intvar_regret_min(X, Space_, Var_) + ; is_BoolVar(Var,Var_) + -> gecode_boolvar_regret_min(X, Space_, Var_) + ; get_for_vars(X, Space, Var, gecode:get_regret_min)). + +get_regret_max(X, Space, Var) :- + assert_is_Space(Space,Space_), + (is_IntVar(Var,Var_) + -> gecode_intvar_regret_max(X, Space_, Var_) + ; is_BoolVar(Var,Var_) + -> gecode_boolvar_regret_max(X, Space_, Var_) + ; get_for_vars(X, Space, Var, gecode:get_regret_max)). + +get_glbSize(X, Space, Var) :- + assert_is_Space(Space,Space_), + (is_SetVar(Var,Var_) + -> gecode_setvar_glbSize(X,Space_,Var_) + ; get_for_vars(X, Space, Var, gecode:get_glbSize)). + +get_lubSize(X, Space, Var) :- + assert_is_Space(Space,Space_), + (is_SetVar(Var,Var_) + -> gecode_setvar_lubSize(X,Space_,Var_) + ; get_for_vars(X, Space, Var, gecode:get_lubSize)). + +get_unknownSize(X, Space, Var) :- + assert_is_Space(Space,Space_), + (is_SetVar(Var,Var_) + -> gecode_setvar_unknownSize(X,Space_,Var_) + ; get_for_vars(X, Space, Var, gecode:get_unknownSize)). + +get_cardMin(X, Space, Var) :- + assert_is_Space(Space,Space_), + (is_SetVar(Var,Var_) + -> gecode_setvar_cardMin(X,Space_,Var_) + ; get_for_vars(X, Space, Var, gecode:get_cardMin)). + +get_cardMax(X, Space, Var) :- + assert_is_Space(Space,Space_), + (is_SetVar(Var,Var_) + -> gecode_setvar_cardMax(X,Space_,Var_) + ; get_for_vars(X, Space, Var, gecode:get_cardMax)). + +get_lubMin(X, Space, Var) :- + assert_is_Space(Space,Space_), + (is_SetVar(Var,Var_) + -> gecode_setvar_lubMin(X,Space_,Var_) + ; get_for_vars(X, Space, Var, gecode:get_lubMin)). + +get_lubMax(X, Space, Var) :- + assert_is_Space(Space,Space_), + (is_SetVar(Var,Var_) + -> gecode_setvar_lubMax(X,Space_,Var_) + ; get_for_vars(X, Space, Var, gecode:get_lubMax)). + +get_glbMin(X, Space, Var) :- + assert_is_Space(Space,Space_), + (is_SetVar(Var,Var_) + -> gecode_setvar_glbMin(X,Space_,Var_) + ; get_for_vars(X, Space, Var, gecode:get_glbMin)). + +get_glbMax(X, Space, Var) :- + assert_is_Space(Space,Space_), + (is_SetVar(Var,Var_) + -> gecode_setvar_glbMax(X,Space_,Var_) + ; get_for_vars(X, Space, Var, gecode:get_glbMax)). + +get_glb_ranges(X, Space, Var) :- + assert_is_Space(Space,Space_), + (is_SetVar(Var,Var_) + -> gecode_setvar_glb_ranges(X,Space_,Var_) + ; get_for_vars(X,Space,Var,gecode:get_glb_ranges)). + +get_lub_ranges(X, Space, Var) :- + assert_is_Space(Space,Space_), + (is_SetVar(Var,Var_) + -> gecode_setvar_lub_ranges(X,Space_,Var_) + ; get_for_vars(X,Space,Var,gecode:get_lub_ranges)). + +get_unknown_ranges(X, Space, Var) :- + assert_is_Space(Space,Space_), + (is_SetVar(Var,Var_) + -> gecode_setvar_unknown_ranges(X,Space_,Var_) + ; get_for_vars(X,Space,Var,gecode:get_unknown_ranges)). + +get_glb_values(X, Space, Var) :- + assert_is_Space(Space,Space_), + (is_SetVar(Var,Var_) + -> gecode_setvar_glb_values(X,Space_,Var_) + ; get_for_vars(X,Space,Var,gecode:get_glb_values)). + +get_lub_values(X, Space, Var) :- + assert_is_Space(Space,Space_), + (is_SetVar(Var,Var_) + -> gecode_setvar_lub_values(X,Space_,Var_) + ; get_for_vars(X,Space,Var,gecode:get_lub_values)). + +get_unknown_values(X, Space, Var) :- + assert_is_Space(Space,Space_), + (is_SetVar(Var,Var_) + -> gecode_setvar_unknown_values(X,Space_,Var_) + ; get_for_vars(X,Space,Var,gecode:get_unknown_values)). + +get_ranges(X, Space, Var) :- + assert_is_Space(Space,Space_), + (is_IntVar(Var,Var_) + -> gecode_intvar_ranges(X,Space_,Var_) + ; get_for_vars(X,Space,Var,gecode:get_ranges)). + +get_values(X, Space, Var) :- + assert_is_Space(Space,Space_), + (is_IntVar(Var,Var_) + -> gecode_intvar_values(X,Space_,Var_) + ; get_for_vars(X,Space,Var,gecode:get_values)). + +new_disjunctor(X, Space) :- + assert_is_Space(Space,Space_), + gecode_new_disjunctor(D,Space_), + X='Disjunctor'(D). + +is_Disjunctor_('Disjunctor'(D),D). +is_Disjunctor(X,Y) :- nonvar(X), is_Disjunctor_(X,Y). +is_Disjunctor(X) :- is_Disjunctor(X,_). + +assert_is_Disjunctor(X,Y) :- + is_Disjunctor(X,Y) -> true ; throw(gecode_error(expected(disjunctor))). + +new_clause(X, Disj) :- + assert_is_Disjunctor(Disj,Disj_), + gecode_new_clause(C, Disj_), + X='Clause'(C). + +is_Clause_('Clause'(C),C) :- + gecode_space_use_keep_index(C,B), + nb_setval(gecode_space_use_keep_index,B). +is_Clause(X,Y) :- nonvar(X), is_Clause_(X,Y). +is_Clause(X) :- is_Clause(X,_). + +assert_is_Clause(X,Y) :- + is_Clause(X,Y) -> true ; throw(gecode_error(expected(clause))). + +is_Space_or_Clause(X,Y) :- + (is_Space(X,Y);is_Clause(X,Y)), !. +assert_is_Space_or_Clause(X,Y) :- + is_Space_or_Clause(X,Y) -> true + ; throw(gecode_error(expected(space,clause))). + +new_forward(Clause, X, Y) :- + assert_is_Clause(Clause, Clause_), + (is_IntVar(X,X_) + -> (is_IntVar(Y,Y_) + -> gecode_clause_intvar_forward(Clause_,X_,Y_) + ; throw(gecode_error(forward))) + ; (is_BoolVar(X,X_) + -> (is_BoolVar(Y,Y_) + -> gecode_clause_boolvar_forward(Clause_,X_,Y_) + ; throw(gecode_error(forward))) + ; (is_SetVar(X,X_) + -> (is_SetVar(Y,Y_) + -> gecode_clause_setvar_forward(Clause_,X_,Y_) + ; throw(gecode_error(forward))) + ; (X=[] + -> Y=[] + ;(X=[H1|T1],Y=[H2|T2]) + -> (new_forward(Clause,H1,H2), + new_forward(Clause,T1,T2)) + ; throw(gecode_error(forward)))))). + +new_intvars_(L,Space,N,I,J) :- length(L,N), new_intvars(L,Space,I,J). +new_intvars_(L,Space,N,IntSet) :- length(L,N), new_intvars(L,Space,IntSet). +new_boolvars_(L,Space,N) :- length(L,N), new_boolvars(L,Space). +new_setvars_(L,Space,N,X1,X2,X3,X4,X5,X6) :- length(L,N), new_setvars(L,Space,X1,X2,X3,X4,X5,X6). +new_setvars_(L,Space,N,X1,X2,X3,X4,X5) :- length(L,N), new_setvars(L,Space,X1,X2,X3,X4,X5). +new_setvars_(L,Space,N,X1,X2,X3,X4) :- length(L,N), new_setvars(L,Space,X1,X2,X3,X4). +new_setvars_(L,Space,N,X1,X2,X3) :- length(L,N), new_setvars(L,Space,X1,X2,X3). +new_setvars_(L,Space,N,X1,X2) :- length(L,N), new_setvars(L,Space,X1,X2). + +keep_(Space, Var) :- + (Var = 'IntVar'(I,J) + -> (J = -1 -> (gecode_intvar_keep(Space,I,K),setarg(2,Var,K)) + ; throw(gecode_error(variable_already_kept(Var)))) + ; (Var = 'BoolVar'(I,J) + -> (J = -1 -> (gecode_boolvar_keep(Space,I,K),setarg(2,Var,K)) + ; throw(gecode_error(variable_already_kept(Var)))) + ; (Var = 'SetVar'(I,J) + -> (J = -1 -> (gecode_setvar_keep(Space,I,K),setarg(2,Var,K)) + ; throw(gecode_error(variable_already_kept(Var)))) + ; keep_list_(Space,Var)))). + +keep_list_(_Space, []) :- !. +keep_list_(Space, [H|T]) :- !, + keep_(Space,H), keep_list_(Space,T). +keep_list_(_, X) :- + throw(gecode_error(not_a_variable(X))). + +%% more concise interface: +(X := Y) :- var(Y), !, throw(gecode_error((X := Y))). +(X := intset(I,J)) :- !, new_intset(X,I,J). +(X := intset(L)) :- !, new_intset(X,L). +(X := space) :- !, new_space(X). +(X := intvar(Space,I,J)) :- !, new_intvar(X,Space,I,J). +(X := intvar(Space,IntSet)) :- !, new_intvar(X,Space,IntSet). +(X := boolvar(Space)) :- !, new_boolvar(X,Space). +(X := setvar(Space,X1,X2,X3,X4,X5,X6)) :- !, new_setvar(X,Space,X1,X2,X3,X4,X5,X6). +(X := setvar(Space,X1,X2,X3,X4,X5)) :- !, new_setvar(X,Space,X1,X2,X3,X4,X5). +(X := setvar(Space,X1,X2,X3,X4)) :- !, new_setvar(X,Space,X1,X2,X3,X4). +(X := setvar(Space,X1,X2,X3)) :- !, new_setvar(X,Space,X1,X2,X3). +(X := setvar(Space,X1,X2)) :- !, new_setvar(X,Space,X1,X2). +(X := intvars(Space,N,I,J)) :- !, new_intvars_(X,Space,N,I,J). +(X := intvars(Space,N,IntSet)) :- !, new_intvars_(X,Space,N,IntSet). +(X := boolvars(Space,N)) :- !, new_boolvars_(X,Space,N). +(X := setvars(Space,N,X1,X2,X3,X4,X5,X6)) :- !, new_setvars_(X,Space,N,X1,X2,X3,X4,X5,X6). +(X := setvars(Space,N,X1,X2,X3,X4,X5)) :- !, new_setvars_(X,Space,N,X1,X2,X3,X4,X5). +(X := setvars(Space,N,X1,X2,X3,X4)) :- !, new_setvars_(X,Space,N,X1,X2,X3,X4). +(X := setvars(Space,N,X1,X2,X3)) :- !, new_setvars_(X,Space,N,X1,X2,X3). +(X := setvars(Space,N,X1,X2)) :- !, new_setvars_(X,Space,N,X1,X2). +(X := tupleset(Set)) :- !, new_tupleset(X, Set). +(X := dfa(S0, Transitions, Finals)) :- !, new_dfa(X, S0, Transitions, Finals). + +(X := min(Space,Var)) :- !, get_min(X,Space,Var). +(X := max(Space,Var)) :- !, get_max(X,Space,Var). +(X := med(Space,Var)) :- !, get_med(X,Space,Var). +(X := val(Space,Var)) :- !, get_val(X,Space,Var). +(X := size(Space,Var)) :- !, get_size(X,Space,Var). +(X := width(Space,Var)) :- !, get_width(X,Space,Var). +(X := regret_min(Space,Var)) :- !, get_regret_min(X,Space,Var). +(X := regret_max(Space,Var)) :- !, get_regret_max(X,Space,Var). +(X := ranges(Space,Var)) :- !, get_ranges(X,Space,Var). +(X := values(Space,Var)) :- !, get_values(X,Space,Var). + +(X := glbSize(Space,Var)) :- !, get_glbSize(X,Space,Var). +(X := lubSize(Space,Var)) :- !, get_lubSize(X,Space,Var). +(X := unknownSize(Space,Var)) :- !, get_unknownSize(X,Space,Var). +(X := cardMin(Space,Var)) :- !, get_cardMin(X,Space,Var). +(X := cardMax(Space,Var)) :- !, get_cardMax(X,Space,Var). +(X := lubMin(Space,Var)) :- !, get_lubMin(X,Space,Var). +(X := lubMax(Space,Var)) :- !, get_lubMax(X,Space,Var). +(X := glbMin(Space,Var)) :- !, get_glbMin(X,Space,Var). +(X := glbMax(Space,Var)) :- !, get_glbMax(X,Space,Var). +(X := glb_ranges(Space,Var)) :- !, get_glb_ranges(X,Space,Var). +(X := lub_ranges(Space,Var)) :- !, get_lub_ranges(X,Space,Var). +(X := unknown_ranges(Space,Var)) :- !, get_unknown_ranges(X,Space,Var). +(X := glb_values(Space,Var)) :- !, get_glb_values(X,Space,Var). +(X := lub_values(Space,Var)) :- !, get_lub_values(X,Space,Var). +(X := unknown_values(Space,Var)) :- !, get_unknown_values(X,Space,Var). + +(X := disjunctor(Space)) :- !, new_disjunctor(X,Space). +(X := clause(Disj)) :- !, new_clause(X,Disj). + +(X := search(Y)) :- !, search(Y,X). +(X := search(Y,L)) :- !, search(Y,X,L). + +% these should be autogenerated: +(C += forward(X,Y)) :- !, new_forward(C,X,Y). +(Space += abs(X1,X2)) :- !, abs(Space,X1,X2). +(Space += abs(X1,X2,X3)) :- !, abs(Space,X1,X2,X3). +(Space += assign(X1,X2)) :- !, assign(Space,X1,X2). +(Space += atmostOne(X1,X2)) :- !, atmostOne(Space,X1,X2). +(Space += binpacking(X1,X2,X3)) :- !, binpacking(Space,X1,X2,X3). +(Space += binpacking(X1,X2,X3,X4)) :- !, binpacking(Space,X1,X2,X3,X4). +(Space += branch(X1,X2)) :- !, branch(Space,X1,X2). +(Space += branch(X1,X2,X3)) :- !, branch(Space,X1,X2,X3). +(Space += cardinality(X1,X2)) :- !, cardinality(Space,X1,X2). +(Space += cardinality(X1,X2,X3)) :- !, cardinality(Space,X1,X2,X3). +(Space += channel(X1,X2)) :- !, channel(Space,X1,X2). +(Space += channel(X1,X2,X3)) :- !, channel(Space,X1,X2,X3). +(Space += channel(X1,X2,X3,X4)) :- !, channel(Space,X1,X2,X3,X4). +(Space += channel(X1,X2,X3,X4,X5)) :- !, channel(Space,X1,X2,X3,X4,X5). +(Space += channelSorted(X1,X2)) :- !, channelSorted(Space,X1,X2). +(Space += circuit(X1)) :- !, circuit(Space,X1). +(Space += circuit(X1,X2)) :- !, circuit(Space,X1,X2). +(Space += circuit(X1,X2,X3)) :- !, circuit(Space,X1,X2,X3). +(Space += circuit(X1,X2,X3,X4)) :- !, circuit(Space,X1,X2,X3,X4). +(Space += circuit(X1,X2,X3,X4,X5)) :- !, circuit(Space,X1,X2,X3,X4,X5). +(Space += circuit(X1,X2,X3,X4,X5,X6)) :- !, circuit(Space,X1,X2,X3,X4,X5,X6). +(Space += clause(X1,X2,X3,X4)) :- !, clause(Space,X1,X2,X3,X4). +(Space += clause(X1,X2,X3,X4,X5)) :- !, clause(Space,X1,X2,X3,X4,X5). +(Space += convex(X1)) :- !, convex(Space,X1). +(Space += convex(X1,X2)) :- !, convex(Space,X1,X2). +(Space += count(X1,X2)) :- !, count(Space,X1,X2). +(Space += count(X1,X2,X3)) :- !, count(Space,X1,X2,X3). +(Space += count(X1,X2,X3,X4)) :- !, count(Space,X1,X2,X3,X4). +(Space += count(X1,X2,X3,X4,X5)) :- !, count(Space,X1,X2,X3,X4,X5). +(Space += cumulative(X1,X2,X3,X4)) :- !, cumulative(Space,X1,X2,X3,X4). +(Space += cumulative(X1,X2,X3,X4,X5)) :- !, cumulative(Space,X1,X2,X3,X4,X5). +(Space += cumulative(X1,X2,X3,X4,X5,X6)) :- !, cumulative(Space,X1,X2,X3,X4,X5,X6). +(Space += cumulative(X1,X2,X3,X4,X5,X6,X7)) :- !, cumulative(Space,X1,X2,X3,X4,X5,X6,X7). +(Space += cumulatives(X1,X2,X3,X4,X5,X6,X7)) :- !, cumulatives(Space,X1,X2,X3,X4,X5,X6,X7). +(Space += cumulatives(X1,X2,X3,X4,X5,X6,X7,X8)) :- !, cumulatives(Space,X1,X2,X3,X4,X5,X6,X7,X8). +(Space += distinct(X1)) :- !, distinct(Space,X1). +(Space += distinct(X1,X2)) :- !, distinct(Space,X1,X2). +(Space += distinct(X1,X2,X3)) :- !, distinct(Space,X1,X2,X3). +(Space += div(X1,X2,X3)) :- !, div(Space,X1,X2,X3). +(Space += div(X1,X2,X3,X4)) :- !, div(Space,X1,X2,X3,X4). +(Space += divmod(X1,X2,X3,X4)) :- !, divmod(Space,X1,X2,X3,X4). +(Space += divmod(X1,X2,X3,X4,X5)) :- !, divmod(Space,X1,X2,X3,X4,X5). +(Space += dom(X1,X2)) :- !, dom(Space,X1,X2). +(Space += dom(X1,X2,X3)) :- !, dom(Space,X1,X2,X3). +(Space += dom(X1,X2,X3,X4)) :- !, dom(Space,X1,X2,X3,X4). +(Space += dom(X1,X2,X3,X4,X5)) :- !, dom(Space,X1,X2,X3,X4,X5). +(Space += element(X1,X2,X3)) :- !, element(Space,X1,X2,X3). +(Space += element(X1,X2,X3,X4)) :- !, element(Space,X1,X2,X3,X4). +(Space += element(X1,X2,X3,X4,X5)) :- !, element(Space,X1,X2,X3,X4,X5). +(Space += element(X1,X2,X3,X4,X5,X6)) :- !, element(Space,X1,X2,X3,X4,X5,X6). +(Space += element(X1,X2,X3,X4,X5,X6,X7)) :- !, element(Space,X1,X2,X3,X4,X5,X6,X7). +(Space += extensional(X1,X2)) :- !, extensional(Space,X1,X2). +(Space += extensional(X1,X2,X3)) :- !, extensional(Space,X1,X2,X3). +(Space += linear(X1,X2,X3)) :- !, linear(Space,X1,X2,X3). +(Space += linear(X1,X2,X3,X4)) :- !, linear(Space,X1,X2,X3,X4). +(Space += linear(X1,X2,X3,X4,X5)) :- !, linear(Space,X1,X2,X3,X4,X5). +(Space += linear(X1,X2,X3,X4,X5,X6)) :- !, linear(Space,X1,X2,X3,X4,X5,X6). +(Space += max(X1,X2)) :- !, max(Space,X1,X2). +(Space += max(X1,X2,X3)) :- !, max(Space,X1,X2,X3). +(Space += max(X1,X2,X3,X4)) :- !, max(Space,X1,X2,X3,X4). +(Space += min(X1,X2)) :- !, min(Space,X1,X2). +(Space += min(X1,X2,X3)) :- !, min(Space,X1,X2,X3). +(Space += min(X1,X2,X3,X4)) :- !, min(Space,X1,X2,X3,X4). +(Space += mod(X1,X2,X3)) :- !, mod(Space,X1,X2,X3). +(Space += mod(X1,X2,X3,X4)) :- !, mod(Space,X1,X2,X3,X4). +(Space += mult(X1,X2,X3)) :- !, mult(Space,X1,X2,X3). +(Space += mult(X1,X2,X3,X4)) :- !, mult(Space,X1,X2,X3,X4). +(Space += nooverlap(X1,X2,X3,X4)) :- !, nooverlap(Space,X1,X2,X3,X4). +(Space += nooverlap(X1,X2,X3,X4,X5)) :- !, nooverlap(Space,X1,X2,X3,X4,X5). +(Space += nooverlap(X1,X2,X3,X4,X5,X6)) :- !, nooverlap(Space,X1,X2,X3,X4,X5,X6). +(Space += nooverlap(X1,X2,X3,X4,X5,X6,X7)) :- !, nooverlap(Space,X1,X2,X3,X4,X5,X6,X7). +(Space += nooverlap(X1,X2,X3,X4,X5,X6,X7,X8)) :- !, nooverlap(Space,X1,X2,X3,X4,X5,X6,X7,X8). +(Space += notMax(X1,X2)) :- !, notMax(Space,X1,X2). +(Space += notMin(X1,X2)) :- !, notMin(Space,X1,X2). +(Space += path(X1,X2,X3)) :- !, path(Space,X1,X2,X3). +(Space += path(X1,X2,X3,X4)) :- !, path(Space,X1,X2,X3,X4). +(Space += path(X1,X2,X3,X4,X5)) :- !, path(Space,X1,X2,X3,X4,X5). +(Space += path(X1,X2,X3,X4,X5,X6)) :- !, path(Space,X1,X2,X3,X4,X5,X6). +(Space += path(X1,X2,X3,X4,X5,X6,X7)) :- !, path(Space,X1,X2,X3,X4,X5,X6,X7). +(Space += path(X1,X2,X3,X4,X5,X6,X7,X8)) :- !, path(Space,X1,X2,X3,X4,X5,X6,X7,X8). +(Space += precede(X1,X2)) :- !, precede(Space,X1,X2). +(Space += precede(X1,X2,X3)) :- !, precede(Space,X1,X2,X3). +(Space += precede(X1,X2,X3,X4)) :- !, precede(Space,X1,X2,X3,X4). +(Space += reify(X1,X2,X3)) :- !, reify(Space,X1,X2,X3). +(Space += rel(X1,X2)) :- !, rel(Space,X1,X2). +(Space += rel(X1,X2,X3)) :- !, rel(Space,X1,X2,X3). +(Space += rel(X1,X2,X3,X4)) :- !, rel(Space,X1,X2,X3,X4). +(Space += rel(X1,X2,X3,X4,X5)) :- !, rel(Space,X1,X2,X3,X4,X5). +(Space += rel(X1,X2,X3,X4,X5,X6)) :- !, rel(Space,X1,X2,X3,X4,X5,X6). +(Space += sequence(X1)) :- !, sequence(Space,X1). +(Space += sequence(X1,X2)) :- !, sequence(Space,X1,X2). +(Space += sequence(X1,X2,X3,X4,X5)) :- !, sequence(Space,X1,X2,X3,X4,X5). +(Space += sequence(X1,X2,X3,X4,X5,X6)) :- !, sequence(Space,X1,X2,X3,X4,X5,X6). +(Space += sorted(X1,X2)) :- !, sorted(Space,X1,X2). +(Space += sorted(X1,X2,X3)) :- !, sorted(Space,X1,X2,X3). +(Space += sorted(X1,X2,X3,X4)) :- !, sorted(Space,X1,X2,X3,X4). +(Space += sqr(X0,X1,X2,X3)) :- !, sqr(Space,X0,X1,X2,X3). +(Space += sqr(X1,X2)) :- !, sqr(Space,X1,X2). +(Space += sqrt(X1,X2)) :- !, sqrt(Space,X1,X2). +(Space += sqrt(X1,X2,X3)) :- !, sqrt(Space,X1,X2,X3). +(Space += unary(X1,X2)) :- !, unary(Space,X1,X2). +(Space += unary(X1,X2,X3)) :- !, unary(Space,X1,X2,X3). +(Space += unary(X1,X2,X3,X4)) :- !, unary(Space,X1,X2,X3,X4). +(Space += unary(X1,X2,X3,X4,X5)) :- !, unary(Space,X1,X2,X3,X4,X5). +(Space += unshare(X1)) :- !, unshare(Space,X1). +(Space += unshare(X1,X2)) :- !, unshare(Space,X1,X2). +(Space += weights(X1,X2,X3,X4)) :- !; weights(Space,X1,X2,X3,X4). + +(Space += minimize(X)) :- !, minimize(Space,X). +(Space += maximize(X)) :- !, maximize(Space,X). +(Space += minimize(X,Y)) :- !, minimize(Space,X,Y). +(Space += maximize(X,Y)) :- !, maximize(Space,X,Y). + +(Space += keep(X)) :- !, keep_(Space,X). +%% -*- prolog -*- +%%============================================================================= +%% Copyright (C) 2011 by Denys Duchier +%% +%% This program is free software: you can redistribute it and/or modify it +%% under the terms of the GNU Lesser General Public License as published by the +%% Free Software Foundation, either version 3 of the License, or (at your +%% option) any later version. +%% +%% This program is distributed in the hope that it will be useful, but WITHOUT +%% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +%% FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +%% more details. +%% +%% You should have received a copy of the GNU Lesser General Public License +%% along with this program. If not, see . +%%============================================================================= + +is_RestartMode_('RM_NONE'). +is_RestartMode_('RM_CONSTANT'). +is_RestartMode_('RM_LINEAR'). +is_RestartMode_('RM_LUBY'). +is_RestartMode_('RM_GEOMETRIC'). + +is_RestartMode_('RM_NONE','RM_NONE'). +is_RestartMode_('RM_CONSTANT','RM_CONSTANT'). +is_RestartMode_('RM_LINEAR','RM_LINEAR'). +is_RestartMode_('RM_LUBY','RM_LUBY'). +is_RestartMode_('RM_GEOMETRIC','RM_GEOMETRIC'). + +is_RestartMode(X,Y) :- nonvar(X), is_RestartMode_(X,Y). +is_RestartMode(X) :- is_RestartMode(X,_). + +is_FloatRelType_('FRT_EQ'). +is_FloatRelType_('FRT_NQ'). +is_FloatRelType_('FRT_LQ'). +is_FloatRelType_('FRT_LE'). +is_FloatRelType_('FRT_GQ'). +is_FloatRelType_('FRT_GR'). + +is_FloatRelType_('FRT_EQ','FRT_EQ'). +is_FloatRelType_('FRT_NQ','FRT_NQ'). +is_FloatRelType_('FRT_LQ','FRT_LQ'). +is_FloatRelType_('FRT_LE','FRT_LE'). +is_FloatRelType_('FRT_GQ','FRT_GQ'). +is_FloatRelType_('FRT_GR','FRT_GR'). + +is_FloatRelType(X,Y) :- nonvar(X), is_FloatRelType_(X,Y). +is_FloatRelType(X) :- is_FloatRelType(X,_). + +is_ReifyMode_('RM_EQV'). +is_ReifyMode_('RM_IMP'). +is_ReifyMode_('RM_PMI'). + +is_ReifyMode_('RM_EQV','RM_EQV'). +is_ReifyMode_('RM_IMP','RM_IMP'). +is_ReifyMode_('RM_PMI','RM_PMI'). + +is_ReifyMode(X,Y) :- nonvar(X), is_ReifyMode_(X,Y). +is_ReifyMode(X) :- is_ReifyMode(X,_). + +is_IntRelType_('IRT_EQ'). +is_IntRelType_('IRT_NQ'). +is_IntRelType_('IRT_LQ'). +is_IntRelType_('IRT_LE'). +is_IntRelType_('IRT_GQ'). +is_IntRelType_('IRT_GR'). + +is_IntRelType_('IRT_EQ','IRT_EQ'). +is_IntRelType_('IRT_NQ','IRT_NQ'). +is_IntRelType_('IRT_LQ','IRT_LQ'). +is_IntRelType_('IRT_LE','IRT_LE'). +is_IntRelType_('IRT_GQ','IRT_GQ'). +is_IntRelType_('IRT_GR','IRT_GR'). + +is_IntRelType(X,Y) :- nonvar(X), is_IntRelType_(X,Y). +is_IntRelType(X) :- is_IntRelType(X,_). + +is_BoolOpType_('BOT_AND'). +is_BoolOpType_('BOT_OR'). +is_BoolOpType_('BOT_IMP'). +is_BoolOpType_('BOT_EQV'). +is_BoolOpType_('BOT_XOR'). + +is_BoolOpType_('BOT_AND','BOT_AND'). +is_BoolOpType_('BOT_OR','BOT_OR'). +is_BoolOpType_('BOT_IMP','BOT_IMP'). +is_BoolOpType_('BOT_EQV','BOT_EQV'). +is_BoolOpType_('BOT_XOR','BOT_XOR'). + +is_BoolOpType(X,Y) :- nonvar(X), is_BoolOpType_(X,Y). +is_BoolOpType(X) :- is_BoolOpType(X,_). + +is_IntConLevel_('ICL_VAL'). +is_IntConLevel_('ICL_BND'). +is_IntConLevel_('ICL_DOM'). +is_IntConLevel_('ICL_DEF'). + +is_IntConLevel_('ICL_VAL','ICL_VAL'). +is_IntConLevel_('ICL_BND','ICL_BND'). +is_IntConLevel_('ICL_DOM','ICL_DOM'). +is_IntConLevel_('ICL_DEF','ICL_DEF'). + +is_IntConLevel(X,Y) :- nonvar(X), is_IntConLevel_(X,Y). +is_IntConLevel(X) :- is_IntConLevel(X,_). + +is_TaskType_('TT_FIXP'). +is_TaskType_('TT_FIXS'). +is_TaskType_('TT_FIXE'). + +is_TaskType_('TT_FIXP','TT_FIXP'). +is_TaskType_('TT_FIXS','TT_FIXS'). +is_TaskType_('TT_FIXE','TT_FIXE'). + +is_TaskType(X,Y) :- nonvar(X), is_TaskType_(X,Y). +is_TaskType(X) :- is_TaskType(X,_). + +is_ExtensionalPropKind_('EPK_DEF'). +is_ExtensionalPropKind_('EPK_SPEED'). +is_ExtensionalPropKind_('EPK_MEMORY'). + +is_ExtensionalPropKind_('EPK_DEF','EPK_DEF'). +is_ExtensionalPropKind_('EPK_SPEED','EPK_SPEED'). +is_ExtensionalPropKind_('EPK_MEMORY','EPK_MEMORY'). + +is_ExtensionalPropKind(X,Y) :- nonvar(X), is_ExtensionalPropKind_(X,Y). +is_ExtensionalPropKind(X) :- is_ExtensionalPropKind(X,_). + +is_SetRelType_('SRT_EQ'). +is_SetRelType_('SRT_NQ'). +is_SetRelType_('SRT_SUB'). +is_SetRelType_('SRT_SUP'). +is_SetRelType_('SRT_DISJ'). +is_SetRelType_('SRT_CMPL'). +is_SetRelType_('SRT_LQ'). +is_SetRelType_('SRT_LE'). +is_SetRelType_('SRT_GQ'). +is_SetRelType_('SRT_GR'). + +is_SetRelType_('SRT_EQ','SRT_EQ'). +is_SetRelType_('SRT_NQ','SRT_NQ'). +is_SetRelType_('SRT_SUB','SRT_SUB'). +is_SetRelType_('SRT_SUP','SRT_SUP'). +is_SetRelType_('SRT_DISJ','SRT_DISJ'). +is_SetRelType_('SRT_CMPL','SRT_CMPL'). +is_SetRelType_('SRT_LQ','SRT_LQ'). +is_SetRelType_('SRT_LE','SRT_LE'). +is_SetRelType_('SRT_GQ','SRT_GQ'). +is_SetRelType_('SRT_GR','SRT_GR'). + +is_SetRelType(X,Y) :- nonvar(X), is_SetRelType_(X,Y). +is_SetRelType(X) :- is_SetRelType(X,_). + +is_SetOpType_('SOT_UNION'). +is_SetOpType_('SOT_DUNION'). +is_SetOpType_('SOT_INTER'). +is_SetOpType_('SOT_MINUS'). + +is_SetOpType_('SOT_UNION','SOT_UNION'). +is_SetOpType_('SOT_DUNION','SOT_DUNION'). +is_SetOpType_('SOT_INTER','SOT_INTER'). +is_SetOpType_('SOT_MINUS','SOT_MINUS'). + +is_SetOpType(X,Y) :- nonvar(X), is_SetOpType_(X,Y). +is_SetOpType(X) :- is_SetOpType(X,_). + +unary(X0,X1,X2,X3,X4,X5) :- + (is_Space_or_Clause(X0,Y0) + -> (is_TaskTypeArgs(X1,Y1) + -> (is_IntVarArgs(X2,Y2) + -> (is_IntArgs(X3,Y3) + -> (is_BoolVarArgs(X4,Y4) + -> (is_IntConLevel(X5,Y5) + -> gecode_constraint_unary_458(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(unary(X0,X1,X2,X3,X4,X5),arg=6))) + ; throw(gecode_argument_error(unary(X0,X1,X2,X3,X4,X5),arg=5))) + ; throw(gecode_argument_error(unary(X0,X1,X2,X3,X4,X5),arg=4))) + ; throw(gecode_argument_error(unary(X0,X1,X2,X3,X4,X5),arg=3))) + ; (is_IntVarArgs(X1,Y1) + -> (is_IntVarArgs(X2,Y2) + -> (is_IntVarArgs(X3,Y3) + -> (is_BoolVarArgs(X4,Y4) + -> (is_IntConLevel(X5,Y5) + -> gecode_constraint_unary_454(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(unary(X0,X1,X2,X3,X4,X5),arg=6))) + ; throw(gecode_argument_error(unary(X0,X1,X2,X3,X4,X5),arg=5))) + ; throw(gecode_argument_error(unary(X0,X1,X2,X3,X4,X5),arg=4))) + ; throw(gecode_argument_error(unary(X0,X1,X2,X3,X4,X5),arg=3))) + ; throw(gecode_argument_error(unary(X0,X1,X2,X3,X4,X5),arg=2)))) + ; throw(gecode_argument_error(unary(X0,X1,X2,X3,X4,X5),arg=1))). + +nvalues(X0,X1,X2,X3,X4) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> (is_IntRelType(X2,Y2) + -> (is_int(X3,Y3) + -> (is_IntConLevel(X4,Y4) + -> gecode_constraint_nvalues_345(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(nvalues(X0,X1,X2,X3,X4),arg=5))) + ; (is_IntVar(X3,Y3) + -> (is_IntConLevel(X4,Y4) + -> gecode_constraint_nvalues_347(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(nvalues(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(nvalues(X0,X1,X2,X3,X4),arg=4)))) + ; throw(gecode_argument_error(nvalues(X0,X1,X2,X3,X4),arg=3))) + ; (is_BoolVarArgs(X1,Y1) + -> (is_IntRelType(X2,Y2) + -> (is_int(X3,Y3) + -> (is_IntConLevel(X4,Y4) + -> gecode_constraint_nvalues_341(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(nvalues(X0,X1,X2,X3,X4),arg=5))) + ; (is_IntVar(X3,Y3) + -> (is_IntConLevel(X4,Y4) + -> gecode_constraint_nvalues_343(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(nvalues(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(nvalues(X0,X1,X2,X3,X4),arg=4)))) + ; throw(gecode_argument_error(nvalues(X0,X1,X2,X3,X4),arg=3))) + ; throw(gecode_argument_error(nvalues(X0,X1,X2,X3,X4),arg=2)))) + ; throw(gecode_argument_error(nvalues(X0,X1,X2,X3,X4),arg=1))). + +max(X0,X1,X2,X3) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVar(X1,Y1) + -> (is_IntVar(X2,Y2) + -> (is_IntVar(X3,Y3) + -> gecode_constraint_max_302(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(max(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(max(X0,X1,X2,X3),arg=3))) + ; (is_IntVarArgs(X1,Y1) + -> (is_IntVar(X2,Y2) + -> (is_IntConLevel(X3,Y3) + -> gecode_constraint_max_300(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(max(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(max(X0,X1,X2,X3),arg=3))) + ; (is_FloatVar(X1,Y1) + -> (is_FloatVar(X2,Y2) + -> (is_FloatVar(X3,Y3) + -> gecode_constraint_max_301(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(max(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(max(X0,X1,X2,X3),arg=3))) + ; (is_SetVar(X1,Y1) + -> (is_IntVar(X2,Y2) + -> (is_Reify(X3,Y3) + -> gecode_constraint_max_305(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(max(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(max(X0,X1,X2,X3),arg=3))) + ; throw(gecode_argument_error(max(X0,X1,X2,X3),arg=2)))))) + ; throw(gecode_argument_error(max(X0,X1,X2,X3),arg=1))). + +dom(X0,X1,X2,X3,X4,X5) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVar(X1,Y1) + -> (is_int(X2,Y2) + -> (is_int(X3,Y3) + -> (is_Reify(X4,Y4) + -> (is_IntConLevel(X5,Y5) + -> gecode_constraint_dom_200(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3,X4,X5),arg=6))) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3,X4,X5),arg=5))) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3,X4,X5),arg=4))) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3,X4,X5),arg=3))) + ; (is_SetVar(X1,Y1) + -> (is_SetRelType(X2,Y2) + -> (is_int(X3,Y3) + -> (is_int(X4,Y4) + -> (is_Reify(X5,Y5) + -> gecode_constraint_dom_209(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3,X4,X5),arg=6))) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3,X4,X5),arg=5))) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3,X4,X5),arg=4))) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3,X4,X5),arg=3))) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3,X4,X5),arg=2)))) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3,X4,X5),arg=1))). + +convex(X0,X1,X2) :- + (is_Space_or_Clause(X0,Y0) + -> (is_SetVar(X1,Y1) + -> (is_SetVar(X2,Y2) + -> gecode_constraint_convex_91(Y0,Y1,Y2) + ; throw(gecode_argument_error(convex(X0,X1,X2),arg=3))) + ; throw(gecode_argument_error(convex(X0,X1,X2),arg=2))) + ; throw(gecode_argument_error(convex(X0,X1,X2),arg=1))). + +nooverlap(X0,X1,X2,X3,X4) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> (is_IntArgs(X2,Y2) + -> (is_IntVarArgs(X3,Y3) + -> (is_IntArgs(X4,Y4) + -> gecode_constraint_nooverlap_329(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(nooverlap(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(nooverlap(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(nooverlap(X0,X1,X2,X3,X4),arg=3))) + ; throw(gecode_argument_error(nooverlap(X0,X1,X2,X3,X4),arg=2))) + ; throw(gecode_argument_error(nooverlap(X0,X1,X2,X3,X4),arg=1))). + +assign(X0,X1,X2) :- + (is_Space_or_Clause(X0,Y0) + -> (is_FloatVar(X1,Y1) + -> (is_FloatAssign(X2,Y2) + -> gecode_constraint_assign_15(Y0,Y1,Y2) + ; throw(gecode_argument_error(assign(X0,X1,X2),arg=3))) + ; (is_FloatVarArgs(X1,Y1) + -> (is_FloatAssign(X2,Y2) + -> gecode_constraint_assign_6(Y0,Y1,Y2) + ; throw(gecode_argument_error(assign(X0,X1,X2),arg=3))) + ; (is_BoolVarArgs(X1,Y1) + -> (is_IntAssign(X2,Y2) + -> gecode_constraint_assign_3(Y0,Y1,Y2) + ; throw(gecode_argument_error(assign(X0,X1,X2),arg=3))) + ; (is_BoolVar(X1,Y1) + -> (is_IntAssign(X2,Y2) + -> gecode_constraint_assign_1(Y0,Y1,Y2) + ; throw(gecode_argument_error(assign(X0,X1,X2),arg=3))) + ; (is_IntVarArgs(X1,Y1) + -> (is_IntAssign(X2,Y2) + -> gecode_constraint_assign_9(Y0,Y1,Y2) + ; throw(gecode_argument_error(assign(X0,X1,X2),arg=3))) + ; (is_IntVar(X1,Y1) + -> (is_IntAssign(X2,Y2) + -> gecode_constraint_assign_17(Y0,Y1,Y2) + ; throw(gecode_argument_error(assign(X0,X1,X2),arg=3))) + ; (is_SetVarArgs(X1,Y1) + -> (is_SetAssign(X2,Y2) + -> gecode_constraint_assign_12(Y0,Y1,Y2) + ; throw(gecode_argument_error(assign(X0,X1,X2),arg=3))) + ; (is_SetVar(X1,Y1) + -> (is_SetAssign(X2,Y2) + -> gecode_constraint_assign_19(Y0,Y1,Y2) + ; throw(gecode_argument_error(assign(X0,X1,X2),arg=3))) + ; throw(gecode_argument_error(assign(X0,X1,X2),arg=2)))))))))) + ; throw(gecode_argument_error(assign(X0,X1,X2),arg=1))). + +element(X0,X1,X2,X3) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> (is_IntVar(X2,Y2) + -> (is_int(X3,Y3) + -> gecode_constraint_element_220(Y0,Y1,Y2,Y3) + ; (is_IntVar(X3,Y3) + -> gecode_constraint_element_224(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(element(X0,X1,X2,X3),arg=4)))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3),arg=3))) + ; (is_BoolVarArgs(X1,Y1) + -> (is_IntVar(X2,Y2) + -> (is_int(X3,Y3) + -> gecode_constraint_element_214(Y0,Y1,Y2,Y3) + ; (is_BoolVar(X3,Y3) + -> gecode_constraint_element_212(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(element(X0,X1,X2,X3),arg=4)))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3),arg=3))) + ; (is_IntSetArgs(X1,Y1) + -> (is_IntVar(X2,Y2) + -> (is_SetVar(X3,Y3) + -> gecode_constraint_element_219(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(element(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3),arg=3))) + ; (is_SetVarArgs(X1,Y1) + -> (is_IntVar(X2,Y2) + -> (is_SetVar(X3,Y3) + -> gecode_constraint_element_227(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(element(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3),arg=3))) + ; (is_IntArgs(X1,Y1) + -> (is_IntVar(X2,Y2) + -> (is_int(X3,Y3) + -> gecode_constraint_element_230(Y0,Y1,Y2,Y3) + ; (is_IntVar(X3,Y3) + -> gecode_constraint_element_236(Y0,Y1,Y2,Y3) + ; (is_BoolVar(X3,Y3) + -> gecode_constraint_element_228(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(element(X0,X1,X2,X3),arg=4))))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3),arg=3))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3),arg=2))))))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3),arg=1))). + +sequence(X0,X1) :- + (is_Space_or_Clause(X0,Y0) + -> (is_SetVarArgs(X1,Y1) + -> gecode_constraint_sequence_437(Y0,Y1) + ; throw(gecode_argument_error(sequence(X0,X1),arg=2))) + ; throw(gecode_argument_error(sequence(X0,X1),arg=1))). + +notMax(X0,X1,X2) :- + (is_Space_or_Clause(X0,Y0) + -> (is_SetVar(X1,Y1) + -> (is_IntVar(X2,Y2) + -> gecode_constraint_notMax_335(Y0,Y1,Y2) + ; throw(gecode_argument_error(notMax(X0,X1,X2),arg=3))) + ; throw(gecode_argument_error(notMax(X0,X1,X2),arg=2))) + ; throw(gecode_argument_error(notMax(X0,X1,X2),arg=1))). + +ite(X0,X1,X2,X3,X4) :- + (is_Space_or_Clause(X0,Y0) + -> (is_BoolVar(X1,Y1) + -> (is_IntVar(X2,Y2) + -> (is_IntVar(X3,Y3) + -> (is_IntVar(X4,Y4) + -> gecode_constraint_ite_256(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(ite(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(ite(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(ite(X0,X1,X2,X3,X4),arg=3))) + ; throw(gecode_argument_error(ite(X0,X1,X2,X3,X4),arg=2))) + ; throw(gecode_argument_error(ite(X0,X1,X2,X3,X4),arg=1))). + +unary(X0,X1,X2) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> (is_IntArgs(X2,Y2) + -> gecode_constraint_unary_451(Y0,Y1,Y2) + ; throw(gecode_argument_error(unary(X0,X1,X2),arg=3))) + ; throw(gecode_argument_error(unary(X0,X1,X2),arg=2))) + ; throw(gecode_argument_error(unary(X0,X1,X2),arg=1))). + +nroot(X0,X1,X2,X3,X4) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVar(X1,Y1) + -> (is_int(X2,Y2) + -> (is_IntVar(X3,Y3) + -> (is_IntConLevel(X4,Y4) + -> gecode_constraint_nroot_339(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(nroot(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(nroot(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(nroot(X0,X1,X2,X3,X4),arg=3))) + ; throw(gecode_argument_error(nroot(X0,X1,X2,X3,X4),arg=2))) + ; throw(gecode_argument_error(nroot(X0,X1,X2,X3,X4),arg=1))). + +circuit(X0,X1,X2,X3) :- + (is_Space_or_Clause(X0,Y0) + -> (is_int(X1,Y1) + -> (is_IntVarArgs(X2,Y2) + -> (is_IntConLevel(X3,Y3) + -> gecode_constraint_circuit_85(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(circuit(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(circuit(X0,X1,X2,X3),arg=3))) + ; (is_IntArgs(X1,Y1) + -> (is_IntVarArgs(X2,Y2) + -> (is_IntVar(X3,Y3) + -> gecode_constraint_circuit_76(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(circuit(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(circuit(X0,X1,X2,X3),arg=3))) + ; throw(gecode_argument_error(circuit(X0,X1,X2,X3),arg=2)))) + ; throw(gecode_argument_error(circuit(X0,X1,X2,X3),arg=1))). + +dom(X0,X1,X2,X3,X4) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVar(X1,Y1) + -> (is_int(X2,Y2) + -> (is_int(X3,Y3) + -> (is_Reify(X4,Y4) + -> gecode_constraint_dom_199(Y0,Y1,Y2,Y3,Y4) + ; (is_IntConLevel(X4,Y4) + -> gecode_constraint_dom_198(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3,X4),arg=5)))) + ; (is_Reify(X3,Y3) + -> (is_IntConLevel(X4,Y4) + -> gecode_constraint_dom_202(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3,X4),arg=4)))) + ; (is_IntSet(X2,Y2) + -> (is_Reify(X3,Y3) + -> (is_IntConLevel(X4,Y4) + -> gecode_constraint_dom_194(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3,X4),arg=3)))) + ; (is_SetVarArgs(X1,Y1) + -> (is_SetRelType(X2,Y2) + -> (is_int(X3,Y3) + -> (is_int(X4,Y4) + -> gecode_constraint_dom_185(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3,X4),arg=3))) + ; (is_IntVarArgs(X1,Y1) + -> (is_int(X2,Y2) + -> (is_int(X3,Y3) + -> (is_IntConLevel(X4,Y4) + -> gecode_constraint_dom_181(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3,X4),arg=3))) + ; (is_FloatVar(X1,Y1) + -> (is_FloatNum(X2,Y2) + -> (is_FloatNum(X3,Y3) + -> (is_Reify(X4,Y4) + -> gecode_constraint_dom_187(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3,X4),arg=3))) + ; (is_SetVar(X1,Y1) + -> (is_SetRelType(X2,Y2) + -> (is_int(X3,Y3) + -> (is_int(X4,Y4) + -> gecode_constraint_dom_208(Y0,Y1,Y2,Y3,Y4) + ; (is_Reify(X4,Y4) + -> gecode_constraint_dom_210(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3,X4),arg=5)))) + ; (is_IntSet(X3,Y3) + -> (is_Reify(X4,Y4) + -> gecode_constraint_dom_206(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3,X4),arg=4)))) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3,X4),arg=3))) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3,X4),arg=2))))))) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3,X4),arg=1))). + +channel(X0,X1,X2,X3) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> (is_IntVarArgs(X2,Y2) + -> (is_IntConLevel(X3,Y3) + -> gecode_constraint_channel_66(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(channel(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(channel(X0,X1,X2,X3),arg=3))) + ; (is_BoolVarArgs(X1,Y1) + -> (is_IntVar(X2,Y2) + -> (is_int(X3,Y3) + -> gecode_constraint_channel_62(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(channel(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(channel(X0,X1,X2,X3),arg=3))) + ; (is_BoolVar(X1,Y1) + -> (is_IntVar(X2,Y2) + -> (is_IntConLevel(X3,Y3) + -> gecode_constraint_channel_60(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(channel(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(channel(X0,X1,X2,X3),arg=3))) + ; throw(gecode_argument_error(channel(X0,X1,X2,X3),arg=2))))) + ; throw(gecode_argument_error(channel(X0,X1,X2,X3),arg=1))). + +nooverlap(X0,X1,X2,X3,X4,X5,X6,X7) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> (is_IntVarArgs(X2,Y2) + -> (is_IntVarArgs(X3,Y3) + -> (is_IntVarArgs(X4,Y4) + -> (is_IntVarArgs(X5,Y5) + -> (is_IntVarArgs(X6,Y6) + -> (is_BoolVarArgs(X7,Y7) + -> gecode_constraint_nooverlap_331(Y0,Y1,Y2,Y3,Y4,Y5,Y6,Y7) + ; (is_IntConLevel(X7,Y7) + -> gecode_constraint_nooverlap_334(Y0,Y1,Y2,Y3,Y4,Y5,Y6,Y7) + ; throw(gecode_argument_error(nooverlap(X0,X1,X2,X3,X4,X5,X6,X7),arg=8)))) + ; throw(gecode_argument_error(nooverlap(X0,X1,X2,X3,X4,X5,X6,X7),arg=7))) + ; throw(gecode_argument_error(nooverlap(X0,X1,X2,X3,X4,X5,X6,X7),arg=6))) + ; throw(gecode_argument_error(nooverlap(X0,X1,X2,X3,X4,X5,X6,X7),arg=5))) + ; throw(gecode_argument_error(nooverlap(X0,X1,X2,X3,X4,X5,X6,X7),arg=4))) + ; throw(gecode_argument_error(nooverlap(X0,X1,X2,X3,X4,X5,X6,X7),arg=3))) + ; throw(gecode_argument_error(nooverlap(X0,X1,X2,X3,X4,X5,X6,X7),arg=2))) + ; throw(gecode_argument_error(nooverlap(X0,X1,X2,X3,X4,X5,X6,X7),arg=1))). + +element(X0,X1,X2,X3,X4,X5,X6) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> (is_IntVar(X2,Y2) + -> (is_int(X3,Y3) + -> (is_IntVar(X4,Y4) + -> (is_int(X5,Y5) + -> (is_IntVar(X6,Y6) + -> gecode_constraint_element_222(Y0,Y1,Y2,Y3,Y4,Y5,Y6) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6),arg=7))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6),arg=6))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6),arg=5))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6),arg=4))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6),arg=3))) + ; (is_BoolVarArgs(X1,Y1) + -> (is_IntVar(X2,Y2) + -> (is_int(X3,Y3) + -> (is_IntVar(X4,Y4) + -> (is_int(X5,Y5) + -> (is_BoolVar(X6,Y6) + -> gecode_constraint_element_216(Y0,Y1,Y2,Y3,Y4,Y5,Y6) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6),arg=7))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6),arg=6))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6),arg=5))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6),arg=4))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6),arg=3))) + ; (is_IntSetArgs(X1,Y1) + -> (is_IntVar(X2,Y2) + -> (is_int(X3,Y3) + -> (is_IntVar(X4,Y4) + -> (is_int(X5,Y5) + -> (is_SetVar(X6,Y6) + -> gecode_constraint_element_218(Y0,Y1,Y2,Y3,Y4,Y5,Y6) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6),arg=7))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6),arg=6))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6),arg=5))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6),arg=4))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6),arg=3))) + ; (is_SetVarArgs(X1,Y1) + -> (is_IntVar(X2,Y2) + -> (is_int(X3,Y3) + -> (is_IntVar(X4,Y4) + -> (is_int(X5,Y5) + -> (is_SetVar(X6,Y6) + -> gecode_constraint_element_226(Y0,Y1,Y2,Y3,Y4,Y5,Y6) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6),arg=7))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6),arg=6))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6),arg=5))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6),arg=4))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6),arg=3))) + ; (is_IntArgs(X1,Y1) + -> (is_IntVar(X2,Y2) + -> (is_int(X3,Y3) + -> (is_IntVar(X4,Y4) + -> (is_int(X5,Y5) + -> (is_IntVar(X6,Y6) + -> gecode_constraint_element_234(Y0,Y1,Y2,Y3,Y4,Y5,Y6) + ; (is_BoolVar(X6,Y6) + -> gecode_constraint_element_232(Y0,Y1,Y2,Y3,Y4,Y5,Y6) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6),arg=7)))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6),arg=6))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6),arg=5))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6),arg=4))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6),arg=3))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6),arg=2))))))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6),arg=1))). + +max(X0,X1,X2) :- + (is_Space_or_Clause(X0,Y0) + -> (is_FloatVarArgs(X1,Y1) + -> (is_FloatVar(X2,Y2) + -> gecode_constraint_max_298(Y0,Y1,Y2) + ; throw(gecode_argument_error(max(X0,X1,X2),arg=3))) + ; (is_IntVarArgs(X1,Y1) + -> (is_IntVar(X2,Y2) + -> gecode_constraint_max_299(Y0,Y1,Y2) + ; throw(gecode_argument_error(max(X0,X1,X2),arg=3))) + ; (is_SetVar(X1,Y1) + -> (is_IntVar(X2,Y2) + -> gecode_constraint_max_304(Y0,Y1,Y2) + ; throw(gecode_argument_error(max(X0,X1,X2),arg=3))) + ; throw(gecode_argument_error(max(X0,X1,X2),arg=2))))) + ; throw(gecode_argument_error(max(X0,X1,X2),arg=1))). + +unshare(X0,X1) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> gecode_constraint_unshare_463(Y0,Y1) + ; (is_BoolVarArgs(X1,Y1) + -> gecode_constraint_unshare_461(Y0,Y1) + ; throw(gecode_argument_error(unshare(X0,X1),arg=2)))) + ; throw(gecode_argument_error(unshare(X0,X1),arg=1))). + +path(X0,X1,X2,X3,X4) :- + (is_Space_or_Clause(X0,Y0) + -> (is_int(X1,Y1) + -> (is_IntVarArgs(X2,Y2) + -> (is_IntVar(X3,Y3) + -> (is_IntVar(X4,Y4) + -> gecode_constraint_path_358(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4),arg=3))) + ; (is_IntVarArgs(X1,Y1) + -> (is_IntVar(X2,Y2) + -> (is_IntVar(X3,Y3) + -> (is_IntConLevel(X4,Y4) + -> gecode_constraint_path_357(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4),arg=3))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4),arg=2)))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4),arg=1))). + +branch(X0,X1,X2,X3,X4,X5,X6) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> (is_IntVarBranch(X2,Y2) + -> (is_IntValBranch(X3,Y3) + -> (is_Symmetries(X4,Y4) + -> (is_IntBranchFilter(X5,Y5) + -> (is_IntVarValPrint(X6,Y6) + -> gecode_constraint_branch_34(Y0,Y1,Y2,Y3,Y4,Y5,Y6) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4,X5,X6),arg=7))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4,X5,X6),arg=6))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4,X5,X6),arg=5))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4,X5,X6),arg=4))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4,X5,X6),arg=3))) + ; (is_BoolVarArgs(X1,Y1) + -> (is_IntVarBranch(X2,Y2) + -> (is_IntValBranch(X3,Y3) + -> (is_Symmetries(X4,Y4) + -> (is_BoolBranchFilter(X5,Y5) + -> (is_BoolVarValPrint(X6,Y6) + -> gecode_constraint_branch_28(Y0,Y1,Y2,Y3,Y4,Y5,Y6) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4,X5,X6),arg=7))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4,X5,X6),arg=6))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4,X5,X6),arg=5))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4,X5,X6),arg=4))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4,X5,X6),arg=3))) + ; (is_SetVarArgs(X1,Y1) + -> (is_SetVarBranch(X2,Y2) + -> (is_SetValBranch(X3,Y3) + -> (is_Symmetries(X4,Y4) + -> (is_SetBranchFilter(X5,Y5) + -> (is_SetVarValPrint(X6,Y6) + -> gecode_constraint_branch_40(Y0,Y1,Y2,Y3,Y4,Y5,Y6) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4,X5,X6),arg=7))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4,X5,X6),arg=6))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4,X5,X6),arg=5))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4,X5,X6),arg=4))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4,X5,X6),arg=3))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4,X5,X6),arg=2))))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4,X5,X6),arg=1))). + +mult(X0,X1,X2,X3) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVar(X1,Y1) + -> (is_IntVar(X2,Y2) + -> (is_IntVar(X3,Y3) + -> gecode_constraint_mult_325(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(mult(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(mult(X0,X1,X2,X3),arg=3))) + ; (is_FloatVar(X1,Y1) + -> (is_FloatVar(X2,Y2) + -> (is_FloatVar(X3,Y3) + -> gecode_constraint_mult_324(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(mult(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(mult(X0,X1,X2,X3),arg=3))) + ; throw(gecode_argument_error(mult(X0,X1,X2,X3),arg=2)))) + ; throw(gecode_argument_error(mult(X0,X1,X2,X3),arg=1))). + +clause(X0,X1,X2,X3,X4,X5) :- + (is_Space_or_Clause(X0,Y0) + -> (is_BoolOpType(X1,Y1) + -> (is_BoolVarArgs(X2,Y2) + -> (is_BoolVarArgs(X3,Y3) + -> (is_int(X4,Y4) + -> (is_IntConLevel(X5,Y5) + -> gecode_constraint_clause_89(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(clause(X0,X1,X2,X3,X4,X5),arg=6))) + ; (is_BoolVar(X4,Y4) + -> (is_IntConLevel(X5,Y5) + -> gecode_constraint_clause_87(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(clause(X0,X1,X2,X3,X4,X5),arg=6))) + ; throw(gecode_argument_error(clause(X0,X1,X2,X3,X4,X5),arg=5)))) + ; throw(gecode_argument_error(clause(X0,X1,X2,X3,X4,X5),arg=4))) + ; throw(gecode_argument_error(clause(X0,X1,X2,X3,X4,X5),arg=3))) + ; throw(gecode_argument_error(clause(X0,X1,X2,X3,X4,X5),arg=2))) + ; throw(gecode_argument_error(clause(X0,X1,X2,X3,X4,X5),arg=1))). + +precede(X0,X1,X2,X3,X4) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> (is_int(X2,Y2) + -> (is_int(X3,Y3) + -> (is_IntConLevel(X4,Y4) + -> gecode_constraint_precede_366(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(precede(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(precede(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(precede(X0,X1,X2,X3,X4),arg=3))) + ; throw(gecode_argument_error(precede(X0,X1,X2,X3,X4),arg=2))) + ; throw(gecode_argument_error(precede(X0,X1,X2,X3,X4),arg=1))). + +distinct(X0,X1) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> gecode_constraint_distinct_160(Y0,Y1) + ; throw(gecode_argument_error(distinct(X0,X1),arg=2))) + ; throw(gecode_argument_error(distinct(X0,X1),arg=1))). + +member(X0,X1,X2,X3) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> (is_IntVar(X2,Y2) + -> (is_Reify(X3,Y3) + -> gecode_constraint_member_312(Y0,Y1,Y2,Y3) + ; (is_IntConLevel(X3,Y3) + -> gecode_constraint_member_311(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(member(X0,X1,X2,X3),arg=4)))) + ; throw(gecode_argument_error(member(X0,X1,X2,X3),arg=3))) + ; (is_BoolVarArgs(X1,Y1) + -> (is_BoolVar(X2,Y2) + -> (is_Reify(X3,Y3) + -> gecode_constraint_member_308(Y0,Y1,Y2,Y3) + ; (is_IntConLevel(X3,Y3) + -> gecode_constraint_member_307(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(member(X0,X1,X2,X3),arg=4)))) + ; throw(gecode_argument_error(member(X0,X1,X2,X3),arg=3))) + ; throw(gecode_argument_error(member(X0,X1,X2,X3),arg=2)))) + ; throw(gecode_argument_error(member(X0,X1,X2,X3),arg=1))). + +mod(X0,X1,X2,X3,X4) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVar(X1,Y1) + -> (is_IntVar(X2,Y2) + -> (is_IntVar(X3,Y3) + -> (is_IntConLevel(X4,Y4) + -> gecode_constraint_mod_323(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(mod(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(mod(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(mod(X0,X1,X2,X3,X4),arg=3))) + ; throw(gecode_argument_error(mod(X0,X1,X2,X3,X4),arg=2))) + ; throw(gecode_argument_error(mod(X0,X1,X2,X3,X4),arg=1))). + +cardinality(X0,X1,X2) :- + (is_Space_or_Clause(X0,Y0) + -> (is_SetVar(X1,Y1) + -> (is_IntVar(X2,Y2) + -> gecode_constraint_cardinality_57(Y0,Y1,Y2) + ; throw(gecode_argument_error(cardinality(X0,X1,X2),arg=3))) + ; throw(gecode_argument_error(cardinality(X0,X1,X2),arg=2))) + ; throw(gecode_argument_error(cardinality(X0,X1,X2),arg=1))). + +atmostOne(X0,X1,X2) :- + (is_Space_or_Clause(X0,Y0) + -> (is_SetVarArgs(X1,Y1) + -> (is_int(X2,Y2) + -> gecode_constraint_atmostOne_53(Y0,Y1,Y2) + ; throw(gecode_argument_error(atmostOne(X0,X1,X2),arg=3))) + ; throw(gecode_argument_error(atmostOne(X0,X1,X2),arg=2))) + ; throw(gecode_argument_error(atmostOne(X0,X1,X2),arg=1))). + +channelSorted(X0,X1,X2) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> (is_SetVar(X2,Y2) + -> gecode_constraint_channelSorted_73(Y0,Y1,Y2) + ; throw(gecode_argument_error(channelSorted(X0,X1,X2),arg=3))) + ; throw(gecode_argument_error(channelSorted(X0,X1,X2),arg=2))) + ; throw(gecode_argument_error(channelSorted(X0,X1,X2),arg=1))). + +extensional(X0,X1,X2,X3,X4) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> (is_TupleSet(X2,Y2) + -> (is_ExtensionalPropKind(X3,Y3) + -> (is_IntConLevel(X4,Y4) + -> gecode_constraint_extensional_253(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(extensional(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(extensional(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(extensional(X0,X1,X2,X3,X4),arg=3))) + ; (is_BoolVarArgs(X1,Y1) + -> (is_TupleSet(X2,Y2) + -> (is_ExtensionalPropKind(X3,Y3) + -> (is_IntConLevel(X4,Y4) + -> gecode_constraint_extensional_248(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(extensional(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(extensional(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(extensional(X0,X1,X2,X3,X4),arg=3))) + ; throw(gecode_argument_error(extensional(X0,X1,X2,X3,X4),arg=2)))) + ; throw(gecode_argument_error(extensional(X0,X1,X2,X3,X4),arg=1))). + +linear(X0,X1,X2,X3) :- + (is_Space_or_Clause(X0,Y0) + -> (is_FloatVarArgs(X1,Y1) + -> (is_FloatRelType(X2,Y2) + -> (is_FloatVar(X3,Y3) + -> gecode_constraint_linear_272(Y0,Y1,Y2,Y3) + ; (is_FloatNum(X3,Y3) + -> gecode_constraint_linear_270(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3),arg=4)))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3),arg=3))) + ; (is_BoolVarArgs(X1,Y1) + -> (is_IntRelType(X2,Y2) + -> (is_int(X3,Y3) + -> gecode_constraint_linear_258(Y0,Y1,Y2,Y3) + ; (is_IntVar(X3,Y3) + -> gecode_constraint_linear_262(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3),arg=4)))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3),arg=3))) + ; (is_IntVarArgs(X1,Y1) + -> (is_IntRelType(X2,Y2) + -> (is_int(X3,Y3) + -> gecode_constraint_linear_290(Y0,Y1,Y2,Y3) + ; (is_IntVar(X3,Y3) + -> gecode_constraint_linear_294(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3),arg=4)))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3),arg=3))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3),arg=2))))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3),arg=1))). + +circuit(X0,X1) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> gecode_constraint_circuit_82(Y0,Y1) + ; throw(gecode_argument_error(circuit(X0,X1),arg=2))) + ; throw(gecode_argument_error(circuit(X0,X1),arg=1))). + +rel(X0,X1,X2,X3,X4) :- + (is_Space_or_Clause(X0,Y0) + -> (is_FloatVar(X1,Y1) + -> (is_FloatRelType(X2,Y2) + -> (is_FloatVal(X3,Y3) + -> (is_Reify(X4,Y4) + -> gecode_constraint_rel_406(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4),arg=5))) + ; (is_FloatVar(X3,Y3) + -> (is_Reify(X4,Y4) + -> gecode_constraint_rel_408(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4),arg=4)))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4),arg=3))) + ; (is_SetOpType(X1,Y1) + -> (is_SetVarArgs(X2,Y2) + -> (is_IntSet(X3,Y3) + -> (is_SetVar(X4,Y4) + -> gecode_constraint_rel_422(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4),arg=4))) + ; (is_IntVarArgs(X2,Y2) + -> (is_IntSet(X3,Y3) + -> (is_SetVar(X4,Y4) + -> gecode_constraint_rel_420(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4),arg=3)))) + ; (is_BoolVarArgs(X1,Y1) + -> (is_IntRelType(X2,Y2) + -> (is_int(X3,Y3) + -> (is_IntConLevel(X4,Y4) + -> gecode_constraint_rel_392(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4),arg=5))) + ; (is_BoolVarArgs(X3,Y3) + -> (is_IntConLevel(X4,Y4) + -> gecode_constraint_rel_388(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4),arg=5))) + ; (is_BoolVar(X3,Y3) + -> (is_IntConLevel(X4,Y4) + -> gecode_constraint_rel_386(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4),arg=4))))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4),arg=3))) + ; (is_BoolVar(X1,Y1) + -> (is_IntRelType(X2,Y2) + -> (is_int(X3,Y3) + -> (is_Reify(X4,Y4) + -> gecode_constraint_rel_383(Y0,Y1,Y2,Y3,Y4) + ; (is_IntConLevel(X4,Y4) + -> gecode_constraint_rel_382(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4),arg=5)))) + ; (is_BoolVar(X3,Y3) + -> (is_Reify(X4,Y4) + -> gecode_constraint_rel_379(Y0,Y1,Y2,Y3,Y4) + ; (is_IntConLevel(X4,Y4) + -> gecode_constraint_rel_378(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4),arg=5)))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4),arg=4)))) + ; (is_BoolOpType(X2,Y2) + -> (is_BoolVar(X3,Y3) + -> (is_int(X4,Y4) + -> gecode_constraint_rel_375(Y0,Y1,Y2,Y3,Y4) + ; (is_BoolVar(X4,Y4) + -> gecode_constraint_rel_373(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4),arg=5)))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4),arg=3)))) + ; (is_IntVarArgs(X1,Y1) + -> (is_IntRelType(X2,Y2) + -> (is_int(X3,Y3) + -> (is_IntConLevel(X4,Y4) + -> gecode_constraint_rel_402(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4),arg=5))) + ; (is_IntVar(X3,Y3) + -> (is_IntConLevel(X4,Y4) + -> gecode_constraint_rel_404(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4),arg=5))) + ; (is_IntVarArgs(X3,Y3) + -> (is_IntConLevel(X4,Y4) + -> gecode_constraint_rel_398(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4),arg=4))))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4),arg=3))) + ; (is_IntVar(X1,Y1) + -> (is_IntRelType(X2,Y2) + -> (is_int(X3,Y3) + -> (is_Reify(X4,Y4) + -> gecode_constraint_rel_411(Y0,Y1,Y2,Y3,Y4) + ; (is_IntConLevel(X4,Y4) + -> gecode_constraint_rel_410(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4),arg=5)))) + ; (is_IntVar(X3,Y3) + -> (is_Reify(X4,Y4) + -> gecode_constraint_rel_415(Y0,Y1,Y2,Y3,Y4) + ; (is_IntConLevel(X4,Y4) + -> gecode_constraint_rel_414(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4),arg=5)))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4),arg=4)))) + ; (is_SetRelType(X2,Y2) + -> (is_SetVar(X3,Y3) + -> (is_Reify(X4,Y4) + -> gecode_constraint_rel_419(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4),arg=3)))) + ; (is_SetVar(X1,Y1) + -> (is_SetRelType(X2,Y2) + -> (is_IntVar(X3,Y3) + -> (is_Reify(X4,Y4) + -> gecode_constraint_rel_430(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4),arg=5))) + ; (is_SetVar(X3,Y3) + -> (is_Reify(X4,Y4) + -> gecode_constraint_rel_432(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4),arg=4)))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4),arg=3))) + ; (is_BoolOpType(X1,Y1) + -> (is_BoolVarArgs(X2,Y2) + -> (is_int(X3,Y3) + -> (is_IntConLevel(X4,Y4) + -> gecode_constraint_rel_372(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4),arg=5))) + ; (is_BoolVar(X3,Y3) + -> (is_IntConLevel(X4,Y4) + -> gecode_constraint_rel_370(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4),arg=4)))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4),arg=3))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4),arg=2)))))))))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4),arg=1))). + +min(X0,X1,X2,X3) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVar(X1,Y1) + -> (is_IntVar(X2,Y2) + -> (is_IntVar(X3,Y3) + -> gecode_constraint_min_318(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(min(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(min(X0,X1,X2,X3),arg=3))) + ; (is_IntVarArgs(X1,Y1) + -> (is_IntVar(X2,Y2) + -> (is_IntConLevel(X3,Y3) + -> gecode_constraint_min_316(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(min(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(min(X0,X1,X2,X3),arg=3))) + ; (is_FloatVar(X1,Y1) + -> (is_FloatVar(X2,Y2) + -> (is_FloatVar(X3,Y3) + -> gecode_constraint_min_317(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(min(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(min(X0,X1,X2,X3),arg=3))) + ; (is_SetVar(X1,Y1) + -> (is_IntVar(X2,Y2) + -> (is_Reify(X3,Y3) + -> gecode_constraint_min_321(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(min(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(min(X0,X1,X2,X3),arg=3))) + ; throw(gecode_argument_error(min(X0,X1,X2,X3),arg=2)))))) + ; throw(gecode_argument_error(min(X0,X1,X2,X3),arg=1))). + +cardinality(X0,X1,X2,X3) :- + (is_Space_or_Clause(X0,Y0) + -> (is_SetVarArgs(X1,Y1) + -> (is_int(X2,Y2) + -> (is_int(X3,Y3) + -> gecode_constraint_cardinality_56(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(cardinality(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(cardinality(X0,X1,X2,X3),arg=3))) + ; (is_SetVar(X1,Y1) + -> (is_int(X2,Y2) + -> (is_int(X3,Y3) + -> gecode_constraint_cardinality_58(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(cardinality(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(cardinality(X0,X1,X2,X3),arg=3))) + ; throw(gecode_argument_error(cardinality(X0,X1,X2,X3),arg=2)))) + ; throw(gecode_argument_error(cardinality(X0,X1,X2,X3),arg=1))). + +count(X0,X1,X2,X3) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> (is_IntVarArgs(X2,Y2) + -> (is_IntConLevel(X3,Y3) + -> gecode_constraint_count_109(Y0,Y1,Y2,Y3) + ; (is_IntArgs(X3,Y3) + -> gecode_constraint_count_106(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(count(X0,X1,X2,X3),arg=4)))) + ; (is_IntSet(X2,Y2) + -> (is_IntArgs(X3,Y3) + -> gecode_constraint_count_100(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(count(X0,X1,X2,X3),arg=4))) + ; (is_IntSetArgs(X2,Y2) + -> (is_IntConLevel(X3,Y3) + -> gecode_constraint_count_99(Y0,Y1,Y2,Y3) + ; (is_IntArgs(X3,Y3) + -> gecode_constraint_count_96(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(count(X0,X1,X2,X3),arg=4)))) + ; throw(gecode_argument_error(count(X0,X1,X2,X3),arg=3))))) + ; throw(gecode_argument_error(count(X0,X1,X2,X3),arg=2))) + ; throw(gecode_argument_error(count(X0,X1,X2,X3),arg=1))). + +sqrt(X0,X1,X2) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVar(X1,Y1) + -> (is_IntVar(X2,Y2) + -> gecode_constraint_sqrt_447(Y0,Y1,Y2) + ; throw(gecode_argument_error(sqrt(X0,X1,X2),arg=3))) + ; (is_FloatVar(X1,Y1) + -> (is_FloatVar(X2,Y2) + -> gecode_constraint_sqrt_446(Y0,Y1,Y2) + ; throw(gecode_argument_error(sqrt(X0,X1,X2),arg=3))) + ; throw(gecode_argument_error(sqrt(X0,X1,X2),arg=2)))) + ; throw(gecode_argument_error(sqrt(X0,X1,X2),arg=1))). + +cumulatives(X0,X1,X2,X3,X4,X5,X6,X7,X8) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> (is_IntVarArgs(X2,Y2) + -> (is_IntVarArgs(X3,Y3) + -> (is_IntVarArgs(X4,Y4) + -> (is_IntVarArgs(X5,Y5) + -> (is_IntArgs(X6,Y6) + -> (is_bool(X7,Y7) + -> (is_IntConLevel(X8,Y8) + -> gecode_constraint_cumulatives_157(Y0,Y1,Y2,Y3,Y4,Y5,Y6,Y7,Y8) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=9))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=8))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=7))) + ; (is_IntArgs(X5,Y5) + -> (is_IntArgs(X6,Y6) + -> (is_bool(X7,Y7) + -> (is_IntConLevel(X8,Y8) + -> gecode_constraint_cumulatives_155(Y0,Y1,Y2,Y3,Y4,Y5,Y6,Y7,Y8) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=9))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=8))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=7))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=6)))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=5))) + ; (is_IntArgs(X3,Y3) + -> (is_IntVarArgs(X4,Y4) + -> (is_IntVarArgs(X5,Y5) + -> (is_IntArgs(X6,Y6) + -> (is_bool(X7,Y7) + -> (is_IntConLevel(X8,Y8) + -> gecode_constraint_cumulatives_153(Y0,Y1,Y2,Y3,Y4,Y5,Y6,Y7,Y8) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=9))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=8))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=7))) + ; (is_IntArgs(X5,Y5) + -> (is_IntArgs(X6,Y6) + -> (is_bool(X7,Y7) + -> (is_IntConLevel(X8,Y8) + -> gecode_constraint_cumulatives_151(Y0,Y1,Y2,Y3,Y4,Y5,Y6,Y7,Y8) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=9))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=8))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=7))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=6)))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=5))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=4)))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=3))) + ; (is_IntArgs(X1,Y1) + -> (is_IntVarArgs(X2,Y2) + -> (is_IntVarArgs(X3,Y3) + -> (is_IntVarArgs(X4,Y4) + -> (is_IntVarArgs(X5,Y5) + -> (is_IntArgs(X6,Y6) + -> (is_bool(X7,Y7) + -> (is_IntConLevel(X8,Y8) + -> gecode_constraint_cumulatives_149(Y0,Y1,Y2,Y3,Y4,Y5,Y6,Y7,Y8) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=9))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=8))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=7))) + ; (is_IntArgs(X5,Y5) + -> (is_IntArgs(X6,Y6) + -> (is_bool(X7,Y7) + -> (is_IntConLevel(X8,Y8) + -> gecode_constraint_cumulatives_147(Y0,Y1,Y2,Y3,Y4,Y5,Y6,Y7,Y8) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=9))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=8))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=7))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=6)))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=5))) + ; (is_IntArgs(X3,Y3) + -> (is_IntVarArgs(X4,Y4) + -> (is_IntVarArgs(X5,Y5) + -> (is_IntArgs(X6,Y6) + -> (is_bool(X7,Y7) + -> (is_IntConLevel(X8,Y8) + -> gecode_constraint_cumulatives_145(Y0,Y1,Y2,Y3,Y4,Y5,Y6,Y7,Y8) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=9))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=8))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=7))) + ; (is_IntArgs(X5,Y5) + -> (is_IntArgs(X6,Y6) + -> (is_bool(X7,Y7) + -> (is_IntConLevel(X8,Y8) + -> gecode_constraint_cumulatives_143(Y0,Y1,Y2,Y3,Y4,Y5,Y6,Y7,Y8) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=9))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=8))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=7))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=6)))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=5))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=4)))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=3))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=2)))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=1))). + +nvalues(X0,X1,X2,X3) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> (is_IntRelType(X2,Y2) + -> (is_int(X3,Y3) + -> gecode_constraint_nvalues_344(Y0,Y1,Y2,Y3) + ; (is_IntVar(X3,Y3) + -> gecode_constraint_nvalues_346(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(nvalues(X0,X1,X2,X3),arg=4)))) + ; throw(gecode_argument_error(nvalues(X0,X1,X2,X3),arg=3))) + ; (is_BoolVarArgs(X1,Y1) + -> (is_IntRelType(X2,Y2) + -> (is_int(X3,Y3) + -> gecode_constraint_nvalues_340(Y0,Y1,Y2,Y3) + ; (is_IntVar(X3,Y3) + -> gecode_constraint_nvalues_342(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(nvalues(X0,X1,X2,X3),arg=4)))) + ; throw(gecode_argument_error(nvalues(X0,X1,X2,X3),arg=3))) + ; throw(gecode_argument_error(nvalues(X0,X1,X2,X3),arg=2)))) + ; throw(gecode_argument_error(nvalues(X0,X1,X2,X3),arg=1))). + +binpacking(X0,X1,X2,X3) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> (is_IntVarArgs(X2,Y2) + -> (is_IntArgs(X3,Y3) + -> gecode_constraint_binpacking_54(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(binpacking(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(binpacking(X0,X1,X2,X3),arg=3))) + ; throw(gecode_argument_error(binpacking(X0,X1,X2,X3),arg=2))) + ; throw(gecode_argument_error(binpacking(X0,X1,X2,X3),arg=1))). + +linear(X0,X1,X2,X3,X4,X5,X6) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntArgs(X1,Y1) + -> (is_IntVarArgs(X2,Y2) + -> (is_IntRelType(X3,Y3) + -> (is_int(X4,Y4) + -> (is_Reify(X5,Y5) + -> (is_IntConLevel(X6,Y6) + -> gecode_constraint_linear_285(Y0,Y1,Y2,Y3,Y4,Y5,Y6) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4,X5,X6),arg=7))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4,X5,X6),arg=6))) + ; (is_IntVar(X4,Y4) + -> (is_Reify(X5,Y5) + -> (is_IntConLevel(X6,Y6) + -> gecode_constraint_linear_289(Y0,Y1,Y2,Y3,Y4,Y5,Y6) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4,X5,X6),arg=7))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4,X5,X6),arg=6))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4,X5,X6),arg=5)))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4,X5,X6),arg=4))) + ; (is_BoolVarArgs(X2,Y2) + -> (is_IntRelType(X3,Y3) + -> (is_int(X4,Y4) + -> (is_Reify(X5,Y5) + -> (is_IntConLevel(X6,Y6) + -> gecode_constraint_linear_277(Y0,Y1,Y2,Y3,Y4,Y5,Y6) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4,X5,X6),arg=7))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4,X5,X6),arg=6))) + ; (is_IntVar(X4,Y4) + -> (is_Reify(X5,Y5) + -> (is_IntConLevel(X6,Y6) + -> gecode_constraint_linear_281(Y0,Y1,Y2,Y3,Y4,Y5,Y6) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4,X5,X6),arg=7))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4,X5,X6),arg=6))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4,X5,X6),arg=5)))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4,X5,X6),arg=4))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4,X5,X6),arg=3)))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4,X5,X6),arg=2))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4,X5,X6),arg=1))). + +abs(X0,X1,X2,X3) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVar(X1,Y1) + -> (is_IntVar(X2,Y2) + -> (is_IntConLevel(X3,Y3) + -> gecode_constraint_abs_52(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(abs(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(abs(X0,X1,X2,X3),arg=3))) + ; throw(gecode_argument_error(abs(X0,X1,X2,X3),arg=2))) + ; throw(gecode_argument_error(abs(X0,X1,X2,X3),arg=1))). + +convex(X0,X1) :- + (is_Space_or_Clause(X0,Y0) + -> (is_SetVar(X1,Y1) + -> gecode_constraint_convex_90(Y0,Y1) + ; throw(gecode_argument_error(convex(X0,X1),arg=2))) + ; throw(gecode_argument_error(convex(X0,X1),arg=1))). + +div(X0,X1,X2,X3) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVar(X1,Y1) + -> (is_IntVar(X2,Y2) + -> (is_IntVar(X3,Y3) + -> gecode_constraint_div_163(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(div(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(div(X0,X1,X2,X3),arg=3))) + ; (is_FloatVar(X1,Y1) + -> (is_FloatVar(X2,Y2) + -> (is_FloatVar(X3,Y3) + -> gecode_constraint_div_162(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(div(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(div(X0,X1,X2,X3),arg=3))) + ; throw(gecode_argument_error(div(X0,X1,X2,X3),arg=2)))) + ; throw(gecode_argument_error(div(X0,X1,X2,X3),arg=1))). + +rel(X0,X1,X2,X3,X4,X5) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVar(X1,Y1) + -> (is_IntRelType(X2,Y2) + -> (is_int(X3,Y3) + -> (is_Reify(X4,Y4) + -> (is_IntConLevel(X5,Y5) + -> gecode_constraint_rel_412(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4,X5),arg=6))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4,X5),arg=5))) + ; (is_IntVar(X3,Y3) + -> (is_Reify(X4,Y4) + -> (is_IntConLevel(X5,Y5) + -> gecode_constraint_rel_416(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4,X5),arg=6))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4,X5),arg=5))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4,X5),arg=4)))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4,X5),arg=3))) + ; (is_IntSet(X1,Y1) + -> (is_SetOpType(X2,Y2) + -> (is_SetVar(X3,Y3) + -> (is_SetRelType(X4,Y4) + -> (is_IntSet(X5,Y5) + -> gecode_constraint_rel_395(Y0,Y1,Y2,Y3,Y4,Y5) + ; (is_SetVar(X5,Y5) + -> gecode_constraint_rel_396(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4,X5),arg=6)))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4,X5),arg=5))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4,X5),arg=4))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4,X5),arg=3))) + ; (is_BoolVar(X1,Y1) + -> (is_IntRelType(X2,Y2) + -> (is_int(X3,Y3) + -> (is_Reify(X4,Y4) + -> (is_IntConLevel(X5,Y5) + -> gecode_constraint_rel_384(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4,X5),arg=6))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4,X5),arg=5))) + ; (is_BoolVar(X3,Y3) + -> (is_Reify(X4,Y4) + -> (is_IntConLevel(X5,Y5) + -> gecode_constraint_rel_380(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4,X5),arg=6))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4,X5),arg=5))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4,X5),arg=4)))) + ; (is_BoolOpType(X2,Y2) + -> (is_BoolVar(X3,Y3) + -> (is_int(X4,Y4) + -> (is_IntConLevel(X5,Y5) + -> gecode_constraint_rel_376(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4,X5),arg=6))) + ; (is_BoolVar(X4,Y4) + -> (is_IntConLevel(X5,Y5) + -> gecode_constraint_rel_374(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4,X5),arg=6))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4,X5),arg=5)))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4,X5),arg=4))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4,X5),arg=3)))) + ; (is_SetVar(X1,Y1) + -> (is_SetOpType(X2,Y2) + -> (is_IntSet(X3,Y3) + -> (is_SetRelType(X4,Y4) + -> (is_IntSet(X5,Y5) + -> gecode_constraint_rel_425(Y0,Y1,Y2,Y3,Y4,Y5) + ; (is_SetVar(X5,Y5) + -> gecode_constraint_rel_426(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4,X5),arg=6)))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4,X5),arg=5))) + ; (is_SetVar(X3,Y3) + -> (is_SetRelType(X4,Y4) + -> (is_IntSet(X5,Y5) + -> gecode_constraint_rel_427(Y0,Y1,Y2,Y3,Y4,Y5) + ; (is_SetVar(X5,Y5) + -> gecode_constraint_rel_428(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4,X5),arg=6)))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4,X5),arg=5))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4,X5),arg=4)))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4,X5),arg=3))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4,X5),arg=2)))))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3,X4,X5),arg=1))). + +weights(X0,X1,X2,X3,X4) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntArgs(X1,Y1) + -> (is_IntArgs(X2,Y2) + -> (is_SetVar(X3,Y3) + -> (is_IntVar(X4,Y4) + -> gecode_constraint_weights_465(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(weights(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(weights(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(weights(X0,X1,X2,X3,X4),arg=3))) + ; throw(gecode_argument_error(weights(X0,X1,X2,X3,X4),arg=2))) + ; throw(gecode_argument_error(weights(X0,X1,X2,X3,X4),arg=1))). + +max(X0,X1,X2,X3,X4) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVar(X1,Y1) + -> (is_IntVar(X2,Y2) + -> (is_IntVar(X3,Y3) + -> (is_IntConLevel(X4,Y4) + -> gecode_constraint_max_303(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(max(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(max(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(max(X0,X1,X2,X3,X4),arg=3))) + ; throw(gecode_argument_error(max(X0,X1,X2,X3,X4),arg=2))) + ; throw(gecode_argument_error(max(X0,X1,X2,X3,X4),arg=1))). + +path(X0,X1,X2,X3,X4,X5,X6,X7,X8) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntArgs(X1,Y1) + -> (is_int(X2,Y2) + -> (is_IntVarArgs(X3,Y3) + -> (is_IntVar(X4,Y4) + -> (is_IntVar(X5,Y5) + -> (is_IntVarArgs(X6,Y6) + -> (is_IntVar(X7,Y7) + -> (is_IntConLevel(X8,Y8) + -> gecode_constraint_path_353(Y0,Y1,Y2,Y3,Y4,Y5,Y6,Y7,Y8) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=9))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=8))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=7))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=6))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=5))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=4))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=3))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=2))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=1))). + +unary(X0,X1,X2,X3) :- + (is_Space_or_Clause(X0,Y0) + -> (is_TaskTypeArgs(X1,Y1) + -> (is_IntVarArgs(X2,Y2) + -> (is_IntArgs(X3,Y3) + -> gecode_constraint_unary_459(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(unary(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(unary(X0,X1,X2,X3),arg=3))) + ; (is_IntVarArgs(X1,Y1) + -> (is_IntVarArgs(X2,Y2) + -> (is_IntVarArgs(X3,Y3) + -> gecode_constraint_unary_455(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(unary(X0,X1,X2,X3),arg=4))) + ; (is_IntArgs(X2,Y2) + -> (is_BoolVarArgs(X3,Y3) + -> gecode_constraint_unary_449(Y0,Y1,Y2,Y3) + ; (is_IntConLevel(X3,Y3) + -> gecode_constraint_unary_452(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(unary(X0,X1,X2,X3),arg=4)))) + ; throw(gecode_argument_error(unary(X0,X1,X2,X3),arg=3)))) + ; throw(gecode_argument_error(unary(X0,X1,X2,X3),arg=2)))) + ; throw(gecode_argument_error(unary(X0,X1,X2,X3),arg=1))). + +nroot(X0,X1,X2,X3) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVar(X1,Y1) + -> (is_int(X2,Y2) + -> (is_IntVar(X3,Y3) + -> gecode_constraint_nroot_338(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(nroot(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(nroot(X0,X1,X2,X3),arg=3))) + ; (is_FloatVar(X1,Y1) + -> (is_int(X2,Y2) + -> (is_FloatVar(X3,Y3) + -> gecode_constraint_nroot_337(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(nroot(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(nroot(X0,X1,X2,X3),arg=3))) + ; throw(gecode_argument_error(nroot(X0,X1,X2,X3),arg=2)))) + ; throw(gecode_argument_error(nroot(X0,X1,X2,X3),arg=1))). + +sorted(X0,X1,X2,X3,X4) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> (is_IntVarArgs(X2,Y2) + -> (is_IntVarArgs(X3,Y3) + -> (is_IntConLevel(X4,Y4) + -> gecode_constraint_sorted_440(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(sorted(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(sorted(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(sorted(X0,X1,X2,X3,X4),arg=3))) + ; throw(gecode_argument_error(sorted(X0,X1,X2,X3,X4),arg=2))) + ; throw(gecode_argument_error(sorted(X0,X1,X2,X3,X4),arg=1))). + +circuit(X0,X1,X2,X3,X4) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntArgs(X1,Y1) + -> (is_int(X2,Y2) + -> (is_IntVarArgs(X3,Y3) + -> (is_IntVar(X4,Y4) + -> gecode_constraint_circuit_80(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(circuit(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(circuit(X0,X1,X2,X3,X4),arg=4))) + ; (is_IntVarArgs(X2,Y2) + -> (is_IntVar(X3,Y3) + -> (is_IntConLevel(X4,Y4) + -> gecode_constraint_circuit_77(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(circuit(X0,X1,X2,X3,X4),arg=5))) + ; (is_IntVarArgs(X3,Y3) + -> (is_IntVar(X4,Y4) + -> gecode_constraint_circuit_74(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(circuit(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(circuit(X0,X1,X2,X3,X4),arg=4)))) + ; throw(gecode_argument_error(circuit(X0,X1,X2,X3,X4),arg=3)))) + ; throw(gecode_argument_error(circuit(X0,X1,X2,X3,X4),arg=2))) + ; throw(gecode_argument_error(circuit(X0,X1,X2,X3,X4),arg=1))). + +dom(X0,X1,X2,X3) :- + (is_Space_or_Clause(X0,Y0) + -> (is_FloatVar(X1,Y1) + -> (is_FloatVal(X2,Y2) + -> (is_Reify(X3,Y3) + -> gecode_constraint_dom_189(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3),arg=4))) + ; (is_FloatNum(X2,Y2) + -> (is_FloatNum(X3,Y3) + -> gecode_constraint_dom_186(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3),arg=3)))) + ; (is_FloatVarArgs(X1,Y1) + -> (is_FloatNum(X2,Y2) + -> (is_FloatNum(X3,Y3) + -> gecode_constraint_dom_172(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3),arg=3))) + ; (is_BoolVarArgs(X1,Y1) + -> (is_BoolVarArgs(X2,Y2) + -> (is_IntConLevel(X3,Y3) + -> gecode_constraint_dom_170(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3),arg=3))) + ; (is_BoolVar(X1,Y1) + -> (is_BoolVar(X2,Y2) + -> (is_IntConLevel(X3,Y3) + -> gecode_constraint_dom_168(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3),arg=3))) + ; (is_IntVarArgs(X1,Y1) + -> (is_int(X2,Y2) + -> (is_int(X3,Y3) + -> gecode_constraint_dom_180(Y0,Y1,Y2,Y3) + ; (is_IntConLevel(X3,Y3) + -> gecode_constraint_dom_179(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3),arg=4)))) + ; (is_IntVarArgs(X2,Y2) + -> (is_IntConLevel(X3,Y3) + -> gecode_constraint_dom_177(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3),arg=4))) + ; (is_IntSet(X2,Y2) + -> (is_IntConLevel(X3,Y3) + -> gecode_constraint_dom_175(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3),arg=3))))) + ; (is_IntVar(X1,Y1) + -> (is_int(X2,Y2) + -> (is_int(X3,Y3) + -> gecode_constraint_dom_197(Y0,Y1,Y2,Y3) + ; (is_Reify(X3,Y3) + -> gecode_constraint_dom_201(Y0,Y1,Y2,Y3) + ; (is_IntConLevel(X3,Y3) + -> gecode_constraint_dom_196(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3),arg=4))))) + ; (is_IntVar(X2,Y2) + -> (is_IntConLevel(X3,Y3) + -> gecode_constraint_dom_204(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3),arg=4))) + ; (is_IntSet(X2,Y2) + -> (is_Reify(X3,Y3) + -> gecode_constraint_dom_193(Y0,Y1,Y2,Y3) + ; (is_IntConLevel(X3,Y3) + -> gecode_constraint_dom_192(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3),arg=4)))) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3),arg=3))))) + ; (is_SetVarArgs(X1,Y1) + -> (is_SetRelType(X2,Y2) + -> (is_int(X3,Y3) + -> gecode_constraint_dom_184(Y0,Y1,Y2,Y3) + ; (is_IntSet(X3,Y3) + -> gecode_constraint_dom_183(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3),arg=4)))) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3),arg=3))) + ; (is_SetVar(X1,Y1) + -> (is_SetRelType(X2,Y2) + -> (is_int(X3,Y3) + -> gecode_constraint_dom_207(Y0,Y1,Y2,Y3) + ; (is_IntSet(X3,Y3) + -> gecode_constraint_dom_205(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3),arg=4)))) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3),arg=3))) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3),arg=2)))))))))) + ; throw(gecode_argument_error(dom(X0,X1,X2,X3),arg=1))). + +abs(X0,X1,X2) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVar(X1,Y1) + -> (is_IntVar(X2,Y2) + -> gecode_constraint_abs_51(Y0,Y1,Y2) + ; throw(gecode_argument_error(abs(X0,X1,X2),arg=3))) + ; (is_FloatVar(X1,Y1) + -> (is_FloatVar(X2,Y2) + -> gecode_constraint_abs_50(Y0,Y1,Y2) + ; throw(gecode_argument_error(abs(X0,X1,X2),arg=3))) + ; throw(gecode_argument_error(abs(X0,X1,X2),arg=2)))) + ; throw(gecode_argument_error(abs(X0,X1,X2),arg=1))). + +channel(X0,X1,X2,X3,X4) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> (is_int(X2,Y2) + -> (is_IntVarArgs(X3,Y3) + -> (is_int(X4,Y4) + -> gecode_constraint_channel_68(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(channel(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(channel(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(channel(X0,X1,X2,X3,X4),arg=3))) + ; (is_BoolVarArgs(X1,Y1) + -> (is_IntVar(X2,Y2) + -> (is_int(X3,Y3) + -> (is_IntConLevel(X4,Y4) + -> gecode_constraint_channel_63(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(channel(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(channel(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(channel(X0,X1,X2,X3,X4),arg=3))) + ; throw(gecode_argument_error(channel(X0,X1,X2,X3,X4),arg=2)))) + ; throw(gecode_argument_error(channel(X0,X1,X2,X3,X4),arg=1))). + +assign(X0,X1,X2,X3,X4) :- + (is_Space_or_Clause(X0,Y0) + -> (is_FloatVarArgs(X1,Y1) + -> (is_FloatAssign(X2,Y2) + -> (is_FloatBranchFilter(X3,Y3) + -> (is_FloatVarValPrint(X4,Y4) + -> gecode_constraint_assign_8(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(assign(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(assign(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(assign(X0,X1,X2,X3,X4),arg=3))) + ; (is_BoolVarArgs(X1,Y1) + -> (is_IntAssign(X2,Y2) + -> (is_BoolBranchFilter(X3,Y3) + -> (is_BoolVarValPrint(X4,Y4) + -> gecode_constraint_assign_5(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(assign(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(assign(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(assign(X0,X1,X2,X3,X4),arg=3))) + ; (is_IntVarArgs(X1,Y1) + -> (is_IntAssign(X2,Y2) + -> (is_IntBranchFilter(X3,Y3) + -> (is_IntVarValPrint(X4,Y4) + -> gecode_constraint_assign_11(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(assign(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(assign(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(assign(X0,X1,X2,X3,X4),arg=3))) + ; (is_SetVarArgs(X1,Y1) + -> (is_SetAssign(X2,Y2) + -> (is_SetBranchFilter(X3,Y3) + -> (is_SetVarValPrint(X4,Y4) + -> gecode_constraint_assign_14(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(assign(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(assign(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(assign(X0,X1,X2,X3,X4),arg=3))) + ; throw(gecode_argument_error(assign(X0,X1,X2,X3,X4),arg=2)))))) + ; throw(gecode_argument_error(assign(X0,X1,X2,X3,X4),arg=1))). + +rel(X0,X1,X2) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> (is_IntRelType(X2,Y2) + -> gecode_constraint_rel_399(Y0,Y1,Y2) + ; throw(gecode_argument_error(rel(X0,X1,X2),arg=3))) + ; (is_BoolVarArgs(X1,Y1) + -> (is_IntRelType(X2,Y2) + -> gecode_constraint_rel_389(Y0,Y1,Y2) + ; throw(gecode_argument_error(rel(X0,X1,X2),arg=3))) + ; throw(gecode_argument_error(rel(X0,X1,X2),arg=2)))) + ; throw(gecode_argument_error(rel(X0,X1,X2),arg=1))). + +path(X0,X1,X2,X3) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> (is_IntVar(X2,Y2) + -> (is_IntVar(X3,Y3) + -> gecode_constraint_path_356(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(path(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3),arg=3))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3),arg=2))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3),arg=1))). + +branch(X0,X1,X2,X3) :- + (is_Space_or_Clause(X0,Y0) + -> (is_FloatVar(X1,Y1) + -> (is_FloatValBranch(X2,Y2) + -> (is_FloatVarValPrint(X3,Y3) + -> gecode_constraint_branch_45(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3),arg=3))) + ; (is_FloatVarArgs(X1,Y1) + -> (is_FloatVarBranch(X2,Y2) + -> (is_FloatValBranch(X3,Y3) + -> gecode_constraint_branch_29(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3),arg=3))) + ; (is_BoolVarArgs(X1,Y1) + -> (is_IntVarBranch(X2,Y2) + -> (is_IntValBranch(X3,Y3) + -> gecode_constraint_branch_23(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3),arg=3))) + ; (is_BoolVar(X1,Y1) + -> (is_IntValBranch(X2,Y2) + -> (is_BoolVarValPrint(X3,Y3) + -> gecode_constraint_branch_22(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3),arg=3))) + ; (is_IntVarArgs(X1,Y1) + -> (is_IntVarBranch(X2,Y2) + -> (is_IntValBranch(X3,Y3) + -> gecode_constraint_branch_35(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3),arg=3))) + ; (is_IntVar(X1,Y1) + -> (is_IntValBranch(X2,Y2) + -> (is_IntVarValPrint(X3,Y3) + -> gecode_constraint_branch_47(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3),arg=3))) + ; (is_SetVarArgs(X1,Y1) + -> (is_SetVarBranch(X2,Y2) + -> (is_SetValBranch(X3,Y3) + -> gecode_constraint_branch_41(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3),arg=3))) + ; (is_SetVar(X1,Y1) + -> (is_SetValBranch(X2,Y2) + -> (is_SetVarValPrint(X3,Y3) + -> gecode_constraint_branch_49(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3),arg=3))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3),arg=2)))))))))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3),arg=1))). + +mult(X0,X1,X2,X3,X4) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVar(X1,Y1) + -> (is_IntVar(X2,Y2) + -> (is_IntVar(X3,Y3) + -> (is_IntConLevel(X4,Y4) + -> gecode_constraint_mult_326(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(mult(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(mult(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(mult(X0,X1,X2,X3,X4),arg=3))) + ; throw(gecode_argument_error(mult(X0,X1,X2,X3,X4),arg=2))) + ; throw(gecode_argument_error(mult(X0,X1,X2,X3,X4),arg=1))). + +circuit(X0,X1,X2,X3,X4,X5) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntArgs(X1,Y1) + -> (is_int(X2,Y2) + -> (is_IntVarArgs(X3,Y3) + -> (is_IntVar(X4,Y4) + -> (is_IntConLevel(X5,Y5) + -> gecode_constraint_circuit_81(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(circuit(X0,X1,X2,X3,X4,X5),arg=6))) + ; (is_IntVarArgs(X4,Y4) + -> (is_IntVar(X5,Y5) + -> gecode_constraint_circuit_78(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(circuit(X0,X1,X2,X3,X4,X5),arg=6))) + ; throw(gecode_argument_error(circuit(X0,X1,X2,X3,X4,X5),arg=5)))) + ; throw(gecode_argument_error(circuit(X0,X1,X2,X3,X4,X5),arg=4))) + ; (is_IntVarArgs(X2,Y2) + -> (is_IntVarArgs(X3,Y3) + -> (is_IntVar(X4,Y4) + -> (is_IntConLevel(X5,Y5) + -> gecode_constraint_circuit_75(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(circuit(X0,X1,X2,X3,X4,X5),arg=6))) + ; throw(gecode_argument_error(circuit(X0,X1,X2,X3,X4,X5),arg=5))) + ; throw(gecode_argument_error(circuit(X0,X1,X2,X3,X4,X5),arg=4))) + ; throw(gecode_argument_error(circuit(X0,X1,X2,X3,X4,X5),arg=3)))) + ; throw(gecode_argument_error(circuit(X0,X1,X2,X3,X4,X5),arg=2))) + ; throw(gecode_argument_error(circuit(X0,X1,X2,X3,X4,X5),arg=1))). + +clause(X0,X1,X2,X3,X4) :- + (is_Space_or_Clause(X0,Y0) + -> (is_BoolOpType(X1,Y1) + -> (is_BoolVarArgs(X2,Y2) + -> (is_BoolVarArgs(X3,Y3) + -> (is_int(X4,Y4) + -> gecode_constraint_clause_88(Y0,Y1,Y2,Y3,Y4) + ; (is_BoolVar(X4,Y4) + -> gecode_constraint_clause_86(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(clause(X0,X1,X2,X3,X4),arg=5)))) + ; throw(gecode_argument_error(clause(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(clause(X0,X1,X2,X3,X4),arg=3))) + ; throw(gecode_argument_error(clause(X0,X1,X2,X3,X4),arg=2))) + ; throw(gecode_argument_error(clause(X0,X1,X2,X3,X4),arg=1))). + +precede(X0,X1,X2,X3) :- + (is_Space_or_Clause(X0,Y0) + -> (is_SetVarArgs(X1,Y1) + -> (is_int(X2,Y2) + -> (is_int(X3,Y3) + -> gecode_constraint_precede_368(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(precede(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(precede(X0,X1,X2,X3),arg=3))) + ; (is_IntVarArgs(X1,Y1) + -> (is_int(X2,Y2) + -> (is_int(X3,Y3) + -> gecode_constraint_precede_365(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(precede(X0,X1,X2,X3),arg=4))) + ; (is_IntArgs(X2,Y2) + -> (is_IntConLevel(X3,Y3) + -> gecode_constraint_precede_364(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(precede(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(precede(X0,X1,X2,X3),arg=3)))) + ; throw(gecode_argument_error(precede(X0,X1,X2,X3),arg=2)))) + ; throw(gecode_argument_error(precede(X0,X1,X2,X3),arg=1))). + +channel(X0,X1,X2,X3,X4,X5) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> (is_int(X2,Y2) + -> (is_IntVarArgs(X3,Y3) + -> (is_int(X4,Y4) + -> (is_IntConLevel(X5,Y5) + -> gecode_constraint_channel_69(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(channel(X0,X1,X2,X3,X4,X5),arg=6))) + ; throw(gecode_argument_error(channel(X0,X1,X2,X3,X4,X5),arg=5))) + ; throw(gecode_argument_error(channel(X0,X1,X2,X3,X4,X5),arg=4))) + ; throw(gecode_argument_error(channel(X0,X1,X2,X3,X4,X5),arg=3))) + ; throw(gecode_argument_error(channel(X0,X1,X2,X3,X4,X5),arg=2))) + ; throw(gecode_argument_error(channel(X0,X1,X2,X3,X4,X5),arg=1))). + +cumulative(X0,X1,X2,X3,X4,X5,X6) :- + (is_Space_or_Clause(X0,Y0) + -> (is_int(X1,Y1) + -> (is_TaskTypeArgs(X2,Y2) + -> (is_IntVarArgs(X3,Y3) + -> (is_IntArgs(X4,Y4) + -> (is_IntArgs(X5,Y5) + -> (is_BoolVarArgs(X6,Y6) + -> gecode_constraint_cumulative_126(Y0,Y1,Y2,Y3,Y4,Y5,Y6) + ; (is_IntConLevel(X6,Y6) + -> gecode_constraint_cumulative_129(Y0,Y1,Y2,Y3,Y4,Y5,Y6) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6),arg=7)))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6),arg=6))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6),arg=5))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6),arg=4))) + ; (is_IntVarArgs(X2,Y2) + -> (is_IntVarArgs(X3,Y3) + -> (is_IntVarArgs(X4,Y4) + -> (is_IntArgs(X5,Y5) + -> (is_BoolVarArgs(X6,Y6) + -> gecode_constraint_cumulative_122(Y0,Y1,Y2,Y3,Y4,Y5,Y6) + ; (is_IntConLevel(X6,Y6) + -> gecode_constraint_cumulative_125(Y0,Y1,Y2,Y3,Y4,Y5,Y6) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6),arg=7)))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6),arg=6))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6),arg=5))) + ; (is_IntArgs(X3,Y3) + -> (is_IntArgs(X4,Y4) + -> (is_BoolVarArgs(X5,Y5) + -> (is_IntConLevel(X6,Y6) + -> gecode_constraint_cumulative_119(Y0,Y1,Y2,Y3,Y4,Y5,Y6) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6),arg=7))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6),arg=6))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6),arg=5))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6),arg=4)))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6),arg=3)))) + ; (is_IntVar(X1,Y1) + -> (is_TaskTypeArgs(X2,Y2) + -> (is_IntVarArgs(X3,Y3) + -> (is_IntArgs(X4,Y4) + -> (is_IntArgs(X5,Y5) + -> (is_BoolVarArgs(X6,Y6) + -> gecode_constraint_cumulative_138(Y0,Y1,Y2,Y3,Y4,Y5,Y6) + ; (is_IntConLevel(X6,Y6) + -> gecode_constraint_cumulative_141(Y0,Y1,Y2,Y3,Y4,Y5,Y6) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6),arg=7)))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6),arg=6))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6),arg=5))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6),arg=4))) + ; (is_IntVarArgs(X2,Y2) + -> (is_IntVarArgs(X3,Y3) + -> (is_IntVarArgs(X4,Y4) + -> (is_IntArgs(X5,Y5) + -> (is_BoolVarArgs(X6,Y6) + -> gecode_constraint_cumulative_134(Y0,Y1,Y2,Y3,Y4,Y5,Y6) + ; (is_IntConLevel(X6,Y6) + -> gecode_constraint_cumulative_137(Y0,Y1,Y2,Y3,Y4,Y5,Y6) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6),arg=7)))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6),arg=6))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6),arg=5))) + ; (is_IntArgs(X3,Y3) + -> (is_IntArgs(X4,Y4) + -> (is_BoolVarArgs(X5,Y5) + -> (is_IntConLevel(X6,Y6) + -> gecode_constraint_cumulative_131(Y0,Y1,Y2,Y3,Y4,Y5,Y6) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6),arg=7))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6),arg=6))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6),arg=5))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6),arg=4)))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6),arg=3)))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6),arg=2)))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6),arg=1))). + +distinct(X0,X1,X2) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> (is_IntConLevel(X2,Y2) + -> gecode_constraint_distinct_161(Y0,Y1,Y2) + ; throw(gecode_argument_error(distinct(X0,X1,X2),arg=3))) + ; (is_IntArgs(X1,Y1) + -> (is_IntVarArgs(X2,Y2) + -> gecode_constraint_distinct_158(Y0,Y1,Y2) + ; throw(gecode_argument_error(distinct(X0,X1,X2),arg=3))) + ; throw(gecode_argument_error(distinct(X0,X1,X2),arg=2)))) + ; throw(gecode_argument_error(distinct(X0,X1,X2),arg=1))). + +member(X0,X1,X2,X3,X4) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> (is_IntVar(X2,Y2) + -> (is_Reify(X3,Y3) + -> (is_IntConLevel(X4,Y4) + -> gecode_constraint_member_313(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(member(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(member(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(member(X0,X1,X2,X3,X4),arg=3))) + ; (is_BoolVarArgs(X1,Y1) + -> (is_BoolVar(X2,Y2) + -> (is_Reify(X3,Y3) + -> (is_IntConLevel(X4,Y4) + -> gecode_constraint_member_309(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(member(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(member(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(member(X0,X1,X2,X3,X4),arg=3))) + ; throw(gecode_argument_error(member(X0,X1,X2,X3,X4),arg=2)))) + ; throw(gecode_argument_error(member(X0,X1,X2,X3,X4),arg=1))). + +mod(X0,X1,X2,X3) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVar(X1,Y1) + -> (is_IntVar(X2,Y2) + -> (is_IntVar(X3,Y3) + -> gecode_constraint_mod_322(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(mod(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(mod(X0,X1,X2,X3),arg=3))) + ; throw(gecode_argument_error(mod(X0,X1,X2,X3),arg=2))) + ; throw(gecode_argument_error(mod(X0,X1,X2,X3),arg=1))). + +sqr(X0,X1,X2) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVar(X1,Y1) + -> (is_IntVar(X2,Y2) + -> gecode_constraint_sqr_444(Y0,Y1,Y2) + ; throw(gecode_argument_error(sqr(X0,X1,X2),arg=3))) + ; (is_FloatVar(X1,Y1) + -> (is_FloatVar(X2,Y2) + -> gecode_constraint_sqr_443(Y0,Y1,Y2) + ; throw(gecode_argument_error(sqr(X0,X1,X2),arg=3))) + ; throw(gecode_argument_error(sqr(X0,X1,X2),arg=2)))) + ; throw(gecode_argument_error(sqr(X0,X1,X2),arg=1))). + +sequence(X0,X1,X2,X3,X4,X5,X6) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> (is_IntSet(X2,Y2) + -> (is_int(X3,Y3) + -> (is_int(X4,Y4) + -> (is_int(X5,Y5) + -> (is_IntConLevel(X6,Y6) + -> gecode_constraint_sequence_436(Y0,Y1,Y2,Y3,Y4,Y5,Y6) + ; throw(gecode_argument_error(sequence(X0,X1,X2,X3,X4,X5,X6),arg=7))) + ; throw(gecode_argument_error(sequence(X0,X1,X2,X3,X4,X5,X6),arg=6))) + ; throw(gecode_argument_error(sequence(X0,X1,X2,X3,X4,X5,X6),arg=5))) + ; throw(gecode_argument_error(sequence(X0,X1,X2,X3,X4,X5,X6),arg=4))) + ; throw(gecode_argument_error(sequence(X0,X1,X2,X3,X4,X5,X6),arg=3))) + ; (is_BoolVarArgs(X1,Y1) + -> (is_IntSet(X2,Y2) + -> (is_int(X3,Y3) + -> (is_int(X4,Y4) + -> (is_int(X5,Y5) + -> (is_IntConLevel(X6,Y6) + -> gecode_constraint_sequence_434(Y0,Y1,Y2,Y3,Y4,Y5,Y6) + ; throw(gecode_argument_error(sequence(X0,X1,X2,X3,X4,X5,X6),arg=7))) + ; throw(gecode_argument_error(sequence(X0,X1,X2,X3,X4,X5,X6),arg=6))) + ; throw(gecode_argument_error(sequence(X0,X1,X2,X3,X4,X5,X6),arg=5))) + ; throw(gecode_argument_error(sequence(X0,X1,X2,X3,X4,X5,X6),arg=4))) + ; throw(gecode_argument_error(sequence(X0,X1,X2,X3,X4,X5,X6),arg=3))) + ; throw(gecode_argument_error(sequence(X0,X1,X2,X3,X4,X5,X6),arg=2)))) + ; throw(gecode_argument_error(sequence(X0,X1,X2,X3,X4,X5,X6),arg=1))). + +path(X0,X1,X2,X3,X4,X5,X6) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntArgs(X1,Y1) + -> (is_int(X2,Y2) + -> (is_IntVarArgs(X3,Y3) + -> (is_IntVar(X4,Y4) + -> (is_IntVar(X5,Y5) + -> (is_IntVar(X6,Y6) + -> gecode_constraint_path_354(Y0,Y1,Y2,Y3,Y4,Y5,Y6) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5,X6),arg=7))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5,X6),arg=6))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5,X6),arg=5))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5,X6),arg=4))) + ; (is_IntVarArgs(X2,Y2) + -> (is_IntVar(X3,Y3) + -> (is_IntVar(X4,Y4) + -> (is_IntVar(X5,Y5) + -> (is_IntConLevel(X6,Y6) + -> gecode_constraint_path_351(Y0,Y1,Y2,Y3,Y4,Y5,Y6) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5,X6),arg=7))) + ; (is_IntVarArgs(X5,Y5) + -> (is_IntVar(X6,Y6) + -> gecode_constraint_path_348(Y0,Y1,Y2,Y3,Y4,Y5,Y6) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5,X6),arg=7))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5,X6),arg=6)))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5,X6),arg=5))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5,X6),arg=4))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5,X6),arg=3)))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5,X6),arg=2))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5,X6),arg=1))). + +divmod(X0,X1,X2,X3,X4,X5) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVar(X1,Y1) + -> (is_IntVar(X2,Y2) + -> (is_IntVar(X3,Y3) + -> (is_IntVar(X4,Y4) + -> (is_IntConLevel(X5,Y5) + -> gecode_constraint_divmod_166(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(divmod(X0,X1,X2,X3,X4,X5),arg=6))) + ; throw(gecode_argument_error(divmod(X0,X1,X2,X3,X4,X5),arg=5))) + ; throw(gecode_argument_error(divmod(X0,X1,X2,X3,X4,X5),arg=4))) + ; throw(gecode_argument_error(divmod(X0,X1,X2,X3,X4,X5),arg=3))) + ; throw(gecode_argument_error(divmod(X0,X1,X2,X3,X4,X5),arg=2))) + ; throw(gecode_argument_error(divmod(X0,X1,X2,X3,X4,X5),arg=1))). + +sorted(X0,X1,X2) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> (is_IntVarArgs(X2,Y2) + -> gecode_constraint_sorted_441(Y0,Y1,Y2) + ; throw(gecode_argument_error(sorted(X0,X1,X2),arg=3))) + ; throw(gecode_argument_error(sorted(X0,X1,X2),arg=2))) + ; throw(gecode_argument_error(sorted(X0,X1,X2),arg=1))). + +extensional(X0,X1,X2,X3) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> (is_TupleSet(X2,Y2) + -> (is_ExtensionalPropKind(X3,Y3) + -> gecode_constraint_extensional_252(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(extensional(X0,X1,X2,X3),arg=4))) + ; (is_DFA(X2,Y2) + -> (is_IntConLevel(X3,Y3) + -> gecode_constraint_extensional_255(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(extensional(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(extensional(X0,X1,X2,X3),arg=3)))) + ; (is_BoolVarArgs(X1,Y1) + -> (is_TupleSet(X2,Y2) + -> (is_ExtensionalPropKind(X3,Y3) + -> gecode_constraint_extensional_247(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(extensional(X0,X1,X2,X3),arg=4))) + ; (is_DFA(X2,Y2) + -> (is_IntConLevel(X3,Y3) + -> gecode_constraint_extensional_250(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(extensional(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(extensional(X0,X1,X2,X3),arg=3)))) + ; throw(gecode_argument_error(extensional(X0,X1,X2,X3),arg=2)))) + ; throw(gecode_argument_error(extensional(X0,X1,X2,X3),arg=1))). + +circuit(X0,X1,X2) :- + (is_Space_or_Clause(X0,Y0) + -> (is_int(X1,Y1) + -> (is_IntVarArgs(X2,Y2) + -> gecode_constraint_circuit_84(Y0,Y1,Y2) + ; throw(gecode_argument_error(circuit(X0,X1,X2),arg=3))) + ; (is_IntVarArgs(X1,Y1) + -> (is_IntConLevel(X2,Y2) + -> gecode_constraint_circuit_83(Y0,Y1,Y2) + ; throw(gecode_argument_error(circuit(X0,X1,X2),arg=3))) + ; throw(gecode_argument_error(circuit(X0,X1,X2),arg=2)))) + ; throw(gecode_argument_error(circuit(X0,X1,X2),arg=1))). + +channel(X0,X1,X2) :- + (is_Space_or_Clause(X0,Y0) + -> (is_FloatVar(X1,Y1) + -> (is_IntVar(X2,Y2) + -> gecode_constraint_channel_71(Y0,Y1,Y2) + ; throw(gecode_argument_error(channel(X0,X1,X2),arg=3))) + ; (is_BoolVarArgs(X1,Y1) + -> (is_IntVar(X2,Y2) + -> gecode_constraint_channel_61(Y0,Y1,Y2) + ; (is_SetVar(X2,Y2) + -> gecode_constraint_channel_64(Y0,Y1,Y2) + ; throw(gecode_argument_error(channel(X0,X1,X2),arg=3)))) + ; (is_BoolVar(X1,Y1) + -> (is_IntVar(X2,Y2) + -> gecode_constraint_channel_59(Y0,Y1,Y2) + ; throw(gecode_argument_error(channel(X0,X1,X2),arg=3))) + ; (is_IntVarArgs(X1,Y1) + -> (is_SetVarArgs(X2,Y2) + -> gecode_constraint_channel_67(Y0,Y1,Y2) + ; (is_IntVarArgs(X2,Y2) + -> gecode_constraint_channel_65(Y0,Y1,Y2) + ; throw(gecode_argument_error(channel(X0,X1,X2),arg=3)))) + ; (is_IntVar(X1,Y1) + -> (is_FloatVar(X2,Y2) + -> gecode_constraint_channel_72(Y0,Y1,Y2) + ; throw(gecode_argument_error(channel(X0,X1,X2),arg=3))) + ; (is_SetVarArgs(X1,Y1) + -> (is_SetVarArgs(X2,Y2) + -> gecode_constraint_channel_70(Y0,Y1,Y2) + ; throw(gecode_argument_error(channel(X0,X1,X2),arg=3))) + ; throw(gecode_argument_error(channel(X0,X1,X2),arg=2)))))))) + ; throw(gecode_argument_error(channel(X0,X1,X2),arg=1))). + +count(X0,X1,X2,X3,X4) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> (is_IntArgs(X2,Y2) + -> (is_IntRelType(X3,Y3) + -> (is_int(X4,Y4) + -> gecode_constraint_count_92(Y0,Y1,Y2,Y3,Y4) + ; (is_IntVar(X4,Y4) + -> gecode_constraint_count_94(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(count(X0,X1,X2,X3,X4),arg=5)))) + ; throw(gecode_argument_error(count(X0,X1,X2,X3,X4),arg=4))) + ; (is_int(X2,Y2) + -> (is_IntRelType(X3,Y3) + -> (is_int(X4,Y4) + -> gecode_constraint_count_110(Y0,Y1,Y2,Y3,Y4) + ; (is_IntVar(X4,Y4) + -> gecode_constraint_count_112(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(count(X0,X1,X2,X3,X4),arg=5)))) + ; throw(gecode_argument_error(count(X0,X1,X2,X3,X4),arg=4))) + ; (is_IntSet(X2,Y2) + -> (is_IntRelType(X3,Y3) + -> (is_int(X4,Y4) + -> gecode_constraint_count_102(Y0,Y1,Y2,Y3,Y4) + ; (is_IntVar(X4,Y4) + -> gecode_constraint_count_104(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(count(X0,X1,X2,X3,X4),arg=5)))) + ; (is_IntArgs(X3,Y3) + -> (is_IntConLevel(X4,Y4) + -> gecode_constraint_count_101(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(count(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(count(X0,X1,X2,X3,X4),arg=4)))) + ; (is_IntSetArgs(X2,Y2) + -> (is_IntArgs(X3,Y3) + -> (is_IntConLevel(X4,Y4) + -> gecode_constraint_count_97(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(count(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(count(X0,X1,X2,X3,X4),arg=4))) + ; (is_IntVarArgs(X2,Y2) + -> (is_IntArgs(X3,Y3) + -> (is_IntConLevel(X4,Y4) + -> gecode_constraint_count_107(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(count(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(count(X0,X1,X2,X3,X4),arg=4))) + ; (is_IntVar(X2,Y2) + -> (is_IntRelType(X3,Y3) + -> (is_int(X4,Y4) + -> gecode_constraint_count_114(Y0,Y1,Y2,Y3,Y4) + ; (is_IntVar(X4,Y4) + -> gecode_constraint_count_116(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(count(X0,X1,X2,X3,X4),arg=5)))) + ; throw(gecode_argument_error(count(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(count(X0,X1,X2,X3,X4),arg=3)))))))) + ; throw(gecode_argument_error(count(X0,X1,X2,X3,X4),arg=2))) + ; throw(gecode_argument_error(count(X0,X1,X2,X3,X4),arg=1))). + +cumulatives(X0,X1,X2,X3,X4,X5,X6,X7) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> (is_IntVarArgs(X2,Y2) + -> (is_IntVarArgs(X3,Y3) + -> (is_IntVarArgs(X4,Y4) + -> (is_IntVarArgs(X5,Y5) + -> (is_IntArgs(X6,Y6) + -> (is_bool(X7,Y7) + -> gecode_constraint_cumulatives_156(Y0,Y1,Y2,Y3,Y4,Y5,Y6,Y7) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7),arg=8))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7),arg=7))) + ; (is_IntArgs(X5,Y5) + -> (is_IntArgs(X6,Y6) + -> (is_bool(X7,Y7) + -> gecode_constraint_cumulatives_154(Y0,Y1,Y2,Y3,Y4,Y5,Y6,Y7) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7),arg=8))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7),arg=7))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7),arg=6)))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7),arg=5))) + ; (is_IntArgs(X3,Y3) + -> (is_IntVarArgs(X4,Y4) + -> (is_IntVarArgs(X5,Y5) + -> (is_IntArgs(X6,Y6) + -> (is_bool(X7,Y7) + -> gecode_constraint_cumulatives_152(Y0,Y1,Y2,Y3,Y4,Y5,Y6,Y7) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7),arg=8))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7),arg=7))) + ; (is_IntArgs(X5,Y5) + -> (is_IntArgs(X6,Y6) + -> (is_bool(X7,Y7) + -> gecode_constraint_cumulatives_150(Y0,Y1,Y2,Y3,Y4,Y5,Y6,Y7) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7),arg=8))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7),arg=7))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7),arg=6)))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7),arg=5))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7),arg=4)))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7),arg=3))) + ; (is_IntArgs(X1,Y1) + -> (is_IntVarArgs(X2,Y2) + -> (is_IntVarArgs(X3,Y3) + -> (is_IntVarArgs(X4,Y4) + -> (is_IntVarArgs(X5,Y5) + -> (is_IntArgs(X6,Y6) + -> (is_bool(X7,Y7) + -> gecode_constraint_cumulatives_148(Y0,Y1,Y2,Y3,Y4,Y5,Y6,Y7) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7),arg=8))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7),arg=7))) + ; (is_IntArgs(X5,Y5) + -> (is_IntArgs(X6,Y6) + -> (is_bool(X7,Y7) + -> gecode_constraint_cumulatives_146(Y0,Y1,Y2,Y3,Y4,Y5,Y6,Y7) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7),arg=8))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7),arg=7))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7),arg=6)))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7),arg=5))) + ; (is_IntArgs(X3,Y3) + -> (is_IntVarArgs(X4,Y4) + -> (is_IntVarArgs(X5,Y5) + -> (is_IntArgs(X6,Y6) + -> (is_bool(X7,Y7) + -> gecode_constraint_cumulatives_144(Y0,Y1,Y2,Y3,Y4,Y5,Y6,Y7) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7),arg=8))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7),arg=7))) + ; (is_IntArgs(X5,Y5) + -> (is_IntArgs(X6,Y6) + -> (is_bool(X7,Y7) + -> gecode_constraint_cumulatives_142(Y0,Y1,Y2,Y3,Y4,Y5,Y6,Y7) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7),arg=8))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7),arg=7))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7),arg=6)))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7),arg=5))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7),arg=4)))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7),arg=3))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7),arg=2)))) + ; throw(gecode_argument_error(cumulatives(X0,X1,X2,X3,X4,X5,X6,X7),arg=1))). + +binpacking(X0,X1,X2,X3,X4) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> (is_IntVarArgs(X2,Y2) + -> (is_IntArgs(X3,Y3) + -> (is_IntConLevel(X4,Y4) + -> gecode_constraint_binpacking_55(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(binpacking(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(binpacking(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(binpacking(X0,X1,X2,X3,X4),arg=3))) + ; throw(gecode_argument_error(binpacking(X0,X1,X2,X3,X4),arg=2))) + ; throw(gecode_argument_error(binpacking(X0,X1,X2,X3,X4),arg=1))). + +extensional(X0,X1,X2) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> (is_TupleSet(X2,Y2) + -> gecode_constraint_extensional_251(Y0,Y1,Y2) + ; (is_DFA(X2,Y2) + -> gecode_constraint_extensional_254(Y0,Y1,Y2) + ; throw(gecode_argument_error(extensional(X0,X1,X2),arg=3)))) + ; (is_BoolVarArgs(X1,Y1) + -> (is_TupleSet(X2,Y2) + -> gecode_constraint_extensional_246(Y0,Y1,Y2) + ; (is_DFA(X2,Y2) + -> gecode_constraint_extensional_249(Y0,Y1,Y2) + ; throw(gecode_argument_error(extensional(X0,X1,X2),arg=3)))) + ; throw(gecode_argument_error(extensional(X0,X1,X2),arg=2)))) + ; throw(gecode_argument_error(extensional(X0,X1,X2),arg=1))). + +linear(X0,X1,X2,X3,X4,X5) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> (is_IntRelType(X2,Y2) + -> (is_int(X3,Y3) + -> (is_Reify(X4,Y4) + -> (is_IntConLevel(X5,Y5) + -> gecode_constraint_linear_293(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4,X5),arg=6))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4,X5),arg=5))) + ; (is_IntVar(X3,Y3) + -> (is_Reify(X4,Y4) + -> (is_IntConLevel(X5,Y5) + -> gecode_constraint_linear_297(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4,X5),arg=6))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4,X5),arg=5))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4,X5),arg=4)))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4,X5),arg=3))) + ; (is_BoolVarArgs(X1,Y1) + -> (is_IntRelType(X2,Y2) + -> (is_int(X3,Y3) + -> (is_Reify(X4,Y4) + -> (is_IntConLevel(X5,Y5) + -> gecode_constraint_linear_261(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4,X5),arg=6))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4,X5),arg=5))) + ; (is_IntVar(X3,Y3) + -> (is_Reify(X4,Y4) + -> (is_IntConLevel(X5,Y5) + -> gecode_constraint_linear_265(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4,X5),arg=6))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4,X5),arg=5))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4,X5),arg=4)))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4,X5),arg=3))) + ; (is_FloatValArgs(X1,Y1) + -> (is_FloatVarArgs(X2,Y2) + -> (is_FloatRelType(X3,Y3) + -> (is_FloatVar(X4,Y4) + -> (is_Reify(X5,Y5) + -> gecode_constraint_linear_269(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4,X5),arg=6))) + ; (is_FloatNum(X4,Y4) + -> (is_Reify(X5,Y5) + -> gecode_constraint_linear_267(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4,X5),arg=6))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4,X5),arg=5)))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4,X5),arg=4))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4,X5),arg=3))) + ; (is_IntArgs(X1,Y1) + -> (is_IntVarArgs(X2,Y2) + -> (is_IntRelType(X3,Y3) + -> (is_int(X4,Y4) + -> (is_Reify(X5,Y5) + -> gecode_constraint_linear_284(Y0,Y1,Y2,Y3,Y4,Y5) + ; (is_IntConLevel(X5,Y5) + -> gecode_constraint_linear_283(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4,X5),arg=6)))) + ; (is_IntVar(X4,Y4) + -> (is_Reify(X5,Y5) + -> gecode_constraint_linear_288(Y0,Y1,Y2,Y3,Y4,Y5) + ; (is_IntConLevel(X5,Y5) + -> gecode_constraint_linear_287(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4,X5),arg=6)))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4,X5),arg=5)))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4,X5),arg=4))) + ; (is_BoolVarArgs(X2,Y2) + -> (is_IntRelType(X3,Y3) + -> (is_int(X4,Y4) + -> (is_Reify(X5,Y5) + -> gecode_constraint_linear_276(Y0,Y1,Y2,Y3,Y4,Y5) + ; (is_IntConLevel(X5,Y5) + -> gecode_constraint_linear_275(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4,X5),arg=6)))) + ; (is_IntVar(X4,Y4) + -> (is_Reify(X5,Y5) + -> gecode_constraint_linear_280(Y0,Y1,Y2,Y3,Y4,Y5) + ; (is_IntConLevel(X5,Y5) + -> gecode_constraint_linear_279(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4,X5),arg=6)))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4,X5),arg=5)))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4,X5),arg=4))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4,X5),arg=3)))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4,X5),arg=2)))))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4,X5),arg=1))). + +nooverlap(X0,X1,X2,X3,X4,X5,X6) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> (is_IntVarArgs(X2,Y2) + -> (is_IntVarArgs(X3,Y3) + -> (is_IntVarArgs(X4,Y4) + -> (is_IntVarArgs(X5,Y5) + -> (is_IntVarArgs(X6,Y6) + -> gecode_constraint_nooverlap_333(Y0,Y1,Y2,Y3,Y4,Y5,Y6) + ; throw(gecode_argument_error(nooverlap(X0,X1,X2,X3,X4,X5,X6),arg=7))) + ; throw(gecode_argument_error(nooverlap(X0,X1,X2,X3,X4,X5,X6),arg=6))) + ; throw(gecode_argument_error(nooverlap(X0,X1,X2,X3,X4,X5,X6),arg=5))) + ; throw(gecode_argument_error(nooverlap(X0,X1,X2,X3,X4,X5,X6),arg=4))) + ; (is_IntArgs(X2,Y2) + -> (is_IntVarArgs(X3,Y3) + -> (is_IntArgs(X4,Y4) + -> (is_BoolVarArgs(X5,Y5) + -> (is_IntConLevel(X6,Y6) + -> gecode_constraint_nooverlap_328(Y0,Y1,Y2,Y3,Y4,Y5,Y6) + ; throw(gecode_argument_error(nooverlap(X0,X1,X2,X3,X4,X5,X6),arg=7))) + ; throw(gecode_argument_error(nooverlap(X0,X1,X2,X3,X4,X5,X6),arg=6))) + ; throw(gecode_argument_error(nooverlap(X0,X1,X2,X3,X4,X5,X6),arg=5))) + ; throw(gecode_argument_error(nooverlap(X0,X1,X2,X3,X4,X5,X6),arg=4))) + ; throw(gecode_argument_error(nooverlap(X0,X1,X2,X3,X4,X5,X6),arg=3)))) + ; throw(gecode_argument_error(nooverlap(X0,X1,X2,X3,X4,X5,X6),arg=2))) + ; throw(gecode_argument_error(nooverlap(X0,X1,X2,X3,X4,X5,X6),arg=1))). + +div(X0,X1,X2,X3,X4) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVar(X1,Y1) + -> (is_IntVar(X2,Y2) + -> (is_IntVar(X3,Y3) + -> (is_IntConLevel(X4,Y4) + -> gecode_constraint_div_164(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(div(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(div(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(div(X0,X1,X2,X3,X4),arg=3))) + ; throw(gecode_argument_error(div(X0,X1,X2,X3,X4),arg=2))) + ; throw(gecode_argument_error(div(X0,X1,X2,X3,X4),arg=1))). + +sqr(X0,X1,X2,X3) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVar(X1,Y1) + -> (is_IntVar(X2,Y2) + -> (is_IntConLevel(X3,Y3) + -> gecode_constraint_sqr_445(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(sqr(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(sqr(X0,X1,X2,X3),arg=3))) + ; throw(gecode_argument_error(sqr(X0,X1,X2,X3),arg=2))) + ; throw(gecode_argument_error(sqr(X0,X1,X2,X3),arg=1))). + +path(X0,X1,X2,X3,X4,X5,X6,X7) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntArgs(X1,Y1) + -> (is_int(X2,Y2) + -> (is_IntVarArgs(X3,Y3) + -> (is_IntVar(X4,Y4) + -> (is_IntVar(X5,Y5) + -> (is_IntVar(X6,Y6) + -> (is_IntConLevel(X7,Y7) + -> gecode_constraint_path_355(Y0,Y1,Y2,Y3,Y4,Y5,Y6,Y7) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5,X6,X7),arg=8))) + ; (is_IntVarArgs(X6,Y6) + -> (is_IntVar(X7,Y7) + -> gecode_constraint_path_352(Y0,Y1,Y2,Y3,Y4,Y5,Y6,Y7) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5,X6,X7),arg=8))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5,X6,X7),arg=7)))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5,X6,X7),arg=6))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5,X6,X7),arg=5))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5,X6,X7),arg=4))) + ; (is_IntVarArgs(X2,Y2) + -> (is_IntVar(X3,Y3) + -> (is_IntVar(X4,Y4) + -> (is_IntVarArgs(X5,Y5) + -> (is_IntVar(X6,Y6) + -> (is_IntConLevel(X7,Y7) + -> gecode_constraint_path_349(Y0,Y1,Y2,Y3,Y4,Y5,Y6,Y7) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5,X6,X7),arg=8))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5,X6,X7),arg=7))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5,X6,X7),arg=6))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5,X6,X7),arg=5))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5,X6,X7),arg=4))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5,X6,X7),arg=3)))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5,X6,X7),arg=2))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5,X6,X7),arg=1))). + +unary(X0,X1,X2,X3,X4) :- + (is_Space_or_Clause(X0,Y0) + -> (is_TaskTypeArgs(X1,Y1) + -> (is_IntVarArgs(X2,Y2) + -> (is_IntArgs(X3,Y3) + -> (is_BoolVarArgs(X4,Y4) + -> gecode_constraint_unary_457(Y0,Y1,Y2,Y3,Y4) + ; (is_IntConLevel(X4,Y4) + -> gecode_constraint_unary_460(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(unary(X0,X1,X2,X3,X4),arg=5)))) + ; throw(gecode_argument_error(unary(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(unary(X0,X1,X2,X3,X4),arg=3))) + ; (is_IntVarArgs(X1,Y1) + -> (is_IntVarArgs(X2,Y2) + -> (is_IntVarArgs(X3,Y3) + -> (is_BoolVarArgs(X4,Y4) + -> gecode_constraint_unary_453(Y0,Y1,Y2,Y3,Y4) + ; (is_IntConLevel(X4,Y4) + -> gecode_constraint_unary_456(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(unary(X0,X1,X2,X3,X4),arg=5)))) + ; throw(gecode_argument_error(unary(X0,X1,X2,X3,X4),arg=4))) + ; (is_IntArgs(X2,Y2) + -> (is_BoolVarArgs(X3,Y3) + -> (is_IntConLevel(X4,Y4) + -> gecode_constraint_unary_450(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(unary(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(unary(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(unary(X0,X1,X2,X3,X4),arg=3)))) + ; throw(gecode_argument_error(unary(X0,X1,X2,X3,X4),arg=2)))) + ; throw(gecode_argument_error(unary(X0,X1,X2,X3,X4),arg=1))). + +sorted(X0,X1,X2,X3) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> (is_IntVarArgs(X2,Y2) + -> (is_IntVarArgs(X3,Y3) + -> gecode_constraint_sorted_439(Y0,Y1,Y2,Y3) + ; (is_IntConLevel(X3,Y3) + -> gecode_constraint_sorted_442(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(sorted(X0,X1,X2,X3),arg=4)))) + ; throw(gecode_argument_error(sorted(X0,X1,X2,X3),arg=3))) + ; throw(gecode_argument_error(sorted(X0,X1,X2,X3),arg=2))) + ; throw(gecode_argument_error(sorted(X0,X1,X2,X3),arg=1))). + +element(X0,X1,X2,X3,X4,X5,X6,X7) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> (is_IntVar(X2,Y2) + -> (is_int(X3,Y3) + -> (is_IntVar(X4,Y4) + -> (is_int(X5,Y5) + -> (is_IntVar(X6,Y6) + -> (is_IntConLevel(X7,Y7) + -> gecode_constraint_element_223(Y0,Y1,Y2,Y3,Y4,Y5,Y6,Y7) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6,X7),arg=8))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6,X7),arg=7))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6,X7),arg=6))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6,X7),arg=5))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6,X7),arg=4))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6,X7),arg=3))) + ; (is_BoolVarArgs(X1,Y1) + -> (is_IntVar(X2,Y2) + -> (is_int(X3,Y3) + -> (is_IntVar(X4,Y4) + -> (is_int(X5,Y5) + -> (is_BoolVar(X6,Y6) + -> (is_IntConLevel(X7,Y7) + -> gecode_constraint_element_217(Y0,Y1,Y2,Y3,Y4,Y5,Y6,Y7) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6,X7),arg=8))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6,X7),arg=7))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6,X7),arg=6))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6,X7),arg=5))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6,X7),arg=4))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6,X7),arg=3))) + ; (is_IntArgs(X1,Y1) + -> (is_IntVar(X2,Y2) + -> (is_int(X3,Y3) + -> (is_IntVar(X4,Y4) + -> (is_int(X5,Y5) + -> (is_IntVar(X6,Y6) + -> (is_IntConLevel(X7,Y7) + -> gecode_constraint_element_235(Y0,Y1,Y2,Y3,Y4,Y5,Y6,Y7) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6,X7),arg=8))) + ; (is_BoolVar(X6,Y6) + -> (is_IntConLevel(X7,Y7) + -> gecode_constraint_element_233(Y0,Y1,Y2,Y3,Y4,Y5,Y6,Y7) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6,X7),arg=8))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6,X7),arg=7)))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6,X7),arg=6))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6,X7),arg=5))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6,X7),arg=4))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6,X7),arg=3))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6,X7),arg=2))))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5,X6,X7),arg=1))). + +assign(X0,X1,X2,X3) :- + (is_Space_or_Clause(X0,Y0) + -> (is_FloatVar(X1,Y1) + -> (is_FloatAssign(X2,Y2) + -> (is_FloatVarValPrint(X3,Y3) + -> gecode_constraint_assign_16(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(assign(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(assign(X0,X1,X2,X3),arg=3))) + ; (is_FloatVarArgs(X1,Y1) + -> (is_FloatAssign(X2,Y2) + -> (is_FloatBranchFilter(X3,Y3) + -> gecode_constraint_assign_7(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(assign(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(assign(X0,X1,X2,X3),arg=3))) + ; (is_BoolVarArgs(X1,Y1) + -> (is_IntAssign(X2,Y2) + -> (is_BoolBranchFilter(X3,Y3) + -> gecode_constraint_assign_4(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(assign(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(assign(X0,X1,X2,X3),arg=3))) + ; (is_BoolVar(X1,Y1) + -> (is_IntAssign(X2,Y2) + -> (is_BoolVarValPrint(X3,Y3) + -> gecode_constraint_assign_2(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(assign(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(assign(X0,X1,X2,X3),arg=3))) + ; (is_IntVarArgs(X1,Y1) + -> (is_IntAssign(X2,Y2) + -> (is_IntBranchFilter(X3,Y3) + -> gecode_constraint_assign_10(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(assign(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(assign(X0,X1,X2,X3),arg=3))) + ; (is_IntVar(X1,Y1) + -> (is_IntAssign(X2,Y2) + -> (is_IntVarValPrint(X3,Y3) + -> gecode_constraint_assign_18(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(assign(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(assign(X0,X1,X2,X3),arg=3))) + ; (is_SetVarArgs(X1,Y1) + -> (is_SetAssign(X2,Y2) + -> (is_SetBranchFilter(X3,Y3) + -> gecode_constraint_assign_13(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(assign(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(assign(X0,X1,X2,X3),arg=3))) + ; (is_SetVar(X1,Y1) + -> (is_SetAssign(X2,Y2) + -> (is_SetVarValPrint(X3,Y3) + -> gecode_constraint_assign_20(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(assign(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(assign(X0,X1,X2,X3),arg=3))) + ; throw(gecode_argument_error(assign(X0,X1,X2,X3),arg=2)))))))))) + ; throw(gecode_argument_error(assign(X0,X1,X2,X3),arg=1))). + +element(X0,X1,X2,X3,X4) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> (is_IntVar(X2,Y2) + -> (is_int(X3,Y3) + -> (is_IntConLevel(X4,Y4) + -> gecode_constraint_element_221(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4),arg=5))) + ; (is_IntVar(X3,Y3) + -> (is_IntConLevel(X4,Y4) + -> gecode_constraint_element_225(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4),arg=4)))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4),arg=3))) + ; (is_BoolVarArgs(X1,Y1) + -> (is_IntVar(X2,Y2) + -> (is_int(X3,Y3) + -> (is_IntConLevel(X4,Y4) + -> gecode_constraint_element_215(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4),arg=5))) + ; (is_BoolVar(X3,Y3) + -> (is_IntConLevel(X4,Y4) + -> gecode_constraint_element_213(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4),arg=4)))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4),arg=3))) + ; (is_SetOpType(X1,Y1) + -> (is_SetVarArgs(X2,Y2) + -> (is_SetVar(X3,Y3) + -> (is_SetVar(X4,Y4) + -> gecode_constraint_element_244(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4),arg=4))) + ; (is_IntVarArgs(X2,Y2) + -> (is_SetVar(X3,Y3) + -> (is_SetVar(X4,Y4) + -> gecode_constraint_element_242(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4),arg=4))) + ; (is_IntSetArgs(X2,Y2) + -> (is_SetVar(X3,Y3) + -> (is_SetVar(X4,Y4) + -> gecode_constraint_element_240(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4),arg=4))) + ; (is_IntArgs(X2,Y2) + -> (is_SetVar(X3,Y3) + -> (is_SetVar(X4,Y4) + -> gecode_constraint_element_238(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4),arg=3)))))) + ; (is_IntArgs(X1,Y1) + -> (is_IntVar(X2,Y2) + -> (is_int(X3,Y3) + -> (is_IntConLevel(X4,Y4) + -> gecode_constraint_element_231(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4),arg=5))) + ; (is_IntVar(X3,Y3) + -> (is_IntConLevel(X4,Y4) + -> gecode_constraint_element_237(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4),arg=5))) + ; (is_BoolVar(X3,Y3) + -> (is_IntConLevel(X4,Y4) + -> gecode_constraint_element_229(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4),arg=4))))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4),arg=3))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4),arg=2)))))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4),arg=1))). + +sequence(X0,X1,X2) :- + (is_Space_or_Clause(X0,Y0) + -> (is_SetVarArgs(X1,Y1) + -> (is_SetVar(X2,Y2) + -> gecode_constraint_sequence_438(Y0,Y1,Y2) + ; throw(gecode_argument_error(sequence(X0,X1,X2),arg=3))) + ; throw(gecode_argument_error(sequence(X0,X1,X2),arg=2))) + ; throw(gecode_argument_error(sequence(X0,X1,X2),arg=1))). + +branch(X0,X1,X2,X3,X4) :- + (is_Space_or_Clause(X0,Y0) + -> (is_FloatVarArgs(X1,Y1) + -> (is_FloatVarBranch(X2,Y2) + -> (is_FloatValBranch(X3,Y3) + -> (is_FloatBranchFilter(X4,Y4) + -> gecode_constraint_branch_30(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4),arg=3))) + ; (is_BoolVarArgs(X1,Y1) + -> (is_IntVarBranch(X2,Y2) + -> (is_IntValBranch(X3,Y3) + -> (is_Symmetries(X4,Y4) + -> gecode_constraint_branch_26(Y0,Y1,Y2,Y3,Y4) + ; (is_BoolBranchFilter(X4,Y4) + -> gecode_constraint_branch_24(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4),arg=5)))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4),arg=3))) + ; (is_IntVarArgs(X1,Y1) + -> (is_IntVarBranch(X2,Y2) + -> (is_IntValBranch(X3,Y3) + -> (is_Symmetries(X4,Y4) + -> gecode_constraint_branch_32(Y0,Y1,Y2,Y3,Y4) + ; (is_IntBranchFilter(X4,Y4) + -> gecode_constraint_branch_36(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4),arg=5)))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4),arg=3))) + ; (is_SetVarArgs(X1,Y1) + -> (is_SetVarBranch(X2,Y2) + -> (is_SetValBranch(X3,Y3) + -> (is_SetBranchFilter(X4,Y4) + -> gecode_constraint_branch_42(Y0,Y1,Y2,Y3,Y4) + ; (is_Symmetries(X4,Y4) + -> gecode_constraint_branch_38(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4),arg=5)))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4),arg=3))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4),arg=2)))))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4),arg=1))). + +circuit(X0,X1,X2,X3,X4,X5,X6) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntArgs(X1,Y1) + -> (is_int(X2,Y2) + -> (is_IntVarArgs(X3,Y3) + -> (is_IntVarArgs(X4,Y4) + -> (is_IntVar(X5,Y5) + -> (is_IntConLevel(X6,Y6) + -> gecode_constraint_circuit_79(Y0,Y1,Y2,Y3,Y4,Y5,Y6) + ; throw(gecode_argument_error(circuit(X0,X1,X2,X3,X4,X5,X6),arg=7))) + ; throw(gecode_argument_error(circuit(X0,X1,X2,X3,X4,X5,X6),arg=6))) + ; throw(gecode_argument_error(circuit(X0,X1,X2,X3,X4,X5,X6),arg=5))) + ; throw(gecode_argument_error(circuit(X0,X1,X2,X3,X4,X5,X6),arg=4))) + ; throw(gecode_argument_error(circuit(X0,X1,X2,X3,X4,X5,X6),arg=3))) + ; throw(gecode_argument_error(circuit(X0,X1,X2,X3,X4,X5,X6),arg=2))) + ; throw(gecode_argument_error(circuit(X0,X1,X2,X3,X4,X5,X6),arg=1))). + +pow(X0,X1,X2,X3) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVar(X1,Y1) + -> (is_int(X2,Y2) + -> (is_IntVar(X3,Y3) + -> gecode_constraint_pow_361(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(pow(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(pow(X0,X1,X2,X3),arg=3))) + ; (is_FloatVar(X1,Y1) + -> (is_int(X2,Y2) + -> (is_FloatVar(X3,Y3) + -> gecode_constraint_pow_360(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(pow(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(pow(X0,X1,X2,X3),arg=3))) + ; throw(gecode_argument_error(pow(X0,X1,X2,X3),arg=2)))) + ; throw(gecode_argument_error(pow(X0,X1,X2,X3),arg=1))). + +precede(X0,X1,X2) :- + (is_Space_or_Clause(X0,Y0) + -> (is_SetVarArgs(X1,Y1) + -> (is_IntArgs(X2,Y2) + -> gecode_constraint_precede_367(Y0,Y1,Y2) + ; throw(gecode_argument_error(precede(X0,X1,X2),arg=3))) + ; (is_IntVarArgs(X1,Y1) + -> (is_IntArgs(X2,Y2) + -> gecode_constraint_precede_363(Y0,Y1,Y2) + ; throw(gecode_argument_error(precede(X0,X1,X2),arg=3))) + ; throw(gecode_argument_error(precede(X0,X1,X2),arg=2)))) + ; throw(gecode_argument_error(precede(X0,X1,X2),arg=1))). + +cumulative(X0,X1,X2,X3,X4,X5) :- + (is_Space_or_Clause(X0,Y0) + -> (is_int(X1,Y1) + -> (is_TaskTypeArgs(X2,Y2) + -> (is_IntVarArgs(X3,Y3) + -> (is_IntArgs(X4,Y4) + -> (is_IntArgs(X5,Y5) + -> gecode_constraint_cumulative_128(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5),arg=6))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5),arg=5))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5),arg=4))) + ; (is_IntVarArgs(X2,Y2) + -> (is_IntVarArgs(X3,Y3) + -> (is_IntVarArgs(X4,Y4) + -> (is_IntArgs(X5,Y5) + -> gecode_constraint_cumulative_124(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5),arg=6))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5),arg=5))) + ; (is_IntArgs(X3,Y3) + -> (is_IntArgs(X4,Y4) + -> (is_BoolVarArgs(X5,Y5) + -> gecode_constraint_cumulative_118(Y0,Y1,Y2,Y3,Y4,Y5) + ; (is_IntConLevel(X5,Y5) + -> gecode_constraint_cumulative_121(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5),arg=6)))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5),arg=5))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5),arg=4)))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5),arg=3)))) + ; (is_IntVar(X1,Y1) + -> (is_TaskTypeArgs(X2,Y2) + -> (is_IntVarArgs(X3,Y3) + -> (is_IntArgs(X4,Y4) + -> (is_IntArgs(X5,Y5) + -> gecode_constraint_cumulative_140(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5),arg=6))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5),arg=5))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5),arg=4))) + ; (is_IntVarArgs(X2,Y2) + -> (is_IntVarArgs(X3,Y3) + -> (is_IntVarArgs(X4,Y4) + -> (is_IntArgs(X5,Y5) + -> gecode_constraint_cumulative_136(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5),arg=6))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5),arg=5))) + ; (is_IntArgs(X3,Y3) + -> (is_IntArgs(X4,Y4) + -> (is_BoolVarArgs(X5,Y5) + -> gecode_constraint_cumulative_130(Y0,Y1,Y2,Y3,Y4,Y5) + ; (is_IntConLevel(X5,Y5) + -> gecode_constraint_cumulative_133(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5),arg=6)))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5),arg=5))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5),arg=4)))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5),arg=3)))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5),arg=2)))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5),arg=1))). + +distinct(X0,X1,X2,X3) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntArgs(X1,Y1) + -> (is_IntVarArgs(X2,Y2) + -> (is_IntConLevel(X3,Y3) + -> gecode_constraint_distinct_159(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(distinct(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(distinct(X0,X1,X2,X3),arg=3))) + ; throw(gecode_argument_error(distinct(X0,X1,X2,X3),arg=2))) + ; throw(gecode_argument_error(distinct(X0,X1,X2,X3),arg=1))). + +min(X0,X1,X2) :- + (is_Space_or_Clause(X0,Y0) + -> (is_FloatVarArgs(X1,Y1) + -> (is_FloatVar(X2,Y2) + -> gecode_constraint_min_314(Y0,Y1,Y2) + ; throw(gecode_argument_error(min(X0,X1,X2),arg=3))) + ; (is_IntVarArgs(X1,Y1) + -> (is_IntVar(X2,Y2) + -> gecode_constraint_min_315(Y0,Y1,Y2) + ; throw(gecode_argument_error(min(X0,X1,X2),arg=3))) + ; (is_SetVar(X1,Y1) + -> (is_IntVar(X2,Y2) + -> gecode_constraint_min_320(Y0,Y1,Y2) + ; throw(gecode_argument_error(min(X0,X1,X2),arg=3))) + ; throw(gecode_argument_error(min(X0,X1,X2),arg=2))))) + ; throw(gecode_argument_error(min(X0,X1,X2),arg=1))). + +sqrt(X0,X1,X2,X3) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVar(X1,Y1) + -> (is_IntVar(X2,Y2) + -> (is_IntConLevel(X3,Y3) + -> gecode_constraint_sqrt_448(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(sqrt(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(sqrt(X0,X1,X2,X3),arg=3))) + ; throw(gecode_argument_error(sqrt(X0,X1,X2,X3),arg=2))) + ; throw(gecode_argument_error(sqrt(X0,X1,X2,X3),arg=1))). + +sequence(X0,X1,X2,X3,X4,X5) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> (is_IntSet(X2,Y2) + -> (is_int(X3,Y3) + -> (is_int(X4,Y4) + -> (is_int(X5,Y5) + -> gecode_constraint_sequence_435(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(sequence(X0,X1,X2,X3,X4,X5),arg=6))) + ; throw(gecode_argument_error(sequence(X0,X1,X2,X3,X4,X5),arg=5))) + ; throw(gecode_argument_error(sequence(X0,X1,X2,X3,X4,X5),arg=4))) + ; throw(gecode_argument_error(sequence(X0,X1,X2,X3,X4,X5),arg=3))) + ; (is_BoolVarArgs(X1,Y1) + -> (is_IntSet(X2,Y2) + -> (is_int(X3,Y3) + -> (is_int(X4,Y4) + -> (is_int(X5,Y5) + -> gecode_constraint_sequence_433(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(sequence(X0,X1,X2,X3,X4,X5),arg=6))) + ; throw(gecode_argument_error(sequence(X0,X1,X2,X3,X4,X5),arg=5))) + ; throw(gecode_argument_error(sequence(X0,X1,X2,X3,X4,X5),arg=4))) + ; throw(gecode_argument_error(sequence(X0,X1,X2,X3,X4,X5),arg=3))) + ; throw(gecode_argument_error(sequence(X0,X1,X2,X3,X4,X5),arg=2)))) + ; throw(gecode_argument_error(sequence(X0,X1,X2,X3,X4,X5),arg=1))). + +unshare(X0,X1,X2) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> (is_IntConLevel(X2,Y2) + -> gecode_constraint_unshare_464(Y0,Y1,Y2) + ; throw(gecode_argument_error(unshare(X0,X1,X2),arg=3))) + ; (is_BoolVarArgs(X1,Y1) + -> (is_IntConLevel(X2,Y2) + -> gecode_constraint_unshare_462(Y0,Y1,Y2) + ; throw(gecode_argument_error(unshare(X0,X1,X2),arg=3))) + ; throw(gecode_argument_error(unshare(X0,X1,X2),arg=2)))) + ; throw(gecode_argument_error(unshare(X0,X1,X2),arg=1))). + +path(X0,X1,X2,X3,X4,X5) :- + (is_Space_or_Clause(X0,Y0) + -> (is_int(X1,Y1) + -> (is_IntVarArgs(X2,Y2) + -> (is_IntVar(X3,Y3) + -> (is_IntVar(X4,Y4) + -> (is_IntConLevel(X5,Y5) + -> gecode_constraint_path_359(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5),arg=6))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5),arg=5))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5),arg=4))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5),arg=3))) + ; (is_IntArgs(X1,Y1) + -> (is_IntVarArgs(X2,Y2) + -> (is_IntVar(X3,Y3) + -> (is_IntVar(X4,Y4) + -> (is_IntVar(X5,Y5) + -> gecode_constraint_path_350(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5),arg=6))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5),arg=5))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5),arg=4))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5),arg=3))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5),arg=2)))) + ; throw(gecode_argument_error(path(X0,X1,X2,X3,X4,X5),arg=1))). + +divmod(X0,X1,X2,X3,X4) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVar(X1,Y1) + -> (is_IntVar(X2,Y2) + -> (is_IntVar(X3,Y3) + -> (is_IntVar(X4,Y4) + -> gecode_constraint_divmod_165(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(divmod(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(divmod(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(divmod(X0,X1,X2,X3,X4),arg=3))) + ; throw(gecode_argument_error(divmod(X0,X1,X2,X3,X4),arg=2))) + ; throw(gecode_argument_error(divmod(X0,X1,X2,X3,X4),arg=1))). + +branch(X0,X1,X2,X3,X4,X5) :- + (is_Space_or_Clause(X0,Y0) + -> (is_FloatVarArgs(X1,Y1) + -> (is_FloatVarBranch(X2,Y2) + -> (is_FloatValBranch(X3,Y3) + -> (is_FloatBranchFilter(X4,Y4) + -> (is_FloatVarValPrint(X5,Y5) + -> gecode_constraint_branch_31(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4,X5),arg=6))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4,X5),arg=5))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4,X5),arg=4))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4,X5),arg=3))) + ; (is_BoolVarArgs(X1,Y1) + -> (is_IntVarBranch(X2,Y2) + -> (is_IntValBranch(X3,Y3) + -> (is_Symmetries(X4,Y4) + -> (is_BoolBranchFilter(X5,Y5) + -> gecode_constraint_branch_27(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4,X5),arg=6))) + ; (is_BoolBranchFilter(X4,Y4) + -> (is_BoolVarValPrint(X5,Y5) + -> gecode_constraint_branch_25(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4,X5),arg=6))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4,X5),arg=5)))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4,X5),arg=4))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4,X5),arg=3))) + ; (is_IntVarArgs(X1,Y1) + -> (is_IntVarBranch(X2,Y2) + -> (is_IntValBranch(X3,Y3) + -> (is_Symmetries(X4,Y4) + -> (is_IntBranchFilter(X5,Y5) + -> gecode_constraint_branch_33(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4,X5),arg=6))) + ; (is_IntBranchFilter(X4,Y4) + -> (is_IntVarValPrint(X5,Y5) + -> gecode_constraint_branch_37(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4,X5),arg=6))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4,X5),arg=5)))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4,X5),arg=4))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4,X5),arg=3))) + ; (is_SetVarArgs(X1,Y1) + -> (is_SetVarBranch(X2,Y2) + -> (is_SetValBranch(X3,Y3) + -> (is_SetBranchFilter(X4,Y4) + -> (is_SetVarValPrint(X5,Y5) + -> gecode_constraint_branch_43(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4,X5),arg=6))) + ; (is_Symmetries(X4,Y4) + -> (is_SetBranchFilter(X5,Y5) + -> gecode_constraint_branch_39(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4,X5),arg=6))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4,X5),arg=5)))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4,X5),arg=4))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4,X5),arg=3))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4,X5),arg=2)))))) + ; throw(gecode_argument_error(branch(X0,X1,X2,X3,X4,X5),arg=1))). + +nooverlap(X0,X1,X2,X3,X4,X5,X6,X7,X8) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> (is_IntVarArgs(X2,Y2) + -> (is_IntVarArgs(X3,Y3) + -> (is_IntVarArgs(X4,Y4) + -> (is_IntVarArgs(X5,Y5) + -> (is_IntVarArgs(X6,Y6) + -> (is_BoolVarArgs(X7,Y7) + -> (is_IntConLevel(X8,Y8) + -> gecode_constraint_nooverlap_332(Y0,Y1,Y2,Y3,Y4,Y5,Y6,Y7,Y8) + ; throw(gecode_argument_error(nooverlap(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=9))) + ; throw(gecode_argument_error(nooverlap(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=8))) + ; throw(gecode_argument_error(nooverlap(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=7))) + ; throw(gecode_argument_error(nooverlap(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=6))) + ; throw(gecode_argument_error(nooverlap(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=5))) + ; throw(gecode_argument_error(nooverlap(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=4))) + ; throw(gecode_argument_error(nooverlap(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=3))) + ; throw(gecode_argument_error(nooverlap(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=2))) + ; throw(gecode_argument_error(nooverlap(X0,X1,X2,X3,X4,X5,X6,X7,X8),arg=1))). + +cumulative(X0,X1,X2,X3,X4) :- + (is_Space_or_Clause(X0,Y0) + -> (is_int(X1,Y1) + -> (is_IntVarArgs(X2,Y2) + -> (is_IntArgs(X3,Y3) + -> (is_IntArgs(X4,Y4) + -> gecode_constraint_cumulative_120(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4),arg=3))) + ; (is_IntVar(X1,Y1) + -> (is_IntVarArgs(X2,Y2) + -> (is_IntArgs(X3,Y3) + -> (is_IntArgs(X4,Y4) + -> gecode_constraint_cumulative_132(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4),arg=3))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4),arg=2)))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4),arg=1))). + +member(X0,X1,X2) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> (is_IntVar(X2,Y2) + -> gecode_constraint_member_310(Y0,Y1,Y2) + ; throw(gecode_argument_error(member(X0,X1,X2),arg=3))) + ; (is_BoolVarArgs(X1,Y1) + -> (is_BoolVar(X2,Y2) + -> gecode_constraint_member_306(Y0,Y1,Y2) + ; throw(gecode_argument_error(member(X0,X1,X2),arg=3))) + ; throw(gecode_argument_error(member(X0,X1,X2),arg=2)))) + ; throw(gecode_argument_error(member(X0,X1,X2),arg=1))). + +count(X0,X1,X2,X3,X4,X5) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> (is_int(X2,Y2) + -> (is_IntRelType(X3,Y3) + -> (is_int(X4,Y4) + -> (is_IntConLevel(X5,Y5) + -> gecode_constraint_count_111(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(count(X0,X1,X2,X3,X4,X5),arg=6))) + ; (is_IntVar(X4,Y4) + -> (is_IntConLevel(X5,Y5) + -> gecode_constraint_count_113(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(count(X0,X1,X2,X3,X4,X5),arg=6))) + ; throw(gecode_argument_error(count(X0,X1,X2,X3,X4,X5),arg=5)))) + ; throw(gecode_argument_error(count(X0,X1,X2,X3,X4,X5),arg=4))) + ; (is_IntVar(X2,Y2) + -> (is_IntRelType(X3,Y3) + -> (is_int(X4,Y4) + -> (is_IntConLevel(X5,Y5) + -> gecode_constraint_count_115(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(count(X0,X1,X2,X3,X4,X5),arg=6))) + ; (is_IntVar(X4,Y4) + -> (is_IntConLevel(X5,Y5) + -> gecode_constraint_count_117(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(count(X0,X1,X2,X3,X4,X5),arg=6))) + ; throw(gecode_argument_error(count(X0,X1,X2,X3,X4,X5),arg=5)))) + ; throw(gecode_argument_error(count(X0,X1,X2,X3,X4,X5),arg=4))) + ; (is_IntSet(X2,Y2) + -> (is_IntRelType(X3,Y3) + -> (is_int(X4,Y4) + -> (is_IntConLevel(X5,Y5) + -> gecode_constraint_count_103(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(count(X0,X1,X2,X3,X4,X5),arg=6))) + ; (is_IntVar(X4,Y4) + -> (is_IntConLevel(X5,Y5) + -> gecode_constraint_count_105(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(count(X0,X1,X2,X3,X4,X5),arg=6))) + ; throw(gecode_argument_error(count(X0,X1,X2,X3,X4,X5),arg=5)))) + ; throw(gecode_argument_error(count(X0,X1,X2,X3,X4,X5),arg=4))) + ; (is_IntArgs(X2,Y2) + -> (is_IntRelType(X3,Y3) + -> (is_int(X4,Y4) + -> (is_IntConLevel(X5,Y5) + -> gecode_constraint_count_93(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(count(X0,X1,X2,X3,X4,X5),arg=6))) + ; (is_IntVar(X4,Y4) + -> (is_IntConLevel(X5,Y5) + -> gecode_constraint_count_95(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(count(X0,X1,X2,X3,X4,X5),arg=6))) + ; throw(gecode_argument_error(count(X0,X1,X2,X3,X4,X5),arg=5)))) + ; throw(gecode_argument_error(count(X0,X1,X2,X3,X4,X5),arg=4))) + ; throw(gecode_argument_error(count(X0,X1,X2,X3,X4,X5),arg=3)))))) + ; throw(gecode_argument_error(count(X0,X1,X2,X3,X4,X5),arg=2))) + ; throw(gecode_argument_error(count(X0,X1,X2,X3,X4,X5),arg=1))). + +pow(X0,X1,X2,X3,X4) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVar(X1,Y1) + -> (is_int(X2,Y2) + -> (is_IntVar(X3,Y3) + -> (is_IntConLevel(X4,Y4) + -> gecode_constraint_pow_362(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(pow(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(pow(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(pow(X0,X1,X2,X3,X4),arg=3))) + ; throw(gecode_argument_error(pow(X0,X1,X2,X3,X4),arg=2))) + ; throw(gecode_argument_error(pow(X0,X1,X2,X3,X4),arg=1))). + +notMin(X0,X1,X2) :- + (is_Space_or_Clause(X0,Y0) + -> (is_SetVar(X1,Y1) + -> (is_IntVar(X2,Y2) + -> gecode_constraint_notMin_336(Y0,Y1,Y2) + ; throw(gecode_argument_error(notMin(X0,X1,X2),arg=3))) + ; throw(gecode_argument_error(notMin(X0,X1,X2),arg=2))) + ; throw(gecode_argument_error(notMin(X0,X1,X2),arg=1))). + +cumulative(X0,X1,X2,X3,X4,X5,X6,X7) :- + (is_Space_or_Clause(X0,Y0) + -> (is_int(X1,Y1) + -> (is_TaskTypeArgs(X2,Y2) + -> (is_IntVarArgs(X3,Y3) + -> (is_IntArgs(X4,Y4) + -> (is_IntArgs(X5,Y5) + -> (is_BoolVarArgs(X6,Y6) + -> (is_IntConLevel(X7,Y7) + -> gecode_constraint_cumulative_127(Y0,Y1,Y2,Y3,Y4,Y5,Y6,Y7) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6,X7),arg=8))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6,X7),arg=7))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6,X7),arg=6))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6,X7),arg=5))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6,X7),arg=4))) + ; (is_IntVarArgs(X2,Y2) + -> (is_IntVarArgs(X3,Y3) + -> (is_IntVarArgs(X4,Y4) + -> (is_IntArgs(X5,Y5) + -> (is_BoolVarArgs(X6,Y6) + -> (is_IntConLevel(X7,Y7) + -> gecode_constraint_cumulative_123(Y0,Y1,Y2,Y3,Y4,Y5,Y6,Y7) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6,X7),arg=8))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6,X7),arg=7))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6,X7),arg=6))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6,X7),arg=5))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6,X7),arg=4))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6,X7),arg=3)))) + ; (is_IntVar(X1,Y1) + -> (is_TaskTypeArgs(X2,Y2) + -> (is_IntVarArgs(X3,Y3) + -> (is_IntArgs(X4,Y4) + -> (is_IntArgs(X5,Y5) + -> (is_BoolVarArgs(X6,Y6) + -> (is_IntConLevel(X7,Y7) + -> gecode_constraint_cumulative_139(Y0,Y1,Y2,Y3,Y4,Y5,Y6,Y7) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6,X7),arg=8))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6,X7),arg=7))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6,X7),arg=6))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6,X7),arg=5))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6,X7),arg=4))) + ; (is_IntVarArgs(X2,Y2) + -> (is_IntVarArgs(X3,Y3) + -> (is_IntVarArgs(X4,Y4) + -> (is_IntArgs(X5,Y5) + -> (is_BoolVarArgs(X6,Y6) + -> (is_IntConLevel(X7,Y7) + -> gecode_constraint_cumulative_135(Y0,Y1,Y2,Y3,Y4,Y5,Y6,Y7) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6,X7),arg=8))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6,X7),arg=7))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6,X7),arg=6))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6,X7),arg=5))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6,X7),arg=4))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6,X7),arg=3)))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6,X7),arg=2)))) + ; throw(gecode_argument_error(cumulative(X0,X1,X2,X3,X4,X5,X6,X7),arg=1))). + +branch(X0,X1,X2) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVar(X1,Y1) + -> (is_IntValBranch(X2,Y2) + -> gecode_constraint_branch_46(Y0,Y1,Y2) + ; throw(gecode_argument_error(branch(X0,X1,X2),arg=3))) + ; (is_BoolVar(X1,Y1) + -> (is_IntValBranch(X2,Y2) + -> gecode_constraint_branch_21(Y0,Y1,Y2) + ; throw(gecode_argument_error(branch(X0,X1,X2),arg=3))) + ; (is_FloatVar(X1,Y1) + -> (is_FloatValBranch(X2,Y2) + -> gecode_constraint_branch_44(Y0,Y1,Y2) + ; throw(gecode_argument_error(branch(X0,X1,X2),arg=3))) + ; (is_SetVar(X1,Y1) + -> (is_SetValBranch(X2,Y2) + -> gecode_constraint_branch_48(Y0,Y1,Y2) + ; throw(gecode_argument_error(branch(X0,X1,X2),arg=3))) + ; throw(gecode_argument_error(branch(X0,X1,X2),arg=2)))))) + ; throw(gecode_argument_error(branch(X0,X1,X2),arg=1))). + +dom(X0,X1,X2) :- + (is_Space_or_Clause(X0,Y0) + -> (is_FloatVar(X1,Y1) + -> (is_FloatVal(X2,Y2) + -> gecode_constraint_dom_188(Y0,Y1,Y2) + ; (is_FloatVar(X2,Y2) + -> gecode_constraint_dom_190(Y0,Y1,Y2) + ; throw(gecode_argument_error(dom(X0,X1,X2),arg=3)))) + ; (is_FloatVarArgs(X1,Y1) + -> (is_FloatVarArgs(X2,Y2) + -> gecode_constraint_dom_171(Y0,Y1,Y2) + ; (is_FloatVal(X2,Y2) + -> gecode_constraint_dom_173(Y0,Y1,Y2) + ; throw(gecode_argument_error(dom(X0,X1,X2),arg=3)))) + ; (is_BoolVarArgs(X1,Y1) + -> (is_BoolVarArgs(X2,Y2) + -> gecode_constraint_dom_169(Y0,Y1,Y2) + ; throw(gecode_argument_error(dom(X0,X1,X2),arg=3))) + ; (is_BoolVar(X1,Y1) + -> (is_BoolVar(X2,Y2) + -> gecode_constraint_dom_167(Y0,Y1,Y2) + ; throw(gecode_argument_error(dom(X0,X1,X2),arg=3))) + ; (is_IntVarArgs(X1,Y1) + -> (is_int(X2,Y2) + -> gecode_constraint_dom_178(Y0,Y1,Y2) + ; (is_IntVarArgs(X2,Y2) + -> gecode_constraint_dom_176(Y0,Y1,Y2) + ; (is_IntSet(X2,Y2) + -> gecode_constraint_dom_174(Y0,Y1,Y2) + ; throw(gecode_argument_error(dom(X0,X1,X2),arg=3))))) + ; (is_IntVar(X1,Y1) + -> (is_int(X2,Y2) + -> gecode_constraint_dom_195(Y0,Y1,Y2) + ; (is_IntVar(X2,Y2) + -> gecode_constraint_dom_203(Y0,Y1,Y2) + ; (is_IntSet(X2,Y2) + -> gecode_constraint_dom_191(Y0,Y1,Y2) + ; throw(gecode_argument_error(dom(X0,X1,X2),arg=3))))) + ; (is_SetVarArgs(X1,Y1) + -> (is_SetVarArgs(X2,Y2) + -> gecode_constraint_dom_182(Y0,Y1,Y2) + ; throw(gecode_argument_error(dom(X0,X1,X2),arg=3))) + ; (is_SetVar(X1,Y1) + -> (is_SetVar(X2,Y2) + -> gecode_constraint_dom_211(Y0,Y1,Y2) + ; throw(gecode_argument_error(dom(X0,X1,X2),arg=3))) + ; throw(gecode_argument_error(dom(X0,X1,X2),arg=2)))))))))) + ; throw(gecode_argument_error(dom(X0,X1,X2),arg=1))). + +linear(X0,X1,X2,X3,X4) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> (is_IntRelType(X2,Y2) + -> (is_int(X3,Y3) + -> (is_Reify(X4,Y4) + -> gecode_constraint_linear_292(Y0,Y1,Y2,Y3,Y4) + ; (is_IntConLevel(X4,Y4) + -> gecode_constraint_linear_291(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4),arg=5)))) + ; (is_IntVar(X3,Y3) + -> (is_Reify(X4,Y4) + -> gecode_constraint_linear_296(Y0,Y1,Y2,Y3,Y4) + ; (is_IntConLevel(X4,Y4) + -> gecode_constraint_linear_295(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4),arg=5)))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4),arg=4)))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4),arg=3))) + ; (is_FloatVarArgs(X1,Y1) + -> (is_FloatRelType(X2,Y2) + -> (is_FloatVar(X3,Y3) + -> (is_Reify(X4,Y4) + -> gecode_constraint_linear_273(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4),arg=5))) + ; (is_FloatNum(X3,Y3) + -> (is_Reify(X4,Y4) + -> gecode_constraint_linear_271(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4),arg=4)))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4),arg=3))) + ; (is_BoolVarArgs(X1,Y1) + -> (is_IntRelType(X2,Y2) + -> (is_int(X3,Y3) + -> (is_Reify(X4,Y4) + -> gecode_constraint_linear_260(Y0,Y1,Y2,Y3,Y4) + ; (is_IntConLevel(X4,Y4) + -> gecode_constraint_linear_259(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4),arg=5)))) + ; (is_IntVar(X3,Y3) + -> (is_Reify(X4,Y4) + -> gecode_constraint_linear_264(Y0,Y1,Y2,Y3,Y4) + ; (is_IntConLevel(X4,Y4) + -> gecode_constraint_linear_263(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4),arg=5)))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4),arg=4)))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4),arg=3))) + ; (is_FloatValArgs(X1,Y1) + -> (is_FloatVarArgs(X2,Y2) + -> (is_FloatRelType(X3,Y3) + -> (is_FloatVar(X4,Y4) + -> gecode_constraint_linear_268(Y0,Y1,Y2,Y3,Y4) + ; (is_FloatNum(X4,Y4) + -> gecode_constraint_linear_266(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4),arg=5)))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4),arg=3))) + ; (is_IntArgs(X1,Y1) + -> (is_IntVarArgs(X2,Y2) + -> (is_IntRelType(X3,Y3) + -> (is_int(X4,Y4) + -> gecode_constraint_linear_282(Y0,Y1,Y2,Y3,Y4) + ; (is_IntVar(X4,Y4) + -> gecode_constraint_linear_286(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4),arg=5)))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4),arg=4))) + ; (is_BoolVarArgs(X2,Y2) + -> (is_IntRelType(X3,Y3) + -> (is_int(X4,Y4) + -> gecode_constraint_linear_274(Y0,Y1,Y2,Y3,Y4) + ; (is_IntVar(X4,Y4) + -> gecode_constraint_linear_278(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4),arg=5)))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4),arg=3)))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4),arg=2))))))) + ; throw(gecode_argument_error(linear(X0,X1,X2,X3,X4),arg=1))). + +nooverlap(X0,X1,X2,X3,X4,X5) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> (is_IntArgs(X2,Y2) + -> (is_IntVarArgs(X3,Y3) + -> (is_IntArgs(X4,Y4) + -> (is_BoolVarArgs(X5,Y5) + -> gecode_constraint_nooverlap_327(Y0,Y1,Y2,Y3,Y4,Y5) + ; (is_IntConLevel(X5,Y5) + -> gecode_constraint_nooverlap_330(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(nooverlap(X0,X1,X2,X3,X4,X5),arg=6)))) + ; throw(gecode_argument_error(nooverlap(X0,X1,X2,X3,X4,X5),arg=5))) + ; throw(gecode_argument_error(nooverlap(X0,X1,X2,X3,X4,X5),arg=4))) + ; throw(gecode_argument_error(nooverlap(X0,X1,X2,X3,X4,X5),arg=3))) + ; throw(gecode_argument_error(nooverlap(X0,X1,X2,X3,X4,X5),arg=2))) + ; throw(gecode_argument_error(nooverlap(X0,X1,X2,X3,X4,X5),arg=1))). + +element(X0,X1,X2,X3,X4,X5) :- + (is_Space_or_Clause(X0,Y0) + -> (is_SetOpType(X1,Y1) + -> (is_SetVarArgs(X2,Y2) + -> (is_SetVar(X3,Y3) + -> (is_SetVar(X4,Y4) + -> (is_IntSet(X5,Y5) + -> gecode_constraint_element_245(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5),arg=6))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5),arg=5))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5),arg=4))) + ; (is_IntVarArgs(X2,Y2) + -> (is_SetVar(X3,Y3) + -> (is_SetVar(X4,Y4) + -> (is_IntSet(X5,Y5) + -> gecode_constraint_element_243(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5),arg=6))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5),arg=5))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5),arg=4))) + ; (is_IntSetArgs(X2,Y2) + -> (is_SetVar(X3,Y3) + -> (is_SetVar(X4,Y4) + -> (is_IntSet(X5,Y5) + -> gecode_constraint_element_241(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5),arg=6))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5),arg=5))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5),arg=4))) + ; (is_IntArgs(X2,Y2) + -> (is_SetVar(X3,Y3) + -> (is_SetVar(X4,Y4) + -> (is_IntSet(X5,Y5) + -> gecode_constraint_element_239(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5),arg=6))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5),arg=5))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5),arg=4))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5),arg=3)))))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5),arg=2))) + ; throw(gecode_argument_error(element(X0,X1,X2,X3,X4,X5),arg=1))). + +rel(X0,X1,X2,X3) :- + (is_Space_or_Clause(X0,Y0) + -> (is_FloatVar(X1,Y1) + -> (is_FloatRelType(X2,Y2) + -> (is_FloatVal(X3,Y3) + -> gecode_constraint_rel_405(Y0,Y1,Y2,Y3) + ; (is_FloatVar(X3,Y3) + -> gecode_constraint_rel_407(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3),arg=4)))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3),arg=3))) + ; (is_SetOpType(X1,Y1) + -> (is_SetVarArgs(X2,Y2) + -> (is_SetVar(X3,Y3) + -> gecode_constraint_rel_423(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3),arg=4))) + ; (is_IntVarArgs(X2,Y2) + -> (is_SetVar(X3,Y3) + -> gecode_constraint_rel_421(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3),arg=3)))) + ; (is_FloatVarArgs(X1,Y1) + -> (is_FloatRelType(X2,Y2) + -> (is_FloatVal(X3,Y3) + -> gecode_constraint_rel_393(Y0,Y1,Y2,Y3) + ; (is_FloatVar(X3,Y3) + -> gecode_constraint_rel_394(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3),arg=4)))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3),arg=3))) + ; (is_BoolVarArgs(X1,Y1) + -> (is_IntRelType(X2,Y2) + -> (is_int(X3,Y3) + -> gecode_constraint_rel_391(Y0,Y1,Y2,Y3) + ; (is_BoolVarArgs(X3,Y3) + -> gecode_constraint_rel_387(Y0,Y1,Y2,Y3) + ; (is_BoolVar(X3,Y3) + -> gecode_constraint_rel_385(Y0,Y1,Y2,Y3) + ; (is_IntConLevel(X3,Y3) + -> gecode_constraint_rel_390(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3),arg=4)))))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3),arg=3))) + ; (is_BoolVar(X1,Y1) + -> (is_IntRelType(X2,Y2) + -> (is_int(X3,Y3) + -> gecode_constraint_rel_381(Y0,Y1,Y2,Y3) + ; (is_BoolVar(X3,Y3) + -> gecode_constraint_rel_377(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3),arg=4)))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3),arg=3))) + ; (is_IntVarArgs(X1,Y1) + -> (is_IntRelType(X2,Y2) + -> (is_int(X3,Y3) + -> gecode_constraint_rel_401(Y0,Y1,Y2,Y3) + ; (is_IntVar(X3,Y3) + -> gecode_constraint_rel_403(Y0,Y1,Y2,Y3) + ; (is_IntVarArgs(X3,Y3) + -> gecode_constraint_rel_397(Y0,Y1,Y2,Y3) + ; (is_IntConLevel(X3,Y3) + -> gecode_constraint_rel_400(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3),arg=4)))))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3),arg=3))) + ; (is_IntVar(X1,Y1) + -> (is_IntRelType(X2,Y2) + -> (is_int(X3,Y3) + -> gecode_constraint_rel_409(Y0,Y1,Y2,Y3) + ; (is_IntVar(X3,Y3) + -> gecode_constraint_rel_413(Y0,Y1,Y2,Y3) + ; (is_SetVar(X3,Y3) + -> gecode_constraint_rel_417(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3),arg=4))))) + ; (is_SetRelType(X2,Y2) + -> (is_SetVar(X3,Y3) + -> gecode_constraint_rel_418(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3),arg=4))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3),arg=3)))) + ; (is_SetVar(X1,Y1) + -> (is_IntRelType(X2,Y2) + -> (is_IntVar(X3,Y3) + -> gecode_constraint_rel_424(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3),arg=4))) + ; (is_SetRelType(X2,Y2) + -> (is_IntVar(X3,Y3) + -> gecode_constraint_rel_429(Y0,Y1,Y2,Y3) + ; (is_SetVar(X3,Y3) + -> gecode_constraint_rel_431(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3),arg=4)))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3),arg=3)))) + ; (is_BoolOpType(X1,Y1) + -> (is_BoolVarArgs(X2,Y2) + -> (is_int(X3,Y3) + -> gecode_constraint_rel_371(Y0,Y1,Y2,Y3) + ; (is_BoolVar(X3,Y3) + -> gecode_constraint_rel_369(Y0,Y1,Y2,Y3) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3),arg=4)))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3),arg=3))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3),arg=2))))))))))) + ; throw(gecode_argument_error(rel(X0,X1,X2,X3),arg=1))). + +min(X0,X1,X2,X3,X4) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVar(X1,Y1) + -> (is_IntVar(X2,Y2) + -> (is_IntVar(X3,Y3) + -> (is_IntConLevel(X4,Y4) + -> gecode_constraint_min_319(Y0,Y1,Y2,Y3,Y4) + ; throw(gecode_argument_error(min(X0,X1,X2,X3,X4),arg=5))) + ; throw(gecode_argument_error(min(X0,X1,X2,X3,X4),arg=4))) + ; throw(gecode_argument_error(min(X0,X1,X2,X3,X4),arg=3))) + ; throw(gecode_argument_error(min(X0,X1,X2,X3,X4),arg=2))) + ; throw(gecode_argument_error(min(X0,X1,X2,X3,X4),arg=1))). + +count(X0,X1,X2) :- + (is_Space_or_Clause(X0,Y0) + -> (is_IntVarArgs(X1,Y1) + -> (is_IntVarArgs(X2,Y2) + -> gecode_constraint_count_108(Y0,Y1,Y2) + ; (is_IntSetArgs(X2,Y2) + -> gecode_constraint_count_98(Y0,Y1,Y2) + ; throw(gecode_argument_error(count(X0,X1,X2),arg=3)))) + ; throw(gecode_argument_error(count(X0,X1,X2),arg=2))) + ; throw(gecode_argument_error(count(X0,X1,X2),arg=1))). + +ite(X0,X1,X2,X3,X4,X5) :- + (is_Space_or_Clause(X0,Y0) + -> (is_BoolVar(X1,Y1) + -> (is_IntVar(X2,Y2) + -> (is_IntVar(X3,Y3) + -> (is_IntVar(X4,Y4) + -> (is_IntConLevel(X5,Y5) + -> gecode_constraint_ite_257(Y0,Y1,Y2,Y3,Y4,Y5) + ; throw(gecode_argument_error(ite(X0,X1,X2,X3,X4,X5),arg=6))) + ; throw(gecode_argument_error(ite(X0,X1,X2,X3,X4,X5),arg=5))) + ; throw(gecode_argument_error(ite(X0,X1,X2,X3,X4,X5),arg=4))) + ; throw(gecode_argument_error(ite(X0,X1,X2,X3,X4,X5),arg=3))) + ; throw(gecode_argument_error(ite(X0,X1,X2,X3,X4,X5),arg=2))) + ; throw(gecode_argument_error(ite(X0,X1,X2,X3,X4,X5),arg=1))). diff --git a/packages/odbc b/packages/odbc index d0d1ee4d5..997245829 160000 --- a/packages/odbc +++ b/packages/odbc @@ -1 +1 @@ -Subproject commit d0d1ee4d58373cc611676103e0a50a3ae451a023 +Subproject commit 9972458293415b2d72276bd67875767bfeed00df diff --git a/packages/python/python.c b/packages/python/python.c index c61f034e8..92ea95809 100644 --- a/packages/python/python.c +++ b/packages/python/python.c @@ -1,4 +1,7 @@ +#ifdef _XOPEN_SOURCE +#undef _XOPEN_SOURCE // python does its own thing +#endif #include #include #include @@ -13,26 +16,26 @@ static atom_t ATOM_true, ATOM_t; static functor_t FUNCTOR_dollar1, - FUNCTOR_abs1, - FUNCTOR_all1, - FUNCTOR_any1, - FUNCTOR_bin1, - FUNCTOR_dir1, - FUNCTOR_float1, - FUNCTOR_int1, + FUNCTOR_abs1, + FUNCTOR_all1, + FUNCTOR_any1, + FUNCTOR_bin1, + FUNCTOR_dir1, + FUNCTOR_float1, + FUNCTOR_int1, FUNCTOR_iter1, FUNCTOR_iter2, - FUNCTOR_long1, - FUNCTOR_len1, + FUNCTOR_long1, + FUNCTOR_len1, FUNCTOR_curly1, FUNCTOR_ord1, - FUNCTOR_range1, - FUNCTOR_range2, - FUNCTOR_range3, - FUNCTOR_sum1, - FUNCTOR_pointer1, - FUNCTOR_complex2, - FUNCTOR_plus2, + FUNCTOR_range1, + FUNCTOR_range2, + FUNCTOR_range3, + FUNCTOR_sum1, + FUNCTOR_pointer1, + FUNCTOR_complex2, + FUNCTOR_plus2, FUNCTOR_sub2, FUNCTOR_mul2, FUNCTOR_div2, @@ -135,7 +138,7 @@ static PyObject * bip_abs(term_t t) { PyObject *pVal; - + if (! PL_get_arg(1, t, t) ) return NULL; pVal = term_to_python(t); @@ -239,7 +242,7 @@ static PyObject * bip_float(term_t t) { PyObject *pVal, *o; - + if (! PL_get_arg(1, t, t) ) return NULL; pVal = term_to_python(t); @@ -261,7 +264,7 @@ static PyObject * bip_int(term_t t) { PyObject *pVal, *o; - + if (! PL_get_arg(1, t, t) ) return NULL; pVal = term_to_python(t); @@ -290,7 +293,7 @@ static PyObject * bip_long(term_t t) { PyObject *pVal, *o; - + if (! PL_get_arg(1, t, t) ) return NULL; pVal = term_to_python(t); @@ -312,7 +315,7 @@ static PyObject * bip_iter(term_t t) { PyObject *v; - + if (! PL_get_arg(1, t, t) ) return NULL; v = term_to_python(t); @@ -325,7 +328,7 @@ bip_ord(term_t t) { PyObject *pVal; Py_ssize_t size; - + if (! PL_get_arg(1, t, t) ) return NULL; pVal = term_to_python(t); @@ -361,7 +364,7 @@ bip_ord(term_t t) #else return PyLong_FromLong(s[0]); #endif - } else + } else return NULL; } @@ -661,7 +664,7 @@ term_to_python(term_t t) { char *s; atom_t at; - + if (PL_get_atom(t, &at)) { if (at == ATOM_true) return Py_True; if (at == ATOM_false) return Py_False; @@ -711,7 +714,7 @@ term_to_python(term_t t) out = PyList_New(len); if (!out) return NULL; - + for (i=0; i< len; i++) { if (!PL_get_list(t, arg, t)) { return NULL; @@ -896,7 +899,7 @@ term_to_python(term_t t) rhs = term_to_python(targ); if (PySequence_Check(lhs) && ( #if PY_MAJOR_VERSION < 3 - PyInt_Check(rhs) || + PyInt_Check(rhs) || #endif PyLong_Check(rhs)) ){ return PySequence_Repeat(lhs, get_p_int(rhs, 0)); @@ -923,7 +926,7 @@ term_to_python(term_t t) PyNumber_Divide(lhs, rhs); #else return - PyNumber_TrueDivide(lhs, rhs); + PyNumber_TrueDivide(lhs, rhs); #endif } else if (fun == FUNCTOR_hat2) { term_t targ = PL_new_term_ref(), trhs = PL_new_term_ref(); @@ -964,7 +967,7 @@ term_to_python(term_t t) if (!o) return FALSE; if (! PL_get_arg(2, t, t) ) - return FALSE; + return FALSE; if (!PL_get_functor(t, &fun)) break; } @@ -979,7 +982,7 @@ term_to_python(term_t t) return NULL; if ((pValue = PyObject_GetAttrString(o, s)) == NULL) { PyErr_Print(); - return NULL; + return NULL; } return pValue; } @@ -1044,7 +1047,7 @@ assign_python(PyObject *root, term_t t, PyObject *e) case PL_ATOM: { char *s; - + if (!PL_get_atom_chars(t, &s)) { wchar_t *w; atom_t at; @@ -1056,13 +1059,13 @@ assign_python(PyObject *root, term_t t, PyObject *e) if (!(w = PL_atom_wchars(at, &len))) return -1; wo = PyUnicode_FromWideChar(w, wcslen(w) ); - return PyObject_SetAttr(root, wo, e); + return PyObject_SetAttr(root, wo, e); } if (proper_ascii_string(s)) { - return PyObject_SetAttrString(root, s, e); + return PyObject_SetAttrString(root, s, e); } else { PyObject *wo= PyUnicode_DecodeLatin1(s, strlen(s), NULL); - return PyObject_SetAttr(root, wo, e); + return PyObject_SetAttr(root, wo, e); } } case PL_INTEGER: @@ -1080,7 +1083,7 @@ assign_python(PyObject *root, term_t t, PyObject *e) if (fun == FUNCTOR_dollar1) { char *s; - + if (! PL_get_arg(1, t, t) ) return -1; if (!PL_get_atom_chars(t, &s)) { @@ -1147,7 +1150,7 @@ address_to_term(PyObject *pVal, term_t t) PL_put_pointer(t1, (void *)pVal); PL_cons_functor(to, FUNCTOR_pointer1, t1); Py_INCREF(pVal); - return PL_unify(t, to); + return PL_unify(t, to); } static foreign_t @@ -1225,7 +1228,7 @@ python_to_term(PyObject *pVal, term_t t) term_t to = PL_new_term_ref(), ti = to; int left = PyDict_Size(pVal); PyObject *key, *value; - + while (PyDict_Next(pVal, &pos, &key, &value)) { term_t tkey = PL_new_term_ref(), tval = PL_new_term_ref(), tint, tnew = PL_new_term_ref(); /* do something interesting with the values... */ @@ -1257,12 +1260,12 @@ python_to_term(PyObject *pVal, term_t t) static int python_import(term_t mname, term_t mod) -{ +{ char *s; size_t len; PyObject *pName, *pModule; - if ( !PL_get_nchars(mname, &len, &s, CVT_ALL|CVT_EXCEPTION) ) { + if ( !PL_get_nchars(mname, &len, &s, CVT_ALL|CVT_EXCEPTION) ) { return FALSE; } #if PY_MAJOR_VERSION < 3 @@ -1285,7 +1288,7 @@ python_import(term_t mname, term_t mod) static foreign_t python_f(term_t tmod, term_t fname, term_t tf) -{ +{ char *s; size_t len; PyObject *pF, *pModule; @@ -1294,7 +1297,7 @@ python_f(term_t tmod, term_t fname, term_t tf) if ( PL_is_atom(tmod) ) { PyObject *pName; - if ( !PL_get_nchars(fname, &len, &s, CVT_ALL|CVT_EXCEPTION) ) { + if ( !PL_get_nchars(fname, &len, &s, CVT_ALL|CVT_EXCEPTION) ) { return FALSE; } #if PY_MAJOR_VERSION < 3 @@ -1308,7 +1311,7 @@ python_f(term_t tmod, term_t fname, term_t tf) pModule = PyImport_Import(pName); } else if (!(pModule = term_to_python(tmod))) return FALSE; - if ( !PL_get_nchars(fname, &len, &s, CVT_ALL|CVT_EXCEPTION) ) { + if ( !PL_get_nchars(fname, &len, &s, CVT_ALL|CVT_EXCEPTION) ) { return FALSE; } pF = PyObject_GetAttrString(pModule, s); @@ -1322,13 +1325,13 @@ python_f(term_t tmod, term_t fname, term_t tf) static foreign_t python_o(term_t tmod, term_t fname, term_t tf) -{ +{ char *s; size_t len; PyObject *pO, *pModule; pModule = term_to_python(tmod); - if ( !PL_get_nchars(fname, &len, &s, CVT_ALL|CVT_EXCEPTION) ) { + if ( !PL_get_nchars(fname, &len, &s, CVT_ALL|CVT_EXCEPTION) ) { return FALSE; } pO = PyObject_GetAttrString(pModule, s); @@ -1340,7 +1343,7 @@ python_o(term_t tmod, term_t fname, term_t tf) static foreign_t python_len(term_t tobj, term_t tf) -{ +{ Py_ssize_t len; PyObject *o; @@ -1353,7 +1356,7 @@ python_len(term_t tobj, term_t tf) static foreign_t python_dir(term_t tobj, term_t tf) -{ +{ PyObject *dir; PyObject *o; @@ -1366,7 +1369,7 @@ python_dir(term_t tobj, term_t tf) static foreign_t python_is(term_t tobj, term_t tf) -{ +{ PyObject *o; o = term_to_python(tobj); @@ -1377,7 +1380,7 @@ python_is(term_t tobj, term_t tf) static foreign_t python_apply(term_t tin, term_t targs, term_t keywds, term_t tf) -{ +{ PyObject *pF, *pValue; PyObject *pArgs, *pKeywords; int i, arity; @@ -1397,7 +1400,7 @@ python_apply(term_t tin, term_t targs, term_t keywds, term_t tf) return FALSE; } if (aname == ATOM_t) { - if (arity == 0) + if (arity == 0) pArgs = NULL; else pArgs = term_to_python( targs ); @@ -1473,7 +1476,7 @@ python_access(term_t obj, term_t f, term_t out) return FALSE; if ((pValue = PyObject_GetAttrString(o, s)) == NULL) { PyErr_Print(); - return FALSE; + return FALSE; } return python_to_term(pValue, out); } @@ -1490,18 +1493,18 @@ python_access(term_t obj, term_t f, term_t out) lhs = term_to_python(tleft); if ((o = PyObject_GetAttr(o, lhs)) == NULL) { PyErr_Print(); - return FALSE; + return FALSE; } if (! PL_get_arg(2, f, f) ) - return FALSE; + return FALSE; if (! PL_get_name_arity( f, &name, &arity) ) { return FALSE; - } + } } s = PL_atom_chars(name); if ((pF = PyObject_GetAttrString(o, s)) == NULL) { PyErr_Print(); - return FALSE; + return FALSE; } pArgs = PyTuple_New(arity); for (i = 0 ; i < arity; i++) { @@ -1554,13 +1557,13 @@ python_field(term_t f, term_t tobj, term_t tname, term_t tout) } else if ((o = PyObject_GetAttr(o, lhs)) == NULL) { // PyErr_Print(); PyErr_Clear(); - return FALSE; + return FALSE; } if (! PL_get_arg(2, f, f) ) - return FALSE; + return FALSE; if (! PL_get_name_arity( f, &name, &arity) ) { return FALSE; - } + } } s = PL_atom_chars(name); if (!s || !o) { @@ -1568,7 +1571,7 @@ python_field(term_t f, term_t tobj, term_t tname, term_t tout) } else if ((pF = PyObject_GetAttrString(o, s)) == NULL) { // PyErr_Print(); PyErr_Clear(); - return FALSE; + return FALSE; } return address_to_term(pF, tobj) && @@ -1578,13 +1581,13 @@ python_field(term_t f, term_t tobj, term_t tname, term_t tout) static foreign_t python_main_module(term_t mod) -{ +{ return address_to_term(py_Main, mod); } static foreign_t python_function(term_t tobj) -{ +{ PyObject *obj = term_to_python(tobj); return PyFunction_Check(obj); @@ -1592,11 +1595,11 @@ python_function(term_t tobj) static foreign_t python_run_command(term_t cmd) -{ +{ char *s; size_t len; - if ( PL_get_nchars(cmd, &len, &s, CVT_ALL|CVT_EXCEPTION) ) { + if ( PL_get_nchars(cmd, &len, &s, CVT_ALL|CVT_EXCEPTION) ) { PyRun_SimpleString(s); return TRUE; @@ -1606,7 +1609,7 @@ python_run_command(term_t cmd) static foreign_t init_python(void) -{ +{ Py_Initialize(); py_Main = PyImport_AddModule("__main__"); @@ -1615,7 +1618,7 @@ init_python(void) static foreign_t end_python(void) -{ +{ Py_Finalize(); return TRUE; @@ -1677,4 +1680,3 @@ install_python(void) PL_register_foreign("python_run_command", 1, python_run_command, 0); PL_register_foreign("python_main_module", 1, python_main_module, 0); } - diff --git a/packages/raptor b/packages/raptor index 34d9f6457..36f99e3c3 160000 --- a/packages/raptor +++ b/packages/raptor @@ -1 +1 @@ -Subproject commit 34d9f645721645aac9f4f40c815fe4fe2c6511e6 +Subproject commit 36f99e3c3c978fef25f899dc4fab1ffee334d73c diff --git a/packages/swig/android/JavaYap.java b/packages/swig/android/JavaYap.java index 3b1e7d81b..565e2d57b 100644 --- a/packages/swig/android/JavaYap.java +++ b/packages/swig/android/JavaYap.java @@ -1,5 +1,30 @@ package pt.up.fc.dcc.yap; +/**** using sqlite + For example,the following: + + import android.database.sqlite.SQLiteDatabase; + + should be replaced with: + + import org.sqlite.database.sqlite.SQLiteDatabase; + + As well as replacing all uses of the classes in the android.database.sqlite.* namespace, the application must also be sure to use the following two: + + org.sqlite.database.SQLException + org.sqlite.database.DatabaseErrorHandler + + instead of: + + android.database.SQLException + android.database.DatabaseErrorHandler + + Aside from namespace changes, there are other differences from the stock Android interface that applications need to be aware of: + + The SQLiteStatement.simpleQueryForBlobFileDescriptor() API is not available. The collation sequence "UNICODE" is not available. The collation sequence "LOCALIZED", which normally changes with the system's current locale, is always equivalent to SQLite's built in collation BINARY. + +****/ + import android.app.Activity; import android.os.Bundle; import android.view.View; @@ -18,6 +43,7 @@ import org.sqlite.database.sqlite.SQLiteStatement; import org.sqlite.database.sqlite.SQLiteDatabaseCorruptException; import org.sqlite.database.sqlite.SQLiteOpenHelper; +import org.sqlite.database.SQLException; import org.sqlite.database.DatabaseErrorHandler; class DoNotDeleteErrorHandler implements DatabaseErrorHandler { private static final String TAG = "DoNotDeleteErrorHandler"; @@ -49,7 +75,7 @@ public class JavaYap extends Activity // text.setText(""); if (vs0.nil()) { if (BuildConfig.DEBUG) { - Log.i(TAG, "q="); + Log.i(TAG, "q0=\n"); } if (q.next()) { outputText.append( "yes\n" ); @@ -59,12 +85,12 @@ public class JavaYap extends Activity } else { int i=1; if (BuildConfig.DEBUG) { - Log.i(TAG, "q="); + Log.i(TAG, "q1= "+vs0.text()+"\n"); } while (rc = q.next()) { if (BuildConfig.DEBUG) { - Log.i(TAG, "q="); + Log.i(TAG, "q= "+vs0.text()+"\n"); } YAPListTerm vs = vs0;