Changeset 11844
- Timestamp:
- 05/08/09 21:11:15 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/src/org/armedbear/lisp/compiler-pass2.lisp
r11842 r11844 1002 1002 ;; functions with a wrong number of arguments or malformed keyword argument 1003 1003 ;; lists, and using unrecognized declaration specifiers." (3.2.5) 1004 (defun check-number-of-args (form n &optional (minimum nil))1004 (defun check-number-of-args (form n &optional minimum) 1005 1005 (declare (type fixnum n)) 1006 1006 (let* ((op (car form)) … … 6506 6506 (emit-move-from-stack target representation))) 6507 6507 6508 (defun cons-for-list/list* (args target representation &optional list-star-p) 6509 (let ((cons-heads (if list-star-p 6510 (butlast args 1) 6511 args))) 6512 (dolist (cons-head cons-heads) 6513 (emit 'new +lisp-cons-class+) 6514 (emit 'dup) 6515 (compile-form cons-head 'stack nil)) 6516 (when list-star-p 6517 (compile-form (first (last args)) 'stack nil)) 6518 (unless list-star-p 6519 (emit-invokespecial-init +lisp-cons-class+ (lisp-object-arg-types 1)) 6520 (setf cons-heads (nbutlast cons-heads 1))) 6521 (dolist (cons-head cons-heads) 6522 (declare (ignore cons-head)) 6523 (emit-invokespecial-init +lisp-cons-class+ (lisp-object-arg-types 2))) 6524 (when list-star-p 6525 (apply #'maybe-emit-clear-values args) 6526 (emit-move-from-stack target representation)))) 6527 6508 6528 (defun p2-list (form target representation) 6509 6529 (let* ((args (cdr form)) 6510 6530 (len (length args))) 6511 (cond ((> len 9) ; list1() through list9() are defined in Lisp.java.6531 (cond ((> len 4) ; list1() through list9() are defined in Lisp.java. 6512 6532 (compile-function-call form target representation)) 6513 6533 (t 6514 6534 (cond ((zerop len) 6515 6535 (emit-push-nil)) 6516 ((= len 1) 6517 (emit 'new +lisp-cons-class+) 6518 (emit 'dup) 6519 (compile-form (first args) 'stack nil) 6520 (emit-invokespecial-init +lisp-cons-class+ (lisp-object-arg-types 1))) 6521 ((and (>= *speed* *space*) 6522 (< len 4)) 6523 (emit 'new +lisp-cons-class+) 6524 (emit 'dup) 6525 (compile-form (first args) 'stack nil) 6526 (emit 'new +lisp-cons-class+) 6527 (emit 'dup) 6528 (compile-form (second args) 'stack nil) 6529 (when (= len 3) 6530 (emit 'new +lisp-cons-class+) 6531 (emit 'dup) 6532 (compile-form (third args) 'stack nil)) 6533 (emit-invokespecial-init +lisp-cons-class+ (lisp-object-arg-types 1)) 6534 (emit-invokespecial-init +lisp-cons-class+ (lisp-object-arg-types 2)) 6535 (when (= len 3) 6536 (emit-invokespecial-init +lisp-cons-class+ (lisp-object-arg-types 2)))) 6537 (t 6538 (dolist (arg args) 6539 (compile-form arg 'stack nil)) 6540 (let ((s (copy-seq "list "))) 6541 (setf (schar s 4) (code-char (+ (char-code #\0) len))) 6542 (emit-invokestatic +lisp-class+ s 6543 (make-list len :initial-element +lisp-object+) 6544 +lisp-cons+)))) 6536 ((>= 4 len 1) 6537 (cons-for-list/list* args target representation))) 6545 6538 (unless (every 'single-valued-p args) 6546 6539 (emit-clear-values)) 6547 6540 (emit-move-from-stack target))))) 6548 6541 6549 (defun cons-for-list* (args target representation)6550 (let ((cons-heads (butlast args 1)))6551 (dolist (cons-head cons-heads)6552 (emit 'new +lisp-cons-class+)6553 (emit 'dup)6554 (compile-form cons-head 'stack nil))6555 (compile-form (first (last args)) 'stack nil)6556 (dolist (cons-head cons-heads)6557 (declare (ignore cons-head))6558 (emit-invokespecial-init +lisp-cons-class+ (lisp-object-arg-types 2)))6559 (apply #'maybe-emit-clear-values args)6560 (emit-move-from-stack target representation)))6561 6562 6542 (defun p2-list* (form target representation) 6563 6543 (let* ((args (cdr form)) 6564 6544 (length (length args))) 6565 (cond ((= length 1) 6566 (compile-forms-and-maybe-emit-clear-values (first args) 'stack nil) 6567 (emit-move-from-stack target representation)) 6568 ((>= 4 length 2) 6569 (cons-for-list* args target representation)) 6545 (cond ((>= 4 length 1) 6546 (cons-for-list/list* args target representation t)) 6570 6547 (t 6571 6548 (compile-function-call form target representation)))))
Note: See TracChangeset
for help on using the changeset viewer.