src/JavaConstantPool.st
author vranyj1
Sun, 01 May 2011 12:52:23 +0000
branchjk_new_structure
changeset 761 43e017ec7958
parent 758 be8e84381ce0
child 772 0f92c23b80ee
permissions -rw-r--r--
Merged with /branches/jk
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
     1
"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
     2
 COPYRIGHT (c) 1997 by eXept Software AG
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
     3
              All Rights Reserved
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
     4
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
     5
 This software is furnished under a license and may be used
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    10
 hereby transferred.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    11
"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    12
"{ Package: 'stx:libjava' }"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    13
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    14
Array variableSubclass:#JavaConstantPool
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    15
	instanceVariableNames:'owner'
757
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
    16
	classVariableNames:'ConstantPools'
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    17
	poolDictionaries:''
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    18
	category:'Languages-Java-Reader-Support'
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    19
!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    20
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    21
!JavaConstantPool class methodsFor:'documentation'!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    22
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    23
copyright
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    24
"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    25
 COPYRIGHT (c) 1997 by eXept Software AG
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    26
              All Rights Reserved
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    27
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    28
 This software is furnished under a license and may be used
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    29
 only in accordance with the terms of that license and with the
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    31
 be provided or otherwise made available to, or used by, any
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    32
 other person.  No title to or ownership of the software is
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    33
 hereby transferred.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    34
"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    35
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    36
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    37
! !
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    38
757
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
    39
!JavaConstantPool class methodsFor:'initialization'!
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
    40
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
    41
initialize
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
    42
    ConstantPools := OrderedCollection new: 1000.
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
    43
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
    44
    "Modified: / 08-04-2011 / 17:28:07 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
    45
    "Modified: / 09-04-2011 / 09:25:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
    46
! !
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
    47
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
    48
!JavaConstantPool class methodsFor:'instance creation'!
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
    49
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
    50
new: size 
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
    51
    "return an initialized instance"
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
    52
    
761
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 758
diff changeset
    53
    ^ ConstantPools add: ((super new: size)
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 758
diff changeset
    54
                initialize;
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 758
diff changeset
    55
                yourself).
757
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
    56
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
    57
    "Created: / 08-04-2011 / 16:56:18 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
    58
    "Modified: / 09-04-2011 / 09:24:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
761
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 758
diff changeset
    59
    "Modified: / 11-04-2011 / 18:46:54 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
757
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
    60
! !
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
    61
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
    62
!JavaConstantPool class methodsFor:'accessing'!
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
    63
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
    64
allConstantPools
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
    65
    "linked list of all constant pools in system"
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
    66
    ^ ConstantPools.
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
    67
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
    68
    "Created: / 08-04-2011 / 16:53:58 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
    69
    "Modified: / 09-04-2011 / 09:24:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
    70
!
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
    71
761
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 758
diff changeset
    72
allConstantPools: anOorderedCollection 
757
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
    73
    "linked list of all constant pools in system"
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
    74
    
761
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 758
diff changeset
    75
    ConstantPools := anOorderedCollection.
757
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
    76
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
    77
    "Created: / 08-04-2011 / 17:07:28 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
    78
    "Modified: / 09-04-2011 / 09:24:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
761
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 758
diff changeset
    79
    "Modified: / 11-04-2011 / 18:47:58 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
757
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
    80
