fix arrays of generic terms.
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@422 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
a4c275daf2
commit
6f051a5025
24
C/arrays.c
24
C/arrays.c
@ -756,23 +756,32 @@ p_create_static_array(void)
|
||||
/* Create a named array */
|
||||
AtomEntry *ae = RepAtom(AtomOfTerm(t));
|
||||
StaticArrayEntry *pp;
|
||||
ArrayEntry *app = (ArrayEntry *) pp;
|
||||
|
||||
WRITE_LOCK(ae->ARWLock);
|
||||
pp = RepStaticArrayProp(ae->PropsOfAE);
|
||||
while (!EndOfPAEntr(pp) && pp->KindOfPE != ArrayProperty)
|
||||
pp = RepStaticArrayProp(pp->NextOfPE);
|
||||
|
||||
app = (ArrayEntry *) pp;
|
||||
if (EndOfPAEntr(pp) || pp->ValueOfVE.ints == NULL) {
|
||||
CreateStaticArray(ae, size, props, NULL, pp);
|
||||
return (TRUE);
|
||||
} else if (ArrayIsDynamic(app)) {
|
||||
if (IsVarTerm(app->ValueOfVE) && IsUnboundVar(app->ValueOfVE)) {
|
||||
CreateStaticArray(ae, size, props, NULL, pp);
|
||||
return (TRUE);
|
||||
} else {
|
||||
Error(PERMISSION_ERROR_CREATE_ARRAY,t,"cannot create static array over dynamic array");
|
||||
return (FALSE);
|
||||
}
|
||||
} else {
|
||||
WRITE_UNLOCK(ae->ARWLock);
|
||||
Error(PERMISSION_ERROR_CREATE_ARRAY,t,"create static array");
|
||||
return(FALSE);
|
||||
Error(PERMISSION_ERROR_CREATE_ARRAY,t,"cannot create static array over static array");
|
||||
return (FALSE);
|
||||
}
|
||||
} else {
|
||||
Error(TYPE_ERROR_ATOM,t,"create static array");
|
||||
return (FALSE);
|
||||
}
|
||||
Error(TYPE_ERROR_ATOM,t,"create static array");
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
/* has a static array associated (+Name) */
|
||||
@ -1399,6 +1408,7 @@ p_assign_static(void)
|
||||
if (indx < 0 || indx >= - ptr->ArrayEArity) {
|
||||
WRITE_UNLOCK(ptr->ArRWLock);
|
||||
Error(DOMAIN_ERROR_ARRAY_OVERFLOW,t2,"assign_static");
|
||||
return(FALSE);
|
||||
}
|
||||
switch (ptr->ArrayType) {
|
||||
case array_of_ints:
|
||||
@ -1534,7 +1544,7 @@ p_assign_static(void)
|
||||
ReleaseTermFromDB(ref);
|
||||
}
|
||||
ptr->ValueOfVE.terms[indx] = StoreTermInDB(3,3);
|
||||
if (ptr->ValueOfVE.terms[indx]){
|
||||
if (ptr->ValueOfVE.terms[indx] == NULL){
|
||||
WRITE_UNLOCK(ptr->ArRWLock);
|
||||
return(FALSE);
|
||||
}
|
||||
|
@ -3353,9 +3353,9 @@ reset the stream and is used for @code{tty} type files, and @code{eof_code},
|
||||
which generates a new @code{end-of-file} (default for non-tty files).
|
||||
|
||||
@item alias(+@var{Name})
|
||||
Specify an alias to the file. The alias @t{Name} must be an atom. The
|
||||
alias can be used instead of the file descriptor for every operation
|
||||
concerning the file.
|
||||
Specify an alias to the stream. The alias @t{Name} must be an atom. The
|
||||
alias can be used instead of the stream descriptor for every operation
|
||||
concerning the stream.
|
||||
|
||||
The operation will fail and give an error if the alias name is already
|
||||
in use. YAP allows several aliases for the same file, but only
|
||||
|
@ -86,7 +86,7 @@ print_message(Level, Mss) :-
|
||||
'$format'(user_error,"[ CONTEXT ERROR- ~w: ~w appeared in ~w ]~n",
|
||||
[Goal,Who,Where]).
|
||||
'$output_error_message'(domain_error(array_overflow,Opt), Where) :-
|
||||
'$format'(user_error,"[ DOMAIN ERROR- ~w: invalid index for array ~w ]~n",
|
||||
'$format'(user_error,"[ DOMAIN ERROR- ~w: invalid index ~w for array ]~n",
|
||||
[Where,Opt]).
|
||||
'$output_error_message'(domain_error(array_type,Opt), Where) :-
|
||||
'$format'(user_error,"[ DOMAIN ERROR- ~w: invalid static array type ~w ]~n",
|
||||
|
Reference in New Issue
Block a user