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