Block.st
author Claus Gittinger <cg@exept.de>
Thu, 18 Apr 1996 14:17:36 +0200
changeset 1211 c5bdb3fc3cb4
parent 1189 b8400ee170c6
child 1254 48c2748b5197
permissions -rw-r--r--
commentary
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     1
"
5
67342904af11 *** empty log message ***
claus
parents: 3
diff changeset
     2
 COPYRIGHT (c) 1989 by Claus Gittinger
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
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
"
a27a279701f8 Initial revision
claus
parents:
diff changeset
    12
249
claus
parents: 222
diff changeset
    13
CompiledCode subclass:#Block
1181
6637fee79d7b only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
    14
	instanceVariableNames:'home nargs sourcePos initialPC'
6637fee79d7b only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
    15
	classVariableNames:'InvalidNewSignal'
6637fee79d7b only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
    16
	poolDictionaries:''
6637fee79d7b only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
    17
	category:'Kernel-Methods'
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    18
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    19
a27a279701f8 Initial revision
claus
parents:
diff changeset
    20
!Block class methodsFor:'documentation'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    21
92
0c73b48551ac *** empty log message ***
claus
parents: 83
diff changeset
    22
copyright
0c73b48551ac *** empty log message ***
claus
parents: 83
diff changeset
    23
"
0c73b48551ac *** empty log message ***
claus
parents: 83
diff changeset
    24
 COPYRIGHT (c) 1989 by Claus Gittinger
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
    25
	      All Rights Reserved
92
0c73b48551ac *** empty log message ***
claus
parents: 83
diff changeset
    26
0c73b48551ac *** empty log message ***
claus
parents: 83
diff changeset
    27
 This software is furnished under a license and may be used
0c73b48551ac *** empty log message ***
claus
parents: 83
diff changeset
    28
 only in accordance with the terms of that license and with the
0c73b48551ac *** empty log message ***
claus
parents: 83
diff changeset
    29
 inclusion of the above copyright notice.   This software may not
0c73b48551ac *** empty log message ***
claus
parents: 83
diff changeset
    30
 be provided or otherwise made available to, or used by, any
0c73b48551ac *** empty log message ***
claus
parents: 83
diff changeset
    31
 other person.  No title to or ownership of the software is
0c73b48551ac *** empty log message ***
claus
parents: 83
diff changeset
    32
 hereby transferred.
0c73b48551ac *** empty log message ***
claus
parents: 83
diff changeset
    33
"
0c73b48551ac *** empty log message ***
claus
parents: 83
diff changeset
    34
!
0c73b48551ac *** empty log message ***
claus
parents: 83
diff changeset
    35
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    36
documentation
a27a279701f8 Initial revision
claus
parents:
diff changeset
    37
"
67
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
    38
    Blocks are pieces of executable code which can be evaluated by sending
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
    39
    them a value-message (''value'', ''value:'', ''value:value:'' etc).
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    40
67
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
    41
    Blocks with arguments need a message of type ''value:arg1 ... value:argn''
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
    42
    for evaluation; the number of arguments passed when evaluating must match
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
    43
    the number of arguments the block was declared with otherwise an error is
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
    44
    raised. Blocks without args need a ''value'' message for evaluation.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    45
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
    46
    Blocks keep a reference to the context where the block was declared -
67
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
    47
    this allows blocks to access the methods arguments and/or variables.
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
    48
    This is still true after the method has returned - since the
67
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
    49
    block keeps this reference, the methods context will NOT die in this case.
222
85fee82884dd commenting
claus
parents: 216
diff changeset
    50
    (i.e. Blocks are closures in Smalltalk/X)
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    51
67
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
    52
    A return (via ^-statement) out of a block will force a return from the
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
    53
    blocks method context (if it is still living) - this make the implementation
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
    54
    of long-jumps and control structures possible.
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
    55
    (If the method is not alive (i.e. has already returned), a return out of the 
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
    56
     block will trigger an error)
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    57
67
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
    58
    Long-jump is done by defining a catchBlock as ''[^ self]''
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
    59
    somewhere up in the calling-tree. Then, to do the long-jump from out of some 
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
    60
    deeply nested method, simply do: ''catchBlock value''.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    61
67
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
    62
    Instance variables:
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    63
222
85fee82884dd commenting
claus
parents: 216
diff changeset
    64
      home        <Context>         the context where this block was created (i.e. defined)
85fee82884dd commenting
claus
parents: 216
diff changeset
    65
				    this may be a blockContext or a methodContext
85fee82884dd commenting
claus
parents: 216
diff changeset
    66
      nargs       <SmallInteger>    the number of arguments the block expects
85fee82884dd commenting
claus
parents: 216
diff changeset
    67
      sourcePos   <SmallInteger>    the character position of its source, in chars
85fee82884dd commenting
claus
parents: 216
diff changeset
    68
				    relative to methods source beginning
85fee82884dd commenting
claus
parents: 216
diff changeset
    69
      initialPC   <SmallInteger>    the start position within the byteCode
85fee82884dd commenting
claus
parents: 216
diff changeset
    70
				    for compiled blocks, this is nil.
85fee82884dd commenting
claus
parents: 216
diff changeset
    71
85fee82884dd commenting
claus
parents: 216
diff changeset
    72
85fee82884dd commenting
claus
parents: 216
diff changeset
    73
    Class variables:
85fee82884dd commenting
claus
parents: 216
diff changeset
    74
85fee82884dd commenting
claus
parents: 216
diff changeset
    75
      InvalidNewSignal              raised if a Block is tried to be created
85fee82884dd commenting
claus
parents: 216
diff changeset
    76
				    with new (which is not allowed).
85fee82884dd commenting
claus
parents: 216
diff changeset
    77
				    Only the VM is allowed to create Blocks.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    78
67
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
    79
    NOTICE: layout known by runtime system and compiler - do not change
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    80
"
a27a279701f8 Initial revision
claus
parents:
diff changeset
    81
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
    82
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
    83
!Block class methodsFor:'initialization'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    84
a27a279701f8 Initial revision
claus
parents:
diff changeset
    85
initialize
a27a279701f8 Initial revision
claus
parents:
diff changeset
    86
    "setup the signals"
a27a279701f8 Initial revision
claus
parents:
diff changeset
    87
48
9f68393bea3c *** empty log message ***
claus
parents: 46
diff changeset
    88
    InvalidNewSignal isNil ifTrue:[
302
1f76060d58a4 *** empty log message ***
claus
parents: 249
diff changeset
    89
	InvalidNewSignal := ErrorSignal newSignalMayProceed:false.
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
    90
	InvalidNewSignal nameClass:self message:#invalidNewSignal.
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
    91
	InvalidNewSignal notifierString:'blocks are only created by the system'.
48
9f68393bea3c *** empty log message ***
claus
parents: 46
diff changeset
    92
    ]
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    93
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
    94
a27a279701f8 Initial revision
claus
parents:
diff changeset
    95
!Block class methodsFor:'instance creation'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    96
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
    97
code:codeAddress byteCode:bCode numArgs:numArgs sourcePosition:sourcePos initialPC:initialPC literals:literals dynamic:dynamic
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    98
    "create a new cheap (homeless) block.
222
85fee82884dd commenting
claus
parents: 216
diff changeset
    99
     Not for public use - this is a special hook for the compiler."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   100
a27a279701f8 Initial revision
claus
parents:
diff changeset
   101
    |newBlock|
a27a279701f8 Initial revision
claus
parents:
diff changeset
   102
11
6bf3080856be *** empty log message ***
claus
parents: 10
diff changeset
   103
    newBlock := super basicNew code:codeAddress 
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   104
			   byteCode:bCode
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   105
			   numArgs:numArgs
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   106
		     sourcePosition:sourcePos
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   107
			  initialPC:initialPC
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   108
			   literals:literals
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   109
			    dynamic:dynamic.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   110
    ^ newBlock
a27a279701f8 Initial revision
claus
parents:
diff changeset
   111
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   112
22
847106305963 *** empty log message ***
claus
parents: 11
diff changeset
   113
