Changeset 12769
- Timestamp:
- 06/27/10 19:48:41 (13 years ago)
- Location:
- branches/generic-class-file/abcl
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/generic-class-file/abcl/README.BRANCH
r12767 r12769 39 39 ====== 40 40 41 The code uses structures and structure inclusion for the class file and 42 class file attributes. Each attribute type has an associated specific 43 finalizer and writer function. This should allow for future ease of 44 extension. 41 45 46 There are three phases in the design. Read about that in the file itself. 47 48 Structure inclusion is used as a means of single inheritance. 42 49 43 50 -
branches/generic-class-file/abcl/src/org/armedbear/lisp/jvm-class-file.lisp
-
Property
svn:eol-style
set to
native
-
Property
svn:keywords
set to
Id
r12767 r12769 2 2 ;;; 3 3 ;;; Copyright (C) 2010 Erik Huelsmann 4 ;;; $Id : compiler-pass2.lisp 12311 2009-12-28 23:11:35Z ehuelsmann$4 ;;; $Id$ 5 5 ;;; 6 6 ;;; This program is free software; you can redistribute it and/or … … 60 60 (defun map-primitive-type (type) 61 61 (case type 62 (:int "I")63 (:long "J")64 (:float "F")65 (:double "D")66 (:boolean "Z")67 (:char "C")68 (:byte "B")69 (:short "S")70 ( :void"V")))62 (:int "I") 63 (:long "J") 64 (:float "F") 65 (:double "D") 66 (:boolean "Z") 67 (:char "C") 68 (:byte "B") 69 (:short "S") 70 ((nil :void) "V"))) 71 71 72 72 … … 139 139 140 140 141 (defun descriptor (method-name return-type &rest argument-types)142 ( format nil "~A(~{~A~}~A)" method-name143 (mapcar #'(lambda (arg-type)144 (if (keywordp arg-type)145 (map-primitive-type arg-type) 146 (class-ref arg-type)))147 argument-types)148 (if (keywordp return-type)149 (map-primitive-type return-type)150 (class-name-internal return-type)))) 151 152 153 141 (defun internal-field-type (field-type) 142 (if (keywordp field-type) 143 (map-primitive-type field-type) 144 (class-name-internal field-type))) 145 146 (defun internal-field-ref (field-type) 147 (if (keywordp field-type) 148 (map-primitive-type field-type) 149 (class-ref field-type))) 150 151 (defun descriptor (return-type &rest argument-types) 152 (format nil "(~{~A~}~A)" (mapcar #'internal-field-ref argument-types) 153 (internal-field-type return-type))) 154 154 155 155 156 156 (defstruct pool 157 (count 1) ;; #### why count 1??? 157 (count 1) ;; "A constant pool entry is considered valid if it has 158 ;; an index greater than 0 (zero) and less than pool-count" 158 159 entries-list 160 ;; the entries hash stores raw values, except in case of string and 161 ;; utf8, because both are string values 159 162 (entries (make-hash-table :test #'equal :size 2048 :rehash-size 2.0))) 160 163 … … 184 187 name/type) 185 188 186 (defstruct (constant-string (:constructor make-constant-string (value-index)) 189 (defstruct (constant-string (:constructor make-constant-string 190 (index value-index)) 187 191 (:include constant 188 192 (tag 8))) … … 199 203 descriptor-index) 200 204 201 (defstruct (constant-utf8 (:include constant)) 205 (defstruct (constant-utf8 (:constructor make-constant-utf8 (index value)) 206 (:include constant 207 (tag 11))) 202 208 value) 203 209 204 210 205 ;; Need to add pool/constant creation addition routines here;206 ;; all routines have 2 branches: return existing or push new.207 208 211 (defun pool-add-string (pool string) 209 (let ((entry (gethash (pool-entries string)))) 212 (let ((entry (gethash (cons 8 string) ;; 8 == string-tag 213 (pool-entries pool)))) 210 214 (unless entry 211 (setf entry (make-constant-string (pool-count pool) string)) 212 (push entry (pool-entries-list pool)) 213 (incf (pool-count pool))) 215 (setf entry (make-constant-string (pool-add-utf8 pool string)) 216 (gethash (cons 8 string) (pool-entries pool)) entry) 217 (incf (pool-count pool)) 218 (push entry (pool-entries-list pool))) 214 219 (constant-index entry))) 215 220 216 221 (defun pool-add-utf8 (pool utf8-as-string) 222 (let ((entry (gethash (cons 11 utf8-as-string) ;; 11 == utf8 223 (pool-entries pool)))) 224 (unless entry 225 (setf entry (make-constant-utf8 (pool-count pool) utf8-as-string) 226 (gethash (cons 11 utf8-as-string) (pool-entries pool)) entry) 227 (incf (pool-count pool)) 228 (push entry (pool-entries-list pool))) 229 (constant-index entry))) 217 230 218 231 (defstruct (class-file (:constructor %make-class-file)) … … 417 430 418 431 (defun finalize-method (method class) 419 (declare (ignore method class)) 420 (error "Not implemented")) 432 (setf (method-access-flags method) 433 (map-flags (method-access-flags method)) 434 (method-descriptor method) 435 (pool-add-utf8 (apply #'descriptor (method-descriptor method))) 436 (method-name method) 437 (pool-add-utf8 (map-method-name (method-name method)))) 438 (finalize-attributes attributes nil class)) 421 439 422 440 -
Property
svn:eol-style
set to
Note: See TracChangeset
for help on using the changeset viewer.