-
Notifications
You must be signed in to change notification settings - Fork 3
/
prbltin.h
44 lines (38 loc) · 1.69 KB
/
prbltin.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* prbuiltin.h */
#pragma once
extern node_ptr_t Arguments;
extern subst_ptr_t SubstGoal;
extern subst_ptr_t DerefSubst;
extern node_ptr_t DerefNode;
extern char *Print_buffer ;
/* The following macros are not very efficient but easy to use.
* As an example
* ARG_ATOM(6,atomp) is going to set atomp to the atom value of the
* sixth argument of the current if it exists and returns with an error
* otherwise
*/
#define ARG_ATOM(N,A) if(nth_arg(N) == NULL)return(nargerr(N));\
if(NODEPTR_TYPE(DerefNode)!=ATOM)return(typerr(N,ATOM));\
A = NODEPTR_ATOM(DerefNode);
#define ARG_VAR(N,A) if(nth_arg(N) == NULL)return(nargerr(N));\
if(NODEPTR_TYPE(DerefNode)!= VAR)return(typerr(N,VAR));\
A = DerefNode;
#define ARG_STRING(N,A) if(nth_arg(N) == NULL)return(nargerr(N));\
if(NODEPTR_TYPE(DerefNode)!=STRING)return(typerr(N,STRING));\
A = NODEPTR_STRING(DerefNode);
#define ARG_INT(N,A) if(nth_arg(N) == NULL)return(nargerr(N));\
if(NODEPTR_TYPE(DerefNode)!=INT)return(typerr(N,INT));\
A = NODEPTR_INT(DerefNode);
#define ARG_REAL(N,A) if(nth_arg(N) == NULL)return(nargerr(N));\
if(NODEPTR_TYPE(DerefNode)!=REAL)return(typerr(N,REAL));\
A = NODEPTR_REAL(DerefNode);
#define ARG_PAIR(N,A) if(nth_arg(N) == NULL)return(nargerr(N));\
if(NODEPTR_TYPE(DerefNode)!=PAIR)return(typerr(N,PAIR));\
A = NODEPTR_PAIR(DerefNode);
#define ARG_CLAUSE(N,A) if(nth_arg(N) == NULL)return(nargerr(N));\
if(NODEPTR_TYPE(DerefNode)!=CLAUSE)return(typerr(N,CLAUSE));\
A = NODEPTR_CLAUSE(DerefNode);
#define CHECK_TYPE_ARG(N, T)if(nth_arg(N) == NULL)return(nargerr(N));\
if(NODEPTR_TYPE(DerefNode) != T)return(typerr(N, T));
#define FAIL 0
/* end of file */