BlockContext.st
author Jan Vrany <jan.vrany@labware.com>
Thu, 09 Jul 2020 21:12:19 +0100
branchjv
changeset 25396 d6cc2bdc7773
parent 21024 8734987eb5c7
child 25433 c46176ba6ce2
permissions -rw-r--r--
Fix `BlockContext >> method` for cheap-block contexts Cheap blocks have no home context but they hold on their method directly, so use that. This fixes source code display for cheap blocks in debugger.
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
25396
d6cc2bdc7773 Fix `BlockContext >> method` for cheap-block contexts
Jan Vrany <jan.vrany@labware.com>
parents: 21024
diff changeset
     3
 COPYRIGHT (c) 2020 LabWare
165
63341654cfb8 *** empty log message ***
claus
parents: 154
diff changeset
     4
	      All Rights Reserved
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     5
a27a279701f8 Initial revision
claus
parents:
diff changeset
     6
 This software is furnished under a license and may be used
a27a279701f8 Initial revision
claus
parents:
diff changeset
     7
 only in accordance with the terms of that license and with the
a27a279701f8 Initial revision
claus
parents:
diff changeset
     8
 inclusion of the above copyright notice.   This software may not
a27a279701f8 Initial revision
claus
parents:
diff changeset
     9
 be provided or otherwise made available to, or used by, any
a27a279701f8 Initial revision
claus
parents:
diff changeset
    10
 other person.  No title to or ownership of the software is
a27a279701f8 Initial revision
claus
parents:
diff changeset
    11
 hereby transferred.
a27a279701f8 Initial revision
claus
parents:
diff changeset
    12
"
5528
2a96dd29ca28 guess home of optimized block contexts
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
    13
"{ Package: 'stx:libbasic' }"
2a96dd29ca28 guess home of optimized block contexts
Claus Gittinger <cg@exept.de>
parents: 4623
diff changeset
    14
18433
382d34e96340 class: BlockContext
Stefan Vogel <sv@exept.de>
parents: 15454
diff changeset
    15
"{ NameSpace: Smalltalk }"
382d34e96340 class: BlockContext
Stefan Vogel <sv@exept.de>
parents: 15454
diff changeset
    16
4623
f5a12735a692 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
    17
Context variableSubclass:#BlockContext
1183
e3d58d115e53 subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    18
	instanceVariableNames:''
e3d58d115e53 subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    19
	classVariableNames:''
e3d58d115e53 subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    20
	poolDictionaries:''
e3d58d115e53 subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    21
	category:'Kernel-Methods'
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    22
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    23
88
81dacba7a63a *** empty log message ***
claus
parents: 68
diff changeset
    24
!BlockContext class methodsFor:'documentation'!
81dacba7a63a *** empty log message ***
claus
parents: 68
diff changeset
    25
81dacba7a63a *** empty log message ***
claus
parents: 68
diff changeset
    26
copyright
81dacba7a63a *** empty log message ***
claus
parents: 68
diff changeset
    27
"
81dacba7a63a *** empty log message ***
claus
parents: 68
diff changeset
    28
 COPYRIGHT (c) 1993 by Claus Gittinger
25396
d6cc2bdc7773 Fix `BlockContext >> method` for cheap-block contexts
Jan Vrany <jan.vrany@labware.com>
parents: 21024
diff changeset
    29
 COPYRIGHT (c) 2020 LabWare
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].
25396
d6cc2bdc7773 Fix `BlockContext >> method` for cheap-block contexts
Jan Vrany <jan.vrany@labware.com>
parents: 21024
diff changeset
   124
d6cc2bdc7773 Fix `BlockContext >> method` for cheap-block contexts
Jan Vrany <jan.vrany@labware.com>
parents: 21024
diff changeset
   125
    "/ Note: for BlockContext, `method` instvar holds
d6cc2bdc7773 Fix `BlockContext >> method` for cheap-block contexts
Jan Vrany <jan.vrany@labware.com>
parents: 21024
diff changeset
   126
    "/ on Block (or CheapBlock) instead...
