src/JavaContext.st
author vranyj1
Fri, 25 Nov 2011 08:02:14 +0000
branchjk_new_structure
changeset 1155 d6f6d5fc0343
parent 1152 040cba55a7d2
child 1452 69dcb9c33742
permissions -rw-r--r--
(none)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
     1
"
877
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 752
diff changeset
     2
 COPYRIGHT (c) 1996-2011 by Claus Gittinger
1152
040cba55a7d2 Copyright fixes
vranyj1
parents: 1122
diff changeset
     3
1155
vranyj1
parents: 1152
diff changeset
     4
 New code and modifications done at SWING Research Group [1]:
1152
040cba55a7d2 Copyright fixes
vranyj1
parents: 1122
diff changeset
     5
877
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 752
diff changeset
     6
 COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 752
diff changeset
     7
                            SWING Research Group, Czech Technical University in Prague
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 752
diff changeset
     8
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
     9
 This software is furnished under a license and may be used
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    10
 only in accordance with the terms of that license and with the
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    11
 inclusion of the above copyright notice.   This software may not
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    12
 be provided or otherwise made available to, or used by, any
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    13
 other person.  No title to or ownership of the software is
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    14
 hereby transferred.
877
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 752
diff changeset
    15
1155
vranyj1
parents: 1152
diff changeset
    16
 [1] Code written at SWING Research Group contains a signature
vranyj1
parents: 1152
diff changeset
    17
     of one of the above copright owners. For exact set of such code,
vranyj1
parents: 1152
diff changeset
    18
     see the differences between this version and version stx:libjava
1152
040cba55a7d2 Copyright fixes
vranyj1
parents: 1122
diff changeset
    19
     as of 1.9.2010
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    20
"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    21
"{ Package: 'stx:libjava' }"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    22
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    23
Context variableSubclass:#JavaContext
1093
255c230a1c55 hacking monitors, not working yet :P
hlopkmar
parents: 1022
diff changeset
    24
	instanceVariableNames:'exArg exPC byteCode constPool acqrMonitors'
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    25
	classVariableNames:''
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    26
	poolDictionaries:''
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    27
	category:'Languages-Java-Support'
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    28
!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    29
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    30
!JavaContext class methodsFor:'documentation'!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    31
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    32
copyright
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    33
"
877
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 752
diff changeset
    34
 COPYRIGHT (c) 1996-2011 by Claus Gittinger
1152
040cba55a7d2 Copyright fixes
vranyj1
parents: 1122
diff changeset
    35
1155
vranyj1
parents: 1152
diff changeset
    36
 New code and modifications done at SWING Research Group [1]:
1152
040cba55a7d2 Copyright fixes
vranyj1
parents: 1122
diff changeset
    37
877
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 752
diff changeset
    38
 COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 752
diff changeset
    39
                            SWING Research Group, Czech Technical University in Prague
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 752
diff changeset
    40
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    41
 This software is furnished under a license and may be used
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    42
 only in accordance with the terms of that license and with the
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    43
 inclusion of the above copyright notice.   This software may not
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    44
 be provided or otherwise made available to, or used by, any
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    45
 other person.  No title to or ownership of the software is
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    46
 hereby transferred.
877
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 752
diff changeset
    47
1155
vranyj1
parents: 1152
diff changeset
    48
 [1] Code written at SWING Research Group contains a signature
vranyj1
parents: 1152
diff changeset
    49
     of one of the above copright owners. For exact set of such code,
vranyj1
parents: 1152
diff changeset
    50
     see the differences between this version and version stx:libjava
1152
040cba55a7d2 Copyright fixes
vranyj1
parents: 1122
diff changeset
    51
     as of 1.9.2010
877
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 752
diff changeset
    52
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 752
diff changeset
    53
"
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    54
! !
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    55
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    56
!JavaContext methodsFor:'* As yet uncategorized *'!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    57
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    58
markForException
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    59
    "set the exception handler flag in the receiver.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    60
     The JVM needs this to enter an exception handler instead of restarting
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    61
     from the beginning (when the context is restarted).
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    62
     - a highly internal mechanism and not for public use."
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    63
"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    64
%{  /* NOCONTEXT */
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    65
#ifdef __JAVA_EX_PEND
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    66
     /* actually no longer - only a non-nil exPC is now used as marker */
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    67
     __INST(flags) = (OBJ)((INT)__INST(flags) | __MASKSMALLINT(__JAVA_EX_PEND));
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    68
#endif
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    69
%}
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    70
"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    71
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    72
    "Modified: / 13-12-1995 / 19:05:22 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    73
    "Modified: / 25-10-2010 / 17:19:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    74
