JavaContext.st
author cg
Tue, 27 Jul 1999 18:19:02 +0000
changeset 588 dfb441458353
parent 511 1395b1fc453f
child 614 f042df9169e7
permissions -rw-r--r--
care for half-setup context when breakpointing
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
454
38f590639d65 *** empty log message ***
cg
parents: 429
diff changeset
     1
"
38f590639d65 *** empty log message ***
cg
parents: 429
diff changeset
     2
 COPYRIGHT (c) 1997 by eXept Software AG
511
1395b1fc453f *** empty log message ***
cg
parents: 454
diff changeset
     3
	      All Rights Reserved
454
38f590639d65 *** empty log message ***
cg
parents: 429
diff changeset
     4
38f590639d65 *** empty log message ***
cg
parents: 429
diff changeset
     5
 This software is furnished under a license and may be used
38f590639d65 *** empty log message ***
cg
parents: 429
diff changeset
     6
 only in accordance with the terms of that license and with the
38f590639d65 *** empty log message ***
cg
parents: 429
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
38f590639d65 *** empty log message ***
cg
parents: 429
diff changeset
     8
 be provided or otherwise made available to, or used by, any
38f590639d65 *** empty log message ***
cg
parents: 429
diff changeset
     9
 other person.  No title to or ownership of the software is
38f590639d65 *** empty log message ***
cg
parents: 429
diff changeset
    10
 hereby transferred.
38f590639d65 *** empty log message ***
cg
parents: 429
diff changeset
    11
"
38f590639d65 *** empty log message ***
cg
parents: 429
diff changeset
    12
38f590639d65 *** empty log message ***
cg
parents: 429
diff changeset
    13
38f590639d65 *** empty log message ***
cg
parents: 429
diff changeset
    14
427
a7083b7a8724 *** empty log message ***
cg
parents: 382
diff changeset
    15
Context variableSubclass:#JavaContext
511
1395b1fc453f *** empty log message ***
cg
parents: 454
diff changeset
    16
	instanceVariableNames:'exArg exPC byteCode constPool method'
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
    17
	classVariableNames:''
916f444c5cae intitial checkin
cg
parents:
diff changeset
    18
	poolDictionaries:''
916f444c5cae intitial checkin
cg
parents:
diff changeset
    19
	category:'Java-Support'
916f444c5cae intitial checkin
cg
parents:
diff changeset
    20
!
916f444c5cae intitial checkin
cg
parents:
diff changeset
    21
454
38f590639d65 *** empty log message ***
cg
parents: 429
diff changeset
    22
!JavaContext class methodsFor:'documentation'!
38f590639d65 *** empty log message ***
cg
parents: 429
diff changeset
    23
38f590639d65 *** empty log message ***
cg
parents: 429
diff changeset
    24
copyright
38f590639d65 *** empty log message ***
cg
parents: 429
diff changeset
    25
"
38f590639d65 *** empty log message ***
cg
parents: 429
diff changeset
    26
 COPYRIGHT (c) 1997 by eXept Software AG
511
1395b1fc453f *** empty log message ***
cg
parents: 454
diff changeset
    27
	      All Rights Reserved
454
38f590639d65 *** empty log message ***
cg
parents: 429
diff changeset
    28
38f590639d65 *** empty log message ***
cg
parents: 429
diff changeset
    29
 This software is furnished under a license and may be used
38f590639d65 *** empty log message ***
cg
parents: 429
diff changeset
    30
 only in accordance with the terms of that license and with the
38f590639d65 *** empty log message ***
cg
parents: 429
diff changeset
    31
 inclusion of the above copyright notice.   This software may not
38f590639d65 *** empty log message ***
cg
parents: 429
diff changeset
    32
 be provided or otherwise made available to, or used by, any
38f590639d65 *** empty log message ***
cg
parents: 429
diff changeset
    33
 other person.  No title to or ownership of the software is
