--- a/JavaClass.st Wed Jul 30 10:54:27 1997 +0000
+++ b/JavaClass.st Wed Jul 30 14:41:13 1997 +0000
@@ -147,11 +147,11 @@
nameComponents := fullName asCollectionOfSubstringsSeparatedBy:$/.
nameComponents size <= 1 ifTrue:[
- ^ fullName
+ ^ 'java' "/ fullName
].
^ ((nameComponents asStringWith:$/ from:1 to:(nameComponents size - 1))) replaceAll:$/ by:$.
- "Modified: 22.3.1997 / 14:39:42 / cg"
+ "Modified: 30.7.1997 / 15:35:22 / cg"
!
constantPool
@@ -227,7 +227,11 @@
"
(Java at:'java.awt.Frame') source
+ (Java at:'ArcTest') source
+ (Java at:'ArcCanvas') source
"
+
+ "Modified: 30.7.1997 / 14:31:01 / cg"
!
sourceFile
@@ -289,11 +293,14 @@
m := self compiledMethodAt:#'<clinit>()V'.
m notNil ifTrue:[
"/ 'calling clinit() of ' print. self fullName printNL.
- [
- self invokeJavaMethod:m sender:thisContext.
- ] valueOnUnwindDo:[
- initialized := false
- ]
+ [
+ self
+ invokeJavaMethod:m
+ sender:thisContext
+ selector:#'<clinit>()V'.
+ ] valueOnUnwindDo:[
+ initialized := false
+ ]
] ifFalse:[
"/ self fullName print. ' has no clinit()' printNL.
].
@@ -308,6 +315,8 @@
(Java classNamed:'java/io/FileDescriptor') classInit
(Java classNamed:'java.util.Properties') classInit
"
+
+ "Modified: 30.7.1997 / 13:28:38 / cg"
!
initializeStaticFields
@@ -437,13 +446,16 @@
method := self lookupMethodFor:selector.
method notNil ifTrue:[
- ^ self invokeJavaMethod:method sender:aContext
+ ^ self
+ invokeJavaMethod:method
+ sender:aContext
+ selector:selector
].
^ self doesNotUnderstand:(Message selector:selector)
- "Modified: 7.4.1997 / 22:50:46 / cg"
"Created: 7.4.1997 / 22:52:10 / cg"
+ "Modified: 30.7.1997 / 13:29:09 / cg"
!
invokeJava:selector with:arg
@@ -454,11 +466,15 @@
method := self lookupMethodFor:selector.
method notNil ifTrue:[
- ^ self invokeJavaMethod:method with:arg "/ sender:nil
+ ^ self
+ invokeJavaMethod:method
+ sender:thisContext
+ selector:selector
+ with:arg
].
^ self doesNotUnderstand:(Message selector:selector)
- "Modified: 7.4.1997 / 22:50:38 / cg"
+ "Modified: 30.7.1997 / 13:37:58 / cg"
!
invokeJava:selector with:arg sender:aContext
@@ -469,33 +485,28 @@
method := self lookupMethodFor:selector.
method notNil ifTrue:[
- ^ self invokeJavaMethod:method with:arg sender:aContext
+ ^ self
+ invokeJavaMethod:method
+ sender:aContext
+ selector:selector
+ with:arg
].
^ self doesNotUnderstand:(Message selector:selector)
- "Modified: 7.4.1997 / 22:50:38 / cg"
"Created: 7.4.1997 / 22:52:51 / cg"
+ "Modified: 30.7.1997 / 13:39:45 / cg"
!
-invokeJavaMethod:aJavaMethod
- "invoke a static java method, without arguments"
-
- ^ self
- invokeJavaMethod:aJavaMethod sender:thisContext sender
-
- "Modified: 7.4.1997 / 22:47:34 / cg"
-!
-
-invokeJavaMethod:aJavaMethod sender:aContext
+invokeJavaMethod:aJavaMethod sender:aContext selector:sel
"invoke a static java method, without arguments"
|i val|
aJavaMethod numArgs ~~ 0 ifTrue:[
- self halt:'need arguments'
+ self halt:'need arguments'
].
aJavaMethod isStatic ifFalse:[
- self halt:'non-static function'
+ self halt:'non-static function'
].
i := JavaInterpreter new.
@@ -503,18 +514,30 @@
^ JavaObject convertJavaObject:val signature:(aJavaMethod retValSignature)
-
+ "Modified: 30.7.1997 / 12:01:52 / cg"
+ "Created: 30.7.1997 / 13:34:33 / cg"
!
-invokeJavaMethod:aJavaMethod with:arg
- "invoke a static java method, with one argument"
+invokeJavaMethod:aJavaMethod sender:aContext selector:sel with:arg1
+ "invoke a static java method, without arguments"
+
+ |i val|
- ^ self
- invokeJavaMethod:aJavaMethod
- with:arg
- sender:thisContext sender
+ aJavaMethod numArgs ~~ 1 ifTrue:[
+ self halt:'need arguments'
+ ].
+ aJavaMethod isStatic ifFalse:[
+ self halt:'non-static function'
+ ].
- "Modified: 7.4.1997 / 22:53:45 / cg"
+ i := JavaInterpreter new.
+ i push:arg1.
+ val := i interpret:aJavaMethod sender:aContext.
+
+ ^ JavaObject convertJavaObject:val signature:(aJavaMethod retValSignature)
+
+ "Created: 30.7.1997 / 13:34:33 / cg"
+ "Modified: 30.7.1997 / 13:38:46 / cg"
!
invokeJavaMethod:aJavaMethod with:arg sender:aContext
@@ -796,31 +819,95 @@
isUnresolved
^ false
+!
+
+supportsMethodCategories
+ ^ self == JavaClass
+
+ "Created: 30.7.1997 / 14:58:58 / cg"
! !
!JavaClass methodsFor:'smalltalk interface'!
invoke:selector
- "send a message, without args"
+ "send a message, without args."
|method cls sel|
sel := selector asSymbolIfInterned.
sel notNil ifTrue:[
- cls := self.
- [cls notNil and:[cls ~~ JavaObject]] whileTrue:[
- cls methodDictionary keysAndValuesDo:[:sel :aMethod |
+ cls := self.
+ [cls notNil and:[cls ~~ JavaObject]] whileTrue:[
+ cls methodDictionary keysAndValuesDo:[:sel :aMethod |
"/ aMethod name printNL.
- (aMethod name == selector
- or:[aMethod signatureNameWithoutReturnType = selector]) ifTrue:[
- aMethod numArgs == 0 ifTrue:[
- ^ self invokeJavaMethod:aMethod sender:thisContext
- ]
- ]
- ].
- cls := cls superclass.
- ].
+
+ (aMethod name == selector
+ or:[aMethod signatureNameWithoutReturnType = selector]) ifTrue:[
+ aMethod numArgs == 0 ifTrue:[
+ ^ self
+ invokeJavaMethod:aMethod
+ sender:thisContext
+ selector:selector
+ ]
+ ]
+ ].
+ cls := cls superclass.
+ ].
+ ].
+
+ ^ self doesNotUnderstand:(Message selector:selector)
+
+ "
+ |stack|
+
+ stack := (Java at:'java/util/Stack') basicNew.
+ stack invoke:#'<init>'.
+ "
+ "
+ |stack|
+
+ stack := (Java at:'java/util/Stack') basicNew.
+ stack invoke:#isEmpty.
+ "
+ "
+ |stack|
+
+ stack := (Java at:'java/util/Stack') basicNew.
+ stack invoke:#size.
+ "
+
+ "Created: 30.7.1997 / 14:06:50 / cg"
+ "Modified: 30.7.1997 / 14:07:55 / cg"
+!
+
+invoke:selector signature:signature
+ "send a message, without args."
+
+ |method cls sel sig|
+
+ sel := selector asSymbolIfInterned.
+ sel notNil ifTrue:[
+ sig := signature asSymbolIfInterned.
+ sig notNil ifTrue:[
+ cls := self.
+ [cls notNil and:[cls ~~ JavaObject]] whileTrue:[
+ cls methodDictionary keysAndValuesDo:[:sel :aMethod |
+
+ aMethod name == selector ifTrue:[
+ aMethod signature == signature ifTrue:[
+ aMethod numArgs == 0 ifTrue:[
+ ^ self
+ invokeJavaMethod:aMethod
+ sender:thisContext
+ selector:selector
+ ]
+ ]
+ ]
+ ].
+ cls := cls superclass.
+ ].
+ ].
].
^ self doesNotUnderstand:(Message selector:selector)
@@ -844,38 +931,215 @@
stack invoke:#size.
"
+ "Modified: 30.7.1997 / 14:07:55 / cg"
+ "Created: 30.7.1997 / 14:12:29 / cg"
+!
+invoke:selector signature:signature with:arg
+ "send a message, with 1 arg1."
+
+ |method cls sel sig|
+
+ sel := selector asSymbolIfInterned.
+ sel notNil ifTrue:[
+ sig := signature asSymbolIfInterned.
+ sig notNil ifTrue:[
+ cls := self.
+ [cls notNil and:[cls ~~ JavaObject]] whileTrue:[
+ cls methodDictionary keysAndValuesDo:[:mFullSelector :aMethod |
+
+ aMethod name == sel ifTrue:[
+ aMethod signature == sig ifTrue:[
+ aMethod numArgs == 1 ifTrue:[
+ ^ self
+ invokeJavaMethod:aMethod
+ sender:thisContext
+ selector:selector
+ with:arg
+ ]
+ ]
+ ]
+ ].
+ cls := cls superclass.
+ ].
+ ].
+ ].
+
+ ^ self doesNotUnderstand:(Message selector:selector)
+
+ "
+ |stack|
+
+ stack := (Java at:'java/util/Stack') basicNew.
+ stack invoke:#'<init>'.
+ "
+ "
+ |stack|
+
+ stack := (Java at:'java/util/Stack') basicNew.
+ stack invoke:#isEmpty.
+ "
+ "
+ |stack|
+
+ stack := (Java at:'java/util/Stack') basicNew.
+ stack invoke:#size.
+ "
+
+ "Created: 30.7.1997 / 14:13:30 / cg"
+ "Modified: 30.7.1997 / 14:19:57 / cg"
!
invoke:selector with:arg
- "send a message, with one args"
+ "send a message, with one arg"
+
+ |method cls sel|
+
+ sel := selector asSymbolIfInterned.
+ sel notNil ifTrue:[
+ cls := self.
+ [cls notNil and:[cls ~~ JavaObject]] whileTrue:[
+ cls methodDictionary keysAndValuesDo:[:sel :aMethod |
+
+"/ aMethod name printNL.
+ (aMethod name == selector
+ or:[aMethod signatureNameWithoutReturnType = selector]) ifTrue:[
+ aMethod numArgs == 1 ifTrue:[
+ ^ self
+ invokeJavaMethod:aMethod
+ sender:thisContext
+ selector:selector
+ with:arg
+ ]
+ ]
+ ].
+ cls := cls superclass.
+ ].
+ ].
+
+ ^ self doesNotUnderstand:(Message selector:selector)
+
+ "Modified: 30.7.1997 / 13:59:49 / cg"
+!
+
+invoke:selector with:arg1 with:arg2
+ "send a message, with two args"
|method cls sel|
sel := selector asSymbolIfInterned.
sel notNil ifTrue:[
- cls := self.
- [cls notNil and:[cls ~~ JavaObject]] whileTrue:[
- cls methodDictionary keysAndValuesDo:[:sel :aMethod |
+ cls := self.
+ [cls notNil and:[cls ~~ JavaObject]] whileTrue:[
+ cls methodDictionary keysAndValuesDo:[:sel :aMethod |
"/ aMethod name printNL.
- (aMethod name == selector
- or:[aMethod signatureNameWithoutReturnType = selector]) ifTrue:[
- aMethod numArgs == 1 ifTrue:[
- ^ self
- invokeJavaMethod:aMethod
- with:arg
- sender:thisContext
- ]
- ]
- ].
- cls := cls superclass.
- ].
+ (aMethod name == selector
+ or:[aMethod signatureNameWithoutReturnType = selector]) ifTrue:[
+ aMethod numArgs == 2 ifTrue:[
+ ^ self
+ invokeJavaMethod:aMethod
+ sender:thisContext
+ selector:selector
+ with:arg1
+ with:arg2
+ ]
+ ]
+ ].
+ cls := cls superclass.
+ ].
].
^ self doesNotUnderstand:(Message selector:selector)
- "Modified: 7.4.1997 / 22:54:21 / cg"
+ "Modified: 30.7.1997 / 13:39:15 / cg"
+ "Created: 30.7.1997 / 14:00:09 / cg"
+!
+
+invoke:selector withAll:args
+ "send a message, with a number of args"
+
+ |method cls sel numArgGiven|
+
+ numArgGiven := args size.
+
+ sel := selector asSymbolIfInterned.
+ sel notNil ifTrue:[
+ cls := self.
+ [cls notNil and:[cls ~~ JavaObject]] whileTrue:[
+ cls methodDictionary keysAndValuesDo:[:sel :aMethod |
+
+"/ aMethod name printNL.
+ (aMethod name == selector
+ or:[aMethod signatureNameWithoutReturnType = selector]) ifTrue:[
+ aMethod numArgs == numArgGiven ifTrue:[
+ ^ self
+ invokeJavaMethod:aMethod
+ sender:thisContext
+ selector:selector
+ withAll:args
+ ]
+ ]
+ ].
+ cls := cls superclass.
+ ].
+ ].
+
+ ^ self doesNotUnderstand:(Message selector:selector)
+
+ "Modified: 30.7.1997 / 13:39:15 / cg"
+ "Created: 30.7.1997 / 14:00:53 / cg"
+!
+
+invokeSignature:signature
+ "send a message, without args."
+
+ |method cls sel|
+
+ sel := signature asSymbolIfInterned.
+ sel notNil ifTrue:[
+ cls := self.
+ [cls notNil and:[cls ~~ JavaObject]] whileTrue:[
+ cls methodDictionary keysAndValuesDo:[:sel :aMethod |
+
+"/ aMethod name printNL.
+
+ aMethod signatureName = signature ifTrue:[
+ aMethod numArgs == 0 ifTrue:[
+ ^ self
+ invokeJavaMethod:aMethod
+ sender:thisContext
+ selector:signature
+ ]
+ ]
+ ].
+ cls := cls superclass.
+ ].
+ ].
+
+ ^ self doesNotUnderstand:(Message selector:signature)
+
+ "
+ |stack|
+
+ stack := (Java at:'java/util/Stack') basicNew.
+ stack invoke:#'<init>'.
+ "
+ "
+ |stack|
+
+ stack := (Java at:'java/util/Stack') basicNew.
+ stack invoke:#isEmpty.
+ "
+ "
+ |stack|
+
+ stack := (Java at:'java/util/Stack') basicNew.
+ stack invoke:#size.
+ "
+
+ "Modified: 30.7.1997 / 14:07:55 / cg"
+ "Created: 30.7.1997 / 14:09:31 / cg"
!
methodMatching:aSmalltalkSelector
@@ -902,6 +1166,6 @@
!JavaClass class methodsFor:'documentation'!
version
- ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaClass.st,v 1.49 1997/07/29 19:03:50 cg Exp $'
+ ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaClass.st,v 1.50 1997/07/30 14:40:26 cg Exp $'
! !
JavaClass initialize!
--- a/JavaDecompiler.st Wed Jul 30 10:54:27 1997 +0000
+++ b/JavaDecompiler.st Wed Jul 30 14:41:13 1997 +0000
@@ -321,9 +321,10 @@
interfaces|
pckgName := aJavaClass package.
-
- s nextPutAll:'package ' , (pckgName copy replaceAll:$/ by:$.).
- s nextPutAll:';'; cr; cr.
+ pckgName ~= aJavaClass name ifTrue:[
+ s nextPutAll:'package ' , (pckgName copy replaceAll:$/ by:$.).
+ s nextPutAll:';'; cr; cr.
+ ].
needCR := false.
aJavaClass isPublic ifTrue:[
@@ -517,7 +518,7 @@
s nextPutAll:'}'; cr.
"Created: 22.3.1997 / 14:29:37 / cg"
- "Modified: 25.3.1997 / 19:24:05 / cg"
+ "Modified: 30.7.1997 / 15:27:53 / cg"
! !
!JavaDecompiler class methodsFor:'decompiling'!
@@ -555,9 +556,9 @@
endPC := code size.
endPC == 0 ifTrue:[
javaMethod isNative ifTrue:[
- outStream nextPutAll:'native method'; cr
+ outStream nextPutAll:'// native method'; cr
] ifFalse:[
- outStream nextPutAll:'no bytecode'; cr
+ outStream nextPutAll:'{} // no bytecode'; cr
].
^ self
].
@@ -587,7 +588,7 @@
]
"Created: 16.4.1996 / 14:59:29 / cg"
- "Modified: 20.3.1997 / 13:57:24 / cg"
+ "Modified: 30.7.1997 / 16:13:04 / cg"
! !
!JavaDecompiler methodsFor:'operand decoding'!
@@ -830,6 +831,6 @@
!JavaDecompiler class methodsFor:'documentation'!
version
- ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaDecompiler.st,v 1.25 1997/03/25 18:26:35 cg Exp $'
+ ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaDecompiler.st,v 1.26 1997/07/30 14:40:09 cg Exp $'
! !
JavaDecompiler initialize!
--- a/JavaMethod.st Wed Jul 30 10:54:27 1997 +0000
+++ b/JavaMethod.st Wed Jul 30 14:41:13 1997 +0000
@@ -437,6 +437,30 @@
"Created: 18.3.1997 / 11:06:22 / cg"
!
+specTextFromSignature:aSignature withName:name
+ "given a signature, return a spec as boldified text"
+
+ |s argSpec retvalSpec|
+
+ s := aSignature readStream.
+ s next ~~ $( ifTrue:[self halt. ^ name].
+
+ argSpec := self argSpecFromStream:s.
+
+ s next ~~ $) ifTrue:[self halt. ^ name].
+
+ retvalSpec := self retvalSpecFromStream:s.
+
+ ^ retvalSpec , ' ' , (name asText allBold) , ' (' , argSpec , ')'
+
+ "
+ JavaMethod specTextFromSignature:'(LObject;)V' withName:'foo'
+ JavaMethod specTextFromSignature:'(BB)S' withName:'foo'
+ "
+
+ "Modified: 30.7.1997 / 14:40:12 / cg"
+!
+
specWithArgsFromSignature:aSignature withName:name in:aPackage
"given a signature, return a spec"
@@ -525,8 +549,10 @@
|s|
s := '' writeStream.
- self decompileTo:s.
+ self decompileSourceTo:s.
^ s contents
+
+ "Modified: 30.7.1997 / 16:27:55 / cg"
!
exceptionHandlerTable
@@ -656,6 +682,12 @@
"Modified: 30.7.1997 / 12:43:00 / cg"
!
+previousVersion
+ ^ nil
+
+ "Created: 30.7.1997 / 15:56:18 / cg"
+!
+
retValSignature
^ self class retValSpecFromSignature:signature
@@ -801,12 +833,26 @@
sourceFilename
^ javaClass sourceFile
+!
+
+sourceLineNumber
+ ForceByteCodeDisplay == true ifTrue:[
+ ^ 1
+ ].
+
+ lineNumberTable notNil ifTrue:[
+ ^ lineNumberTable at:2
+ ].
+
+ ^ 1
+
+ "Created: 30.7.1997 / 15:40:45 / cg"
+ "Modified: 30.7.1997 / 15:46:12 / cg"
! !
!JavaMethod methodsFor:'decompiling'!
-decompileTo:aStream
- JavaDecompiler decompile:self to:aStream.
+decompileSourceTo:aStream
self isNative ifFalse:[
self isAbstract ifFalse:[
aStream cr; cr.
@@ -815,6 +861,8 @@
aStream nextPutAll:'error while decompiling:'.
aStream cr; cr; spaces:4.
aStream nextPutAll:ex errorString.
+
+ JavaDecompiler decompile:self to:aStream.
ex return
] do:[
aStream nextPutAll:(JavaDeparser decompile:self).
@@ -823,7 +871,14 @@
].
^ true
- "Modified: 20.3.1997 / 14:04:48 / cg"
+ "Modified: 30.7.1997 / 16:19:28 / cg"
+ "Created: 30.7.1997 / 16:28:09 / cg"
+!
+
+decompiler
+ ^ JavaDecompiler
+
+ "Created: 30.7.1997 / 16:36:48 / cg"
! !
!JavaMethod methodsFor:'methodref interchangability'!
@@ -891,12 +946,13 @@
"/ self isBreakpointed ifTrue:[
"/ ^ (LabelAndIcon '!! ' , self signatureName
"/ ].
+
name = #'<init>' ifTrue:[
- ^ self class specFromSignature:signature withName:(javaClass name).
+ ^ self class specTextFromSignature:signature withName:(javaClass name).
].
- ^ self signatureName
+ ^ self signatureNameText
- "Modified: 7.4.1997 / 17:28:00 / cg"
+ "Modified: 30.7.1997 / 14:40:42 / cg"
!
shortDisplayString
@@ -925,6 +981,14 @@
"Created: 18.3.1997 / 11:11:01 / cg"
!
+signatureNameText
+ "return a text to be used when browsing"
+
+ ^ self class specTextFromSignature:signature withName:name
+
+ "Created: 30.7.1997 / 14:40:29 / cg"
+!
+
signatureNameWithArgsIn:aPackage
"return a string to be used when browsing"
@@ -970,6 +1034,15 @@
^ (accessFlags bitAnd:16r0010) ~~ 0
!
+isIgnored
+ "not really a java attribute;
+ added to allow browsing"
+
+ ^ false.
+
+ "Created: 30.7.1997 / 15:34:33 / cg"
+!
+
isNOOPMethod
isNOOPMethod isNil ifTrue:[
self checkForNOOPMethod
@@ -1098,6 +1171,6 @@
!JavaMethod class methodsFor:'documentation'!
version
- ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaMethod.st,v 1.44 1997/07/30 10:54:27 cg Exp $'
+ ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaMethod.st,v 1.45 1997/07/30 14:39:30 cg Exp $'
! !
JavaMethod initialize!
--- a/JavaObject.st Wed Jul 30 10:54:27 1997 +0000
+++ b/JavaObject.st Wed Jul 30 14:41:13 1997 +0000
@@ -111,6 +111,224 @@
]
! !
+!JavaObject methodsFor:'interpreter interface'!
+
+invoke:selector interpreter:i sender:aContext
+ "send a message, without args"
+
+ |method cls sel|
+
+ method := self lookupMethod:selector numArgs:0.
+ method notNil ifTrue:[
+ ^ self
+ invokeJavaMethod:method
+ interpreter:i
+ sender:aContext
+ selector:selector
+ ].
+
+ ^ super doesNotUnderstand:(Message selector:selector)
+
+ "
+ |stack|
+
+ stack := (Java at:'java/util/Stack') basicNew.
+ stack invoke:#'<init>'.
+ "
+ "
+ |stack|
+
+ stack := (Java at:'java/util/Stack') new.
+ stack invoke:#isEmpty.
+ "
+ "
+ |stack|
+
+ stack := (Java at:'java/util/Stack') new.
+ stack invoke:#size.
+ "
+
+ "Modified: 30.7.1997 / 13:27:48 / cg"
+!
+
+invoke:selector interpreter:i sender:aContext with:argument
+ "send a message, with 1 argument.
+ TEMPORARY: This method needs more work."
+
+ |sel method cls argClass jSel|
+
+ sel := selector asSymbolIfInterned.
+ sel notNil ifTrue:[
+ "/
+ "/ hard to do - must find a matching method probably
+ "/
+ (argument isKindOf:JavaObject) ifTrue:[
+ argClass := argument class.
+ ] ifFalse:[
+ "/
+ "/ map to Java:
+ "/ String -> [c
+ "/
+ (argument isMemberOf:String) ifTrue:[
+ jSel := (selector , '([C)V') asSymbolIfInterned.
+ jSel notNil ifTrue:[
+ ^ self
+ invoke:jSel
+ interpreter:i
+ sender:aContext
+ with:argument
+ ]
+ ]
+ ].
+
+ method := self lookupMethod:sel numArgs:1.
+ method notNil ifTrue:[
+ ^ self
+ invokeJavaMethod:method
+ interpreter:i
+ sender:aContext
+ selector:sel
+ with:argument
+ ].
+
+"/ cls := self class.
+"/ [cls notNil and:[cls ~~ JavaObject]] whileTrue:[
+"/ cls methodDictionary keysAndValuesDo:[:sel :aMethod |
+"/ aMethod name == sel ifTrue:[
+"/ aMethod numArgs == 1 ifTrue:[
+"/ "/
+"/ "/ this is not completely correct:
+"/ "/ must look for the best type-match,
+"/ "/ (especially: have to look for best match
+"/ "/ over whole superclass chain ...)
+"/ "/ for now take the first with matching number of args
+"/ "/
+"/ ^ self invokeJavaMethod:aMethod with:argument
+"/ ]
+"/ ]
+"/ ].
+"/ cls := cls superclass.
+"/ ].
+ ].
+
+ ^ super doesNotUnderstand:(Message selector:selector)
+
+ "
+ |stack|
+
+ stack := (Java at:'java/util/Stack') new.
+ stack invoke:#push with:1.
+ "
+ "
+ |stack|
+
+ stack := (Java at:'java/util/Stack') new.
+ stack invoke:#push with:1.
+ stack invoke:#push with:2.
+ stack invoke:#pop.
+ stack invoke:#pop.
+ stack invoke:#pop.
+ "
+
+ "Modified: 30.7.1997 / 13:46:39 / cg"
+!
+
+invoke:selector interpreter:i sender:aContext with:arg1 with:arg2
+ "send a message, with 2 arguments.
+ TEMPORARY: This method needs more work."
+
+ |sel method cls argClass jSel|
+
+ sel := selector asSymbolIfInterned.
+ sel notNil ifTrue:[
+ method := self lookupMethod:sel numArgs:2.
+ method notNil ifTrue:[
+ ^ self
+ invokeJavaMethod:method
+ interpreter:i
+ sender:aContext
+ selector:selector
+ with:arg1 with:arg2
+ ].
+ ].
+
+ ^ super doesNotUnderstand:(Message selector:selector)
+
+ "Modified: 30.7.1997 / 13:47:05 / cg"
+!
+
+invoke:selector interpreter:i sender:aContext with:arg1 with:arg2 with:arg3
+ "send a message, with 3 arguments.
+ TEMPORARY: This method needs more work."
+
+ |sel method cls argClass jSel|
+
+ sel := selector asSymbolIfInterned.
+ sel notNil ifTrue:[
+ method := self lookupMethod:sel numArgs:3.
+ method notNil ifTrue:[
+ ^ self
+ invokeJavaMethod:method
+ interpreter:i
+ sender:aContext
+ selector:selector
+ with:arg1 with:arg2 with:arg3
+ ].
+ ].
+
+ ^ super doesNotUnderstand:(Message selector:selector)
+
+ "Modified: 30.7.1997 / 13:47:22 / cg"
+!
+
+invoke:selector interpreter:i sender:aContext with:arg1 with:arg2 with:arg3 with:arg4
+ "send a message, with 4 arguments.
+ TEMPORARY: This method needs more work."
+
+ |sel method cls argClass jSel|
+
+ sel := selector asSymbolIfInterned.
+ sel notNil ifTrue:[
+ method := self lookupMethod:sel numArgs:4.
+ method notNil ifTrue:[
+ ^ self
+ invokeJavaMethod:method
+ interpreter:i
+ sender:aContext
+ selector:selector
+ with:arg1 with:arg2 with:arg3 with:arg4
+ ].
+ ].
+
+ ^ super doesNotUnderstand:(Message selector:selector)
+
+ "Modified: 30.7.1997 / 13:47:45 / cg"
+!
+
+invoke:selector interpreter:i sender:aContext withAll:arguments
+ "send a message, with arguments.
+ TEMPORARY: This method needs more work."
+
+ |sel method cls argClass jSel|
+
+ sel := selector asSymbolIfInterned.
+ sel notNil ifTrue:[
+ method := self lookupMethod:sel numArgs:arguments size.
+ method notNil ifTrue:[
+ ^ self
+ invokeJavaMethod:method
+ interpreter:i
+ sender:aContext
+ selector:selector
+ withAll:arguments
+ ].
+ ].
+
+ ^ super doesNotUnderstand:(Message selector:selector)
+
+ "Modified: 30.7.1997 / 13:48:02 / cg"
+! !
+
!JavaObject methodsFor:'message sending'!
doesNotUnderstand:aMessage
@@ -133,91 +351,35 @@
].
^ super doesNotUnderstand:aMessage
- "Modified: 18.3.1997 / 11:47:16 / cg"
-!
-
-invokeJava:selector
- "send javaSelector (name+sig) message, without arguments"
-
- |method|
-
- method := self class lookupMethodFor:selector.
- method notNil ifTrue:[
- ^ self invokeJavaMethod:method sender:thisContext
- ].
-
- ^ super doesNotUnderstand:(Message selector:selector)
-
- "Modified: 1.2.1997 / 21:47:11 / cg"
+ "Modified: 30.7.1997 / 13:46:01 / cg"
!
-invokeJava:selector interpreter:i sender:s with:arg1 with:arg2
- "send javaSelector (name+sig) message, with 2 arguments"
-
- |method|
-
- method := self class lookupMethodFor:selector.
- method notNil ifTrue:[
- ^ self
- invokeJavaMethod:method
- interpreter:i
- sender:s
- with:arg1
- with:arg2
- ].
- ^ super doesNotUnderstand:(Message selector:selector)
-
- "Modified: 18.3.1997 / 11:47:37 / cg"
-!
-
-invokeJava:selector with:arg
- "send javaSelector (name+sig) message, with 1 argument"
-
- |method|
-
- method := self class lookupMethodFor:selector.
- method notNil ifTrue:[
- ^ self
- invokeJavaMethod:method
- with:arg
- ].
- ^ super doesNotUnderstand:(Message selector:selector)
-
- "Modified: 18.3.1997 / 11:47:46 / cg"
-!
-
-invokeJavaMethod:aJavaMethod
- "invoke java method, without arguments"
-
- ^ self
- invokeJavaMethod:aJavaMethod
- interpreter:JavaInterpreter new
- sender:thisContext sender.
-
- "Modified: 18.3.1997 / 11:46:07 / cg"
-!
-
-invokeJavaMethod:aJavaMethod interpreter:i sender:aContext
- "invoke a java method, without arguments"
+invokeJavaMethod:aJavaMethod interpreter:i sender:s selector:sel
+ "invoke a java method, without arguments."
|val|
aJavaMethod numArgs ~~ 0 ifTrue:[
- self halt:'need arguments'
+ self halt:'argument count'
].
aJavaMethod isStatic ifTrue:[
self halt:'static function'
].
-"/ i := JavaInterpreter new.
+ val := aJavaMethod valueWithReceiver:self arguments:#() selector:sel.
+ val notNil ifTrue:[^ val].
+
i push:self.
- val := i interpret:aJavaMethod sender:aContext.
+ val := i interpret:aJavaMethod sender:s.
^ JavaObject convertJavaObject:val signature:(aJavaMethod retValSignature)
+
+ "Modified: 30.7.1997 / 13:20:29 / cg"
+ "Created: 30.7.1997 / 13:37:25 / cg"
!
-invokeJavaMethod:aJavaMethod interpreter:i sender:s with:arg1
+invokeJavaMethod:aJavaMethod interpreter:i sender:s selector:sel with:arg1
"invoke a java method, with two arguments.
CAVEAT: these cannot be long or doubles currently."
@@ -230,6 +392,9 @@
self halt:'static function'
].
+ val := aJavaMethod valueWithReceiver:self arguments:(Array with:arg1) selector:sel.
+ val notNil ifTrue:[^ val].
+
i push:self.
i push:arg1.
@@ -237,6 +402,36 @@
^ JavaObject convertJavaObject:val signature:(aJavaMethod retValSignature)
+ "Modified: 30.7.1997 / 13:20:35 / cg"
+ "Created: 30.7.1997 / 13:41:01 / cg"
+!
+
+invokeJavaMethod:aJavaMethod interpreter:i sender:s selector:sel with:arg1 with:arg2
+ "invoke a java method, with two arguments.
+ CAVEAT: these cannot be long or doubles currently."
+
+ |val|
+
+ aJavaMethod numArgs ~~ 2 ifTrue:[
+ self halt:'argument count'
+ ].
+ aJavaMethod isStatic ifTrue:[
+ self halt:'static function'
+ ].
+
+ val := aJavaMethod valueWithReceiver:self arguments:(Array with:arg1 with:arg2) selector:sel.
+ val notNil ifTrue:[^ val].
+
+ i push:self.
+ i push:arg1.
+ i push:arg2.
+
+ val := i interpret:aJavaMethod sender:s.
+
+ ^ JavaObject convertJavaObject:val signature:(aJavaMethod retValSignature)
+
+ "Modified: 30.7.1997 / 13:20:35 / cg"
+ "Created: 30.7.1997 / 13:36:02 / cg"
!
invokeJavaMethod:aJavaMethod interpreter:i sender:s with:arg1 with:arg2
@@ -252,6 +447,9 @@
self halt:'static function'
].
+ val := aJavaMethod valueWithReceiver:self arguments:(Array with:arg1 with:arg2).
+ val notNil ifTrue:[^ val].
+
i push:self.
i push:arg1.
i push:arg2.
@@ -260,6 +458,7 @@
^ JavaObject convertJavaObject:val signature:(aJavaMethod retValSignature)
+ "Modified: 30.7.1997 / 13:20:35 / cg"
!
invokeJavaMethod:aJavaMethod interpreter:i sender:s with:arg1 with:arg2 with:arg3
@@ -275,6 +474,9 @@
self halt:'static function'
].
+ val := aJavaMethod valueWithReceiver:self arguments:(Array with:arg1 with:arg2 with:arg3).
+ val notNil ifTrue:[^ val].
+
i push:self.
i push:arg1.
i push:arg2.
@@ -284,6 +486,7 @@
^ JavaObject convertJavaObject:val signature:(aJavaMethod retValSignature)
+ "Modified: 30.7.1997 / 13:20:44 / cg"
!
invokeJavaMethod:aJavaMethod interpreter:i sender:s with:arg1 with:arg2 with:arg3 with:arg4
@@ -299,6 +502,9 @@
self halt:'static function'
].
+ val := aJavaMethod valueWithReceiver:self arguments:(Array with:arg1 with:arg2 with:arg3 with:arg4).
+ val notNil ifTrue:[^ val].
+
i push:self.
i push:arg1.
i push:arg2.
@@ -309,6 +515,7 @@
^ JavaObject convertJavaObject:val signature:(aJavaMethod retValSignature)
+ "Modified: 30.7.1997 / 13:20:51 / cg"
!
invokeJavaMethod:aJavaMethod interpreter:i sender:s withAll:args
@@ -324,6 +531,9 @@
self halt:'static function'
].
+ val := aJavaMethod valueWithReceiver:self arguments:args.
+ val notNil ifTrue:[^ val].
+
i push:self.
args do:[:arg |
i push:arg.
@@ -333,28 +543,21 @@
^ JavaObject convertJavaObject:val signature:(aJavaMethod retValSignature)
-!
-
-invokeJavaMethod:aJavaMethod sender:aContext
- "invoke a java method, without arguments"
-
- ^ self invokeJavaMethod:aJavaMethod interpreter:JavaInterpreter new sender:aContext
-!
-
-invokeJavaMethod:aJavaMethod with:arg
- "invoke a java method, with one argument.
- CAVEAT: this cannot be a long or doubles currently."
-
- ^ self invokeJavaMethod:aJavaMethod interpreter:JavaInterpreter new sender:thisContext sender with:arg
-
+ "Modified: 30.7.1997 / 13:20:58 / cg"
!
invokeJavaMethod:aJavaMethod with:arg1 with:arg2
"invoke a java method, with two arguments.
CAVEAT: these cannot be long or doubles currently."
- ^ self invokeJavaMethod:aJavaMethod interpreter:JavaInterpreter new sender:thisContext sender with:arg1 with:arg2
+ ^ self
+ invokeJavaMethod:aJavaMethod
+ interpreter:JavaInterpreter new
+ sender:thisContext sender
+ with:arg1
+ with:arg2
+ "Modified: 30.7.1997 / 13:25:36 / cg"
! !
!JavaObject methodsFor:'printing & storing'!
@@ -402,39 +605,10 @@
invoke:selector
"send a message, without args"
- ^ self invoke:selector interpreter:(JavaInterpreter new) sender:thisContext sender
-
- "
- |stack|
-
- stack := (Java at:'java/util/Stack') basicNew.
- stack invoke:#'<init>'.
- "
- "
- |stack|
-
- stack := (Java at:'java/util/Stack') new.
- stack invoke:#isEmpty.
- "
- "
- |stack|
-
- stack := (Java at:'java/util/Stack') new.
- stack invoke:#size.
- "
-!
-
-invoke:selector interpreter:i sender:aContext
- "send a message, without args"
-
- |method cls sel|
-
- method := self lookupMethod:selector numArgs:0.
- method notNil ifTrue:[
- ^ self invokeJavaMethod:method interpreter:i sender:aContext
- ].
-
- ^ super doesNotUnderstand:(Message selector:selector)
+ ^ self
+ invoke:selector
+ interpreter:(JavaInterpreter new)
+ sender:thisContext sender
"
|stack|
@@ -455,61 +629,29 @@
stack invoke:#size.
"
- "Modified: 1.2.1997 / 21:47:25 / cg"
+ "Modified: 30.7.1997 / 13:44:34 / cg"
!
-invoke:selector interpreter:i sender:aContext with:argument
+invoke:selector sender:aContext
+ "send a message, without args"
+
+ ^ self
+ invoke:selector
+ interpreter:(JavaInterpreter new)
+ sender:aContext
+
+ "Modified: 30.7.1997 / 13:59:18 / cg"
+!
+
+invoke:selector with:arg
"send a message, with 1 argument.
TEMPORARY: This method needs more work."
- |sel method cls argClass jSel|
-
- sel := selector asSymbolIfInterned.
- sel notNil ifTrue:[
- "/
- "/ hard to do - must find a matching method probably
- "/
- (argument isKindOf:JavaObject) ifTrue:[
- argClass := argument class.
- ] ifFalse:[
- "/
- "/ map to Java:
- "/ String -> [c
- "/
- (argument isMemberOf:String) ifTrue:[
- jSel := (selector , '([C)V') asSymbolIfInterned.
- jSel notNil ifTrue:[
- ^ self invokeJava:jSel interpreter:i sender:aContext with:argument
- ]
- ]
- ].
-
- method := self lookupMethod:sel numArgs:1.
- method notNil ifTrue:[
- ^ self invokeJavaMethod:method interpreter:i sender:aContext with:argument
- ].
-
-"/ cls := self class.
-"/ [cls notNil and:[cls ~~ JavaObject]] whileTrue:[
-"/ cls methodDictionary keysAndValuesDo:[:sel :aMethod |
-"/ aMethod name == sel ifTrue:[
-"/ aMethod numArgs == 1 ifTrue:[
-"/ "/
-"/ "/ this is not completely correct:
-"/ "/ must look for the best type-match,
-"/ "/ (especially: have to look for best match
-"/ "/ over whole superclass chain ...)
-"/ "/ for now take the first with matching number of args
-"/ "/
-"/ ^ self invokeJavaMethod:aMethod with:argument
-"/ ]
-"/ ]
-"/ ].
-"/ cls := cls superclass.
-"/ ].
- ].
-
- ^ super doesNotUnderstand:(Message selector:selector)
+ ^ self
+ invoke:selector
+ interpreter:JavaInterpreter new
+ sender:thisContext sender
+ with:arg
"
|stack|
@@ -528,148 +670,11 @@
stack invoke:#pop.
"
- "Modified: 22.3.1997 / 00:57:33 / cg"
-!
-
-invoke:selector interpreter:i sender:aContext with:arg1 with:arg2
- "send a message, with 2 arguments.
- TEMPORARY: This method needs more work."
-
- |sel method cls argClass jSel|
-
- sel := selector asSymbolIfInterned.
- sel notNil ifTrue:[
- method := self lookupMethod:sel numArgs:2.
- method notNil ifTrue:[
- ^ self invokeJavaMethod:method interpreter:i sender:aContext
- with:arg1 with:arg2
- ].
- ].
-
- ^ super doesNotUnderstand:(Message selector:selector)
-
- "Modified: 1.2.1997 / 21:47:31 / cg"
-!
-
-invoke:selector interpreter:i sender:aContext with:arg1 with:arg2 with:arg3
- "send a message, with 3 arguments.
- TEMPORARY: This method needs more work."
-
- |sel method cls argClass jSel|
-
- sel := selector asSymbolIfInterned.
- sel notNil ifTrue:[
- method := self lookupMethod:sel numArgs:3.
- method notNil ifTrue:[
- ^ self invokeJavaMethod:method interpreter:i sender:aContext
- with:arg1 with:arg2 with:arg3
- ].
- ].
-
- ^ super doesNotUnderstand:(Message selector:selector)
-
- "Modified: 1.2.1997 / 21:47:33 / cg"
-!
-
-invoke:selector interpreter:i sender:aContext with:arg1 with:arg2 with:arg3 with:arg4
- "send a message, with 4 arguments.
- TEMPORARY: This method needs more work."
-
- |sel method cls argClass jSel|
-
- sel := selector asSymbolIfInterned.
- sel notNil ifTrue:[
- method := self lookupMethod:sel numArgs:4.
- method notNil ifTrue:[
- ^ self invokeJavaMethod:method interpreter:i sender:aContext
- with:arg1 with:arg2 with:arg3 with:arg4
- ].
- ].
-
- ^ super doesNotUnderstand:(Message selector:selector)
-
- "Modified: 1.2.1997 / 21:47:36 / cg"
-!
-
-invoke:selector interpreter:i sender:aContext withAll:arguments
- "send a message, with arguments.
- TEMPORARY: This method needs more work."
-
- |sel method cls argClass jSel|
-
- sel := selector asSymbolIfInterned.
- sel notNil ifTrue:[
- method := self lookupMethod:sel numArgs:arguments size.
- method notNil ifTrue:[
- ^ self invokeJavaMethod:method interpreter:i sender:aContext withAll:arguments
- ].
- ].
-
- ^ super doesNotUnderstand:(Message selector:selector)
-
- "Modified: 1.2.1997 / 21:47:38 / cg"
-!
-
-invoke:selector sender:aContext
- "send a message, without args"
-
- |method cls sel|
-
- method := self lookupMethod:selector numArgs:0.
- method notNil ifTrue:[
- ^ self invokeJavaMethod:method interpreter:(JavaInterpreter new) sender:aContext
- ].
-
- ^ super doesNotUnderstand:(Message selector:selector)
-
- "
- |stack|
-
- stack := (Java at:'java/util/Stack') basicNew.
- stack invoke:#'<init>'.
- "
- "
- |stack|
-
- stack := (Java at:'java/util/Stack') new.
- stack invoke:#isEmpty.
- "
- "
- |stack|
-
- stack := (Java at:'java/util/Stack') new.
- stack invoke:#size.
- "
-
- "Modified: 1.2.1997 / 21:47:40 / cg"
-!
-
-invoke:selector with:arg
- "send a message, with 1 argument.
- TEMPORARY: This method needs more work."
-
- ^ self invoke:selector interpreter:JavaInterpreter new sender:thisContext sender with:arg
-
- "
- |stack|
-
- stack := (Java at:'java/util/Stack') new.
- stack invoke:#push with:1.
- "
- "
- |stack|
-
- stack := (Java at:'java/util/Stack') new.
- stack invoke:#push with:1.
- stack invoke:#push with:2.
- stack invoke:#pop.
- stack invoke:#pop.
- stack invoke:#pop.
- "
+ "Modified: 30.7.1997 / 13:44:44 / cg"
!
invoke:selector with:arg1 with:arg2
- "send a message, with 2 arguments.
+ "send a message, with 2 argument.
TEMPORARY: This method needs more work."
^ self
@@ -679,22 +684,37 @@
with:arg1
with:arg2
- "
- |stack|
+ "Modified: 30.7.1997 / 13:44:58 / cg"
+!
+
+invoke:selector with:arg1 with:arg2 with:arg3
+ "send a message, with 3 argument.
+ TEMPORARY: This method needs more work."
+
+ ^ self
+ invoke:selector
+ interpreter:JavaInterpreter new
+ sender:thisContext sender
+ with:arg1
+ with:arg2
+ with:arg3
- stack := (Java at:'java/util/Stack') new.
- stack invoke:#push with:1.
- "
- "
- |stack|
+ "Modified: 30.7.1997 / 13:44:58 / cg"
+ "Created: 30.7.1997 / 13:48:24 / cg"
+!
+
+invoke:selector withAll:args
+ "send a message, with anumber of arguments.
+ TEMPORARY: This method needs more work."
- stack := (Java at:'java/util/Stack') new.
- stack invoke:#push with:1.
- stack invoke:#push with:2.
- stack invoke:#pop.
- stack invoke:#pop.
- stack invoke:#pop.
- "
+ ^ self
+ invoke:selector
+ interpreter:JavaInterpreter new
+ sender:thisContext sender
+ withAll:args
+
+ "Modified: 30.7.1997 / 13:44:58 / cg"
+ "Created: 30.7.1997 / 13:56:33 / cg"
!
lookupMethod:selector numArgs:nargs
@@ -755,5 +775,5 @@
!JavaObject class methodsFor:'documentation'!
version
- ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaObject.st,v 1.27 1997/04/07 17:25:44 cg Exp $'
+ ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaObject.st,v 1.28 1997/07/30 14:41:13 cg Exp $'
! !