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