Object subclass:#JavaContext
instanceVariableNames:'method class sender stack frameBase pc sp'
classVariableNames:''
poolDictionaries:''
category:'Java-Support'
!
!JavaContext methodsFor:'ST context mimicri'!
argsAndVars
|nArgs nVars|
stack isNil ifTrue:[^ #()].
frameBase isNil ifTrue:[^ #()].
nArgs := method numArgs.
nVars := method numVars.
method isStatic ifTrue:[
(nArgs + nVars) == 0 ifTrue:[
^ #()
].
^ (stack copyFrom:frameBase to:(frameBase + nArgs + nVars - 1)) asArray
].
^ (stack copyFrom:(frameBase+1) to:(frameBase + nArgs + nVars)) asArray
"Created: 1.5.1996 / 17:32:44 / cg"
"Modified: 12.8.1997 / 22:04:39 / cg"
!
canReturn
^ false
"Created: 1.5.1996 / 15:05:36 / cg"
!
findNextContextWithSelector:sel1 or:sel2
sender isNil ifTrue:[^ nil].
^ sender findNextContextWithSelector:sel1 or:sel2
"Created: 20.3.1997 / 13:54:01 / cg"
!
hasStackToShow
^ true
!
isBlockContext
^ false
"Created: 1.5.1996 / 15:05:26 / cg"
!
lineNumber
|nr|
"/ 'ask line for pc:' print. pc printCR.
pc isNil ifTrue:[" '-> 0 [a]' printCR. " ^0].
nr := method lineNumberForPC:pc.
nr isNil ifTrue:[" '-> 0 [b]' printCR. " ^ 0].
"/ '-> ' print. nr printCR.
^ nr.
"Created: 1.5.1996 / 15:05:47 / cg"
"Modified: 12.8.1997 / 02:39:44 / cg"
!
methodClass
^ class
"Created: 1.5.1996 / 15:04:17 / cg"
!
methodHome
^ self
"Created: 1.5.1996 / 15:03:43 / cg"
!
numArgs
^ method numArgs
"Created: 1.5.1996 / 15:04:35 / cg"
!
numVars
^ 0
"Created: 1.5.1996 / 15:05:03 / cg"
!
receiver
method isStatic ifTrue:[
^ method javaClass
].
frameBase > stack size ifTrue:[
^ nil
].
"/ method displayString printCR.
"/ frameBase print. ' -> ' print. (stack at:frameBase) printCR.
^ stack at:frameBase
"Created: 1.5.1996 / 15:04:03 / cg"
"Modified: 4.8.1997 / 23:39:01 / cg"
!
selector
^ (method name , method signature) asSymbol "/ signatureName
"Created: 1.5.1996 / 15:03:03 / cg"
!
stack
^ stack
!
stackFrame
sp < frameBase ifTrue:[
'oops - negative stackFrame' errorPrintCR.
^ #()
].
stack isNil ifTrue:[^ #()].
"/ method displayString printCR.
"/ frameBase print. ' ... ' print. (sp-1) printCR.
"/ (stack collect:[:e | e class name]) printCR.
"/ method isStatic ifFalse:[
"/ ^ stack copyFrom:frameBase+1 to:(sp-1)
"/ ].
^ stack copyFrom:frameBase to:(sp-1)
"Modified: 12.8.1997 / 21:55:47 / cg"
! !
!JavaContext methodsFor:'accessing'!
class:aJavaClass method:aJavaMethod sender:aContext stack:s frameBase:f
class := aJavaClass.
method := aJavaMethod.
sender := aContext.
stack := s.
frameBase := f
"Modified: 1.5.1996 / 17:39:34 / cg"
"Created: 1.5.1996 / 17:42:27 / cg"
!
class:aJavaClass method:aJavaMethod sender:aContext stack:s stackPointer:spp frameBase:f
class := aJavaClass.
method := aJavaMethod.
sender := aContext.
stack := s.
sp := spp.
frameBase := f
"Modified: 1.5.1996 / 17:39:34 / cg"
"Created: 1.5.1996 / 17:42:27 / cg"
!
method
^ method.
"Created: 1.5.1996 / 15:00:23 / cg"
"Modified: 1.5.1996 / 15:00:47 / cg"
!
pc
^ pc
!
sender
^ sender.
"Modified: 1.5.1996 / 15:00:47 / cg"
"Created: 1.5.1996 / 15:01:18 / cg"
!
setPC:anInteger
pc := anInteger
!
setPC:pcInteger SP:spInteger
pc := pcInteger.
sp := spInteger.
!
setSP:anInteger
sp := anInteger
!
setStack:aCollection
stack := aCollection
!
sp
^ sp
! !
!JavaContext methodsFor:'printing & storing'!
printString
|nm mS recCls rec recClsName rnm|
nm := class fullName.
(nm startsWith:'java/lang/') ifTrue:[
nm := class name
] ifFalse:[
(nm startsWith:'java.lang.') ifTrue:[
nm := class name
].
].
"/ to avoid confusion with corresponding smalltalk classes ...
(Smalltalk includesKey:(nm asSymbol)) ifTrue:[
nm := 'JAVA-' , nm
].
mS := nm , '::' , method signatureName.
rec := self receiver.
recCls := rec class.
(rec isKindOf:JavaObject) ifFalse:[
rnm := '[' , recCls name , ']'
] ifTrue:[
recClsName := recCls name.
(Smalltalk includesKey:(recClsName asSymbol)) ifTrue:[
rnm := 'JAVA-' , recClsName
] ifFalse:[
(recCls fullName startsWith:'java/lang/') ifTrue:[
rnm := recClsName
] ifFalse:[
rnm := recCls fullName
].
].
].
(rnm ~= nm) ifTrue:[
^ rnm , '>>' , mS
].
^ mS
"Created: 1.5.1996 / 15:07:43 / cg"
"Modified: 8.8.1997 / 12:12:25 / cg"
! !
!JavaContext class methodsFor:'documentation'!
version
^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaContext.st,v 1.16 1997/08/13 13:11:04 cg Exp $'
! !