38f590639d65 *** empty log message ***
cg
parents: 429
diff changeset
    34
 hereby transferred.
38f590639d65 *** empty log message ***
cg
parents: 429
diff changeset
    35
"
38f590639d65 *** empty log message ***
cg
parents: 429
diff changeset
    36
38f590639d65 *** empty log message ***
cg
parents: 429
diff changeset
    37
38f590639d65 *** empty log message ***
cg
parents: 429
diff changeset
    38
! !
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
    39
916f444c5cae intitial checkin
cg
parents:
diff changeset
    40
!JavaContext methodsFor:'ST context mimicri'!
916f444c5cae intitial checkin
cg
parents:
diff changeset
    41
261
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
    42
arg1Index
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
    43
    "the java stack contains the receiver in a non-static
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
    44
     method, as slot 0. Therefore, the first arg is found at slot2
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
    45
     if this is for a non-static method"
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    46
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    47
    self method isStatic ifTrue:[
261
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
    48
	^ 1
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    49
    ].
261
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
    50
    ^ 2
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
    51
!
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
    52
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
    53
argAt:n
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
    54
    "return the i'th argument (1..nArgs)"
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
    55
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
    56
    ^ self at:(self arg1Index - 1 + n)
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    57
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    58
    "Created: / 2.1.1998 / 17:54:13 / cg"
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    59
    "Modified: / 2.1.1998 / 21:39:30 / cg"
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    60
!
117
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
    61
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    62
argAt:n put:value
261
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
    63
    "change the i'th argument (1..nArgs)"
216
abe4c0313d97 checkin from browser
cg
parents: 211
diff changeset
    64
261
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
    65
    ^ super argAt:(self arg1Index - 1 + n) put:value
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    66
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    67
    "Created: / 2.1.1998 / 17:54:34 / cg"
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    68
    "Modified: / 2.1.1998 / 21:35:19 / cg"
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    69
!
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    70
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    71
args
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    72
    "return an array filled with the arguments of this context"
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    73
261
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
    74
    |n|
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
    75
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    76
    n := self numArgs.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    77
    n == 0 ifTrue:[
261
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
    78
	"/ little optimization here - avoid creating empty containers
255
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
    79
	^ #()
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    80
    ].
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    81
261
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
    82
    ^ (Array new:n) replaceFrom:1 to:n with:self startingAt:(self arg1Index).
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    83
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    84
    "Created: / 2.1.1998 / 17:54:57 / cg"
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    85
    "Modified: / 2.1.1998 / 21:34:44 / cg"
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    86
!
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    87
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    88
argsAndVars
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    89
    "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
    90
261
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
    91
    |n|
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
    92
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    93
    n := self numArgs + self numVars.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    94
    n == 0 ifTrue:[
363
1c36ff13b671 *** empty log message ***
cg
parents: 346
diff changeset
    95
	"/ little optimization here - avoid creating empty containers
1c36ff13b671 *** empty log message ***
cg
parents: 346
diff changeset
    96
	^ #()
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    97
    ].
261
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
    98
    ^ (Array new:n) replaceFrom:1 to:n with:self startingAt:(self arg1Index).
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
    99
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   100
    "Created: / 2.1.1998 / 17:55:14 / cg"
261
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   101
    "Modified: / 13.1.1998 / 15:44:56 / cg"
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
   102
!
916f444c5cae intitial checkin
cg
parents:
diff changeset
   103
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   104
lineNumber
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   105
    |nr pc|
156
fee47d32724d *** empty log message ***
cg
parents: 129
diff changeset
   106
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   107
    pc := self pc.
43
2c4ca2eb8d07 checkin from browser
cg
parents: 41
diff changeset
   108
211
bd118f601aed *** empty log message ***
cg
parents: 210
diff changeset
   109
