Eclipse stuff

This commit is contained in:
Vítor Santos Costa 2014-03-13 12:54:06 +00:00
parent 242f585484
commit 4591e1baaf
9 changed files with 62 additions and 43 deletions

View File

@ -850,7 +850,7 @@ interrupt_call( USES_REGS1 )
return v;
PP = P->u.Osbpp.p0;
if (Yap_only_has_signal(YAP_CREEP_SIGNAL) &&
PP->ExtraPredFlags & (NoDebugPredFlag|HiddenPredFlag) )
(PP->ExtraPredFlags & (NoDebugPredFlag|HiddenPredFlag)) )
return 2;
S = (CELL *) P->u.Osbpp.p;
SET_ASP(YENV, P->u.Osbpp.s);

View File

@ -95,7 +95,7 @@ extern X_API Int YAP_PLArityOfSWIFunctor(functor_t at);
/* This is silly, but let's keep it like that for now */
X_API Int
YAP_PLArityOfSWIFunctor(functor_t f) {
if ((CELL)(f) & 2 && ((CELL)f) < N_SWI_FUNCTORS*4+2)
if (((CELL)(f) & 2) && ((CELL)f) < N_SWI_FUNCTORS*4+2)
return ArityOfFunctor(SWI_Functors[(CELL)f/4]);
if (IsAtomTerm(f))
return 0;
@ -1001,7 +1001,7 @@ X_API int PL_throw(term_t exception)
{
CACHE_REGS
YAP_Throw(Yap_GetFromSlot(exception PASS_REGS));
longjmp(LOCAL_execution->env, 0);
longjmp(LOCAL_execution->q_env, 0);
return 0;
}
@ -1315,6 +1315,7 @@ X_API int PL_unify_wchars(term_t t, int type, size_t len, const pl_wchar_t *char
if (LOCAL_Error_TYPE && !Yap_SWIHandleError( "PL_unify_wchars" ))
return FALSE;
}
return FALSE;
}
typedef struct {
@ -2233,43 +2234,43 @@ X_API qid_t PL_open_query(module_t ctx, int flags, predicate_t p, term_t t0)
t = Yap_AddressFromSlot(t0 PASS_REGS);
/* ignore flags and module for now */
open_query *new = (open_query *)Yap_AllocCodeSpace(sizeof(open_query));
qid_t new = (qid_t)Yap_AllocCodeSpace(sizeof(*qid_t));
LOCAL_execution = new;
new->open=1;
new->state=0;
new->flags = flags;
new->pe = (PredEntry *)p;
new->g = t;
return LOCAL_execution;
new->q_open=1;
new->q_state=0;
new->q_flags = flags;
new->q_pe = (PredEntry *)p;
new->q_g = t;
return new;
}
X_API int PL_next_solution(qid_t qi)
{
CACHE_REGS
int result;
if (qi->open != 1) return 0;
if (setjmp(LOCAL_execution->env))
if (qi->q_open != 1) return 0;
if (setjmp(LOCAL_execution->q_env))
return 0;
// don't forget, on success these guys must create slots
if (qi->state == 0) {
result = YAP_EnterGoal((YAP_PredEntryPtr)qi->pe, qi->g, &qi->h);
if (qi->q_state == 0) {
result = YAP_EnterGoal((YAP_PredEntryPtr)qi->q_pe, qi->q_g, &qi->q_h);
} else {
LOCAL_AllowRestart = qi->open;
result = YAP_RetryGoal(&qi->h);
LOCAL_AllowRestart = qi->q_open;
result = YAP_RetryGoal(&qi->q_h);
}
qi->state = 1;
qi->q_state = 1;
if (result == 0) {
YAP_LeaveGoal(FALSE, &qi->h);
qi->open = 0;
YAP_LeaveGoal(FALSE, &qi->q_h);
qi->q_open = 0;
}
return result;
}
X_API void PL_cut_query(qid_t qi)
{
if (qi->open != 1 || qi->state == 0) return;
YAP_LeaveGoal(FALSE, &qi->h);
qi->open = 0;
if (qi->q_open != 1 || qi->q_state == 0) return;
YAP_LeaveGoal(FALSE, &qi->q_h);
qi->q_open = 0;
Yap_FreeCodeSpace( (char *)qi );
}
@ -2277,15 +2278,15 @@ X_API void PL_close_query(qid_t qi)
{
CACHE_REGS
if (EX && !(qi->flags & (PL_Q_CATCH_EXCEPTION))) {
if (EX && !(qi->q_flags & (PL_Q_CATCH_EXCEPTION))) {
EX = NULL;
}
/* need to implement backtracking here */
if (qi->open != 1 || qi->state == 0) {
if (qi->q_open != 1 || qi->q_state == 0) {
return;
}
YAP_LeaveGoal(FALSE, &qi->h);
qi->open = 0;
YAP_LeaveGoal(FALSE, &qi->q_h);
qi->q_open = 0;
Yap_FreeCodeSpace( (char *)qi );
}
@ -2306,6 +2307,7 @@ X_API int PL_toplevel(void)
return TRUE;
}
}
return TRUE;
}
X_API int PL_call(term_t tp, module_t m)

