JavaContext.st
author cg
Tue, 09 Jul 1996 20:50:50 +0000
changeset 125 c99addd65f73
parent 117 4625d32e5a00
child 129 f40775af59a5
permissions -rw-r--r--
*** empty log message ***
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
     1
Object subclass:#JavaContext
117
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
     2
	instanceVariableNames:'method class sender stack frameBase pc sp'
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
916f444c5cae intitial checkin
cg
parents:
diff changeset
    11
argsAndVars
117
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
    12
    |nArgs nVars|
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
    13
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
    14
    nArgs := method numArgs.
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
    15
    nVars := method numVars.
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
    16
41
eb7974d88088 checkin from browser
cg
parents: 32
diff changeset
    17
    method isStatic ifTrue:[
117
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
    18
        (nArgs + nVars) == 0 ifTrue:[
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
    19
            ^ #()
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
    20
        ].
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
    21
        ^ (stack copyFrom:frameBase to:(frameBase + nArgs + nVars - 1)) asArray
41
eb7974d88088 checkin from browser
cg
parents: 32
diff changeset
    22
    ].
117
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
    23
    ^ (stack copyFrom:(frameBase+1) to:(frameBase + nArgs + nVars)) asArray
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
    24
916f444c5cae intitial checkin
cg
parents:
diff changeset
    25
    "Created: 1.5.1996 / 17:32:44 / cg"
916f444c5cae intitial checkin
cg
parents:
diff changeset
    26
    "Modified: 1.5.1996 / 17:41:50 / cg"
916f444c5cae intitial checkin
cg
parents:
diff changeset
    27
!
916f444c5cae intitial checkin
cg
parents:
diff changeset
    28
916f444c5cae intitial checkin
cg
parents:
diff changeset
    29
canReturn
916f444c5cae intitial checkin
cg
parents:
diff changeset
    30
    ^ false
916f444c5cae intitial checkin
cg
parents:
diff changeset
    31
916f444c5cae intitial checkin
cg
parents:
diff changeset
    32
    "Created: 1.5.1996 / 15:05:36 / cg"
916f444c5cae intitial checkin
cg
parents:
diff changeset
    33
!
916f444c5cae intitial checkin
cg
parents:
diff changeset
    34
88
8b66ed9a9a5d *** empty log message ***
cg
parents: 84
diff changeset
    35
hasStackToShow
8b66ed9a9a5d *** empty log message ***
cg
parents: 84
diff changeset
    36
    ^ true
8b66ed9a9a5d *** empty log message ***
cg
parents: 84
diff changeset
    37
!
8b66ed9a9a5d *** empty log message ***
cg
parents: 84
diff changeset
    38
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
    39
isBlockContext
916f444c5cae intitial checkin
cg
parents:
diff changeset
    40
    ^ false
916f444c5cae intitial checkin
cg
parents:
diff changeset
    41
916f444c5cae intitial checkin
cg
parents:
diff changeset
    42
    "Created: 1.5.1996 / 15:05:26 / cg"
916f444c5cae intitial checkin
cg
parents:
diff changeset
    43
!
916f444c5cae intitial checkin
cg
parents:
diff changeset
    44
916f444c5cae intitial checkin
cg
parents:
diff changeset
    45
lineNumber
43
2c4ca2eb8d07 checkin from browser
cg
parents: 41
diff changeset
    46
    |nr|
2c4ca2eb8d07 checkin from browser
cg
parents: 41
diff changeset
    47
2c4ca2eb8d07 checkin from browser
cg
parents: 41
diff changeset
    48
    pc isNil ifTrue:[^0].
2c4ca2eb8d07 checkin from browser
cg
parents: 41
diff changeset
    49
2c4ca2eb8d07 checkin from browser
cg
parents: 41
diff changeset
    50
    nr := method lineNumberForPC:pc.
2c4ca2eb8d07 checkin from browser
cg
parents: 41
diff changeset
    51
    nr isNil ifTrue:[^ 0].
2c4ca2eb8d07 checkin from browser
cg
parents: 41
diff changeset
    52
    ^ nr.
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
    53
916f444c5cae intitial checkin
cg
parents:
diff changeset
    54
    "Created: 1.5.1996 / 15:05:47 / cg"
916f444c5cae intitial checkin
cg
parents:
diff changeset
    55
!
916f444c5cae intitial checkin
cg
parents:
diff changeset
    56
916f444c5cae intitial checkin
cg
parents:
diff changeset
    57
methodClass
916f444c5cae intitial checkin
cg
parents:
diff changeset
    58
    ^ class
916f444c5cae intitial checkin
cg
parents:
diff changeset
    59
916f444c5cae intitial checkin
cg
parents:
diff changeset
    60
    "Created: 1.5.1996 / 15:04:17 / cg"
916f444c5cae intitial checkin
cg
parents:
diff changeset
    61
