--- a/JavaFieldRef2.st Fri Feb 14 14:27:26 2014 +0100
+++ b/JavaFieldRef2.st Wed Jan 28 03:12:08 2015 +0100
@@ -1,9 +1,9 @@
"
- COPYRIGHT (c) 1996-2011 by Claus Gittinger
+ COPYRIGHT (c) 1996-2015 by Claus Gittinger
New code and modifications done at SWING Research Group [1]:
- COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
+ COPYRIGHT (c) 2010-2015 by Jan Vrany, Jan Kurs and Marcel Hlopko
SWING Research Group, Czech Technical University in Prague
This software is furnished under a license and may be used
@@ -20,10 +20,10 @@
"
"{ Package: 'stx:libjava' }"
-JavaClassContentRef2 subclass:#JavaFieldRef2
- instanceVariableNames:'offset type'
- classVariableNames:'T_LONG T_DOUBLE'
- poolDictionaries:''
+JavaClassMemberRef2 subclass:#JavaFieldRef2
+ instanceVariableNames:'resolvedOffset'
+ classVariableNames:''
+ poolDictionaries:'JavaConstants'
category:'Languages-Java-Reader-Support-new'
!
@@ -31,11 +31,11 @@
copyright
"
- COPYRIGHT (c) 1996-2011 by Claus Gittinger
+ COPYRIGHT (c) 1996-2015 by Claus Gittinger
New code and modifications done at SWING Research Group [1]:
- COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
+ COPYRIGHT (c) 2010-2015 by Jan Vrany, Jan Kurs and Marcel Hlopko
SWING Research Group, Czech Technical University in Prague
This software is furnished under a license and may be used
@@ -51,15 +51,28 @@
as of 1.9.2010
"
-! !
+!
-!JavaFieldRef2 class methodsFor:'initialization'!
+documentation
+"
+ A symbolic reference to a field.
+
+ [author:]
+ Marcel Hlopko <marcel.hlopko@fit.cvut.cz>
+ Jan Vrany <jan.vrany@fit.cvut.cz>
-initialize
- T_LONG := 1.
- T_DOUBLE := 2.
+ [instance variables:]
+ !! resolvedOffset ...... once resolved, this slot contains physical offset
+ of the field within an instance (if instance field)
+ or of the static field withing a class instance
+ (if static field).
+ !!!!!! Used by the VM !!!!!!
- "Created: / 15-05-2011 / 22:31:19 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ [class variables:]
+
+ [see also:]
+
+"
! !
!JavaFieldRef2 methodsFor:'accessing'!
@@ -71,112 +84,121 @@
!
offset
- ^ offset.
+ ^ resolvedOffset.
"Created: / 15-05-2011 / 22:26:08 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
!
+resolvedOffset
+ ^ resolvedOffset.
+
+ "Created: / 31-01-2014 / 09:15:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
type
- type == T_LONG ifTrue: [ ^ #long. ].
- type == T_DOUBLE ifTrue: [ ^ #double ].
^ type.
"Created: / 15-05-2011 / 22:29:05 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 05-10-2013 / 23:57:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaFieldRef2 methodsFor:'printing & storing'!
+
+printOn:aStream
+ super printOn: aStream.
+ aStream nextPut: $(.
+ self classRef javaClassName printOn: aStream.
+ aStream nextPut:$#.
+ aStream nextPutAll: self nameAndType name.
+ aStream nextPut: $).
+
+ "Modified: / 15-08-2014 / 15:30:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!JavaFieldRef2 methodsFor:'private - resolving'!
findInstOffset
"fieldRef must be resolved before calling me"
- self assert: classCache notNil.
- self assert: valueCache notNil.
- ^ classCache instVarOffsetOf: self name.
+ self assert: resolvedClass notNil.
+ self assert: resolvedValue notNil.
+ ^ resolvedClass instVarOffsetOf: self name.
"Created: / 07-12-2011 / 13:44:59 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
!
-findResolvedStaticValue
-
-self findResolvedValue.
-
- "Created: / 28-04-2011 / 22:05:10 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
- "Modified: / 03-12-2011 / 12:16:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 08-12-2011 / 13:37:05 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-!
-
findResolvedValue: doClassInit
- valueCache := JavaResolver uniqueInstance
+ "
+ Stores resolved field in valueCache field, fills offset and
+ type fields.
+ "
+ resolvedValue := JavaResolver uniqueInstance
resolveFieldIndentifiedByRef: self.
- valueCache isStatic ifTrue: [ classCache := valueCache javaClass ] ifFalse: [
- classCache := (constantPool at: classRefIndex) resolve: doClassInit.
+ resolvedValue isStatic ifTrue: [ resolvedClass := resolvedValue javaClass ] ifFalse: [
+ resolvedClass := self classRef resolve: doClassInit.
].
- classCache isNil ifTrue: [ self breakPoint: #mh ].
+ resolvedClass isNil ifTrue: [ self breakPoint: #mh ].
self resolveOffset.
- nameAndTypeCache := (constantPool at: nameAndTypeIndex) resolve.
- self resolveType.
- nameAndTypeCache isNil ifTrue: [ self breakPoint: #mh ].
"Modified: / 07-12-2011 / 21:52:23 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
"Created: / 09-02-2012 / 23:09:18 / mh <hlopik@gmail.com>"
- "Modified: / 16-10-2012 / 10:46:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 12-10-2013 / 17:54:48 / Marcel Hlopko <marcel.hlopko@fit.cvut.cz>"
+ "Modified: / 31-01-2014 / 03:02:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
findStaticOffset
"fieldRef must be resolved before calling me"
- self assert: classCache notNil.
- self assert: valueCache notNil.
- ^ classCache class instVarOffsetOf: self name.
+ self assert: resolvedClass notNil.
+ self assert: resolvedValue notNil.
+ ^ resolvedClass class instVarOffsetOf: self name.
"Created: / 07-12-2011 / 13:45:15 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
!
preResolve
- self resolveType
+ | descriptor |
+
+ descriptor := (constantPool at: nameAndTypeIndex) descriptor.
+ type := 0.
+ descriptor = 'J' ifTrue:[
+ type := ACX_R_LONG.
+ ] ifFalse:[
+ descriptor = 'D' ifTrue:[
+ type := ACX_R_DOUBLE
+ ]
+ ].
"Created: / 16-10-2012 / 10:45:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 31-01-2014 / 03:38:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
resolveOffset
"fieldRef must be resolved before calling me"
-
- self assert: valueCache notNil.
- self assert: classCache isJavaClass.
- valueCache isStatic ifTrue: [ offset := self findStaticOffset. ] ifFalse: [
- offset := self findInstOffset.
+
+ self assert: resolvedValue notNil.
+ self assert: resolvedClass isJavaClass.
+ resolvedValue isStatic ifTrue: [ resolvedOffset := self findStaticOffset. ] ifFalse: [
+ resolvedOffset := self findInstOffset.
].
- self assert: offset notNil.
+ self assert: resolvedOffset notNil.
"Modified: / 07-12-2011 / 21:47:43 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-!
+! !
-resolveStaticOffset
- "fieldRef must be resolved before calling me"
-
- | currentClass |
- currentClass := classCache.
- self assert: (currentClass class instVarNames includes: self name).
- offset := currentClass class instVarOffsetOf: self name.
+!JavaFieldRef2 methodsFor:'resolving'!
+
+invalidate
- "Modified: / 07-12-2011 / 13:38:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-!
+ resolvedOffset := nil.
+ ^ super invalidate.
-resolveType
- type := JavaMethod typeFromSignature:((constantPool at: nameAndTypeIndex) descriptor) in:nil.
- type == #long ifTrue:[
- type := T_LONG.
- ] ifFalse:[
- type == #double ifTrue:[
- type := T_DOUBLE
- ]
- ].
-
- "Created: / 15-05-2011 / 22:29:02 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Created: / 14-10-2013 / 23:39:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 07-08-2014 / 14:38:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!JavaFieldRef2 class methodsFor:'documentation'!
version_CVS
- ^ '$Header: /cvs/stx/stx/libjava/JavaFieldRef2.st,v 1.6 2013-09-06 00:41:23 vrany Exp $'
+ ^ '$Header: /cvs/stx/stx/libjava/JavaFieldRef2.st,v 1.7 2015-01-28 02:10:50 vrany Exp $'
!
version_HG
@@ -185,8 +207,6 @@
!
version_SVN
- ^ '§Id§'
+ ^ 'Id'
! !
-
-JavaFieldRef2 initialize!