fix regression tests
This commit is contained in:
48
C/args.c
48
C/args.c
@@ -31,19 +31,16 @@ xarg *
|
||||
Yap_ArgListToVector (Term listl, const param_t *def, int n)
|
||||
{
|
||||
CACHE_REGS
|
||||
Term *tailp;
|
||||
if (!IsPairTerm(listl) && listl != TermNil) {
|
||||
listl = MkPairTerm( listl, TermNil );
|
||||
}
|
||||
Int length = Yap_SkipList( &listl, &tailp );
|
||||
if (length < 0 )
|
||||
return NULL;
|
||||
xarg *a = calloc( n , sizeof(xarg) );
|
||||
while (IsPairTerm(listl)) {
|
||||
Term hd = HeadOfTerm( listl );
|
||||
listl = TailOfTerm( listl );
|
||||
if (IsVarTerm(hd)) {
|
||||
LOCAL_Error_TYPE = INSTANTIATION_ERROR;
|
||||
LOCAL_Error_Term = hd;
|
||||
free( a );
|
||||
return NULL;
|
||||
}
|
||||
@@ -58,13 +55,15 @@ Yap_ArgListToVector (Term listl, const param_t *def, int n)
|
||||
} else if (IsApplTerm( hd )) {
|
||||
Functor f = FunctorOfTerm( hd );
|
||||
if (IsExtensionFunctor(f)) {
|
||||
LOCAL_Error_TYPE = TYPE_ERROR_PARAMETER;
|
||||
free( a );
|
||||
return NULL;
|
||||
LOCAL_Error_TYPE = TYPE_ERROR_PARAMETER;
|
||||
LOCAL_Error_Term = hd;
|
||||
free( a );
|
||||
return NULL;
|
||||
}
|
||||
arity_t arity = ArityOfFunctor( f );
|
||||
if (arity != 1) {
|
||||
LOCAL_Error_TYPE = DOMAIN_ERROR_OUT_OF_RANGE;
|
||||
LOCAL_Error_Term = hd;
|
||||
free( a );
|
||||
return NULL;
|
||||
}
|
||||
@@ -78,7 +77,7 @@ Yap_ArgListToVector (Term listl, const param_t *def, int n)
|
||||
}
|
||||
}
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
static xarg *
|
||||
matchKey2(Atom key, xarg *e0, int n, const param2_t *def)
|
||||
@@ -95,17 +94,16 @@ matchKey2(Atom key, xarg *e0, int n, const param2_t *def)
|
||||
}
|
||||
|
||||
|
||||
/// Yap_ArgList2ToVector is much the same as before,
|
||||
/// but assumes parameters also have something called a
|
||||
/// scope
|
||||
xarg *
|
||||
Yap_ArgList2ToVector (Term listl, const param2_t *def, int n)
|
||||
{
|
||||
CACHE_REGS
|
||||
Term *tailp;
|
||||
if (!IsPairTerm(listl) && listl != TermNil) {
|
||||
listl = MkPairTerm( listl, TermNil );
|
||||
}
|
||||
Int length = Yap_SkipList( &listl, &tailp );
|
||||
if (length < 0 )
|
||||
return NULL;
|
||||
xarg *a = calloc( n , sizeof(xarg) );
|
||||
while (IsPairTerm(listl)) {
|
||||
Term hd = HeadOfTerm( listl );
|
||||
@@ -124,25 +122,41 @@ Yap_ArgList2ToVector (Term listl, const param2_t *def, int n)
|
||||
} else if (IsApplTerm( hd )) {
|
||||
Functor f = FunctorOfTerm( hd );
|
||||
if (IsExtensionFunctor(f)) {
|
||||
LOCAL_Error_TYPE = TYPE_ERROR_PARAMETER;
|
||||
free( a );
|
||||
return NULL;
|
||||
LOCAL_Error_TYPE = TYPE_ERROR_PARAMETER;
|
||||
LOCAL_Error_Term = hd;
|
||||
free( a );
|
||||
return NULL;
|
||||
}
|
||||
arity_t arity = ArityOfFunctor( f );
|
||||
if (arity != 1) {
|
||||
LOCAL_Error_TYPE = DOMAIN_ERROR_OUT_OF_RANGE;
|
||||
LOCAL_Error_Term = hd;
|
||||
free( a );
|
||||
return NULL;
|
||||
}
|
||||
xarg *na = matchKey2( NameOfFunctor( f ), a, n, def);
|
||||
na->used = 1;
|
||||
na->tvalue = ArgOfTerm(1, hd);
|
||||
if (na) {
|
||||
na->used = 1;
|
||||
na->tvalue = ArgOfTerm(1, hd);
|
||||
}
|
||||
} else {
|
||||
LOCAL_Error_TYPE = TYPE_ERROR_PARAMETER;
|
||||
LOCAL_Error_Term = hd;
|
||||
free( a );
|
||||
return NULL;
|
||||
}
|
||||
listl = TailOfTerm(listl);
|
||||
}
|
||||
if (IsVarTerm(listl)) {
|
||||
LOCAL_Error_TYPE = INSTANTIATION_ERROR;
|
||||
free( a );
|
||||
return NULL;
|
||||
}
|
||||
if (TermNil != listl) {
|
||||
LOCAL_Error_TYPE = TYPE_ERROR_LIST;
|
||||
LOCAL_Error_Term = listl;
|
||||
free( a );
|
||||
return NULL;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
Reference in New Issue
Block a user