!
916f444c5cae intitial checkin
cg
parents:
diff changeset
    62
916f444c5cae intitial checkin
cg
parents:
diff changeset
    63
methodHome
916f444c5cae intitial checkin
cg
parents:
diff changeset
    64
    ^ self
916f444c5cae intitial checkin
cg
parents:
diff changeset
    65
916f444c5cae intitial checkin
cg
parents:
diff changeset
    66
    "Created: 1.5.1996 / 15:03:43 / cg"
916f444c5cae intitial checkin
cg
parents:
diff changeset
    67
!
916f444c5cae intitial checkin
cg
parents:
diff changeset
    68
916f444c5cae intitial checkin
cg
parents:
diff changeset
    69
numArgs
916f444c5cae intitial checkin
cg
parents:
diff changeset
    70
    ^ method numArgs
916f444c5cae intitial checkin
cg
parents:
diff changeset
    71
916f444c5cae intitial checkin
cg
parents:
diff changeset
    72
    "Created: 1.5.1996 / 15:04:35 / cg"
916f444c5cae intitial checkin
cg
parents:
diff changeset
    73
!
916f444c5cae intitial checkin
cg
parents:
diff changeset
    74
916f444c5cae intitial checkin
cg
parents:
diff changeset
    75
nvars
916f444c5cae intitial checkin
cg
parents:
diff changeset
    76
    ^ 0
916f444c5cae intitial checkin
cg
parents:
diff changeset
    77
916f444c5cae intitial checkin
cg
parents:
diff changeset
    78
    "Created: 1.5.1996 / 15:05:03 / cg"
916f444c5cae intitial checkin
cg
parents:
diff changeset
    79
!
916f444c5cae intitial checkin
cg
parents:
diff changeset
    80
916f444c5cae intitial checkin
cg
parents:
diff changeset
    81
receiver
41
eb7974d88088 checkin from browser
cg
parents: 32
diff changeset
    82
    method isStatic ifTrue:[
eb7974d88088 checkin from browser
cg
parents: 32
diff changeset
    83
        ^ method javaClass
eb7974d88088 checkin from browser
cg
parents: 32
diff changeset
    84
    ].
84
cbc2de53e086 *** empty log message ***
cg
parents: 52
diff changeset
    85
    frameBase > stack size ifTrue:[
cbc2de53e086 *** empty log message ***
cg
parents: 52
diff changeset
    86
        ^ nil
cbc2de53e086 *** empty log message ***
cg
parents: 52
diff changeset
    87
    ].
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
    88
    ^ stack at:frameBase
916f444c5cae intitial checkin
cg
parents:
diff changeset
    89
916f444c5cae intitial checkin
cg
parents:
diff changeset
    90
    "Created: 1.5.1996 / 15:04:03 / cg"
916f444c5cae intitial checkin
cg
parents:
diff changeset
    91
    "Modified: 1.5.1996 / 17:43:17 / cg"
916f444c5cae intitial checkin
cg
parents:
diff changeset
    92
!
916f444c5cae intitial checkin
cg
parents:
diff changeset
    93
32
0dbaa43a73db checkin from browser
cg
parents: 28
diff changeset
    94
selector            
0dbaa43a73db checkin from browser
cg
parents: 28
diff changeset
    95
    ^ (method name , method signature) asSymbol "/ signatureName
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
    96
916f444c5cae intitial checkin
cg
parents:
diff changeset
    97
    "Created: 1.5.1996 / 15:03:03 / cg"
88
8b66ed9a9a5d *** empty log message ***
cg
parents: 84
diff changeset
    98
!
8b66ed9a9a5d *** empty log message ***
cg
parents: 84
diff changeset
    99
117
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
   100
stack
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
   101
    ^ stack 
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
   102
!
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
   103
88
8b66ed9a9a5d *** empty log message ***
cg
parents: 84
diff changeset
   104
stackFrame
117
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
   105
sp < frameBase ifTrue:[
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
   106
 'oops - negative stackFrame' errorPrintCR.
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
   107
 ^ #()
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
   108
].
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
   109
    ^ stack copyFrom:frameBase to:(sp-1)
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
   110
! !
916f444c5cae intitial checkin
cg
parents:
diff changeset
   111
916f444c5cae intitial checkin
cg
parents:
diff changeset
   112
!JavaContext methodsFor:'accessing'!
916f444c5cae intitial checkin
cg
parents:
diff changeset
   113
916f444c5cae intitial checkin
cg
parents:
diff changeset
   114
class:aJavaClass method:aJavaMethod sender:aContext stack:s frameBase:f
916f444c5cae intitial checkin
cg
parents:
diff changeset
   115
    class := aJavaClass.
916f444c5cae intitial checkin
cg
parents:
diff changeset
   116
    method := aJavaMethod.
