Changeset 11624


Ignore:
Timestamp:
02/04/09 22:22:29 (12 years ago)
Author:
ehuelsmann
Message:

Wider use of CONVERT-REPRESENTATION shows an issue: LispInteger?.getInstance() returns a LispInteger?.
Store Fixnum and Bignum values in fields of type LispInteger? to resolve it.

Additionally, simplify DECLARE-BIGNUM.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/compiler-pass2.lisp

    r11622 r11624  
    18931893
    18941894(defun make-constructor (super lambda-name args)
    1895   (let* ((*compiler-debug* nil) ; We don't normally need to see debugging output for constructors.
     1895  (let* ((*compiler-debug* nil)
     1896         ;; We don't normally need to see debugging output for constructors.
    18961897         (constructor (make-method :name "<init>"
    18971898                                   :descriptor "()V"))
     
    21702171         (if (minusp n) "MINUS_" "")
    21712172         (abs n)))
    2172      (declare-field g +lisp-fixnum+)
     2173     (declare-field g +lisp-integer+)
    21732174     (cond ((<= 0 n 255)
    21742175      (emit 'getstatic +lisp-fixnum-class+ "constants" +lisp-fixnum-array+)
     
    21782179      (emit-push-constant-int n)
    21792180            (convert-representation :int nil)))
    2180      (emit 'putstatic *this-class* g +lisp-fixnum+)
     2181     (emit 'putstatic *this-class* g +lisp-integer+)
    21812182     (setf *static-code* *code*)
    21822183     (setf (gethash n ht) g))))
     
    21862187  (declare-with-hashtable
    21872188   n *declared-integers* ht g
    2188    (cond ((<= most-negative-java-long n most-positive-java-long)
    2189     (let ((*code* *static-code*))
    2190       (setf g (format nil "BIGNUM_~A~D"
    2191           (if (minusp n) "MINUS_" "")
    2192           (abs n)))
    2193       (declare-field g +lisp-bignum+)
    2194       (emit 'new +lisp-bignum-class+)
    2195       (emit 'dup)
     2189   (setf g (concatenate 'string "BIGNUM_" (symbol-name (gensym))))
     2190   (let ((*code* *static-code*))
     2191     (declare-field g +lisp-integer+)
     2192     (emit 'new +lisp-bignum-class+)
     2193     (emit 'dup)
     2194     (cond ((<= most-negative-java-long n most-positive-java-long)
     2195;;      (setf g (format nil "BIGNUM_~A~D"
     2196;;          (if (minusp n) "MINUS_" "")
     2197;;          (abs n)))
    21962198      (emit 'ldc2_w (pool-long n))
    2197       (emit-invokespecial-init +lisp-bignum-class+ '("J"))
    2198       (emit 'putstatic *this-class* g +lisp-bignum+)
    2199       (setf *static-code* *code*)))
     2199      (emit-invokespecial-init +lisp-bignum-class+ '("J")))
    22002200   (t
    22012201    (let* ((*print-base* 10)
    2202      (s (with-output-to-string (stream) (dump-form n stream)))
    2203      (*code* *static-code*))
    2204       (setf g (concatenate 'string "BIGNUM_" (symbol-name (gensym))))
    2205       (declare-field g +lisp-bignum+)
    2206       (emit 'new +lisp-bignum-class+)
    2207       (emit 'dup)
     2202     (s (with-output-to-string (stream) (dump-form n stream))))
    22082203      (emit 'ldc (pool-string s))
    22092204      (emit-push-constant-int 10)
    2210       (emit-invokespecial-init +lisp-bignum-class+ (list +java-string+ "I"))
    2211       (emit 'putstatic *this-class* g +lisp-bignum+)
    2212       (setf *static-code* *code*))))
     2205      (emit-invokespecial-init +lisp-bignum-class+
     2206                                     (list +java-string+ "I")))))
     2207     (emit 'putstatic *this-class* g +lisp-integer+)
     2208     (setf *static-code* *code*))
    22132209   (setf (gethash n ht) g)))
    22142210
     
    23762372            (emit-push-constant-int form))
    23772373           ((integerp form)
    2378             (emit 'getstatic *this-class* (declare-bignum form) +lisp-bignum+)
     2374            (emit 'getstatic *this-class* (declare-bignum form) +lisp-integer+)
    23792375            (emit-invokevirtual +lisp-object-class+ "intValue" nil "I"))
    23802376           (t
     
    23872383            (emit-push-constant-long form))
    23882384           ((integerp form)
    2389             (emit 'getstatic *this-class* (declare-bignum form) +lisp-bignum+)
     2385            (emit 'getstatic *this-class* (declare-bignum form) +lisp-integer+)
    23902386            (emit-invokevirtual +lisp-object-class+ "longValue" nil "J"))
    23912387           (t
     
    24392435           (if translation
    24402436               (emit 'getstatic +lisp-fixnum-class+ translation +lisp-fixnum+)
    2441                (emit 'getstatic *this-class* (declare-fixnum form) +lisp-fixnum+))))
     2437               (emit 'getstatic *this-class* (declare-fixnum form)
     2438                     +lisp-integer+))))
    24422439        ((integerp form)
    24432440         ;; A bignum.
    2444          (emit 'getstatic *this-class* (declare-bignum form) +lisp-bignum+))
     2441         (emit 'getstatic *this-class* (declare-bignum form) +lisp-integer+))
    24452442        ((typep form 'single-float)
    24462443         (emit 'getstatic *this-class*
Note: See TracChangeset for help on using the changeset viewer.