View File

@ -2,14 +2,14 @@ void Yap_swi_install(void);
void Yap_install_blobs(void);
typedef struct open_query_struct {
int open;
int state;
YAP_Term *g;
PredEntry *pe;
yamop *p, *cp;
jmp_buf env;
int flags;
YAP_dogoalinfo h;
int q_open;
int q_state;
YAP_Term *q_g;
PredEntry *q_pe;
yamop *q_p, *q_cp;
jmp_buf q_env;
int q_flags;
YAP_dogoalinfo q_h;
} open_query;
#define addr_hash(V) (((CELL) (V)) >> 4 & (N_SWI_HASH-1))

View File

@ -230,9 +230,13 @@ PL_EXPORT_DATA(IOSTREAM) S__iob[3]; /* Libs standard streams */
#define Sgetchar() Sgetc(Sinput)
#define Sputchar(c) Sputc((c), Soutput)
#define S__checkpasteeof(s,c) \
if ( (c)==-1 && (s)->flags & (SIO_FEOF|SIO_FERR) ) \
((s)->flags |= SIO_FEOF2)
static inline void
S__checkpasteeof(IOSTREAM *s, int c)
{
if ( (c)==-1 && (s)->flags & (SIO_FEOF|SIO_FERR) )
((s)->flags |= SIO_FEOF2);
}
#define S__updatefilepos_getc(s, c) \
((s)->position ? S__fupdatefilepos_getc((s), (c)) \
: S__fcheckpasteeof((s), (c)))

View File

@ -1579,12 +1579,14 @@ readLine(IOSTREAM *in, IOSTREAM *out, char *buffer)
buf--;
continue;
}
/*FALLTHROUGH*/
default:
if ( truePrologFlag(PLFLAG_TTY_CONTROL) )
Sputcode(c, out);
*buf++ = c;
}
}
return FALSE; /* make eclipse happy */
}
@ -1898,9 +1900,9 @@ set_stream(IOSTREAM *s, term_t stream, atom_t aname, term_t a ARG_LD)
clear(s, SIO_REPXML|SIO_REPPL);
if ( val == ATOM_error )
if ( val == ATOM_error ) {
;
else if ( val == ATOM_xml )
} else if ( val == ATOM_xml )
set(s, SIO_REPXML);
else if ( val == ATOM_prolog )
set(s, SIO_REPPL);

View File

@ -511,13 +511,13 @@ get_file_name(term_t n, char **namep, char *tmp, int flags)
PL_put_term(av+0, n);
if ( rc && flags & PL_FILE_EXIST )
if ( rc && (flags & PL_FILE_EXIST) )
rc = add_option(options, FUNCTOR_access1, ATOM_exist);
if ( rc && flags & PL_FILE_READ )
if ( rc && (flags & PL_FILE_READ) )
rc = add_option(options, FUNCTOR_access1, ATOM_read);
if ( rc && flags & PL_FILE_WRITE )
if ( rc && (flags & PL_FILE_WRITE) )
rc = add_option(options, FUNCTOR_access1, ATOM_write);
if ( rc && flags & PL_FILE_EXECUTE )
if ( rc && (flags & PL_FILE_EXECUTE) )
rc = add_option(options, FUNCTOR_access1, ATOM_execute);
if ( rc ) rc = PL_unify_nil(options);

View File

@ -633,6 +633,7 @@ update_linepos(IOSTREAM *s, int c)
break;
case '\t':
p->linepos |= 7;
/*FALLTHROUGH*/
default:
p->linepos++;
}

View File

@ -21,6 +21,8 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#if defined(_WIN32) || defined(__MINGW32__)
#define UNICODE 1
#define _UNICODE 1
@ -781,6 +783,8 @@ out:
simple:
retval = _waccess(buf, mode);
goto out;
return FALSE;
}
@ -943,6 +947,7 @@ readdir(DIR *dp)
if ( (de = translate_data(dp)) )
return de;
}
return FALSE;
}
@ -1070,3 +1075,6 @@ _xos_setenv(const char *name, char *value, int overwrite)
return -1; /* TBD: convert error */
}
#endif

View File

@ -48,6 +48,7 @@ int check_smooth(int *smooth)
case 1: /* p.counts = (none), with 0-valued params */
emit_internal_error("unexpected case in check_smooth()");
RET_ERR(ierr_unmatched_branches);
break;
case 2: /* p.counts = 0 only, w/o 0-valued params */
case 3: /* p.counts = 0 only, with 0-valued params */
*smooth = 0;
@ -58,6 +59,7 @@ int check_smooth(int *smooth)
case 5: /* p.counts = + only, with 0-valued params */
emit_error("parameters fixed to zero in MAP estimation");
RET_ERR(err_invalid_numeric_value);
break;
case 6: /* p.counts = (both), w/o 0-valued params */
case 7: /* p.counts = (both), with 0-valued params */
emit_error("mixture of zero and non-zero pseudo counts");