author | hlopkmar |
Fri, 13 May 2011 16:15:45 +0000 | |
branch | jk_new_structure |
changeset 786 | e3de6a198e63 |
parent 785 | 7811d2e77ca6 |
child 809 | 0fd3dbe06abb |
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 |
||
786 | 36 |
tmp := self name. |
37 |
[tmp startsWith: '['] whileTrue: [tmp := tmp copyFrom: 2]. |
|
38 |
tmp := tmp replaceAll: $/ with: $.. |
|
785
7811d2e77ca6
aaaargh forgot to delete old code after fixing it.. and wondering why it's not working :)
hlopkmar
parents:
783
diff
changeset
|
39 |
(tmp startsWith: 'L') ifTrue: [ tmp := tmp copyFrom: 2 to: tmp size ]. |
7811d2e77ca6
aaaargh forgot to delete old code after fixing it.. and wondering why it's not working :)
hlopkmar
parents:
783
diff
changeset
|
40 |
(tmp endsWith: ';') ifTrue: [ tmp := tmp copyFrom: 1 to: tmp size - 1 ]. |
7811d2e77ca6
aaaargh forgot to delete old code after fixing it.. and wondering why it's not working :)
hlopkmar
parents:
783
diff
changeset
|
41 |
^ tmp. |
758 | 42 |
|
43 |
"Created: / 08-04-2011 / 18:30:44 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
786 | 44 |
"Modified: / 13-05-2011 / 18:14:22 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
758 | 45 |
! |
46 |
||
47 |
name |
|
778
caa3a009f617
refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents:
777
diff
changeset
|
48 |
^constantPool at: nameIndex. |
758 | 49 |
|
50 |
"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
|
51 |
"Modified: / 13-05-2011 / 09:59:58 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
758 | 52 |
! ! |
53 |
||
54 |
!JavaClassRef2 methodsFor:'array support'! |
|
55 |
||
56 |
arrayDimensions |
|
778
caa3a009f617
refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents:
777
diff
changeset
|
57 |
^ self name occurrencesOf: $[. |
758 | 58 |
|
59 |
"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
|
60 |
"Modified: / 13-05-2011 / 10:00:15 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
758 | 61 |
! |
62 |
||
63 |
isJavaArrayClassRef |
|
778
caa3a009f617
refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents:
777
diff
changeset
|
64 |
^ self name startsWith: '['. |
758 | 65 |
|
66 |
"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
|
67 |
"Modified: / 13-05-2011 / 10:00:21 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 68 |
! ! |
69 |
||
70 |
!JavaClassRef2 methodsFor:'comparing'! |
|
71 |
||
758 | 72 |
= anotherJavaClassRef |
752 | 73 |
"superclass JavaRef2 says that I am responsible to implement this method" |
758 | 74 |
|
75 |
anotherJavaClassRef isJavaClassRef ifFalse: [ ^ false ]. |
|
76 |
^ self name = anotherJavaClassRef name. |
|
752 | 77 |
|
758 | 78 |
"Modified: / 08-04-2011 / 13:48:56 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 79 |
! |
80 |
||
81 |
hash |
|
778
caa3a009f617
refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents:
777
diff
changeset
|
82 |
^ self name hash. |
752 | 83 |
|
778
caa3a009f617
refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents:
777
diff
changeset
|
84 |
"Modified: / 13-05-2011 / 10:00:26 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 85 |
! ! |
86 |
||
87 |
!JavaClassRef2 methodsFor:'initialization'! |
|
88 |
||
771 | 89 |
initializeIn: aJavaConstantPool withNameAt: nameCPIndex |
90 |
nameIndex := nameCPIndex. |
|
91 |
constantPool := aJavaConstantPool. |
|
752 | 92 |
super initialize. |
93 |
||
771 | 94 |
"Modified: / 10-05-2011 / 14:57:38 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
95 |
! ! |
|
96 |
||
97 |
!JavaClassRef2 methodsFor:'printing'! |
|
98 |
||
99 |
fullName |
|
100 |
^ self name. |
|
101 |
||
102 |
"Created: / 10-05-2011 / 14:19:27 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
103 |
! |
|
104 |
||
105 |
printString |
|
778
caa3a009f617
refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents:
777
diff
changeset
|
106 |
^ 'JavaClassRef for: ' , self name printString. |
771 | 107 |
|
108 |
"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
|
109 |
"Modified: / 13-05-2011 / 10:00:33 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 110 |
! ! |
111 |
||
112 |
!JavaClassRef2 methodsFor:'private - resolving'! |
|
113 |
||
761 | 114 |
findResolvedStaticValue |
115 |
"Resolving static inner classes is not different from resolving any other class, it's only done in different circumstances" |
|
116 |
||
117 |
^ self findResolvedValue. |
|
118 |
||
119 |
"Created: / 28-04-2011 / 21:57:46 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
120 |
! |
|
121 |
||
752 | 122 |
findResolvedValue |
758 | 123 |
"Resolve reference and set valueCache." |
124 |
||
125 |
valueCache := JavaResolver uniqueInstance |
|
126 |
resolveClassIndentifiedByRef: self. |
|
127 |
||
128 |
"Modified: / 08-04-2011 / 17:39:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
129 |
! ! |
|
752 | 130 |
|
761 | 131 |
!JavaClassRef2 methodsFor:'queries'! |
132 |
||
133 |
isJavaClassRef |
|
134 |
^true. |
|
135 |
||
136 |
"Created: / 11-04-2011 / 19:10:00 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
|
137 |
! ! |
|
138 |
||
758 | 139 |
!JavaClassRef2 methodsFor:'resolving'! |
140 |
||
141 |
invalidateForClass: internalJavaClassName |
|
142 |
"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
|
143 |
Return true, if reference was invalidated." |
caa3a009f617
refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents:
777
diff
changeset
|
144 |
self name = internalJavaClassName |
caa3a009f617
refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents:
777
diff
changeset
|
145 |
ifTrue: |
caa3a009f617
refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents:
777
diff
changeset
|
146 |
[ self invalidate. |
caa3a009f617
refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents:
777
diff
changeset
|
147 |
^ true ]. |
caa3a009f617
refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents:
777
diff
changeset
|
148 |
^ false. |
758 | 149 |
|
778
caa3a009f617
refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents:
777
diff
changeset
|
150 |
"Modified: / 13-05-2011 / 09:59:37 / Marcel Hlopko <hlopkmar@fel.cvut.cz>" |
752 | 151 |
! ! |
152 |
||
153 |
!JavaClassRef2 class methodsFor:'documentation'! |
|
154 |
||
155 |
version_SVN |
|
156 |
^ '$Id$' |
|
157 |
! ! |