"/ 'ask line for pc:' print. pc printCR.
255
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   110
    pc isNil ifTrue:[
363
1c36ff13b671 *** empty log message ***
cg
parents: 346
diff changeset
   111
	nr := self lineNumberFromMethod.
1c36ff13b671 *** empty log message ***
cg
parents: 346
diff changeset
   112
	nr notNil ifTrue:[
1c36ff13b671 *** empty log message ***
cg
parents: 346
diff changeset
   113
	    ^ nr
1c36ff13b671 *** empty log message ***
cg
parents: 346
diff changeset
   114
	].
1c36ff13b671 *** empty log message ***
cg
parents: 346
diff changeset
   115
	" '-> 0 [a]' printCR. " 
1c36ff13b671 *** empty log message ***
cg
parents: 346
diff changeset
   116
	^0
255
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   117
    ].
43
2c4ca2eb8d07 checkin from browser
cg
parents: 41
diff changeset
   118
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   119
    nr := self method lineNumberForPC:pc.
255
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   120
    nr isNil ifTrue:[
363
1c36ff13b671 *** empty log message ***
cg
parents: 346
diff changeset
   121
	nr := self lineNumberFromMethod.
1c36ff13b671 *** empty log message ***
cg
parents: 346
diff changeset
   122
	nr notNil ifTrue:[
1c36ff13b671 *** empty log message ***
cg
parents: 346
diff changeset
   123
	    ^ nr
1c36ff13b671 *** empty log message ***
cg
parents: 346
diff changeset
   124
	].
1c36ff13b671 *** empty log message ***
cg
parents: 346
diff changeset
   125
	" '-> 0 [b]' printCR. " 
1c36ff13b671 *** empty log message ***
cg
parents: 346
diff changeset
   126
	^ 0
255
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   127
    ].
211
bd118f601aed *** empty log message ***
cg
parents: 210
diff changeset
   128
"/ '-> ' print. nr printCR.
210
6a64bc70270b *** empty log message ***
cg
parents: 205
diff changeset
   129
     ^ nr.
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
   130
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   131
    "Created: / 1.5.1996 / 15:05:47 / cg"
261
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   132
    "Modified: / 15.1.1998 / 15:25:29 / cg"
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
   133
!
916f444c5cae intitial checkin
cg
parents:
diff changeset
   134
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   135
lineNumberFromMethod
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   136
    |m|
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   137
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   138
    m := self method.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   139
    m notNil ifTrue:[
255
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   140
	^ m lineNumber
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   141
    ].
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   142
    ^ nil
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
   143
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   144
    "Created: / 4.1.1998 / 23:34:45 / cg"
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   145
    "Modified: / 4.1.1998 / 23:35:55 / cg"
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   146
!
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   147
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   148
method
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   149
    "the method may be found in the interpreter temps ..."
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   150
382
acef9fb5ee5a checkin from browser
cg
parents: 363
diff changeset
   151
    (method isKindOf:JavaMethod) ifTrue:[^ method].
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   152
    ^ super method
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   153
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   154
    "Created: / 1.5.1996 / 15:03:43 / cg"
382
acef9fb5ee5a checkin from browser
cg
parents: 363
diff changeset
   155
    "Modified: / 16.10.1998 / 01:22:12 / cg"
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
   156
!
916f444c5cae intitial checkin
cg
parents:
diff changeset
   157
916f444c5cae intitial checkin
cg
parents:
diff changeset
   158
methodHome
916f444c5cae intitial checkin
cg
parents:
diff changeset
   159
    ^ self
916f444c5cae intitial checkin
cg
parents:
diff changeset
   160
!
916f444c5cae intitial checkin
cg
parents:
diff changeset
   161
916f444c5cae intitial checkin
cg
parents:
diff changeset
   162
numArgs
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   163
    "return the number of args.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   164
     Redefined since Java keeps the receiver of a non-static method
261
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   165
     at local slot 1."
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
   166
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   167
    |n|