916f444c5cae intitial checkin
cg
parents:
diff changeset
   117
    sender := aContext.
916f444c5cae intitial checkin
cg
parents:
diff changeset
   118
    stack := s.
916f444c5cae intitial checkin
cg
parents:
diff changeset
   119
    frameBase := f
916f444c5cae intitial checkin
cg
parents:
diff changeset
   120
916f444c5cae intitial checkin
cg
parents:
diff changeset
   121
    "Modified: 1.5.1996 / 17:39:34 / cg"
916f444c5cae intitial checkin
cg
parents:
diff changeset
   122
    "Created: 1.5.1996 / 17:42:27 / cg"
916f444c5cae intitial checkin
cg
parents:
diff changeset
   123
!
916f444c5cae intitial checkin
cg
parents:
diff changeset
   124
117
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
   125
class:aJavaClass method:aJavaMethod sender:aContext stack:s stackPointer:spp frameBase:f
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
   126
    class := aJavaClass.
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
   127
    method := aJavaMethod.
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
   128
    sender := aContext.
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
   129
    stack := s.
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
   130
    sp := spp.
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
   131
    frameBase := f
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
   132
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
   133
    "Modified: 1.5.1996 / 17:39:34 / cg"
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
   134
    "Created: 1.5.1996 / 17:42:27 / cg"
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
   135
!
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
   136
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
   137
method
916f444c5cae intitial checkin
cg
parents:
diff changeset
   138
    ^ method.
916f444c5cae intitial checkin
cg
parents:
diff changeset
   139
916f444c5cae intitial checkin
cg
parents:
diff changeset
   140
    "Created: 1.5.1996 / 15:00:23 / cg"
916f444c5cae intitial checkin
cg
parents:
diff changeset
   141
    "Modified: 1.5.1996 / 15:00:47 / cg"
916f444c5cae intitial checkin
cg
parents:
diff changeset
   142
!
916f444c5cae intitial checkin
cg
parents:
diff changeset
   143
32
0dbaa43a73db checkin from browser
cg
parents: 28
diff changeset
   144
pc
0dbaa43a73db checkin from browser
cg
parents: 28
diff changeset
   145
    ^ pc
0dbaa43a73db checkin from browser
cg
parents: 28
diff changeset
   146
!
0dbaa43a73db checkin from browser
cg
parents: 28
diff changeset
   147
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
   148
sender
916f444c5cae intitial checkin
cg
parents:
diff changeset
   149
    ^ sender.
916f444c5cae intitial checkin
cg
parents:
diff changeset
   150
916f444c5cae intitial checkin
cg
parents:
diff changeset
   151
    "Modified: 1.5.1996 / 15:00:47 / cg"
916f444c5cae intitial checkin
cg
parents:
diff changeset
   152
    "Created: 1.5.1996 / 15:01:18 / cg"
32
0dbaa43a73db checkin from browser
cg
parents: 28
diff changeset
   153
!
0dbaa43a73db checkin from browser
cg
parents: 28
diff changeset
   154
0dbaa43a73db checkin from browser
cg
parents: 28
diff changeset
   155
setPC:anInteger
0dbaa43a73db checkin from browser
cg
parents: 28
diff changeset
   156
    pc := anInteger
117
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
   157
!
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
   158
125
c99addd65f73 *** empty log message ***
cg
parents: 117
diff changeset
   159
setPC:pcInteger SP:spInteger
c99addd65f73 *** empty log message ***
cg
parents: 117
diff changeset
   160
    pc := pcInteger.
c99addd65f73 *** empty log message ***
cg
parents: 117
diff changeset
   161
    sp := spInteger.
c99addd65f73 *** empty log message ***
cg
parents: 117
diff changeset
   162
!
c99addd65f73 *** empty log message ***
cg
parents: 117
diff changeset
   163
117
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
   164
setSP:anInteger
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
   165
    sp := anInteger
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
   166
!
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
   167
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
   168
setStack:aCollection
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
   169
    stack := aCollection
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
   170
!
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
   171
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
   172
sp
4625d32e5a00 rewritten to use an Array for the stack,
cg
parents: 88
diff changeset
   173
    ^ sp
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
   174
! !
916f444c5cae intitial checkin
cg
parents:
diff changeset
   175
916f444c5cae intitial checkin
cg
parents:
diff changeset
   176
!JavaContext methodsFor:'printing & storing'!
916f444c5cae intitial checkin
cg
parents:
diff changeset
   177
916f444c5cae intitial checkin
cg
parents:
diff changeset
   178
printString
52
1dc41619b6f8 checkin from browser
cg
parents: 43
diff changeset
   179
    |clsName nm mS recCls rec recClsName rnm|
1dc41619b6f8 checkin from browser
cg
parents: 43
diff changeset
   180
1dc41619b6f8 checkin from browser
cg
parents: 43
diff changeset
   181
    clsName := class name.