new
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   114
    "catch creation of blocks - only the system creates blocks"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   115
128
c50a2157883e return value of signal raise
claus
parents: 103
diff changeset
   116
    ^ InvalidNewSignal raise.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   117
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   118
22
847106305963 *** empty log message ***
claus
parents: 11
diff changeset
   119
new:size
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   120
    "catch creation of blocks - only the system creates blocks"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   121
128
c50a2157883e return value of signal raise
claus
parents: 103
diff changeset
   122
    ^ InvalidNewSignal raise.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   123
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   124
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   125
!Block class methodsFor:'queries'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   126
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   127
isBuiltInClass
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   128
    "this class is known by the run-time-system"
11
6bf3080856be *** empty log message ***
claus
parents: 10
diff changeset
   129
1181
6637fee79d7b only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   130
    ^ self == Block
6637fee79d7b only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   131
6637fee79d7b only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   132
    "Modified: 16.4.1996 / 11:25:30 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   133
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   134
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   135
!Block methodsFor:'STV compatibility'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   136
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   137
on:aSignal do:exceptionBlock
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   138
    "added for ST/V compatibility; evaluate the receiver,
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   139
     handling aSignal. The argument, exceptionBlock is evaluated
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   140
     if the signal is raised during evaluation.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   141
     Warning: no warranty, if the code below mimics ST/V's behavior
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   142
     correctly - give me a note if it does not ."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   143
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   144
    aSignal handle:[:ex |
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   145
	exceptionBlock value.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   146
	ex return
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   147
    ] do:self
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   148
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   149
    "
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   150
     [
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   151
	1 foo
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   152
     ] on:MessageNotUnderstoodSignal do:[]
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   153
    "
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   154
! !
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   155
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   156
!Block methodsFor:'accessing'!
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   157
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   158
home
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   159
    "return the receivers home context (the context where it was
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   160
     created). For cheap blocks, nil is returned"
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   161
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   162
    ^ home
161
ed36169f354d *** empty log message ***
claus
parents: 154
diff changeset
   163
!
ed36169f354d *** empty log message ***
claus
parents: 154
diff changeset
   164
ed36169f354d *** empty log message ***
claus
parents: 154
diff changeset
   165
method
ed36169f354d *** empty log message ***
claus
parents: 154
diff changeset
   166
    "return the receivers method 
ed36169f354d *** empty log message ***
claus
parents: 154
diff changeset
   167
     (the method where the block was created)."
ed36169f354d *** empty log message ***
claus
parents: 154
diff changeset
   168
ed36169f354d *** empty log message ***
claus
parents: 154
diff changeset
   169
    home notNil ifTrue:[
ed36169f354d *** empty log message ***
claus
parents: 154
diff changeset
   170
	^ home method
ed36169f354d *** empty log message ***
claus
parents: 154
diff changeset
   171
    ].
ed36169f354d *** empty log message ***
claus
parents: 154
diff changeset
   172
    ^ nil
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   173
!
11
6bf3080856be *** empty log message ***
claus
parents: 10
diff changeset
   174
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   175
methodHome
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   176
    "return the receivers method home context (the context where it was
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   177
     defined). For cheap blocks, nil is returned"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   178
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   179
    home notNil ifTrue:[
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   180
	^ home methodHome
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   181
    ].
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   182
    ^ home
11
6bf3080856be *** empty log message ***
claus
parents: 10
diff changeset
   183
!
6bf3080856be *** empty log message ***
claus
parents: 10
diff changeset
   184
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   185
numArgs
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   186
    "return the number of arguments I expect for evaluation"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   187
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   188
    ^ nargs
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   189
! !
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   190
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   191
!Block methodsFor:'copying'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   192
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   193
deepCopy
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   194
    "raise an error - deepCopy is not allowed for blocks"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   195
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   196
    ^ self deepCopyError
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   197
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   198
a27a279701f8 Initial revision
claus
parents:
diff changeset
   199
!Block methodsFor:'error handling'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   200
328
claus
parents: 326
diff changeset
   201
invalidCodeObject
67
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   202
    "this error is triggered by the interpreter when a non-Block object
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   203
     is about to be executed.
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   204
     In this case, the VM sends this to the bad method (the receiver).
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   205
     Can only happen when the Compiler/runtime system is broken or
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   206
     someone played around."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   207
128
c50a2157883e return value of signal raise
claus
parents: 103
diff changeset
   208
    ^ InvalidCodeSignal
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   209
	raiseRequestWith:self
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   210
	errorString:'invalid block - not executable'
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   211
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   212
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   213
wrongNumberOfArguments:numberGiven
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   214
    "report that the number of arguments given does not match the number expected"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   215
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   216
    ^ ArgumentSignal
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   217
	raiseRequestWith:self
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   218
	errorString:('block got ' , numberGiven printString ,
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   219
		     ' args while ' , nargs printString , ' where expected')
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   220
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   221
a27a279701f8 Initial revision
claus
parents:
diff changeset
   222
!Block methodsFor:'evaluation'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   223
a27a279701f8 Initial revision
claus
parents:
diff changeset
   224
value
a27a279701f8 Initial revision
claus
parents:
diff changeset
   225
    "evaluate the receiver with no block args. The receiver must be a block without arguments."
a27a279701f8 Initial revision
claus
parents:
diff changeset
   226
a27a279701f8 Initial revision
claus
parents:
diff changeset
   227
%{  /* NOCONTEXT */
a27a279701f8 Initial revision
claus
parents:
diff changeset
   228
a27a279701f8 Initial revision
claus
parents:
diff changeset
   229
    REGISTER OBJFUNC thecode;
a27a279701f8 Initial revision
claus
parents:
diff changeset
   230
    OBJ home;
a27a279701f8 Initial revision
claus
parents:
diff changeset
   231
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   232
    if (__INST(nargs) == __MKSMALLINT(0)) {
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   233
#if defined(THIS_CONTEXT)
328
claus
parents: 326
diff changeset
   234
	if (__ISVALID_ILC_LNO(__pilc))
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   235
	    __ContextInstPtr(__thisContext)->c_lineno = __ILC_LNO_AS_OBJ(__pilc);
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   236
#endif
328
claus
parents: 326
diff changeset
   237
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   238
	thecode = __BlockInstPtr(self)->b_code;
11
6bf3080856be *** empty log message ***
claus
parents: 10
diff changeset
   239
#ifdef NEW_BLOCK_CALL
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   240
	if (thecode != (OBJFUNC)nil) {
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   241
	    /* compiled machine code */
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   242
	    RETURN ( (*thecode)(self, COMMA_SND) );
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   243
	}
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   244
	/* interpreted code */
328
claus
parents: 326
diff changeset
   245
# ifdef PASS_ARG_POINTER
400
claus
parents: 384
diff changeset
   246
	RETURN ( __interpret(self, 0, nil, nil COMMA_SND, nil) );
328
claus
parents: 326
diff changeset
   247
# else
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   248
	RETURN ( __interpret(self, 0, nil, nil COMMA_SND, nil) );
328
claus
parents: 326
diff changeset
   249
# endif
11
6bf3080856be *** empty log message ***
claus
parents: 10
diff changeset
   250
#else
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   251
	home = __BlockInstPtr(self)->b_home;
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   252
	if (thecode != (OBJFUNC)nil) {
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   253
	    /* compiled machine code */
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   254
	    RETURN ( (*thecode)(home COMMA_SND) );
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   255
	}
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   256
	/* interpreted code */
328
claus
parents: 326
diff changeset
   257
# ifdef PASS_ARG_POINTER
400
claus
parents: 384
diff changeset
   258
	RETURN ( __interpret(self, 0, nil, home COMMA_SND, nil) );
328
claus
parents: 326
diff changeset
   259
# else
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   260
	RETURN ( __interpret(self, 0, nil, home COMMA_SND, nil) );
328
claus
parents: 326
diff changeset
   261
# endif
11
6bf3080856be *** empty log message ***
claus
parents: 10
diff changeset
   262
#endif
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   263
    }
a27a279701f8 Initial revision
claus
parents:
diff changeset
   264
%}
a27a279701f8 Initial revision
claus
parents:
diff changeset
   265