198
5543d1079a4a *** empty log message ***
cg
parents: 156
diff changeset
   168
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   169
    n := super numArgs.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   170
    self method isStatic ifFalse:[
255
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   171
	n := n - 1
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   172
    ].
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   173
    ^ n
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
   174
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   175
    "Created: / 2.1.1998 / 22:21:24 / cg"
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
   176
!
916f444c5cae intitial checkin
cg
parents:
diff changeset
   177
261
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   178
numTemps
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   179
    "return the number of temporary variables of the Method.
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   180
     Redefined since Java keeps the receiver of a non-static method
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   181
     at local slot 1."
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   182
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   183
    |n|
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   184
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   185
    n := self size - super numVars - super numArgs.
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   186
    ^ n
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   187
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   188
    "Created: / 13.1.1998 / 16:52:32 / cg"
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   189
    "Modified: / 13.1.1998 / 17:23:27 / cg"
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   190
!
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   191
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   192
numVars
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   193
    "return the number of locals.
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   194
     Redefined since Java keeps the receiver of a non-static method
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   195
     at local slot 0 and holds the args as locals."
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   196
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   197
    |n|
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   198
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   199
    n := super numVars.
588
dfb441458353 care for half-setup context when breakpointing
cg
parents: 511
diff changeset
   200
    ^ (n - self numArgs) max:0
261
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   201
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   202
    "Created: / 13.1.1998 / 17:03:08 / cg"
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   203
    "Modified: / 13.1.1998 / 17:25:16 / cg"
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   204
!
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   205
32
0dbaa43a73db checkin from browser
cg
parents: 28
diff changeset
   206
pc
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   207
    lineNr isNil ifTrue:[^ nil].
429
99990a8a3509 *** empty log message ***
cg
parents: 427
diff changeset
   208
    ^ lineNr bitAnd:16rFFFF
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
   209
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   210
    "Created: / 4.1.1998 / 23:33:48 / cg"
429
99990a8a3509 *** empty log message ***
cg
parents: 427
diff changeset
   211
    "Modified: / 10.11.1998 / 13:20:12 / cg"
99990a8a3509 *** empty log message ***
cg
parents: 427
diff changeset
   212
!
99990a8a3509 *** empty log message ***
cg
parents: 427
diff changeset
   213
99990a8a3509 *** empty log message ***
cg
parents: 427
diff changeset
   214
quickLineNumber
99990a8a3509 *** empty log message ***
cg
parents: 427
diff changeset
   215
    "the lineNumber - without decompiling"
99990a8a3509 *** empty log message ***
cg
parents: 427
diff changeset
   216
99990a8a3509 *** empty log message ***
cg
parents: 427
diff changeset
   217
    ^ self method quickLineNumberForPC:self pc
99990a8a3509 *** empty log message ***
cg
parents: 427
diff changeset
   218
99990a8a3509 *** empty log message ***
cg
parents: 427
diff changeset
   219
    "Created: / 10.11.1998 / 14:20:30 / cg"
117
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
   220