d6cc2bdc7773 Fix `BlockContext >> method` for cheap-block contexts
Jan Vrany <jan.vrany@labware.com>
parents: 21024
diff changeset
   127
    method isBlock ifTrue: [
d6cc2bdc7773 Fix `BlockContext >> method` for cheap-block contexts
Jan Vrany <jan.vrany@labware.com>
parents: 21024
diff changeset
   128
        ^ method homeMethod
d6cc2bdc7773 Fix `BlockContext >> method` for cheap-block contexts
Jan Vrany <jan.vrany@labware.com>
parents: 21024
diff changeset
   129
    ].      
14213
de1d8ff5f7eb changed:
Claus Gittinger <cg@exept.de>
parents: 11313
diff changeset
   130
    ^ super method
de1d8ff5f7eb changed:
Claus Gittinger <cg@exept.de>
parents: 11313
diff changeset
   131
de1d8ff5f7eb changed:
Claus Gittinger <cg@exept.de>
parents: 11313
diff changeset
   132
    "Modified: / 19-07-2012 / 10:58:55 / cg"
25396
d6cc2bdc7773 Fix `BlockContext >> method` for cheap-block contexts
Jan Vrany <jan.vrany@labware.com>
parents: 21024
diff changeset
   133
    "Modified: / 09-07-2020 / 21:06:53 / Jan Vrany <jan.vrany@labware.com>"
360
claus
parents: 357
diff changeset
   134
!
claus
parents: 357
diff changeset
   135
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   136
methodHome
a27a279701f8 Initial revision
claus
parents:
diff changeset
   137
    "return the method-home for block contexts"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   138
a27a279701f8 Initial revision
claus
parents:
diff changeset
   139
    |con h|
a27a279701f8 Initial revision
claus
parents:
diff changeset
   140
15267
47d41a3d1cbf class: BlockContext
Claus Gittinger <cg@exept.de>
parents: 15220
diff changeset
   141
    home isNil ifTrue:[^ nil].
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   142
    home isContext ifFalse:[^ nil]. "copying blocks have no method home"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   143
15267
47d41a3d1cbf class: BlockContext
Claus Gittinger <cg@exept.de>
parents: 15220
diff changeset
   144
    con := self.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   145
    h := home.
15267
47d41a3d1cbf class: BlockContext
Claus Gittinger <cg@exept.de>
parents: 15220
diff changeset
   146
    [h notNil] whileTrue:[
15220
62c90d2c1698 class: BlockContext
Stefan Vogel <sv@exept.de>
parents: 14215
diff changeset
   147
        con := h.
62c90d2c1698 class: BlockContext
Stefan Vogel <sv@exept.de>
parents: 14215
diff changeset
   148
        h := con home
15267
47d41a3d1cbf class: BlockContext
Claus Gittinger <cg@exept.de>
parents: 15220
diff changeset
   149
    ].
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   150
    ^ con
a27a279701f8 Initial revision
claus
parents:
diff changeset
   151
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   152
a27a279701f8 Initial revision
claus
parents:
diff changeset
   153
selector
a27a279701f8 Initial revision
claus
parents:
diff changeset
   154
    "return the selector of the context - which is one of the value
281
d63a7d2c31a6 *** empty log message ***
claus
parents: 241
diff changeset
   155
     selectors. This selector is not found in the context, but synthesized."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   156
a27a279701f8 Initial revision
claus
parents:
diff changeset
   157
    |nargs|
a27a279701f8 Initial revision
claus
parents:
diff changeset
   158