.
103
de0f8152878f errors now raise a signal
claus
parents: 98
diff changeset
   266
    ^ self wrongNumberOfArguments:0
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   267
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   268
a27a279701f8 Initial revision
claus
parents:
diff changeset
   269
value:arg
a27a279701f8 Initial revision
claus
parents:
diff changeset
   270
    "evaluate the receiver with one argument. The receiver must be a 1-arg block."
a27a279701f8 Initial revision
claus
parents:
diff changeset
   271
a27a279701f8 Initial revision
claus
parents:
diff changeset
   272
%{  /* NOCONTEXT */
a27a279701f8 Initial revision
claus
parents:
diff changeset
   273
a27a279701f8 Initial revision
claus
parents:
diff changeset
   274
    REGISTER OBJFUNC thecode;
a27a279701f8 Initial revision
claus
parents:
diff changeset
   275
    OBJ home;
a27a279701f8 Initial revision
claus
parents:
diff changeset
   276
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   277
    if (__INST(nargs) == __MKSMALLINT(1)) {
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   278
#if defined(THIS_CONTEXT)
328
claus
parents: 326
diff changeset
   279
	if (__ISVALID_ILC_LNO(__pilc))
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   280
	    __ContextInstPtr(__thisContext)->c_lineno = __ILC_LNO_AS_OBJ(__pilc);
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   281
#endif
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   282
	thecode = __BlockInstPtr(self)->b_code;
11
6bf3080856be *** empty log message ***
claus
parents: 10
diff changeset
   283
#ifdef NEW_BLOCK_CALL
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   284
	if (thecode != (OBJFUNC)nil) {
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   285
	    RETURN ( (*thecode)(self COMMA_SND, arg) );
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   286
	}
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   287
	/* interpreted code */
328
claus
parents: 326
diff changeset
   288
# ifdef PASS_ARG_POINTER
claus
parents: 326
diff changeset
   289
	RETURN ( __interpret(self, 1, nil, nil COMMA_SND, nil, &arg) );
claus
parents: 326
diff changeset
   290
# else
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   291
	RETURN ( __interpret(self, 1, nil, nil COMMA_SND, nil, arg) );
328
claus
parents: 326
diff changeset
   292
# endif
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   293
#else
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   294
	home = __BlockInstPtr(self)->b_home;
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   295
	if (thecode != (OBJFUNC)nil) {
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   296
	    RETURN ( (*thecode)(home COMMA_SND, arg) );
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   297
	}
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   298
	/* interpreted code */
328
claus
parents: 326
diff changeset
   299
# ifdef PASS_ARG_POINTER
claus
parents: 326
diff changeset
   300
	RETURN ( __interpret(self, 1, nil, home COMMA_SND, nil, &arg) );
claus
parents: 326
diff changeset
   301
# else
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   302
	RETURN ( __interpret(self, 1, nil, home COMMA_SND, nil, arg) );
328
claus
parents: 326
diff changeset
   303
# endif
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   304
#endif
a27a279701f8 Initial revision
claus
parents:
diff changeset
   305
    }
a27a279701f8 Initial revision
claus
parents:
diff changeset
   306
%}
a27a279701f8 Initial revision
claus
parents:
diff changeset
   307
.
103
de0f8152878f errors now raise a signal
claus
parents: 98
diff changeset
   308
    ^ self wrongNumberOfArguments:1
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   309
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   310
a27a279701f8 Initial revision
claus
parents:
diff changeset
   311
value:arg1 value:arg2
a27a279701f8 Initial revision
claus
parents:
diff changeset
   312
    "evaluate the receiver with two arguments. The receiver must be a 2-arg block."
a27a279701f8 Initial revision
claus
parents:
diff changeset
   313
a27a279701f8 Initial revision
claus
parents:
diff changeset
   314
%{  /* NOCONTEXT */
a27a279701f8 Initial revision
claus
parents:
diff changeset
   315
a27a279701f8 Initial revision
claus
parents:
diff changeset
   316
    REGISTER OBJFUNC thecode;
a27a279701f8 Initial revision
claus
parents:
diff changeset
   317
    OBJ home;
a27a279701f8 Initial revision
claus
parents:
diff changeset
   318
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   319
    if (__INST(nargs) == __MKSMALLINT(2)) {
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   320
#if defined(THIS_CONTEXT)
328
claus
parents: 326
diff changeset
   321
	if (__ISVALID_ILC_LNO(__pilc))
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   322
	    __ContextInstPtr(__thisContext)->c_lineno = __ILC_LNO_AS_OBJ(__pilc);
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   323
#endif
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   324
	thecode = __BlockInstPtr(self)->b_code;
11
6bf3080856be *** empty log message ***
claus
parents: 10
diff changeset
   325
#ifdef NEW_BLOCK_CALL
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   326
	if (thecode != (OBJFUNC)nil) {
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   327
	    RETURN ( (*thecode)(self COMMA_SND, arg1, arg2) );
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   328
	}
328
claus
parents: 326
diff changeset
   329
# ifdef PASS_ARG_POINTER
claus
parents: 326
diff changeset
   330
	RETURN ( __interpret(self, 2, nil, nil COMMA_SND, nil, &arg1) );
claus
parents: 326
diff changeset
   331
# else
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   332
	RETURN ( __interpret(self, 2, nil, nil COMMA_SND, nil, arg1, arg2) );
328
claus
parents: 326
diff changeset
   333
# endif
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   334
#else
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   335
	home = __BlockInstPtr(self)->b_home;
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   336
	if (thecode != (OBJFUNC)nil) {
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   337
	    RETURN ( (*thecode)(home COMMA_SND, arg1, arg2) );
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   338
	}
328
claus
parents: 326
diff changeset
   339
# ifdef PASS_ARG_POINTER
claus
parents: 326
diff changeset
   340
	RETURN ( __interpret(self, 2, nil, home COMMA_SND, nil, &arg1) );
claus
parents: 326
diff changeset
   341
# else
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   342
	RETURN ( __interpret(self, 2, nil, home COMMA_SND, nil, arg1, arg2) );
328
claus
parents: 326
diff changeset
   343
# endif
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   344
#endif
a27a279701f8 Initial revision
claus
parents:
diff changeset
   345
    }
a27a279701f8 Initial revision
claus
parents:
diff changeset
   346
%}
a27a279701f8 Initial revision
claus
parents:
diff changeset
   347
.
103
de0f8152878f errors now raise a signal
claus
parents: 98
diff changeset
   348
    ^ self wrongNumberOfArguments:2
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   349
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   350
a27a279701f8 Initial revision
claus
parents:
diff changeset
   351
value:arg1 value:arg2 value:arg3
a27a279701f8 Initial revision
claus
parents:
diff changeset
   352
    "evaluate the receiver with three arguments. The receiver must be a 3-arg block."
a27a279701f8 Initial revision
claus
parents:
diff changeset
   353
a27a279701f8 Initial revision
claus
parents:
diff changeset
   354