! !
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    75
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    76
!JavaContext methodsFor:'ST context mimicri'!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    77
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    78
arg1Index
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    79
    "the java stack contains the receiver in a non-static
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    80
     method, as slot 0. Therefore, the first arg is found at slot2
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    81
     if this is for a non-static method"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    82
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    83
    self method isStatic ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    84
	^ 1
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    85
    ].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    86
    ^ 2
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    87
!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    88
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    89
argAt:n
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    90
    "return the i'th argument (1..nArgs)"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    91
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    92
    ^ self at:(self arg1Index - 1 + n)
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    93
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    94
    "Created: / 2.1.1998 / 17:54:13 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    95
    "Modified: / 2.1.1998 / 21:39:30 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    96
!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    97
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    98
argAt:n put:value
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    99
    "change the i'th argument (1..nArgs)"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   100
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   101
    ^ super argAt:(self arg1Index - 1 + n) put:value
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   102
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   103
    "Created: / 2.1.1998 / 17:54:34 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   104
    "Modified: / 2.1.1998 / 21:35:19 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   105
!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   106
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   107
args
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   108
    "return an array filled with the arguments of this context"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   109
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   110
    |n|
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   111
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   112
    n := self numArgs.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   113
    n == 0 ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   114
	"/ little optimization here - avoid creating empty containers
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   115
	^ #()
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   116
    ].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   117
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   118
    ^ (Array new:n) replaceFrom:1 to:n with:self startingAt:(self arg1Index).
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   119
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   120
    "Created: / 2.1.1998 / 17:54:57 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   121
    "Modified: / 2.1.1998 / 21:34:44 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   122
!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   123
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   124
argsAndVars
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   125
    "return an array filled with the arguments and variables of this context"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   126
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   127
    |n|
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   128
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   129
    n := self numArgs + self numVars.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   130
    n == 0 ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   131
	"/ little optimization here - avoid creating empty containers
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   132
	^ #()
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   133
    ].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   134
    ^ (Array new:n) replaceFrom:1 to:n with:self startingAt:(self arg1Index).
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   135
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   136
    "Created: / 2.1.1998 / 17:55:14 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   137
    "Modified: / 13.1.1998 / 15:44:56 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   138
!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   139
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   140
lineNumber
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   141
    |nr pc|
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   142
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   143
    pc := self pc.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   144
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   145
"/ 'ask line for pc:' print. pc printCR.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   146
    pc isNil ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   147
	nr := self lineNumberFromMethod.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   148
	nr notNil ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   149
	    ^ nr
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   150
	].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   151
	" '-> 0 [a]' printCR. "
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   152
	^0
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   153
    ].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   154
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   155
    nr := self method lineNumberForPC:pc.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   156
    nr isNil ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   157
	nr := self lineNumberFromMethod.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   158
	nr notNil ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   159
	    ^ nr
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   160
	].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   161
	" '-> 0 [b]' printCR. "
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   162
	^ 0
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   163
    ].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   164
"/ '-> ' print. nr printCR.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   165
     ^ nr.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   166
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   167
    "Created: / 1.5.1996 / 15:05:47 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   168
    "Modified: / 15.1.1998 / 15:25:29 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   169
!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   170
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   171
lineNumberFromMethod
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   172
    |m|
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   173
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   174
    m := self method.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   175
    m notNil ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   176
	^ m lineNumber
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   177
    ].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   178
    ^ nil
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   179
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   180
    "Created: / 4.1.1998 / 23:34:45 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   181
    "Modified: / 4.1.1998 / 23:35:55 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   182
!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   183
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   184
method
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   185
    "the method may be found in the interpreter temps ..."
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   186
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   187
    method isJavaMethod ifTrue:[^ method].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   188
    ^ super method
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   189
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   190
    "Created: / 1.5.1996 / 15:03:43 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   191
    "Modified: / 25.9.1999 / 23:26:40 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   192
