author | hlopkmar |
Wed, 07 Dec 2011 20:37:12 +0000 | |
branch | jk_new_structure |
changeset 1239 | 9e302ab52dc2 |
parent 1234 | 6ddf1122f94b |
child 1240 | aea022b94a34 |
permissions | -rw-r--r-- |
877 | 1 |
" |
2 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger |
|
1152 | 3 |
|
1155 | 4 |
New code and modifications done at SWING Research Group [1]: |
1152 | 5 |
|
877 | 6 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko |
7 |
SWING Research Group, Czech Technical University in Prague |
|
8 |
||
9 |
This software is furnished under a license and may be used |
|
10 |
only in accordance with the terms of that license and with the |
|
11 |
inclusion of the above copyright notice. This software may not |
|
12 |
be provided or otherwise made available to, or used by, any |
|
13 |
other person. No title to or ownership of the software is |
|
14 |
hereby transferred. |
|
15 |
||
1155 | 16 |
[1] Code written at SWING Research Group contains a signature |
17 |
of one of the above copright owners. For exact set of such code, |
|
18 |
see the differences between this version and version stx:libjava |
|
1152 | 19 |
as of 1.9.2010 |
877 | 20 |
" |
752 | 21 |
"{ Package: 'stx:libjava' }" |
22 |
||
23 |
JavaClassContentRef2 subclass:#JavaFieldRef2 |
|
792 | 24 |
instanceVariableNames:'offset type' |
25 |
classVariableNames:'T_LONG T_DOUBLE' |
|
752 | 26 |
poolDictionaries:'' |
27 |
category:'Languages-Java-Reader-Support-new' |
|
28 |
! |
|
29 |
||
877 | 30 |
!JavaFieldRef2 class methodsFor:'documentation'! |
31 |
||
32 |
copyright |
|
33 |
" |
|
34 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger |
|
1152 | 35 |
|
1155 | 36 |
New code and modifications done at SWING Research Group [1]: |
1152 | 37 |
|
877 | 38 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko |
39 |
SWING Research Group, Czech Technical University in Prague |
|
40 |
||
41 |
This software is furnished under a license and may be used |
|
42 |
only in accordance with the terms of that license and with the |
|
43 |
inclusion of the above copyright notice. This software may not |
|
44 |
be provided or otherwise made available to, or used by, any |
|
45 |
other person. No title to or ownership of the software is |
|
46 |
hereby transferred. |
|
47 |
||
1155 | 48 |
[1] Code written at SWING Research Group contains a signature |
49 |
of one of the above copright owners. For exact set of such code, |
|
50 |
see the differences between this version and version stx:libjava |
|
1152 | 51 |
as of 1.9.2010 |
877 | 52 |
|
53 |
" |
|
54 |
! ! |
|
752 | 55 |
|
792 | 56 |
!JavaFieldRef2 class methodsFor:'initialization'! |
57 |
||
58 |
initialize |
|
59 |
T_LONG := 1. |
|
60 |
T_DOUBLE := 2. |
|
61 |
||
62 |
"Created: / 15-05-2011 / 22:31:19 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
63 |
! ! |
|
64 |
||
761 | 65 |
!JavaFieldRef2 methodsFor:'accessing'! |
66 |
||
67 |
isJavaFieldRef |
|
68 |
^true. |
|
69 |
||
70 |
"Created: / 11-04-2011 / 21:47:51 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
791 | 71 |
! |
72 |
||
73 |
offset |
|
74 |
^ offset. |
|
75 |
||
76 |
"Created: / 15-05-2011 / 22:26:08 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
792 | 77 |
! |
78 |
||
79 |
type |
|
80 |
type == T_LONG ifTrue: [ ^ #long. ]. |
|
81 |
type == T_DOUBLE ifTrue: [ ^ #double ]. |
|
82 |
^ type. |
|
83 |
||
84 |
"Created: / 15-05-2011 / 22:29:05 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
761 | 85 |
! ! |
86 |
||
758 | 87 |
!JavaFieldRef2 methodsFor:'private - resolving'! |
88 |
||
1234 | 89 |
findInstOffset |
90 |
"fieldRef must be resolved before calling me" |
|
91 |
self assert: classCache notNil. |
|
92 |
self assert: valueCache notNil. |
|
93 |
^ classCache instVarOffsetOf: self name. |
|
94 |
||
95 |
"Created: / 07-12-2011 / 13:44:59 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
96 |
! |
|
97 |
||
761 | 98 |
findResolvedStaticValue |
791 | 99 |
valueCache := JavaResolver uniqueInstance |
761 | 100 |
resolveStaticFieldIndentifiedByRef: self. |
1239 | 101 |
|
819 | 102 |
"/Use javaClass of the field, not the class ref!! |
1239 | 103 |
|
104 |
classCache := valueCache javaClass. |
|
1205 | 105 |
classCache isNil ifTrue: [ self breakPoint: #mh ]. |
1239 | 106 |
self resolveOffset. |
794
9635f32d1723
implemented deeper caching in new resolving refs to help keeping C-code lean and clean
hlopkmar
parents:
793
diff
changeset
|
107 |
nameAndTypeCache := (constantPool at: nameAndTypeIndex) resolve. |
9635f32d1723
implemented deeper caching in new resolving refs to help keeping C-code lean and clean
hlopkmar
parents:
793
diff
changeset
|
108 |
self resolveType. |
1205 | 109 |
nameAndTypeCache isNil ifTrue: [ self breakPoint: #mh ]. |
761 | 110 |
|
111 |
"Created: / 28-04-2011 / 22:05:10 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
1205 | 112 |
"Modified: / 03-12-2011 / 12:16:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1239 | 113 |
"Modified: / 07-12-2011 / 21:33:22 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
761 | 114 |
! |
115 |
||
758 | 116 |
findResolvedValue |
791 | 117 |
valueCache := JavaResolver uniqueInstance |
118 |
resolveFieldIndentifiedByRef: self. |
|
1239 | 119 |
|
120 |
||
121 |
valueCache isStatic ifTrue: [ classCache := valueCache javaClass ] ifFalse: [ |
|
122 |
classCache := (constantPool at: classRefIndex) resolve |
|
123 |
]. |
|
794
9635f32d1723
implemented deeper caching in new resolving refs to help keeping C-code lean and clean
hlopkmar
parents:
793
diff
changeset
|
124 |
classCache ifNil: [ self breakPoint: #mh ]. |
806 | 125 |
self resolveOffset. |
794
9635f32d1723
implemented deeper caching in new resolving refs to help keeping C-code lean and clean
hlopkmar
parents:
793
diff
changeset
|
126 |
nameAndTypeCache := (constantPool at: nameAndTypeIndex) resolve. |
793 | 127 |
self resolveType. |
806 | 128 |
nameAndTypeCache ifNil: [ self breakPoint: #mh ]. |
791 | 129 |
|
1239 | 130 |
"Modified (comment): / 07-12-2011 / 20:51:43 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
792 | 131 |
! |
132 |
||
1234 | 133 |
findStaticOffset |
134 |
"fieldRef must be resolved before calling me" |
|
135 |
self assert: classCache notNil. |
|
136 |
self assert: valueCache notNil. |
|
137 |
^ classCache class instVarOffsetOf: self name. |
|
138 |
||
139 |
"Created: / 07-12-2011 / 13:45:15 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
140 |
! |
|
141 |
||
806 | 142 |
resolveOffset |
143 |
"fieldRef must be resolved before calling me" |
|
144 |
||
1239 | 145 |
self assert: valueCache notNil. |
1234 | 146 |
self assert: classCache isJavaClass. |
147 |
valueCache isStatic ifTrue: [ offset := self findStaticOffset. ] ifFalse: [ |
|
148 |
offset := self findInstOffset. |
|
1239 | 149 |
offset isNil ifTrue: [ self breakPoint:#mh. offset := self findStaticOffset. ] |
1234 | 150 |
]. |
151 |
self assert: offset notNil. |
|
806 | 152 |
|
1239 | 153 |
"Modified: / 07-12-2011 / 21:21:09 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
806 | 154 |
! |
155 |
||
156 |
resolveStaticOffset |
|
157 |
"fieldRef must be resolved before calling me" |
|
807
b9dde0678965
I should not be committing anything when I'm in hurry.. swapped resolveOffset and resolveStaticOffset
hlopkmar
parents:
806
diff
changeset
|
158 |
|
806 | 159 |
| currentClass | |
1233 | 160 |
currentClass := classCache. |
161 |
self assert: (currentClass class instVarNames includes: self name). |
|
162 |
offset := currentClass class instVarOffsetOf: self name. |
|
806 | 163 |
|
1233 | 164 |
"Modified: / 07-12-2011 / 13:38:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
806 | 165 |
! |
166 |
||
792 | 167 |
resolveType |
168 |
type := JavaMethod typeFromSignature:((constantPool at: nameAndTypeIndex) descriptor) in:nil. |
|
169 |
type == #long ifTrue:[ |
|
170 |
type := T_LONG. |
|
171 |
] ifFalse:[ |
|
172 |
type == #double ifTrue:[ |
|
173 |
type := T_DOUBLE |
|
174 |
] |
|
175 |
]. |
|
176 |
||
177 |
"Created: / 15-05-2011 / 22:29:02 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
758 | 178 |
! ! |
179 |
||
752 | 180 |
!JavaFieldRef2 class methodsFor:'documentation'! |
181 |
||
182 |
version_SVN |
|
183 |
^ '$Id$' |
|
184 |
! ! |
|
792 | 185 |
|
186 |
JavaFieldRef2 initialize! |