blanks and backslashed strings

This commit is contained in:
Vitor Santos Costa 2015-02-10 00:03:02 +00:00
parent 888a58b715
commit afd8c9b9c4
20 changed files with 6953 additions and 2086 deletions

View File

@ -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));
}

View File

@ -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 <sys/stat.h>
#endif
#if HAVE_SYS_SELECT_H && !_MSC_VER && !defined(__MINGW32__)
#if HAVE_SYS_SELECT_H && !_MSC_VER && !defined(__MINGW32__)
#include <sys/select.h>
#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 <windows.h>
#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);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

859
C/write.c

File diff suppressed because it is too large Load Diff

View File

@ -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)

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -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
//! @}

View File

@ -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;
}

View File

@ -26,6 +26,8 @@
#ifndef UTF8_H_INCLUDED
#define UTF8_H_INCLUDED
#include <wchar.h>
#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,

View File

@ -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

@ -1 +1 @@
Subproject commit 849232fea0f549f6704b16afa1c986e0d50ec177
Subproject commit 8257467ff9a7bb901d1688e6a75ad072e0246aba

File diff suppressed because it is too large Load Diff

@ -1 +1 @@
Subproject commit d0d1ee4d58373cc611676103e0a50a3ae451a023
Subproject commit 9972458293415b2d72276bd67875767bfeed00df

View File

@ -1,4 +1,7 @@
#ifdef _XOPEN_SOURCE
#undef _XOPEN_SOURCE // python does its own thing
#endif
#include <Python.h>
#include <SWI-Stream.h>
#include <SWI-Prolog.h>
@ -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);
}

@ -1 +1 @@
Subproject commit 34d9f645721645aac9f4f40c815fe4fe2c6511e6
Subproject commit 36f99e3c3c978fef25f899dc4fab1ffee334d73c

View File

@ -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;