Block.st
changeset 2841 d3cab7c7d334
parent 2828 1a9cee4de6a6
child 3349 84a92126a268
equal deleted inserted replaced
2840:493b24293589 2841:d3cab7c7d334
   879      ArgArray must be either an Array or nil.
   879      ArgArray must be either an Array or nil.
   880      The size of the argArray must match the number of arguments the receiver expects."
   880      The size of the argArray must match the number of arguments the receiver expects."
   881 
   881 
   882     |a1 a2 a3 a4 a5 a6 a7 a8|
   882     |a1 a2 a3 a4 a5 a6 a7 a8|
   883 
   883 
   884     (argArray notNil and:[argArray class ~~ Array]) ifTrue:[
   884     (argArray notNil and:[(argArray class ~~ Array) and:[argArray isArray not]]) ifTrue:[
   885 	^ self badArgumentArry
   885 	^ self badArgumentArry
   886     ].
   886     ].
   887     (argArray size == nargs) ifFalse:[
   887     (argArray size == nargs) ifFalse:[
   888 	^ self wrongNumberOfArguments:(argArray size)
   888 	^ self wrongNumberOfArguments:(argArray size)
   889     ].
   889     ].
   890 %{
   890 %{
   891 
   891 
   892     REGISTER OBJFUNC thecode;
   892     REGISTER OBJFUNC thecode;
   893     OBJ home;
   893     OBJ home;
   894     REGISTER OBJ *ap;
   894     REGISTER OBJ *ap;
   895     int nargs;
   895     int __nargs;
       
   896     OBJ nA;
   896 
   897 
   897 #if defined(THIS_CONTEXT)
   898 #if defined(THIS_CONTEXT)
   898     if (__ISVALID_ILC_LNO(__pilc))
   899     if (__ISVALID_ILC_LNO(__pilc))
   899 	    __ContextInstPtr(__thisContext)->c_lineno = __ILC_LNO_AS_OBJ(__pilc);
   900 	    __ContextInstPtr(__thisContext)->c_lineno = __ILC_LNO_AS_OBJ(__pilc);
   900 #endif
   901 #endif
   901     thecode = __BlockInstPtr(self)->b_code;
   902     thecode = __BlockInstPtr(self)->b_code;
   902 
   903 
   903 #ifndef NEW_BLOCK_CALL
   904 #ifndef NEW_BLOCK_CALL
   904     home = __BlockInstPtr(self)->b_home;
   905     home = __BlockInstPtr(self)->b_home;
   905     if (thecode != (OBJFUNC)nil) {
   906     if (thecode != (OBJFUNC)nil) {
   906 	switch (nargs = __intVal(__INST(nargs))) {
   907 	if ((nA = __INST(nargs)) == __MKSMALLINT(0)) {
       
   908 	    RETURN ( (*thecode)(home) );
       
   909 	}
       
   910 
       
   911 	switch (__intVal(__INST(nargs))) {
   907 	    default:
   912 	    default:
   908 		goto error;
   913 		goto error;
   909 	    case 8:
   914 	    case 8:
   910 		ap = __ArrayInstPtr(argArray)->a_element;
   915 		ap = __ArrayInstPtr(argArray)->a_element;
   911 		RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7]) );
   916 		RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7]) );
   934 		break;
   939 		break;
   935 	}
   940 	}
   936     }
   941     }
   937 #endif
   942 #endif
   938 
   943 
   939     switch (nargs = __intVal(__INST(nargs))) {
   944     __nargs = __intVal(__INST(nargs));
   940 	default:
   945     if (__nargs) {
   941 	    goto error;
   946         switch (__nargs) {
   942 	case 8:
   947 	    default:
   943 	    a8 = __ArrayInstPtr(argArray)->a_element[7];
   948 	        goto error;
   944 	case 7:
   949 	    case 8:
   945 	    a7 = __ArrayInstPtr(argArray)->a_element[6];
   950 	        a8 = __ArrayInstPtr(argArray)->a_element[7];
   946 	case 6:
   951 	    case 7:
   947 	    a6 = __ArrayInstPtr(argArray)->a_element[5];
   952 	        a7 = __ArrayInstPtr(argArray)->a_element[6];
   948 	case 5:
   953 	    case 6:
   949 	    a5 = __ArrayInstPtr(argArray)->a_element[4];
   954 	        a6 = __ArrayInstPtr(argArray)->a_element[5];
   950 	case 4:
   955 	    case 5:
   951 	    a4 = __ArrayInstPtr(argArray)->a_element[3];
   956 	        a5 = __ArrayInstPtr(argArray)->a_element[4];
   952 	case 3:
   957 	    case 4:
   953 	    a3 = __ArrayInstPtr(argArray)->a_element[2];
   958 	        a4 = __ArrayInstPtr(argArray)->a_element[3];
   954 	case 2:
   959 	    case 3:
   955 	    a2 = __ArrayInstPtr(argArray)->a_element[1];
   960 	        a3 = __ArrayInstPtr(argArray)->a_element[2];
   956 	case 1:
   961 	    case 2:
   957 	    a1 = __ArrayInstPtr(argArray)->a_element[0];
   962 	        a2 = __ArrayInstPtr(argArray)->a_element[1];
   958 	case 0:
   963 	    case 1:
   959 	    break;
   964 	        a1 = __ArrayInstPtr(argArray)->a_element[0];
       
   965 	    case 0:
       
   966 	        break;
       
   967 	}
   960     }
   968     }
   961 
   969 
   962 #ifdef NEW_BLOCK_CALL
   970 #ifdef NEW_BLOCK_CALL
   963     if (thecode != (OBJFUNC)nil) {
   971     if (thecode != (OBJFUNC)nil) {
   964 	RETURN ( (*thecode)(self, a1, a2, a3, a4, a5, a6, a7, a8) );
   972 	RETURN ( (*thecode)(self, a1, a2, a3, a4, a5, a6, a7, a8) );
   965     }
   973     }
   966 # ifdef PASS_ARG_POINTER
   974 # ifdef PASS_ARG_POINTER
   967     RETURN ( __interpret(self, nargs, nil, nil, nil, nil, &a1) );
   975     RETURN ( __interpret(self, __nargs, nil, nil, nil, nil, &a1) );
   968 # else
   976 # else
   969     RETURN ( __interpret(self, nargs, nil, nil, nil, nil, a1, a2, a3, a4, a5, a6, a7, a8) );
   977     RETURN ( __interpret(self, __nargs, nil, nil, nil, nil, a1, a2, a3, a4, a5, a6, a7, a8) );
   970 # endif
   978 # endif
   971 
   979 
   972 #else
   980 #else
   973 
   981 
   974 # ifdef PASS_ARG_POINTER
   982 # ifdef PASS_ARG_POINTER
   975     RETURN ( __interpret(self, nargs, nil, home, nil, nil, &a1) );
   983     RETURN ( __interpret(self, __nargs, nil, home, nil, nil, &a1) );
   976 # else
   984 # else
   977     RETURN ( __interpret(self, nargs, nil, home, nil, nil, a1, a2, a3, a4, a5, a6, a7, a8) );
   985     RETURN ( __interpret(self, __nargs, nil, home, nil, nil, a1, a2, a3, a4, a5, a6, a7, a8) );
   978 # endif
   986 # endif
   979 
   987 
   980 #endif
   988 #endif
   981 
   989 
   982 error: ;
   990 error: ;
   983 %}
   991 %}.
   984 .
       
   985     "
   992     "
   986      the above code only supports up-to 7 arguments
   993      the above code only supports up-to 7 arguments
   987     "
   994     "
   988     ^ ArgumentSignal
   995     ^ ArgumentSignal
   989 	raiseRequestWith:self
   996 	raiseRequestWith:self
  1215 	methodClass name printOn:aStream.
  1222 	methodClass name printOn:aStream.
  1216     ].
  1223     ].
  1217     aStream nextPut:$-.
  1224     aStream nextPut:$-.
  1218     sel printOn:aStream.
  1225     sel printOn:aStream.
  1219 
  1226 
  1220 "
  1227 "/
  1221     aStream nextPutAll:'[] in '.
  1228 "/    aStream nextPutAll:'[] in '.
  1222     homeClass := home containingClass.
  1229 "/    homeClass := home containingClass.
  1223     homeClass notNil ifTrue:[
  1230 "/    homeClass notNil ifTrue:[
  1224 	homeClass name printOn:aStream.
  1231 "/	homeClass name printOn:aStream.
  1225 	aStream space.
  1232 "/	aStream space.
  1226 	(homeClass selectorForMethod:home) printOn:aStream
  1233 "/	(homeClass selectorForMethod:home) printOn:aStream
  1227     ] ifFalse:[
  1234 "/    ] ifFalse:[
  1228 	aStream nextPutAll:' ???' 
  1235 "/	aStream nextPutAll:' ???' 
  1229     ]
  1236 "/    ]
  1230 "
  1237 "/
       
  1238 
  1231 ! !
  1239 ! !
  1232 
  1240 
  1233 !Block methodsFor:'private accessing'!
  1241 !Block methodsFor:'private accessing'!
  1234 
  1242 
  1235 byteCode:bCode numArgs:numArgs numStack:numStack sourcePosition:srcPos initialPC:iPC literals:lits
  1243 byteCode:bCode numArgs:numArgs numStack:numStack sourcePosition:srcPos initialPC:iPC literals:lits
  1439 ! !
  1447 ! !
  1440 
  1448 
  1441 !Block class methodsFor:'documentation'!
  1449 !Block class methodsFor:'documentation'!
  1442 
  1450 
  1443 version
  1451 version
  1444     ^ '$Header: /cvs/stx/stx/libbasic/Block.st,v 1.76 1997-07-31 22:32:08 cg Exp $'
  1452     ^ '$Header: /cvs/stx/stx/libbasic/Block.st,v 1.77 1997-08-07 15:33:00 cg Exp $'
  1445 ! !
  1453 ! !
  1446 Block initialize!
  1454 Block initialize!