%{  /* NOCONTEXT */
a27a279701f8 Initial revision
claus
parents:
diff changeset
   355
a27a279701f8 Initial revision
claus
parents:
diff changeset
   356
    REGISTER OBJFUNC thecode;
a27a279701f8 Initial revision
claus
parents:
diff changeset
   357
    OBJ home;
a27a279701f8 Initial revision
claus
parents:
diff changeset
   358
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   359
    if (__INST(nargs) == __MKSMALLINT(3)) {
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   360
#if defined(THIS_CONTEXT)
328
claus
parents: 326
diff changeset
   361
	if (__ISVALID_ILC_LNO(__pilc))
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   362
	    __ContextInstPtr(__thisContext)->c_lineno = __ILC_LNO_AS_OBJ(__pilc);
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   363
#endif
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   364
	thecode = __BlockInstPtr(self)->b_code;
11
6bf3080856be *** empty log message ***
claus
parents: 10
diff changeset
   365
#ifdef NEW_BLOCK_CALL
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   366
	if (thecode != (OBJFUNC)nil) {
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   367
	    RETURN ( (*thecode)(self COMMA_SND, arg1, arg2, arg3) );
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   368
	}
328
claus
parents: 326
diff changeset
   369
# ifdef PASS_ARG_POINTER
claus
parents: 326
diff changeset
   370
	RETURN ( __interpret(self, 3, nil, nil COMMA_SND, nil, &arg1) );
claus
parents: 326
diff changeset
   371
# else
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   372
	RETURN ( __interpret(self, 3, nil, nil COMMA_SND, nil, arg1, arg2, arg3) );
328
claus
parents: 326
diff changeset
   373
# endif
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   374
#else
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   375
	home = __BlockInstPtr(self)->b_home;
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   376
	if (thecode != (OBJFUNC)nil) {
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   377
	    RETURN ( (*thecode)(home COMMA_SND, arg1, arg2, arg3) );
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   378
	}
328
claus
parents: 326
diff changeset
   379
# ifdef PASS_ARG_POINTER
claus
parents: 326
diff changeset
   380
	RETURN ( __interpret(self, 3, nil, home COMMA_SND, nil, &arg1) );
claus
parents: 326
diff changeset
   381
# else
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   382
	RETURN ( __interpret(self, 3, nil, home COMMA_SND, nil, arg1, arg2, arg3) );
328
claus
parents: 326
diff changeset
   383
# endif
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   384
#endif
a27a279701f8 Initial revision
claus
parents:
diff changeset
   385
    }
a27a279701f8 Initial revision
claus
parents:
diff changeset
   386
%}
a27a279701f8 Initial revision
claus
parents:
diff changeset
   387
.
103
de0f8152878f errors now raise a signal
claus
parents: 98
diff changeset
   388
    ^ self wrongNumberOfArguments:3
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   389
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   390
a27a279701f8 Initial revision
claus
parents:
diff changeset
   391
value:arg1 value:arg2 value:arg3 value:arg4
a27a279701f8 Initial revision
claus
parents:
diff changeset
   392
    "evaluate the receiver with four arguments. The receiver must be a 4-arg block."
a27a279701f8 Initial revision
claus
parents:
diff changeset
   393
a27a279701f8 Initial revision
claus
parents:
diff changeset
   394
%{  /* NOCONTEXT */
a27a279701f8 Initial revision
claus
parents:
diff changeset
   395
a27a279701f8 Initial revision
claus
parents:
diff changeset
   396
    REGISTER OBJFUNC thecode;
a27a279701f8 Initial revision
claus
parents:
diff changeset
   397
    OBJ home;
a27a279701f8 Initial revision
claus
parents:
diff changeset
   398
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   399
    if (__INST(nargs) == __MKSMALLINT(4)) {
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   400
#if defined(THIS_CONTEXT)
328
claus
parents: 326
diff changeset
   401
	if (__ISVALID_ILC_LNO(__pilc))
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   402
	    __ContextInstPtr(__thisContext)->c_lineno = __ILC_LNO_AS_OBJ(__pilc);
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   403
#endif
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   404
	thecode = __BlockInstPtr(self)->b_code;
11
6bf3080856be *** empty log message ***
claus
parents: 10
diff changeset
   405
#ifdef NEW_BLOCK_CALL
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   406
	if (thecode != (OBJFUNC)nil) {
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   407
	    RETURN ( (*thecode)(self COMMA_SND, arg1, arg2, arg3, arg4) );
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   408
	}
328
claus
parents: 326
diff changeset
   409
# ifdef PASS_ARG_POINTER
claus
parents: 326
diff changeset
   410
	RETURN ( __interpret(self, 4, nil, nil COMMA_SND, nil, &arg1) );
claus
parents: 326
diff changeset
   411
# else
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   412
	RETURN ( __interpret(self, 4, nil, nil COMMA_SND, nil, arg1, arg2, arg3, arg4) );
328
claus
parents: 326
diff changeset
   413
# endif
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   414
#else
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   415
	home = __BlockInstPtr(self)->b_home;
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   416
	if (thecode != (OBJFUNC)nil) {
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   417
	    RETURN ( (*thecode)(home COMMA_SND, arg1, arg2, arg3, arg4) );
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   418
	}
328
claus
parents: 326
diff changeset
   419
# ifdef PASS_ARG_POINTER
claus
parents: 326
diff changeset
   420
	RETURN ( __interpret(self, 4, nil, home COMMA_SND, nil, &arg1) );
claus
parents: 326
diff changeset
   421
# else
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   422
	RETURN ( __interpret(self, 4, nil, home COMMA_SND, nil, arg1, arg2, arg3, arg4) );
328
claus
parents: 326
diff changeset
   423
# endif
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   424
#endif
a27a279701f8 Initial revision
claus
parents:
diff changeset
   425
    }
a27a279701f8 Initial revision
claus
parents:
diff changeset
   426
%}
a27a279701f8 Initial revision
claus
parents:
diff changeset
   427
.
103
de0f8152878f errors now raise a signal
claus
parents: 98
diff changeset
   428
    ^ self wrongNumberOfArguments:4
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   429
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   430
a27a279701f8 Initial revision
claus
parents:
diff changeset
   431
value:arg1 value:arg2 value:arg3 value:arg4 value:arg5
a27a279701f8 Initial revision
claus
parents:
diff changeset
   432
    "evaluate the receiver with four arguments. The receiver must be a 5-arg block."
a27a279701f8 Initial revision
claus
parents:
diff changeset
   433
a27a279701f8 Initial revision
claus
parents:
diff changeset
   434
%{  /* NOCONTEXT */
a27a279701f8 Initial revision
claus
parents:
diff changeset
   435
a27a279701f8 Initial revision
claus
parents:
diff changeset
   436
    REGISTER OBJFUNC thecode;
a27a279701f8 Initial revision
claus
parents:
diff changeset
   437
    OBJ home;
a27a279701f8 Initial revision
claus
parents:
diff changeset
   438
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   439
    if (__INST(nargs) == __MKSMALLINT(5)) {
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   440
#if defined(THIS_CONTEXT)
328
claus
parents: 326
diff changeset
   441
	if (__ISVALID_ILC_LNO(__pilc))
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   442
	    __ContextInstPtr(__thisContext)->c_lineno = __ILC_LNO_AS_OBJ(__pilc);
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   443
#endif
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   444
	thecode = __BlockInstPtr(self)->b_code;
11
6bf3080856be *** empty log message ***
claus
parents: 10
diff changeset
   445
#ifdef NEW_BLOCK_CALL
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   446
	if (thecode != (OBJFUNC)nil) {
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   447
	    RETURN ( (*thecode)(self COMMA_SND, arg1, arg2, arg3, arg4, arg5) );
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   448
	}
328
claus
parents: 326
diff changeset
   449
# ifdef PASS_ARG_POINTER
claus
parents: 326
diff changeset
   450
	RETURN ( __interpret(self, 5, nil, nil COMMA_SND, nil, &arg1) );
claus
parents: 326
diff changeset
   451
# else
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   452
	RETURN ( __interpret(self, 5, nil, nil COMMA_SND, nil, arg1, arg2, arg3, arg4, arg5) );
328
claus
parents: 326
diff changeset
   453
# endif
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   454
#else
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   455
	home = __BlockInstPtr(self)->b_home;
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   456
	if (thecode != (OBJFUNC)nil) {
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   457
	    RETURN ( (*thecode)(home COMMA_SND, arg1, arg2, arg3, arg4, arg5) );
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   458
	}
328
claus
parents: 326
diff changeset
   459
# ifdef PASS_ARG_POINTER
claus
parents: 326
diff changeset
   460
	RETURN ( __interpret(self, 5, nil, home COMMA_SND, nil, &arg1) );
claus
parents: 326
diff changeset
   461
# else
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   462
	RETURN ( __interpret(self, 5, nil, home COMMA_SND, nil, arg1, arg2, arg3, arg4, arg5) );
328
claus
parents: 326
diff changeset
   463
# endif
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   464
#endif
a27a279701f8 Initial revision
claus
parents:
diff changeset
   465
    }
a27a279701f8 Initial revision
claus
parents:
diff changeset
   466
%}
a27a279701f8 Initial revision
claus
parents:
diff changeset
   467
