JavaContext.st
author cg
Mon, 05 Jan 1998 18:49:32 +0000
changeset 252 04b330744577
parent 228 18ed0b234062
child 255 2d8b3948a08a
permissions -rw-r--r--
new javaVM stuff & back to pre-stefans changes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
     1
'From Smalltalk/X, Version:3.3.1 on 5-jan-1998 at 2:09:56 pm'                   !
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
     2
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
     3
Context subclass:#JavaContext
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
     4
	instanceVariableNames:'exArg byteCode constPool method'
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
     5
	classVariableNames:''
916f444c5cae intitial checkin
cg
parents:
diff changeset
     6
	poolDictionaries:''
916f444c5cae intitial checkin
cg
parents:
diff changeset
     7
	category:'Java-Support'
916f444c5cae intitial checkin
cg
parents:
diff changeset
     8
!
916f444c5cae intitial checkin
cg
parents:
diff changeset
     9
916f444c5cae intitial checkin
cg
parents:
diff changeset
    10
916f444c5cae intitial checkin
cg
parents:
diff changeset
    11
!JavaContext methodsFor:'ST context mimicri'!
916f444c5cae intitial checkin
cg
parents:
diff changeset
    12
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    13
argAt:n
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    14
    |arg0Index|
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    15
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    16
    self method isStatic ifTrue:[
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    17
        arg0Index := 0
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    18
    ] ifFalse:[
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    19
        arg0Index := 1
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    20
    ].
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    21
    ^ self at:arg0Index+n
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    22
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    23
    "Created: / 2.1.1998 / 17:54:13 / cg"
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    24
    "Modified: / 2.1.1998 / 21:39:30 / cg"
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    25
!
117
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
    26
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    27
argAt:n put:value
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    28
    |arg0Index|
216
abe4c0313d97 checkin from browser
cg
parents: 211
diff changeset
    29
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    30
    self method isStatic ifTrue:[
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    31
        arg0Index := 0
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    32
    ] ifFalse:[
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    33
        arg0Index := 1
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    34
    ].
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    35
    ^ super argAt:arg0Index+n put:value
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    36
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    37
    "Created: / 2.1.1998 / 17:54:34 / cg"
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    38
    "Modified: / 2.1.1998 / 21:35:19 / cg"
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    39
!
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    40
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    41
args
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    42
    "return an array filled with the arguments of this context"
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    43
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    44
    |n arg1Index|
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
    45
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    46
    n := self numArgs.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    47
    n == 0 ifTrue:[
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    48
        "/ little optimization here - avaoid creating empty containers
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    49
        ^ #()
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    50
    ].
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    51
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    52
    self method isStatic ifTrue:[
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    53
        arg1Index := 1
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    54
    ] ifFalse:[
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    55
        arg1Index := 2
41
eb7974d88088 checkin from browser
cg
parents: 32
diff changeset
    56
    ].
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    57
    ^ (Array new:n) replaceFrom:1 to:n with:self startingAt:arg1Index.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    58
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    59
    "Created: / 2.1.1998 / 17:54:57 / cg"
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    60
    "Modified: / 2.1.1998 / 21:34:44 / cg"
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    61
!
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    62
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    63
argsAndVars
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    64
    "return an array filled with the arguments and variables of this context"
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    65
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    66
    |n arg1Index|
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
    67
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    68
    n := self numArgs + self numVars.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    69
    n == 0 ifTrue:[
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    70
        "/ little optimization here - avaoid creating empty containers
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    71
        ^ #()
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    72
    ].
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    73
    self method isStatic ifTrue:[
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    74
        arg1Index := 1
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    75
    ] ifFalse:[
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    76
        arg1Index := 2
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    77
    ].
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    78
    ^ (Array new:n) replaceFrom:1 to:n with:self startingAt:arg1Index.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    79
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    80
    "Created: / 2.1.1998 / 17:55:14 / cg"
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    81
    "Modified: / 2.1.1998 / 21:35:39 / cg"
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
    82
!
916f444c5cae intitial checkin
cg
parents:
diff changeset
    83
916f444c5cae intitial checkin
cg
parents:
diff changeset
    84
canReturn
916f444c5cae intitial checkin
cg
parents:
diff changeset
    85
    ^ false
916f444c5cae intitial checkin
cg
parents:
diff changeset
    86
916f444c5cae intitial checkin
cg
parents:
diff changeset
    87
    "Created: 1.5.1996 / 15:05:36 / cg"
