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