Commit | Line | Data |
---|---|---|
0f2d19dd JB |
1 | /* Copyright (C) 1995,1996 Free Software Foundation, Inc. |
2 | * | |
3 | * This program is free software; you can redistribute it and/or modify | |
4 | * it under the terms of the GNU General Public License as published by | |
5 | * the Free Software Foundation; either version 2, or (at your option) | |
6 | * any later version. | |
7 | * | |
8 | * This program is distributed in the hope that it will be useful, | |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | * GNU General Public License for more details. | |
12 | * | |
13 | * You should have received a copy of the GNU General Public License | |
14 | * along with this software; see the file COPYING. If not, write to | |
15 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
16 | * | |
17 | * As a special exception, the Free Software Foundation gives permission | |
18 | * for additional uses of the text contained in its release of GUILE. | |
19 | * | |
20 | * The exception is that, if you link the GUILE library with other files | |
21 | * to produce an executable, this does not by itself cause the | |
22 | * resulting executable to be covered by the GNU General Public License. | |
23 | * Your use of that executable is in no way restricted on account of | |
24 | * linking the GUILE library code into it. | |
25 | * | |
26 | * This exception does not however invalidate any other reasons why | |
27 | * the executable file might be covered by the GNU General Public License. | |
28 | * | |
29 | * This exception applies only to the code released by the | |
30 | * Free Software Foundation under the name GUILE. If you copy | |
31 | * code from other Free Software Foundation releases into a copy of | |
32 | * GUILE, as the General Public License permits, the exception does | |
33 | * not apply to the code that you add in this way. To avoid misleading | |
34 | * anyone as to the status of such modified files, you must delete | |
35 | * this exception notice from them. | |
36 | * | |
37 | * If you write modifications of your own for GUILE, it is your choice | |
38 | * whether to permit this exception to apply to your modifications. | |
39 | * If you do not wish that, delete this exception notice. | |
40 | */ | |
41 | \f | |
42 | #include <stdio.h> | |
43 | #include "_scm.h" | |
44 | ||
45 | #ifdef __STDC__ | |
46 | #include <stdarg.h> | |
47 | #define var_start(x, y) va_start(x, y) | |
48 | #else | |
49 | #include <varargs.h> | |
50 | #define var_start(x, y) va_start(x) | |
51 | #endif | |
52 | ||
53 | \f | |
54 | ||
55 | ||
56 | /* {Pairs} | |
57 | */ | |
58 | ||
59 | SCM_PROC(s_cons, "cons", 2, 0, 0, scm_cons); | |
60 | #ifdef __STDC__ | |
61 | SCM | |
62 | scm_cons (SCM x, SCM y) | |
63 | #else | |
64 | SCM | |
65 | scm_cons (x, y) | |
66 | SCM x; | |
67 | SCM y; | |
68 | #endif | |
69 | { | |
70 | register SCM z; | |
71 | SCM_NEWCELL (z); | |
72 | SCM_CAR (z) = x; | |
73 | SCM_CDR (z) = y; | |
74 | return z; | |
75 | } | |
76 | ||
77 | #ifdef __STDC__ | |
78 | SCM | |
79 | scm_cons2 (SCM w, SCM x, SCM y) | |
80 | #else | |
81 | SCM | |
82 | scm_cons2 (w, x, y) | |
83 | SCM w; | |
84 | SCM x; | |
85 | SCM y; | |
86 | #endif | |
87 | { | |
88 | register SCM z; | |
89 | SCM_NEWCELL (z); | |
90 | SCM_CAR (z) = x; | |
91 | SCM_CDR (z) = y; | |
92 | x = z; | |
93 | SCM_NEWCELL (z); | |
94 | SCM_CAR (z) = w; | |
95 | SCM_CDR (z) = x; | |
96 | return z; | |
97 | } | |
98 | ||
99 | ||
100 | SCM_PROC(s_pair_p, "pair?", 1, 0, 0, scm_pair_p); | |
101 | #ifdef __STDC__ | |
102 | SCM | |
103 | scm_pair_p(SCM x) | |
104 | #else | |
105 | SCM | |
106 | scm_pair_p(x) | |
107 | SCM x; | |
108 | #endif | |
109 | { | |
110 | if SCM_IMP(x) return SCM_BOOL_F; | |
111 | return SCM_CONSP(x) ? SCM_BOOL_T : SCM_BOOL_F; | |
112 | } | |
113 | ||
114 | SCM_PROC(s_set_car_x, "set-car!", 2, 0, 0, scm_set_car_x); | |
115 | #ifdef __STDC__ | |
116 | SCM | |
117 | scm_set_car_x(SCM pair, SCM value) | |
118 | #else | |
119 | SCM | |
120 | scm_set_car_x(pair, value) | |
121 | SCM pair; | |
122 | SCM value; | |
123 | #endif | |
124 | { | |
125 | SCM_ASSERT(SCM_NIMP(pair) && SCM_CONSP(pair), pair, SCM_ARG1, s_set_car_x); | |
126 | SCM_CAR(pair) = value; | |
127 | return value; | |
128 | } | |
129 | ||
130 | SCM_PROC(s_set_cdr_x, "set-cdr!", 2, 0, 0, scm_set_cdr_x); | |
131 | #ifdef __STDC__ | |
132 | SCM | |
133 | scm_set_cdr_x(SCM pair, SCM value) | |
134 | #else | |
135 | SCM | |
136 | scm_set_cdr_x(pair, value) | |
137 | SCM pair; | |
138 | SCM value; | |
139 | #endif | |
140 | { | |
141 | SCM_ASSERT(SCM_NIMP(pair) && SCM_CONSP(pair), pair, SCM_ARG1, s_set_cdr_x); | |
142 | SCM_CDR(pair) = value; | |
143 | return value; | |
144 | } | |
145 | ||
146 | ||
147 | \f | |
148 | ||
149 | static scm_iproc cxrs[] = | |
150 | { | |
151 | {"car", 0}, | |
152 | {"cdr", 0}, | |
153 | {"caar", 0}, | |
154 | {"cadr", 0}, | |
155 | {"cdar", 0}, | |
156 | {"cddr", 0}, | |
157 | {"caaar", 0}, | |
158 | {"caadr", 0}, | |
159 | {"cadar", 0}, | |
160 | {"caddr", 0}, | |
161 | {"cdaar", 0}, | |
162 | {"cdadr", 0}, | |
163 | {"cddar", 0}, | |
164 | {"cdddr", 0}, | |
165 | {"caaaar", 0}, | |
166 | {"caaadr", 0}, | |
167 | {"caadar", 0}, | |
168 | {"caaddr", 0}, | |
169 | {"cadaar", 0}, | |
170 | {"cadadr", 0}, | |
171 | {"caddar", 0}, | |
172 | {"cadddr", 0}, | |
173 | {"cdaaar", 0}, | |
174 | {"cdaadr", 0}, | |
175 | {"cdadar", 0}, | |
176 | {"cdaddr", 0}, | |
177 | {"cddaar", 0}, | |
178 | {"cddadr", 0}, | |
179 | {"cdddar", 0}, | |
180 | {"cddddr", 0}, | |
181 | {0, 0} | |
182 | }; | |
183 | ||
184 | \f | |
185 | #ifdef __STDC__ | |
186 | void | |
187 | scm_init_pairs (void) | |
188 | #else | |
189 | void | |
190 | scm_init_pairs () | |
191 | #endif | |
192 | { | |
193 | scm_init_iprocs(cxrs, scm_tc7_cxr); | |
194 | #include "pairs.x" | |
195 | } | |
196 |