Changeset 12895
- Timestamp:
- 08/13/10 21:10:39 (13 years ago)
- Location:
- branches/generic-class-file/abcl/src/org/armedbear/lisp
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/generic-class-file/abcl/src/org/armedbear/lisp/compiler-pass2.lisp
r12894 r12895 797 797 (let* ((*compiler-debug* nil) 798 798 ;; We don't normally need to see debugging output for constructors. 799 (method ( !make-method :constructor :void nil799 (method (make-method :constructor :void nil 800 800 :flags '(:public))) 801 801 (code (method-add-code method)) … … 3809 3809 (defmacro with-temp-class-file (pathname class-file lambda-list &body body) 3810 3810 `(let* ((,pathname (make-temp-file)) 3811 (,class-file (make- class-file :pathname ,pathname3811 (,class-file (make-abcl-class-file :pathname ,pathname 3812 3812 :lambda-list ,lambda-list))) 3813 3813 (unwind-protect … … 3821 3821 (cond (*file-compilation* 3822 3822 (let* ((pathname (funcall *pathnames-generator*)) 3823 (class-file (make- class-file :pathname pathname3823 (class-file (make-abcl-class-file :pathname pathname 3824 3824 :lambda-list lambda-list))) 3825 3825 (with-open-class-file (f class-file) … … 3827 3827 (setf (local-function-class-file local-function) class-file))) 3828 3828 (t 3829 (let ((class-file (make- class-file :lambda-list lambda-list)))3829 (let ((class-file (make-abcl-class-file :lambda-list lambda-list))) 3830 3830 (with-open-stream (stream (sys::%make-byte-array-output-stream)) 3831 3831 (set-compiland-and-write-class class-file compiland stream) … … 3855 3855 (cond (*file-compilation* 3856 3856 (let* ((pathname (funcall *pathnames-generator*)) 3857 (class-file (make- class-file :pathname pathname3858 :lambda-list lambda-list)))3857 (class-file (make-abcl-class-file :pathname pathname 3858 :lambda-list lambda-list))) 3859 3859 (with-open-class-file (f class-file) 3860 3860 (set-compiland-and-write-class class-file compiland f)) … … 3864 3864 local-function compiland g)))) 3865 3865 (t 3866 (let ((class-file (make- class-file :lambda-list lambda-list)))3866 (let ((class-file (make-abcl-class-file :lambda-list lambda-list))) 3867 3867 (with-open-stream (stream (sys::%make-byte-array-output-stream)) 3868 3868 (set-compiland-and-write-class class-file compiland stream) … … 3917 3917 (cond (*file-compilation* 3918 3918 (setf (compiland-class-file compiland) 3919 (make- class-file :pathname (funcall *pathnames-generator*)3920 :lambda-list lambda-list))3919 (make-abcl-class-file :pathname (funcall *pathnames-generator*) 3920 :lambda-list lambda-list)) 3921 3921 (let ((class-file (compiland-class-file compiland))) 3922 3922 (with-open-class-file (f class-file) … … 3928 3928 (t 3929 3929 (setf (compiland-class-file compiland) 3930 (make- class-file :lambda-list lambda-list))3930 (make-abcl-class-file :lambda-list lambda-list)) 3931 3931 (with-open-stream (stream (sys::%make-byte-array-output-stream)) 3932 3932 (compile-and-write-to-stream (compiland-class-file compiland) … … 6851 6851 ;; methods 6852 6852 (dolist (method (abcl-class-file-methods class-file)) 6853 ( !write-method method stream))6853 (write-method method stream)) 6854 6854 ;; attributes count 6855 6855 (cond (*file-compilation* … … 6926 6926 6927 6927 (arg-types (analyze-args compiland)) 6928 (method ( !make-method "execute" +lisp-object+ arg-types6928 (method (make-method "execute" +lisp-object+ arg-types 6929 6929 :flags '(:final :public))) 6930 6930 (code (method-add-code method)) … … 7112 7112 (astore (compiland-argument-register compiland))) 7113 7113 7114 (maybe-initialize-thread-var) 7114 (unless (and *hairy-arglist-p* 7115 (or (memq '&OPTIONAL args) (memq '&KEY args))) 7116 (maybe-initialize-thread-var)) 7115 7117 (setf *code* (nconc code *code*))) 7116 7118 … … 7181 7183 (aver (eq (car form) 'LAMBDA)) 7182 7184 (catch 'compile-defun-abort 7183 (let* ((class-file (make- class-file :pathname filespec7184 :lambda-name name7185 :lambda-list (cadr form)))7185 (let* ((class-file (make-abcl-class-file :pathname filespec 7186 :lambda-name name 7187 :lambda-list (cadr form))) 7186 7188 (*compiler-error-bailout* 7187 7189 `(lambda () 7188 (compile-1 (make-compiland :name ',name 7189 :lambda-expression (make-compiler-error-form ',form) 7190 :class-file 7191 (make-class-file :pathname ,filespec 7192 :lambda-name ',name 7193 :lambda-list (cadr ',form))) 7194 ,stream))) 7190 (compile-1 7191 (make-compiland :name ',name 7192 :lambda-expression (make-compiler-error-form ',form) 7193 :class-file 7194 (make-abcl-class-file :pathname ,filespec 7195 :lambda-name ',name 7196 :lambda-list (cadr ',form))) 7197 ,stream))) 7195 7198 (*compile-file-environment* environment)) 7196 7197 7198 7199 7200 7201 7199 (compile-1 (make-compiland :name name 7200 :lambda-expression 7201 (precompiler:precompile-form form t 7202 environment) 7203 :class-file class-file) 7204 stream)))) 7202 7205 7203 7206 (defvar *catch-errors* t) -
branches/generic-class-file/abcl/src/org/armedbear/lisp/jvm-class-file.lisp
r12886 r12895 504 504 505 505 (defstruct (class-file (:constructor 506 !make-class-file (class superclass access-flags)))506 make-class-file (class superclass access-flags))) 507 507 "Holds the components of a class file." 508 508 (constants (make-pool)) … … 534 534 "Returns all methods which have `name'." 535 535 (remove name (class-file-methods class) 536 :test-not #'string= :key #' !method-name))536 :test-not #'string= :key #'method-name)) 537 537 538 538 (defun class-method (class name return &rest args) … … 540 540 (let ((return-and-args (cons return args))) 541 541 (find-if #'(lambda (c) 542 (and (string= ( !method-name c) name)543 (equal ( !method-descriptor c) return-and-args)))542 (and (string= (method-name c) name) 543 (equal (method-descriptor c) return-and-args))) 544 544 (class-file-methods class)))) 545 545 … … 674 674 ;; flags 675 675 (write-u2 (class-file-access-flags class) stream) 676 676 677 ;; class name 677 678 678 (write-u2 (class-file-class class) stream) 679 679 680 ;; superclass 680 681 (write-u2 (class-file-superclass class) stream) … … 691 692 (write-u2 (length (class-file-methods class)) stream) 692 693 (dolist (method (class-file-methods class)) 693 ( !write-method method stream))694 (write-method method stream)) 694 695 695 696 ;; attributes … … 832 833 833 834 834 (defstruct (method (:constructor % !make-method)835 (:conc-name !method-))835 (defstruct (method (:constructor %make-method) 836 (:conc-name method-)) 836 837 "Holds information on the properties of methods in the class(-file)." 837 838 access-flags … … 855 856 (t name))) 856 857 857 (defun !make-method (name return args &key (flags '(:public)))858 (defun make-method (name return args &key (flags '(:public))) 858 859 "Creates a method for addition to a class file." 859 (% !make-method :descriptor (cons return args)860 (%make-method :descriptor (cons return args) 860 861 :access-flags flags 861 862 :name name)) … … 864 865 "Add `attribute' to the list of attributes of `method', 865 866 returning `attribute'." 866 (push attribute ( !method-attributes method))867 (push attribute (method-attributes method)) 867 868 attribute) 868 869 … … 872 873 (method-add-attribute 873 874 method 874 (make-code-attribute (+ (length (cdr ( !method-descriptor method)))875 (if (member :static ( !method-access-flags method))875 (make-code-attribute (+ (length (cdr (method-descriptor method))) 876 (if (member :static (method-access-flags method)) 876 877 0 1))))) ;; 1 == implicit 'this' 877 878 … … 886 887 (defun method-attribute (method name) 887 888 "Returns the first attribute of `method' with `name'." 888 (find name ( !method-attributes method)889 (find name (method-attributes method) 889 890 :test #'string= :key #'attribute-name)) 890 891 … … 893 894 "Prepares `method' for serialization." 894 895 (let ((pool (class-file-constants class))) 895 (setf ( !method-access-flags method)896 (map-flags ( !method-access-flags method))897 ( !method-descriptor method)898 (pool-add-utf8 pool (apply #'descriptor ( !method-descriptor method)))899 ( !method-name method)900 (pool-add-utf8 pool (map-method-name ( !method-name method)))))901 (finalize-attributes ( !method-attributes method) nil class))902 903 904 (defun !write-method (method stream)896 (setf (method-access-flags method) 897 (map-flags (method-access-flags method)) 898 (method-descriptor method) 899 (pool-add-utf8 pool (apply #'descriptor (method-descriptor method))) 900 (method-name method) 901 (pool-add-utf8 pool (map-method-name (method-name method))))) 902 (finalize-attributes (method-attributes method) nil class)) 903 904 905 (defun write-method (method stream) 905 906 "Write class file representation of `method' to `stream'." 906 (write-u2 ( !method-access-flags method) stream)907 (write-u2 ( !method-name method) stream)908 ;;(sys::%format t "method-name: ~a~%" ( !method-name method))909 (write-u2 ( !method-descriptor method) stream)910 (write-attributes ( !method-attributes method) stream))907 (write-u2 (method-access-flags method) stream) 908 (write-u2 (method-name method) stream) 909 ;;(sys::%format t "method-name: ~a~%" (method-name method)) 910 (write-u2 (method-descriptor method) stream) 911 (write-attributes (method-attributes method) stream)) 911 912 912 913 (defstruct attribute … … 951 952 (:include attribute 952 953 (name "Code") 953 (finalizer #' !finalize-code)954 (writer #' !write-code))954 (finalizer #'finalize-code-attribute) 955 (writer #'write-code-attribute)) 955 956 (:constructor %make-code-attribute)) 956 957 "The attribute containing the actual JVM byte code; … … 982 983 (acons label offset (code-labels code)))) 983 984 984 (defun !finalize-code (code parent class)985 (defun finalize-code-attribute (code parent class) 985 986 "Prepares the `code' attribute for serialization, within method `parent'." 986 987 (declare (ignore parent)) … … 1000 1001 (code-labels code) labels))) 1001 1002 1003 (setf (code-exception-handlers code) 1004 (remove-if #'(lambda (h) 1005 (eql (code-label-offset code (exception-start-pc h)) 1006 (code-label-offset code (exception-end-pc h)))) 1007 (code-exception-handlers code))) 1008 1002 1009 (dolist (exception (code-exception-handlers code)) 1003 1010 (setf (exception-start-pc exception) … … 1015 1022 (finalize-attributes (code-attributes code) code class)) 1016 1023 1017 (defun !write-code (code stream)1024 (defun write-code-attribute (code stream) 1018 1025 "Writes the attribute `code' to `stream'." 1019 1026 ;;(sys::%format t "max-stack: ~a~%" (code-max-stack code)) … … 1086 1093 1087 1094 " 1088 1095 ;;; ### TODO 1089 1096 ) 1090 1097 … … 1130 1137 (setf (code-code code) *code* 1131 1138 (code-max-locals code) *registers-allocated* 1132 ;; (code-exception-handlers code) *handlers*1133 1139 (code-current-local code) *register*)) 1134 1140 1135 1141 (defun restore-code-specials (code) 1136 1142 (setf *code* (code-code code) 1137 ;; *handlers* (code-exception-handlers code)1138 1143 *registers-allocated* (code-max-locals code) 1139 1144 *register* (code-current-local code))) -
branches/generic-class-file/abcl/src/org/armedbear/lisp/jvm.lisp
r12894 r12895 151 151 "java.util.UUID")))))) 152 152 153 (defun make- class-file (&key pathname lambda-name lambda-list)153 (defun make-abcl-class-file (&key pathname lambda-name lambda-list) 154 154 "Creates a `class-file' structure. If `pathname' is non-NIL, it's 155 155 used to derive a class name. If it is NIL, a random one created
Note: See TracChangeset
for help on using the changeset viewer.