.
103
de0f8152878f errors now raise a signal
claus
parents: 98
diff changeset
   468
    ^ self wrongNumberOfArguments:5
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   469
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   470
a27a279701f8 Initial revision
claus
parents:
diff changeset
   471
value:arg1 value:arg2 value:arg3 value:arg4 value:arg5 value:arg6
a27a279701f8 Initial revision
claus
parents:
diff changeset
   472
    "evaluate the receiver with four arguments. The receiver must be a 6-arg block."
a27a279701f8 Initial revision
claus
parents:
diff changeset
   473
a27a279701f8 Initial revision
claus
parents:
diff changeset
   474
%{  /* NOCONTEXT */
a27a279701f8 Initial revision
claus
parents:
diff changeset
   475
a27a279701f8 Initial revision
claus
parents:
diff changeset
   476
    REGISTER OBJFUNC thecode;
a27a279701f8 Initial revision
claus
parents:
diff changeset
   477
    OBJ home;
a27a279701f8 Initial revision
claus
parents:
diff changeset
   478
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   479
    if (__INST(nargs) == __MKSMALLINT(6)) {
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   480
#if defined(THIS_CONTEXT)
328
claus
parents: 326
diff changeset
   481
	if (__ISVALID_ILC_LNO(__pilc))
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   482
	    __ContextInstPtr(__thisContext)->c_lineno = __ILC_LNO_AS_OBJ(__pilc);
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   483
#endif
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   484
	thecode = __BlockInstPtr(self)->b_code;
11
6bf3080856be *** empty log message ***
claus
parents: 10
diff changeset
   485
#ifdef NEW_BLOCK_CALL
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   486
	if (thecode != (OBJFUNC)nil) {
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   487
	    RETURN ( (*thecode)(self COMMA_SND, arg1, arg2, arg3, arg4, arg5, arg6) );
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   488
	}
328
claus
parents: 326
diff changeset
   489
# ifdef PASS_ARG_POINTER
claus
parents: 326
diff changeset
   490
	RETURN ( __interpret(self, 6, nil, nil COMMA_SND, nil, &arg1) );
claus
parents: 326
diff changeset
   491
# else
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   492
	RETURN ( __interpret(self, 6, nil, nil COMMA_SND, nil, arg1, arg2, arg3, arg4, arg5, arg6) );
328
claus
parents: 326
diff changeset
   493
# endif
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   494
#else
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   495
	home = __BlockInstPtr(self)->b_home;
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   496
	if (thecode != (OBJFUNC)nil) {
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   497
	    RETURN ( (*thecode)(home COMMA_SND, arg1, arg2, arg3, arg4, arg5, arg6) );
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   498
	}
328
claus
parents: 326
diff changeset
   499
# ifdef PASS_ARG_POINTER
claus
parents: 326
diff changeset
   500
	RETURN ( __interpret(self, 6, nil, home COMMA_SND, nil, &arg1) );
claus
parents: 326
diff changeset
   501
# else
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   502
	RETURN ( __interpret(self, 6, nil, home COMMA_SND, nil, arg1, arg2, arg3, arg4, arg5, arg6) );
328
claus
parents: 326
diff changeset
   503
# endif
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   504
#endif
a27a279701f8 Initial revision
claus
parents:
diff changeset
   505
    }
a27a279701f8 Initial revision
claus
parents:
diff changeset
   506
%}
a27a279701f8 Initial revision
claus
parents:
diff changeset
   507
.
103
de0f8152878f errors now raise a signal
claus
parents: 98
diff changeset
   508
    ^ self wrongNumberOfArguments:6
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   509
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   510
a27a279701f8 Initial revision
claus
parents:
diff changeset
   511
valueWithArguments:argArray
a27a279701f8 Initial revision
claus
parents:
diff changeset
   512
    "evaluate the receiver with arguments taken from argArray.
313
83c50ef3886a *** empty log message ***
claus
parents: 306
diff changeset
   513
     ArgArray must be either an Array or nil.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   514
     The size of the argArray must match the number of arguments the receiver expects."
a27a279701f8 Initial revision
claus
parents:
diff changeset
   515
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   516
    |a1 a2 a3 a4 a5 a6 a7 a8|
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   517
319
claus
parents: 313
diff changeset
   518
    (argArray notNil and:[argArray class ~~ Array]) ifTrue:[
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   519
	^ self badArgumentArry
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   520
    ].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   521
    (argArray size == nargs) ifFalse:[
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   522
	^ self wrongNumberOfArguments:(argArray size)
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   523
    ].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   524
%{
a27a279701f8 Initial revision
claus
parents:
diff changeset
   525
a27a279701f8 Initial revision
claus
parents:
diff changeset
   526
    REGISTER OBJFUNC thecode;
a27a279701f8 Initial revision
claus
parents:
diff changeset
   527
    OBJ home;
67
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   528
    REGISTER OBJ *ap;
328
claus
parents: 326
diff changeset
   529
    int nargs;
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   530
a27a279701f8 Initial revision
claus
parents:
diff changeset
   531
#if defined(THIS_CONTEXT)
328
claus
parents: 326
diff changeset
   532
    if (__ISVALID_ILC_LNO(__pilc))
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   533
	    __ContextInstPtr(__thisContext)->c_lineno = __ILC_LNO_AS_OBJ(__pilc);
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   534
#endif
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   535
    thecode = __BlockInstPtr(self)->b_code;
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   536
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   537
#ifndef NEW_BLOCK_CALL
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   538
    home = __BlockInstPtr(self)->b_home;
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   539
    if (thecode != (OBJFUNC)nil) {
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   540
        switch (nargs = __intVal(__INST(nargs))) {
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   541
            default:
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   542
                goto error;
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   543
            case 8:
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   544
                ap = __ArrayInstPtr(argArray)->a_element;
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   545
	        RETURN ( (*thecode)(home COMMA_SND, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7]) );
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   546
            case 7:
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   547
                ap = __ArrayInstPtr(argArray)->a_element;
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   548
	        RETURN ( (*thecode)(home COMMA_SND, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6]) );
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   549
            case 6:
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   550
                ap = __ArrayInstPtr(argArray)->a_element;
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   551
	        RETURN ( (*thecode)(home COMMA_SND, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5]) );
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   552
            case 5:
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   553
                ap = __ArrayInstPtr(argArray)->a_element;
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   554
	        RETURN ( (*thecode)(home COMMA_SND, ap[0], ap[1], ap[2], ap[3], ap[4]) );
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   555
            case 4:
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   556
                ap = __ArrayInstPtr(argArray)->a_element;
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   557
	        RETURN ( (*thecode)(home COMMA_SND, ap[0], ap[1], ap[2], ap[3]) );
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   558
            case 3:
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   559
                ap = __ArrayInstPtr(argArray)->a_element;
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   560
	        RETURN ( (*thecode)(home COMMA_SND, ap[0], ap[1], ap[2]) );
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   561
            case 2:
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   562
                ap = __ArrayInstPtr(argArray)->a_element;
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   563
	        RETURN ( (*thecode)(home COMMA_SND, ap[0], ap[1]) );
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   564
            case 1:
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   565
	        RETURN ( (*thecode)(home COMMA_SND, __ArrayInstPtr(argArray)->a_element[0]) );
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   566
            case 0:
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   567
	        RETURN ( (*thecode)(home COMMA_SND) );
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   568
                break;
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   569
	}
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   570
    }
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   571
#endif
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   572
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   573
    switch (nargs = __intVal(__INST(nargs))) {
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   574
	default:
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   575
	    goto error;
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   576
	case 8:
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   577
	    a8 = __ArrayInstPtr(argArray)->a_element[7];
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   578
	case 7:
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   579
	    a7 = __ArrayInstPtr(argArray)->a_element[6];
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   580
	case 6:
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   581
	    a6 = __ArrayInstPtr(argArray)->a_element[5];
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   582
	case 5:
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   583
	    a5 = __ArrayInstPtr(argArray)->a_element[4];
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   584
	case 4:
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   585
	    a4 = __ArrayInstPtr(argArray)->a_element[3];
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   586
	case 3:
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   587
	    a3 = __ArrayInstPtr(argArray)->a_element[2];
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   588
	case 2:
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   589
	    a2 = __ArrayInstPtr(argArray)->a_element[1];
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   590
	case 1:
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   591
	    a1 = __ArrayInstPtr(argArray)->a_element[0];
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   592
	case 0:
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   593
	    break;
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   594
    }
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1041
diff changeset
   595
