@@ -16,7 +16,7 @@ package body BBS.lisp.evaluate.func is
16
16
procedure defun (e : out element_type; s : cons_index; p : phase) is
17
17
params : element_type;
18
18
name : element_type;
19
- temp : element_type ;
19
+ temp : cons_index ;
20
20
p2 : element_type;
21
21
p3 : element_type;
22
22
symb : symb_index;
@@ -41,7 +41,7 @@ package body BBS.lisp.evaluate.func is
41
41
--
42
42
p2 := cons_table(s).cdr;
43
43
p3 := cons_table(p2.ps).car; -- Should be a symbol or tempsym
44
- temp := cons_table(p2.ps).cdr; -- Should be parameter list.
44
+ temp := getList( cons_table(p2.ps).cdr) ; -- Should be parameter list.
45
45
--
46
46
-- Process the function name
47
47
--
@@ -75,32 +75,32 @@ package body BBS.lisp.evaluate.func is
75
75
-- functions or local blocks. Thus there should be no stack
76
76
-- variables to check when processing the parameter list.
77
77
--
78
- if isList( temp) then
79
- params := cons_table(getList( temp) ).car;
78
+ if temp > NIL_CONS then
79
+ params := cons_table(temp).car;
80
80
else
81
81
error(" defun" , " Improper parameters." );
82
82
e := (Kind => E_ERROR);
83
83
return ;
84
84
end if ;
85
- temp := params;
85
+ temp := getList( params) ;
86
86
BBS.lisp.stack.start_frame(error_occured);
87
- while temp.Kind = E_CONS loop
88
- if isList(cons_table(temp.ps ).car) then
87
+ while temp > NIL_CONS loop
88
+ if isList(cons_table(temp).car) then
89
89
error(" defun" , " A parameter cannot be a list." );
90
- BBS.lisp.memory.deref(cons_table(temp.ps ).car);
91
- cons_table(temp.ps ).car := (Kind => E_ERROR);
90
+ BBS.lisp.memory.deref(cons_table(temp).car);
91
+ cons_table(temp).car := (Kind => E_ERROR);
92
92
error_occured := True;
93
93
end if ;
94
94
declare
95
- el : element_type := cons_table(temp.ps ).car;
95
+ el : element_type := cons_table(temp).car;
96
96
str : string_index;
97
97
offset : Natural := 1 ;
98
98
begin
99
99
if (el.Kind = E_SYMBOL) then
100
100
if (symb_table(el.sym).Kind = SY_BUILTIN) or
101
101
(symb_table(el.sym).Kind = SY_SPECIAL) then
102
102
error(" defun" , " Parameter can't be a builtin or special symbol." );
103
- cons_table(temp.ps ).car := (Kind => E_ERROR);
103
+ cons_table(temp).car := (Kind => E_ERROR);
104
104
error_occured := True;
105
105
else
106
106
msg(" defun" , " Converting symbol to parameter." );
@@ -123,23 +123,23 @@ package body BBS.lisp.evaluate.func is
123
123
error(" defun" , " Can't convert item into a parameter." );
124
124
print(el, False, True);
125
125
Put_Line(" Item is of kind " & ptr_type'Image(el.kind));
126
- BBS.lisp.memory.deref(cons_table(temp.ps ).car);
127
- cons_table(temp.ps ).car := (Kind => E_ERROR);
126
+ BBS.lisp.memory.deref(cons_table(temp).car);
127
+ cons_table(temp).car := (Kind => E_ERROR);
128
128
error_occured := True;
129
129
end if ;
130
130
offset := offset + 1 ;
131
- cons_table(temp.ps ).car := el;
131
+ cons_table(temp).car := el;
132
132
end ;
133
- temp := cons_table(temp.ps ).cdr;
133
+ temp := getList( cons_table(temp).cdr) ;
134
134
end loop ;
135
135
else
136
136
error(" defun" , " Something went horribly wrong and defun did not get a list." );
137
137
error_occured := True;
138
138
end if ;
139
139
if error_occured then
140
140
BBS.lisp.memory.deref(params);
141
- temp := cons_table(p2.ps).cdr;
142
- cons_table(temp.ps ).car := (Kind => E_ERROR);
141
+ temp := getList( cons_table(p2.ps).cdr) ;
142
+ cons_table(temp).car := (Kind => E_ERROR);
143
143
e := (Kind => E_ERROR);
144
144
end if ;
145
145
when PH_PARSE_END =>
@@ -154,9 +154,9 @@ package body BBS.lisp.evaluate.func is
154
154
return ;
155
155
end if ;
156
156
name := cons_table(s).car;
157
- temp := cons_table(s).cdr;
158
- if isList( temp) then
159
- params := cons_table(getList( temp) ).car;
157
+ temp := getList( cons_table(s).cdr) ;
158
+ if temp > NIL_CONS then
159
+ params := cons_table(temp).car;
160
160
else
161
161
error(" defun" , " Improper parameters." );
162
162
e := (kind => E_ERROR);
@@ -167,7 +167,7 @@ package body BBS.lisp.evaluate.func is
167
167
e := (kind => E_ERROR);
168
168
return ;
169
169
end if ;
170
- if (params.kind /= E_CONS ) and (params.kind /= E_NIL) then
170
+ if (not isList(params) ) and (params.kind /= E_NIL) then
171
171
error(" defun" , " Parameter list must be a list or NIL." );
172
172
e := (kind => E_ERROR);
173
173
return ;
@@ -185,10 +185,10 @@ package body BBS.lisp.evaluate.func is
185
185
elsif symb_table(symb).kind = SY_VARIABLE then
186
186
BBS.lisp.memory.deref(symb_table(symb).pv);
187
187
end if ;
188
- temp := cons_table(s).cdr;
188
+ temp := getList( cons_table(s).cdr) ;
189
189
cons_table(s).cdr := NIL_ELEM;
190
190
symb_table(symb) := (ref => 1 , str => symb_table(symb).str,
191
- kind => SY_LAMBDA, ps => temp.ps );
191
+ kind => SY_LAMBDA, ps => temp);
192
192
end case ;
193
193
e := NIL_ELEM;
194
194
end ;
@@ -205,7 +205,7 @@ package body BBS.lisp.evaluate.func is
205
205
--
206
206
procedure lambda (e : out element_type; s : cons_index; p : phase) is
207
207
params : element_type;
208
- temp : element_type ;
208
+ temp : cons_index ;
209
209
error_occured : Boolean := False;
210
210
begin
211
211
--
@@ -235,26 +235,26 @@ package body BBS.lisp.evaluate.func is
235
235
e := (kind => E_ERROR);
236
236
return ;
237
237
end if ;
238
- temp := params;
238
+ temp := getList( params) ;
239
239
BBS.lisp.stack.start_frame(error_occured);
240
240
declare
241
241
el : element_type;
242
242
str : string_index;
243
243
offset : Natural := 1 ;
244
244
begin
245
- while temp.kind = E_CONS loop
246
- if isList(cons_table(temp.ps ).car) then
245
+ while temp > NIL_CONS loop
246
+ if isList(cons_table(temp).car) then
247
247
error(" lambda" , " A parameter cannot be a list." );
248
- BBS.lisp.memory.deref(cons_table(temp.ps ).car);
249
- cons_table(temp.ps ).car := (Kind => E_ERROR);
248
+ BBS.lisp.memory.deref(cons_table(temp).car);
249
+ cons_table(temp).car := (Kind => E_ERROR);
250
250
error_occured := True;
251
251
end if ;
252
- el := cons_table(temp.ps ).car;
252
+ el := cons_table(temp).car;
253
253
if (el.kind = E_SYMBOL) then
254
254
if (symb_table(el.sym).Kind = SY_BUILTIN) or
255
255
(symb_table(el.sym).Kind = SY_SPECIAL) then
256
256
error(" lambda" , " Parameter can't be a builtin or special symbol." );
257
- cons_table(temp.ps ).car := (Kind => E_ERROR);
257
+ cons_table(temp).car := (Kind => E_ERROR);
258
258
error_occured := True;
259
259
else
260
260
str := symb_table(el.sym).str;
@@ -277,13 +277,13 @@ package body BBS.lisp.evaluate.func is
277
277
error(" lambda" , " Can't convert item into a parameter." );
278
278
print(el, False, True);
279
279
Put_Line(" Item is of kind " & ptr_type'Image(el.kind));
280
- BBS.lisp.memory.deref(cons_table(temp.ps ).car);
281
- cons_table(temp.ps ).car := (Kind => E_ERROR);
280
+ BBS.lisp.memory.deref(cons_table(temp).car);
281
+ cons_table(temp).car := (Kind => E_ERROR);
282
282
error_occured := True;
283
283
end if ;
284
284
offset := offset + 1 ;
285
- cons_table(temp.ps ).car := el;
286
- temp := cons_table(temp.ps ).cdr;
285
+ cons_table(temp).car := el;
286
+ temp := getList( cons_table(temp).cdr) ;
287
287
end loop ;
288
288
end ;
289
289
else
@@ -292,8 +292,8 @@ package body BBS.lisp.evaluate.func is
292
292
end if ;
293
293
if error_occured then
294
294
BBS.lisp.memory.deref(params);
295
- temp := cons_table(s).cdr;
296
- cons_table(temp.ps ).car := (Kind => E_ERROR);
295
+ temp := getList( cons_table(s).cdr) ;
296
+ cons_table(temp).car := (Kind => E_ERROR);
297
297
e := (Kind => E_ERROR);
298
298
end if ;
299
299
when PH_PARSE_END =>
@@ -307,15 +307,15 @@ package body BBS.lisp.evaluate.func is
307
307
e := (kind => E_ERROR);
308
308
return ;
309
309
end if ;
310
- temp := cons_table(s).car;
311
- if isList( temp) then
312
- params := temp;
310
+ temp := getList( cons_table(s).car) ;
311
+ if temp > NIL_CONS then
312
+ params := makeList( temp) ;
313
313
else
314
314
error(" defun" , " Improper parameters." );
315
315
e := (kind => E_ERROR);
316
316
return ;
317
317
end if ;
318
- if (params.kind /= E_CONS ) and (params.kind /= E_NIL) then
318
+ if (not isList(params) ) and (params.kind /= E_NIL) then
319
319
error(" lambda" , " Parameter list must be a list or NIL." );
320
320
e := (kind => E_ERROR);
321
321
return ;
0 commit comments