BlockContext.st
author Jan Vrany <jan.vrany@labware.com>
Sat, 29 Oct 2022 01:05:05 +0100
branchjv
changeset 25446 98fb817db6de
parent 25433 c46176ba6ce2
permissions -rw-r--r--
Add `Character >> isMathLetter` and `#isMathBinaryOperator`
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
a27a279701f8 Initial revision
claus
parents:
diff changeset
   144
    h := home.
25433
c46176ba6ce2 Cherry-picked `BlockContext` from a6b6dda4caff:
Jan Vrany <jan.vrany@labware.com>
parents: 25396
diff changeset
   145
    [
15220
62c90d2c1698 class: BlockContext
Stefan Vogel <sv@exept.de>
parents: 14215
diff changeset
   146
        con := h.
25433
c46176ba6ce2 Cherry-picked `BlockContext` from a6b6dda4caff:
Jan Vrany <jan.vrany@labware.com>
parents: 25396
diff changeset
   147
        h := con home.
c46176ba6ce2 Cherry-picked `BlockContext` from a6b6dda4caff:
Jan Vrany <jan.vrany@labware.com>
parents: 25396
diff changeset
   148
        h notNil
c46176ba6ce2 Cherry-picked `BlockContext` from a6b6dda4caff:
Jan Vrany <jan.vrany@labware.com>
parents: 25396
diff changeset
   149
    ] whileTrue.
c46176ba6ce2 Cherry-picked `BlockContext` from a6b6dda4caff:
Jan Vrany <jan.vrany@labware.com>
parents: 25396
diff changeset
   150
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   151
    ^ con
25433
c46176ba6ce2 Cherry-picked `BlockContext` from a6b6dda4caff:
Jan Vrany <jan.vrany@labware.com>
parents: 25396
diff changeset
   152
c46176ba6ce2 Cherry-picked `BlockContext` from a6b6dda4caff:
Jan Vrany <jan.vrany@labware.com>
parents: 25396
diff changeset
   153
    "Modified: / 02-02-2018 / 14:01:32 / stefan"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   154
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   155
a27a279701f8 Initial revision
claus
parents:
diff changeset
   156
selector
a27a279701f8 Initial revision
claus
parents:
diff changeset
   157
    "return the selector of the context - which is one of the value
281
d63a7d2c31a6 *** empty log message ***
claus
parents: 241
diff changeset
   158
     selectors. This selector is not found in the context, but synthesized."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   159
a27a279701f8 Initial revision
claus
parents:
diff changeset
   160
    |nargs|
a27a279701f8 Initial revision
claus
parents:
diff changeset
   161