!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   193
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   194
numArgs
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   195
    "return the number of args.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   196
     Redefined since Java keeps the receiver of a non-static method
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   197
     at local slot 1."
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   198
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   199
    |n|
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   200
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   201
    n := super numArgs.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   202
    self method isStatic ifFalse:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   203
	n := n - 1
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   204
    ].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   205
    ^ n
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   206
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   207
    "Created: / 2.1.1998 / 22:21:24 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   208
!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   209
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   210
numTemps
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   211
    "return the number of temporary variables of the Method.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   212
     Redefined since Java keeps the receiver of a non-static method
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   213
     at local slot 1."
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   214
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   215
    |n|
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   216
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   217
    n := self size - super numVars - super numArgs.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   218
    ^ n
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   219
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   220
    "Created: / 13.1.1998 / 16:52:32 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   221
    "Modified: / 13.1.1998 / 17:23:27 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   222
!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   223
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   224
numVars
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   225
    "return the number of locals.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   226
     Redefined since Java keeps the receiver of a non-static method
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   227
     at local slot 0 and holds the args as locals."
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   228
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   229
    |n|
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   230
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   231
    n := super numVars.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   232
    ^ (n - self numArgs) max:0
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   233
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   234
    "Created: / 13.1.1998 / 17:03:08 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   235
    "Modified: / 13.1.1998 / 17:25:16 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   236
!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   237
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   238
pc
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   239
    lineNr isNil ifTrue:[^ nil].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   240
    ^ lineNr bitAnd:16rFFFF
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   241
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   242
    "Created: / 4.1.1998 / 23:33:48 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   243
    "Modified: / 10.11.1998 / 13:20:12 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   244
!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   245
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   246
quickLineNumber
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   247
    "the lineNumber - without decompiling"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   248
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   249
    ^ self method quickLineNumberForPC:self pc
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   250
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   251
    "Created: / 10.11.1998 / 14:20:30 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   252
!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   253
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   254
selector
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   255
    "the selector can be extracted from the method.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   256
     the method may be found in the interpreter temps ..."
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   257
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   258
    |s m|
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   259
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   260
    selector isNil ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   261
	m := self method.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   262
	m notNil ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   263
	    ^ m name
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   264
	]
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   265
    ].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   266
    ^ super selector
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   267
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   268
    "Modified: / 30.12.1997 / 17:22:06 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   269
    "Created: / 30.12.1997 / 17:23:47 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   270
!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   271
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   272
setPC:newPC
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   273
    lineNr := newPC
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   274
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   275
    "Created: / 5.1.1998 / 00:09:02 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   276
!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   277
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   278
temporaries
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   279
    "return an array filled with the arguments and variables of this context"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   280
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   281
    |n nSkipped|
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   282
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   283
    "/ the flas-numVars includes the receiver and args
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   284
    nSkipped := super numVars "self numArgs + self numVars".
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   285
    "/ but my context setup is args+numvars.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   286
    nSkipped := super numArgs + super numVars.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   287
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   288
    n := self size - nSkipped.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   289
    n == 0 ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   290
	"/ little optimization here - avaoid creating empty containers
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   291
	^ #()
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   292
    ].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   293
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   294
    ^ (Array new:n) replaceFrom:1 to:n with:self startingAt:nSkipped+1.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   295
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   296
    "Created: / 13.1.1998 / 15:44:12 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   297
    "Modified: / 13.1.1998 / 17:22:54 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   298
!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   299
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   300
vars
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   301
    "return an array filled with the local variables of this context"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   302
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   303
    |nonVars mySize|
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   304
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   305
    mySize := self numVars.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   306
    mySize == 0 ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   307
	"/ little optimization here - avaoid creating empty containers
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   308
	^ #()
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   309
    ].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   310
    nonVars := (self arg1Index-1) + self numArgs.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   311
    ^ (Array new:mySize) replaceFrom:1 to:mySize with:self startingAt:nonVars+1
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   312
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   313
    "Created: / 13.1.1998 / 16:48:16 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   314
! !
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   315
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   316
!JavaContext methodsFor:'accessing'!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   317
1093
255c230a1c55 hacking monitors, not working yet :P
hlopkmar
parents: 1022
diff changeset
   318
acquiredMonitors
255c230a1c55 hacking monitors, not working yet :P
hlopkmar
parents: 1022
diff changeset
   319
^acqrMonitors
255c230a1c55 hacking monitors, not working yet :P
hlopkmar
parents: 1022
diff changeset
   320