18433
382d34e96340 class: BlockContext
Stefan Vogel <sv@exept.de>
parents: 15454
diff changeset
   159
    nargs := self argumentCount.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   160
    (nargs == 0) ifTrue:[^ #value].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   161
    (nargs == 1) ifTrue:[^ #value:].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   162
    (nargs == 2) ifTrue:[^ #value:value:].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   163
    (nargs == 3) ifTrue:[^ #value:value:value:].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   164
    (nargs == 4) ifTrue:[^ #value:value:value:value:].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   165
    (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
   166
    (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
   167
    (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
   168
    (nargs == 8) ifTrue:[^ #value:value:value:value:value:value:value:value:].
15454
fd304e6048f0 class: BlockContext
Claus Gittinger <cg@exept.de>
parents: 15382
diff changeset
   169
    (nargs == 9) ifTrue:[^ #value:value:value:value:value:value:value:value:value:].
fd304e6048f0 class: BlockContext
Claus Gittinger <cg@exept.de>
parents: 15382
diff changeset
   170
    (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
   171
    (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
   172
    (nargs == 12) ifTrue:[^ #value:value:value:value:value:value:value:value:value:value:value:value:].
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   173
    ^ nil
a27a279701f8 Initial revision
claus
parents:
diff changeset
   174
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   175
92
0c73b48551ac *** empty log message ***
claus
parents: 88
diff changeset
   176
!BlockContext methodsFor:'printing & storing'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   177
15382
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   178
printReceiverOn:aStream
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   179
    "print a string describing the receiver of the context on aStream
357
claus
parents: 293
diff changeset
   180
claus
parents: 293
diff changeset
   181
     Since this is also used by the debugger(s), be very careful to
281
d63a7d2c31a6 *** empty log message ***
claus
parents: 241
diff changeset
   182
     return something useful, even in case internals of the system
d63a7d2c31a6 *** empty log message ***
claus
parents: 241
diff changeset
   183
     got corrupted ... (i.e. avoid messageNotUnderstood here)"
d63a7d2c31a6 *** empty log message ***
claus
parents: 241
diff changeset
   184
15382
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   185
    |cls who mHome m className homeSel|
357
claus
parents: 293
diff changeset
   186
15382
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   187
    home isContext ifFalse:[
11307
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   188
        "
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   189
         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
   190
         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
   191
         that one ...
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   192
         ... 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
   193
         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
   194
         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
   195
        "
241
6f30be88e314 *** empty log message ***
claus
parents: 216
diff changeset
   196
11307
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   197
        "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
   198
         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
   199
         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
   200
         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
   201
        "
14213
de1d8ff5f7eb changed:
Claus Gittinger <cg@exept.de>
parents: 11313
diff changeset
   202
        m := self method.
11307
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   203
        m isNil ifTrue:[
15382
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   204
            aStream nextPutAll:'[] (optimized) in ???'.
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   205
        ] ifFalse:[
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   206
            aStream nextPutAll:'[] in '.
20889
15225da02dc3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 18433
diff changeset
   207
            cls := m mclass.
15225da02dc3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 18433
diff changeset
   208
            cls isNil ifTrue:[
15225da02dc3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 18433
diff changeset
   209
                cls := m getMclass.
15225da02dc3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 18433
diff changeset
   210
                cls isNil ifTrue:[
15225da02dc3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 18433
diff changeset
   211
                    className := '*Unbound*'
15225da02dc3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 18433
diff changeset
   212
                ] ifFalse:[
15225da02dc3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 18433
diff changeset
   213
                    className := '(previously in) ',cls name
15225da02dc3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 18433
diff changeset
   214
                ].    
15225da02dc3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 18433
diff changeset
   215
            ] ifFalse:[
15225da02dc3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 18433
diff changeset
   216
                className := cls name.
15225da02dc3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 18433
diff changeset
   217
            ].
15225da02dc3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 18433
diff changeset
   218
            className printOn:aStream. 
15382
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   219
            aStream nextPutAll:'>>'.
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   220
            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
   221
        ].
15382
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   222
        ^ self.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   223
    ].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   224
281
d63a7d2c31a6 *** empty log message ***
claus
parents: 241
diff changeset
   225
    mHome := self methodHome.
d63a7d2c31a6 *** empty log message ***
claus
parents: 241
diff changeset
   226
    mHome isNil ifTrue:[
15382
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   227
        aStream nextPutAll:'[] (no methodHome!!) in ???'.
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   228
        ^ self.
281
d63a7d2c31a6 *** empty log message ***
claus
parents: 241
diff changeset
   229
    ].
d63a7d2c31a6 *** empty log message ***
claus
parents: 241
diff changeset
   230
293
31df3850e98c *** empty log message ***
claus
parents: 281
diff changeset
   231
    "
31df3850e98c *** empty log message ***
claus
parents: 281
diff changeset
   232
     kludge to avoid slow search for containing class
31df3850e98c *** empty log message ***
claus
parents: 281
diff changeset
   233
    "
15382
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   234
    homeSel := mHome selector.
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   235
    (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
   236
        cls := mHome receiver class.
15382
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   237
        homeSel := #doIt.
293
31df3850e98c *** empty log message ***
claus
parents: 281
diff changeset
   238
    ] ifFalse:[
11307
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   239
        m := mHome method.
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   240
        m isNil ifTrue:[
15382
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   241
            aStream nextPutAll:'[] (no method!!) in ???'.
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   242
            ^ self.
11307
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   243
        ].
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   244
        who := m who.
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   245
        who notNil ifTrue:[
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   246
            cls := who methodClass
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   247
        ] ifFalse:[
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   248
            cls := receiver class.
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   249
        ].
241
6f30be88e314 *** empty log message ***
claus
parents: 216
diff changeset
   250
    ].
1852
89b2328f4203 use new Method>>who interface
Claus Gittinger <cg@exept.de>
parents: 1444
diff changeset
   251
89b2328f4203 use new Method>>who interface
Claus Gittinger <cg@exept.de>
parents: 1444
diff changeset
   252
    cls isNil ifTrue:[
15382
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   253
        className := '???(no home class!!)'
1852
89b2328f4203 use new Method>>who interface
Claus Gittinger <cg@exept.de>
parents: 1444
diff changeset
   254
    ] ifFalse:[
11307
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   255
        className := cls name.
15382
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   256
        className isEmptyOrNil ifTrue:[
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   257
            className := '???(nameless class!!)'
11307
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   258
        ]
281
d63a7d2c31a6 *** empty log message ***
claus
parents: 241
diff changeset
   259
    ].
15382
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   260
    aStream nextPutAll:'[] in '; nextPutAll:className; nextPutAll:'>>'.
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   261
    homeSel printOn:aStream.
1444
cb2493aa4d0c fixed homeless-optimized-block printString
Claus Gittinger <cg@exept.de>
parents: 1293
diff changeset
   262
14213
de1d8ff5f7eb changed:
Claus Gittinger <cg@exept.de>
parents: 11313
diff changeset
   263
    "Modified: / 19-07-2012 / 11:02:41 / cg"
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$'
25396
d6cc2bdc7773 Fix `BlockContext >> method` for cheap-block contexts
Jan Vrany <jan.vrany@labware.com>
parents: 21024
diff changeset
   291
!
d6cc2bdc7773 Fix `BlockContext >> method` for cheap-block contexts
Jan Vrany <jan.vrany@labware.com>
parents: 21024
diff changeset
   292
d6cc2bdc7773 Fix `BlockContext >> method` for cheap-block contexts
Jan Vrany <jan.vrany@labware.com>
parents: 21024
diff changeset
   293
version_HG
d6cc2bdc7773 Fix `BlockContext >> method` for cheap-block contexts
Jan Vrany <jan.vrany@labware.com>
parents: 21024
diff changeset
   294
d6cc2bdc7773 Fix `BlockContext >> method` for cheap-block contexts
Jan Vrany <jan.vrany@labware.com>
parents: 21024
diff changeset
   295
    ^ '$Changeset: <not expanded> $'
1183
e3d58d115e53 subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   296
! !
15220
62c90d2c1698 class: BlockContext
Stefan Vogel <sv@exept.de>
parents: 14215
diff changeset
   297