916f444c5cae intitial checkin
cg
parents:
diff changeset
    88
!
916f444c5cae intitial checkin
cg
parents:
diff changeset
    89
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    90
lineNumber
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    91
    |nr pc|
156
fee47d32724d *** empty log message ***
cg
parents: 129
diff changeset
    92
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    93
    pc := self pc.
43
2c4ca2eb8d07 checkin from browser
cg
parents: 41
diff changeset
    94
211
bd118f601aed *** empty log message ***
cg
parents: 210
diff changeset
    95
"/ 'ask line for pc:' print. pc printCR.
bd118f601aed *** empty log message ***
cg
parents: 210
diff changeset
    96
    pc isNil ifTrue:[" '-> 0 [a]' printCR. " ^0].
43
2c4ca2eb8d07 checkin from browser
cg
parents: 41
diff changeset
    97
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    98
    nr := self method lineNumberForPC:pc.
211
bd118f601aed *** empty log message ***
cg
parents: 210
diff changeset
    99
    nr isNil ifTrue:[" '-> 0 [b]' printCR. " ^ 0].
bd118f601aed *** empty log message ***
cg
parents: 210
diff changeset
   100
"/ '-> ' print. nr printCR.
210
6a64bc70270b *** empty log message ***
cg
parents: 205
diff changeset
   101
     ^ nr.
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
   102
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   103
    "Created: / 1.5.1996 / 15:05:47 / cg"
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   104
    "Modified: / 4.1.1998 / 23:35:38 / cg"
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
   105
!
916f444c5cae intitial checkin
cg
parents:
diff changeset
   106
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   107
lineNumberFromMethod
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   108
    |m|
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   109
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   110
    m := self method.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   111
    m notNil ifTrue:[
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   112
        ^ m lineNumber
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   113
    ].
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   114
    ^ nil
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
   115
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   116
    "Created: / 4.1.1998 / 23:34:45 / cg"
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   117
    "Modified: / 4.1.1998 / 23:35:55 / cg"
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   118
!
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   119
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   120
method
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   121
    "the method may be found in the interpreter temps ..."
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   122
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   123
    (method isMemberOf:JavaMethod) ifTrue:[^ method].
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   124
    ^ super method
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   125
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   126
    "Created: / 1.5.1996 / 15:03:43 / cg"
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   127
    "Modified: / 2.1.1998 / 21:38:00 / cg"
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
   128
!
916f444c5cae intitial checkin
cg
parents:
diff changeset
   129
916f444c5cae intitial checkin
cg
parents:
diff changeset
   130
methodHome
916f444c5cae intitial checkin
cg
parents:
diff changeset
   131
    ^ self
916f444c5cae intitial checkin
cg
parents:
diff changeset
   132
!
916f444c5cae intitial checkin
cg
parents:
diff changeset
   133
916f444c5cae intitial checkin
cg
parents:
diff changeset
   134
numArgs
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   135
    "return the number of args.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   136
     Redefined since Java keeps the receiver of a non-static method
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   137
     at local slot 0."
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
   138
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   139
    |n|
198
5543d1079a4a *** empty log message ***
cg
parents: 156
diff changeset
   140
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   141
    n := super numArgs.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   142
    self method isStatic ifFalse:[
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   143
        n := n - 1
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   144
    ].
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   145
    ^ n
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
   146
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   147
    "Created: / 2.1.1998 / 22:21:24 / cg"
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
   148
!
916f444c5cae intitial checkin
cg
parents:
diff changeset
   149
32
0dbaa43a73db checkin from browser
cg
parents: 28
diff changeset
   150
pc
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   151
    lineNr isNil ifTrue:[^ nil].
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   152
    ^ super lineNumber
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
   153
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   154
    "Created: / 4.1.1998 / 23:33:48 / cg"
117
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
   155
!
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
   156
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   157
selector
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   158
    "the selector can be extracted from the method.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   159
     the method may be found in the interpreter temps ..."
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   160
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   161
    |s m|
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   162
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   163
    selector isNil ifTrue:[
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   164
	m := self method.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   165
	m notNil ifTrue:[
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   166
	    ^ m name
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   167
	]
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   168
    ].
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   169
    ^ super selector
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   170
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   171
    "Modified: / 30.12.1997 / 17:22:06 / cg"
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   172
    "Created: / 30.12.1997 / 17:23:47 / cg"
