@@ -74,18 +74,21 @@ require rtconstpool.fs
74
74
\ ========
75
75
\
76
76
\ *C jvm_class {
77
- \ ** addr rtcp; \ runtime constant pool
78
- \ ** wid fd_idx; \ static field index wordlist
79
- \ ** addr fd_table; \ static field table
77
+ \ ** addr status; \ status of the class
78
+ \ ** addr init_loader; \ initial loader
79
+ \ ** addr rtcp; \ runtime constant pool
80
+ \ ** addr super; \ link to super class
81
+ \ ** wid filed_offset; \ static field offset wordlist
82
+ \ ** addr field_table; \ static field table
80
83
\ ** }
81
84
\
82
85
83
86
0 cells constant jvm_class.status
84
87
1 cells constant jvm_class.init_loader
85
88
2 cells constant jvm_class.rtcp
86
89
3 cells constant jvm_class.super
87
- 4 cells constant jvm_class.fd_idx
88
- 5 cells constant jvm_class.fd_table
90
+ 4 cells constant jvm_class.field_offset
91
+ 5 cells constant jvm_class.field_table
89
92
90
93
6 cells constant jvm_class.size()
91
94
@@ -112,58 +115,58 @@ require rtconstpool.fs
112
115
\ *G get the address of the super class
113
116
jvm_class.super + @
114
117
;
115
- \ FIXME change idx to offset!
116
- : jvm_class.getFd_idx_wid () ( addr -- wid )
117
- \ *G get the wordlist id for the static field index translation
118
- jvm_class.fd_idx + @
118
+
119
+ : jvm_class.getField_offset_wid () ( addr -- wid )
120
+ \ *G get the wordlist id for the static field offset translation
121
+ jvm_class.field_offset + @
119
122
;
120
123
121
- : jvm_class.getFd_idx () { addr c-addr n -- idx woir }
122
- \ *G get the index of a static field
123
- addr jvm_class.getFd_idx_wid ()
124
+ : jvm_class.getField_offset () { addr c-addr n -- off woir }
125
+ \ *G get the offset of a static field
126
+ addr jvm_class.getField_offset_wid ()
124
127
c-addr n rot
125
128
jvm_find_word throw
126
129
0
127
130
;
128
131
129
- : jvm_class.getStaticIdx () { addr idx -- value }
130
- \ *G get the value of a static field (32bit) by index
131
- addr jvm_class.fd_table + idx cells + jvm_field_@
132
+ : jvm_class.getStaticOffset () { addr off -- value }
133
+ \ *G get the value of a static field (32bit) by offset
134
+ addr jvm_class.field_table + off cells + jvm_field_@
132
135
;
133
136
134
137
: jvm_class.getStatic() { addr c-addr n -- value woir }
135
138
\ *G get the value of a static field (32bit) by name
136
139
\ ." trying to get " c-addr n type CR
137
- addr c-addr n jvm_class.getFd_idx () throw
138
- \ ." index : " dup . CR
139
- addr swap jvm_class.getStaticIdx () 0
140
+ addr c-addr n jvm_class.getField_offset () throw
141
+ \ ." offset : " dup . CR
142
+ addr swap jvm_class.getStaticOffset () 0
140
143
;
141
144
142
- : jvm_class.setStaticIdx () { addr val idx -- }
143
- \ *G set the value of a static field (32bit) by index
144
- val addr jvm_class.fd_table + idx cells +
145
+ : jvm_class.setStaticOffset () { addr val off -- }
146
+ \ *G set the value of a static field (32bit) by offset
147
+ val addr jvm_class.field_table + off cells +
145
148
jvm_field_!
146
149
;
147
150
148
151
: jvm_class.setStatic() { addr val c-addr n -- woir }
149
152
\ *G get the value of a static field (32bit) by name
150
153
\ ." trying to set " c-addr n type ." to " val . CR
151
154
addr val
152
- over c-addr n jvm_class.getFd_idx () throw \ get idx
153
- \ ." index : " dup . CR
154
- jvm_class.setStaticIdx ()
155
+ over c-addr n jvm_class.getField_offset () throw \ get off
156
+ \ ." offset : " dup . CR
157
+ jvm_class.setStaticOffset ()
155
158
0
156
159
;
157
160
158
- : jvm_class.getStatic2Idx () { addr idx -- lsb-value msb-value }
159
- \ *G get the value of a static field (64bit) by index
160
- addr jvm_class.fd_table + idx cells + jvm_field_2@
161
+ : jvm_class.getStatic2Offset () { addr off -- lsb-value msb-value }
162
+ \ *G get the value of a static field (64bit) by offset
163
+ addr jvm_class.field_table + off cells + jvm_field_2@
161
164
;
162
165
163
166
: jvm_class.getStatic2() { addr c-addr n -- lsb-value msb-value wior }
164
167
\ *G get the value of a static field (64bit) by name
165
- addr c-addr n jvm_class.getFd_idx () throw
166
- addr swap jvm_class.getStatic2Idx () 0
168
+ addr c-addr n jvm_class.getField_offset () throw
169
+ addr swap jvm_class.getStatic2Offset () 0
167
170
;
168
171
169
172
: jvm_class.new() ( -- addr)
@@ -173,8 +176,8 @@ require rtconstpool.fs
173
176
jvm_class.STATUS:UNINIT over ( jvm_class.status + ) !
174
177
\ 0 over jvm_class.init_loader + !
175
178
\ 0 over jvm_class.rtcp + !
176
- wordlist over jvm_class.fd_idx + !
177
- \ 0 over jvm_class.fd_table + !
179
+ wordlist over jvm_class.field_offset + !
180
+ \ 0 over jvm_class.field_table + !
178
181
;
179
182
180
183
: jvm_class.prepare() { addr_cl loader addr_cf -- wior }
@@ -190,28 +193,28 @@ require rtconstpool.fs
190
193
addr_cf jvm_cf_fields_addr
191
194
addr_cf jvm_cf_fields_count
192
195
0 ?DO
193
- ( idx addr )
194
- \ idx next free index of the table
196
+ ( off addr )
197
+ \ off next free offset of the table
195
198
\ addr address of the field entry
196
199
dup ACC_STATIC jvm_fd_?flags IF
197
200
addr_cf over jvm_fd_identifier
198
- ( idx addr c-addr n )
201
+ ( off addr c-addr n )
199
202
addr_cf jvm_cf_constpool_addr
200
- ( idx addr c-addr n addr2 )
203
+ ( off addr c-addr n addr2 )
201
204
3 pick jvm_fd_desc_idx
202
- ( idx addr c-addr n addr2 idx2 )
205
+ ( off addr c-addr n addr2 idx2 )
203
206
jvm_constpool_idx
204
- ( idx addr c-addr n addr3 )
207
+ ( off addr c-addr n addr3 )
205
208
jvm_cp_utf8_c-ref
206
- ( idx addr c-addr n c-addr2 n2 )
209
+ ( off addr c-addr n c-addr2 n2 )
207
210
jvm_field_desc_size -rot
208
- ( idx addr size c-addr n )
211
+ ( off addr size c-addr n )
209
212
4 pick -rot
210
- ( idx addr size idx c-addr n )
211
- addr_cl jvm_class.getFd_idx_wid ()
212
- ( idx addr size idx c-addr n wid )
213
+ ( off addr size off c-addr n )
214
+ addr_cl jvm_class.getField_offset_wid ()
215
+ ( off addr size off c-addr n wid )
213
216
jvm_add_word
214
- ( idx addr size )
217
+ ( off addr size )
215
218
rot + swap
216
219
ENDIF
217
220
@@ -222,7 +225,7 @@ require rtconstpool.fs
222
225
allocate throw \ allocate static table memory
223
226
\ TODO Initial values §5.4.2, 1st paragraph
224
227
225
- addr_cl jvm_class.fd_table + ! \ store table
228
+ addr_cl jvm_class.field_table + ! \ store table
226
229
227
230
jvm_class.STATUS:PREPARED addr_cl jvm_class.status + ! \ store status
228
231
loader addr_cl jvm_class.init_loader + ! \ store loader
0 commit comments