BlockContext.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Tue, 09 Jul 2013 22:51:30 +0100
branchjv
changeset 18071 009cf668b0ed
parent 18066 89d51443ba6f
parent 15454 fd304e6048f0
child 18442 bd42fa983e3f
permissions -rw-r--r--
Merged d262e3aecaca and e8be1358e39b (branch default - CVS HEAD)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     1
"
a27a279701f8 Initial revision
claus
parents:
diff changeset
     2
 COPYRIGHT (c) 1993 by Claus Gittinger
165
63341654cfb8 *** empty log message ***
claus
parents: 154
diff changeset
     3
	      All Rights Reserved
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     4
a27a279701f8 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
a27a279701f8 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
a27a279701f8 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
a27a279701f8 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
a27a279701f8 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
a27a279701f8 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
a27a279701f8 Initial revision
claus
parents:
diff changeset
    11
"
5528
2a96dd29ca28 guess home of optimized block contexts
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
    12
"{ Package: 'stx:libbasic' }"
2a96dd29ca28 guess home of optimized block contexts
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
    13
4623
f5a12735a692 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
    14
Context variableSubclass:#BlockContext
1183
e3d58d115e53 subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    15
	instanceVariableNames:''
e3d58d115e53 subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    16
	classVariableNames:''
e3d58d115e53 subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    17
	poolDictionaries:''
e3d58d115e53 subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    18
	category:'Kernel-Methods'
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    19
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    20
88
81dacba7a63a *** empty log message ***
claus
parents: 68
diff changeset
    21
!BlockContext class methodsFor:'documentation'!
81dacba7a63a *** empty log message ***
claus
parents: 68
diff changeset
    22
81dacba7a63a *** empty log message ***
claus
parents: 68
diff changeset
    23
copyright
81dacba7a63a *** empty log message ***
claus
parents: 68
diff changeset
    24
"
81dacba7a63a *** empty log message ***
claus
parents: 68
diff changeset
    25
 COPYRIGHT (c) 1993 by Claus Gittinger
165
63341654cfb8 *** empty log message ***
claus
parents: 154
diff changeset
    26
	      All Rights Reserved
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    27
88
81dacba7a63a *** empty log message ***
claus
parents: 68
diff changeset
    28
 This software is furnished under a license and may be used
81dacba7a63a *** empty log message ***
claus
parents: 68
diff changeset
    29
 only in accordance with the terms of that license and with the
81dacba7a63a *** empty log message ***
claus
parents: 68
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
81dacba7a63a *** empty log message ***
claus
parents: 68
diff changeset
    31
 be provided or otherwise made available to, or used by, any
81dacba7a63a *** empty log message ***
claus
parents: 68
diff changeset
    32
 other person.  No title to or ownership of the software is
81dacba7a63a *** empty log message ***
claus
parents: 68
diff changeset
    33
 hereby transferred.
81dacba7a63a *** empty log message ***
claus
parents: 68
diff changeset
    34
"
81dacba7a63a *** empty log message ***
claus
parents: 68
diff changeset
    35
!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    36
88
81dacba7a63a *** empty log message ***
claus
parents: 68
diff changeset
    37
documentation
81dacba7a63a *** empty log message ***
claus
parents: 68
diff changeset
    38
"
8666
66e7d5922ae9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5528
diff changeset
    39
    BlockContexts represent the stack context objects of blocks.
66e7d5922ae9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5528
diff changeset
    40
    The layout is the same as for other contexts - this class has been added
88
81dacba7a63a *** empty log message ***
claus
parents: 68
diff changeset
    41
    to avoid a flag in an instance variable.
81dacba7a63a *** empty log message ***
claus
parents: 68
diff changeset
    42
    (has become necessary with cheap blocks, which have no home).
81dacba7a63a *** empty log message ***
claus
parents: 68
diff changeset
    43
8666
66e7d5922ae9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5528
diff changeset
    44
    WARNING: layout and size known by compiler and runtime system -
66e7d5922ae9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5528
diff changeset
    45
	     do not change.
