|
1 " |
|
2 COPYRIGHT (c) 1996-2011 by Claus Gittinger |
|
3 |
|
4 New code and modifications done at SWING Research Group [1]: |
|
5 |
|
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 |
|
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 |
|
19 as of 1.9.2010 |
|
20 " |
|
21 "{ Package: 'stx:libjava' }" |
|
22 |
|
23 JavaClassContentRef2 subclass:#JavaFieldRef2 |
|
24 instanceVariableNames:'offset type' |
|
25 classVariableNames:'T_LONG T_DOUBLE' |
|
26 poolDictionaries:'' |
|
27 category:'Languages-Java-Reader-Support-new' |
|
28 ! |
|
29 |
|
30 !JavaFieldRef2 class methodsFor:'documentation'! |
|
31 |
|
32 copyright |
|
33 " |
|
34 COPYRIGHT (c) 1996-2011 by Claus Gittinger |
|
35 |
|
36 New code and modifications done at SWING Research Group [1]: |
|
37 |
|
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 |
|
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 |
|
51 as of 1.9.2010 |
|
52 |
|
53 " |
|
54 ! ! |
|
55 |
|
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 |
|
65 !JavaFieldRef2 methodsFor:'accessing'! |
|
66 |
|
67 isJavaFieldRef |
|
68 ^true. |
|
69 |
|
70 "Created: / 11-04-2011 / 21:47:51 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
71 ! |
|
72 |
|
73 offset |
|
74 ^ offset. |
|
75 |
|
76 "Created: / 15-05-2011 / 22:26:08 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
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>" |
|
85 ! ! |
|
86 |
|
87 !JavaFieldRef2 methodsFor:'private - resolving'! |
|
88 |
|
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 |
|
98 findResolvedStaticValue |
|
99 |
|
100 self findResolvedValue. |
|
101 |
|
102 "Created: / 28-04-2011 / 22:05:10 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
103 "Modified: / 03-12-2011 / 12:16:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
104 "Modified: / 08-12-2011 / 13:37:05 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
105 ! |
|
106 |
|
107 findResolvedValue: doClassInit |
|
108 valueCache := JavaResolver uniqueInstance |
|
109 resolveFieldIndentifiedByRef: self. |
|
110 valueCache isStatic ifTrue: [ classCache := valueCache javaClass ] ifFalse: [ |
|
111 classCache := (constantPool at: classRefIndex) resolve: doClassInit. |
|
112 ]. |
|
113 classCache isNil ifTrue: [ self breakPoint: #mh ]. |
|
114 self resolveOffset. |
|
115 nameAndTypeCache := (constantPool at: nameAndTypeIndex) resolve. |
|
116 self resolveType. |
|
117 nameAndTypeCache isNil ifTrue: [ self breakPoint: #mh ]. |
|
118 |
|
119 "Modified: / 07-12-2011 / 21:52:23 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
120 "Created: / 09-02-2012 / 23:09:18 / mh <hlopik@gmail.com>" |
|
121 "Modified: / 16-10-2012 / 10:46:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
122 ! |
|
123 |
|
124 findStaticOffset |
|
125 "fieldRef must be resolved before calling me" |
|
126 self assert: classCache notNil. |
|
127 self assert: valueCache notNil. |
|
128 ^ classCache class instVarOffsetOf: self name. |
|
129 |
|
130 "Created: / 07-12-2011 / 13:45:15 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
131 ! |
|
132 |
|
133 preResolve |
|
134 self resolveType |
|
135 |
|
136 "Created: / 16-10-2012 / 10:45:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
137 ! |
|
138 |
|
139 resolveOffset |
|
140 "fieldRef must be resolved before calling me" |
|
141 |
|
142 self assert: valueCache notNil. |
|
143 self assert: classCache isJavaClass. |
|
144 valueCache isStatic ifTrue: [ offset := self findStaticOffset. ] ifFalse: [ |
|
145 offset := self findInstOffset. |
|
146 ]. |
|
147 self assert: offset notNil. |
|
148 |
|
149 "Modified: / 07-12-2011 / 21:47:43 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
150 ! |
|
151 |
|
152 resolveStaticOffset |
|
153 "fieldRef must be resolved before calling me" |
|
154 |
|
155 | currentClass | |
|
156 currentClass := classCache. |
|
157 self assert: (currentClass class instVarNames includes: self name). |
|
158 offset := currentClass class instVarOffsetOf: self name. |
|
159 |
|
160 "Modified: / 07-12-2011 / 13:38:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
161 ! |
|
162 |
|
163 resolveType |
|
164 type := JavaMethod typeFromSignature:((constantPool at: nameAndTypeIndex) descriptor) in:nil. |
|
165 type == #long ifTrue:[ |
|
166 type := T_LONG. |
|
167 ] ifFalse:[ |
|
168 type == #double ifTrue:[ |
|
169 type := T_DOUBLE |
|
170 ] |
|
171 ]. |
|
172 |
|
173 "Created: / 15-05-2011 / 22:29:02 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
174 ! ! |
|
175 |
|
176 !JavaFieldRef2 class methodsFor:'documentation'! |
|
177 |
|
178 version_SVN |
|
179 ^ '$Id$' |
|
180 ! ! |
|
181 |
|
182 JavaFieldRef2 initialize! |