Changeset 12850


Ignore:
Timestamp:
08/02/10 06:41:33 (12 years ago)
Author:
ehuelsmann
Message:

Continue CLASS-NAME integration, define a solution for arrays.

Location:
branches/generic-class-file/abcl/src/org/armedbear/lisp
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/generic-class-file/abcl/src/org/armedbear/lisp/compiler-pass2.lisp

    r12846 r12850  
    211211      (code-add-exception-handler *current-code-attribute*
    212212                                  start end handler type)))
    213 
    214 
    215 (defconstant +lisp-object-array+ "[Lorg/armedbear/lisp/LispObject;")
    216 (defconstant +closure-binding-array+ "[Lorg/armedbear/lisp/ClosureBinding;")
    217 (defconstant +lisp-fixnum-array+ "[Lorg/armedbear/lisp/Fixnum;")
    218 (defconstant +lisp-character-array+ "[Lorg/armedbear/lisp/LispCharacter;")
    219 (defconstant +lisp-closure-parameter-array+ "[Lorg/armedbear/lisp/Closure$Parameter;")
    220213
    221214(defun !class-name (class-name)
  • branches/generic-class-file/abcl/src/org/armedbear/lisp/jvm-class-file.lisp

    r12846 r12850  
    8383(defstruct (class-name (:conc-name class-)
    8484                       (:constructor %make-class-name))
     85  "Used for class identification.
     86
     87The caller should instantiate only one `class-name' per class, as they are
     88used as class identifiers and compared using EQ.
     89
     90Some instructions need a class argument, others need a reference identifier.
     91This class is used to abstract from the difference."
    8592  name-internal
    8693  ref
    87   array-ref)
     94  array-class ;; cached array class reference
     95  ;; keeping a reference to the associated array class allows class
     96  ;; name comparisons to be EQ: all classes should exist only once,
     97  )
    8898
    8999(defun make-class-name (name)
     
    94104  (setf name (substitute #\/ #\. name))
    95105  (%make-class-name :name-internal name
    96                     :ref (concatenate 'string "L" name ";")
    97                     :array-ref (concatenate 'string "[L" name ";")))
     106                    :ref (concatenate 'string "L" name ";")))
     107
     108(defun class-array (class-name)
     109  "Returns a class-name representing an array of `class-name'.
     110For multi-dimensional arrays, call this function multiple times, using
     111its own result.
     112
     113This function can be called multiple times on the same `class-name' without
     114violating the 'only one instance' requirement: the returned value is cached
     115and used on successive calls."
     116  (unless (class-array-class class-name)
     117    ;; Alessio Stalla found by dumping a class file that the JVM uses
     118    ;; the same representation (ie '[L<class-name>;') in CHECKCAST as
     119    ;; it does in field references, meaning the class name and class ref
     120    ;; are identified by the same string
     121    (let ((name-and-ref (concatenate 'string "[" (class-ref class-name))))
     122      (setf (class-array-class class-name)
     123            (%make-class-name :name-internal name-and-ref
     124                              :ref name-and-ref))))
     125  (class-array-class class-name))
    98126
    99127(defmacro define-class-name (symbol java-dotted-name &optional documentation)
     
    106134(define-class-name +java-string+ "java.lang.String")
    107135(define-class-name +lisp-object+ "org.armedbear.lisp.LispObject")
     136(defconstant +lisp-object-array+ (class-array +lisp-object+))
    108137(define-class-name +lisp-simple-string+ "org.armedbear.lisp.SimpleString")
    109138(define-class-name +lisp+ "org.armedbear.lisp.Lisp")
     
    113142(define-class-name +lisp-thread+ "org.armedbear.lisp.LispThread")
    114143(define-class-name +lisp-closure-binding+ "org.armedbear.lisp.ClosureBinding")
     144(defconstant +closure-binding-array+ (class-array +lisp-closure-binding+))
    115145(define-class-name +lisp-integer+ "org.armedbear.lisp.LispInteger")
    116146(define-class-name +lisp-fixnum+ "org.armedbear.lisp.Fixnum")
     147(defconstant +lisp-fixnum-array+ (class-array +lisp-fixnum+))
    117148(define-class-name +lisp-bignum+ "org.armedbear.lisp.Bignum")
    118149(define-class-name +lisp-single-float+ "org.armedbear.lisp.SingleFloat")
     
    121152(define-class-name +lisp-load+ "org.armedbear.lisp.Load")
    122153(define-class-name +lisp-character+ "org.armedbear.lisp.LispCharacter")
     154(defconstant +lisp-character-array+ (class-array +lisp-character+))
    123155(define-class-name +lisp-structure-object+ "org.armedbear.lisp.StructureObject")
    124156(define-class-name +lisp-simple-vector+ "org.armedbear.lisp.SimpleVector")
     
    144176(define-class-name +lisp-closure-parameter+
    145177    "org.armedbear.lisp.Closure$Parameter")
    146 (define-class-name +!fasl-loader+ "org.armedbear.lisp.FaslClassLoader")
     178(defconstant +lisp-closure-parameter-array+
     179  (class-array +lisp-closure-parameter+))
    147180
    148181#|
Note: See TracChangeset for help on using the changeset viewer.