1293
02fb05148c98 documentation
Claus Gittinger <cg@exept.de>
parents: 1183
diff changeset
    46
02fb05148c98 documentation
Claus Gittinger <cg@exept.de>
parents: 1183
diff changeset
    47
    [author:]
8666
66e7d5922ae9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5528
diff changeset
    48
	Claus Gittinger
1293
02fb05148c98 documentation
Claus Gittinger <cg@exept.de>
parents: 1183
diff changeset
    49
02fb05148c98 documentation
Claus Gittinger <cg@exept.de>
parents: 1183
diff changeset
    50
    [see also:]
8666
66e7d5922ae9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5528
diff changeset
    51
	Context Block Method
66e7d5922ae9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5528
diff changeset
    52
	Exception Signal
88
81dacba7a63a *** empty log message ***
claus
parents: 68
diff changeset
    53
"
81dacba7a63a *** empty log message ***
claus
parents: 68
diff changeset
    54
! !
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    55
a27a279701f8 Initial revision
claus
parents:
diff changeset
    56
!BlockContext methodsFor:'accessing'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    57
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    58
canReturn
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    59
    "return true, if the receiver allows returning through it.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    60
     For normal method contexts, this normally returns true;
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    61
     for blocks, it (currently) always returns false."
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    62
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    63
    ^ false
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    64
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    65
5528
2a96dd29ca28 guess home of optimized block contexts
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
    66
guessedHome
2a96dd29ca28 guess home of optimized block contexts
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
    67
    "a temporary kludge: optimized block contexts do (currently) not provide
2a96dd29ca28 guess home of optimized block contexts
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
    68
     any home info. The code below tries to guess the home."
2a96dd29ca28 guess home of optimized block contexts
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
    69
8666
66e7d5922ae9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5528
diff changeset
    70
    |sender tryVars selSender possibleBlocks method|
5528
2a96dd29ca28 guess home of optimized block contexts
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
    71
2a96dd29ca28 guess home of optimized block contexts
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
    72
    (home isNil or:[home isContext not]) ifTrue:[
8666
66e7d5922ae9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5528
diff changeset
    73
	(sender := self sender) notNil ifTrue:[
66e7d5922ae9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5528
diff changeset
    74
	    tryVars := false.
66e7d5922ae9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5528
diff changeset
    75
	    (selSender := sender selector) notNil ifTrue:[
66e7d5922ae9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5528
diff changeset
    76
		(selSender endsWith:'do:') ifTrue:[
66e7d5922ae9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5528
diff changeset
    77
		    tryVars := true.
66e7d5922ae9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5528
diff changeset
    78
		] ifFalse:[
66e7d5922ae9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5528
diff changeset
    79
		    (selSender endsWith:'Do:') ifTrue:[
66e7d5922ae9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5528
diff changeset
    80
			tryVars := true.
66e7d5922ae9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5528
diff changeset
    81
		    ]
66e7d5922ae9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5528
diff changeset
    82
		]
66e7d5922ae9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5528
diff changeset
    83
	    ].
66e7d5922ae9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5528
diff changeset
    84
	    tryVars ifTrue:[
66e7d5922ae9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5528
diff changeset
    85
		possibleBlocks := sender argsAndVars select:[:v | v isBlock].
66e7d5922ae9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5528
diff changeset
    86
		possibleBlocks := possibleBlocks select:[:b | b home isNil].
5528
2a96dd29ca28 guess home of optimized block contexts
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
    87
8666
66e7d5922ae9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5528
diff changeset
    88
		possibleBlocks size == 1 ifTrue:[
66e7d5922ae9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5528
diff changeset
    89
		    method := possibleBlocks first method.
66e7d5922ae9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5528
diff changeset
    90
		    ^ method.
66e7d5922ae9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5528
diff changeset
    91
		].
66e7d5922ae9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5528
diff changeset
    92
	    ]
66e7d5922ae9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5528
diff changeset
    93
	].
5528
2a96dd29ca28 guess home of optimized block contexts
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
    94
    ].
2a96dd29ca28 guess home of optimized block contexts
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
    95
    ^ nil
