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