255c230a1c55 hacking monitors, not working yet :P
hlopkmar
parents: 1022
diff changeset
   321
    "Created: / 08-11-2011 / 12:23:18 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
255c230a1c55 hacking monitors, not working yet :P
hlopkmar
parents: 1022
diff changeset
   322
!
255c230a1c55 hacking monitors, not working yet :P
hlopkmar
parents: 1022
diff changeset
   323
1096
c543f127c67a fixed some stupid mistakes, but still not working
hlopkmar
parents: 1095
diff changeset
   324
acquiredMonitorsDo: aBlock 
1102
df54d5b34c6b i broke something important in last commit - quickly reverting back :)
hlopkmar
parents: 1101
diff changeset
   325
    acqrMonitors isNil ifTrue: [ ^self ].
1097
41def5679e28 finally working monitors yeeaah
hlopkmar
parents: 1096
diff changeset
   326
    acqrMonitors copy reverseDo: aBlock.
1094
68b154263d74 fixes in monitors, still not working
hlopkmar
parents: 1093
diff changeset
   327
68b154263d74 fixes in monitors, still not working
hlopkmar
parents: 1093
diff changeset
   328
    "Created: / 08-11-2011 / 15:03:31 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
1102
df54d5b34c6b i broke something important in last commit - quickly reverting back :)
hlopkmar
parents: 1101
diff changeset
   329
    "Modified: / 08-11-2011 / 21:46:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1094
68b154263d74 fixes in monitors, still not working
hlopkmar
parents: 1093
diff changeset
   330
!
68b154263d74 fixes in monitors, still not working
hlopkmar
parents: 1093
diff changeset
   331
1095
6d0bfccd9ae7 tiny logging of monitors
hlopkmar
parents: 1094
diff changeset
   332
addMonitor: mon 
1100
1405b1485a66 fixes and guards for monitors
hlopkmar
parents: 1098
diff changeset
   333
    self assert: (acqrMonitors isNil or: [ acqrMonitors isOrderedCollection ]).
1405b1485a66 fixes and guards for monitors
hlopkmar
parents: 1098
diff changeset
   334
    acqrMonitors ifNil: [ acqrMonitors := Stack new ].
1405b1485a66 fixes and guards for monitors
hlopkmar
parents: 1098
diff changeset
   335
    acqrMonitors push: mon.
1122
2f8e947cfda2 in-the-middle-of-work commit
hlopkmar
parents: 1102
diff changeset
   336
    self markForUnwind.
1093
255c230a1c55 hacking monitors, not working yet :P
hlopkmar
parents: 1022
diff changeset
   337
255c230a1c55 hacking monitors, not working yet :P
hlopkmar
parents: 1022
diff changeset
   338
    "Created: / 08-11-2011 / 14:19:21 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
1098
vranyj1
parents: 1097
diff changeset
   339
    "Modified: / 08-11-2011 / 21:40:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1122
2f8e947cfda2 in-the-middle-of-work commit
hlopkmar
parents: 1102
diff changeset
   340
    "Modified: / 17-11-2011 / 19:13:15 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
1093
255c230a1c55 hacking monitors, not working yet :P
hlopkmar
parents: 1022
diff changeset
   341
!
255c230a1c55 hacking monitors, not working yet :P
hlopkmar
parents: 1022
diff changeset
   342
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   343
programmingLanguage
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   344
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   345
    ^JavaLanguage instance
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   346
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   347
    "Created: / 17-03-2011 / 10:17:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1093
255c230a1c55 hacking monitors, not working yet :P
hlopkmar
parents: 1022
diff changeset
   348
!
255c230a1c55 hacking monitors, not working yet :P
hlopkmar
parents: 1022
diff changeset
   349
255c230a1c55 hacking monitors, not working yet :P
hlopkmar
parents: 1022
diff changeset
   350
removeMonitor: mon 
1122
2f8e947cfda2 in-the-middle-of-work commit
hlopkmar
parents: 1102
diff changeset
   351
    | poppedObject |
