Changeset 12862
- Timestamp:
- 08/05/10 20:20:18 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/generic-class-file/abcl/src/org/armedbear/lisp/jvm-class-file.lisp
r12861 r12862 1022 1022 1023 1023 1024 ;; ### Can't be used yet: no serialization1025 1024 (defstruct (source-file-attribute (:conc-name source-) 1026 1025 (:include attribute 1027 (name "SourceFile"))) 1026 (name "SourceFile") 1027 (finalizer #'finalize-source-file) 1028 (writer #'write-source-file))) 1028 1029 "An attribute of the class file indicating which source file 1029 1030 it was compiled from." 1030 1031 filename) 1031 1032 1032 ;; ### Can't be used yet: no serialization 1033 (defstruct (line-numbers-attribute (:include attribute 1034 (name "LineNumberTable"))) 1033 (defun finalize-source-file (source-file code class) 1034 (declare (ignorable code class)) 1035 (setf (source-filename source-file) 1036 (pool-add-utf8 (class-file-constants class) 1037 (source-filename source-file)))) 1038 1039 (defun write-source-file (source-file stream) 1040 (write-u2 (source-filename source-file) stream)) 1041 1042 1043 1044 (defstruct (line-numbers-attribute 1045 (:conc-name line-numbers-) 1046 (:include attribute 1047 (name "LineNumberTable") 1048 (finalizer #'finalize-line-numbers) 1049 (writer #'write-line-numbers))) 1035 1050 "An attribute of `code-attribute', containing a mapping of offsets 1036 1051 within the code section to the line numbers in the source file." 1037 line-numbers;; a list of line-number structures, in reverse order1052 table ;; a list of line-number structures, in reverse order 1038 1053 ) 1039 1054 … … 1042 1057 line) 1043 1058 1044 ;; ### Can't be used yet: no serialization 1045 (defstruct (local-variables-attribute (:conc-name local-var-) 1046 (:include attribute 1047 (name "LocalVariableTable"))) 1059 (defun finalize-line-numbers (line-numbers code class) 1060 (declare (ignorable code class)) 1061 (dolist (line-number (line-numbers-table line-numbers)) 1062 (setf (line-number-start-pc line-number) 1063 (code-label-offset code (line-number-start-pc line-number))))) 1064 1065 (defun write-line-numbers (line-numbers stream) 1066 (write-u2 (length (line-numbers-table line-numbers)) stream) 1067 (dolist (line-number (reverse (line-numbers-table line-numbers))) 1068 (write-u2 (line-number-start-pc line-number) stream) 1069 (write-u2 (line-number-line line-number) stream))) 1070 1071 1072 1073 (defstruct (local-variables-attribute 1074 (:conc-name local-var-) 1075 (:include attribute 1076 (name "LocalVariableTable") 1077 (finalizer #'finalize-local-variables) 1078 (writer #'write-local-variables))) 1048 1079 "An attribute of the `code-attribute', containing a table of local variable 1049 1080 names, their type and their scope of validity." 1050 locals;; a list of local-variable structures, in reverse order1081 table ;; a list of local-variable structures, in reverse order 1051 1082 ) 1052 1083 1053 1084 (defstruct (local-variable (:conc-name local-)) 1054 1085 start-pc ;; a label, before finalization 1055 length 1086 length ;; a label (at the ending position) before finalization 1056 1087 name 1057 1088 descriptor 1058 1089 index ;; The index of the variable inside the block of locals 1059 1090 ) 1091 1092 (defun finalize-local-variables (local-variables code class) 1093 (dolist (local-variable (local-var-table local-variables)) 1094 (setf (local-start-pc local-variable) 1095 (code-label-offset code (local-start-pc local-variable)) 1096 (local-length local-variable) 1097 ;; calculate 'length' from the distance between 2 labels 1098 (- (code-label-offset code (local-length local-variable)) 1099 (local-start-pc local-variable)) 1100 (local-name local-variable) 1101 (pool-add-utf8 (class-file-constants class) 1102 (local-name local-variable)) 1103 (local-descriptor local-variable) 1104 (pool-add-utf8 (class-file-constants class) 1105 (local-descriptor local-variable))))) 1106 1107 (defun write-local-variables (local-variables stream) 1108 (write-u2 (length (local-var-table local-variables)) stream) 1109 (dolist (local-variable (reverse (local-var-table local-variables))) 1110 (write-u2 (local-start-pc local-variable) stream) 1111 (write-u2 (local-length local-variable) stream) 1112 (write-u2 (local-name local-variable) stream) 1113 (write-u2 (local-descriptor local-variable) stream) 1114 (write-u2 (local-index local-variable) stream))) 1060 1115 1061 1116 #|
Note: See TracChangeset
for help on using the changeset viewer.