18433
382d34e96340 class: BlockContext
Stefan Vogel <sv@exept.de>
parents: 15454
diff changeset
   162
    nargs := self argumentCount.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   163
    (nargs == 0) ifTrue:[^ #value].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   164
    (nargs == 1) ifTrue:[^ #value:].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   165
    (nargs == 2) ifTrue:[^ #value:value:].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   166
    (nargs == 3) ifTrue:[^ #value:value:value:].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   167
    (nargs == 4) ifTrue:[^ #value:value:value:value:].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   168
    (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
   169
    (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
   170
    (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
   171
    (nargs == 8) ifTrue:[^ #value:value:value:value:value:value:value:value:].
15454
fd304e6048f0 class: BlockContext
Claus Gittinger <cg@exept.de>
parents: 15382
diff changeset
   172
    (nargs == 9) ifTrue:[^ #value:value:value:value:value:value:value:value:value:].
fd304e6048f0 class: BlockContext
Claus Gittinger <cg@exept.de>
parents: 15382
diff changeset
   173
    (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
   174
    (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
   175
    (nargs == 12) ifTrue:[^ #value:value:value:value:value:value:value:value:value:value:value:value:].
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   176
    ^ nil
a27a279701f8 Initial revision
claus
parents:
diff changeset
   177
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   178
92
0c73b48551ac *** empty log message ***
claus
parents: 88
diff changeset
   179
!BlockContext methodsFor:'printing & storing'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   180
25433
c46176ba6ce2 Cherry-picked `BlockContext` from a6b6dda4caff:
Jan Vrany <jan.vrany@labware.com>
parents: 25396
diff changeset
   181
printReceiverWithSeparator:sep on:aStream
15382
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   182
    "print a string describing the receiver of the context on aStream
357
claus
parents: 293
diff changeset
   183
claus
parents: 293
diff changeset
   184
     Since this is also used by the debugger(s), be very careful to
281
d63a7d2c31a6 *** empty log message ***
claus
parents: 241
diff changeset
   185
     return something useful, even in case internals of the system
d63a7d2c31a6 *** empty log message ***
claus
parents: 241
diff changeset
   186
     got corrupted ... (i.e. avoid messageNotUnderstood here)"
d63a7d2c31a6 *** empty log message ***
claus
parents: 241
diff changeset
   187
15382
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   188
    |cls who mHome m className homeSel|
357
claus
parents: 293
diff changeset
   189
15382
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   190
    home isContext ifFalse:[
11307
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   191
        "
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   192
         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
   193
         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
   194
         that one ...
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   195
         ... 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
   196
         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
   197
         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
   198
        "
241
6f30be88e314 *** empty log message ***
claus
parents: 216
diff changeset
   199
11307
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   200
        "temporary kludge - peek into the sender context.
25433
c46176ba6ce2 Cherry-picked `BlockContext` from a6b6dda4caff:
Jan Vrany <jan.vrany@labware.com>
parents: 25396
diff changeset
   201
         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
   202
         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
   203
         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
   204
        "
14213
de1d8ff5f7eb changed:
Claus Gittinger <cg@exept.de>
parents: 11313
diff changeset
   205
        m := self method.
11307
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   206
        m isNil ifTrue:[
15382
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   207
            aStream nextPutAll:'[] (optimized) in ???'.
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   208
        ] ifFalse:[
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   209
            aStream nextPutAll:'[] in '.
20889
15225da02dc3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 18433
diff changeset
   210
            cls := m mclass.
15225da02dc3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 18433
diff changeset
   211
            cls isNil ifTrue:[
15225da02dc3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 18433
diff changeset
   212
                cls := m getMclass.
15225da02dc3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 18433
diff changeset
   213
                cls isNil ifTrue:[
15225da02dc3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 18433
diff changeset
   214
                    className := '*Unbound*'
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 := '(previously in) ',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
            ] ifFalse:[
15225da02dc3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 18433
diff changeset
   219
                className := cls name.
15225da02dc3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 18433
diff changeset
   220
            ].
15225da02dc3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 18433
diff changeset
   221
            className printOn:aStream. 
25433
c46176ba6ce2 Cherry-picked `BlockContext` from a6b6dda4caff:
Jan Vrany <jan.vrany@labware.com>
parents: 25396
diff changeset
   222
            aStream nextPutAll:sep.
c46176ba6ce2 Cherry-picked `BlockContext` from a6b6dda4caff:
Jan Vrany <jan.vrany@labware.com>
parents: 25396
diff changeset
   223
            aStream bold.
15382
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   224
            m selector printOn:aStream.
25433
c46176ba6ce2 Cherry-picked `BlockContext` from a6b6dda4caff:
Jan Vrany <jan.vrany@labware.com>
parents: 25396
diff changeset
   225
            aStream normal.
11307
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   226
        ].
15382
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   227
        ^ self.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   228
    ].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   229
281
d63a7d2c31a6 *** empty log message ***
claus
parents: 241
diff changeset
   230
    mHome := self methodHome.
d63a7d2c31a6 *** empty log message ***
claus
parents: 241
diff changeset
   231
    mHome isNil ifTrue:[
15382
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   232
        aStream nextPutAll:'[] (no methodHome!!) in ???'.
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   233
        ^ self.
281
d63a7d2c31a6 *** empty log message ***
claus
parents: 241
diff changeset
   234
    ].
d63a7d2c31a6 *** empty log message ***
claus
parents: 241
diff changeset
   235
293
31df3850e98c *** empty log message ***
claus
parents: 281
diff changeset
   236
    "
31df3850e98c *** empty log message ***
claus
parents: 281
diff changeset
   237
     kludge to avoid slow search for containing class
31df3850e98c *** empty log message ***
claus
parents: 281
diff changeset
   238
    "
15382
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   239
    homeSel := mHome selector.
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   240
    (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
   241
        cls := mHome receiver class.
15382
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   242
        homeSel := #doIt.
293
31df3850e98c *** empty log message ***
claus
parents: 281
diff changeset
   243
    ] ifFalse:[
11307
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   244
        m := mHome method.
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   245
        m isNil ifTrue:[
15382
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   246
            aStream nextPutAll:'[] (no method!!) in ???'.
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   247
            ^ self.
11307
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   248
        ].
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   249
        who := m who.
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   250
        who notNil ifTrue:[
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   251
            cls := who methodClass
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   252
        ] ifFalse:[
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   253
            cls := receiver class.
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   254
        ].
241
6f30be88e314 *** empty log message ***
claus
parents: 216
diff changeset
   255
    ].
1852
89b2328f4203 use new Method>>who interface
Claus Gittinger <cg@exept.de>
parents: 1444
diff changeset
   256
89b2328f4203 use new Method>>who interface
Claus Gittinger <cg@exept.de>
parents: 1444
diff changeset
   257
    cls isNil ifTrue:[
15382
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   258
        className := '???(no home class!!)'
1852
89b2328f4203 use new Method>>who interface
Claus Gittinger <cg@exept.de>
parents: 1444
diff changeset
   259
    ] ifFalse:[
11307
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   260
        className := cls name.
15382
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   261
        className isEmptyOrNil ifTrue:[
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   262
            className := '???(nameless class!!)'
11307
98d31040610f Print methods: Show message sends as Class >> #selector (with the #),
Stefan Vogel <sv@exept.de>
parents: 11168
diff changeset
   263
        ]
281
d63a7d2c31a6 *** empty log message ***
claus
parents: 241
diff changeset
   264
    ].
25433
c46176ba6ce2 Cherry-picked `BlockContext` from a6b6dda4caff:
Jan Vrany <jan.vrany@labware.com>
parents: 25396
diff changeset
   265
    aStream nextPutAll:'[] in '; nextPutAll:className; nextPutAll:sep.
c46176ba6ce2 Cherry-picked `BlockContext` from a6b6dda4caff:
Jan Vrany <jan.vrany@labware.com>
parents: 25396
diff changeset
   266
    aStream bold.
15382
5a8665b2765a New: #printReceiverOn:
Stefan Vogel <sv@exept.de>
parents: 15267
diff changeset
   267
    homeSel printOn:aStream.
25433
c46176ba6ce2 Cherry-picked `BlockContext` from a6b6dda4caff:
Jan Vrany <jan.vrany@labware.com>
parents: 25396
diff changeset
   268
    aStream normal.
1444
cb2493aa4d0c fixed homeless-optimized-block printString
Claus Gittinger <cg@exept.de>
parents: 1293
diff changeset
   269
14213
de1d8ff5f7eb changed:
Claus Gittinger <cg@exept.de>
parents: 11313
diff changeset
   270
    "Modified: / 19-07-2012 / 11:02:41 / cg"
25433
c46176ba6ce2 Cherry-picked `BlockContext` from a6b6dda4caff:
Jan Vrany <jan.vrany@labware.com>
parents: 25396
diff changeset
   271
    "Modified (format): / 13-02-2017 / 19:56:14 / cg"
c46176ba6ce2 Cherry-picked `BlockContext` from a6b6dda4caff:
Jan Vrany <jan.vrany@labware.com>
parents: 25396
diff changeset
   272
    "Modified: / 26-06-2018 / 19:25:02 / Claus Gittinger"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   273
! !
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   274
14215
02bf5047248e changed:
Claus Gittinger <cg@exept.de>
parents: 14213
diff changeset
   275
!BlockContext methodsFor:'testing'!
02bf5047248e changed:
Claus Gittinger <cg@exept.de>
parents: 14213
diff changeset
   276
02bf5047248e changed:
Claus Gittinger <cg@exept.de>
parents: 14213
diff changeset
   277
isBlockContext
02bf5047248e changed:
Claus Gittinger <cg@exept.de>
parents: 14213
diff changeset
   278
    "return true, iff the receiver is a BlockContext, false otherwise"
02bf5047248e changed:
Claus Gittinger <cg@exept.de>
parents: 14213
diff changeset
   279
02bf5047248e changed:
Claus Gittinger <cg@exept.de>
parents: 14213
diff changeset
   280
    ^ true
02bf5047248e changed:
Claus Gittinger <cg@exept.de>
parents: 14213
diff changeset
   281
!
02bf5047248e changed:
Claus Gittinger <cg@exept.de>
parents: 14213
diff changeset
   282
02bf5047248e changed:
Claus Gittinger <cg@exept.de>
parents: 14213
diff changeset
   283
isCheapBlockContext
02bf5047248e changed:
Claus Gittinger <cg@exept.de>
parents: 14213
diff changeset
   284
    "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
   285
     Cheap blocks do not refer to their home"
02bf5047248e changed:
Claus Gittinger <cg@exept.de>
parents: 14213
diff changeset
   286
02bf5047248e changed:
Claus Gittinger <cg@exept.de>
parents: 14213
diff changeset
   287
    ^ home isNil
02bf5047248e changed:
Claus Gittinger <cg@exept.de>
parents: 14213
diff changeset
   288
02bf5047248e changed:
Claus Gittinger <cg@exept.de>
parents: 14213
diff changeset
   289
    "Created: / 19-07-2012 / 11:22:23 / cg"
02bf5047248e changed:
Claus Gittinger <cg@exept.de>
parents: 14213
diff changeset
   290
! !
02bf5047248e changed:
Claus Gittinger <cg@exept.de>
parents: 14213
diff changeset
   291
1183
e3d58d115e53 subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   292
!BlockContext class methodsFor:'documentation'!
e3d58d115e53 subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   293
e3d58d115e53 subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   294
version
20889
15225da02dc3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 18433
diff changeset
   295
    ^ '$Header$'
14215
02bf5047248e changed:
Claus Gittinger <cg@exept.de>
parents: 14213
diff changeset
   296
!
02bf5047248e changed:
Claus Gittinger <cg@exept.de>
parents: 14213
diff changeset
   297
02bf5047248e changed:
Claus Gittinger <cg@exept.de>
parents: 14213
diff changeset
   298
version_CVS
20889
15225da02dc3 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 18433
diff changeset
   299
    ^ '$Header$'
25396
d6cc2bdc7773 Fix `BlockContext >> method` for cheap-block contexts
Jan Vrany <jan.vrany@labware.com>
parents: 21024
diff changeset
   300
!
d6cc2bdc7773 Fix `BlockContext >> method` for cheap-block contexts
Jan Vrany <jan.vrany@labware.com>
parents: 21024
diff changeset
   301
d6cc2bdc7773 Fix `BlockContext >> method` for cheap-block contexts
Jan Vrany <jan.vrany@labware.com>
parents: 21024
diff changeset
   302
version_HG
d6cc2bdc7773 Fix `BlockContext >> method` for cheap-block contexts
Jan Vrany <jan.vrany@labware.com>
parents: 21024
diff changeset
   303
d6cc2bdc7773 Fix `BlockContext >> method` for cheap-block contexts
Jan Vrany <jan.vrany@labware.com>
parents: 21024
diff changeset
   304
    ^ '$Changeset: <not expanded> $'
1183
e3d58d115e53 subclasses of fixed classes are still possible
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   305
! !
15220
62c90d2c1698 class: BlockContext
Stefan Vogel <sv@exept.de>
parents: 14215
diff changeset
   306