1095
6d0bfccd9ae7 tiny logging of monitors
hlopkmar
parents: 1094
diff changeset
   352
    acqrMonitors isNil ifTrue: [
1100
1405b1485a66 fixes and guards for monitors
hlopkmar
parents: 1098
diff changeset
   353
        Logger 
1405b1485a66 fixes and guards for monitors
hlopkmar
parents: 1098
diff changeset
   354
            log: ('removeMonitor: called but no monitors in acqrMonitors (%1)' 
1405b1485a66 fixes and guards for monitors
hlopkmar
parents: 1098
diff changeset
   355
                    bindWith: self)
1405b1485a66 fixes and guards for monitors
hlopkmar
parents: 1098
diff changeset
   356
            severity: #warn
1405b1485a66 fixes and guards for monitors
hlopkmar
parents: 1098
diff changeset
   357
            facility: #JVM.
1405b1485a66 fixes and guards for monitors
hlopkmar
parents: 1098
diff changeset
   358
        self breakPoint: #mh.
1405b1485a66 fixes and guards for monitors
hlopkmar
parents: 1098
diff changeset
   359
        ^ self.
1094
68b154263d74 fixes in monitors, still not working
hlopkmar
parents: 1093
diff changeset
   360
    ].
1100
1405b1485a66 fixes and guards for monitors
hlopkmar
parents: 1098
diff changeset
   361
    poppedObject := acqrMonitors top.
1405b1485a66 fixes and guards for monitors
hlopkmar
parents: 1098
diff changeset
   362
    self assert: (poppedObject == mon).
1405b1485a66 fixes and guards for monitors
hlopkmar
parents: 1098
diff changeset
   363
    acqrMonitors remove: mon
1405b1485a66 fixes and guards for monitors
hlopkmar
parents: 1098
diff changeset
   364
        ifAbsent: [
1405b1485a66 fixes and guards for monitors
hlopkmar
parents: 1098
diff changeset
   365
            Logger 
1405b1485a66 fixes and guards for monitors
hlopkmar
parents: 1098
diff changeset
   366
                log: ('removeMonitor: called but no such monitor in acqrMonitors (%1)' 
1405b1485a66 fixes and guards for monitors
hlopkmar
parents: 1098
diff changeset
   367
                        bindWith: self)
1405b1485a66 fixes and guards for monitors
hlopkmar
parents: 1098
diff changeset
   368
                severity: #warn
1405b1485a66 fixes and guards for monitors
hlopkmar
parents: 1098
diff changeset
   369
                facility: #JVM.
1405b1485a66 fixes and guards for monitors
hlopkmar
parents: 1098
diff changeset
   370
            self breakPoint: #mh.
1405b1485a66 fixes and guards for monitors
hlopkmar
parents: 1098
diff changeset
   371
            ^ self.
1122
2f8e947cfda2 in-the-middle-of-work commit
hlopkmar
parents: 1102
diff changeset
   372
        ].
2f8e947cfda2 in-the-middle-of-work commit
hlopkmar
parents: 1102
diff changeset
   373
        acqrMonitors isEmpty ifTrue: [self unmarkForUnwind].
1093
255c230a1c55 hacking monitors, not working yet :P
hlopkmar
parents: 1022
diff changeset
   374
255c230a1c55 hacking monitors, not working yet :P
hlopkmar
parents: 1022
diff changeset
   375
    "Created: / 08-11-2011 / 14:19:58 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
1098
vranyj1
parents: 1097
diff changeset
   376
    "Modified: / 08-11-2011 / 21:39:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1122
2f8e947cfda2 in-the-middle-of-work commit
hlopkmar
parents: 1102
diff changeset
   377
    "Modified: / 17-11-2011 / 19:14:29 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   378
! !
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   379
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   380
!JavaContext methodsFor:'exception handler support'!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   381
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   382
exceptionArg:aJavaException
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   383
    exArg := aJavaException.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   384
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   385
    "Created: / 7.1.1998 / 21:36:56 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   386
!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   387
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   388
exceptionArg:aJavaException pc:newPc
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   389
    exArg := aJavaException.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   390
    exPC := newPc.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   391
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   392
    "Created: / 7.1.1998 / 21:36:56 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   393
! !
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   394
1098
vranyj1
parents: 1097
diff changeset
   395
!JavaContext methodsFor:'non local control flow'!
vranyj1
parents: 1097
diff changeset
   396
vranyj1
parents: 1097
diff changeset
   397
unwindAndRestartForJavaException
1102
df54d5b34c6b i broke something important in last commit - quickly reverting back :)
hlopkmar
parents: 1101
diff changeset
   398