11
6bf3080856be *** empty log message ***
claus
parents: 10
diff changeset
   596
#ifdef NEW_BLOCK_CALL
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   597
    if (thecode != (OBJFUNC)nil) {
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   598
	RETURN ( (*thecode)(self COMMA_SND, a1, a2, a3, a4, a5, a6, a7, a8) );
11
6bf3080856be *** empty log message ***
claus
parents: 10
diff changeset
   599
    }
328
claus
parents: 326
diff changeset
   600
# ifdef PASS_ARG_POINTER
claus
parents: 326
diff changeset
   601
    RETURN ( __interpret(self, nargs, nil, nil COMMA_SND, nil, &a1) );
claus
parents: 326
diff changeset
   602
# else
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   603
    RETURN ( __interpret(self, nargs, nil, nil COMMA_SND, nil, a1, a2, a3, a4, a5, a6, a7, a8) );
328
claus
parents: 326
diff changeset
   604
# endif
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   605
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   606
#else
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   607
328
claus
parents: 326
diff changeset
   608
# ifdef PASS_ARG_POINTER
claus
parents: 326
diff changeset
   609
    RETURN ( __interpret(self, nargs, nil, home COMMA_SND, nil, &a1) );
claus
parents: 326
diff changeset
   610
# else
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   611
    RETURN ( __interpret(self, nargs, nil, home COMMA_SND, nil, a1, a2, a3, a4, a5, a6, a7, a8) );
328
claus
parents: 326
diff changeset
   612
# endif
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 864
diff changeset
   613
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   614
#endif
67
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   615
11
6bf3080856be *** empty log message ***
claus
parents: 10
diff changeset
   616
error: ;
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   617
%}
11
6bf3080856be *** empty log message ***
claus
parents: 10
diff changeset
   618
.
138
c9f46b635f98 *** empty log message ***
claus
parents: 128
diff changeset
   619
    "
c9f46b635f98 *** empty log message ***
claus
parents: 128
diff changeset
   620
     the above code only supports up-to 7 arguments
c9f46b635f98 *** empty log message ***
claus
parents: 128
diff changeset
   621
    "
128
c50a2157883e return value of signal raise
claus
parents: 103
diff changeset
   622
    ^ ArgumentSignal
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   623
	raiseRequestWith:self
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   624
	errorString:'only blocks with up-to 7 arguments supported'
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   625
! !
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   626
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   627
!Block methodsFor:'looping'!
325
claus
parents: 319
diff changeset
   628
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   629
doUntil:aBlock
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   630
    "repeat the receiver block until aBlock evaluates to true.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   631
     The receiver is evaluated at least once.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   632
     This is the same as '... doWhile:[... not]' "
325
claus
parents: 319
diff changeset
   633
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   634
    "this implementation is for purists ... :-)"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   635
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   636
    self value.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   637
    aBlock value ifTrue:[^ nil].
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   638
    thisContext restart
325
claus
parents: 319
diff changeset
   639
claus
parents: 319
diff changeset
   640
    "
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   641
     |n|
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   642
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   643
     n := 1.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   644
     [n printNewline] doUntil:[ (n := n + 1) > 5 ]
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   645
    "
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   646
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   647
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   648
doWhile:aBlock
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   649
    "repeat the receiver block until aBlock evaluates to false.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   650
     The receiver is evaluated at least once."
67
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   651
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   652
    "this implementation is for purists ... :-)"
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   653
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   654
    self value.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   655
    aBlock value ifFalse:[^ nil].
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   656
    thisContext restart
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   657
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   658
    "
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   659
     |n|
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   660
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   661
     n := 1.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   662
     [n printNewline] doWhile:[ (n := n + 1) <= 5 ]
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   663
    "
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   664
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   665
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   666
loop
1211
c5bdb3fc3cb4 commentary
Claus Gittinger <cg@exept.de>
parents: 1189
diff changeset
   667
    "repeat the receiver forever 
c5bdb3fc3cb4 commentary
Claus Gittinger <cg@exept.de>
parents: 1189
diff changeset
   668
     (the receiver block should contain a return somewhere).
c5bdb3fc3cb4 commentary
Claus Gittinger <cg@exept.de>
parents: 1189
diff changeset
   669
     The implementation below was inspired by a corresponding Self method."
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   670
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   671
    self value.
67
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   672
    thisContext restart
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   673
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   674
    "
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   675
     |n|
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   676
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   677
     n := 1.
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   678
     [
1211
c5bdb3fc3cb4 commentary
Claus Gittinger <cg@exept.de>
parents: 1189
diff changeset
   679
        n printNewline.
c5bdb3fc3cb4 commentary
Claus Gittinger <cg@exept.de>
parents: 1189
diff changeset
   680
        n >= 10 ifTrue:[^ nil].
c5bdb3fc3cb4 commentary
Claus Gittinger <cg@exept.de>
parents: 1189
diff changeset
   681
        n := n + 1
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   682
     ] loop
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   683
    "
1211
c5bdb3fc3cb4 commentary
Claus Gittinger <cg@exept.de>
parents: 1189
diff changeset
   684
c5bdb3fc3cb4 commentary
Claus Gittinger <cg@exept.de>
parents: 1189
diff changeset
   685
    "Modified: 18.4.1996 / 13:50:40 / cg"
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   686
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   687
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   688
loopWithExit
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   689
    "the receiver must be a block of one argument.  It is evaluated in a loop forever, 
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   690
     and is passed a block, which, if sent a value:-message, will exit the receiver block, 
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   691
     returning the parameter of the value:-message. Used for loops with exit in the middle.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   692
     Inspired by a corresponding Self method."
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   693
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   694
    |exitBlock|
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   695
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   696
    exitBlock := [:exitValue | ^ exitValue].
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   697
    [true] whileTrue:[self value:exitBlock]
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   698
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   699
    "
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   700
     |i|
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   701
     i := 1.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   702
     [:exit |
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   703
	Transcript showCr:i.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   704
	i == 5 ifTrue:[exit value:'thats it'].
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   705
	i := i + 1
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   706
     ] loopWithExit
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   707
    "
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   708
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   709
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   710
repeat
1211
c5bdb3fc3cb4 commentary
Claus Gittinger <cg@exept.de>
parents: 1189
diff changeset
   711
    "repeat the receiver forever - same as loop, for ST-80 compatibility.
c5bdb3fc3cb4 commentary
Claus Gittinger <cg@exept.de>
parents: 1189
diff changeset
   712
      (the receiver block should contain a return somewhere)."
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   713
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   714
    self value.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   715
    thisContext restart
1211
c5bdb3fc3cb4 commentary
Claus Gittinger <cg@exept.de>
parents: 1189
diff changeset
   716
