includ e6.2 changes for globals.
This commit is contained in:
parent
a6d0944996
commit
417fb5c52c
154
C/globals.c
154
C/globals.c
@ -910,30 +910,6 @@ p_nb_setarg( USES_REGS1 )
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
to = Deref(ARG3);
|
to = Deref(ARG3);
|
||||||
if (!IsVarTerm(to)) {
|
|
||||||
Term torig;
|
|
||||||
if (IsIntTerm(to) || IsAtomTerm(to)) {
|
|
||||||
destp[pos] = to;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
torig = Deref(destp[pos]);
|
|
||||||
|
|
||||||
if (IsFloatTerm(to) && !IsVarTerm(torig) && IsFloatTerm(torig) && RepAppl(torig) < RepAppl(GlobalArena)) {
|
|
||||||
CELL *c0 = RepAppl(to);
|
|
||||||
CELL *c1 = RepAppl(torig);
|
|
||||||
#if SIZEOF_DOUBLE == 2*SIZEOF_LONG_INT
|
|
||||||
c1[2] = c0[2];
|
|
||||||
#endif
|
|
||||||
c1[1] = c0[1];
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
if (IsLongIntTerm(to) && !IsVarTerm(torig) && IsLongIntTerm(torig) && RepAppl(torig) < RepAppl(GlobalArena)) {
|
|
||||||
CELL *c0 = RepAppl(to);
|
|
||||||
CELL *c1 = RepAppl(torig);
|
|
||||||
c1[1] = c0[1];
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
to = CopyTermToArena(ARG3, GlobalArena, FALSE, TRUE, 2, &GlobalArena, garena_overflow_size(ArenaPt(GlobalArena) PASS_REGS) PASS_REGS);
|
to = CopyTermToArena(ARG3, GlobalArena, FALSE, TRUE, 2, &GlobalArena, garena_overflow_size(ArenaPt(GlobalArena) PASS_REGS) PASS_REGS);
|
||||||
if (to == 0L)
|
if (to == 0L)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -1044,6 +1020,136 @@ p_nb_linkval( USES_REGS1 )
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static Int
|
||||||
|
p_nb_create_accumulator(void)
|
||||||
|
{
|
||||||
|
Term t = Deref(ARG1), acct, to;
|
||||||
|
CELL *destp;
|
||||||
|
|
||||||
|
if (IsVarTerm(t)) {
|
||||||
|
Yap_Error(INSTANTIATION_ERROR,t,"nb_create_accumulator");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
if (!IsIntegerTerm(t) && !IsBigIntTerm(t) && !IsFloatTerm(t)) {
|
||||||
|
Yap_Error(TYPE_ERROR_NUMBER,t,"nb_create_accumulator");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
acct = Yap_MkApplTerm(FunctorGNumber,1,&t);
|
||||||
|
if (!Yap_unify(ARG2, acct)) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
to = CopyTermToArena(t, GlobalArena, TRUE, TRUE, 2, &GlobalArena, garena_overflow_size(ArenaPt(GlobalArena)));
|
||||||
|
if (to == 0L)
|
||||||
|
return FALSE;
|
||||||
|
destp = RepAppl(Deref(ARG2));
|
||||||
|
destp[1] = to;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Int
|
||||||
|
p_nb_add_to_accumulator(void)
|
||||||
|
{
|
||||||
|
Term t = Deref(ARG1), t0, tadd;
|
||||||
|
Functor f;
|
||||||
|
CELL *destp;
|
||||||
|
|
||||||
|
if (IsVarTerm(t)) {
|
||||||
|
Yap_Error(INSTANTIATION_ERROR,t,"nb_create_accumulator");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
if (!IsApplTerm(t)) {
|
||||||
|
Yap_Error(TYPE_ERROR_NUMBER,t,"nb_accumulator_value");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
f = FunctorOfTerm(t);
|
||||||
|
if (f != FunctorGNumber) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
destp = RepAppl(t);
|
||||||
|
t0 = Deref(destp[1]);
|
||||||
|
tadd = Deref(ARG2);
|
||||||
|
if (IsVarTerm(tadd)) {
|
||||||
|
Yap_Error(INSTANTIATION_ERROR,tadd,"nb_create_accumulator");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
if (IsIntegerTerm(t0) && IsIntegerTerm(tadd)) {
|
||||||
|
Int i0 = IntegerOfTerm(t0);
|
||||||
|
Int i1 = IntegerOfTerm(tadd);
|
||||||
|
Term new = MkIntegerTerm(i0+i1);
|
||||||
|
|
||||||
|
if (IsIntTerm(new)) {
|
||||||
|
/* forget it if it was something else */
|
||||||
|
destp[1] = new;
|
||||||
|
} else {
|
||||||
|
/* long, do we have spapce or not ?? */
|
||||||
|
if (IsLongIntTerm(t0)) {
|
||||||
|
CELL *target = RepAppl(t0);
|
||||||
|
CELL *source = RepAppl(new);
|
||||||
|
target[1] = source[1];
|
||||||
|
} else {
|
||||||
|
/* we need to create a new long int */
|
||||||
|
new = CopyTermToArena(new, GlobalArena, TRUE, TRUE, 2, &GlobalArena, garena_overflow_size(ArenaPt(GlobalArena)));
|
||||||
|
destp = RepAppl(Deref(ARG1));
|
||||||
|
destp[1] = new;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
if (IsFloatTerm(t0) && IsFloatTerm(tadd)) {
|
||||||
|
Float f0 = FloatOfTerm(t0);
|
||||||
|
Float f1 = FloatOfTerm(tadd);
|
||||||
|
Term new = MkFloatTerm(f0+f1);
|
||||||
|
CELL *target = RepAppl(t0);
|
||||||
|
CELL *source = RepAppl(new);
|
||||||
|
|
||||||
|
#if SIZEOF_DOUBLE == 2*SIZEOF_LONG_INT
|
||||||
|
target[2] = source[2];
|
||||||
|
#endif
|
||||||
|
target[1] = source[1];
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
if (IsNumTerm(t0) && IsNumTerm(tadd)) {
|
||||||
|
Term t2[2], new;
|
||||||
|
t2[0] = t0;
|
||||||
|
t2[1] = tadd;
|
||||||
|
new = Yap_MkApplTerm(FunctorPlus, 2, t2);
|
||||||
|
|
||||||
|
new = Yap_Eval(new);
|
||||||
|
new = CopyTermToArena(new, GlobalArena, TRUE, TRUE, 2, &GlobalArena, garena_overflow_size(ArenaPt(GlobalArena)));
|
||||||
|
destp = RepAppl(Deref(ARG1));
|
||||||
|
destp[1] = new;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static Int
|
||||||
|
p_nb_accumulator_value(void)
|
||||||
|
{
|
||||||
|
Term t = Deref(ARG1), to;
|
||||||
|
Functor f;
|
||||||
|
|
||||||
|
if (IsVarTerm(t)) {
|
||||||
|
Yap_Error(INSTANTIATION_ERROR,t,"nb_accumulator_value");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
if (!IsApplTerm(t)) {
|
||||||
|
Yap_Error(TYPE_ERROR_NUMBER,t,"nb_accumulator_value");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
f = FunctorOfTerm(t);
|
||||||
|
if (f != FunctorGNumber) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
to = Yap_CopyTerm(RepAppl(t)[1]);
|
||||||
|
return Yap_unify(to, ARG2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Term
|
Term
|
||||||
Yap_SetGlobalVal(Atom at, Term t0)
|
Yap_SetGlobalVal(Atom at, Term t0)
|
||||||
{
|
{
|
||||||
|
@ -396,6 +396,7 @@
|
|||||||
FunctorNot = Yap_MkFunctor(AtomNot,1);
|
FunctorNot = Yap_MkFunctor(AtomNot,1);
|
||||||
FunctorOr = Yap_MkFunctor(AtomSemic,2);
|
FunctorOr = Yap_MkFunctor(AtomSemic,2);
|
||||||
FunctorPermissionError = Yap_MkFunctor(AtomPermissionError,3);
|
FunctorPermissionError = Yap_MkFunctor(AtomPermissionError,3);
|
||||||
|
FunctorPlus = Yap_MkFunctor(AtomPlus,2);
|
||||||
FunctorPortray = Yap_MkFunctor(AtomPortray,1);
|
FunctorPortray = Yap_MkFunctor(AtomPortray,1);
|
||||||
FunctorPrologConstraint = Yap_MkFunctor(AtomProlog,2);
|
FunctorPrologConstraint = Yap_MkFunctor(AtomProlog,2);
|
||||||
FunctorQuery = Yap_MkFunctor(AtomQuery,1);
|
FunctorQuery = Yap_MkFunctor(AtomQuery,1);
|
||||||
|
@ -396,6 +396,7 @@
|
|||||||
FunctorNot = FuncAdjust(FunctorNot);
|
FunctorNot = FuncAdjust(FunctorNot);
|
||||||
FunctorOr = FuncAdjust(FunctorOr);
|
FunctorOr = FuncAdjust(FunctorOr);
|
||||||
FunctorPermissionError = FuncAdjust(FunctorPermissionError);
|
FunctorPermissionError = FuncAdjust(FunctorPermissionError);
|
||||||
|
FunctorPlus = FuncAdjust(FunctorPlus);
|
||||||
FunctorPortray = FuncAdjust(FunctorPortray);
|
FunctorPortray = FuncAdjust(FunctorPortray);
|
||||||
FunctorPrologConstraint = FuncAdjust(FunctorPrologConstraint);
|
FunctorPrologConstraint = FuncAdjust(FunctorPrologConstraint);
|
||||||
FunctorQuery = FuncAdjust(FunctorQuery);
|
FunctorQuery = FuncAdjust(FunctorQuery);
|
||||||
|
@ -790,6 +790,8 @@
|
|||||||
#define FunctorOr Yap_heap_regs->FunctorOr_
|
#define FunctorOr Yap_heap_regs->FunctorOr_
|
||||||
Functor FunctorPermissionError_;
|
Functor FunctorPermissionError_;
|
||||||
#define FunctorPermissionError Yap_heap_regs->FunctorPermissionError_
|
#define FunctorPermissionError Yap_heap_regs->FunctorPermissionError_
|
||||||
|
Functor FunctorPlus_;
|
||||||
|
#define FunctorPlus Yap_heap_regs->FunctorPlus_
|
||||||
Functor FunctorPortray_;
|
Functor FunctorPortray_;
|
||||||
#define FunctorPortray Yap_heap_regs->FunctorPortray_
|
#define FunctorPortray Yap_heap_regs->FunctorPortray_
|
||||||
Functor FunctorPrologConstraint_;
|
Functor FunctorPrologConstraint_;
|
||||||
|
@ -401,6 +401,7 @@ F NBQueue Queue 4
|
|||||||
F Not Not 1
|
F Not Not 1
|
||||||
F Or Semic 2
|
F Or Semic 2
|
||||||
F PermissionError PermissionError 3
|
F PermissionError PermissionError 3
|
||||||
|
F Plus Plus 2
|
||||||
F Portray Portray 1
|
F Portray Portray 1
|
||||||
F PrologConstraint Prolog 2
|
F PrologConstraint Prolog 2
|
||||||
F Query Query 1
|
F Query Query 1
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 1a0d65780320ecb052c13efe49cbbfcdaa55ea83
|
Subproject commit 5c2419f04dcd32f6929be1785621ed57918af1a4
|
@ -1 +1 @@
|
|||||||
Subproject commit 1be7f59f9950258f3542d4426c87340994e3edf6
|
Subproject commit 652ce8786dfd16f852ef3a30d0365f11375e160f
|
Reference in New Issue
Block a user