"
COPYRIGHT (c) 1996-2011 by Claus Gittinger
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
SWING Research Group, Czech Technical University in Prague
Parts of the code written by Claus Gittinger are under following
license:
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
Parts of the code written at SWING Reasearch Group [1] are MIT licensed:
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the 'Software'), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
[1] Code written at SWING Research Group contain a signature
of one of the above copright owners.
"
"{ Package: 'stx:libjava' }"
Class subclass:#JavaBehavior
instanceVariableNames:'constantPool interfaces accessFlags'
classVariableNames:'InitialValuePerType A_OBSOLETE A_INTERFACE A_PUBLIC A_FINAL
A_ABSTRACT A_INITIALIZED A_SMALLTALK A_ABSTRACT_OR_INTERFACE
A_STATIC A_NATIVE A_SYNTHETIC A_ANNOTATION A_ENUM'
poolDictionaries:''
category:'Languages-Java-Classes'
!
!JavaBehavior class methodsFor:'documentation'!
copyright
"
COPYRIGHT (c) 1996-2011 by Claus Gittinger
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
SWING Research Group, Czech Technical University in Prague
Parts of the code written by Claus Gittinger are under following
license:
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
Parts of the code written at SWING Reasearch Group [1] are MIT licensed:
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the 'Software'), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
[1] Code written at SWING Research Group contain a signature
of one of the above copright owners.
"
!
documentation
"
Describes what is known and required by the VM.
"
! !
!JavaBehavior class methodsFor:'initialization'!
initialize
"/ those are defined in Java and read from the classFile
A_PUBLIC := 16r000001.
"/ A_PRIVATE := 16r000002.
"/ A_PROTECTED := 16r000004.
A_STATIC := 16r000008.
A_FINAL := 16r000010.
"/ A_SUPER := 16r000020.
"/ A_SYNCHRONIZED := 16r000020.
"/ A_VOLATILE := 16r000040.
"/ A_TRANSIENT := 16r000080.
A_NATIVE := 16r000100.
A_INTERFACE := 16r000200.
A_ABSTRACT := 16r000400.
A_SYNTHETIC := 16r001000. "/ 1.1
A_ANNOTATION := 16r002000. "/ 1.1
A_ENUM := 16r004000. "/ 1.1
A_OBSOLETE := 16r008000.
"/ those are local to the ST/X implementation
A_INITIALIZED := 16r100000.
A_SMALLTALK := 16r200000.
A_ABSTRACT_OR_INTERFACE := A_ABSTRACT bitOr:A_INTERFACE.
InitialValuePerType := IdentityDictionary new.
InitialValuePerType at:$B put:0.
InitialValuePerType at:$C put:0.
InitialValuePerType at:$D put:0.0.
InitialValuePerType at:$F put:(0.0 asShortFloat).
InitialValuePerType at:$I put:0.
InitialValuePerType at:$J put:0.
InitialValuePerType at:$S put:0.
InitialValuePerType at:$Z put:0.
InitialValuePerType at:$L put:nil.
InitialValuePerType at:$[ put:nil.
"
JavaBehavior initialize
"
"Modified: / 13.11.1998 / 14:09:52 / cg"
! !
!JavaBehavior class methodsFor:'constants'!
A_NATIVE
^ A_NATIVE
"Created: / 16.5.1998 / 01:18:43 / cg"
!
A_PUBLIC
^ A_PUBLIC
"Created: / 13.5.1998 / 13:03:18 / cg"
!
A_STATIC
^ A_STATIC
"Created: / 16.5.1998 / 00:02:07 / cg"
! !
!JavaBehavior class methodsFor:'signature parsing'!
initialValueFromSignature:aSignature
"given a signature, return an initializer value"
|s|
s := aSignature readStream.
^ self initialValueFromStream:s.
"
JavaBehavior initialValueFromSignature:'LObject;'
JavaBehavior initialValueFromSignature:'B'
JavaBehavior initialValueFromSignature:'I'
"
!
initialValueFromStream:s
"parse a fieldTypeSpec - see java doc"
|typeChar|
typeChar := s next.
^ InitialValuePerType at:typeChar ifAbsent:nil.
! !
!JavaBehavior methodsFor:'accessing'!
accessFlags
^ accessFlags
!
constantPool
^ constantPool
!
interfaces
interfaces notNil ifTrue:[
interfaces := interfaces collect:[:clsRef |
clsRef isUnresolved ifTrue:[
clsRef preResolve
] ifFalse:[
clsRef
]
].
].
^ interfaces
! !
!JavaBehavior methodsFor:'compiler interface'!
programmingLanguage
^JavaLanguage instance
"Created: / 26-10-2010 / 23:42:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!JavaBehavior methodsFor:'private accessing'!
makeObsolete
accessFlags := accessFlags bitOr:A_OBSOLETE
"Created: 7.8.1997 / 19:04:48 / cg"
!
markUninitialized
(accessFlags bitAnd:A_INITIALIZED) ~~ 0 ifTrue:[
accessFlags := accessFlags bitXor:A_INITIALIZED
].
!
setAccessFlags:flags
accessFlags := flags.
"Created: 15.4.1996 / 16:42:52 / cg"
!
setConstantPool: aJavaConstantPool
constantPool := aJavaConstantPool.
constantPool ifNotNil:[constantPool owner: self].
"Created: / 15-04-1996 / 16:42:52 / cg"
"Modified: / 22-05-2011 / 13:16:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
setInterfaces:i
i size > 0 ifTrue:[
interfaces := i
] ifFalse:[
interfaces := nil
]
"Modified: 7.4.1997 / 15:44:53 / cg"
! !
!JavaBehavior methodsFor:'queries'!
hasInterface:aJavaInterface
"return true, if I respond to all methods as
required by the argument, an aJavaInterface"
interfaces size > 0 ifTrue:[
self interfaces do:[:if |
aJavaInterface == if ifTrue:[
^ true
].
]
].
superclass isJavaClass ifTrue:[
^ superclass hasInterface:aJavaInterface
].
^ false.
"/ aJavaInterface methodDictionary keysAndValuesDo:[:sel :mthd |
"/ (self canUnderstand:sel) ifFalse:[
"/ ^ false.
"/ ]
"/ ].
^ true
"Modified: / 28.1.1998 / 01:46:16 / cg"
!
isAbstract
"return true, if the receiver is abstract
(i.e. may not have instances)"
^ (accessFlags bitAnd:A_ABSTRACT) ~~ 0
"Modified: / 7.5.1998 / 12:24:42 / cg"
!
isFinal
"return true, if the receiver is final
(i.e. may not be subclassed)"
^ (accessFlags bitAnd:A_FINAL) ~~ 0
"Modified: / 7.5.1998 / 12:24:21 / cg"
!
isInitialized
"return true, if the receiver is initialized"
^ (accessFlags bitAnd:A_INITIALIZED) ~~ 0
"Modified: / 7.5.1998 / 12:23:54 / cg"
!
isInterface
"return true, if the receiver is an interface"
^ (accessFlags bitAnd:A_INTERFACE) ~~ 0
"Modified: / 7.5.1998 / 12:23:39 / cg"
!
isObsolete
"return true, if the receiver is obsolete
Java classes are never."
^ (accessFlags bitAnd:A_OBSOLETE) ~~ 0.
"Modified: 7.8.1997 / 19:04:28 / cg"
!
isPublic
"return true, if the receiver is public"
^ (accessFlags bitAnd:A_PUBLIC) ~~ 0
"Modified: / 7.5.1998 / 12:22:44 / cg"
! !
!JavaBehavior class methodsFor:'documentation'!
version
^ '$Id: /cvs/stx/stx/libjava/JavaBehavior.st,v 1.4 2011/08/18 18:42:48 vrany Exp $'
!
version_CVS
^ '§Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaBehavior.st,v 1.3 2009/10/09 14:04:26 cg Exp §'
!
version_SVN
^ '$Id: JavaBehavior.st,v 1.4 2011/08/18 18:42:48 vrany Exp $'
! !
JavaBehavior initialize!