2a96dd29ca28 guess home of optimized block contexts
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
    96
!
2a96dd29ca28 guess home of optimized block contexts
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
    97
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    98
home
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    99
    "return the immediate home of the receiver.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   100
     normally this is the methodcontext, where the block was created,
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   101
     for nested block contexts, this is the surrounding blocks context."
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   102
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   103
    home isContext ifFalse:[^ nil]. "copying blocks have no home"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   104
    ^ home
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   105
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   106
3324
0295f7b3b208 Add #homeReceiver (as in ST80).
Stefan Vogel <sv@exept.de>
parents: 2157
diff changeset
   107
homeReceiver
0295f7b3b208 Add #homeReceiver (as in ST80).
Stefan Vogel <sv@exept.de>
parents: 2157
diff changeset
   108
    "return the receiver from the context, where the receiver was defined"
0295f7b3b208 Add #homeReceiver (as in ST80).
Stefan Vogel <sv@exept.de>
parents: 2157
diff changeset
   109
0295f7b3b208 Add #homeReceiver (as in ST80).
Stefan Vogel <sv@exept.de>
parents: 2157
diff changeset
   110
    home isContext ifFalse:[^ nil]. "copying blocks have no home"
0295f7b3b208 Add #homeReceiver (as in ST80).
Stefan Vogel <sv@exept.de>
parents: 2157
diff changeset
   111
    ^ home receiver
0295f7b3b208 Add #homeReceiver (as in ST80).
Stefan Vogel <sv@exept.de>
parents: 2157
diff changeset
   112
0295f7b3b208 Add #homeReceiver (as in ST80).
Stefan Vogel <sv@exept.de>
parents: 2157
diff changeset
   113
    "Created: / 5.3.1998 / 16:20:31 / stefan"
0295f7b3b208 Add #homeReceiver (as in ST80).
Stefan Vogel <sv@exept.de>
parents: 2157
diff changeset
   114
!
0295f7b3b208 Add #homeReceiver (as in ST80).
Stefan Vogel <sv@exept.de>
parents: 2157
diff changeset
   115
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   116
method
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   117
    "return the method in which the current contexts block was created."
360
claus
parents: 357
diff changeset
   118
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   119
    home notNil ifTrue:[^ home method].
14213
de1d8ff5f7eb changed:
Claus Gittinger <cg@exept.de>
parents: 11313
diff changeset
   120
    ^ super method
de1d8ff5f7eb changed:
Claus Gittinger <cg@exept.de>
parents: 11313
diff changeset
   121
de1d8ff5f7eb changed:
Claus Gittinger <cg@exept.de>
parents: 11313
diff changeset
   122
    "Modified: / 19-07-2012 / 10:58:55 / cg"
360
claus
parents: 357
diff changeset
   123
!
claus
parents: 357
diff changeset
   124
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   125
methodHome
a27a279701f8 Initial revision
claus
parents:
diff changeset
   126
    "return the method-home for block contexts"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   127
a27a279701f8 Initial revision
claus
parents:
diff changeset
   128
    |con h|
a27a279701f8 Initial revision
claus
parents:
diff changeset
   129
15267
47d41a3d1cbf class: BlockContext
Claus Gittinger <cg@exept.de>
parents: 15220
diff changeset
   130
    home isNil ifTrue:[^ nil].
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   131
    home isContext ifFalse:[^ nil]. "copying blocks have no method home"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   132
15267
47d41a3d1cbf class: BlockContext
Claus Gittinger <cg@exept.de>
parents: 15220
diff changeset
   133
    con := self.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   134
    h := home.
15267
47d41a3d1cbf class: BlockContext
Claus Gittinger <cg@exept.de>
parents: 15220
diff changeset
   135
    [h notNil] whileTrue:[
15220
62c90d2c1698 class: BlockContext
Stefan Vogel <sv@exept.de>
parents: 14215
diff changeset
   136
        con := h.
62c90d2c1698 class: BlockContext
Stefan Vogel <sv@exept.de>
parents: 14215
diff changeset
   137
        h := con home
15267
47d41a3d1cbf class: BlockContext
Claus Gittinger <cg@exept.de>
parents: 15220
diff changeset
   138
    ].
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   139
    ^ con