125
c99addd65f73 *** empty log message ***
cg
parents: 117
diff changeset
   173
!
c99addd65f73 *** empty log message ***
cg
parents: 117
diff changeset
   174
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   175
setPC:newPC
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   176
    lineNr := newPC
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   177
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   178
    "Created: / 5.1.1998 / 00:09:02 / cg"
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   179
! !
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   180
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   181
!JavaContext methodsFor:'exception handler support'!
117
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
   182
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   183
markForException
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   184
    "set the exception handler flag in the receiver.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   185
     The JVM needs this to enter an exception handler instead of restarting
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   186
     from the beginning (when the context is restarted).
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   187
     - a highly internal mechanism and not for public use."
117
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
   188
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   189
%{  /* NOCONTEXT */
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   190
     __INST(flags) = (OBJ)((INT)__INST(flags) | __MASKSMALLINT(__JAVA_EX_PEND));
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   191
%}
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   192
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   193
    "Modified: 13.12.1995 / 19:05:22 / cg"
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
   194
! !
916f444c5cae intitial checkin
cg
parents:
diff changeset
   195
916f444c5cae intitial checkin
cg
parents:
diff changeset
   196
!JavaContext methodsFor:'printing & storing'!
916f444c5cae intitial checkin
cg
parents:
diff changeset
   197
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   198
receiverPrintString
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   199
    "return a string describing the receiver of the context" 
52
1dc41619b6f8 checkin from browser
cg
parents: 43
diff changeset
   200
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   201
    |receiverClass receiverClassName newString implementorClass|
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
   202
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   203
%{
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   204
    /*
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   205
     * special handling for (invalid) free objects.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   206
     * these only appear if some primitiveCode does not correctly use SEND macros,
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   207
     * which may lead to sends to free objects. In normal operation, this 'cannot' happen.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   208
     */ 
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   209
    if (__isNonNilObject(__INST(receiver)) && (__qClass(__INST(receiver))==nil)) {
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   210
	receiverClassName = __MKSTRING("FreeObject");
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   211
    }
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   212
%}.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   213
    receiverClassName notNil ifTrue:[^ receiverClassName].
228
18ed0b234062 checkin from browser
cg
parents: 216
diff changeset
   214
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   215
    receiverClass := receiver class.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   216
    receiverClassName := receiverClass name.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   217
    (receiverClass == SmallInteger) ifTrue:[
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   218
	newString := '(' , receiver printString , ') ' , receiverClassName
228
18ed0b234062 checkin from browser
cg
parents: 216
diff changeset
   219
    ] ifFalse:[
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   220
	newString := receiverClassName
228
18ed0b234062 checkin from browser
cg
parents: 216
diff changeset
   221
    ].
18ed0b234062 checkin from browser
cg
parents: 216
diff changeset
   222
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   223
    "
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   224
     kludge to avoid slow search for containing class
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   225
    "
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   226
    (selector ~~ #doIt and:[selector ~~ #doIt:]) ifTrue:[
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   227
	implementorClass := self methodClass. 
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   228
    ].
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   229
    implementorClass notNil ifTrue: [
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   230
	(implementorClass ~~ receiverClass) ifTrue: [
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   231
	    newString := newString , '>>>',
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   232
			 implementorClass name printString
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   233
	]
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   234
    ] ifFalse:[
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   235
	self searchClass ~~ receiverClass ifTrue:[
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   236
	    newString := newString , '>>>' , self searchClass name
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   237
	].
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   238
"/        "
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   239
"/         kludge for doIt - these unbound methods are not
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   240
"/         found in the classes methodDictionary
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   241
"/        "
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   242
"/        (selector ~~ #doIt and:[selector ~~ #doIt:]) ifTrue:[
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   243
"/            newString := newString , '>>>**NONE**'
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   244
"/        ]
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
   245
    ].
916f444c5cae intitial checkin
cg
parents:
diff changeset
   246
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   247
    ^ newString
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
   248
916f444c5cae intitial checkin
cg
parents:
diff changeset
   249
! !
916f444c5cae intitial checkin
cg
parents:
diff changeset
   250
129
f40775af59a5 checkin from browser
cg
parents: 125
diff changeset
   251
!JavaContext class methodsFor:'documentation'!
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
   252
916f444c5cae intitial checkin
cg
parents:
diff changeset
   253
version
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   254
    ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaContext.st,v 1.18 1998/01/05 18:47:12 cg Exp $'
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
   255
! !