!
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
   221
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   222
selector
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   223
    "the selector can be extracted from the method.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   224
     the method may be found in the interpreter temps ..."
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
    |s m|
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   227
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   228
    selector isNil ifTrue:[
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   229
	m := self method.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   230
	m notNil ifTrue:[
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   231
	    ^ m name
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   232
	]
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
    ^ super selector
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   235
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   236
    "Modified: / 30.12.1997 / 17:22:06 / cg"
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   237
    "Created: / 30.12.1997 / 17:23:47 / cg"
125
c99addd65f73 *** empty log message ***
cg
parents: 117
diff changeset
   238
!
c99addd65f73 *** empty log message ***
cg
parents: 117
diff changeset
   239
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   240
setPC:newPC
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   241
    lineNr := newPC
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   242
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   243
    "Created: / 5.1.1998 / 00:09:02 / cg"
261
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   244
!
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   245
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   246
temporaries
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   247
    "return an array filled with the arguments and variables of this context"
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   248
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   249
    |n nSkipped|
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   250
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   251
    "/ the flas-numVars includes the receiver and args
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   252
    nSkipped := super numVars "self numArgs + self numVars".
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   253
    "/ but my context setup is args+numvars.
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   254
    nSkipped := super numArgs + super numVars.
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   255
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   256
    n := self size - nSkipped.
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   257
    n == 0 ifTrue:[
363
1c36ff13b671 *** empty log message ***
cg
parents: 346
diff changeset
   258
	"/ little optimization here - avaoid creating empty containers
1c36ff13b671 *** empty log message ***
cg
parents: 346
diff changeset
   259
	^ #()
261
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   260
    ].
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   261
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   262
    ^ (Array new:n) replaceFrom:1 to:n with:self startingAt:nSkipped+1.
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   263
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   264
    "Created: / 13.1.1998 / 15:44:12 / cg"
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   265
    "Modified: / 13.1.1998 / 17:22:54 / cg"
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   266
!
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   267
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   268
vars 
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   269
    "return an array filled with the local variables of this context"
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   270
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   271
    |nonVars mySize|
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   272
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   273
    mySize := self numVars.
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   274
    mySize == 0 ifTrue:[
363
1c36ff13b671 *** empty log message ***
cg
parents: 346
diff changeset
   275
	"/ little optimization here - avaoid creating empty containers
1c36ff13b671 *** empty log message ***
cg
parents: 346
diff changeset
   276
	^ #()
261
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   277
    ].
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   278
    nonVars := (self arg1Index-1) + self numArgs.
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   279
    ^ (Array new:mySize) replaceFrom:1 to:mySize with:self startingAt:nonVars+1
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   280
d95d5a3cc475 lots of new stuff
cg
parents: 255
diff changeset
   281
    "Created: / 13.1.1998 / 16:48:16 / cg"
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   282
! !
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   283
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   284
!JavaContext methodsFor:'exception handler support'!
117
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
   285
255
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   286
exceptionArg:aJavaException
511
1395b1fc453f *** empty log message ***
cg
parents: 454
diff changeset
   287
    exArg := aJavaException.
1395b1fc453f *** empty log message ***
cg
parents: 454
diff changeset
   288
1395b1fc453f *** empty log message ***
cg
parents: 454
diff changeset
   289
    "Created: / 7.1.1998 / 21:36:56 / cg"
1395b1fc453f *** empty log message ***
cg
parents: 454
diff changeset
   290
!
1395b1fc453f *** empty log message ***
cg
parents: 454
diff changeset
   291
1395b1fc453f *** empty log message ***
cg
parents: 454
diff changeset
   292
exceptionArg:aJavaException pc:newPc
1395b1fc453f *** empty log message ***
cg
parents: 454
diff changeset
   293
    exArg := aJavaException.
1395b1fc453f *** empty log message ***
cg
parents: 454
diff changeset
   294
    exPC := newPc.
255
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   295
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   296
    "Created: / 7.1.1998 / 21:36:56 / cg"
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   297
!
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   298
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   299
markForException
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   300
    "set the exception handler flag in the receiver.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   301
     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
   302
     from the beginning (when the context is restarted).
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   303
     - a highly internal mechanism and not for public use."
117
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
   304
363
1c36ff13b671 *** empty log message ***
cg
parents: 346
diff changeset
   305
    flags := flags bitOr:16r08000000.
1c36ff13b671 *** empty log message ***
cg
parents: 346
diff changeset
   306
1c36ff13b671 *** empty log message ***
cg
parents: 346
diff changeset
   307
"/ %{  /* NOCONTEXT */
1c36ff13b671 *** empty log message ***
cg
parents: 346
diff changeset
   308
"/      __INST(flags) = (OBJ)((INT)__INST(flags) | __MASKSMALLINT(__JAVA_EX_PEND));
1c36ff13b671 *** empty log message ***
cg
parents: 346
diff changeset
   309
"/ %}
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   310
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   311
    "Modified: 13.12.1995 / 19:05:22 / cg"
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
   312
! !
916f444c5cae intitial checkin
cg
parents:
diff changeset
   313
916f444c5cae intitial checkin
cg
parents:
diff changeset
   314
!JavaContext methodsFor:'printing & storing'!
916f444c5cae intitial checkin
cg
parents:
diff changeset
   315
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   316
receiverPrintString
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   317
    "return a string describing the receiver of the context" 
52
1dc41619b6f8 checkin from browser
cg
parents: 43
diff changeset
   318
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   319
    |receiverClass receiverClassName newString implementorClass|
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
   320
363
1c36ff13b671 *** empty log message ***
cg
parents: 346
diff changeset
   321
"/ %{
1c36ff13b671 *** empty log message ***
cg
parents: 346
diff changeset
   322
"/     /*
1c36ff13b671 *** empty log message ***
cg
parents: 346
diff changeset
   323
"/      * special handling for (invalid) free objects.
1c36ff13b671 *** empty log message ***
cg
parents: 346
diff changeset
   324
"/      * these only appear if some primitiveCode does not correctly use SEND macros,
1c36ff13b671 *** empty log message ***
cg
parents: 346
diff changeset
   325
"/      * which may lead to sends to free objects. In normal operation, this 'cannot' happen.
1c36ff13b671 *** empty log message ***
cg
parents: 346
diff changeset
   326
"/      */ 
1c36ff13b671 *** empty log message ***
cg
parents: 346
diff changeset
   327
"/     if (__isNonNilObject(__INST(receiver)) && (__qClass(__INST(receiver))==nil)) {
1c36ff13b671 *** empty log message ***
cg
parents: 346
diff changeset
   328
"/         receiverClassName = __MKSTRING("FreeObject");
1c36ff13b671 *** empty log message ***
cg
parents: 346
diff changeset
   329
"/     }
1c36ff13b671 *** empty log message ***
cg
parents: 346
diff changeset
   330
"/ %}.
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   331
    receiverClassName notNil ifTrue:[^ receiverClassName].
228
18ed0b234062 checkin from browser
cg
parents: 216
diff changeset
   332
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   333
    receiverClass := receiver class.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   334
    receiverClassName := receiverClass name.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   335
    (receiverClass == SmallInteger) ifTrue:[
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   336
	newString := '(' , receiver printString , ') ' , receiverClassName
228
18ed0b234062 checkin from browser
cg
parents: 216
diff changeset
   337
    ] ifFalse:[
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   338
	newString := receiverClassName
228
18ed0b234062 checkin from browser
cg
parents: 216
diff changeset
   339
    ].
18ed0b234062 checkin from browser
cg
parents: 216
diff changeset
   340
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   341
    "
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   342
     kludge to avoid slow search for containing class
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   343
    "
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   344
    (selector ~~ #doIt and:[selector ~~ #doIt:]) ifTrue:[
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   345
	implementorClass := self methodClass. 
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   346
    ].
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   347
    implementorClass notNil ifTrue: [
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   348
	(implementorClass ~~ receiverClass) ifTrue: [
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   349
	    newString := newString , '>>>',
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   350
			 implementorClass name printString
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   351
	]
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   352
    ] ifFalse:[
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   353
	self searchClass ~~ receiverClass ifTrue:[
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   354
	    newString := newString , '>>>' , self searchClass name
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   355
	].
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   356
"/        "
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   357
"/         kludge for doIt - these unbound methods are not
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   358
"/         found in the classes methodDictionary
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   359
"/        "
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   360
"/        (selector ~~ #doIt and:[selector ~~ #doIt:]) ifTrue:[
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   361
"/            newString := newString , '>>>**NONE**'
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   362
"/        ]
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
   363
    ].
916f444c5cae intitial checkin
cg
parents:
diff changeset
   364
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 228
diff changeset
   365
    ^ newString
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
   366
916f444c5cae intitial checkin
cg
parents:
diff changeset
   367
! !
916f444c5cae intitial checkin
cg
parents:
diff changeset
   368
343
b6ff12d916fb checkin from browser
cg
parents: 264
diff changeset
   369
!JavaContext methodsFor:'queries'!
b6ff12d916fb checkin from browser
cg
parents: 264
diff changeset
   370
b6ff12d916fb checkin from browser
cg
parents: 264
diff changeset
   371
hasStackToShow
b6ff12d916fb checkin from browser
cg
parents: 264
diff changeset
   372
    "private interface to the debugger.
b6ff12d916fb checkin from browser
cg
parents: 264
diff changeset
   373
     Smalltalk contexts return false here - other language frames
b6ff12d916fb checkin from browser
cg
parents: 264
diff changeset
   374
     (i.e. Java frames) may want to show the evaluation stack"
b6ff12d916fb checkin from browser
cg
parents: 264
diff changeset
   375
b6ff12d916fb checkin from browser
cg
parents: 264
diff changeset
   376
    ^ true
b6ff12d916fb checkin from browser
cg
parents: 264
diff changeset
   377
b6ff12d916fb checkin from browser
cg
parents: 264
diff changeset
   378
    "Modified: / 13.5.1997 / 16:31:12 / cg"
b6ff12d916fb checkin from browser
cg
parents: 264
diff changeset
   379
    "Created: / 7.5.1998 / 01:23:57 / cg"
b6ff12d916fb checkin from browser
cg
parents: 264
diff changeset
   380
!
b6ff12d916fb checkin from browser
cg
parents: 264
diff changeset
   381
346
36573254a561 added #isJavaContext
cg
parents: 343
diff changeset
   382
isJavaContext
36573254a561 added #isJavaContext
cg
parents: 343
diff changeset
   383
    "return true, if this is a javaContext."
36573254a561 added #isJavaContext
cg
parents: 343
diff changeset
   384
36573254a561 added #isJavaContext
cg
parents: 343
diff changeset
   385
    ^ true
36573254a561 added #isJavaContext
cg
parents: 343
diff changeset
   386
36573254a561 added #isJavaContext
cg
parents: 343
diff changeset
   387
    "Created: / 8.5.1998 / 21:23:47 / cg"
36573254a561 added #isJavaContext
cg
parents: 343
diff changeset
   388
!
36573254a561 added #isJavaContext
cg
parents: 343
diff changeset
   389
343
b6ff12d916fb checkin from browser
cg
parents: 264
diff changeset
   390
stackFrame
b6ff12d916fb checkin from browser
cg
parents: 264
diff changeset
   391
    "private interface to the debugger."
b6ff12d916fb checkin from browser
cg
parents: 264
diff changeset
   392
b6ff12d916fb checkin from browser
cg
parents: 264
diff changeset
   393
    ^ (1 to:self size) collect:[:i | self at:i]
b6ff12d916fb checkin from browser
cg
parents: 264
diff changeset
   394
b6ff12d916fb checkin from browser
cg
parents: 264
diff changeset
   395
    "Created: / 7.5.1998 / 01:26:19 / cg"
b6ff12d916fb checkin from browser
cg
parents: 264
diff changeset
   396
! !
b6ff12d916fb checkin from browser
cg
parents: 264
diff changeset
   397
129
f40775af59a5 checkin from browser
cg
parents: 125
diff changeset
   398
!JavaContext class methodsFor:'documentation'!
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
   399
916f444c5cae intitial checkin
cg
parents:
diff changeset
   400
version
588
dfb441458353 care for half-setup context when breakpointing
cg
parents: 511
diff changeset
   401
    ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaContext.st,v 1.30 1999/07/27 18:19:02 cg Exp $'
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
   402
! !