--- a/JavaLookup.st Sun Nov 18 15:22:21 2012 +0000
+++ b/JavaLookup.st Sun Nov 18 17:09:25 2012 +0000
@@ -306,71 +306,78 @@
!JavaLookup::Smalltalk2Java methodsFor:'lookup'!
-lookupMethodForSelector:selector directedTo:initialSearchClass for:receiver withArguments:argArrayOrNil from:sendingContext ilc: ilc
+lookupMethodForSelector: selector directedTo: initialSearchClass for: receiver withArguments: argArrayOrNil from: sendingContext ilc: ilc
"
- As a courtesy to a Smalltalker, try to map smalltalk selectors to a java ones.
- Returns JavaMethodDescriptor or nil.
- "
- | name nameSizePlusOne candidates finder static cls m |
-
+ As a courtesy to a Smalltalker, try to map smalltalk selectors to a java ones.
+ Returns JavaMethodDescriptor or nil."
+
+ | name nameSizePlusOne candidates finder static cls m |
+ self halt.
name := selector upTo: $:.
nameSizePlusOne := name size + 1.
static := receiver isBehavior.
candidates := OrderedCollection new.
- finder := [:cls|
- cls methodDictionary keysAndValuesDo:[:sel :mthd|
- "candidates may contain a method with same selector ->
- do not add super-class's method"
- (candidates contains:[:each|each selector == sel]) ifFalse:[
- (mthd mclass ~~ ProxyMethod
- and:[((sel size >= nameSizePlusOne) and:[(sel at: nameSizePlusOne) == $( and:[(sel startsWith: name)]])
- and:[mthd descriptor numArgs == argArrayOrNil size]]) ifTrue:[
- candidates add: mthd
- ]
+ finder := [
+ :cls |
+ cls methodDictionary
+ keysAndValuesDo: [
+ :sel :mthd |
+ "candidates may contain a method with same selector ->
+ do not add super-class's method"
+ (candidates contains: [:each | each selector == sel ]) ifFalse: [
+ (mthd mclass ~~ ProxyMethod
+ and: [
+ ((sel size >= nameSizePlusOne)
+ and: [ (sel at: nameSizePlusOne) == $( and: [ (sel startsWith: name) ] ])
+ and: [ mthd descriptor numArgs == argArrayOrNil size ]
+ ])
+ ifTrue: [ candidates add: mthd ]
+ ]
]
- ]
].
-
- "Search class for method candidates"
+ "Search class for method candidates"
cls := initialSearchClass theNonMetaclass.
- static ifTrue:[
- finder value: cls
- ] ifFalse:[
- [ cls notNil and:[cls ~~ JavaObject] ] whileTrue:[
+ static ifTrue: [ finder value: cls ] ifFalse: [
+ [ cls notNil and: [ cls ~~ JavaObject ] ] whileTrue: [
finder value: cls.
cls := cls superclass.
- ]
- ].
-
- candidates notEmpty ifTrue:[
- m := self compileProxyWithSelector: selector in: receiver class calling: candidates.
- ilc notNil ifTrue:[ilc bindTo: m forClass: receiver class].
-
- "Install the proxy"
- self addSelector: selector withMethod: m toClass: receiver class.
-
- ^m.
- ].
-
- "Hmm, hmm, maybe a public field?"
- (argArrayOrNil size < 2) ifTrue:[
- | field |
-
- field := initialSearchClass theNonMetaclass
- lookupFieldFor: name
- static: initialSearchClass isMetaclass
- onlyPublic: true.
- field notNil ifTrue:[
- m := self compileProxyWithSelector: selector in: receiver class accessing: field.
- ilc notNil ifTrue:[ilc bindTo: m forClass: receiver class].
-
- "Install the proxy"
- self addSelector: selector withMethod: m toClass: receiver class.
-
- ^m.
]
].
- ^nil
+ candidates notEmpty ifTrue: [
+ m := self
+ compileProxyWithSelector: selector
+ in: receiver class
+ calling: candidates.
+ ilc notNil ifTrue: [ ilc bindTo: m forClass: receiver class ].
+ "Install the proxy"
+ self
+ addSelector: selector
+ withMethod: m
+ toClass: receiver class.
+ ^ m.
+ ].
+ "Hmm, hmm, maybe a public field?"
+ (argArrayOrNil size < 2) ifTrue: [
+ | field |
+ field := initialSearchClass theNonMetaclass
+ lookupFieldFor: name
+ static: initialSearchClass isMetaclass
+ onlyPublic: true.
+ field notNil ifTrue: [
+ m := self
+ compileProxyWithSelector: selector
+ in: receiver class
+ accessing: field.
+ ilc notNil ifTrue: [ ilc bindTo: m forClass: receiver class ].
+ "Install the proxy"
+ self
+ addSelector: selector
+ withMethod: m
+ toClass: receiver class.
+ ^ m.
+ ]
+ ].
+ ^ nil
"Created: / 21-02-2011 / 13:38:55 / kursjan <kursjan@fit.cvut.cz>"
"Modified: / 29-08-2011 / 20:38:21 / kursjan"
@@ -380,6 +387,7 @@
"Modified: / 01-01-2012 / 19:58:59 / kursjan <kursjan@fit.cvut.cz>"
"Modified (comment): / 02-01-2012 / 10:35:25 / kursjan <kursjan@fit.cvut.cz>"
"Modified: / 17-03-2012 / 17:22:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 18-11-2012 / 18:08:39 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
! !
!JavaLookup::Smalltalk2Java methodsFor:'lookup (old)'!