Ulrich Neumerkel's patch so that variables are declared in front of a block.
This commit is contained in:
parent
a8e3af4c33
commit
2016e118b3
127
C/absmi.c
127
C/absmi.c
|
@ -610,7 +610,6 @@ char *Yap_op_names[_std_top + 1] =
|
||||||
Int
|
Int
|
||||||
Yap_absmi(int inp)
|
Yap_absmi(int inp)
|
||||||
{
|
{
|
||||||
|
|
||||||
#if BP_FREE
|
#if BP_FREE
|
||||||
/* some function might be using bp for an internal variable, it is the
|
/* some function might be using bp for an internal variable, it is the
|
||||||
callee's responsability to save it */
|
callee's responsability to save it */
|
||||||
|
@ -7422,81 +7421,85 @@ Yap_absmi(int inp)
|
||||||
BOp(execute_cpred, pp);
|
BOp(execute_cpred, pp);
|
||||||
{
|
{
|
||||||
PredEntry *pt0;
|
PredEntry *pt0;
|
||||||
|
|
||||||
BEGD(d0);
|
BEGD(d0);
|
||||||
CACHE_Y_AS_ENV(YREG);
|
CACHE_Y_AS_ENV(YREG);
|
||||||
#ifdef FROZEN_STACKS
|
#ifdef FROZEN_STACKS
|
||||||
{
|
{
|
||||||
choiceptr top_b = PROTECT_FROZEN_B(B);
|
choiceptr top_b = PROTECT_FROZEN_B(B);
|
||||||
|
|
||||||
#ifdef SBA
|
#ifdef SBA
|
||||||
if (YREG > (CELL *) top_b || YREG < H) ASP = (CELL *)top_b;
|
if (YREG > (CELL *) top_b || YREG < H) ASP = (CELL *)top_b;
|
||||||
#else
|
#else
|
||||||
if (YREG > (CELL *) top_b) ASP = (CELL *)top_b;
|
if (YREG > (CELL *) top_b) ASP = (CELL *)top_b;
|
||||||
#endif /* SBA */
|
#endif /* SBA */
|
||||||
else ASP = YREG+E_CB;
|
else ASP = YREG+E_CB;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (YREG > (CELL *) B) {
|
if (YREG > (CELL *) B) {
|
||||||
ASP = (CELL *) B;
|
ASP = (CELL *) B;
|
||||||
} else {
|
} else {
|
||||||
ASP = YREG+E_CB;
|
ASP = YREG+E_CB;
|
||||||
}
|
}
|
||||||
/* for slots to work */
|
/* for slots to work */
|
||||||
#endif /* FROZEN_STACKS */
|
#endif /* FROZEN_STACKS */
|
||||||
pt0 = PREG->u.pp.p;
|
pt0 = PREG->u.pp.p;
|
||||||
#ifdef LOW_LEVEL_TRACER
|
#ifdef LOW_LEVEL_TRACER
|
||||||
if (Yap_do_low_level_trace) {
|
if (Yap_do_low_level_trace) {
|
||||||
low_level_trace(enter_pred,pt0,XREGS+1);
|
low_level_trace(enter_pred,pt0,XREGS+1);
|
||||||
}
|
}
|
||||||
#endif /* LOW_LEVEL_TRACE */
|
#endif /* LOW_LEVEL_TRACE */
|
||||||
CACHE_A1();
|
CACHE_A1();
|
||||||
BEGD(d0);
|
BEGD(d0);
|
||||||
d0 = (CELL)B;
|
d0 = (CELL)B;
|
||||||
#ifndef NO_CHECKING
|
#ifndef NO_CHECKING
|
||||||
check_stack(NoStackExecute, H);
|
check_stack(NoStackExecute, H);
|
||||||
#endif
|
#endif
|
||||||
/* for profiler */
|
/* for profiler */
|
||||||
save_pc();
|
save_pc();
|
||||||
ENV_YREG[E_CB] = d0;
|
ENV_YREG[E_CB] = d0;
|
||||||
ENDD(d0);
|
ENDD(d0);
|
||||||
#ifdef DEPTH_LIMIT
|
#ifdef DEPTH_LIMIT
|
||||||
if (DEPTH <= MkIntTerm(1)) {/* I assume Module==0 is prolog */
|
if (DEPTH <= MkIntTerm(1)) {/* I assume Module==0 is prolog */
|
||||||
if (pt0->ModuleOfPred) {
|
if (pt0->ModuleOfPred) {
|
||||||
if (DEPTH == MkIntTerm(0))
|
if (DEPTH == MkIntTerm(0))
|
||||||
FAIL();
|
FAIL();
|
||||||
else DEPTH = RESET_DEPTH();
|
else DEPTH = RESET_DEPTH();
|
||||||
|
}
|
||||||
|
} else if (pt0->ModuleOfPred) {
|
||||||
|
DEPTH -= MkIntConstant(2);
|
||||||
}
|
}
|
||||||
} else if (pt0->ModuleOfPred)
|
|
||||||
DEPTH -= MkIntConstant(2);
|
|
||||||
#endif /* DEPTH_LIMIT */
|
#endif /* DEPTH_LIMIT */
|
||||||
/* now call C-Code */
|
/* now call C-Code */
|
||||||
CPredicate f = PREG->u.pp.p->cs.f_code;
|
{
|
||||||
yamop *oldPREG = PREG;
|
CPredicate f = PREG->u.pp.p->cs.f_code;
|
||||||
saveregs();
|
yamop *oldPREG = PREG;
|
||||||
d0 = (f)();
|
saveregs();
|
||||||
setregs();
|
d0 = (f)();
|
||||||
|
setregs();
|
||||||
#ifdef SHADOW_S
|
#ifdef SHADOW_S
|
||||||
SREG = Yap_REGS.S_;
|
SREG = Yap_REGS.S_;
|
||||||
#endif
|
#endif
|
||||||
if (!d0) {
|
if (!d0) {
|
||||||
FAIL();
|
FAIL();
|
||||||
}
|
}
|
||||||
if (oldPREG == PREG) {
|
if (oldPREG == PREG) {
|
||||||
/* we did not update PREG */
|
/* we did not update PREG */
|
||||||
/* we can proceed */
|
/* we can proceed */
|
||||||
PREG = CPREG;
|
PREG = CPREG;
|
||||||
ENV_YREG = ENV;
|
ENV_YREG = ENV;
|
||||||
#ifdef DEPTH_LIMIT
|
#ifdef DEPTH_LIMIT
|
||||||
DEPTH = ENV_YREG[E_DEPTH];
|
DEPTH = ENV_YREG[E_DEPTH];
|
||||||
#endif
|
#endif
|
||||||
WRITEBACK_Y_AS_ENV();
|
WRITEBACK_Y_AS_ENV();
|
||||||
} else {
|
} else {
|
||||||
/* call the new code */
|
/* call the new code */
|
||||||
CACHE_A1();
|
CACHE_A1();
|
||||||
}
|
}
|
||||||
JMPNext();
|
}
|
||||||
ENDCACHE_Y_AS_ENV();
|
JMPNext();
|
||||||
ENDD(d0);
|
ENDCACHE_Y_AS_ENV();
|
||||||
|
ENDD(d0);
|
||||||
}
|
}
|
||||||
ENDBOp();
|
ENDBOp();
|
||||||
|
|
||||||
|
|
|
@ -594,12 +594,14 @@ p_power(Term t1, Term t2)
|
||||||
static inline Int
|
static inline Int
|
||||||
ipow(Int x, Int p)
|
ipow(Int x, Int p)
|
||||||
{
|
{
|
||||||
|
Int r;
|
||||||
|
|
||||||
if (p == 0) return 1L;
|
if (p == 0) return 1L;
|
||||||
if (x == 0 && p > 0) return 0L;
|
if (x == 0 && p > 0) return 0L;
|
||||||
if(p < 0)
|
if(p < 0)
|
||||||
return (-p % 2) ? x : 1L;
|
return (-p % 2) ? x : 1L;
|
||||||
|
|
||||||
Int r = 1L;
|
r = 1L;
|
||||||
for(;;) {
|
for(;;) {
|
||||||
if(p & 1) {
|
if(p & 1) {
|
||||||
if (mul_overflow((r*x), r, x)) {
|
if (mul_overflow((r*x), r, x)) {
|
||||||
|
|
|
@ -547,8 +547,8 @@ a_cmp(Term t1, Term t2)
|
||||||
}
|
}
|
||||||
t1 = Yap_Eval(t1);
|
t1 = Yap_Eval(t1);
|
||||||
if (IsIntegerTerm(t1)) {
|
if (IsIntegerTerm(t1)) {
|
||||||
t2 = Yap_Eval(t2);
|
|
||||||
Int i1 = IntegerOfTerm(t1);
|
Int i1 = IntegerOfTerm(t1);
|
||||||
|
t2 = Yap_Eval(t2);
|
||||||
|
|
||||||
if (IsIntegerTerm(t2)) {
|
if (IsIntegerTerm(t2)) {
|
||||||
Int i2 = IntegerOfTerm(t2);
|
Int i2 = IntegerOfTerm(t2);
|
||||||
|
@ -565,8 +565,8 @@ a_cmp(Term t1, Term t2)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
} else if (IsFloatTerm(t1)) {
|
} else if (IsFloatTerm(t1)) {
|
||||||
t2 = Yap_Eval(t2);
|
|
||||||
Float f1 = FloatOfTerm(t1);
|
Float f1 = FloatOfTerm(t1);
|
||||||
|
t2 = Yap_Eval(t2);
|
||||||
|
|
||||||
if (IsIntegerTerm(t2)) {
|
if (IsIntegerTerm(t2)) {
|
||||||
Int i2 = IntegerOfTerm(t2);
|
Int i2 = IntegerOfTerm(t2);
|
||||||
|
|
|
@ -2354,6 +2354,8 @@ sweep_trail(choiceptr gc_B, tr_fr_ptr old_TR)
|
||||||
/* next, clean trail */
|
/* next, clean trail */
|
||||||
source = dest = (tr_fr_ptr)Yap_TrailBase;
|
source = dest = (tr_fr_ptr)Yap_TrailBase;
|
||||||
while (source < old_TR) {
|
while (source < old_TR) {
|
||||||
|
CELL trail_cell;
|
||||||
|
|
||||||
while (next && source == next->cp_tr) {
|
while (next && source == next->cp_tr) {
|
||||||
choiceptr b = next;
|
choiceptr b = next;
|
||||||
b->cp_tr = dest;
|
b->cp_tr = dest;
|
||||||
|
@ -2361,7 +2363,7 @@ sweep_trail(choiceptr gc_B, tr_fr_ptr old_TR)
|
||||||
b->cp_b = current;
|
b->cp_b = current;
|
||||||
current = b;
|
current = b;
|
||||||
}
|
}
|
||||||
CELL trail_cell = TrailTerm(source);
|
trail_cell = TrailTerm(source);
|
||||||
if (trail_cell != (CELL)source) {
|
if (trail_cell != (CELL)source) {
|
||||||
dest++;
|
dest++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6744,6 +6744,10 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, y
|
||||||
}
|
}
|
||||||
update_clause_choice_point(ipc->u.OtILl.n,ap_pc);
|
update_clause_choice_point(ipc->u.OtILl.n,ap_pc);
|
||||||
return ipc->u.OtILl.d;
|
return ipc->u.OtILl.d;
|
||||||
|
#if TABLING
|
||||||
|
case _table_try_single:
|
||||||
|
return (LogUpdClause *)ClauseCodeToStaticClause(ipc);
|
||||||
|
#endif
|
||||||
case _trust_logical:
|
case _trust_logical:
|
||||||
case _count_trust_logical:
|
case _count_trust_logical:
|
||||||
case _profiled_trust_logical:
|
case _profiled_trust_logical:
|
||||||
|
|
14
C/iopreds.c
14
C/iopreds.c
|
@ -184,10 +184,12 @@ static encoding_t
|
||||||
DefaultEncoding(void)
|
DefaultEncoding(void)
|
||||||
{
|
{
|
||||||
char *s = getenv("LANG");
|
char *s = getenv("LANG");
|
||||||
|
size_t sz;
|
||||||
|
|
||||||
/* if we don't have a LNAG then just use ISO_LATIN1 */
|
/* if we don't have a LNAG then just use ISO_LATIN1 */
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return ENC_ISO_LATIN1;
|
return ENC_ISO_LATIN1;
|
||||||
int sz = strlen(s);
|
sz = strlen(s);
|
||||||
if (sz > 5) {
|
if (sz > 5) {
|
||||||
if (s[sz-5] == 'U' &&
|
if (s[sz-5] == 'U' &&
|
||||||
s[sz-4] == 'T' &&
|
s[sz-4] == 'T' &&
|
||||||
|
@ -3490,11 +3492,13 @@ p_has_bom (void)
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_representation_error (void)
|
p_representation_error (void)
|
||||||
{ /* '$representation_error'(+Stream,-ErrorMessage) */
|
{
|
||||||
|
/* '$representation_error'(+Stream,-ErrorMessage) */
|
||||||
|
Term t;
|
||||||
Int sno = CheckStream (ARG1, Input_Stream_f|Output_Stream_f, "representation_errors/1");
|
Int sno = CheckStream (ARG1, Input_Stream_f|Output_Stream_f, "representation_errors/1");
|
||||||
if (sno < 0)
|
if (sno < 0)
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
Term t = Deref(ARG2);
|
t = Deref(ARG2);
|
||||||
|
|
||||||
if (IsVarTerm(t)) {
|
if (IsVarTerm(t)) {
|
||||||
UNLOCK(Stream[sno].streamlock);
|
UNLOCK(Stream[sno].streamlock);
|
||||||
|
@ -5883,6 +5887,8 @@ static Int
|
||||||
p_same_file(void) {
|
p_same_file(void) {
|
||||||
char *f1 = RepAtom(AtomOfTerm(Deref(ARG1)))->StrOfAE;
|
char *f1 = RepAtom(AtomOfTerm(Deref(ARG1)))->StrOfAE;
|
||||||
char *f2 = RepAtom(AtomOfTerm(Deref(ARG2)))->StrOfAE;
|
char *f2 = RepAtom(AtomOfTerm(Deref(ARG2)))->StrOfAE;
|
||||||
|
int out;
|
||||||
|
|
||||||
if (strcmp(f1,f2) == 0)
|
if (strcmp(f1,f2) == 0)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
#if HAVE_LSTAT
|
#if HAVE_LSTAT
|
||||||
|
@ -5934,7 +5940,7 @@ p_same_file(void) {
|
||||||
/* file does not exist, but was opened? Return -1 */
|
/* file does not exist, but was opened? Return -1 */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
int out = (b1->st_ino == b2->st_ino
|
out = (b1->st_ino == b2->st_ino
|
||||||
#ifdef __LCC__
|
#ifdef __LCC__
|
||||||
&& memcmp((const void *)&(b1->st_dev),(const void *)&(b2->st_dev),sizeof(buf1.st_dev)) == 0
|
&& memcmp((const void *)&(b1->st_dev),(const void *)&(b2->st_dev),sizeof(buf1.st_dev)) == 0
|
||||||
#else
|
#else
|
||||||
|
|
Reference in New Issue