1098
vranyj1
parents: 1097
diff changeset
   399
    "Called by JavaVM>>throwException: unwinds the stack
vranyj1
parents: 1097
diff changeset
   400
     up to this context and restarts it so an exception handler
vranyj1
parents: 1097
diff changeset
   401
     executes"
1102
df54d5b34c6b i broke something important in last commit - quickly reverting back :)
hlopkmar
parents: 1101
diff changeset
   402
df54d5b34c6b i broke something important in last commit - quickly reverting back :)
hlopkmar
parents: 1101
diff changeset
   403
    | con wasMarked |
df54d5b34c6b i broke something important in last commit - quickly reverting back :)
hlopkmar
parents: 1101
diff changeset
   404
1098
vranyj1
parents: 1097
diff changeset
   405
    "Each context that has a monitor acquired has
vranyj1
parents: 1097
diff changeset
   406
     and unwind action that release all monitors acquired.
vranyj1
parents: 1097
diff changeset
   407
     However, we DONT want my monitors to be released,
vranyj1
parents: 1097
diff changeset
   408
     so we temporarily unmark this context for unwind and
vranyj1
parents: 1097
diff changeset
   409
     then mark it again, eventually"
1102
df54d5b34c6b i broke something important in last commit - quickly reverting back :)
hlopkmar
parents: 1101
diff changeset
   410
1098
vranyj1
parents: 1097
diff changeset
   411
    wasMarked := self isUnwindContext.
1102
df54d5b34c6b i broke something important in last commit - quickly reverting back :)
hlopkmar
parents: 1101
diff changeset
   412
    wasMarked ifTrue:[self unmarkForUnwind].    
df54d5b34c6b i broke something important in last commit - quickly reverting back :)
hlopkmar
parents: 1101
diff changeset
   413
    self senderIsNil ifFalse:[
df54d5b34c6b i broke something important in last commit - quickly reverting back :)
hlopkmar
parents: 1101
diff changeset
   414
        con := thisContext evaluateUnwindActionsUpTo:self.
1098
vranyj1
parents: 1097
diff changeset
   415
    ].
1102
df54d5b34c6b i broke something important in last commit - quickly reverting back :)
hlopkmar
parents: 1101
diff changeset
   416
    wasMarked ifTrue:[self markForUnwind].
df54d5b34c6b i broke something important in last commit - quickly reverting back :)
hlopkmar
parents: 1101
diff changeset
   417
df54d5b34c6b i broke something important in last commit - quickly reverting back :)
hlopkmar
parents: 1101
diff changeset
   418
    "oops, if nil, I am not on the calling chain;
1098
vranyj1
parents: 1097
diff changeset
   419
     (bad bad, unwind action have already been performed.
1102
df54d5b34c6b i broke something important in last commit - quickly reverting back :)
hlopkmar
parents: 1101
diff changeset
   420
      should we check for this situation first and NOT evaluate
df54d5b34c6b i broke something important in last commit - quickly reverting back :)
hlopkmar
parents: 1101
diff changeset
   421
      the unwind actions in this case ?)
1098
vranyj1
parents: 1097
diff changeset
   422
    "
1102
df54d5b34c6b i broke something important in last commit - quickly reverting back :)
hlopkmar
parents: 1101
diff changeset
   423
    con isNil ifTrue:[
1098
vranyj1
parents: 1097
diff changeset
   424
        "
vranyj1
parents: 1097
diff changeset
   425
         tried to return to a context which is already dead
1102
df54d5b34c6b i broke something important in last commit - quickly reverting back :)
hlopkmar
parents: 1101
diff changeset
   426
         (i.e. the method/block has already executed a return)
df54d5b34c6b i broke something important in last commit - quickly reverting back :)
hlopkmar
parents: 1101
diff changeset
   427
        "
df54d5b34c6b i broke something important in last commit - quickly reverting back :)
hlopkmar
parents: 1101
diff changeset
   428
        ^ self invalidReturnOrRestartError:#'unwindAndRestart:' with:nil
1098
vranyj1
parents: 1097
diff changeset
   429
    ].
1102
df54d5b34c6b i broke something important in last commit - quickly reverting back :)
hlopkmar
parents: 1101
diff changeset
   430
    "
1098
vranyj1
parents: 1097
diff changeset
   431
     now, that all unwind-actions are done, I can use the
vranyj1
parents: 1097
diff changeset
   432
     low-level restart ...