! !
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
    81
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    82
!JavaConstantPool class methodsFor:'special'!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    83
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    84
compressPools
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    85
    "unify all constants"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    86
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    87
    |strings nameandTypes jStrings|
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    88
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    89
    strings := Set new.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    90
    nameandTypes := Set new.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    91
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    92
    self allInstancesDo:[:aPool |
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    93
        aPool keysAndValuesDo:[:idx :aConst |
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    94
            |existing nt|
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    95
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    96
            aConst isString ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    97
                existing := strings elementAt:aConst ifAbsent:nil.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    98
                existing isNil ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    99
                    strings add:aConst
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   100
                ] ifFalse:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   101
                    aPool at:idx put:existing
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   102
                ]
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   103
            ] ifFalse:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   104
                (aConst isMemberOf:JavaFieldref) ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   105
                    nt := aConst nameandType.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   106
                    existing := nameandTypes elementAt:nt ifAbsent:nil.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   107
                    existing isNil ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   108
                        nameandTypes add:nt
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   109
                    ] ifFalse:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   110
                        aConst nameandType:existing
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   111
                    ]
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   112
                ] ifFalse:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   113
                    (aConst isMemberOf:JavaNameandType) ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   114
                        existing := nameandTypes elementAt:aConst ifAbsent:nil.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   115
                        existing isNil ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   116
                            nameandTypes add:aConst
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   117
                        ] ifFalse:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   118
                            aPool at:idx put:existing
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   119
                        ]
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   120
                    ]
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   121
                ]
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   122
            ]
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   123
        ].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   124
    ]
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   125
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   126
    "
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   127
     self compressPools
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   128
    "
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   129
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   130
    "Modified: 19.8.1997 / 14:04:25 / cg"
757
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
   131
!
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
   132
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
   133
invalidateForClass: internalJavaClassName 
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
   134
    "Only alias, everybody calls invalidateForClass so why not me :)"
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
   135
    
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
   136
    ^self invalidateReferencesToClass: internalJavaClassName.
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
   137
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
   138
    "Created: / 08-04-2011 / 16:52:52 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
   139
!
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
   140
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
   141
invalidateReferencesToClass: internalJavaClassName 
758
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 757
diff changeset
   142
    "Go over all constant pools and call invalidateForClass on all 
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 757
diff changeset
   143
     references. (usable when given class was unloaded etc)"
be8e84381ce0 Merged with /branches/jk
vranyj1
parents: 757
diff changeset
   144
    ConstantPools do: [:each | each invalidateForClass: internalJavaClassName].
757
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
   145
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
   146
    "Created: / 08-04-2011 / 16:09:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   147
! !
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   148
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   149
!JavaConstantPool methodsFor:'accessing'!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   150
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   151
owner
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   152
    "return owner"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   153
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   154
    ^ owner
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   155
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   156
    "Created: 28.6.1996 / 21:12:22 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   157
!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   158
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   159
owner:something
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   160
    "set owner"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   161
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   162
    owner := something.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   163
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   164
    "Created: 28.6.1996 / 21:12:22 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   165
! !
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   166
757
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
   167
!JavaConstantPool methodsFor:'initialization'!
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
   168
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
   169
initialize
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
   170
    "Invoked when a new instance is created."
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
   171
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
   172
    "/ please change as required (and remove this comment)
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
   173
    "/ owner := nil.
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
   174
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
   175
    "/ super initialize.   -- commented since inherited method does nothing
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
   176
! !
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
   177
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   178
!JavaConstantPool methodsFor:'printing & storing'!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   179
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   180
displayString
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   181
    owner isNil ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   182
        ^ '*** unowned ConstantPool'
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   183
    ].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   184
    ^ 'ConstantPool of ' , owner fullName
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   185
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   186
    "Created: 28.6.1996 / 21:13:41 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   187
    "Modified: 28.6.1996 / 21:20:26 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   188
! !
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   189
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   190
!JavaConstantPool methodsFor:'queries'!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   191
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   192
refersToMethod:aJavaMethod
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   193
    self do:[:constItem |
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   194
        (constItem == aJavaMethod) ifTrue:[^ true].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   195
        (constItem isMemberOf:JavaMethodref) ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   196
            self halt.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   197
        ].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   198
        (constItem isMemberOf:JavaUnresolvedMethodrefConstant) ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   199
            self halt.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   200
        ]
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   201
    ].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   202
    ^ false
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   203
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   204
    "Modified: 29.7.1997 / 17:36:49 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   205
    "Created: 29.7.1997 / 17:39:19 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   206