c5bdb3fc3cb4 commentary
Claus Gittinger <cg@exept.de>
parents: 1189
diff changeset
   717
    "Modified: 18.4.1996 / 13:50:55 / cg"
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   718
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   719
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   720
valueWithExit
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   721
    "the receiver must be a block of one argument.  It is evaluated, and is passed a block,
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   722
     which, if sent a value:-message, will exit the receiver block, returning the parameter of the 
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   723
     value:-message. Used for premature returns to the caller.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   724
     Taken from a manchester goody (a similar construct also appears in Self)."
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   725
1211
c5bdb3fc3cb4 commentary
Claus Gittinger <cg@exept.de>
parents: 1189
diff changeset
   726
    ^ self value:[:exitValue | ^exitValue]
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   727
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   728
    "
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   729
     [:exit |
1211
c5bdb3fc3cb4 commentary
Claus Gittinger <cg@exept.de>
parents: 1189
diff changeset
   730
        1 to:10 do:[:i |
c5bdb3fc3cb4 commentary
Claus Gittinger <cg@exept.de>
parents: 1189
diff changeset
   731
            Transcript showCr:i.
c5bdb3fc3cb4 commentary
Claus Gittinger <cg@exept.de>
parents: 1189
diff changeset
   732
            i == 5 ifTrue:[exit value:'thats it']
c5bdb3fc3cb4 commentary
Claus Gittinger <cg@exept.de>
parents: 1189
diff changeset
   733
        ].
c5bdb3fc3cb4 commentary
Claus Gittinger <cg@exept.de>
parents: 1189
diff changeset
   734
        'regular block-value; never returned'
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   735
     ] valueWithExit
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   736
    "
1211
c5bdb3fc3cb4 commentary
Claus Gittinger <cg@exept.de>
parents: 1189
diff changeset
   737
c5bdb3fc3cb4 commentary
Claus Gittinger <cg@exept.de>
parents: 1189
diff changeset
   738
    "Modified: 18.4.1996 / 13:51:38 / cg"
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   739
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   740
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   741
whileFalse
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   742
    "evaluate the receiver while it evaluates to false (ST80 compatibility)"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   743
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   744
    "this implementation is for purists ... :-)"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   745
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   746
    self value ifTrue:[^ nil].
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   747
    thisContext restart
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   748
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   749
    "
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   750
     |n|
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   751
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   752
     n := 1.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   753
     [n printNewline. (n := n + 1) > 10] whileFalse
67
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   754
    "
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   755
!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   756
67
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   757
whileFalse:aBlock
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   758
    "evaluate the argument, aBlock while the receiver evaluates to false.
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   759
     - usually open coded by compilers, but needed here for #perform 
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   760
       and expression evaluation."
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   761
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   762
    "this implementation is for purists ... :-)"
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   763
67
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   764
    self value ifTrue:[^ nil].
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   765
    aBlock value.
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   766
    thisContext restart
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   767
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   768
    "
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   769
     |n|
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   770
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   771
     n := 1.
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   772
     [n > 10] whileFalse:[
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   773
	n printNewline.
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   774
	n := n + 1
67
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   775
     ]
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   776
    "
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   777
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   778
a27a279701f8 Initial revision
claus
parents:
diff changeset
   779
whileTrue
67
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   780
    "evaluate the receiver while it evaluates to true (ST80 compatibility)"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   781
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   782
    "this implementation is for purists ... :-)"
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   783
67
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   784
    self value ifFalse:[^ nil].
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   785
    thisContext restart
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   786
67
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   787
    "
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   788
     |n|
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   789
67
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   790
     n := 1.
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   791
     [n printNewline. (n := n + 1) <= 10] whileTrue
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   792
    "
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   793
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   794
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   795
whileTrue:aBlock
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   796
    "evaluate the argument, aBlock while the receiver evaluates to true.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   797
     - usually open coded by compilers, but needed here for #perform 
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   798
       and expression evaluation."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   799
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   800
    "this implementation is for purists ... :-)"
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   801
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   802
    self value ifFalse:[^ nil].
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   803
    aBlock value.
67
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   804
    thisContext restart
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   805
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   806
    "
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   807
     |n|
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   808
67
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   809
     n := 1.
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   810
     [n <= 10] whileTrue:[
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   811
	n printNewline.
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   812
	n := n + 1
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   813
     ]
68
59faa75185ba *** empty log message ***
claus
parents: 67
diff changeset
   814
    "
67
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   815
! !
e52341804063 *** empty log message ***
claus
parents: 54
diff changeset
   816
92
0c73b48551ac *** empty log message ***
claus
parents: 83
diff changeset
   817
!Block methodsFor:'printing & storing'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   818
a27a279701f8 Initial revision
claus
parents:
diff changeset
   819
printOn:aStream
44
b262907c93ea *** empty log message ***
claus
parents: 22
diff changeset
   820
    "append a a printed representation of the block to aStream"
b262907c93ea *** empty log message ***
claus
parents: 22
diff changeset
   821
213
3b56a17534fd *** empty log message ***
claus
parents: 212
diff changeset
   822
    |homeClass h sel methodClass|
54
06dbdeeed4f9 *** empty log message ***
claus
parents: 48
diff changeset
   823
06dbdeeed4f9 *** empty log message ***
claus
parents: 48
diff changeset
   824
    "cheap blocks have no home context, but a method instead"
06dbdeeed4f9 *** empty log message ***
claus
parents: 48
diff changeset
   825
06dbdeeed4f9 *** empty log message ***
claus
parents: 48
diff changeset
   826
    (home isNil or:[home isContext not]) ifTrue:[
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   827
	aStream nextPutAll:'[] in '.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   828
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   829
	"
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   830
	 currently, some cheap blocks don't know where they have been created
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   831
	"
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   832
	aStream nextPutAll:' ??? (optimized)'.
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   833
	^ self
54
06dbdeeed4f9 *** empty log message ***
claus
parents: 48
diff changeset
   834
    ].
06dbdeeed4f9 *** empty log message ***
claus
parents: 48
diff changeset
   835
06dbdeeed4f9 *** empty log message ***
claus
parents: 48
diff changeset
   836
    "a full blown block (with home, but without method)"
06dbdeeed4f9 *** empty log message ***
claus
parents: 48
diff changeset
   837
06dbdeeed4f9 *** empty log message ***
claus
parents: 48
diff changeset
   838
    aStream nextPutAll:'[] in '. 
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   839
    h := self methodHome.
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   840
    sel := h selector.
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   841
"/ old:
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   842
"/    home receiver class name printOn:aStream.
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   843
"/ new:
212
3edd10edefaf *** empty log message ***
claus
parents: 161
diff changeset
   844
"/    (h searchClass whichClassImplements:sel) name printOn:aStream.
213
3b56a17534fd *** empty log message ***
claus
parents: 212
diff changeset
   845
    methodClass := h methodClass.
3b56a17534fd *** empty log message ***
claus
parents: 212
diff changeset
   846
    methodClass isNil ifTrue:[
3b56a17534fd *** empty log message ***
claus
parents: 212
diff changeset
   847
	'UnboundMethod' printOn:aStream.
3b56a17534fd *** empty log message ***
claus
parents: 212
diff changeset
   848
    ] ifFalse:[
3b56a17534fd *** empty log message ***
claus
parents: 212
diff changeset
   849
	methodClass name printOn:aStream.
3b56a17534fd *** empty log message ***
claus
parents: 212
diff changeset
   850
    ].
54
06dbdeeed4f9 *** empty log message ***
claus
parents: 48
diff changeset
   851
    aStream nextPut:$-.
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   852
    sel printOn:aStream.
54
06dbdeeed4f9 *** empty log message ***
claus
parents: 48
diff changeset
   853
06dbdeeed4f9 *** empty log message ***
claus
parents: 48
diff changeset
   854
"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   855
    aStream nextPutAll:'[] in '.
a27a279701f8 Initial revision
claus
parents:
diff changeset
   856
    homeClass := home containingClass.
a27a279701f8 Initial revision
claus
parents:
diff changeset
   857
    homeClass notNil ifTrue:[
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   858
	homeClass name printOn:aStream.
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   859
	aStream space.
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   860
	(homeClass selectorForMethod:home) printOn:aStream
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   861
    ] ifFalse:[
154
d4236ec280a6 *** empty log message ***
claus
parents: 138
diff changeset
   862
	aStream nextPutAll:' ???' 
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   863
    ]
54
06dbdeeed4f9 *** empty log message ***
claus
parents: 48
diff changeset
   864