1dc41619b6f8 checkin from browser
cg
parents: 43
diff changeset
   182
    (Smalltalk includes:(clsName asSymbol)) ifTrue:[
1dc41619b6f8 checkin from browser
cg
parents: 43
diff changeset
   183
        nm := 'JAVA-' , clsName
1dc41619b6f8 checkin from browser
cg
parents: 43
diff changeset
   184
    ] ifFalse:[
1dc41619b6f8 checkin from browser
cg
parents: 43
diff changeset
   185
        (class fullName startsWith:'java/lang/') ifTrue:[
1dc41619b6f8 checkin from browser
cg
parents: 43
diff changeset
   186
            nm := clsName
1dc41619b6f8 checkin from browser
cg
parents: 43
diff changeset
   187
        ] ifFalse:[
1dc41619b6f8 checkin from browser
cg
parents: 43
diff changeset
   188
            nm := class fullName
1dc41619b6f8 checkin from browser
cg
parents: 43
diff changeset
   189
        ].
1dc41619b6f8 checkin from browser
cg
parents: 43
diff changeset
   190
    ].
1dc41619b6f8 checkin from browser
cg
parents: 43
diff changeset
   191
    mS := nm , '::' , method signatureName.
1dc41619b6f8 checkin from browser
cg
parents: 43
diff changeset
   192
1dc41619b6f8 checkin from browser
cg
parents: 43
diff changeset
   193
    rec := self receiver.
1dc41619b6f8 checkin from browser
cg
parents: 43
diff changeset
   194
    recCls := rec class.
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
   195
52
1dc41619b6f8 checkin from browser
cg
parents: 43
diff changeset
   196
    (rec isKindOf:JavaObject) ifFalse:[
1dc41619b6f8 checkin from browser
cg
parents: 43
diff changeset
   197
        rnm := '[' , recCls name , ']'
1dc41619b6f8 checkin from browser
cg
parents: 43
diff changeset
   198
    ] ifTrue:[
1dc41619b6f8 checkin from browser
cg
parents: 43
diff changeset
   199
        recClsName := recCls name.
1dc41619b6f8 checkin from browser
cg
parents: 43
diff changeset
   200
        (Smalltalk includes:(recClsName asSymbol)) ifTrue:[
1dc41619b6f8 checkin from browser
cg
parents: 43
diff changeset
   201
            rnm := 'JAVA-' , recClsName
1dc41619b6f8 checkin from browser
cg
parents: 43
diff changeset
   202
        ] ifFalse:[
1dc41619b6f8 checkin from browser
cg
parents: 43
diff changeset
   203
            (recCls fullName startsWith:'java/lang/') ifTrue:[
1dc41619b6f8 checkin from browser
cg
parents: 43
diff changeset
   204
                rnm := recClsName
1dc41619b6f8 checkin from browser
cg
parents: 43
diff changeset
   205
            ] ifFalse:[
1dc41619b6f8 checkin from browser
cg
parents: 43
diff changeset
   206
                rnm := recCls fullName
1dc41619b6f8 checkin from browser
cg
parents: 43
diff changeset
   207
            ].
1dc41619b6f8 checkin from browser
cg
parents: 43
diff changeset
   208
        ].
1dc41619b6f8 checkin from browser
cg
parents: 43
diff changeset
   209
    ].
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
   210
52
1dc41619b6f8 checkin from browser
cg
parents: 43
diff changeset
   211
    (rnm ~= nm) ifTrue:[
1dc41619b6f8 checkin from browser
cg
parents: 43
diff changeset
   212
        ^ rnm , '>>' , mS
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
   213
    ].
916f444c5cae intitial checkin
cg
parents:
diff changeset
   214
916f444c5cae intitial checkin
cg
parents:
diff changeset
   215
    ^ mS
916f444c5cae intitial checkin
cg
parents:
diff changeset
   216
916f444c5cae intitial checkin
cg
parents:
diff changeset
   217
    "Created: 1.5.1996 / 15:07:43 / cg"
916f444c5cae intitial checkin
cg
parents:
diff changeset
   218
    "Modified: 1.5.1996 / 17:58:16 / cg"
916f444c5cae intitial checkin
cg
parents:
diff changeset
   219
! !
916f444c5cae intitial checkin
cg
parents:
diff changeset
   220
84
cbc2de53e086 *** empty log message ***
cg
parents: 52
diff changeset
   221
!JavaContext  class methodsFor:'documentation'!
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
   222
916f444c5cae intitial checkin
cg
parents:
diff changeset
   223
version
125
c99addd65f73 *** empty log message ***
cg
parents: 117
diff changeset
   224
    ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaContext.st,v 1.9 1996/07/09 20:50:26 cg Exp $'
28
916f444c5cae intitial checkin
cg
parents:
diff changeset
   225
! !