!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   207
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   208
refersToMethodNamed:aJavaMethodName
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   209
    self do:[:constItem |
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   210
        (constItem isKindOf:JavaMethod) ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   211
            constItem name = aJavaMethodName ifTrue:[^ true].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   212
        ] ifFalse:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   213
            (constItem isMemberOf:JavaMethodref) ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   214
                constItem name = aJavaMethodName ifTrue:[^ true].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   215
            ].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   216
            (constItem isMemberOf:JavaUnresolvedMethodrefConstant) ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   217
                self halt.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   218
            ]
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   219
        ]
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   220
    ].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   221
    ^ false
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   222
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   223
    "Created: / 29.7.1997 / 17:39:24 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   224
    "Modified: / 16.10.1998 / 01:22:02 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   225
! !
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   226
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   227
!JavaConstantPool methodsFor:'special'!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   228
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   229
classReferencesDo:aBlock
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   230
    self do:[:constItem |
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   231
        constItem isJavaClass ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   232
            aBlock value:constItem
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   233
        ] 
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   234
    ]
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   235
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   236
    "Modified: / 7.8.1997 / 19:17:38 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   237
    "Created: / 4.1.1998 / 00:40:11 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   238
!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   239
757
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
   240
invalidateForClass: internalJavaClassName
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
   241
"go over all entries and call invalidateForClass on all references"
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
   242
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
   243
self do: [:entry | entry isJavaRef ifTrue:[entry invalidateForClass: internalJavaClassName]].
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
   244
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
   245
    "Created: / 08-04-2011 / 16:11:36 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
   246
!
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
   247
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   248
updateClassRefsFrom:oldClass to:newClass
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   249
owner == oldClass ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   250
    self halt.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   251
    ^ self
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   252
].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   253
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   254
    self keysAndValuesDo:[:index :constItem |
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   255
        |nameIndex|
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   256
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   257
        constItem == oldClass ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   258
            self at:index put:newClass
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   259
        ] ifFalse:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   260
            (constItem isNil
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   261
            or:[constItem isNumber]) ifFalse:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   262
                constItem isString ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   263
                    "/ nothing done ...
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   264
                ] ifFalse:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   265
                    (constItem isMemberOf:(Java java_lang_String)) ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   266
                        "/ nothing done ...
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   267
                    ] ifFalse:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   268
                        constItem isBehavior ifFalse:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   269
                            constItem updateClassRefsFrom:oldClass to:newClass
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   270
                        ] ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   271
                            constItem isJavaClass ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   272
                                constItem fullName = oldClass fullName ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   273
                                    'JAVA: class update by name [in pool].' infoPrintCR.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   274
                                    newClass isNil ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   275
                                        "/ mhm - must find a slot for the classes name
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   276
                                        nameIndex := -1.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   277
                                        self 
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   278
                                            at:index
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   279
                                            put:(JavaUnresolvedClassConstant
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   280
                                                    pool:self
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   281
                                                    poolIndex:index
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   282
                                                    nameIndex:nameIndex)
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   283
                                    ] ifFalse:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   284
                                        self at:index put:newClass
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   285
                                    ]
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   286
                                ]
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   287
                            ]
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   288
                        ]
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   289
                    ]
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   290
                ]
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   291
            ]
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   292
        ]
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   293
    ]
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   294
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   295
    "Modified: / 4.2.1998 / 22:12:03 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   296
! !
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   297
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   298
!JavaConstantPool class methodsFor:'documentation'!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   299
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   300
version
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   301
    ^ '$Id$'
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   302
!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   303
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   304
version_SVN
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   305
    ^ '$Id$'
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   306
! !
757
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
   307
b98b1cd769c0 JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
vranyj1
parents: 752
diff changeset
   308
JavaConstantPool initialize!
761
43e017ec7958 Merged with /branches/jk
vranyj1
parents: 758
diff changeset
   309