"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   865
! !
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   866
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   867
!Block methodsFor:'private accessing'!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   868
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   869
code:codeAddress byteCode:bCode numArgs:numArgs sourcePosition:srcPos initialPC:iPC literals:lits dynamic:dynamic
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   870
    "set all relevant internals"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   871
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   872
    self code:codeAddress.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   873
    byteCode := bCode.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   874
    nargs := numArgs.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   875
    sourcePos := srcPos.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   876
    initialPC := iPC.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   877
    literals := lits.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   878
    self dynamic:dynamic
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   879
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   880
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   881
initialPC:initial 
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   882
    "set the initial pc for evaluation - DANGER ALERT"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   883
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   884
    initialPC := initial
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   885
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   886
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   887
numArgs:numArgs
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   888
    "set the number of arguments I expect for evaluation - DANGER ALERT"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   889
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   890
    nargs := numArgs
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   891
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   892
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   893
sourcePosition:position 
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   894
    "set the position of the source within my method"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   895
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   896
    sourcePos := position
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   897
! !
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   898
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   899
!Block methodsFor:'privileged evaluation'!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   900
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   901
valueUninterruptably
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   902
    "evaluate the receiver with interrupts blocked.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   903
     This does not prevent preemption by a higher priority processes
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   904
     if any becomes runnable due to the evaluation of the receiver
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   905
     (i.e. if a semaphore is signalled)."
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   906
864
9d034b442868 faster uninterruptablyDo:
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   907
    |wasBlocked|
9d034b442868 faster uninterruptablyDo:
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   908
9d034b442868 faster uninterruptablyDo:
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   909
    wasBlocked := OperatingSystem blockInterrupts.
1041
12e2524284e2 oops - unterrupts remained blocked sometimes
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   910
    ^ self valueNowOrOnUnwindDo:[wasBlocked ifFalse:[OperatingSystem unblockInterrupts]].
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   911
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   912
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   913
valueUnpreemptively
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   914
    "evaluate the receiver without the possiblity of preemption
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   915
     (i.e. at a very high priority)"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   916
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   917
    |oldPrio activeProcess|
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   918
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   919
    activeProcess := Processor activeProcess.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   920
    oldPrio := activeProcess changePriority:(Processor highestPriority).
864
9d034b442868 faster uninterruptablyDo:
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
   921
    ^ self valueNowOrOnUnwindDo:[
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   922
	activeProcess priority:oldPrio
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   923
    ]
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   924
! !
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   925
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   926
!Block methodsFor:'process creation'!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   927
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   928
fork
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   929
    "create a new process executing the receiver at the current priority."
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   930
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   931
    ^ self newProcess resume
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   932
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   933
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   934
forkAt:priority
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   935
    "create a new process executing the receiver at a different priority."
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   936
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   937
    ^ (self newProcess priority:priority) resume
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   938
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   939
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   940
forkWith:argArray
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   941
    "create a new process executing the receiver,
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   942
     passing elements in argArray as arguments to the receiver block."
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   943
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   944
    ^ [self valueWithArguments:argArray] fork.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   945
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   946
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   947
newProcess
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   948
    "create a new (unscheduled) process executing the receiver"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   949
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   950
    ^ Process for:self priority:(Processor activePriority)
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   951
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   952
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   953
newProcessWithArguments:argArray
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   954
    "create a new (unscheduled) process executing the receiver,
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   955
     passing the elements in argArray as arguments to the receiver block."
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   956
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   957
    ^ [self valueWithArguments:argArray] newProcess
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   958
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   959
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   960
promise
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   961
    "create a promise on the receiver. The promise will evaluate the
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   962
     receiver and promise to return the value with the #value message.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   963
     The evaluation will be performed as a separate process.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   964
     Asking the promise for its value will either block the asking process
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   965
     (if the evaluation has not yet been finished) or return the value
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   966
     immediately."
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   967
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   968
    ^ Promise value:self
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   969
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   970
    "
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   971
     |p|
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   972
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   973
     p := [1000 factorial] promise.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   974
     'do something else ...'.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   975
     p value
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   976
    "
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   977
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   978
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   979
promiseAt:prio
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   980
    "create a promise on the receiver. The promise will evaluate the
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   981
     receiver and promise to return the value with the #value message.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   982
     The evaluation will be performed as a separate process running at prio.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   983
     Asking the promise for its value will either block the asking process
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   984
     (if the evaluation has not yet been finished) or return the value
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   985
     immediately."
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   986
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   987
    ^ Promise value:self priority:prio
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   988
! !
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   989
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   990
!Block methodsFor:'testing'!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   991
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   992
isBlock
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   993
    "return true, if this is a block - yes I am"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   994
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   995
    ^ true
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   996
! !
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   997
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   998
!Block methodsFor:'unwinding'!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   999
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1000
valueNowOrOnUnwindDo:aBlock
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1001
    "evaluate the receiver - after that, or when some method sent within unwinds (i.e. does
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1002
     a long return), evaluate the argument, aBlock.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1003
     This is used to make certain that cleanup actions (for example closing files etc.) are
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1004
     executed regardless of error actions"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1005
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1006
    |v|
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1007
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1008
    thisContext markForUnwind.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1009
    v := self value.       "the real logic is in Context>>unwind"
1187
619ff79bc665 valueNowOrOnUnwindDo: don't execute unwind block when block is currently executed 'now'.
Stefan Vogel <sv@exept.de>
parents: 1181
diff changeset
  1010
    thisContext unmarkForUnwind.
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1011
    aBlock value.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1012
    ^ v
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1013
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1014
    "
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1015
     in the following example, f will be closed even if the block
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1016
     returns with 'oops'. There are many more applications of this kind
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1017
     found in the system.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1018
    "
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1019
    "
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1020
     |f|
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1021
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1022
     f := 'Makefile' asFilename readStream.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1023
     [
1187
619ff79bc665 valueNowOrOnUnwindDo: don't execute unwind block when block is currently executed 'now'.
Stefan Vogel <sv@exept.de>
parents: 1181
diff changeset
  1024
        l := f nextLine.
619ff79bc665 valueNowOrOnUnwindDo: don't execute unwind block when block is currently executed 'now'.
Stefan Vogel <sv@exept.de>
parents: 1181
diff changeset
  1025
        l isNil ifTrue:[^ 'oops']
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1026
     ] valueNowOrOnUnwindDo:[
1187
619ff79bc665 valueNowOrOnUnwindDo: don't execute unwind block when block is currently executed 'now'.
Stefan Vogel <sv@exept.de>
parents: 1181
diff changeset
  1027
        f close
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1028
     ]
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1029
    "
1187
619ff79bc665 valueNowOrOnUnwindDo: don't execute unwind block when block is currently executed 'now'.
Stefan Vogel <sv@exept.de>
parents: 1181
diff changeset
  1030
619ff79bc665 valueNowOrOnUnwindDo: don't execute unwind block when block is currently executed 'now'.
Stefan Vogel <sv@exept.de>
parents: 1181
diff changeset
  1031
    "Modified: 16.4.1996 / 11:05:26 / stefan"
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1032
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1033
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1034
valueOnUnwindDo:aBlock
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1035
    "evaluate the receiver - when some method sent within unwinds (i.e. does
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1036
     a long return), evaluate the argument, aBlock.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1037
     This is used to make certain that cleanup actions (for example closing files etc.) are
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1038
     executed regardless of error actions"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1039
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1040
    thisContext markForUnwind.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1041
    ^ self value        "the real logic is in Context>>unwind"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1042
! !
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1043
1181
6637fee79d7b only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
  1044
!Block class methodsFor:'documentation'!
6637fee79d7b only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
  1045
6637fee79d7b only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
  1046
version
1211
c5bdb3fc3cb4 commentary
Claus Gittinger <cg@exept.de>
parents: 1189
diff changeset
  1047
    ^ '$Header: /cvs/stx/stx/libbasic/Block.st,v 1.51 1996-04-18 12:17:36 cg Exp $'
1181
6637fee79d7b only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
  1048
! !
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1049
Block initialize!