author | vranyj1 |
Tue, 16 Oct 2012 08:44:08 +0000 | |
branch | jk_new_structure |
changeset 1730 | 2fad052d64b7 |
parent 1353 | 2968f8acb434 |
child 1731 | bba0ebc31d2b |
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 |
1243 | 99 |
|
100 |
self findResolvedValue. |
|
761 | 101 |
|
102 |
"Created: / 28-04-2011 / 22:05:10 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
1205 | 103 |
"Modified: / 03-12-2011 / 12:16:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1243 | 104 |
"Modified: / 08-12-2011 / 13:37:05 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
761 | 105 |
! |
106 |
||
1353 | 107 |
findResolvedValue: doClassInit |
791 | 108 |
valueCache := JavaResolver uniqueInstance |
1353 | 109 |
resolveFieldIndentifiedByRef: self. |
1239 | 110 |
valueCache isStatic ifTrue: [ classCache := valueCache javaClass ] ifFalse: [ |
1353 | 111 |
classCache := (constantPool at: classRefIndex) resolve: doClassInit. |
1239 | 112 |
]. |
794
9635f32d1723
implemented deeper caching in new resolving refs to help keeping C-code lean and clean
hlopkmar
parents:
793
diff
changeset
|
113 |
classCache ifNil: [ self breakPoint: #mh ]. |
806 | 114 |
self resolveOffset. |
794
9635f32d1723
implemented deeper caching in new resolving refs to help keeping C-code lean and clean
hlopkmar
parents:
793
diff
changeset
|
115 |
nameAndTypeCache := (constantPool at: nameAndTypeIndex) resolve. |
793 | 116 |
self resolveType. |
806 | 117 |
nameAndTypeCache ifNil: [ self breakPoint: #mh ]. |
791 | 118 |
|
1240 | 119 |
"Modified: / 07-12-2011 / 21:52:23 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
1353 | 120 |
"Created: / 09-02-2012 / 23:09:18 / mh <hlopik@gmail.com>" |
792 | 121 |
! |
122 |
||
1234 | 123 |
findStaticOffset |
124 |
"fieldRef must be resolved before calling me" |
|
125 |
self assert: classCache notNil. |
|
126 |
self assert: valueCache notNil. |
|
127 |
^ classCache class instVarOffsetOf: self name. |
|
128 |
||
129 |
"Created: / 07-12-2011 / 13:45:15 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
130 |
! |
|
131 |
||
1730 | 132 |
preResolve |
133 |
self resolveType |
|
134 |
||
135 |
"Created: / 16-10-2012 / 10:45:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
136 |
! |
|
137 |
||
806 | 138 |
resolveOffset |
139 |
"fieldRef must be resolved before calling me" |
|
140 |
||
1239 | 141 |
self assert: valueCache notNil. |
1234 | 142 |
self assert: classCache isJavaClass. |
143 |
valueCache isStatic ifTrue: [ offset := self findStaticOffset. ] ifFalse: [ |
|
144 |
offset := self findInstOffset. |
|
145 |
]. |
|
146 |
self assert: offset notNil. |
|
806 | 147 |
|
1240 | 148 |
"Modified: / 07-12-2011 / 21:47:43 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
806 | 149 |
! |
150 |
||
151 |
resolveStaticOffset |
|
152 |
"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
|
153 |
|
806 | 154 |
| currentClass | |
1233 | 155 |
currentClass := classCache. |
156 |
self assert: (currentClass class instVarNames includes: self name). |
|
157 |
offset := currentClass class instVarOffsetOf: self name. |
|
806 | 158 |
|
1233 | 159 |
"Modified: / 07-12-2011 / 13:38:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
806 | 160 |
! |
161 |
||
792 | 162 |
resolveType |
163 |
type := JavaMethod typeFromSignature:((constantPool at: nameAndTypeIndex) descriptor) in:nil. |
|
164 |
type == #long ifTrue:[ |
|
165 |
type := T_LONG. |
|
166 |
] ifFalse:[ |
|
167 |
type == #double ifTrue:[ |
|
168 |
type := T_DOUBLE |
|
169 |
] |
|
170 |
]. |
|
171 |
||
172 |
"Created: / 15-05-2011 / 22:29:02 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
758 | 173 |
! ! |
174 |
||
752 | 175 |
!JavaFieldRef2 class methodsFor:'documentation'! |
176 |
||
177 |
version_SVN |
|
178 |
^ '$Id$' |
|
179 |
! ! |
|
792 | 180 |
|
181 |
JavaFieldRef2 initialize! |