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