28 for (i = 0; i < n; i++) {
29 if (!strcmp((
char *)def->name, (
char *)RepAtom(key)->StrOfAE)) {
44 for (i = 0; i < n; i++) {
45 if (!strcmp((
char *)def->name, (
char *)RepAtom(key)->StrOfAE)) {
53#define YAP_XARGINFO(Error, Message)
56xarg *Yap_ArgListToVector__(
const char *file,
const char *
function,
int lineno,
57 Term listl,
const param_t *def,
int n,
59 yap_error_number err) {
62 if (IsVarTerm(listl)) {
64 "while opening listl = ArgOfTerm(2, listl ,k)");
67 a = calloc(n,
sizeof(
xarg));
69 if (!IsPairTerm(listl) && listl != TermNil) {
70 if (IsAtomTerm(listl)) {
71 xarg *na = matchKey(AtomOfTerm(listl), a, n, def);
75 }
else if (IsApplTerm(listl)) {
76 Functor f = FunctorOfTerm(listl);
77 if (IsExtensionFunctor(f)) {
78 Yap_ThrowError__(file,
function, lineno, TYPE_ERROR_LIST, listl,
"callable");
80 arity_t arity = ArityOfFunctor(f);
82 Yap_ThrowError__(file,
function, lineno, TYPE_ERROR_LIST, listl,
"bad arity");
84 xarg *na = matchKey(NameOfFunctor(f), a, n, def);
89 na->tvalue = ArgOfTerm(1, listl);
91 Yap_ThrowError__(file,
function, lineno, TYPE_ERROR_ATOM, listl,
"not atom");
93 listl = MkPairTerm(listl, TermNil);
95 while (IsPairTerm(listl)) {
96 Term hd = HeadOfTerm(listl);
97 listl = TailOfTerm(listl);
99 Yap_ThrowError__(file,
function, lineno, INSTANTIATION_ERROR, hd,
"sub-element");
101 if (IsVarTerm(listl)) {
102 Yap_ThrowError__(file,
function, lineno, INSTANTIATION_ERROR, listl,
"sub-list");
104 if (IsAtomTerm(hd)) {
105 xarg *na = matchKey(AtomOfTerm(hd), a, n, def);
109 na->tvalue = TermNil;
111 }
else if (IsApplTerm(hd)) {
113 if (IsExtensionFunctor(f)) {
116 arity_t arity = ArityOfFunctor(f);
121 xarg *na = matchKey(NameOfFunctor(f), a, n, def);
126 na->tvalue = ArgOfTerm(1, hd);
131 if (IsVarTerm(listl)) {
132 Yap_ThrowError__(file,
function, lineno, INSTANTIATION_ERROR, listl,
"unbound");
133 }
else if (listl != TermNil) {
134 Yap_ThrowError__(file,
function, lineno, TYPE_ERROR_LIST, listl,
"bad list");
141 for (i = 0; i < n; i++) {
142 if (!strcmp((
char *)def->name, (
char *)RepAtom(key)->StrOfAE)) {
156 if (!IsPairTerm(listl) && listl != TermNil) {
157 if (IsVarTerm(listl)) {
158 Yap_ThrowError__(file,
function, lineno, INSTANTIATION_ERROR, listl,
"unbound");
160 if (IsAtomTerm(listl)) {
161 xarg *na = matchKey2(AtomOfTerm(listl), a, n, def);
167 if (IsApplTerm(listl)) {
168 Functor f = FunctorOfTerm(listl);
169 if (IsExtensionFunctor(f)) {
173 arity_t arity = ArityOfFunctor(f);
175 Yap_ThrowError__(file,
function, lineno, TYPE_ERROR_LIST, listl,
"bad arity");
177 xarg *na = matchKey2(NameOfFunctor(f), a, n, def);
185 listl = MkPairTerm(listl, TermNil);
187 while (IsPairTerm(listl)) {
188 Term hd = HeadOfTerm(listl);
192 if (IsAtomTerm(hd)) {
193 xarg *na = matchKey2(AtomOfTerm(hd), a, n, def);
199 na->tvalue = TermNil;
201 }
else if (IsApplTerm(hd)) {
203 if (IsExtensionFunctor(f)) {
204 Yap_ThrowError__(file,
function, lineno, TYPE_ERROR_PARAMETER, hd,
"bad compound");
206 arity_t arity = ArityOfFunctor(f);
211 xarg *na = matchKey2(NameOfFunctor(f), a, n, def);
214 na->tvalue = ArgOfTerm(1, hd);
221 Yap_ThrowError__(file,
function, lineno, INSTANTIATION_ERROR, hd,
"unbound");
223 listl = TailOfTerm(listl);
225 if (IsVarTerm(listl)) {
228 if (TermNil != listl) {
int Yap_ArgKey(Atom key, const param_t *def, int n)
Returns the index of an argument key, or -1 if not found.
xarg * Yap_ArgList2ToVector__(const char *file, const char *function, int lineno, Term listl, const param2_t *def, int n, yap_error_number err)
Yap_ArgList2ToVector is much the same as before, but assumes parameters also have something called a ...
void Yap_ThrowError__(const char *file, const char *function, int lineno, yap_error_number type, Term where, const char *msg,...)
Throw an error directly to the error handler.