vranyj1
parents: 1097
diff changeset
   433
    "
vranyj1
parents: 1097
diff changeset
   434
    ^ self restart
vranyj1
parents: 1097
diff changeset
   435
vranyj1
parents: 1097
diff changeset
   436
    "Created: / 08-11-2011 / 22:00:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
vranyj1
parents: 1097
diff changeset
   437
! !
vranyj1
parents: 1097
diff changeset
   438
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   439
!JavaContext methodsFor:'printing & storing'!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   440
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   441
receiverPrintString
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   442
    "return a string describing the receiver of the context"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   443
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   444
    |receiverClass receiverClassName newString implementorClass searchClass|
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   445
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   446
"/ %{
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   447
"/     /*
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   448
"/      * special handling for (invalid) free objects.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   449
"/      * these only appear if some primitiveCode does not correctly use SEND macros,
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   450
"/      * which may lead to sends to free objects. In normal operation, this 'cannot' happen.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   451
"/      */
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   452
"/     if (__isNonNilObject(__INST(receiver)) && (__qClass(__INST(receiver))==nil)) {
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   453
"/         receiverClassName = __MKSTRING("FreeObject");
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   454
"/     }
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   455
"/ %}.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   456
"/    receiverClassName notNil ifTrue:[^ receiverClassName].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   457
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   458
    receiverClass := receiver class.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   459
    "/ java has no class-methods ...
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   460
    receiverClass := receiverClass theNonMetaclass.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   461
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   462
    receiverClassName := receiverClass nameInBrowser.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   463
    (receiverClass == SmallInteger) ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   464
	newString := '(' , receiver printString , ') ' , receiverClassName
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   465
    ] ifFalse:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   466
	newString := receiverClassName
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   467
    ].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   468
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   469
    "
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   470
     kludge to avoid slow search for containing class
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   471
    "
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   472
    (selector ~~ #doIt and:[selector ~~ #doIt:]) ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   473
	implementorClass := self methodClass.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   474
    ].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   475
    implementorClass notNil ifTrue: [
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   476
	(implementorClass ~~ receiverClass) ifTrue: [
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   477
	    newString := newString , '>>>',
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   478
			 implementorClass nameInBrowser printString
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   479
	]
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   480
    ] ifFalse:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   481
	searchClass := self searchClass.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   482
	searchClass ~~ receiverClass ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   483
	    newString := newString , '>>>' , searchClass nameInBrowser
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   484
	].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   485
"/        "
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   486
"/         kludge for doIt - these unbound methods are not
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   487
"/         found in the classes methodDictionary
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   488
"/        "
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   489
"/        (selector ~~ #doIt and:[selector ~~ #doIt:]) ifTrue:[
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   490
"/            newString := newString , '>>>**NONE**'
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   491
"/        ]
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   492
    ].
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   493
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   494
    ^ newString
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   495
! !
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   496
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   497
!JavaContext methodsFor:'queries'!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   498
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   499
hasStackToShow
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   500
    "private interface to the debugger.
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   501
     Smalltalk contexts return false here - other language frames
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   502
     (i.e. Java frames) may want to show the evaluation stack"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   503
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   504
    ^ true
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   505
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   506
    "Modified: / 13.5.1997 / 16:31:12 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   507
    "Created: / 7.5.1998 / 01:23:57 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   508
!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   509
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   510
isJavaContext
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   511
    "return true, if this is a javaContext."
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   512
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   513
    ^ true
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   514
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   515
    "Created: / 8.5.1998 / 21:23:47 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   516
!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   517
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   518
stackFrame
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   519
    "private interface to the debugger."
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   520
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   521
    ^ (1 to:self size) collect:[:i | self at:i]
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   522
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   523
    "Created: / 7.5.1998 / 01:26:19 / cg"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   524
! !
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   525
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   526
!JavaContext class methodsFor:'documentation'!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   527
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   528
version
1022
38b710d7dfbc svn properties fixed
vranyj1
parents: 923
diff changeset
   529
    ^ '$Id$'
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   530
!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   531
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   532
version_SVN
1022
38b710d7dfbc svn properties fixed
vranyj1
parents: 923
diff changeset
   533
    ^ '$Id$'
1093
255c230a1c55 hacking monitors, not working yet :P
hlopkmar
parents: 1022
diff changeset
   534
! !