More work on Java code partitioner.
"
Copyright (c) 2010-2011 Jan Vrany, Jan Kurs & Marcel Hlopko,
SWING Research Group, Czech Technical University
in Prague
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.
"
"{ Package: 'stx:libjava' }"
Method subclass:#ProxyMethod
instanceVariableNames:'body'
classVariableNames:'InstallProxies'
poolDictionaries:''
category:'System-Compiler-Interop'
!
!ProxyMethod class methodsFor:'documentation'!
copyright
"
Copyright (c) 2010-2011 Jan Vrany, Jan Kurs & Marcel Hlopko,
SWING Research Group, Czech Technical University
in Prague
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.
"
!
documentation
"
ProxyMethod is a special method generated by the system
that usually calls other methods. Proxy method are used when
an additional dispatch logic is required and cannot be handled
by native dispatch method not by MOP - such as multiple dispatch
or dynamaic java overload dispatch.
[author:]
Jan Vrany <jan.vrany@fit.cvut.cz>
[instance variables:]
[class variables:]
[see also:]
ProxyMethodCompiler
ProxyMethodNode
JavaLookup (an example how to use this stuff)
"
! !
!ProxyMethod class methodsFor:'initialization'!
initialize
"Invoked at system start or when the class is dynamically loaded."
"/ self makeMetaMethod.
InstallProxies := true.
"Modified: / 23-12-2011 / 14:13:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!ProxyMethod class methodsFor:'accessing'!
installProxies
^InstallProxies
"Created: / 23-12-2011 / 13:08:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
installProxies: aBoolean
InstallProxies := aBoolean
"
InstallProxies := true.
InstallProxies := false
"
"Created: / 23-12-2011 / 13:08:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!ProxyMethod class methodsFor:'misc'!
makeMetaMethod
self flags:((self flags
bitOr:Behavior flagMetaMethod)
bitClear:Behavior flagMethod)
"
GuardedMethod makeNormalMethod
GuardedMethod makeMetaMethod
"
"Created: / 06-12-2011 / 21:19:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
makeNormalMethod
self flags:((self flags
bitOr:Behavior flagMethod)
bitClear:Behavior flagMetaMethod)
"
ProxyMethod makeNormalMethod
ProxyMethod makeMetaMethod
"
"Created: / 06-12-2011 / 21:18:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!ProxyMethod methodsFor:'accessing'!
body
^ body
!
body:aProxyMethodNode
body := aProxyMethodNode.
self recompile.
"Modified: / 14-12-2011 / 21:22:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
category
"return the methods category or nil"
^ #'* proxies *'
"Created: / 16-12-2011 / 20:24:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
getPackage
"return the package-ID of the method"
^self package
"Created: / 16-12-2011 / 20:25:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
interpretWithReceiver: receiver
^self interpretWithReceiver: receiver arguments: #()
"Created: / 06-12-2011 / 21:21:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
interpretWithReceiver: receiver arg: a1
^self interpretWithReceiver: receiver arguments: { a1 }
"Created: / 06-12-2011 / 21:21:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
interpretWithReceiver: receiver arg: a1 arg: a2
^self interpretWithReceiver: receiver arguments: { a1 . a2 }
"Created: / 06-12-2011 / 21:21:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
interpretWithReceiver: receiver arg: a1 arg: a2 arg: a3
^self interpretWithReceiver: receiver arguments: { a1 . a2 . a3 }
"Created: / 06-12-2011 / 21:22:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
interpretWithReceiver: receiver arguments: arguments
^body evaluateWithReceiver: receiver arguments: arguments
"Created: / 06-12-2011 / 21:23:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
package
"return the package-ID of the method (nil is translated to noProject here)"
^#'* proxies *'
"Created: / 16-12-2011 / 20:25:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
source
^String streamContents:[:s|
s nextPut: $"; cr.
s nextPutAll: 'This is a generated proxy method'; cr.
self decompileTo: s. s cr.
s nextPut: $"; cr.
]
"Created: / 23-12-2011 / 13:51:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!ProxyMethod methodsFor:'building'!
addGuard: aGuard
body isNil ifTrue:[
self assert:aGuard fallback notNil
message:'Attempt set guard without fallback'.
] ifFalse:[
self assert:aGuard fallback isNil
message:'Attempt add guard with fallback'.
aGuard fallback: body.
].
self body: aGuard.
"Created: / 06-12-2011 / 21:37:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!ProxyMethod methodsFor:'compiler interface'!
syntaxHighlighterClass
"if #askClass is returned here, my owning class will be asked for the syntaxHighlighter.
if nil is returned, no syntaxHighlighting will be done.
Can be redefined in subclasses (MetaMethod) which use special syntax."
^ nil
"Created: / 23-12-2011 / 13:52:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!ProxyMethod methodsFor:'displaying'!
printStringForBrowserWithSelector:selector inClass:class
^selector , ' * proxy *' asText colorizeAllWith: Color gray
"Created: / 16-12-2011 / 01:16:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!ProxyMethod methodsFor:'testing'!
isProxyMethod
"return true, if the receiver is a proxy method.
True is returned here."
^true.
"Created: / 16-12-2012 / 13:35:08 / Marcel Hlopko <marcel.hlopko@fit.cvut.cz>"
!
isStatic
^self mclass isMetaclass
"Created: / 29-02-2012 / 13:47:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
isSynthetic
^true
"Created: / 13-04-2012 / 16:06:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!ProxyMethod methodsFor:'utilities'!
recompile
"Nothing to do now, will change later"
"Created: / 06-12-2011 / 21:38:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!ProxyMethod class methodsFor:'documentation'!
version_CVS
^ '$Header: /cvs/stx/stx/libjava/ProxyMethod.st,v 1.2 2013-02-25 11:15:32 vrany Exp $'
!
version_HG
^ '$Changeset: <not expanded> $'
!
version_SVN
^ '§Id§'
! !
ProxyMethod initialize!