--- a/Block.st Mon Dec 21 15:02:12 2015 +0100
+++ b/Block.st Tue Dec 22 00:56:34 2015 +0100
@@ -1543,24 +1543,26 @@
"Created: / 29.7.1998 / 19:19:48 / cg"
!
-valueWithArguments:argArray
+valueWithArguments:argArrayIn
"evaluate the receiver with arguments taken from argArray.
ArgArray must be either an Array or nil.
The size of the argArray must match the number of arguments the receiver expects."
- |a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15|
-
+ |argArray a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15|
+
+ argArray := argArrayIn.
(argArray notNil and:[(argArray class ~~ Array) and:[argArray isArray not]]) ifTrue:[
- argArray isCollection ifTrue:[
- ^ self valueWithArguments:argArray asArray
- ].
- ^ self badArgumentArray:argArray
+ argArray isCollection ifTrue:[
+ argArray := argArray asArray
+ ] ifFalse:[
+ ^ self badArgumentArray:argArray
+ ].
].
- (argArray size == nargs) ifFalse:[
- ^ self wrongNumberOfArguments:argArray size
+ (argArray size ~~ nargs) ifTrue:[
+ ^ self wrongNumberOfArguments:argArray size
].
+
%{
-
REGISTER OBJFUNC thecode;
OBJ home;
REGISTER OBJ *ap;
@@ -1568,7 +1570,7 @@
#if defined(THIS_CONTEXT)
if (__ISVALID_ILC_LNO(__pilc))
- __ContextInstPtr(__thisContext)->c_lineno = __ILC_LNO_AS_OBJ(__pilc);
+ __ContextInstPtr(__thisContext)->c_lineno = __ILC_LNO_AS_OBJ(__pilc);
#endif
thecode = __BlockInstPtr(self)->b_code;
@@ -1577,96 +1579,96 @@
#ifndef NEW_BLOCK_CALL
home = __BlockInstPtr(self)->b_home;
if (thecode != (OBJFUNC)nil) {
- /* the most common case (0 args) here (without a switch) */
-
- if (nA == __mkSmallInteger(0)) {
- RETURN ( (*thecode)(home) );
- }
-
- ap = __arrayVal(argArray); /* nonNil after above test (size is known to be ok) */
- switch ((INT)(nA)) {
- default:
- goto error;
- case (INT)__mkSmallInteger(15):
- RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8], ap[9], ap[10], ap[11], ap[12], ap[13], ap[14]) );
- case (INT)__mkSmallInteger(14):
- RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8], ap[9], ap[10], ap[11], ap[12], ap[13]) );
- case (INT)__mkSmallInteger(13):
- RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8], ap[9], ap[10], ap[11], ap[12]) );
- case (INT)__mkSmallInteger(12):
- RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8], ap[9], ap[10], ap[11]) );
- case (INT)__mkSmallInteger(11):
- RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8], ap[9], ap[10]) );
- case (INT)__mkSmallInteger(10):
- RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8], ap[9]) );
- case (INT)__mkSmallInteger(9):
- RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8]) );
- case (INT)__mkSmallInteger(8):
- RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7]) );
- case (INT)__mkSmallInteger(7):
- RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6]) );
- case (INT)__mkSmallInteger(6):
- RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5]) );
- case (INT)__mkSmallInteger(5):
- RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4]) );
- case (INT)__mkSmallInteger(4):
- RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3]) );
- case (INT)__mkSmallInteger(3):
- RETURN ( (*thecode)(home, ap[0], ap[1], ap[2]) );
- case (INT)__mkSmallInteger(2):
- RETURN ( (*thecode)(home, ap[0], ap[1]) );
- case (INT)__mkSmallInteger(1):
- RETURN ( (*thecode)(home, ap[0]) );
- case (INT)__mkSmallInteger(0):
- RETURN ( (*thecode)(home) );
- break;
- }
+ /* the most common case (0 args) here (without a switch) */
+
+ if (nA == __mkSmallInteger(0)) {
+ RETURN ( (*thecode)(home) );
+ }
+
+ ap = __arrayVal(argArray); /* nonNil after above test (size is known to be ok) */
+ switch ((INT)(nA)) {
+ default:
+ goto error;
+ case (INT)__mkSmallInteger(15):
+ RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8], ap[9], ap[10], ap[11], ap[12], ap[13], ap[14]) );
+ case (INT)__mkSmallInteger(14):
+ RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8], ap[9], ap[10], ap[11], ap[12], ap[13]) );
+ case (INT)__mkSmallInteger(13):
+ RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8], ap[9], ap[10], ap[11], ap[12]) );
+ case (INT)__mkSmallInteger(12):
+ RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8], ap[9], ap[10], ap[11]) );
+ case (INT)__mkSmallInteger(11):
+ RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8], ap[9], ap[10]) );
+ case (INT)__mkSmallInteger(10):
+ RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8], ap[9]) );
+ case (INT)__mkSmallInteger(9):
+ RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8]) );
+ case (INT)__mkSmallInteger(8):
+ RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7]) );
+ case (INT)__mkSmallInteger(7):
+ RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6]) );
+ case (INT)__mkSmallInteger(6):
+ RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5]) );
+ case (INT)__mkSmallInteger(5):
+ RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4]) );
+ case (INT)__mkSmallInteger(4):
+ RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3]) );
+ case (INT)__mkSmallInteger(3):
+ RETURN ( (*thecode)(home, ap[0], ap[1], ap[2]) );
+ case (INT)__mkSmallInteger(2):
+ RETURN ( (*thecode)(home, ap[0], ap[1]) );
+ case (INT)__mkSmallInteger(1):
+ RETURN ( (*thecode)(home, ap[0]) );
+ case (INT)__mkSmallInteger(0):
+ RETURN ( (*thecode)(home) );
+ break;
+ }
}
#endif
if (nA != __mkSmallInteger(0)) {
- ap = __arrayVal(argArray); /* nonNil after above test (size is known to be ok) */
- switch ((INT)nA) {
- default:
- goto error;
- case (INT)__mkSmallInteger(15):
- a15 = ap[14];
- case (INT)__mkSmallInteger(14):
- a14 = ap[13];
- case (INT)__mkSmallInteger(13):
- a13 = ap[12];
- case (INT)__mkSmallInteger(12):
- a12 = ap[11];
- case (INT)__mkSmallInteger(11):
- a11 = ap[10];
- case (INT)__mkSmallInteger(10):
- a10 = ap[9];
- case (INT)__mkSmallInteger(9):
- a9 = ap[8];
- case (INT)__mkSmallInteger(8):
- a8 = ap[7];
- case (INT)__mkSmallInteger(7):
- a7 = ap[6];
- case (INT)__mkSmallInteger(6):
- a6 = ap[5];
- case (INT)__mkSmallInteger(5):
- a5 = ap[4];
- case (INT)__mkSmallInteger(4):
- a4 = ap[3];
- case (INT)__mkSmallInteger(3):
- a3 = ap[2];
- case (INT)__mkSmallInteger(2):
- a2 = ap[1];
- case (INT)__mkSmallInteger(1):
- a1 = ap[0];
- case (INT)__mkSmallInteger(0):
- break;
- }
+ ap = __arrayVal(argArray); /* nonNil after above test (size is known to be ok) */
+ switch ((INT)nA) {
+ default:
+ goto error;
+ case (INT)__mkSmallInteger(15):
+ a15 = ap[14];
+ case (INT)__mkSmallInteger(14):
+ a14 = ap[13];
+ case (INT)__mkSmallInteger(13):
+ a13 = ap[12];
+ case (INT)__mkSmallInteger(12):
+ a12 = ap[11];
+ case (INT)__mkSmallInteger(11):
+ a11 = ap[10];
+ case (INT)__mkSmallInteger(10):
+ a10 = ap[9];
+ case (INT)__mkSmallInteger(9):
+ a9 = ap[8];
+ case (INT)__mkSmallInteger(8):
+ a8 = ap[7];
+ case (INT)__mkSmallInteger(7):
+ a7 = ap[6];
+ case (INT)__mkSmallInteger(6):
+ a6 = ap[5];
+ case (INT)__mkSmallInteger(5):
+ a5 = ap[4];
+ case (INT)__mkSmallInteger(4):
+ a4 = ap[3];
+ case (INT)__mkSmallInteger(3):
+ a3 = ap[2];
+ case (INT)__mkSmallInteger(2):
+ a2 = ap[1];
+ case (INT)__mkSmallInteger(1):
+ a1 = ap[0];
+ case (INT)__mkSmallInteger(0):
+ break;
+ }
}
#ifdef NEW_BLOCK_CALL
if (thecode != (OBJFUNC)nil) {
- RETURN ( (*thecode)(self, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) );
+ RETURN ( (*thecode)(self, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) );
}
# ifdef PASS_ARG_POINTER
RETURN ( __interpret(self, __intVal(nA), nil, nil, nil, nil, &a1) );
@@ -1690,8 +1692,13 @@
the above code only supports up-to 15 arguments
"
^ ArgumentError
- raiseRequestWith:self
- errorString:'only blocks with up-to 15 arguments supported'
+ raiseRequestWith:self
+ errorString:'only blocks with up-to 15 arguments supported'
+
+ "
+ [:a :b :c | Transcript showCR:a; showCR:b; showCR:c] valueWithArguments:#(1 2 3).
+ [:a :b :c | Transcript showCR:a; showCR:b; showCR:c] valueWithArguments:#(1 2 3) asOrderedCollection.
+ "
!
valueWithOptionalArgument:arg