a27a279701f8 Initial revision
claus
parents:
diff changeset
   140
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   141
a27a279701f8 Initial revision
claus
parents:
diff changeset
   142
selector
a27a279701f8 Initial revision
claus
parents:
diff changeset
   143
    "return the selector of the context - which is one of the value
281
d63a7d2c31a6 *** empty log message ***
claus
parents: 241
diff changeset
   144
     selectors. This selector is not found in the context, but synthesized."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   145
a27a279701f8 Initial revision
claus
parents:
diff changeset
   146
    |nargs|
a27a279701f8 Initial revision
claus
parents:
diff changeset
   147
154
d4236ec280a6 *** empty log message ***
claus
parents: 92
diff changeset
   148
    nargs := self numArgs.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   149
    (nargs == 0) ifTrue:[^ #value].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   150
    (nargs == 1) ifTrue:[^ #value:].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   151
    (nargs == 2) ifTrue:[^ #value:value:].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   152
    (nargs == 3) ifTrue:[^ #value:value:value:].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   153
    (nargs == 4) ifTrue:[^ #value:value:value:value:].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   154
    (nargs == 5) ifTrue:[^ #value:value:value:value:value:].
11168
44fef5d29484 Support up to 8 args in #selector
Stefan Vogel <sv@exept.de>
parents: 8666
diff changeset
   155
    (nargs == 6) ifTrue:[^ #value:value:value:value:value:value:].
44fef5d29484 Support up to 8 args in #selector
Stefan Vogel <sv@exept.de>
parents: 8666
diff changeset
   156
    (nargs == 7) ifTrue:[^ #value:value:value:value:value:value:value:].
44fef5d29484 Support up to 8 args in #selector
Stefan Vogel <sv@exept.de>
parents: 8666
diff changeset
   157
    (nargs == 8) ifTrue:[^ #value:value:value:value:value:value:value:value:].
15454
fd304e6048f0 class: BlockContext
Claus Gittinger <cg@exept.de>
parents: 15382
diff changeset
   158
    (nargs == 9) ifTrue:[^ #value:value:value:value:value:value:value:value:value:].
fd304e6048f0 class: BlockContext
Claus Gittinger <cg@exept.de>
parents: 15382
diff changeset
   159
    (nargs == 10) ifTrue:[^ #value:value:value:value:value:value:value:value:value:value:].
fd304e6048f0 class: BlockContext
Claus Gittinger <cg@exept.de>
parents: 15382
diff changeset
   160
    (nargs == 11) ifTrue:[^ #value:value:value:value:value:value:value:value:value:value:value:].
fd304e6048f0 class: BlockContext
Claus Gittinger <cg@exept.de>
parents: 15382
diff changeset
   161
    (nargs == 12) ifTrue:[^ #value:value:value:value:value:value:value:value:value:value:value:value:].
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   162
    ^ nil
a27a279701f8 Initial revision
claus
parents:
diff changeset
   163
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   164
92
0c73b48551ac *** empty log message ***
claus
parents: 88
diff changeset
   165
!BlockContext methodsFor:'printing & storing'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   166
15382
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   167
printReceiverOn:aStream
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   168
    "print a string describing the receiver of the context on aStream
357
claus
parents: 293
diff changeset
   169
claus
parents: 293
diff changeset
   170
     Since this is also used by the debugger(s), be very careful to
281
d63a7d2c31a6 *** empty log message ***
claus
parents: 241
diff changeset
   171
     return something useful, even in case internals of the system
d63a7d2c31a6 *** empty log message ***
claus
parents: 241
diff changeset
   172
     got corrupted ... (i.e. avoid messageNotUnderstood here)"
d63a7d2c31a6 *** empty log message ***
claus
parents: 241
diff changeset
   173
15382
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   174
    |cls who mHome m className homeSel|
357
claus
parents: 293
diff changeset
   175
15382
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   176
    home isContext ifFalse:[
11307
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   177
        "
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   178
         mhmh - an optimized blocks context
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   179
         should get the block here, and get the method from
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   180
         that one ...
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   181
         ... but in 2.x, there is no easy way to get to the block
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   182
         since that one is not in the context.
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   183
         Starting with 3.x, the new block calling scheme will fix this.
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   184
        "
241
6f30be88e314 *** empty log message ***
claus
parents: 216
diff changeset
   185
11307
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   186
        "temporary kludge - peek into the sender context.
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   187
         If its a do-like method and there is a single block variable
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   188
         in the args or temporaries, that must be the one.
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   189
         This helps in some cases.
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   190
        "
14213
de1d8ff5f7eb changed:
Claus Gittinger <cg@exept.de>
parents: 11313
diff changeset
   191
        m := self method.
11307
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   192
        m isNil ifTrue:[
15382
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   193
            aStream nextPutAll:'[] (optimized) in ???'.
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   194
        ] ifFalse:[
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   195
            aStream nextPutAll:'[] in '.
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   196
            m mclass name printOn:aStream.
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   197
            aStream nextPutAll:'>>'.
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   198
            m selector printOn:aStream.
11307
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   199
        ].
15382
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   200
        ^ self.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   201
    ].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   202
281
d63a7d2c31a6 *** empty log message ***
claus
parents: 241
diff changeset
   203
    mHome := self methodHome.
d63a7d2c31a6 *** empty log message ***
claus
parents: 241
diff changeset
   204
    mHome isNil ifTrue:[
15382
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   205
        aStream nextPutAll:'[] (no methodHome!!) in ???'.
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   206
        ^ self.
281
d63a7d2c31a6 *** empty log message ***
claus
parents: 241
diff changeset
   207
    ].
d63a7d2c31a6 *** empty log message ***
claus
parents: 241
diff changeset
   208
293
31df3850e98c *** empty log message ***
claus
parents: 281
diff changeset
   209
    "
31df3850e98c *** empty log message ***
claus
parents: 281
diff changeset
   210
     kludge to avoid slow search for containing class
31df3850e98c *** empty log message ***
claus
parents: 281
diff changeset
   211
    "
15382
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   212
    homeSel := mHome selector.
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   213
    (homeSel == #doIt or:[homeSel == #doIt:]) ifTrue:[
11307
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   214
        cls := mHome receiver class.
15382
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   215
        homeSel := #doIt.
293
31df3850e98c *** empty log message ***
claus
parents: 281
diff changeset
   216
    ] ifFalse:[
11307
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   217
        m := mHome method.
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   218
        m isNil ifTrue:[
15382
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   219
            aStream nextPutAll:'[] (no method!!) in ???'.
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   220
            ^ self.
11307
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   221
        ].
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   222
        who := m who.
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   223
        who notNil ifTrue:[
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   224
            cls := who methodClass
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   225
        ] ifFalse:[
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   226
            cls := receiver class.
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   227
        ].
241
6f30be88e314 *** empty log message ***
claus
parents: 216
diff changeset
   228
    ].
1852
89b2328f4203 use new Method>>who interface
Claus Gittinger <cg@exept.de>
parents: 1444
diff changeset
   229
89b2328f4203 use new Method>>who interface
Claus Gittinger <cg@exept.de>
parents: 1444
diff changeset
   230
    cls isNil ifTrue:[
15382
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   231
        className := '???(no home class!!)'
1852
89b2328f4203 use new Method>>who interface
Claus Gittinger <cg@exept.de>
parents: 1444
diff changeset
   232
    ] ifFalse:[
11307
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   233
        className := cls name.
15382
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   234
        className isEmptyOrNil ifTrue:[
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   235
            className := '???(nameless class!!)'
11307
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   236
        ]
281
d63a7d2c31a6 *** empty log message ***
claus
parents: 241
diff changeset
   237
    ].
15382
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   238
    aStream nextPutAll:'[] in '; nextPutAll:className; nextPutAll:'>>'.
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   239
    homeSel printOn:aStream.
1444
cb2493aa4d0c fixed homeless-optimized-block printString
Claus Gittinger <cg@exept.de>
parents: 1293
diff changeset
   240
14213
de1d8ff5f7eb changed:
Claus Gittinger <cg@exept.de>
parents: 11313
diff changeset
   241
    "Modified: / 19-07-2012 / 11:02:41 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   242
! !
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   243
14215
02bf5047248e changed:
Claus Gittinger <cg@exept.de>
parents: 14213
diff changeset
   244
!BlockContext methodsFor:'testing'!
02bf5047248e changed:
Claus Gittinger <cg@exept.de>
parents: 14213
diff changeset
   245
02bf5047248e changed:
Claus Gittinger <cg@exept.de>
parents: 14213
diff changeset
   246
isBlockContext
02bf5047248e changed:
Claus Gittinger <cg@exept.de>
parents: 14213
diff changeset
   247
    "return true, iff the receiver is a BlockContext, false otherwise"
02bf5047248e changed:
Claus Gittinger <cg@exept.de>
parents: 14213
diff changeset
   248
02bf5047248e changed:
Claus Gittinger <cg@exept.de>
parents: 14213
diff changeset
   249
    ^ true
02bf5047248e changed:
Claus Gittinger <cg@exept.de>
parents: 14213
diff changeset
   250
!
02bf5047248e changed:
Claus Gittinger <cg@exept.de>
parents: 14213
diff changeset
   251
02bf5047248e changed:
Claus Gittinger <cg@exept.de>
parents: 14213
diff changeset
   252
isCheapBlockContext
02bf5047248e changed:
Claus Gittinger <cg@exept.de>
parents: 14213
diff changeset
   253
    "return true, iff the receiver is a BlockContext, for a cheap block, false otherwise.
02bf5047248e changed:
Claus Gittinger <cg@exept.de>
parents: 14213
diff changeset
   254
     Cheap blocks do not refer to their home"
02bf5047248e changed:
Claus Gittinger <cg@exept.de>
parents: 14213
diff changeset
   255
02bf5047248e changed:
Claus Gittinger <cg@exept.de>
parents: 14213
diff changeset
   256
    ^ home isNil
02bf5047248e changed:
Claus Gittinger <cg@exept.de>
parents: 14213
diff changeset
   257
02bf5047248e changed:
Claus Gittinger <cg@exept.de>
parents: 14213
diff changeset
   258
    "Created: / 19-07-2012 / 11:22:23 / cg"
02bf5047248e changed:
Claus Gittinger <cg@exept.de>
parents: 14213
diff changeset
   259
! !
02bf5047248e changed:
Claus Gittinger <cg@exept.de>
parents: 14213
diff changeset
   260
1183
e3d58d115e53 subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   261
!BlockContext class methodsFor:'documentation'!
e3d58d115e53 subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   262
e3d58d115e53 subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   263
version
15454
fd304e6048f0 class: BlockContext
Claus Gittinger <cg@exept.de>
parents: 15382
diff changeset
   264
    ^ '$Header: /cvs/stx/stx/libbasic/BlockContext.st,v 1.39 2013-07-04 06:29:43 cg Exp $'
14215
02bf5047248e changed:
Claus Gittinger <cg@exept.de>
parents: 14213
diff changeset
   265
!
02bf5047248e changed:
Claus Gittinger <cg@exept.de>
parents: 14213
diff changeset
   266
02bf5047248e changed:
Claus Gittinger <cg@exept.de>
parents: 14213
diff changeset
   267
version_CVS
15454
fd304e6048f0 class: BlockContext
Claus Gittinger <cg@exept.de>
parents: 15382
diff changeset
   268
    ^ '$Header: /cvs/stx/stx/libbasic/BlockContext.st,v 1.39 2013-07-04 06:29:43 cg Exp $'
1183
e3d58d115e53 subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   269
! !
15220
62c90d2c1698 class: BlockContext
Stefan Vogel <sv@exept.de>
parents: 14215
diff changeset
   270