1 | ;;;-*-Mode: LISP; Package: CCL -*- |
---|
2 | ;;; |
---|
3 | ;;; Copyright (C) 1994-2001 Digitool, Inc |
---|
4 | ;;; This file is part of OpenMCL. |
---|
5 | ;;; |
---|
6 | ;;; OpenMCL is licensed under the terms of the Lisp Lesser GNU Public |
---|
7 | ;;; License , known as the LLGPL and distributed with OpenMCL as the |
---|
8 | ;;; file "LICENSE". The LLGPL consists of a preamble and the LGPL, |
---|
9 | ;;; which is distributed with OpenMCL as the file "LGPL". Where these |
---|
10 | ;;; conflict, the preamble takes precedence. |
---|
11 | ;;; |
---|
12 | ;;; OpenMCL is referenced in the preamble as the "LIBRARY." |
---|
13 | ;;; |
---|
14 | ;;; The LLGPL is also available online at |
---|
15 | ;;; http://opensource.franz.com/preamble.html |
---|
16 | |
---|
17 | (in-package "CCL") |
---|
18 | |
---|
19 | ;;; Wimp out, but don't choke on (the (values ...) form) |
---|
20 | (defnx1 nx1-the the (&whole call typespec form &environment env) |
---|
21 | (if (and (self-evaluating-p form) |
---|
22 | (not (typep form typespec)) |
---|
23 | (progn (nx1-whine :type call) t)) |
---|
24 | (setq typespec t)) |
---|
25 | ;; Allow VALUES types here (or user-defined types that |
---|
26 | ;; expand to VALUES types). |
---|
27 | (let* ((ctype (values-specifier-type typespec))) |
---|
28 | (if (typep ctype 'values-ctype) |
---|
29 | (setq typespec '*) |
---|
30 | (setq typespec (nx-target-type (type-specifier ctype))))) |
---|
31 | (let* ((*nx-form-type* typespec) |
---|
32 | (transformed (nx-transform form env))) |
---|
33 | (if (and (consp transformed) |
---|
34 | (eq (car transformed) 'the)) |
---|
35 | (setq transformed form)) |
---|
36 | (make-acode |
---|
37 | (%nx1-operator typed-form) |
---|
38 | typespec |
---|
39 | (nx1-transformed-form transformed env)))) |
---|
40 | |
---|
41 | (defnx1 nx1-struct-ref struct-ref (&whole whole structure offset) |
---|
42 | (if (not (fixnump (setq offset (nx-get-fixnum offset)))) |
---|
43 | (nx1-treat-as-call whole) |
---|
44 | (make-acode (%nx1-operator struct-ref) |
---|
45 | (nx1-form structure) |
---|
46 | (nx1-form offset)))) |
---|
47 | |
---|
48 | (defnx1 nx1-struct-set struct-set (&whole whole structure offset newval) |
---|
49 | (if (not (fixnump (setq offset (nx-get-fixnum offset)))) |
---|
50 | (nx1-treat-as-call whole) |
---|
51 | (make-acode |
---|
52 | (%nx1-operator struct-set) |
---|
53 | (nx1-form structure) |
---|
54 | (nx1-form offset) |
---|
55 | (nx1-form newval)))) |
---|
56 | |
---|
57 | (defnx1 nx1-istruct-typep ((istruct-typep)) (&whole whole thing type &environment env) |
---|
58 | (if (and (quoted-form-p type) (symbolp (cadr type))) |
---|
59 | (make-acode (%nx1-operator istruct-typep) |
---|
60 | (nx1-immediate :eq) |
---|
61 | (nx1-form thing) |
---|
62 | (nx1-form type)) |
---|
63 | (nx1-treat-as-call whole))) |
---|
64 | |
---|
65 | (defnx1 nx1-make-list make-list (&whole whole size &rest keys &environment env) |
---|
66 | (if (and keys |
---|
67 | (or |
---|
68 | (neq (list-length keys) 2) |
---|
69 | (neq (nx-transform (%car keys) env) :initial-element))) |
---|
70 | (nx1-treat-as-call whole) |
---|
71 | (make-acode |
---|
72 | (%nx1-operator make-list) |
---|
73 | (nx1-form size) |
---|
74 | (nx1-form (%cadr keys))))) |
---|
75 | |
---|
76 | ;;; New semantics: expansion functions are defined in current lexical environment |
---|
77 | ;;; vice null environment. May be meaningless ... |
---|
78 | (defnx1 nx1-macrolet macrolet (defs &body body) |
---|
79 | (let* ((old-env *nx-lexical-environment*) |
---|
80 | (new-env (new-lexical-environment old-env))) |
---|
81 | (dolist (def defs) |
---|
82 | (destructuring-bind (name arglist &body mbody) def |
---|
83 | (push |
---|
84 | (cons |
---|
85 | name |
---|
86 | (cons |
---|
87 | 'macro |
---|
88 | (multiple-value-bind (function warnings) (compile-named-function (parse-macro name arglist mbody old-env) name old-env) |
---|
89 | (setq *nx-warnings* (append *nx-warnings* warnings)) |
---|
90 | function))) |
---|
91 | (lexenv.functions new-env)))) |
---|
92 | (let* ((*nx-lexical-environment* new-env)) |
---|
93 | (with-nx-declarations (pending) |
---|
94 | (multiple-value-bind (body decls) (parse-body body new-env) |
---|
95 | (nx-process-declarations pending decls) |
---|
96 | (nx1-progn-body body)))))) |
---|
97 | |
---|
98 | ;;; Does SYMBOL-MACROLET allow declarations ? Yes ... |
---|
99 | (defnx1 nx1-symbol-macrolet symbol-macrolet (defs &body forms) |
---|
100 | (let* ((old-env *nx-lexical-environment*)) |
---|
101 | (with-nx-declarations (pending) |
---|
102 | (multiple-value-bind (body decls) |
---|
103 | (parse-body forms old-env nil) |
---|
104 | (nx-process-declarations pending decls) |
---|
105 | (let ((env *nx-lexical-environment*) |
---|
106 | (*nx-bound-vars* *nx-bound-vars*)) |
---|
107 | (dolist (def defs) |
---|
108 | (destructuring-bind (sym expansion) def |
---|
109 | (let* ((var (nx-new-var pending sym)) |
---|
110 | (bits (nx-var-bits var))) |
---|
111 | (when (%ilogbitp $vbitspecial bits) |
---|
112 | (nx-error "SPECIAL declaration applies to symbol macro ~s" sym)) |
---|
113 | (nx-set-var-bits var (%ilogior (%ilsl $vbitignoreunused 1) bits)) |
---|
114 | (setf (var-ea var) (cons :symbol-macro expansion))))) |
---|
115 | (nx-effect-other-decls pending env) |
---|
116 | (nx1-env-body body old-env)))))) |
---|
117 | |
---|
118 | (defnx1 nx1-progn progn (&body args) |
---|
119 | (nx1-progn-body args)) |
---|
120 | |
---|
121 | (defnx1 nx1-with-c-frame with-c-frame (var &body body) |
---|
122 | (make-acode (%nx1-operator with-c-frame) |
---|
123 | (nx1-form `(let* ((,var (%foreign-stack-pointer))) |
---|
124 | ,@body)))) |
---|
125 | |
---|
126 | (defnx1 nx1-with-variable-c-frame with-variable-c-frame (size var &body body) |
---|
127 | (make-acode (%nx1-operator with-variable-c-frame) |
---|
128 | (nx1-form size) |
---|
129 | (nx1-form `(let* ((,var (%foreign-stack-pointer))) |
---|
130 | ,@body)))) |
---|
131 | |
---|
132 | |
---|
133 | (defun nx1-progn-body (args) |
---|
134 | (if (null (cdr args)) |
---|
135 | (nx1-form (%car args)) |
---|
136 | (make-acode (%nx1-operator progn) (nx1-formlist args)))) |
---|
137 | |
---|
138 | (defnx1 nx1-unaryop ((%word-to-int) (uvsize) (%reference-external-entry-point) |
---|
139 | (%symbol->symptr)) |
---|
140 | (arg) |
---|
141 | (make-acode |
---|
142 | (%nx1-default-operator) (nx1-form arg))) |
---|
143 | |
---|
144 | (defnx1 nx1-nullaryop ((%current-tcr) (%interrupt-poll) (%foreign-stack-pointer) (%current-frame-ptr)) () |
---|
145 | (make-acode (%nx1-default-operator))) |
---|
146 | |
---|
147 | (defnx1 nx1-fixnum-ref ((%fixnum-ref) (%fixnum-ref-natural)) (base &optional (offset 0)) |
---|
148 | (make-acode (%nx1-default-operator) |
---|
149 | (nx1-form base) |
---|
150 | (nx1-form offset))) |
---|
151 | |
---|
152 | (defnx1 nx1-type-unaryop ((typecode) (lisptag) (fulltag)) |
---|
153 | (arg) |
---|
154 | (let* ((operator |
---|
155 | (case *nx-sfname* |
---|
156 | ((typecode) (%nx1-operator typecode)) |
---|
157 | ((lisptag) (%nx1-operator lisptag)) |
---|
158 | (( fulltag) (%nx1-operator fulltag))))) |
---|
159 | (make-acode |
---|
160 | operator (nx1-form arg)))) |
---|
161 | |
---|
162 | |
---|
163 | (defnx1 nx1-code-char ((code-char)) (arg &environment env) |
---|
164 | (make-acode (if (nx-form-typep arg '(unsigned-byte 8) env) |
---|
165 | (%nx1-operator %code-char) |
---|
166 | (%nx1-operator code-char)) |
---|
167 | (nx1-form arg))) |
---|
168 | |
---|
169 | (defnx1 nx1-char-code ((char-code)) (arg &environment env) |
---|
170 | (make-acode (if (nx-form-typep arg 'character env) |
---|
171 | (%nx1-operator %char-code) |
---|
172 | (%nx1-operator char-code)) |
---|
173 | (nx1-form arg))) |
---|
174 | |
---|
175 | (defnx1 nx1-cXr ((car) (cdr)) (arg &environment env) |
---|
176 | (let* ((op (if (eq *nx-sfname* 'car) (%nx1-operator car) (%nx1-operator cdr))) |
---|
177 | (inline-op (if (eq op (%nx1-operator car)) (%nx1-operator %car) (%nx1-operator %cdr)))) |
---|
178 | (make-acode (if (or (nx-inline-car-cdr env) (nx-form-typep arg 'list env)) |
---|
179 | inline-op |
---|
180 | op) |
---|
181 | (nx1-prefer-areg arg env)))) |
---|
182 | |
---|
183 | (defnx1 nx1-rplacX ((rplaca) (rplacd)) (pairform valform &environment env) |
---|
184 | (let* ((op (if (eq *nx-sfname* 'rplaca) (%nx1-operator rplaca) (%nx1-operator rplacd))) |
---|
185 | (inline-op (if (eq op (%nx1-operator rplaca)) (%nx1-operator %rplaca) (%nx1-operator %rplacd)))) |
---|
186 | (make-acode (if (or (nx-inline-car-cdr env) |
---|
187 | (and (nx-trust-declarations env) |
---|
188 | (or (subtypep *nx-form-type* 'cons) |
---|
189 | (nx-form-typep pairform 'cons env)))) |
---|
190 | inline-op |
---|
191 | op) |
---|
192 | (nx1-prefer-areg pairform env) |
---|
193 | (nx1-form valform)))) |
---|
194 | |
---|
195 | (defnx1 nx1-set-cXr ((set-car) (set-cdr)) (pairform valform &environment env) |
---|
196 | (let* ((op (if (eq *nx-sfname* 'set-car) (%nx1-operator set-car) (%nx1-operator set-cdr))) |
---|
197 | (inline-op (if (eq op (%nx1-operator set-car)) (%nx1-operator %rplaca) (%nx1-operator %rplacd))) |
---|
198 | (inline-p (or (nx-inline-car-cdr env) |
---|
199 | (and (nx-trust-declarations env) |
---|
200 | (or (subtypep *nx-form-type* 'cons) |
---|
201 | (nx-form-typep pairform 'cons env))))) |
---|
202 | (acode (make-acode (if inline-p inline-op op) |
---|
203 | (nx1-prefer-areg pairform env) |
---|
204 | (nx1-form valform)))) |
---|
205 | (if inline-p |
---|
206 | (make-acode (if (eq op (%nx1-operator set-car)) (%nx1-operator %car) (%nx1-operator %cdr)) acode) |
---|
207 | acode))) |
---|
208 | |
---|
209 | (defun nx1-cc-binaryop (op cc form1 form2) |
---|
210 | (make-acode op (nx1-immediate cc) (nx1-form form1) (nx1-form form2))) |
---|
211 | |
---|
212 | (defnx1 nx1-ccEQ-unaryop ((characterp) (endp) (consp) (base-char-p)) (arg) |
---|
213 | (make-acode (%nx1-default-operator) (nx1-immediate :EQ) (nx1-form arg))) |
---|
214 | |
---|
215 | |
---|
216 | |
---|
217 | (defnx1 nx1-ccEQ-binaryop ( (%ptr-eql) (eq)) |
---|
218 | (form1 form2) |
---|
219 | (nx1-cc-binaryop (%nx1-default-operator) :eq form1 form2)) |
---|
220 | |
---|
221 | |
---|
222 | (defnx1 nx1-ccNE-binaryop ((neq)) |
---|
223 | (form1 form2) |
---|
224 | (nx1-cc-binaryop (%nx1-default-operator) :ne form1 form2)) |
---|
225 | |
---|
226 | (defnx1 nx1-logbitp ((logbitp)) (&whole w bitnum int &environment env) |
---|
227 | (if (and (nx-form-typep bitnum |
---|
228 | (target-word-size-case (32 '(integer 0 29)) |
---|
229 | (64 '(integer 0 60))) env) |
---|
230 | (nx-form-typep int 'fixnum env)) |
---|
231 | (nx1-cc-binaryop (%nx1-operator %ilogbitp) :ne bitnum int) |
---|
232 | (make-acode (%nx1-operator logbitp) (nx1-form bitnum) (nx1-form int)))) |
---|
233 | |
---|
234 | |
---|
235 | |
---|
236 | (defnx1 nx1-ccGT-unaryop ((int>0-p)) (arg) |
---|
237 | (make-acode (%nx1-default-operator) (nx1-immediate :gt) (nx1-form arg))) |
---|
238 | |
---|
239 | (defnx1 nx1-macro-unaryop (multiple-value-list) (arg) |
---|
240 | (make-acode |
---|
241 | (%nx1-default-operator) (nx1-form arg))) |
---|
242 | |
---|
243 | (defnx1 nx1-atom ((atom)) (arg) |
---|
244 | (nx1-form `(not (consp ,arg)))) |
---|
245 | |
---|
246 | (defnx1 nx1-locally locally (&body forms) |
---|
247 | (with-nx-declarations (pending) |
---|
248 | (let ((env *nx-lexical-environment*)) |
---|
249 | (multiple-value-bind (body decls) (parse-body forms env nil) |
---|
250 | (nx-process-declarations pending decls) |
---|
251 | (nx-effect-other-decls pending env) |
---|
252 | (setq body (nx1-progn-body body)) |
---|
253 | (if decls |
---|
254 | (make-acode (%nx1-operator %decls-body) body *nx-new-p2decls*) |
---|
255 | body))))) |
---|
256 | |
---|
257 | (defnx1 nx1-%new-ptr (%new-ptr) (&whole whole size clear-p) |
---|
258 | (make-acode (%nx1-operator %new-ptr) (nx1-form size) (nx1-form clear-p))) |
---|
259 | |
---|
260 | ;;; This might also want to look at, e.g., the last form in a progn: |
---|
261 | ;;; (not (progn ... x)) => (progn ... (not x)), etc. |
---|
262 | (defnx1 nx1-negation ((not) (null)) (arg) |
---|
263 | (if (nx1-negate-form (setq arg (nx1-form arg))) |
---|
264 | arg |
---|
265 | (make-acode (%nx1-operator not) (nx1-immediate :eq) arg))) |
---|
266 | |
---|
267 | (defun nx1-negate-form (form) |
---|
268 | (let* ((subform (nx-untyped-form form))) |
---|
269 | (when (and (acode-p subform) (typep (acode-operator subform) 'fixnum)) |
---|
270 | (let* ((op (acode-operator subform))) |
---|
271 | (declare (fixnum op)) |
---|
272 | (when (logbitp operator-cc-invertable-bit op) |
---|
273 | (%rplaca |
---|
274 | (%cdr (%cadr subform)) |
---|
275 | (acode-invert-condition-keyword (%cadr (%cadr subform)))) |
---|
276 | t))))) |
---|
277 | |
---|
278 | ;;; This is called from pass 1, and therefore shouldn't mess with "puntable bindings" |
---|
279 | ;;; (assuming, of course, that anyone should ...) |
---|
280 | (defun nx-untyped-form (form) |
---|
281 | (while (and (consp form) |
---|
282 | (eq (%car form) (%nx1-operator typed-form))) |
---|
283 | (setq form (%caddr form))) |
---|
284 | form) |
---|
285 | |
---|
286 | |
---|
287 | |
---|
288 | (defnx1 nx1-cxxr ((caar) (cadr) (cdar) (cddr)) (form) |
---|
289 | (let* ((op *nx-sfname*)) |
---|
290 | (let* ((inner (case op |
---|
291 | ((cdar caar) 'car) |
---|
292 | (t 'cdr))) |
---|
293 | (outer (case op |
---|
294 | ((cdar cddr) 'cdr) |
---|
295 | (t 'car)))) |
---|
296 | (nx1-form `(,outer (,inner ,form)))))) |
---|
297 | |
---|
298 | (defnx1 nx1-%int-to-ptr ((%int-to-ptr)) (int) |
---|
299 | (make-acode |
---|
300 | (%nx1-operator %consmacptr%) |
---|
301 | (make-acode (%nx1-operator %immediate-int-to-ptr) |
---|
302 | (nx1-form int)))) |
---|
303 | |
---|
304 | (defnx1 nx1-%ptr-to-int ((%ptr-to-int)) (ptr) |
---|
305 | (make-acode |
---|
306 | (%nx1-operator %immediate-ptr-to-int) |
---|
307 | (make-acode (%nx1-operator %macptrptr%) |
---|
308 | (nx1-form ptr)))) |
---|
309 | |
---|
310 | (defnx1 nx1-%null-ptr-p ((%null-ptr-p)) (ptr) |
---|
311 | (nx1-form `(%ptr-eql ,ptr (%int-to-ptr 0)))) |
---|
312 | |
---|
313 | (defnx1 nx1-binop ( (%ilsl) (%ilsr) (%iasr) |
---|
314 | (cons) (%temp-cons)) |
---|
315 | (arg1 arg2) |
---|
316 | (make-acode (%nx1-default-operator) (nx1-form arg1) (nx1-form arg2))) |
---|
317 | |
---|
318 | |
---|
319 | |
---|
320 | (defnx1 nx1-%misc-ref ((%misc-ref)) (v i) |
---|
321 | (make-acode (%nx1-operator uvref) (nx1-form v) (nx1-form i))) |
---|
322 | |
---|
323 | |
---|
324 | |
---|
325 | |
---|
326 | (defnx1 nx1-schar ((schar)) (s i &environment env) |
---|
327 | (make-acode (%nx1-operator %sbchar) (nx1-form s env) (nx1-form i env))) |
---|
328 | |
---|
329 | |
---|
330 | ;;; This has to be ultra-bizarre because %schar is a macro. |
---|
331 | ;;; %schar shouldn't be a macro. |
---|
332 | (defnx1 nx1-%schar ((%schar)) (&whole w arg idx &environment env) |
---|
333 | (let* ((arg (nx-transform arg env)) |
---|
334 | (idx (nx-transform idx env)) |
---|
335 | (argvar (make-symbol "STRING")) |
---|
336 | (idxvar (make-symbol "INDEX"))) |
---|
337 | (nx1-form `(let* ((,argvar ,arg) |
---|
338 | (,idxvar ,idx)) |
---|
339 | (declare (optimize (speed 3) (safety 0))) |
---|
340 | (declare (simple-base-string ,argvar)) |
---|
341 | (schar ,argvar ,idxvar)) env))) |
---|
342 | |
---|
343 | (defnx1 nx1-%scharcode ((%scharcode)) (arg idx &environment env) |
---|
344 | (make-acode (%nx1-operator %scharcode) (nx1-form arg)(nx1-form idx))) |
---|
345 | |
---|
346 | |
---|
347 | (defnx1 nx1-svref ((svref) (%svref)) (&environment env v i) |
---|
348 | (make-acode (if (nx-inhibit-safety-checking env) |
---|
349 | (%nx1-operator %svref) |
---|
350 | (%nx1-default-operator)) |
---|
351 | (nx1-prefer-areg v env) |
---|
352 | (nx1-form i))) |
---|
353 | |
---|
354 | (defnx1 nx1-%slot-ref ((%slot-ref)) (instance idx) |
---|
355 | (make-acode (%nx1-default-operator) |
---|
356 | (nx1-form instance) |
---|
357 | (nx1-form idx))) |
---|
358 | |
---|
359 | |
---|
360 | (defnx1 nx1-%err-disp ((%err-disp)) (&rest args) |
---|
361 | (make-acode (%nx1-operator %err-disp) |
---|
362 | (nx1-arglist args))) |
---|
363 | |
---|
364 | (defnx1 nx1-macro-binop ((nth-value)) (arg1 arg2) |
---|
365 | (make-acode (%nx1-default-operator) (nx1-form arg1) (nx1-form arg2))) |
---|
366 | |
---|
367 | (defnx1 nx1-%typed-miscref ((%typed-miscref) (%typed-misc-ref)) (subtype uvector index) |
---|
368 | (make-acode (%nx1-operator %typed-uvref) |
---|
369 | (nx1-form subtype) |
---|
370 | (nx1-form uvector) |
---|
371 | (nx1-form index))) |
---|
372 | |
---|
373 | |
---|
374 | |
---|
375 | (defnx1 nx1-%typed-miscset ((%typed-miscset) (%typed-misc-set)) (subtype uvector index newvalue) |
---|
376 | (make-acode (%nx1-operator %typed-uvset) |
---|
377 | (nx1-form subtype) |
---|
378 | (nx1-form uvector) |
---|
379 | (nx1-form index) |
---|
380 | (nx1-form newvalue))) |
---|
381 | |
---|
382 | (defnx1 nx1-logior-2 ((logior-2)) (&whole w &environment env arg-1 arg-2) |
---|
383 | (nx-binary-boole-op w |
---|
384 | env |
---|
385 | arg-1 |
---|
386 | arg-2 |
---|
387 | (%nx1-operator %ilogior2) |
---|
388 | (%nx1-operator logior2) |
---|
389 | (%nx1-operator %natural-logior))) |
---|
390 | |
---|
391 | (defnx1 nx1-logxor-2 ((logxor-2)) (&whole w &environment env arg-1 arg-2) |
---|
392 | (nx-binary-boole-op w |
---|
393 | env |
---|
394 | arg-1 |
---|
395 | arg-2 |
---|
396 | (%nx1-operator %ilogxor2) |
---|
397 | (%nx1-operator logxor2) |
---|
398 | (%nx1-operator %natural-logxor))) |
---|
399 | |
---|
400 | (defnx1 nx1-logand-2 ((logand-2)) (&whole w &environment env arg-1 arg-2) |
---|
401 | (nx-binary-boole-op w |
---|
402 | env |
---|
403 | arg-1 |
---|
404 | arg-2 |
---|
405 | (%nx1-operator %ilogand2) |
---|
406 | (%nx1-operator logand2) |
---|
407 | (%nx1-operator %natural-logand))) |
---|
408 | |
---|
409 | (defnx1 nx1-require ((require-simple-vector) (require-simple-string) (require-integer) (require-list) |
---|
410 | (require-fixnum) (require-real) (require-character) (require-number) (require-symbol) (require-s8) (require-u8) (require-s16) (require-u16) (require-s32) (require-u32) (require-s64) (require-u64)) |
---|
411 | (arg) |
---|
412 | (make-acode (%nx1-default-operator) (nx1-form arg))) |
---|
413 | |
---|
414 | (defnx1 nx1-%marker-marker ((%unbound-marker) (%slot-unbound-marker) (%illegal-marker)) () |
---|
415 | (make-acode (%nx1-default-operator))) |
---|
416 | |
---|
417 | (defnx1 nx1-throw (throw) (tag valuesform) |
---|
418 | (make-acode (%nx1-operator throw) (nx1-form tag) (nx1-form valuesform))) |
---|
419 | |
---|
420 | |
---|
421 | ;;; This is still used in inlining/lambda application. |
---|
422 | ;;; The tricky parts of handling inlining reasonably have to do with |
---|
423 | ;;; processing the body (including &optional/&key forms) in the environment |
---|
424 | ;;; in which the lambda was defined (e.g., macros and symbol-macros.) |
---|
425 | ;;; (I'm not sure that the traditional MCL/OpenMCL frontend handles |
---|
426 | ;;; these cases 100% correctly, but it seems difficult to do this |
---|
427 | ;;; correctly without being able to jerk around with the environment, |
---|
428 | ;;; for a variety of reasons.) |
---|
429 | ;;; A lambda application - ((lambda ()) ...) is applied in the same |
---|
430 | ;;; environment it's defined in, so the hard case involves inlining |
---|
431 | ;;; functions whose environment may contain syntactic constructs |
---|
432 | ;;; not present in the current environment (and which does -not- generally |
---|
433 | ;;; contain whatever randomness is floating around at the point of |
---|
434 | ;;; application.) |
---|
435 | (defun nx1-destructure (lambda-list bindform cdr-p &whole-allowed-p forms &optional (body-env *nx-lexical-environment*)) |
---|
436 | (let* ((old-env body-env) |
---|
437 | (*nx-bound-vars* *nx-bound-vars*) |
---|
438 | (bindform (nx1-form bindform))) |
---|
439 | (if (not (verify-lambda-list lambda-list t &whole-allowed-p)) |
---|
440 | (nx-error "Invalid lambda-list ~s" lambda-list) |
---|
441 | (let* ((*nx-lexical-environment* body-env)) |
---|
442 | (with-nx-declarations (pending) |
---|
443 | (multiple-value-bind (body decls) |
---|
444 | (parse-body forms *nx-lexical-environment*) |
---|
445 | (nx-process-declarations pending decls) |
---|
446 | (multiple-value-bind (req opt rest keys auxen whole) |
---|
447 | (nx-parse-structured-lambda-list pending lambda-list nil &whole-allowed-p) |
---|
448 | (nx-effect-other-decls pending *nx-lexical-environment*) |
---|
449 | (make-acode |
---|
450 | (%nx1-operator debind) |
---|
451 | nil |
---|
452 | bindform |
---|
453 | req |
---|
454 | opt |
---|
455 | rest |
---|
456 | keys |
---|
457 | auxen |
---|
458 | whole |
---|
459 | (nx1-env-body body old-env) |
---|
460 | *nx-new-p2decls* |
---|
461 | cdr-p)))))))) |
---|
462 | |
---|
463 | |
---|
464 | |
---|
465 | (defnx1 nx1-%setf-macptr ((%setf-macptr)) (ptr newval) |
---|
466 | (let* ((arg1 (nx1-form ptr)) |
---|
467 | (arg2 (nx1-form newval))) |
---|
468 | (if (and (consp arg1) (eq (%car arg1) (%nx1-operator %consmacptr%))) |
---|
469 | ;e.g. (%setf-macptr (%null-ptr) <foo>) |
---|
470 | (make-acode (%nx1-operator %consmacptr%) |
---|
471 | (make-acode (%nx1-operator progn) |
---|
472 | (list arg1 (make-acode (%nx1-operator %macptrptr%) arg2)))) |
---|
473 | (make-acode (%nx1-operator %setf-macptr) arg1 arg2)))) |
---|
474 | |
---|
475 | (defnx1 nx1-%setf-double-float ((%setf-double-float)) (double-node double-val) |
---|
476 | (make-acode (%nx1-operator %setf-double-float) (nx1-form double-node) (nx1-form double-val))) |
---|
477 | |
---|
478 | (defnx1 nx1-%setf-short-float ((%setf-short-float) (%setf-single-float)) (short-node short-val) |
---|
479 | (target-word-size-case |
---|
480 | (32 |
---|
481 | (make-acode (%nx1-operator %setf-short-float) (nx1-form short-node) (nx1-form short-val))) |
---|
482 | (64 |
---|
483 | (error "%SETF-SHORT-FLOAT makes no sense on 64-bit platforms.")))) |
---|
484 | |
---|
485 | |
---|
486 | (defnx1 nx1-%inc-ptr ((%inc-ptr)) (ptr &optional (increment 1)) |
---|
487 | (make-acode (%nx1-operator %consmacptr%) |
---|
488 | (make-acode (%nx1-operator %immediate-inc-ptr) |
---|
489 | (make-acode (%nx1-operator %macptrptr%) (nx1-form ptr)) |
---|
490 | (nx1-form increment)))) |
---|
491 | |
---|
492 | (defnx1 nx1-svset ((svset) (%svset)) (&environment env vector index value) |
---|
493 | (make-acode (if (nx-inhibit-safety-checking env) |
---|
494 | (%nx1-operator %svset) |
---|
495 | (%nx1-default-operator)) |
---|
496 | (nx1-prefer-areg vector env) (nx1-form index) (nx1-form value))) |
---|
497 | |
---|
498 | (defnx1 nx1-+ ((+-2)) (&whole whole &environment env num1 num2) |
---|
499 | (let* ((f1 (nx1-form num1)) |
---|
500 | (f2 (nx1-form num2))) |
---|
501 | (if (nx-binary-fixnum-op-p num1 num2 env t) |
---|
502 | (let* ((fixadd (make-acode (%nx1-operator %i+) f1 f2)) |
---|
503 | (small-enough (target-word-size-case |
---|
504 | (32 '(signed-byte 28)) |
---|
505 | (64 '(signed-byte 59))))) |
---|
506 | (if (or (and (nx-acode-form-typep f1 small-enough env) |
---|
507 | (nx-acode-form-typep f2 small-enough env)) |
---|
508 | (nx-binary-fixnum-op-p num1 num2 env nil)) |
---|
509 | fixadd |
---|
510 | (make-acode (%nx1-operator typed-form) 'integer (make-acode (%nx1-operator fixnum-overflow) fixadd)))) |
---|
511 | (if (and (nx-form-typep num1 'double-float env) |
---|
512 | (nx-form-typep num2 'double-float env)) |
---|
513 | (nx1-form `(%double-float+-2 ,num1 ,num2)) |
---|
514 | (if (and (nx-form-typep num1 'short-float env) |
---|
515 | (nx-form-typep num2 'short-float env)) |
---|
516 | (nx1-form `(%short-float+-2 ,num1 ,num2)) |
---|
517 | (if (nx-binary-natural-op-p num1 num2 env nil) |
---|
518 | (make-acode (%nx1-operator typed-form) |
---|
519 | (target-word-size-case |
---|
520 | (32 '(unsigned-byte 32)) |
---|
521 | (64 '(unsigned-byte 64))) |
---|
522 | (make-acode (%nx1-operator %natural+) f1 f2)) |
---|
523 | (make-acode (%nx1-operator typed-form) 'number |
---|
524 | (make-acode (%nx1-operator add2) f1 f2)))))))) |
---|
525 | |
---|
526 | (defnx1 nx1-%double-float-x-2 ((%double-float+-2) (%double-float--2) (%double-float*-2) (%double-float/-2 )) |
---|
527 | (f0 f1) |
---|
528 | (make-acode (%nx1-operator typed-form) 'double-float |
---|
529 | (make-acode (%nx1-default-operator) (nx1-form f0) (nx1-form f1)))) |
---|
530 | |
---|
531 | |
---|
532 | (defnx1 nx1-%short-float-x-2 ((%short-float+-2) (%short-float--2) (%short-float*-2) (%short-float/-2 )) |
---|
533 | (f0 f1) |
---|
534 | (make-acode (%nx1-operator typed-form) 'short-float |
---|
535 | (make-acode (%nx1-default-operator) (nx1-form f0) (nx1-form f1)))) |
---|
536 | |
---|
537 | |
---|
538 | (defnx1 nx1-*-2 ((*-2)) (&whole whole &environment env num1 num2) |
---|
539 | (if (nx-binary-fixnum-op-p num1 num2 env) |
---|
540 | (make-acode (%nx1-operator %i*) (nx1-form num1 env) (nx1-form num2 env)) |
---|
541 | (if (and (nx-form-typep num1 'double-float env) |
---|
542 | (nx-form-typep num2 'double-float env)) |
---|
543 | (nx1-form `(%double-float*-2 ,num1 ,num2)) |
---|
544 | (if (and (nx-form-typep num1 'short-float env) |
---|
545 | (nx-form-typep num2 'short-float env)) |
---|
546 | (nx1-form `(%short-float*-2 ,num1 ,num2)) |
---|
547 | (make-acode (%nx1-operator mul2) (nx1-form num1 env) (nx1-form num2 env)))))) |
---|
548 | |
---|
549 | (defnx1 nx1-%negate ((%negate)) (&whole whole num &environment env) |
---|
550 | (if (nx-form-typep num 'fixnum env) |
---|
551 | (if (subtypep *nx-form-type* 'fixnum) |
---|
552 | (make-acode (%nx1-operator %%ineg)(nx1-form num)) |
---|
553 | (make-acode (%nx1-operator %ineg) (nx1-form num))) |
---|
554 | (make-acode (%nx1-operator minus1) (nx1-form num)))) |
---|
555 | |
---|
556 | |
---|
557 | (defnx1 nx1--2 ((--2)) (&whole whole &environment env num0 num1) |
---|
558 | (if (nx-binary-fixnum-op-p num0 num1 env t) |
---|
559 | (let* ((f0 (nx1-form num0)) |
---|
560 | (f1 (nx1-form num1)) |
---|
561 | (fixsub (make-acode (%nx1-operator %i-) f0 f1)) |
---|
562 | (small-enough (target-word-size-case |
---|
563 | (32 '(signed-byte 28)) |
---|
564 | (64 '(signed-byte 59))))) |
---|
565 | (if (or (and (nx-acode-form-typep f0 small-enough env) |
---|
566 | (nx-acode-form-typep f1 small-enough env)) |
---|
567 | (nx-binary-fixnum-op-p num0 num1 env nil)) |
---|
568 | fixsub |
---|
569 | (make-acode (%nx1-operator fixnum-overflow) fixsub))) |
---|
570 | (if (and (nx-form-typep num0 'double-float env) |
---|
571 | (nx-form-typep num1 'double-float env)) |
---|
572 | (nx1-form `(%double-float--2 ,num0 ,num1)) |
---|
573 | (if (and (nx-form-typep num0 'short-float env) |
---|
574 | (nx-form-typep num1 'short-float env)) |
---|
575 | (nx1-form `(%short-float--2 ,num0 ,num1)) |
---|
576 | (if (nx-binary-natural-op-p num0 num1 env nil) |
---|
577 | (make-acode (%nx1-operator %natural-) |
---|
578 | (nx1-form num0) |
---|
579 | (nx1-form num1)) |
---|
580 | (make-acode (%nx1-operator sub2) |
---|
581 | (nx1-form num0) |
---|
582 | (nx1-form num1))))))) |
---|
583 | |
---|
584 | (defnx1 nx1-/-2 ((/-2)) (num0 num1 &environment env) |
---|
585 | (if (and (nx-form-typep num0 'double-float env) |
---|
586 | (nx-form-typep num1 'double-float env)) |
---|
587 | (nx1-form `(%double-float/-2 ,num0 ,num1)) |
---|
588 | (if (and (nx-form-typep num0 'short-float env) |
---|
589 | (nx-form-typep num1 'short-float env)) |
---|
590 | (nx1-form `(%short-float/-2 ,num0 ,num1)) |
---|
591 | (make-acode (%nx1-operator div2) (nx1-form num0) (nx1-form num1))))) |
---|
592 | |
---|
593 | |
---|
594 | |
---|
595 | (defnx1 nx1-numcmp ((<-2) (>-2) (<=-2) (>=-2)) (&whole whole &environment env num1 num2) |
---|
596 | (let* ((op *nx-sfname*) |
---|
597 | (both-fixnums (nx-binary-fixnum-op-p num1 num2 env t)) |
---|
598 | (both-natural (nx-binary-natural-op-p num1 num2 env )) |
---|
599 | (both-double-floats |
---|
600 | (let* ((dfloat-1 (nx-form-typep num1 'double-float env)) |
---|
601 | (dfloat-2 (nx-form-typep num2 'double-float env))) |
---|
602 | (if dfloat-1 |
---|
603 | (or dfloat-2 (if (typep num2 'fixnum) (setq num2 (coerce num2 'double-float)))) |
---|
604 | (if dfloat-2 (if (typep num1 'fixnum) (setq num1 (coerce num1 'double-float))))))) |
---|
605 | (both-short-floats |
---|
606 | (let* ((sfloat-1 (nx-form-typep num1 'short-float env)) |
---|
607 | (sfloat-2 (nx-form-typep num2 'short-float env))) |
---|
608 | (if sfloat-1 |
---|
609 | (or sfloat-2 (if (typep num2 'fixnum) (setq num2 (coerce num2 'short-float)))) |
---|
610 | (if sfloat-2 (if (typep num1 'fixnum) (setq num1 (coerce num1 'short-float)))))))) |
---|
611 | |
---|
612 | (if (or both-fixnums both-double-floats both-short-floats both-natural) |
---|
613 | (make-acode |
---|
614 | (if both-fixnums |
---|
615 | (%nx1-operator %i<>) |
---|
616 | (if both-natural |
---|
617 | (%nx1-operator %natural<>) |
---|
618 | (if both-double-floats |
---|
619 | (%nx1-operator double-float-compare) |
---|
620 | (%nx1-operator short-float-compare)))) |
---|
621 | (make-acode |
---|
622 | (%nx1-operator immediate) |
---|
623 | (if (eq op '<-2) |
---|
624 | :LT |
---|
625 | (if (eq op '>=-2) |
---|
626 | :GE |
---|
627 | (if (eq op '<=-2) |
---|
628 | :LE |
---|
629 | :GT)))) |
---|
630 | (nx1-form num1) |
---|
631 | (nx1-form num2)) |
---|
632 | (make-acode (%nx1-operator numcmp) |
---|
633 | (make-acode |
---|
634 | (%nx1-operator immediate) |
---|
635 | (if (eq op '<-2) |
---|
636 | :LT |
---|
637 | (if (eq op '>=-2) |
---|
638 | :GE |
---|
639 | (if (eq op '<=-2) |
---|
640 | :LE |
---|
641 | :GT)))) |
---|
642 | (nx1-form num1) |
---|
643 | (nx1-form num2))))) |
---|
644 | |
---|
645 | (defnx1 nx1-num= ((=-2) (/=-2)) (&whole whole &environment env num1 num2 ) |
---|
646 | (let* ((op *nx-sfname*) |
---|
647 | (2-fixnums (nx-binary-fixnum-op-p num1 num2 env t)) |
---|
648 | (2-naturals (nx-binary-natural-op-p num1 num2 env)) |
---|
649 | (2-rats (and (nx-form-typep num1 'rational env) |
---|
650 | (nx-form-typep num2 'rational env))) |
---|
651 | (2-dfloats (let* ((dfloat-1 (nx-form-typep num1 'double-float env)) |
---|
652 | (dfloat-2 (nx-form-typep num2 'double-float env))) |
---|
653 | (if dfloat-1 |
---|
654 | (or dfloat-2 (if (typep num2 'fixnum) (setq num2 (coerce num2 'double-float)))) |
---|
655 | (if dfloat-2 (if (typep num1 'fixnum) (setq num1 (coerce num1 'double-float))))))) |
---|
656 | (2-sfloats (let* ((sfloat-1 (nx-form-typep num1 'short-float env)) |
---|
657 | (sfloat-2 (nx-form-typep num2 'short-float env))) |
---|
658 | (if sfloat-1 |
---|
659 | (or sfloat-2 (if (typep num2 'fixnum) (setq num2 (coerce num2 'short-float)))) |
---|
660 | (if sfloat-2 (if (typep num1 'fixnum) (setq num1 (coerce num1 'short-float))))))) |
---|
661 | ) |
---|
662 | (if (and 2-naturals (not 2-fixnums)) |
---|
663 | (make-acode |
---|
664 | (%nx1-operator %natural<>) |
---|
665 | (make-acode |
---|
666 | (%nx1-operator immediate) |
---|
667 | (if (eq op '=-2) |
---|
668 | :EQ |
---|
669 | :NE)) |
---|
670 | (nx1-form num1) |
---|
671 | (nx1-form num2)) |
---|
672 | (if 2-rats |
---|
673 | (let* ((form `(,(if 2-fixnums 'eq 'eql) ,num1 ,num2))) |
---|
674 | (nx1-form (if (eq op '=-2) form `(not ,form)))) |
---|
675 | (if (or 2-dfloats 2-sfloats) |
---|
676 | (make-acode |
---|
677 | (if 2-dfloats |
---|
678 | (%nx1-operator double-float-compare) |
---|
679 | (%nx1-operator short-float-compare)) |
---|
680 | (make-acode |
---|
681 | (%nx1-operator immediate) |
---|
682 | (if (eq op '=-2) |
---|
683 | :EQ |
---|
684 | :NE)) |
---|
685 | (nx1-form num1) |
---|
686 | (nx1-form num2)) |
---|
687 | (make-acode (%nx1-operator numcmp) |
---|
688 | (make-acode |
---|
689 | (%nx1-operator immediate) |
---|
690 | (if (eq op '=-2) |
---|
691 | :EQ |
---|
692 | :NE)) |
---|
693 | (nx1-form num1) |
---|
694 | (nx1-form num2))))))) |
---|
695 | |
---|
696 | |
---|
697 | (defnx1 nx1-uvset ((uvset) (%misc-set)) (vector index value &environment env) |
---|
698 | (make-acode (%nx1-operator uvset) |
---|
699 | (nx1-form vector) |
---|
700 | (nx1-form index) |
---|
701 | (nx1-form value))) |
---|
702 | |
---|
703 | (defnx1 nx1-set-schar ((set-schar)) (&whole w s i v &environment env) |
---|
704 | (make-acode (%nx1-operator %set-sbchar) (nx1-form s) (nx1-form i) (nx1-form v))) |
---|
705 | |
---|
706 | |
---|
707 | |
---|
708 | (defnx1 nx1-%set-schar ((%set-schar)) (arg idx char &environment env) |
---|
709 | (let* ((arg (nx-transform arg env)) |
---|
710 | (idx (nx-transform idx env)) |
---|
711 | (char (nx-transform char env)) |
---|
712 | (argvar (make-symbol "ARG")) |
---|
713 | (idxvar (make-symbol "IDX")) |
---|
714 | (charvar (make-symbol "CHAR"))) |
---|
715 | (nx1-form `(let* ((,argvar ,arg) |
---|
716 | (,idxvar ,idx) |
---|
717 | (,charvar ,char)) |
---|
718 | (declare (optimize (speed 3) (safety 0))) |
---|
719 | (declare (simple-base-string ,argvar)) |
---|
720 | (setf (schar ,argvar ,idxvar) ,charvar)) |
---|
721 | env))) |
---|
722 | |
---|
723 | (defnx1 nx1-%set-scharcode ((%set-scharcode)) (&whole w s i v) |
---|
724 | (make-acode (%nx1-operator %set-scharcode) |
---|
725 | (nx1-form s) |
---|
726 | (nx1-form i) |
---|
727 | (nx1-form v))) |
---|
728 | |
---|
729 | |
---|
730 | (defnx1 nx1-list-vector-values ((list) (vector) (values) (%temp-list)) (&rest args) |
---|
731 | (make-acode (%nx1-default-operator) (nx1-formlist args))) |
---|
732 | |
---|
733 | |
---|
734 | |
---|
735 | (defnx1 nx1-%gvector ( (%gvector)) (&rest args) |
---|
736 | (make-acode (%nx1-operator %gvector) (nx1-arglist args))) |
---|
737 | |
---|
738 | (defnx1 nx1-quote quote (form) |
---|
739 | (nx1-immediate form)) |
---|
740 | |
---|
741 | (defnx1 nx1-list* ((list*)) (first &rest rest) |
---|
742 | (make-acode (%nx1-operator list*) (nx1-arglist (cons first rest) 1))) |
---|
743 | |
---|
744 | |
---|
745 | #| |
---|
746 | (defnx1 nx1-append ((append)) (&rest args) |
---|
747 | (make-acode (%nx1-operator append) (nx1-arglist args 2))) |
---|
748 | |
---|
749 | |
---|
750 | |# |
---|
751 | |
---|
752 | (defnx1 nx1-or or (&whole whole &optional (firstform nil firstform-p) &rest moreforms) |
---|
753 | (if (not firstform-p) |
---|
754 | (nx1-form nil) |
---|
755 | (if (null moreforms) |
---|
756 | (nx1-form firstform) |
---|
757 | (progn |
---|
758 | (make-acode (%nx1-operator or) (nx1-formlist (%cdr whole))))))) |
---|
759 | |
---|
760 | (defun nx1-1d-vref (env arr dim0 &optional uvref-p) |
---|
761 | (let* ((simple-vector-p (nx-form-typep arr 'simple-vector env)) |
---|
762 | (string-p (unless simple-vector-p |
---|
763 | (if (nx-form-typep arr 'string env) |
---|
764 | (or (nx-form-typep arr 'simple-string env) |
---|
765 | (return-from nx1-1d-vref (nx1-form `(char ,arr ,dim0))))))) |
---|
766 | (simple-1d-array-p (unless (or simple-vector-p string-p) |
---|
767 | (nx-form-typep arr '(simple-array * (*)) env))) |
---|
768 | |
---|
769 | (array-type (specifier-type (nx-form-type arr env))) |
---|
770 | (type-keyword (funcall |
---|
771 | (arch::target-array-type-name-from-ctype-function |
---|
772 | (backend-target-arch *target-backend*)) |
---|
773 | array-type))) |
---|
774 | (if (and simple-1d-array-p type-keyword) |
---|
775 | (make-acode (%nx1-operator %typed-uvref) |
---|
776 | (nx1-immediate type-keyword) |
---|
777 | (nx1-form arr) |
---|
778 | (nx1-form dim0)) |
---|
779 | (let* ((op (cond (simple-1d-array-p (%nx1-operator uvref)) |
---|
780 | (string-p (%nx1-operator %sbchar)) |
---|
781 | (simple-vector-p |
---|
782 | (if (nx-inhibit-safety-checking env) (%nx1-operator %svref) (%nx1-operator svref))) |
---|
783 | (uvref-p (%nx1-operator uvref)) |
---|
784 | (t (%nx1-operator %aref1))))) |
---|
785 | (make-acode op (nx1-form arr) (nx1-form dim0)))))) |
---|
786 | |
---|
787 | (defnx1 nx1-aref ((aref)) (&whole whole &environment env arr &optional (dim0 nil dim0-p) |
---|
788 | &rest other-dims) |
---|
789 | (if (and dim0-p (null other-dims)) |
---|
790 | (nx1-1d-vref env arr dim0) |
---|
791 | (nx1-treat-as-call whole))) |
---|
792 | |
---|
793 | (defnx1 nx1-uvref ((uvref)) (&environment env arr dim0) |
---|
794 | (nx1-1d-vref env arr dim0 t)) |
---|
795 | |
---|
796 | (defnx1 nx1-%aref2 ((%aref2)) (&whole whole &environment env arr i j) |
---|
797 | (let* ((arch (backend-target-arch *target-backend*)) |
---|
798 | (ctype (specifier-type (nx-form-type arr env))) |
---|
799 | (atype (if (csubtypep ctype (specifier-type '(array * (* *)))) ctype)) |
---|
800 | (simple-atype (if (and atype |
---|
801 | (csubtypep atype (specifier-type '(simple-array * (* *))))) |
---|
802 | atype)) |
---|
803 | (type-keyword (if atype |
---|
804 | (funcall |
---|
805 | (arch::target-array-type-name-from-ctype-function arch) |
---|
806 | atype)))) |
---|
807 | (if (and type-keyword simple-atype) |
---|
808 | (let* ((dims (array-ctype-dimensions atype)) |
---|
809 | (dim0 (car dims)) |
---|
810 | (dim1 (cadr dims))) |
---|
811 | (make-acode (%nx1-operator simple-typed-aref2) |
---|
812 | (nx1-form type-keyword) |
---|
813 | (nx1-form arr) |
---|
814 | (nx1-form i) |
---|
815 | (nx1-form j) |
---|
816 | (nx1-form (if (typep dim0 'fixnum) dim0)) |
---|
817 | (nx1-form (if (typep dim1 'fixnum) dim1)))) |
---|
818 | (make-acode (%nx1-operator general-aref2) |
---|
819 | (nx1-form arr) |
---|
820 | (nx1-form i) |
---|
821 | (nx1-form j))))) |
---|
822 | |
---|
823 | (defnx1 nx1-%aref3 ((%aref3)) (&whole whole &environment env arr i j k) |
---|
824 | (let* ((arch (backend-target-arch *target-backend*)) |
---|
825 | (ctype (specifier-type (nx-form-type arr env))) |
---|
826 | (atype (if (csubtypep ctype (specifier-type '(array * (* * *)))) ctype)) |
---|
827 | (simple-atype (if (and atype |
---|
828 | (csubtypep atype (specifier-type '(simple-array * (* * *))))) |
---|
829 | atype)) |
---|
830 | (type-keyword (if atype |
---|
831 | (funcall |
---|
832 | (arch::target-array-type-name-from-ctype-function arch) |
---|
833 | atype)))) |
---|
834 | (if (and type-keyword simple-atype) |
---|
835 | (let* ((dims (array-ctype-dimensions atype)) |
---|
836 | (dim0 (car dims)) |
---|
837 | (dim1 (cadr dims)) |
---|
838 | (dim2 (caddr dims))) |
---|
839 | (make-acode (%nx1-operator simple-typed-aref3) |
---|
840 | (nx1-form type-keyword) |
---|
841 | (nx1-form arr) |
---|
842 | (nx1-form i) |
---|
843 | (nx1-form j) |
---|
844 | (nx1-form k) |
---|
845 | (nx1-form (if (typep dim0 'fixnum) dim0)) |
---|
846 | (nx1-form (if (typep dim1 'fixnum) dim1)) |
---|
847 | (nx1-form (if (typep dim2 'fixnum) dim2)))) |
---|
848 | (make-acode (%nx1-operator general-aref3) |
---|
849 | (nx1-form arr) |
---|
850 | (nx1-form i) |
---|
851 | (nx1-form j) |
---|
852 | (nx1-form k))))) |
---|
853 | |
---|
854 | (defun nx1-1d-vset (arr newval dim0 env) |
---|
855 | (let* ((simple-vector-p (nx-form-typep arr 'simple-vector env)) |
---|
856 | (string-p (unless simple-vector-p |
---|
857 | (if (nx-form-typep arr 'string env) |
---|
858 | (or (nx-form-typep arr 'simple-string env) |
---|
859 | (return-from nx1-1d-vset (nx1-form `(set-char ,arr ,newval ,dim0))))))) |
---|
860 | (simple-1d-array-p (unless (or simple-vector-p string-p) |
---|
861 | (nx-form-typep arr '(simple-array * (*)) env))) |
---|
862 | (array-type (specifier-type (nx-form-type arr env))) |
---|
863 | (type-keyword (funcall |
---|
864 | (arch::target-array-type-name-from-ctype-function |
---|
865 | (backend-target-arch *target-backend*)) |
---|
866 | array-type))) |
---|
867 | (if (and type-keyword simple-1d-array-p) |
---|
868 | (make-acode (%nx1-operator %typed-uvset) |
---|
869 | (nx1-immediate type-keyword) |
---|
870 | (nx1-form arr) |
---|
871 | (nx1-form newval) |
---|
872 | (nx1-form dim0)) |
---|
873 | (let* ((op (cond (simple-1d-array-p (%nx1-operator uvset)) |
---|
874 | (string-p (%nx1-operator %set-sbchar)) |
---|
875 | (simple-vector-p (if (nx-inhibit-safety-checking env) (%nx1-operator %svset) (%nx1-operator svset))) |
---|
876 | (t (%nx1-operator aset1))))) |
---|
877 | (if op |
---|
878 | (make-acode |
---|
879 | op |
---|
880 | (nx1-form arr) |
---|
881 | (nx1-form newval) |
---|
882 | (nx1-form dim0)) |
---|
883 | (nx1-form `(,(if string-p 'set-schar '%aset1) ,arr ,newval ,dim0))))))) |
---|
884 | |
---|
885 | (defnx1 nx1-aset ((aset)) (&whole whole |
---|
886 | arr newval |
---|
887 | &optional (dim0 nil dim0-p) |
---|
888 | &environment env |
---|
889 | &rest other-dims) |
---|
890 | (if (and dim0-p (null other-dims)) |
---|
891 | (nx1-1d-vset arr newval dim0 env) |
---|
892 | (nx1-treat-as-call whole))) |
---|
893 | |
---|
894 | (defnx1 nx1-%aset2 ((%aset2)) (&whole whole &environment env arr i j new) |
---|
895 | (let* ((arch (backend-target-arch *target-backend*)) |
---|
896 | (ctype (specifier-type (nx-form-type arr env))) |
---|
897 | (atype (if (csubtypep ctype (specifier-type '(array * (* *)))) ctype)) |
---|
898 | (simple-atype (if (and atype |
---|
899 | (csubtypep atype (specifier-type '(simple-array * (* *))))) |
---|
900 | atype)) |
---|
901 | (type-keyword (if atype |
---|
902 | (funcall |
---|
903 | (arch::target-array-type-name-from-ctype-function arch) |
---|
904 | atype)))) |
---|
905 | |
---|
906 | (if (and type-keyword simple-atype) |
---|
907 | (let* ((dims (array-ctype-dimensions atype)) |
---|
908 | (dim0 (car dims)) |
---|
909 | (dim1 (cadr dims))) |
---|
910 | (make-acode (%nx1-operator simple-typed-aset2) |
---|
911 | (nx1-form type-keyword) |
---|
912 | (nx1-form arr) |
---|
913 | (nx1-form i) |
---|
914 | (nx1-form j) |
---|
915 | (nx1-form new) |
---|
916 | (nx1-form (if (typep dim0 'fixnum) dim0)) |
---|
917 | (nx1-form (if (typep dim1 'fixnum) dim1)))) |
---|
918 | (make-acode (%nx1-operator general-aset2) |
---|
919 | (nx1-form arr) |
---|
920 | (nx1-form i) |
---|
921 | (nx1-form j) |
---|
922 | (nx1-form new))))) |
---|
923 | |
---|
924 | (defnx1 nx1-%aset3 ((%aset3)) (&whole whole &environment env arr i j k new) |
---|
925 | (let* ((arch (backend-target-arch *target-backend*)) |
---|
926 | (ctype (specifier-type (nx-form-type arr env))) |
---|
927 | (atype (if (csubtypep ctype (specifier-type '(array * (* * *)))) ctype)) |
---|
928 | (simple-atype (if (and atype |
---|
929 | (csubtypep atype (specifier-type '(simple-array * (* * *))))) |
---|
930 | atype)) |
---|
931 | (type-keyword (if atype |
---|
932 | (funcall |
---|
933 | (arch::target-array-type-name-from-ctype-function arch) |
---|
934 | atype)))) |
---|
935 | |
---|
936 | (if (and type-keyword simple-atype) |
---|
937 | (let* ((dims (array-ctype-dimensions atype)) |
---|
938 | (dim0 (car dims)) |
---|
939 | (dim1 (cadr dims)) |
---|
940 | (dim2 (caddr dims))) |
---|
941 | (make-acode (%nx1-operator simple-typed-aset3) |
---|
942 | (nx1-form type-keyword) |
---|
943 | (nx1-form arr) |
---|
944 | (nx1-form i) |
---|
945 | (nx1-form j) |
---|
946 | (nx1-form k) |
---|
947 | (nx1-form new) |
---|
948 | (nx1-form (if (typep dim0 'fixnum) dim0)) |
---|
949 | (nx1-form (if (typep dim1 'fixnum) dim1)) |
---|
950 | (nx1-form (if (typep dim2 'fixnum) dim2)))) |
---|
951 | (make-acode (%nx1-operator general-aset3) |
---|
952 | (nx1-form arr) |
---|
953 | (nx1-form i) |
---|
954 | (nx1-form j) |
---|
955 | (nx1-form k) |
---|
956 | (nx1-form new))))) |
---|
957 | |
---|
958 | (defnx1 nx1-prog1 (prog1 multiple-value-prog1) (save &body args |
---|
959 | &aux (l (list (nx1-form save)))) |
---|
960 | (make-acode |
---|
961 | (%nx1-default-operator) |
---|
962 | (dolist (arg args (nreverse l)) |
---|
963 | (push (nx1-form arg) l)))) |
---|
964 | |
---|
965 | (defnx1 nx1-if if (test true &optional false) |
---|
966 | (if (null true) |
---|
967 | (if (null false) |
---|
968 | (return-from nx1-if (nx1-form `(progn ,test nil))) |
---|
969 | (psetq test `(not ,test) true false false true))) |
---|
970 | (make-acode (%nx1-operator if) (nx1-form test) (nx1-form true) (nx1-form false))) |
---|
971 | |
---|
972 | (defnx1 nx1-%debug-trap dbg (&optional arg) |
---|
973 | (make-acode (%nx1-operator %debug-trap) (nx1-form arg))) |
---|
974 | |
---|
975 | (defnx1 nx1-setq setq (&whole whole &rest args &environment env &aux res) |
---|
976 | (when (%ilogbitp 0 (length args)) |
---|
977 | (nx-error "Odd number of forms in ~s ." whole)) |
---|
978 | (while args |
---|
979 | (let ((sym (nx-need-var (%car args) nil)) |
---|
980 | (val (%cadr args))) |
---|
981 | (multiple-value-bind (expansion win) (macroexpand-1 sym env) |
---|
982 | (if win |
---|
983 | (push (nx1-form `(setf ,expansion ,val)) res) |
---|
984 | (multiple-value-bind (info inherited catchp) |
---|
985 | (nx-lex-info sym) |
---|
986 | (push |
---|
987 | (if (eq info :symbol-macro) |
---|
988 | (progn |
---|
989 | (nx-set-var-bits catchp |
---|
990 | (%ilogior |
---|
991 | (%ilsl $vbitsetq 1) |
---|
992 | (%ilsl $vbitreffed 1) |
---|
993 | (nx-var-bits catchp))) |
---|
994 | (nx1-form `(setf ,inherited ,val))) |
---|
995 | (let* ((valtype (nx-form-type val env)) |
---|
996 | (declared-type (nx-declared-type sym))) |
---|
997 | (let ((*nx-form-type* declared-type)) |
---|
998 | (setq val (nx1-typed-form val env))) |
---|
999 | (if (and info (neq info :special)) |
---|
1000 | (progn |
---|
1001 | (nx1-check-assignment sym env) |
---|
1002 | (let ((inittype (var-inittype info))) |
---|
1003 | (if (and inittype (not (subtypep valtype inittype))) |
---|
1004 | (setf (var-inittype info) nil))) |
---|
1005 | (if inherited |
---|
1006 | (nx-set-var-bits info (%ilogior (%ilsl $vbitsetq 1) |
---|
1007 | (%ilsl $vbitnoreg 1) ; I know, I know ... Someday ... |
---|
1008 | (nx-var-bits info))) |
---|
1009 | (nx-set-var-bits info (%ilogior2 (%ilsl $vbitsetq 1) (nx-var-bits info)))) |
---|
1010 | (nx-adjust-setq-count info 1 catchp) ; In the hope that that day will come ... |
---|
1011 | (make-acode (%nx1-operator setq-lexical) info val)) |
---|
1012 | (make-acode |
---|
1013 | (if (nx1-check-special-ref sym info) |
---|
1014 | (progn |
---|
1015 | (nx-record-xref-info :references sym) |
---|
1016 | (nx-record-xref-info :sets sym) |
---|
1017 | (if (nx-global-p sym env) |
---|
1018 | (%nx1-operator global-setq) |
---|
1019 | (%nx1-operator setq-special))) |
---|
1020 | (%nx1-operator setq-free)) ; Screw: no object lisp. Still need setq-free ? For constants ? |
---|
1021 | (nx1-note-vcell-ref sym) |
---|
1022 | val)))) |
---|
1023 | res))) |
---|
1024 | (setq args (%cddr args))))) |
---|
1025 | (make-acode (%nx1-operator progn) (nreverse res))) |
---|
1026 | |
---|
1027 | ;;; See if we're trying to setq something that's currently declared "UNSETTABLE"; whine if so. |
---|
1028 | ;;; If we find a contour in which a "SETTABLE NIL" vdecl for the variable exists, whine. |
---|
1029 | ;;; If we find a contour in which a "SETTABLE T" vdecl for the variable exists. or |
---|
1030 | ;;; the contour in which the variable's bound, return nil. |
---|
1031 | ;;; Should find something ... |
---|
1032 | (defun nx1-check-assignment (sym env) |
---|
1033 | (loop |
---|
1034 | (unless (and env (istruct-typep env 'lexical-environment)) |
---|
1035 | (return)) |
---|
1036 | (dolist (decl (lexenv.vdecls env)) |
---|
1037 | (when (and (eq (car decl) sym) |
---|
1038 | (eq (cadr decl) 'settable)) |
---|
1039 | (unless (cddr decl) |
---|
1040 | (nx1-whine :unsettable sym)) |
---|
1041 | (return-from nx1-check-assignment nil))) |
---|
1042 | (let ((vars (lexenv.variables env))) |
---|
1043 | (unless (atom vars) |
---|
1044 | (dolist (var vars) |
---|
1045 | (when (eq (var-name var) sym) (return-from nx1-check-assignment nil))))) |
---|
1046 | (setq env (lexenv.parent-env env)))) |
---|
1047 | |
---|
1048 | ;;; The cleanup issue is a little vague (ok, it's a -lot- vague) about the environment in |
---|
1049 | ;;; which the load-time form is defined, although it apparently gets "executed in a null |
---|
1050 | ;;; lexical environment". Ignoring the fact that it's meaningless to talk of executing |
---|
1051 | ;;; something in a lexical environment, we can sort of infer that it must also be defined |
---|
1052 | ;;; in a null lexical environment. |
---|
1053 | |
---|
1054 | (defnx1 nx1-load-time-value (load-time-value) (&environment env form &optional read-only-p) |
---|
1055 | ; Validate the "read-only-p" argument |
---|
1056 | (if (and read-only-p (neq read-only-p t)) (require-type read-only-p '(member t nil))) |
---|
1057 | ; Then ignore it. |
---|
1058 | (if *nx-load-time-eval-token* |
---|
1059 | (multiple-value-bind (function warnings) |
---|
1060 | (compile-named-function |
---|
1061 | `(lambda () ,form) nil nil nil nil nil *nx-load-time-eval-token* (backend-name *target-backend*)) |
---|
1062 | (setq *nx-warnings* (append *nx-warnings* warnings)) |
---|
1063 | (nx1-immediate (list *nx-load-time-eval-token* `(funcall ,function)))) |
---|
1064 | (nx1-immediate (eval form)))) |
---|
1065 | |
---|
1066 | (defnx1 nx1-catch (catch) (operation &body body) |
---|
1067 | (make-acode (%nx1-operator catch) (nx1-form operation) (nx1-catch-body body))) |
---|
1068 | |
---|
1069 | (defnx1 nx1-%badarg ((%badarg)) (badthing right-type) |
---|
1070 | (make-acode (%nx1-operator %badarg2) |
---|
1071 | (nx1-form badthing) |
---|
1072 | (nx1-form (or (if (quoted-form-p right-type) (%typespec-id (cadr right-type))) right-type)))) |
---|
1073 | |
---|
1074 | (defnx1 nx1-unwind-protect (unwind-protect) (protected-form &body cleanup-form) |
---|
1075 | (if cleanup-form |
---|
1076 | (make-acode (%nx1-operator unwind-protect) |
---|
1077 | (nx1-catch-body (list protected-form)) |
---|
1078 | (nx1-progn-body cleanup-form)) |
---|
1079 | (nx1-form protected-form))) |
---|
1080 | |
---|
1081 | (defnx1 nx1-progv progv (symbols values &body body) |
---|
1082 | (make-acode (%nx1-operator progv) |
---|
1083 | (nx1-form `(check-symbol-list ,symbols)) |
---|
1084 | (nx1-form values) |
---|
1085 | (nx1-catch-body body))) |
---|
1086 | |
---|
1087 | (defun nx1-catch-body (body) |
---|
1088 | (let* ((temp (new-lexical-environment *nx-lexical-environment*))) |
---|
1089 | (setf (lexenv.variables temp) 'catch) |
---|
1090 | (let* ((*nx-lexical-environment* (new-lexical-environment temp))) |
---|
1091 | (nx1-progn-body body)))) |
---|
1092 | |
---|
1093 | |
---|
1094 | |
---|
1095 | |
---|
1096 | |
---|
1097 | |
---|
1098 | (defnx1 nx1-apply ((apply)) (&whole call fn arg &rest args &aux (orig args) (spread-p t)) |
---|
1099 | (if (null (%car (last (push arg args)))) |
---|
1100 | (setq spread-p nil args (butlast args))) |
---|
1101 | (let ((name (nx1-func-name fn)) |
---|
1102 | (global nil)) |
---|
1103 | (if name |
---|
1104 | (if (eq (%car fn) 'quote) |
---|
1105 | (setq global t name (nx1-form fn)) |
---|
1106 | (let* ((afunc (nth-value 1 (nx-lexical-finfo name)))) |
---|
1107 | (when (and afunc (eq afunc *nx-call-next-method-function*)) |
---|
1108 | (setq name (if (or arg orig) |
---|
1109 | '%call-next-method-with-args |
---|
1110 | '%call-next-method) |
---|
1111 | global t |
---|
1112 | args (cons (var-name *nx-next-method-var*) args))))) |
---|
1113 | (setq name (nx1-form fn))) |
---|
1114 | (nx1-call name args spread-p global))) |
---|
1115 | |
---|
1116 | (defnx1 nx1-%apply-lexpr ((%apply-lexpr)) (&whole call fn arg &rest args &aux (orig args)) |
---|
1117 | (push arg args) |
---|
1118 | (let ((name (nx1-func-name fn)) |
---|
1119 | (global nil)) |
---|
1120 | (if name |
---|
1121 | (if (eq (%car fn) 'quote) |
---|
1122 | (setq global t name (nx1-form fn)) |
---|
1123 | (let* ((afunc (nth-value 1 (nx-lexical-finfo name)))) |
---|
1124 | (when (and afunc (eq afunc *nx-call-next-method-function*)) |
---|
1125 | (setq name (if (or arg orig) |
---|
1126 | '%call-next-method-with-args |
---|
1127 | '%call-next-method) |
---|
1128 | global t |
---|
1129 | args (cons (var-name *nx-next-method-var*) args))))) |
---|
1130 | (setq name (nx1-form fn))) |
---|
1131 | (nx1-call name args 0 global))) |
---|
1132 | |
---|
1133 | |
---|
1134 | |
---|
1135 | (defnx1 nx1-%defun %defun (&whole w def &optional (doc nil doc-p) &environment env) |
---|
1136 | (declare (ignorable doc doc-p)) |
---|
1137 | ; Pretty bogus. |
---|
1138 | (if (and (consp def) |
---|
1139 | (eq (%car def) 'nfunction) |
---|
1140 | (consp (%cdr def)) |
---|
1141 | (symbolp (%cadr def))) |
---|
1142 | (note-function-info (%cadr def) nil env)) |
---|
1143 | (nx1-treat-as-call w)) |
---|
1144 | |
---|
1145 | |
---|
1146 | (defnx1 nx1-function function (arg &aux fn afunc) |
---|
1147 | (if (symbolp arg) |
---|
1148 | (progn |
---|
1149 | (when (macro-function arg *nx-lexical-environment*) |
---|
1150 | (nx-error |
---|
1151 | "~S can't be used to reference lexically visible macro ~S." |
---|
1152 | 'function arg)) |
---|
1153 | (if (multiple-value-setq (fn afunc) (nx-lexical-finfo arg)) |
---|
1154 | (progn |
---|
1155 | (when afunc |
---|
1156 | (incf (afunc-fn-refcount afunc)) |
---|
1157 | (when (%ilogbitp $fbitbounddownward (afunc-bits afunc)) |
---|
1158 | (incf (afunc-fn-downward-refcount afunc)))) |
---|
1159 | (nx1-symbol (%cddr fn))) |
---|
1160 | (progn |
---|
1161 | (while (setq fn (assq arg *nx-synonyms*)) |
---|
1162 | (setq arg (%cdr fn))) |
---|
1163 | (nx1-form `(%function ',arg))))) |
---|
1164 | (if (and (consp arg) (eq (%car arg) 'setf)) |
---|
1165 | (nx1-form `(function ,(nx-need-function-name arg))) |
---|
1166 | (nx1-ref-inner-function nil arg)))) |
---|
1167 | |
---|
1168 | (defnx1 nx1-nfunction nfunction (name def) |
---|
1169 | (nx1-ref-inner-function name def)) |
---|
1170 | |
---|
1171 | (defun nx1-ref-inner-function (name def &optional afunc) |
---|
1172 | (setq afunc (nx1-compile-inner-function name def afunc)) |
---|
1173 | (setf (afunc-fn-refcount afunc) 1) |
---|
1174 | (nx1-afunc-ref afunc)) |
---|
1175 | |
---|
1176 | (defun nx1-compile-inner-function (name def |
---|
1177 | &optional p (env *nx-lexical-environment*) |
---|
1178 | &aux (q *nx-current-function*)) |
---|
1179 | (unless p (setq p (make-afunc))) |
---|
1180 | (setf (afunc-parent p) q) |
---|
1181 | (setf (afunc-parent q) *nx-parent-function*) |
---|
1182 | (setf (afunc-tags q) *nx-tags*) |
---|
1183 | (setf (afunc-blocks q) *nx-blocks*) |
---|
1184 | (setf (afunc-inner-functions q) (push p *nx-inner-functions*)) |
---|
1185 | (setf (lexenv.lambda env) q) |
---|
1186 | (nx1-compile-lambda name def p q env *nx-current-compiler-policy* *nx-load-time-eval-token*)) ;returns p. |
---|
1187 | |
---|
1188 | (defun nx1-afunc-ref (afunc) |
---|
1189 | (let ((op (if (afunc-inherited-vars afunc) |
---|
1190 | (%nx1-operator closed-function) |
---|
1191 | (%nx1-operator simple-function))) |
---|
1192 | (ref (afunc-ref-form afunc))) |
---|
1193 | (if ref |
---|
1194 | (%rplaca ref op) ; returns ref |
---|
1195 | (setf (afunc-ref-form afunc) |
---|
1196 | (make-acode |
---|
1197 | op |
---|
1198 | afunc))))) |
---|
1199 | |
---|
1200 | (defnx1 nx1-%function %function (form &aux symbol) |
---|
1201 | (let ((sym (nx1-form form))) |
---|
1202 | (if (and (eq (car sym) (%nx1-operator immediate)) |
---|
1203 | (setq symbol (cadr sym)) |
---|
1204 | (symbolp symbol)) |
---|
1205 | (progn |
---|
1206 | (nx1-call-result-type symbol) ; misnamed. Checks for (un-)definedness. |
---|
1207 | (make-acode (%nx1-default-operator) symbol)) |
---|
1208 | (make-acode (%nx1-operator call) (nx1-immediate '%function) (list nil (list sym)))))) |
---|
1209 | |
---|
1210 | (defnx1 nx1-tagbody tagbody (&rest args) |
---|
1211 | (let* ((newtags nil) |
---|
1212 | (*nx-lexical-environment* (new-lexical-environment *nx-lexical-environment*)) |
---|
1213 | (pending (make-pending-declarations)) |
---|
1214 | (*nx-bound-vars* *nx-bound-vars*) |
---|
1215 | (catchvar (nx-new-temp-var pending "tagbody-catch-tag")) |
---|
1216 | (indexvar (nx-new-temp-var pending "tagbody-tag-index")) |
---|
1217 | (counter (list 0)) |
---|
1218 | (looplabel (cons nil nil)) |
---|
1219 | (*nx-tags* *nx-tags*)) |
---|
1220 | (dolist (form args) |
---|
1221 | (when (atom form) |
---|
1222 | (if (or (symbolp form) (integerp form)) |
---|
1223 | (if (assoc form newtags) |
---|
1224 | (nx-error "Duplicate tag in TAGBODY: ~S." form) |
---|
1225 | (push (list form nil counter catchvar nil nil) newtags)) |
---|
1226 | (nx-error "Illegal form in TAGBODY: ~S." form)))) |
---|
1227 | (dolist (tag (setq newtags (nreverse newtags))) |
---|
1228 | (push tag *nx-tags*)) |
---|
1229 | (let* ((body nil) |
---|
1230 | (*nx-loop-nesting-level* (1+ *nx-loop-nesting-level*))) |
---|
1231 | (dolist (form args (setq body (nreverse body))) |
---|
1232 | (push |
---|
1233 | (if (atom form) |
---|
1234 | (let ((info (nx-tag-info form))) |
---|
1235 | (%rplaca (%cdr (%cdr (%cdr (%cdr info)))) t) |
---|
1236 | (cons (%nx1-operator tag-label) info)) |
---|
1237 | (nx1-form form)) |
---|
1238 | body)) |
---|
1239 | (if (eq 0 (%car counter)) |
---|
1240 | (make-acode (%nx1-operator local-tagbody) newtags body) |
---|
1241 | (progn |
---|
1242 | (nx-set-var-bits catchvar (logior (nx-var-bits catchvar) |
---|
1243 | (%ilsl $vbitdynamicextent 1))) |
---|
1244 | (nx-inhibit-register-allocation) ; There are alternatives ... |
---|
1245 | (dolist (tag (reverse newtags)) |
---|
1246 | (when (%cadr tag) |
---|
1247 | (push |
---|
1248 | (nx1-form `(if (eql ,(var-name indexvar) ,(%cadr tag)) (go ,(%car tag)))) |
---|
1249 | body))) |
---|
1250 | (make-acode |
---|
1251 | (%nx1-operator let*) |
---|
1252 | (list catchvar indexvar) |
---|
1253 | (list (make-acode (%nx1-operator cons) *nx-nil* *nx-nil*) *nx-nil*) |
---|
1254 | (make-acode |
---|
1255 | (%nx1-operator local-tagbody) |
---|
1256 | (list looplabel) |
---|
1257 | (list |
---|
1258 | (cons (%nx1-operator tag-label) looplabel) |
---|
1259 | (make-acode |
---|
1260 | (%nx1-operator if) |
---|
1261 | (make-acode |
---|
1262 | (%nx1-operator setq-lexical) |
---|
1263 | indexvar |
---|
1264 | (make-acode |
---|
1265 | (%nx1-operator catch) |
---|
1266 | (nx1-form (var-name catchvar)) |
---|
1267 | (make-acode |
---|
1268 | (%nx1-operator local-tagbody) |
---|
1269 | newtags |
---|
1270 | body))) |
---|
1271 | (make-acode (%nx1-operator local-go) looplabel) |
---|
1272 | *nx-nil*))) |
---|
1273 | 0)))))) |
---|
1274 | |
---|
1275 | |
---|
1276 | |
---|
1277 | (defnx1 nx1-go go (tag) |
---|
1278 | (multiple-value-bind (info closed) |
---|
1279 | (nx-tag-info tag) |
---|
1280 | (unless info (nx-error "Can't GO to tag ~S." tag)) |
---|
1281 | (if (not closed) |
---|
1282 | (let ((defnbackref (cdr (cdr (cdr (cdr info)))))) |
---|
1283 | (if (car defnbackref) |
---|
1284 | (rplaca (cdr defnbackref) t)) |
---|
1285 | (make-acode (%nx1-operator local-go) info)) |
---|
1286 | (progn |
---|
1287 | |
---|
1288 | (make-acode |
---|
1289 | (%nx1-operator throw) (nx1-symbol (var-name (cadddr info))) (nx1-form closed)))))) |
---|
1290 | |
---|
1291 | |
---|
1292 | |
---|
1293 | |
---|
1294 | ;;; address-expression should return a fixnum; that's our little |
---|
1295 | ;;; secret. result spec can be NIL, :void, or anything that an |
---|
1296 | ;;; arg-spec can be. arg-spec can be :double, :single, :address, |
---|
1297 | ;;; :signed-doubleword, :unsigned-doubleword, :signed-fullword, |
---|
1298 | ;;; :unsigned-fullword, :signed-halfword, :unsigned-halfword, |
---|
1299 | ;;; :signed-byte, or :unsigned-byte |
---|
1300 | ;;; On ppc64, :hybrid-int-float, :hybrid-float-float, and :hybrid-float-int |
---|
1301 | ;;; can also be used to express some struct-by-value cases. |
---|
1302 | |
---|
1303 | (defparameter *arg-spec-keywords* |
---|
1304 | '(:double-float :single-float :address :signed-doubleword |
---|
1305 | :unsigned-doubleword :signed-fullword :unsigned-fullword |
---|
1306 | :signed-halfword :unsigned-halfword :signed-byte :unsigned-byte |
---|
1307 | :hybrid-int-float :hybrid-float-int :hybrid-float-float)) |
---|
1308 | |
---|
1309 | |
---|
1310 | (defnx1 nx1-ff-call ((%ff-call)) (address-expression &rest arg-specs-and-result-spec) |
---|
1311 | (nx1-ff-call-internal |
---|
1312 | address-expression arg-specs-and-result-spec |
---|
1313 | (ecase (backend-name *target-backend*) |
---|
1314 | (:linuxppc32 (%nx1-operator eabi-ff-call)) |
---|
1315 | ((:darwinppc32 :linuxppc64 :darwinppc64) (%nx1-operator poweropen-ff-call)) |
---|
1316 | ((:linuxx8664 :freebsdx8664 :darwinx8664) (%nx1-operator ff-call))))) |
---|
1317 | |
---|
1318 | (defnx1 nx1-syscall ((%syscall)) (idx &rest arg-specs-and-result-spec) |
---|
1319 | (flet ((map-to-representation-types (list) |
---|
1320 | (collect ((out)) |
---|
1321 | (do* ((l list (cddr l))) |
---|
1322 | ((null (cdr l)) |
---|
1323 | (if l |
---|
1324 | (progn |
---|
1325 | (out (foreign-type-to-representation-type (car l))) |
---|
1326 | (out)) |
---|
1327 | (error "Missing result type in ~s" list))) |
---|
1328 | (out (foreign-type-to-representation-type (car l))) |
---|
1329 | (out (cadr l)))))) |
---|
1330 | (nx1-ff-call-internal |
---|
1331 | idx (map-to-representation-types arg-specs-and-result-spec) |
---|
1332 | (ecase (backend-name *target-backend*) |
---|
1333 | (:linuxppc32 (%nx1-operator eabi-syscall)) |
---|
1334 | ((:darwinppc32 :darwinppc64 :linuxppc64) |
---|
1335 | (%nx1-operator poweropen-syscall)) |
---|
1336 | ((:linuxx8664 :freebsdx8664 :darwinx8664) (%nx1-operator syscall)))))) |
---|
1337 | |
---|
1338 | (defun nx1-ff-call-internal (address-expression arg-specs-and-result-spec operator ) |
---|
1339 | (let* ((specs ()) |
---|
1340 | (vals ()) |
---|
1341 | (register-spec-seen nil) |
---|
1342 | (monitor (eq (car arg-specs-and-result-spec) :monitor-exception-ports)) |
---|
1343 | (arg-specs (butlast arg-specs-and-result-spec)) |
---|
1344 | (result-spec (car (last arg-specs-and-result-spec)))) |
---|
1345 | (if monitor |
---|
1346 | (setq arg-specs (cdr arg-specs))) |
---|
1347 | (unless (evenp (length arg-specs)) |
---|
1348 | (error "odd number of arg-specs")) |
---|
1349 | (loop |
---|
1350 | (when (null arg-specs) (return)) |
---|
1351 | (let* ((arg-keyword (pop arg-specs)) |
---|
1352 | (value (pop arg-specs))) |
---|
1353 | (if (or (memq arg-keyword *arg-spec-keywords*) |
---|
1354 | (typep arg-keyword 'unsigned-byte)) |
---|
1355 | (progn |
---|
1356 | (push arg-keyword specs) |
---|
1357 | (push value vals)) |
---|
1358 | (if (eq arg-keyword :registers) |
---|
1359 | (if register-spec-seen |
---|
1360 | (error "duplicate :registers in ~s" arg-specs-and-result-spec) |
---|
1361 | (progn |
---|
1362 | (setq register-spec-seen t) |
---|
1363 | (push arg-keyword specs) |
---|
1364 | (push value vals))) |
---|
1365 | (error "Unknown argument spec: ~s" arg-keyword))))) |
---|
1366 | (unless (or (eq result-spec :void) |
---|
1367 | (memq result-spec *arg-spec-keywords*)) |
---|
1368 | (error "Unknown result spec: ~s" result-spec)) |
---|
1369 | (make-acode operator |
---|
1370 | (nx1-form address-expression) |
---|
1371 | (nreverse specs) |
---|
1372 | (mapcar #'nx1-form (nreverse vals)) |
---|
1373 | result-spec |
---|
1374 | monitor))) |
---|
1375 | |
---|
1376 | (defnx1 nx1-block block (blockname &body forms) |
---|
1377 | (let* ((*nx-blocks* *nx-blocks*) |
---|
1378 | (*nx-lexical-environment* (new-lexical-environment *nx-lexical-environment*)) |
---|
1379 | (*nx-bound-vars* *nx-bound-vars*) |
---|
1380 | (tagvar (nx-new-temp-var (make-pending-declarations))) |
---|
1381 | (thisblock (cons (setq blockname (nx-need-sym blockname)) tagvar)) |
---|
1382 | (body nil)) |
---|
1383 | (push thisblock *nx-blocks*) |
---|
1384 | (setq body (nx1-progn-body forms)) |
---|
1385 | (%rplacd thisblock nil) |
---|
1386 | (let ((tagbits (nx-var-bits tagvar))) |
---|
1387 | (if (not (%ilogbitp $vbitclosed tagbits)) |
---|
1388 | (if (neq 0 (%ilogand $vrefmask tagbits)) |
---|
1389 | (make-acode |
---|
1390 | (%nx1-operator local-block) |
---|
1391 | thisblock |
---|
1392 | body) |
---|
1393 | body) |
---|
1394 | (progn |
---|
1395 | (nx-set-var-bits tagvar (%ilogior (%ilsl $vbitdynamicextent 1) tagbits)) |
---|
1396 | (nx-inhibit-register-allocation) ; Could also set $vbitnoreg in all setqed vars, or keep track better |
---|
1397 | (make-acode |
---|
1398 | (%nx1-operator local-block) |
---|
1399 | thisblock |
---|
1400 | (make-acode |
---|
1401 | (%nx1-operator let) |
---|
1402 | (list tagvar) |
---|
1403 | (list (make-acode (%nx1-operator cons) (nx1-form nil) (nx1-form nil))) |
---|
1404 | (make-acode |
---|
1405 | (%nx1-operator catch) |
---|
1406 | (make-acode (%nx1-operator lexical-reference) tagvar) |
---|
1407 | body) |
---|
1408 | 0))))))) |
---|
1409 | |
---|
1410 | (defnx1 nx1-return-from return-from (blockname &optional value) |
---|
1411 | (multiple-value-bind (info closed) |
---|
1412 | (nx-block-info (setq blockname (nx-need-sym blockname))) |
---|
1413 | (unless info (nx-error "Can't RETURN-FROM block : ~S." blockname)) |
---|
1414 | (unless closed (nx-adjust-ref-count (cdr info))) |
---|
1415 | (make-acode |
---|
1416 | (if closed |
---|
1417 | (%nx1-operator throw) |
---|
1418 | (%nx1-operator local-return-from)) |
---|
1419 | (if closed |
---|
1420 | (nx1-symbol (var-name (cdr info))) |
---|
1421 | info) |
---|
1422 | (nx1-form value)))) |
---|
1423 | |
---|
1424 | (defnx1 nx1-funcall ((funcall)) (func &rest args) |
---|
1425 | (let ((name func)) |
---|
1426 | (if (and (consp name) |
---|
1427 | (eq (%car name) 'function) |
---|
1428 | (consp (%cdr name)) |
---|
1429 | (null (%cddr name)) |
---|
1430 | (or |
---|
1431 | (if (symbolp (setq name (%cadr name))) |
---|
1432 | (or (not (macro-function name *nx-lexical-environment*)) |
---|
1433 | (nx-error "Can't funcall macro function ~s ." name))) |
---|
1434 | (and (consp name) |
---|
1435 | (or (eq (%car name) 'lambda) |
---|
1436 | (setq name (nx-need-function-name name)))))) |
---|
1437 | (nx1-form (cons name args)) ; This picks up call-next-method evil. |
---|
1438 | (nx1-call (nx1-form func) args nil t)))) |
---|
1439 | |
---|
1440 | (defnx1 nx1-multiple-value-call multiple-value-call (value-form &rest args) |
---|
1441 | (make-acode (%nx1-default-operator) |
---|
1442 | (nx1-form value-form) |
---|
1443 | (nx1-formlist args))) |
---|
1444 | |
---|
1445 | #| |
---|
1446 | (defun nx1-call-name (fn &aux (name (nx1-func-name fn))) |
---|
1447 | (if (and name (or (eq (%car fn) 'quote) (null (nx-lexical-finfo name)))) |
---|
1448 | (make-acode (%nx1-operator immediate) name) |
---|
1449 | (or name (nx1-form fn)))) |
---|
1450 | |# |
---|
1451 | |
---|
1452 | (defnx1 nx1-compiler-let compiler-let (bindings &body forms) |
---|
1453 | (let* ((vars nil) |
---|
1454 | (varinits nil)) |
---|
1455 | (dolist (pair bindings) |
---|
1456 | (push (nx-pair-name pair) vars) |
---|
1457 | (push (eval (nx-pair-initform pair)) varinits)) |
---|
1458 | (progv (nreverse vars) (nreverse varinits) (nx1-catch-body forms)))) |
---|
1459 | |
---|
1460 | (defnx1 nx1-fbind fbind (fnspecs &body body &environment old-env) |
---|
1461 | (let* ((fnames nil) |
---|
1462 | (vars nil) |
---|
1463 | (vals nil)) |
---|
1464 | (dolist (spec fnspecs (setq vals (nreverse vals))) |
---|
1465 | (destructuring-bind (fname initform) spec |
---|
1466 | (push (setq fname (nx-need-function-name fname)) fnames) |
---|
1467 | (push (nx1-form initform) vals))) |
---|
1468 | (let* ((new-env (new-lexical-environment old-env)) |
---|
1469 | (*nx-bound-vars* *nx-bound-vars*) |
---|
1470 | (*nx-lexical-environment* new-env) |
---|
1471 | (pending (make-pending-declarations))) |
---|
1472 | (dolist (fname fnames) |
---|
1473 | (let ((var (nx-new-var pending (make-symbol (symbol-name fname))))) |
---|
1474 | (nx-set-var-bits var (%ilogior (%ilsl $vbitignoreunused 1) |
---|
1475 | (nx-var-bits var))) |
---|
1476 | (let ((afunc (make-afunc))) |
---|
1477 | (setf (afunc-bits afunc) (%ilsl $fbitruntimedef 1)) |
---|
1478 | (setf (afunc-lfun afunc) var) |
---|
1479 | (push var vars) |
---|
1480 | (push (cons fname (cons 'function (cons afunc (var-name var)))) (lexenv.functions new-env))))) |
---|
1481 | (make-acode |
---|
1482 | (%nx1-operator let) |
---|
1483 | vars |
---|
1484 | vals |
---|
1485 | (nx1-env-body body old-env) |
---|
1486 | *nx-new-p2decls*)))) |
---|
1487 | |
---|
1488 | (defun maybe-warn-about-nx1-alphatizer-binding (funcname) |
---|
1489 | (when (and (symbolp funcname) |
---|
1490 | (gethash funcname *nx1-alphatizers*)) |
---|
1491 | (nx1-whine :special-fbinding funcname))) |
---|
1492 | |
---|
1493 | (defnx1 nx1-flet flet (defs &body forms) |
---|
1494 | (with-nx-declarations (pending) |
---|
1495 | (let* ((env *nx-lexical-environment*) |
---|
1496 | (*nx-lexical-environment* env) |
---|
1497 | (*nx-bound-vars* *nx-bound-vars*) |
---|
1498 | (new-env (new-lexical-environment env)) |
---|
1499 | (names nil) |
---|
1500 | (funcs nil) |
---|
1501 | (pairs nil) |
---|
1502 | (fname nil) |
---|
1503 | (name nil)) |
---|
1504 | (multiple-value-bind (body decls) (parse-body forms env nil) |
---|
1505 | (nx-process-declarations pending decls) |
---|
1506 | (dolist (def defs (setq names (nreverse names) funcs (nreverse funcs))) |
---|
1507 | (destructuring-bind (funcname lambda-list &body flet-function-body) def |
---|
1508 | (setq fname (nx-need-function-name funcname)) |
---|
1509 | (maybe-warn-about-nx1-alphatizer-binding funcname) |
---|
1510 | (multiple-value-bind (body decls) |
---|
1511 | (parse-body flet-function-body env) |
---|
1512 | (let ((func (make-afunc))) |
---|
1513 | (setf (afunc-environment func) env |
---|
1514 | (afunc-lambdaform func) `(lambda ,lambda-list |
---|
1515 | ,@decls |
---|
1516 | (block ,(if (consp funcname) (%cadr funcname) funcname) |
---|
1517 | ,@body))) |
---|
1518 | (push func funcs) |
---|
1519 | (when (and *nx-next-method-var* |
---|
1520 | (eq funcname 'call-next-method) |
---|
1521 | (null *nx-call-next-method-function*)) |
---|
1522 | (setq *nx-call-next-method-function* func)) |
---|
1523 | (push (cons funcname func) pairs) |
---|
1524 | (if (consp funcname) |
---|
1525 | (setq funcname fname)) |
---|
1526 | (push (setq name (make-symbol (symbol-name funcname))) names) |
---|
1527 | (push (cons funcname (cons 'function (cons func name))) (lexenv.functions new-env)))))) |
---|
1528 | (let ((vars nil) |
---|
1529 | (rvars nil) |
---|
1530 | (rfuncs nil)) |
---|
1531 | (dolist (sym names vars) (push (nx-new-var pending sym) vars)) |
---|
1532 | (nx-effect-other-decls pending new-env) |
---|
1533 | (setq body (let* ((*nx-lexical-environment* new-env)) |
---|
1534 | (nx1-dynamic-extent-functions vars new-env) |
---|
1535 | (nx1-env-body body env))) |
---|
1536 | (dolist (pair pairs) |
---|
1537 | (let ((afunc (cdr pair)) |
---|
1538 | (var (pop vars))) |
---|
1539 | (when (or (afunc-callers afunc) |
---|
1540 | (neq 0 (afunc-fn-refcount afunc)) |
---|
1541 | (neq 0 (afunc-fn-downward-refcount afunc))) |
---|
1542 | (push (nx1-compile-inner-function (%car pair) |
---|
1543 | (afunc-lambdaform afunc) |
---|
1544 | afunc |
---|
1545 | (afunc-environment afunc)) |
---|
1546 | rfuncs) |
---|
1547 | (push var rvars)))) |
---|
1548 | (nx-reconcile-inherited-vars rfuncs) |
---|
1549 | (dolist (f rfuncs) (nx1-afunc-ref f)) |
---|
1550 | (make-acode |
---|
1551 | (%nx1-operator flet) |
---|
1552 | rvars |
---|
1553 | rfuncs |
---|
1554 | body |
---|
1555 | *nx-new-p2decls*)))))) |
---|
1556 | |
---|
1557 | (defun nx1-dynamic-extent-functions (vars env) |
---|
1558 | (let ((bits nil) |
---|
1559 | (varinfo nil)) |
---|
1560 | (dolist (decl (lexenv.fdecls env)) |
---|
1561 | (let ((downward-guy (if (eq (cadr decl) 'dynamic-extent) (car decl)))) |
---|
1562 | (when downward-guy |
---|
1563 | (multiple-value-bind (finfo afunc) (nx-lexical-finfo downward-guy) |
---|
1564 | (when (and afunc |
---|
1565 | (not (%ilogbitp $fbitdownward (setq bits (afunc-bits afunc)))) |
---|
1566 | (setq varinfo (and (consp (%cdr finfo)) (nx-lex-info (%cddr finfo)))) |
---|
1567 | (memq varinfo vars)) |
---|
1568 | (setf (afunc-bits afunc) |
---|
1569 | (%ilogior |
---|
1570 | bits |
---|
1571 | (%ilsl $fbitdownward 1) |
---|
1572 | (%ilsl $fbitbounddownward 1))) |
---|
1573 | (nx-set-var-bits varinfo (%ilogior (%ilsl $vbitdynamicextent 1) (nx-var-bits varinfo)))))))))) |
---|
1574 | |
---|
1575 | (defnx1 nx1-labels labels (defs &body forms) |
---|
1576 | (with-nx-declarations (pending) |
---|
1577 | (let* ((env *nx-lexical-environment*) |
---|
1578 | (old-env (lexenv.parent-env env)) |
---|
1579 | (*nx-bound-vars* *nx-bound-vars*) |
---|
1580 | (func nil) |
---|
1581 | (funcs nil) |
---|
1582 | (funcrefs nil) |
---|
1583 | (bodies nil) |
---|
1584 | (vars nil) |
---|
1585 | (blockname nil) |
---|
1586 | (fname nil) |
---|
1587 | (name nil)) |
---|
1588 | (multiple-value-bind (body decls) (parse-body forms env nil) |
---|
1589 | (dolist (def defs (setq funcs (nreverse funcs) bodies (nreverse bodies))) |
---|
1590 | (destructuring-bind (funcname lambda-list &body labels-function-body) def |
---|
1591 | (maybe-warn-about-nx1-alphatizer-binding funcname) |
---|
1592 | (push (setq func (make-afunc)) funcs) |
---|
1593 | (setq blockname funcname) |
---|
1594 | (setq fname (nx-need-function-name funcname)) |
---|
1595 | (when (consp funcname) |
---|
1596 | (setq blockname (%cadr funcname) funcname fname)) |
---|
1597 | (let ((var (nx-new-var pending (setq name (make-symbol (symbol-name funcname)))))) |
---|
1598 | (nx-set-var-bits var (%ilsl $vbitignoreunused 1)) |
---|
1599 | (push var vars)) |
---|
1600 | (push func funcrefs) |
---|
1601 | (multiple-value-bind (body decls) |
---|
1602 | (parse-body labels-function-body old-env) |
---|
1603 | (push (cons funcname (cons 'function (cons func name))) (lexenv.functions env)) |
---|
1604 | (let* ((expansion `(lambda ,lambda-list |
---|
1605 | ,@decls |
---|
1606 | (block ,blockname |
---|
1607 | ,@body)))) |
---|
1608 | (setf (afunc-lambdaform func) expansion |
---|
1609 | (afunc-environment func) env) |
---|
1610 | (push (cons funcname expansion) |
---|
1611 | bodies))))) |
---|
1612 | (nx1-dynamic-extent-functions vars env) |
---|
1613 | (dolist (def bodies) |
---|
1614 | (nx1-compile-inner-function (car def) (cdr def) (setq func (pop funcs)))) |
---|
1615 | (nx-process-declarations pending decls) |
---|
1616 | (nx-effect-other-decls pending env) |
---|
1617 | (setq body (nx1-env-body body old-env)) |
---|
1618 | (nx-reconcile-inherited-vars funcrefs) |
---|
1619 | (dolist (f funcrefs) (nx1-afunc-ref f)) |
---|
1620 | (make-acode |
---|
1621 | (%nx1-operator labels) |
---|
1622 | (nreverse vars) |
---|
1623 | (nreverse funcrefs) |
---|
1624 | body |
---|
1625 | *nx-new-p2decls*))))) |
---|
1626 | |
---|
1627 | |
---|
1628 | |
---|
1629 | (defnx1 nx1-set-bit ((%set-bit)) (ptr offset &optional (newval nil newval-p)) |
---|
1630 | (unless newval-p (setq newval offset offset 0)) |
---|
1631 | (make-acode |
---|
1632 | (%nx1-operator %set-bit) |
---|
1633 | (make-acode (%nx1-operator %macptrptr%) (nx1-form ptr)) |
---|
1634 | (nx1-form offset) |
---|
1635 | (nx1-form newval))) |
---|
1636 | |
---|
1637 | (defnx1 nx1-set-xxx ((%set-ptr) (%set-long) (%set-word) (%set-byte) |
---|
1638 | (%set-unsigned-long) (%set-unsigned-word) (%set-unsigned-byte)) |
---|
1639 | (ptr offset &optional (newval nil new-val-p) &aux (op *nx-sfname*)) |
---|
1640 | (unless new-val-p (setq newval offset offset 0)) |
---|
1641 | (make-acode |
---|
1642 | (%nx1-operator %immediate-set-xxx) |
---|
1643 | (case op |
---|
1644 | (%set-ptr 0) |
---|
1645 | (%set-word 2) |
---|
1646 | (%set-unsigned-word (logior 32 2)) |
---|
1647 | (%set-byte 1) |
---|
1648 | (%set-unsigned-byte (logior 32 1)) |
---|
1649 | (%set-unsigned-long (logior 32 4)) |
---|
1650 | (t 4)) |
---|
1651 | (make-acode (%nx1-operator %macptrptr%) (nx1-form ptr)) |
---|
1652 | (nx1-form offset) |
---|
1653 | (nx1-form newval))) |
---|
1654 | |
---|
1655 | (defnx1 nx1-set-64-xxx ((%%set-unsigned-longlong) (%%set-signed-longlong)) |
---|
1656 | (&whole w ptr offset newval &aux (op *nx-sfname*)) |
---|
1657 | (target-word-size-case |
---|
1658 | (32 (nx1-treat-as-call w)) |
---|
1659 | (64 |
---|
1660 | (make-acode |
---|
1661 | (%nx1-operator %immediate-set-xxx) |
---|
1662 | (case op |
---|
1663 | (%%set-signed-longlong (logior 32 8)) |
---|
1664 | (t 8)) |
---|
1665 | (make-acode (%nx1-operator %macptrptr%) (nx1-form ptr)) |
---|
1666 | (nx1-form offset) |
---|
1667 | (nx1-form newval))))) |
---|
1668 | |
---|
1669 | |
---|
1670 | (defnx1 nx1-get-bit ((%get-bit)) (ptrform &optional (offset 0)) |
---|
1671 | (make-acode |
---|
1672 | (%nx1-operator typed-form) |
---|
1673 | 'bit |
---|
1674 | (make-acode |
---|
1675 | (%nx1-operator %get-bit) |
---|
1676 | (make-acode (%nx1-operator %macptrptr%) (nx1-form ptrform)) |
---|
1677 | (nx1-form offset)))) |
---|
1678 | |
---|
1679 | (defnx1 nx1-get-64-xxx ((%%get-unsigned-longlong) (%%get-signed-longlong)) |
---|
1680 | (&whole w ptrform offsetform) |
---|
1681 | (target-word-size-case |
---|
1682 | (32 (nx1-treat-as-call w)) |
---|
1683 | (64 |
---|
1684 | (let* ((flagbits (case *nx-sfname* |
---|
1685 | (%%get-unsigned-longlong 8) |
---|
1686 | (%%get-signed-longlong (logior 32 8)))) |
---|
1687 | (signed (logbitp 5 flagbits))) |
---|
1688 | (make-acode (%nx1-operator typed-form) |
---|
1689 | (if signed |
---|
1690 | '(signed-byte 64) |
---|
1691 | '(unsigned-byte 64)) |
---|
1692 | (make-acode |
---|
1693 | (%nx1-operator immediate-get-xxx) |
---|
1694 | flagbits |
---|
1695 | (make-acode (%nx1-operator %macptrptr%) (nx1-form ptrform)) |
---|
1696 | (nx1-form offsetform))))))) |
---|
1697 | |
---|
1698 | (defnx1 nx1-get-xxx ((%get-long) (%get-full-long) (%get-signed-long) |
---|
1699 | (%get-fixnum) |
---|
1700 | (%get-word) (%get-unsigned-word) |
---|
1701 | (%get-byte) (%get-unsigned-byte) |
---|
1702 | (%get-signed-word) |
---|
1703 | (%get-signed-byte) |
---|
1704 | (%get-unsigned-long)) |
---|
1705 | (ptrform &optional (offset 0)) |
---|
1706 | (let* ((sfname *nx-sfname*) |
---|
1707 | (flagbits (case sfname |
---|
1708 | ((%get-long %get-full-long %get-signed-long) (logior 4 32)) |
---|
1709 | (%get-fixnum (logior 4 32 64)) |
---|
1710 | |
---|
1711 | ((%get-word %get-unsigned-word) 2) |
---|
1712 | (%get-signed-word (logior 2 32)) |
---|
1713 | ((%get-byte %get-unsigned-byte) 1) |
---|
1714 | (%get-signed-byte (logior 1 32)) |
---|
1715 | (%get-unsigned-long 4))) |
---|
1716 | (signed (logbitp 5 flagbits))) |
---|
1717 | (declare (fixnum flagbits)) |
---|
1718 | (make-acode (%nx1-operator typed-form) |
---|
1719 | (case (logand 15 flagbits) |
---|
1720 | (4 (if (logbitp 6 flagbits) |
---|
1721 | 'fixnum |
---|
1722 | (if signed |
---|
1723 | '(signed-byte 32) |
---|
1724 | '(unsigned-byte 32)))) |
---|
1725 | (2 (if signed |
---|
1726 | '(signed-byte 16) |
---|
1727 | '(unsigned-byte 16))) |
---|
1728 | (1 (if signed |
---|
1729 | '(signed-byte 8) |
---|
1730 | '(unsigned-byte 8)))) |
---|
1731 | (make-acode |
---|
1732 | (%nx1-operator immediate-get-xxx) |
---|
1733 | flagbits |
---|
1734 | (make-acode (%nx1-operator %macptrptr%) (nx1-form ptrform)) |
---|
1735 | (nx1-form offset))))) |
---|
1736 | |
---|
1737 | (defnx1 nx1-%get-ptr ((%get-ptr) ) (ptrform &optional (offset 0)) |
---|
1738 | (make-acode |
---|
1739 | (%nx1-operator %consmacptr%) |
---|
1740 | (make-acode |
---|
1741 | (%nx1-operator immediate-get-ptr) |
---|
1742 | (make-acode (%nx1-operator %macptrptr%) (nx1-form ptrform)) |
---|
1743 | (nx1-form offset)))) |
---|
1744 | |
---|
1745 | (defnx1 nx1-%get-float ((%get-single-float) |
---|
1746 | (%get-double-float)) (ptrform &optional (offset 0)) |
---|
1747 | (make-acode |
---|
1748 | (%nx1-operator typed-form) |
---|
1749 | (if (eq *nx-sfname* '%get-single-float) |
---|
1750 | 'single-float |
---|
1751 | 'double-float) |
---|
1752 | (make-acode |
---|
1753 | (%nx1-default-operator) |
---|
1754 | (make-acode (%nx1-operator %macptrptr%) (nx1-form ptrform)) |
---|
1755 | (nx1-form offset)))) |
---|
1756 | |
---|
1757 | (defnx1 nx1-%set-float ((%set-single-float) |
---|
1758 | (%set-double-float)) (&whole whole ptrform offset &optional (newval nil newval-p)) |
---|
1759 | (unless newval-p |
---|
1760 | (setq newval offset |
---|
1761 | offset 0)) |
---|
1762 | (make-acode |
---|
1763 | (%nx1-operator typed-form) |
---|
1764 | (if (eq *nx-sfname* '%set-single-float) |
---|
1765 | 'single-float |
---|
1766 | 'double-float) |
---|
1767 | (make-acode |
---|
1768 | (%nx1-default-operator) |
---|
1769 | (make-acode (%nx1-operator %macptrptr%) (nx1-form ptrform)) |
---|
1770 | (nx1-form offset) |
---|
1771 | (nx1-form newval)))) |
---|
1772 | |
---|
1773 | (defnx1 nx1-let let (pairs &body forms &environment old-env) |
---|
1774 | (let* ((vars nil) |
---|
1775 | (vals nil) |
---|
1776 | (varspecs nil)) |
---|
1777 | (with-nx-declarations (pending) |
---|
1778 | (multiple-value-bind (body decls) |
---|
1779 | (parse-body forms *nx-lexical-environment* nil) |
---|
1780 | (nx-process-declarations pending decls) |
---|
1781 | ; Make sure that the initforms are processed in the outer |
---|
1782 | ; environment (in case any declaration handlers side-effected |
---|
1783 | ; the environment.) |
---|
1784 | (let* ((*nx-lexical-environment* old-env)) |
---|
1785 | (dolist (pair pairs) |
---|
1786 | (push (nx-need-var (nx-pair-name pair)) vars) |
---|
1787 | (push (nx1-typed-var-initform pending (car vars) (nx-pair-initform pair)) vals))) |
---|
1788 | (let* ((*nx-bound-vars* (append vars *nx-bound-vars*)) |
---|
1789 | (varbindings (nx1-note-var-bindings |
---|
1790 | (dolist (sym vars varspecs) |
---|
1791 | (push (nx-new-var pending sym) varspecs)) |
---|
1792 | (setq vals (nreverse vals)))) |
---|
1793 | (form |
---|
1794 | (make-acode |
---|
1795 | (%nx1-operator let) |
---|
1796 | varspecs |
---|
1797 | vals |
---|
1798 | (progn |
---|
1799 | (nx-effect-other-decls pending *nx-lexical-environment*) |
---|
1800 | (nx1-env-body body old-env)) |
---|
1801 | *nx-new-p2decls*))) |
---|
1802 | (nx1-check-var-bindings varbindings) |
---|
1803 | (nx1-punt-bindings varspecs vals) |
---|
1804 | form))))) |
---|
1805 | |
---|
1806 | |
---|
1807 | |
---|
1808 | ;((lambda (lambda-list) . body) . args) |
---|
1809 | (defun nx1-lambda-bind (lambda-list args body &optional (body-environment *nx-lexical-environment*)) |
---|
1810 | (let* ((old-env body-environment) |
---|
1811 | (arg-env *nx-lexical-environment*) |
---|
1812 | (arglist nil) |
---|
1813 | var-bound-vars |
---|
1814 | vars vals vars* vals*) |
---|
1815 | ;; If the lambda list contains &LEXPR, we can't do it. Yet. |
---|
1816 | (multiple-value-bind (ok req opttail resttail) (verify-lambda-list lambda-list) |
---|
1817 | (declare (ignore req opttail)) |
---|
1818 | (when (and ok (eq (%car resttail) '&lexpr)) |
---|
1819 | (return-from nx1-lambda-bind (nx1-call (nx1-form `(lambda ,lambda-list ,@body)) args)))) |
---|
1820 | (let* ((*nx-lexical-environment* body-environment) |
---|
1821 | (*nx-bound-vars* *nx-bound-vars*)) |
---|
1822 | (with-nx-declarations (pending) |
---|
1823 | (multiple-value-bind (body decls) (parse-body body *nx-lexical-environment*) |
---|
1824 | (nx-process-declarations pending decls) |
---|
1825 | (multiple-value-bind (req opt rest keys auxen) |
---|
1826 | (nx-parse-simple-lambda-list pending lambda-list) |
---|
1827 | (let* ((*nx-lexical-environment* arg-env)) |
---|
1828 | (setq arglist (nx1-formlist args))) |
---|
1829 | (nx-effect-other-decls pending *nx-lexical-environment*) |
---|
1830 | (setq body (nx1-env-body body old-env)) |
---|
1831 | (while req |
---|
1832 | (when (null arglist) |
---|
1833 | (nx-error "Not enough args in Lambda form: ~S ~S." lambda-list args)) |
---|
1834 | (let* ((var (pop req)) |
---|
1835 | (val (pop arglist)) |
---|
1836 | (binding (nx1-note-var-binding var val))) |
---|
1837 | (push var vars) |
---|
1838 | (push val vals) |
---|
1839 | (when binding (push binding var-bound-vars)))) |
---|
1840 | (nx1-check-var-bindings var-bound-vars) |
---|
1841 | (nx1-punt-bindings vars vals) |
---|
1842 | (destructuring-bind (&optional optvars inits spvars) opt |
---|
1843 | (while optvars |
---|
1844 | (if arglist |
---|
1845 | (progn |
---|
1846 | (push (%car optvars) vars) (push (%car arglist) vals) |
---|
1847 | (when (%car spvars) (push (%car spvars) vars) (push *nx-t* vals))) |
---|
1848 | (progn |
---|
1849 | (push (%car optvars) vars*) (push (%car inits) vals*) |
---|
1850 | (when (%car spvars) (push (%car spvars) vars*) (push *nx-nil* vals*)))) |
---|
1851 | (setq optvars (%cdr optvars) spvars (%cdr spvars) inits (%cdr inits) |
---|
1852 | arglist (%cdr arglist)))) |
---|
1853 | (if arglist |
---|
1854 | (when (and (not keys) (not rest)) |
---|
1855 | (nx-error "Extra args in Lambda form: ~S ~S." lambda-list args)) |
---|
1856 | (when rest |
---|
1857 | (push rest vars*) (push *nx-nil* vals*) |
---|
1858 | (nx1-punt-bindings (cons rest nil) (cons *nx-nil* nil)) |
---|
1859 | (setq rest nil))) |
---|
1860 | (when keys |
---|
1861 | (let* ((punt nil)) |
---|
1862 | (destructuring-bind (kallowother keyvars spvars inits keyvect) keys |
---|
1863 | (do* ((pairs arglist (%cddr pairs))) |
---|
1864 | ((null pairs)) |
---|
1865 | (let* ((keyword (car pairs))) |
---|
1866 | (when (or (not (acode-p keyword)) |
---|
1867 | (neq (acode-operator keyword) (%nx1-operator immediate)) |
---|
1868 | (eq (%cadr keyword) :allow-other-keys)) |
---|
1869 | (return (setq punt t))))) |
---|
1870 | (do* ((nkeys (length keyvect)) |
---|
1871 | (keyargs (make-array nkeys :initial-element nil)) |
---|
1872 | (argl arglist (%cddr argl)) |
---|
1873 | (n 0 (%i+ n 1)) |
---|
1874 | idx arg hit) |
---|
1875 | ((null argl) |
---|
1876 | (unless rest |
---|
1877 | (while arglist |
---|
1878 | (push (%cadr arglist) vals) |
---|
1879 | (setq arglist (%cddr arglist)))) |
---|
1880 | (dotimes (i (the fixnum nkeys)) |
---|
1881 | (push (%car keyvars) vars*) |
---|
1882 | (push (or (%svref keyargs i) (%car inits)) vals*) |
---|
1883 | (when (%car spvars) |
---|
1884 | (push (%car spvars) vars*) |
---|
1885 | (push (if (%svref keyargs i) *nx-t* *nx-nil*) vals*)) |
---|
1886 | (setq keyvars (%cdr keyvars) inits (%cdr inits) spvars (%cdr spvars))) |
---|
1887 | (setq keys hit)) |
---|
1888 | (setq arg (%car argl)) |
---|
1889 | (unless (and (not punt) |
---|
1890 | (%cdr argl)) |
---|
1891 | (let ((var (nx-new-temp-var pending))) |
---|
1892 | (when (or (null rest) (%ilogbitp $vbitdynamicextent (nx-var-bits rest))) |
---|
1893 | (nx-set-var-bits var (%ilogior (%ilsl $vbitdynamicextent 1) (nx-var-bits var)))) |
---|
1894 | (setq body (make-acode |
---|
1895 | (%nx1-operator debind) |
---|
1896 | nil |
---|
1897 | (make-acode |
---|
1898 | (%nx1-operator lexical-reference) var) |
---|
1899 | nil |
---|
1900 | nil |
---|
1901 | rest |
---|
1902 | keys |
---|
1903 | auxen |
---|
1904 | nil |
---|
1905 | body |
---|
1906 | *nx-new-p2decls* |
---|
1907 | nil) |
---|
1908 | rest var keys nil auxen nil) |
---|
1909 | (return nil))) |
---|
1910 | (unless (or (setq idx (position (%cadr arg) keyvect)) |
---|
1911 | (eq (%cadr arg) :allow-other-keys) |
---|
1912 | (and kallowother (symbolp (%cadr arg)))) |
---|
1913 | (nx-error "Invalid keyword in Lambda form: ~S ~S." |
---|
1914 | lambda-list args)) |
---|
1915 | (when (and idx (null (%svref keyargs idx))) |
---|
1916 | (setq hit t) |
---|
1917 | (%svset keyargs idx n)))))) |
---|
1918 | (destructuring-bind (&optional auxvars auxvals) auxen |
---|
1919 | (let ((vars!% (nreconc vars* auxvars)) |
---|
1920 | (vals!& (nreconc vals* auxvals))) |
---|
1921 | (make-acode (%nx1-operator lambda-bind) |
---|
1922 | (append (nreverse vals) arglist) |
---|
1923 | (nreverse vars) |
---|
1924 | rest |
---|
1925 | keys |
---|
1926 | (list vars!% vals!&) |
---|
1927 | body |
---|
1928 | *nx-new-p2decls*))))))))) |
---|
1929 | |
---|
1930 | (defun nx-inhibit-register-allocation (&optional (why 0)) |
---|
1931 | (let ((afunc *nx-current-function*)) |
---|
1932 | (setf (afunc-bits afunc) |
---|
1933 | (%ilogior (%ilsl $fbitnoregs 1) |
---|
1934 | why |
---|
1935 | (afunc-bits afunc))))) |
---|
1936 | |
---|
1937 | |
---|
1938 | |
---|
1939 | (defnx1 nx1-lap-function (ppc-lap-function) (name bindings &body body) |
---|
1940 | (declare (ftype (function (t t t)) %define-ppc-lap-function)) |
---|
1941 | (require "PPC-LAP" "ccl:compiler;ppc;ppc-lap") |
---|
1942 | (setf (afunc-lfun *nx-current-function*) |
---|
1943 | (%define-ppc-lap-function name `((let ,bindings ,@body)) |
---|
1944 | (dpb (length bindings) $lfbits-numreq 0)))) |
---|
1945 | |
---|
1946 | (defnx1 nx1-x86-lap-function (x86-lap-function) (name bindings &body body) |
---|
1947 | (declare (ftype (function (t t t t)) %define-x86-lap-function)) |
---|
1948 | (require "X86-LAP") |
---|
1949 | (setf (afunc-lfun *nx-current-function*) |
---|
1950 | (%define-x86-lap-function name `((let ,bindings ,@body)) |
---|
1951 | (dpb (length bindings) $lfbits-numreq 0)))) |
---|
1952 | |
---|
1953 | |
---|
1954 | |
---|
1955 | (defun nx1-env-body (body old-env) |
---|
1956 | (do* ((form (nx1-progn-body body)) |
---|
1957 | (env *nx-lexical-environment* (lexenv.parent-env env))) |
---|
1958 | ((or (eq env old-env) (null env)) form) |
---|
1959 | (let ((vars (lexenv.variables env))) |
---|
1960 | (if (consp vars) |
---|
1961 | (dolist (var vars) |
---|
1962 | (nx-check-var-usage var)))))) |
---|
1963 | |
---|
1964 | (defnx1 nx1-let* (let*) (varspecs &body forms) |
---|
1965 | (let* ((vars nil) |
---|
1966 | (vals nil) |
---|
1967 | (val nil) |
---|
1968 | (var-bound-vars nil) |
---|
1969 | (*nx-bound-vars* *nx-bound-vars*) |
---|
1970 | (old-env *nx-lexical-environment*)) |
---|
1971 | (with-nx-declarations (pending) |
---|
1972 | (multiple-value-bind (body decls) |
---|
1973 | (parse-body forms *nx-lexical-environment* nil) |
---|
1974 | (nx-process-declarations pending decls) |
---|
1975 | (dolist (pair varspecs) |
---|
1976 | (let* ((sym (nx-need-var (nx-pair-name pair))) |
---|
1977 | (var (progn |
---|
1978 | (push (setq val (nx1-typed-var-initform pending sym (nx-pair-initform pair))) vals) |
---|
1979 | (nx-new-var pending sym))) |
---|
1980 | (binding (nx1-note-var-binding var val))) |
---|
1981 | (when binding (push binding var-bound-vars)) |
---|
1982 | (push var vars))) |
---|
1983 | (nx-effect-other-decls pending *nx-lexical-environment*) |
---|
1984 | (let* ((result |
---|
1985 | (make-acode |
---|
1986 | (%nx1-default-operator) |
---|
1987 | (setq vars (nreverse vars)) |
---|
1988 | (setq vals (nreverse vals)) |
---|
1989 | (nx1-env-body body old-env) |
---|
1990 | *nx-new-p2decls*))) |
---|
1991 | (nx1-check-var-bindings var-bound-vars) |
---|
1992 | (nx1-punt-bindings vars vals) |
---|
1993 | result))))) |
---|
1994 | |
---|
1995 | (defnx1 nx1-multiple-value-bind multiple-value-bind |
---|
1996 | (varspecs bindform &body forms) |
---|
1997 | (if (= (length varspecs) 1) |
---|
1998 | (nx1-form `(let* ((,(car varspecs) ,bindform)) ,@forms)) |
---|
1999 | (let* ((vars nil) |
---|
2000 | (*nx-bound-vars* *nx-bound-vars*) |
---|
2001 | (old-env *nx-lexical-environment*) |
---|
2002 | (mvform (nx1-form bindform))) |
---|
2003 | (with-nx-declarations (pending) |
---|
2004 | (multiple-value-bind (body decls) |
---|
2005 | (parse-body forms *nx-lexical-environment* nil) |
---|
2006 | (nx-process-declarations pending decls) |
---|
2007 | (dolist (sym varspecs) |
---|
2008 | (push (nx-new-var pending sym t) vars)) |
---|
2009 | (nx-effect-other-decls pending *nx-lexical-environment*) |
---|
2010 | (make-acode |
---|
2011 | (%nx1-operator multiple-value-bind) |
---|
2012 | (nreverse vars) |
---|
2013 | mvform |
---|
2014 | (nx1-env-body body old-env) |
---|
2015 | *nx-new-p2decls*)))))) |
---|
2016 | |
---|
2017 | |
---|
2018 | ;;; This isn't intended to be user-visible; there isn't a whole lot of |
---|
2019 | ;;; sanity-checking applied to the subtag. |
---|
2020 | (defnx1 nx1-%alloc-misc ((%alloc-misc)) (element-count subtag &optional (init nil init-p)) |
---|
2021 | (if init-p ; ensure that "init" is evaluated before miscobj is created. |
---|
2022 | (make-acode (%nx1-operator %make-uvector) |
---|
2023 | (nx1-form element-count) |
---|
2024 | (nx1-form subtag) |
---|
2025 | (nx1-form init)) |
---|
2026 | (make-acode (%nx1-operator %make-uvector) |
---|
2027 | (nx1-form element-count) |
---|
2028 | (nx1-form subtag)))) |
---|
2029 | |
---|
2030 | (defnx1 nx1-%lisp-word-ref (%lisp-word-ref) (base offset) |
---|
2031 | (make-acode (%nx1-operator %lisp-word-ref) |
---|
2032 | (nx1-form base) |
---|
2033 | (nx1-form offset))) |
---|
2034 | |
---|
2035 | (defnx1 nx1-%single-to-double ((%single-to-double)) (arg) |
---|
2036 | (make-acode (%nx1-operator %single-to-double) |
---|
2037 | (nx1-form arg))) |
---|
2038 | |
---|
2039 | (defnx1 nx1-%double-to-single ((%double-to-single)) (arg) |
---|
2040 | (make-acode (%nx1-operator %double-to-single) |
---|
2041 | (nx1-form arg))) |
---|
2042 | |
---|
2043 | (defnx1 nx1-%fixnum-to-double ((%fixnum-to-double)) (arg) |
---|
2044 | (make-acode (%nx1-operator %fixnum-to-double) |
---|
2045 | (nx1-form arg))) |
---|
2046 | |
---|
2047 | (defnx1 nx1-%fixnum-to-single ((%fixnum-to-single)) (arg) |
---|
2048 | (make-acode (%nx1-operator %fixnum-to-single) |
---|
2049 | (nx1-form arg))) |
---|
2050 | |
---|
2051 | (defnx1 nx1-%double-float ((%double-float)) (&whole whole arg &optional (result nil result-p)) |
---|
2052 | (declare (ignore result)) |
---|
2053 | (if result-p |
---|
2054 | (nx1-treat-as-call whole) |
---|
2055 | (make-acode (%nx1-operator %double-float) (nx1-form arg)))) |
---|
2056 | |
---|
2057 | (defnx1 nx1-%short-float ((%short-float)) (&whole whole arg &optional (result nil result-p)) |
---|
2058 | (declare (ignore result)) |
---|
2059 | (if result-p |
---|
2060 | (nx1-treat-as-call whole) |
---|
2061 | (make-acode (%nx1-operator %single-float) (nx1-form arg)))) |
---|
2062 | |
---|
2063 | |
---|
2064 | (defnx1 nx1-symvector ((%symptr->symvector) (%symvector->symptr)) (arg) |
---|
2065 | (make-acode (%nx1-default-operator) (nx1-form arg))) |
---|
2066 | |
---|
2067 | (defnx1 nx1-ash (ash) (&whole call &environment env num amt) |
---|
2068 | (let* ((unsigned-natural-type (target-word-size-case |
---|
2069 | (32 '(unsigned-byte 32)) |
---|
2070 | (64 '(unsigned-byte 64)))) |
---|
2071 | (max (target-word-size-case (32 32) (64 64))) |
---|
2072 | (maxbits (target-word-size-case |
---|
2073 | (32 29) |
---|
2074 | (64 60)))) |
---|
2075 | (cond ((eq amt 0) (nx1-form `(require-type ,num 'integer) env)) |
---|
2076 | ((and (fixnump amt) |
---|
2077 | (< amt 0)) |
---|
2078 | (if (nx-form-typep num 'fixnum env) |
---|
2079 | (make-acode (%nx1-operator %iasr) |
---|
2080 | (make-acode (%nx1-operator fixnum) |
---|
2081 | (- amt)) |
---|
2082 | (nx1-form num)) |
---|
2083 | (if (nx-form-typep num unsigned-natural-type env) |
---|
2084 | (make-acode (%nx1-operator natural-shift-right) |
---|
2085 | (nx1-form num) |
---|
2086 | (make-acode (%nx1-operator fixnum) |
---|
2087 | (- amt))) |
---|
2088 | (nx1-treat-as-call call)))) |
---|
2089 | ((and (fixnump amt) |
---|
2090 | (<= 0 amt maxbits) |
---|
2091 | (or (nx-form-typep num `(signed-byte ,(- (1+ maxbits) amt)) env) |
---|
2092 | (and (nx-form-typep num 'fixnum env) |
---|
2093 | (nx-trust-declarations env) |
---|
2094 | (subtypep *nx-form-type* 'fixnum)))) |
---|
2095 | (nx1-form `(%ilsl ,amt ,num))) |
---|
2096 | ((and (fixnump amt) |
---|
2097 | (< amt max) |
---|
2098 | (nx-form-typep num unsigned-natural-type env) |
---|
2099 | (nx-trust-declarations env) |
---|
2100 | (subtypep *nx-form-type* unsigned-natural-type)) |
---|
2101 | (make-acode (%nx1-operator natural-shift-left) |
---|
2102 | (nx1-form num) |
---|
2103 | (nx1-form amt))) |
---|
2104 | (t (nx1-treat-as-call call))))) |
---|
2105 | |
---|
2106 | |
---|
2107 | |
---|
2108 | (defun nx-badformat (&rest args) |
---|
2109 | (nx-error "Bad argument format in ~S ." args)) |
---|
2110 | |
---|
2111 | (defnx1 nx1-eval-when eval-when (when &body body) |
---|
2112 | (nx1-progn-body (if (or (memq 'eval when) (memq :execute when)) body))) |
---|
2113 | |
---|
2114 | (defnx1 nx1-misplaced (declare) (&rest args) |
---|
2115 | (nx-error "~S not expected in ~S." *nx-sfname* (cons *nx-sfname* args))) |
---|
2116 | |
---|