author | hlopkmar |
Fri, 13 May 2011 15:45:51 +0000 | |
branch | jk_new_structure |
changeset 783 | e805ae9fb6c6 |
parent 778 | caa3a009f617 |
child 785 | 7811d2e77ca6 |
permissions | -rw-r--r-- |
752 | 1 |
"{ Package: 'stx:libjava' }" |
2 |
||
3 |
JavaRef2 subclass:#JavaClassRef2 |
|
778
caa3a009f617
refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents:
777
diff
changeset
|
4 |
instanceVariableNames:'nameIndex' |
752 | 5 |
classVariableNames:'' |
6 |
poolDictionaries:'' |
|
7 |
category:'Languages-Java-Reader-Support-new' |
|
8 |
! |
|
9 |
||
10 |
||
11 |
!JavaClassRef2 class methodsFor:'instance creation'! |
|
12 |
||
771 | 13 |
in: aJavaConstantPool withNameAt: nameIndex |
14 |
||
758 | 15 |
|
771 | 16 |
^ self basicNew initializeIn: aJavaConstantPool withNameAt: nameIndex. |
752 | 17 |
|
771 | 18 |
"Created: / 10-05-2011 / 14:56:15 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
758 | 19 |
! ! |
20 |
||
21 |
!JavaClassRef2 methodsFor:'accessing'! |
|
22 |
||
761 | 23 |
classLoader |
777 | 24 |
self owner ifNil: [ ^ nil ] ifNotNil: [ ^ self owner classLoader ]. |
761 | 25 |
|
26 |
"Created: / 11-04-2011 / 21:52:06 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
777 | 27 |
"Modified: / 12-05-2011 / 18:32:57 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
761 | 28 |
! |
29 |
||
758 | 30 |
javaClassName |
761 | 31 |
"return java class name as written in java programs e.g. java.util.String |
32 |
in case of array, return class name without square brackets" |
|
33 |
||
34 |
| tmp | |
|
35 |
||
771 | 36 |
tmp := (self name replaceAll: '[' with: ''). |
783 | 37 |
tmp := tmp replaceAll: '/' with: '.'. |
38 |
(tmp startsWith: 'L') ifTrue: [tmp := tmp copyFrom: 2 to: tmp size]. |
|
39 |
(tmp endsWith: ';') ifTrue: [tmp := tmp copyFrom: 1 to: tmp size - 1]. |
|
40 |
^ tmp copyFrom: 2 to: tmp size -1. |
|
758 | 41 |
|
42 |
"Created: / 08-04-2011 / 18:30:44 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
783 | 43 |
"Modified: / 13-05-2011 / 17:44:18 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
758 | 44 |
! |
45 |
||
46 |
name |
|
778
caa3a009f617
refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents:
777
diff
changeset
|
47 |
^constantPool at: nameIndex. |
758 | 48 |
|
49 |
"Created: / 08-04-2011 / 13:48:36 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
778
caa3a009f617
refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents:
777
diff
changeset
|
50 |
"Modified: / 13-05-2011 / 09:59:58 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
758 | 51 |
! ! |
52 |
||
53 |
!JavaClassRef2 methodsFor:'array support'! |
|
54 |
||
55 |
arrayDimensions |
|
778
caa3a009f617
refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents:
777
diff
changeset
|
56 |
^ self name occurrencesOf: $[. |
758 | 57 |
|
58 |
"Created: / 08-04-2011 / 18:42:02 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
778
caa3a009f617
refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents:
777
diff
changeset
|
59 |
"Modified: / 13-05-2011 / 10:00:15 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
758 | 60 |
! |
61 |
||
62 |
isJavaArrayClassRef |
|
778
caa3a009f617
refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents:
777
diff
changeset
|
63 |
^ self name startsWith: '['. |
758 | 64 |
|
65 |
"Created: / 08-04-2011 / 18:40:40 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
778
caa3a009f617
refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents:
777
diff
changeset
|
66 |
"Modified: / 13-05-2011 / 10:00:21 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 67 |
! ! |
68 |
||
69 |
!JavaClassRef2 methodsFor:'comparing'! |
|
70 |
||
758 | 71 |
= anotherJavaClassRef |
752 | 72 |
"superclass JavaRef2 says that I am responsible to implement this method" |
758 | 73 |
|
74 |
anotherJavaClassRef isJavaClassRef ifFalse: [ ^ false ]. |
|
75 |
^ self name = anotherJavaClassRef name. |
|
752 | 76 |
|
758 | 77 |
"Modified: / 08-04-2011 / 13:48:56 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 78 |
! |
79 |
||
80 |
hash |
|
778
caa3a009f617
refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents:
777
diff
changeset
|
81 |
^ self name hash. |
752 | 82 |
|
778
caa3a009f617
refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents:
777
diff
changeset
|
83 |
"Modified: / 13-05-2011 / 10:00:26 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 84 |
! ! |
85 |
||
86 |
!JavaClassRef2 methodsFor:'initialization'! |
|
87 |
||
771 | 88 |
initializeIn: aJavaConstantPool withNameAt: nameCPIndex |
89 |
nameIndex := nameCPIndex. |
|
90 |
constantPool := aJavaConstantPool. |
|
752 | 91 |
super initialize. |
92 |
||
771 | 93 |
"Modified: / 10-05-2011 / 14:57:38 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
94 |
! ! |
|
95 |
||
96 |
!JavaClassRef2 methodsFor:'printing'! |
|
97 |
||
98 |
fullName |
|
99 |
^ self name. |
|
100 |
||
101 |
"Created: / 10-05-2011 / 14:19:27 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
102 |
! |
|
103 |
||
104 |
printString |
|
778
caa3a009f617
refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents:
777
diff
changeset
|
105 |
^ 'JavaClassRef for: ' , self name printString. |
771 | 106 |
|
107 |
"Created: / 10-05-2011 / 14:16:50 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
778
caa3a009f617
refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents:
777
diff
changeset
|
108 |
"Modified: / 13-05-2011 / 10:00:33 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 109 |
! ! |
110 |
||
111 |
!JavaClassRef2 methodsFor:'private - resolving'! |
|
112 |
||
761 | 113 |
findResolvedStaticValue |
114 |
"Resolving static inner classes is not different from resolving any other class, it's only done in different circumstances" |
|
115 |
||
116 |
^ self findResolvedValue. |
|
117 |
||
118 |
"Created: / 28-04-2011 / 21:57:46 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
119 |
! |
|
120 |
||
752 | 121 |
findResolvedValue |
758 | 122 |
"Resolve reference and set valueCache." |
123 |
||
124 |
valueCache := JavaResolver uniqueInstance |
|
125 |
resolveClassIndentifiedByRef: self. |
|
126 |
||
127 |
"Modified: / 08-04-2011 / 17:39:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
128 |
! ! |
|
752 | 129 |
|
761 | 130 |
!JavaClassRef2 methodsFor:'queries'! |
131 |
||
132 |
isJavaClassRef |
|
133 |
^true. |
|
134 |
||
135 |
"Created: / 11-04-2011 / 19:10:00 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
136 |
! ! |
|
137 |
||
758 | 138 |
!JavaClassRef2 methodsFor:'resolving'! |
139 |
||
140 |
invalidateForClass: internalJavaClassName |
|
141 |
"Invalidate (means call invalidate) reference if it has something to do with given class (e.g Class named internalJavaClassName was unloaded). |
|
778
caa3a009f617
refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents:
777
diff
changeset
|
142 |
Return true, if reference was invalidated." |
caa3a009f617
refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents:
777
diff
changeset
|
143 |
self name = internalJavaClassName |
caa3a009f617
refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents:
777
diff
changeset
|
144 |
ifTrue: |
caa3a009f617
refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents:
777
diff
changeset
|
145 |
[ self invalidate. |
caa3a009f617
refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents:
777
diff
changeset
|
146 |
^ true ]. |
caa3a009f617
refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents:
777
diff
changeset
|
147 |
^ false. |
758 | 148 |
|
778
caa3a009f617
refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents:
777
diff
changeset
|
149 |
"Modified: / 13-05-2011 / 09:59:37 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 150 |
! ! |
151 |
||
152 |
!JavaClassRef2 class methodsFor:'documentation'! |
|
153 |
||
154 |
version_SVN |
|
155 |
^ '$Id$' |
|
156 |
! ! |