Block.st
changeset 1037 4488f834cb6b
parent 864 9d034b442868
child 1041 12e2524284e2
equal deleted inserted replaced
1036:d79dc9e4c6f5 1037:4488f834cb6b
    79     NOTICE: layout known by runtime system and compiler - do not change
    79     NOTICE: layout known by runtime system and compiler - do not change
    80 "
    80 "
    81 !
    81 !
    82 
    82 
    83 version
    83 version
    84     ^ '$Header: /cvs/stx/stx/libbasic/Block.st,v 1.44 1996-01-15 21:43:12 cg Exp $'
    84     ^ '$Header: /cvs/stx/stx/libbasic/Block.st,v 1.45 1996-02-28 23:25:38 cg Exp $'
    85 ! !
    85 ! !
    86 
    86 
    87 !Block class methodsFor:'initialization'!
    87 !Block class methodsFor:'initialization'!
    88 
    88 
    89 initialize
    89 initialize
   245 	}
   245 	}
   246 	/* interpreted code */
   246 	/* interpreted code */
   247 # ifdef PASS_ARG_POINTER
   247 # ifdef PASS_ARG_POINTER
   248 	RETURN ( __interpret(self, 0, nil, nil COMMA_SND, nil) );
   248 	RETURN ( __interpret(self, 0, nil, nil COMMA_SND, nil) );
   249 # else
   249 # else
   250 	RETURN ( interpret(self, 0, nil, nil COMMA_SND, nil) );
   250 	RETURN ( __interpret(self, 0, nil, nil COMMA_SND, nil) );
   251 # endif
   251 # endif
   252 #else
   252 #else
   253 	home = _BlockInstPtr(self)->b_home;
   253 	home = _BlockInstPtr(self)->b_home;
   254 	if (thecode != (OBJFUNC)nil) {
   254 	if (thecode != (OBJFUNC)nil) {
   255 	    /* compiled machine code */
   255 	    /* compiled machine code */
   257 	}
   257 	}
   258 	/* interpreted code */
   258 	/* interpreted code */
   259 # ifdef PASS_ARG_POINTER
   259 # ifdef PASS_ARG_POINTER
   260 	RETURN ( __interpret(self, 0, nil, home COMMA_SND, nil) );
   260 	RETURN ( __interpret(self, 0, nil, home COMMA_SND, nil) );
   261 # else
   261 # else
   262 	RETURN ( interpret(self, 0, nil, home COMMA_SND, nil) );
   262 	RETURN ( __interpret(self, 0, nil, home COMMA_SND, nil) );
   263 # endif
   263 # endif
   264 #endif
   264 #endif
   265     }
   265     }
   266 %}
   266 %}
   267 .
   267 .
   288 	}
   288 	}
   289 	/* interpreted code */
   289 	/* interpreted code */
   290 # ifdef PASS_ARG_POINTER
   290 # ifdef PASS_ARG_POINTER
   291 	RETURN ( __interpret(self, 1, nil, nil COMMA_SND, nil, &arg) );
   291 	RETURN ( __interpret(self, 1, nil, nil COMMA_SND, nil, &arg) );
   292 # else
   292 # else
   293 	RETURN ( interpret(self, 1, nil, nil COMMA_SND, nil, arg) );
   293 	RETURN ( __interpret(self, 1, nil, nil COMMA_SND, nil, arg) );
   294 # endif
   294 # endif
   295 #else
   295 #else
   296 	home = _BlockInstPtr(self)->b_home;
   296 	home = _BlockInstPtr(self)->b_home;
   297 	if (thecode != (OBJFUNC)nil) {
   297 	if (thecode != (OBJFUNC)nil) {
   298 	    RETURN ( (*thecode)(home COMMA_SND, arg) );
   298 	    RETURN ( (*thecode)(home COMMA_SND, arg) );
   299 	}
   299 	}
   300 	/* interpreted code */
   300 	/* interpreted code */
   301 # ifdef PASS_ARG_POINTER
   301 # ifdef PASS_ARG_POINTER
   302 	RETURN ( __interpret(self, 1, nil, home COMMA_SND, nil, &arg) );
   302 	RETURN ( __interpret(self, 1, nil, home COMMA_SND, nil, &arg) );
   303 # else
   303 # else
   304 	RETURN ( interpret(self, 1, nil, home COMMA_SND, nil, arg) );
   304 	RETURN ( __interpret(self, 1, nil, home COMMA_SND, nil, arg) );
   305 # endif
   305 # endif
   306 #endif
   306 #endif
   307     }
   307     }
   308 %}
   308 %}
   309 .
   309 .
   329 	    RETURN ( (*thecode)(self COMMA_SND, arg1, arg2) );
   329 	    RETURN ( (*thecode)(self COMMA_SND, arg1, arg2) );
   330 	}
   330 	}
   331 # ifdef PASS_ARG_POINTER
   331 # ifdef PASS_ARG_POINTER
   332 	RETURN ( __interpret(self, 2, nil, nil COMMA_SND, nil, &arg1) );
   332 	RETURN ( __interpret(self, 2, nil, nil COMMA_SND, nil, &arg1) );
   333 # else
   333 # else
   334 	RETURN ( interpret(self, 2, nil, nil COMMA_SND, nil, arg1, arg2) );
   334 	RETURN ( __interpret(self, 2, nil, nil COMMA_SND, nil, arg1, arg2) );
   335 # endif
   335 # endif
   336 #else
   336 #else
   337 	home = _BlockInstPtr(self)->b_home;
   337 	home = _BlockInstPtr(self)->b_home;
   338 	if (thecode != (OBJFUNC)nil) {
   338 	if (thecode != (OBJFUNC)nil) {
   339 	    RETURN ( (*thecode)(home COMMA_SND, arg1, arg2) );
   339 	    RETURN ( (*thecode)(home COMMA_SND, arg1, arg2) );
   340 	}
   340 	}
   341 # ifdef PASS_ARG_POINTER
   341 # ifdef PASS_ARG_POINTER
   342 	RETURN ( __interpret(self, 2, nil, home COMMA_SND, nil, &arg1) );
   342 	RETURN ( __interpret(self, 2, nil, home COMMA_SND, nil, &arg1) );
   343 # else
   343 # else
   344 	RETURN ( interpret(self, 2, nil, home COMMA_SND, nil, arg1, arg2) );
   344 	RETURN ( __interpret(self, 2, nil, home COMMA_SND, nil, arg1, arg2) );
   345 # endif
   345 # endif
   346 #endif
   346 #endif
   347     }
   347     }
   348 %}
   348 %}
   349 .
   349 .
   369 	    RETURN ( (*thecode)(self COMMA_SND, arg1, arg2, arg3) );
   369 	    RETURN ( (*thecode)(self COMMA_SND, arg1, arg2, arg3) );
   370 	}
   370 	}
   371 # ifdef PASS_ARG_POINTER
   371 # ifdef PASS_ARG_POINTER
   372 	RETURN ( __interpret(self, 3, nil, nil COMMA_SND, nil, &arg1) );
   372 	RETURN ( __interpret(self, 3, nil, nil COMMA_SND, nil, &arg1) );
   373 # else
   373 # else
   374 	RETURN ( interpret(self, 3, nil, nil COMMA_SND, nil, arg1, arg2, arg3) );
   374 	RETURN ( __interpret(self, 3, nil, nil COMMA_SND, nil, arg1, arg2, arg3) );
   375 # endif
   375 # endif
   376 #else
   376 #else
   377 	home = _BlockInstPtr(self)->b_home;
   377 	home = _BlockInstPtr(self)->b_home;
   378 	if (thecode != (OBJFUNC)nil) {
   378 	if (thecode != (OBJFUNC)nil) {
   379 	    RETURN ( (*thecode)(home COMMA_SND, arg1, arg2, arg3) );
   379 	    RETURN ( (*thecode)(home COMMA_SND, arg1, arg2, arg3) );
   380 	}
   380 	}
   381 # ifdef PASS_ARG_POINTER
   381 # ifdef PASS_ARG_POINTER
   382 	RETURN ( __interpret(self, 3, nil, home COMMA_SND, nil, &arg1) );
   382 	RETURN ( __interpret(self, 3, nil, home COMMA_SND, nil, &arg1) );
   383 # else
   383 # else
   384 	RETURN ( interpret(self, 3, nil, home COMMA_SND, nil, arg1, arg2, arg3) );
   384 	RETURN ( __interpret(self, 3, nil, home COMMA_SND, nil, arg1, arg2, arg3) );
   385 # endif
   385 # endif
   386 #endif
   386 #endif
   387     }
   387     }
   388 %}
   388 %}
   389 .
   389 .
   409 	    RETURN ( (*thecode)(self COMMA_SND, arg1, arg2, arg3, arg4) );
   409 	    RETURN ( (*thecode)(self COMMA_SND, arg1, arg2, arg3, arg4) );
   410 	}
   410 	}
   411 # ifdef PASS_ARG_POINTER
   411 # ifdef PASS_ARG_POINTER
   412 	RETURN ( __interpret(self, 4, nil, nil COMMA_SND, nil, &arg1) );
   412 	RETURN ( __interpret(self, 4, nil, nil COMMA_SND, nil, &arg1) );
   413 # else
   413 # else
   414 	RETURN ( interpret(self, 4, nil, nil COMMA_SND, nil, arg1, arg2, arg3, arg4) );
   414 	RETURN ( __interpret(self, 4, nil, nil COMMA_SND, nil, arg1, arg2, arg3, arg4) );
   415 # endif
   415 # endif
   416 #else
   416 #else
   417 	home = _BlockInstPtr(self)->b_home;
   417 	home = _BlockInstPtr(self)->b_home;
   418 	if (thecode != (OBJFUNC)nil) {
   418 	if (thecode != (OBJFUNC)nil) {
   419 	    RETURN ( (*thecode)(home COMMA_SND, arg1, arg2, arg3, arg4) );
   419 	    RETURN ( (*thecode)(home COMMA_SND, arg1, arg2, arg3, arg4) );
   420 	}
   420 	}
   421 # ifdef PASS_ARG_POINTER
   421 # ifdef PASS_ARG_POINTER
   422 	RETURN ( __interpret(self, 4, nil, home COMMA_SND, nil, &arg1) );
   422 	RETURN ( __interpret(self, 4, nil, home COMMA_SND, nil, &arg1) );
   423 # else
   423 # else
   424 	RETURN ( interpret(self, 4, nil, home COMMA_SND, nil, arg1, arg2, arg3, arg4) );
   424 	RETURN ( __interpret(self, 4, nil, home COMMA_SND, nil, arg1, arg2, arg3, arg4) );
   425 # endif
   425 # endif
   426 #endif
   426 #endif
   427     }
   427     }
   428 %}
   428 %}
   429 .
   429 .
   449 	    RETURN ( (*thecode)(self COMMA_SND, arg1, arg2, arg3, arg4, arg5) );
   449 	    RETURN ( (*thecode)(self COMMA_SND, arg1, arg2, arg3, arg4, arg5) );
   450 	}
   450 	}
   451 # ifdef PASS_ARG_POINTER
   451 # ifdef PASS_ARG_POINTER
   452 	RETURN ( __interpret(self, 5, nil, nil COMMA_SND, nil, &arg1) );
   452 	RETURN ( __interpret(self, 5, nil, nil COMMA_SND, nil, &arg1) );
   453 # else
   453 # else
   454 	RETURN ( interpret(self, 5, nil, nil COMMA_SND, nil, arg1, arg2, arg3, arg4, arg5) );
   454 	RETURN ( __interpret(self, 5, nil, nil COMMA_SND, nil, arg1, arg2, arg3, arg4, arg5) );
   455 # endif
   455 # endif
   456 #else
   456 #else
   457 	home = _BlockInstPtr(self)->b_home;
   457 	home = _BlockInstPtr(self)->b_home;
   458 	if (thecode != (OBJFUNC)nil) {
   458 	if (thecode != (OBJFUNC)nil) {
   459 	    RETURN ( (*thecode)(home COMMA_SND, arg1, arg2, arg3, arg4, arg5) );
   459 	    RETURN ( (*thecode)(home COMMA_SND, arg1, arg2, arg3, arg4, arg5) );
   460 	}
   460 	}
   461 # ifdef PASS_ARG_POINTER
   461 # ifdef PASS_ARG_POINTER
   462 	RETURN ( __interpret(self, 5, nil, home COMMA_SND, nil, &arg1) );
   462 	RETURN ( __interpret(self, 5, nil, home COMMA_SND, nil, &arg1) );
   463 # else
   463 # else
   464 	RETURN ( interpret(self, 5, nil, home COMMA_SND, nil, arg1, arg2, arg3, arg4, arg5) );
   464 	RETURN ( __interpret(self, 5, nil, home COMMA_SND, nil, arg1, arg2, arg3, arg4, arg5) );
   465 # endif
   465 # endif
   466 #endif
   466 #endif
   467     }
   467     }
   468 %}
   468 %}
   469 .
   469 .
   489 	    RETURN ( (*thecode)(self COMMA_SND, arg1, arg2, arg3, arg4, arg5, arg6) );
   489 	    RETURN ( (*thecode)(self COMMA_SND, arg1, arg2, arg3, arg4, arg5, arg6) );
   490 	}
   490 	}
   491 # ifdef PASS_ARG_POINTER
   491 # ifdef PASS_ARG_POINTER
   492 	RETURN ( __interpret(self, 6, nil, nil COMMA_SND, nil, &arg1) );
   492 	RETURN ( __interpret(self, 6, nil, nil COMMA_SND, nil, &arg1) );
   493 # else
   493 # else
   494 	RETURN ( interpret(self, 6, nil, nil COMMA_SND, nil, arg1, arg2, arg3, arg4, arg5, arg6) );
   494 	RETURN ( __interpret(self, 6, nil, nil COMMA_SND, nil, arg1, arg2, arg3, arg4, arg5, arg6) );
   495 # endif
   495 # endif
   496 #else
   496 #else
   497 	home = _BlockInstPtr(self)->b_home;
   497 	home = _BlockInstPtr(self)->b_home;
   498 	if (thecode != (OBJFUNC)nil) {
   498 	if (thecode != (OBJFUNC)nil) {
   499 	    RETURN ( (*thecode)(home COMMA_SND, arg1, arg2, arg3, arg4, arg5, arg6) );
   499 	    RETURN ( (*thecode)(home COMMA_SND, arg1, arg2, arg3, arg4, arg5, arg6) );
   500 	}
   500 	}
   501 # ifdef PASS_ARG_POINTER
   501 # ifdef PASS_ARG_POINTER
   502 	RETURN ( __interpret(self, 6, nil, home COMMA_SND, nil, &arg1) );
   502 	RETURN ( __interpret(self, 6, nil, home COMMA_SND, nil, &arg1) );
   503 # else
   503 # else
   504 	RETURN ( interpret(self, 6, nil, home COMMA_SND, nil, arg1, arg2, arg3, arg4, arg5, arg6) );
   504 	RETURN ( __interpret(self, 6, nil, home COMMA_SND, nil, arg1, arg2, arg3, arg4, arg5, arg6) );
   505 # endif
   505 # endif
   506 #endif
   506 #endif
   507     }
   507     }
   508 %}
   508 %}
   509 .
   509 .
   513 valueWithArguments:argArray
   513 valueWithArguments:argArray
   514     "evaluate the receiver with arguments taken from argArray.
   514     "evaluate the receiver with arguments taken from argArray.
   515      ArgArray must be either an Array or nil.
   515      ArgArray must be either an Array or nil.
   516      The size of the argArray must match the number of arguments the receiver expects."
   516      The size of the argArray must match the number of arguments the receiver expects."
   517 
   517 
   518     |a1 a2 a3 a4 a5 a6 a7|
   518     |a1 a2 a3 a4 a5 a6 a7 a8|
   519 
   519 
   520     (argArray notNil and:[argArray class ~~ Array]) ifTrue:[
   520     (argArray notNil and:[argArray class ~~ Array]) ifTrue:[
   521 	^ self badArgumentArry
   521 	^ self badArgumentArry
   522     ].
   522     ].
   523     (argArray size == nargs) ifFalse:[
   523     (argArray size == nargs) ifFalse:[
   532 
   532 
   533 #if defined(THIS_CONTEXT)
   533 #if defined(THIS_CONTEXT)
   534     if (__ISVALID_ILC_LNO(__pilc))
   534     if (__ISVALID_ILC_LNO(__pilc))
   535 	    _ContextInstPtr(__thisContext)->c_lineno = __ILC_LNO_AS_OBJ(__pilc);
   535 	    _ContextInstPtr(__thisContext)->c_lineno = __ILC_LNO_AS_OBJ(__pilc);
   536 #endif
   536 #endif
       
   537     thecode = _BlockInstPtr(self)->b_code;
       
   538 
       
   539 #ifndef NEW_BLOCK_CALL
       
   540     home = _BlockInstPtr(self)->b_home;
       
   541     if (thecode != (OBJFUNC)nil) {
       
   542         switch (nargs = _intVal(_INST(nargs))) {
       
   543             default:
       
   544                 goto error;
       
   545             case 8:
       
   546                 ap = _ArrayInstPtr(argArray)->a_element;
       
   547 	        RETURN ( (*thecode)(home COMMA_SND, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7]) );
       
   548             case 7:
       
   549                 ap = _ArrayInstPtr(argArray)->a_element;
       
   550 	        RETURN ( (*thecode)(home COMMA_SND, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6]) );
       
   551             case 6:
       
   552                 ap = _ArrayInstPtr(argArray)->a_element;
       
   553 	        RETURN ( (*thecode)(home COMMA_SND, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5]) );
       
   554             case 5:
       
   555                 ap = _ArrayInstPtr(argArray)->a_element;
       
   556 	        RETURN ( (*thecode)(home COMMA_SND, ap[0], ap[1], ap[2], ap[3], ap[4]) );
       
   557             case 4:
       
   558                 ap = _ArrayInstPtr(argArray)->a_element;
       
   559 	        RETURN ( (*thecode)(home COMMA_SND, ap[0], ap[1], ap[2], ap[3]) );
       
   560             case 3:
       
   561                 ap = _ArrayInstPtr(argArray)->a_element;
       
   562 	        RETURN ( (*thecode)(home COMMA_SND, ap[0], ap[1], ap[2]) );
       
   563             case 2:
       
   564                 ap = _ArrayInstPtr(argArray)->a_element;
       
   565 	        RETURN ( (*thecode)(home COMMA_SND, ap[0], ap[1]) );
       
   566             case 1:
       
   567 	        RETURN ( (*thecode)(home COMMA_SND, _ArrayInstPtr(argArray)->a_element[0]) );
       
   568             case 0:
       
   569 	        RETURN ( (*thecode)(home COMMA_SND) );
       
   570                 break;
       
   571 	}
       
   572     }
       
   573 #endif
       
   574 
   537     switch (nargs = _intVal(_INST(nargs))) {
   575     switch (nargs = _intVal(_INST(nargs))) {
   538 	default:
   576 	default:
   539 	    goto error;
   577 	    goto error;
       
   578 	case 8:
       
   579 	    a8 = _ArrayInstPtr(argArray)->a_element[7];
   540 	case 7:
   580 	case 7:
   541 	    a7 = _ArrayInstPtr(argArray)->a_element[6];
   581 	    a7 = _ArrayInstPtr(argArray)->a_element[6];
   542 	case 6:
   582 	case 6:
   543 	    a6 = _ArrayInstPtr(argArray)->a_element[5];
   583 	    a6 = _ArrayInstPtr(argArray)->a_element[5];
   544 	case 5:
   584 	case 5:
   552 	case 1:
   592 	case 1:
   553 	    a1 = _ArrayInstPtr(argArray)->a_element[0];
   593 	    a1 = _ArrayInstPtr(argArray)->a_element[0];
   554 	case 0:
   594 	case 0:
   555 	    break;
   595 	    break;
   556     }
   596     }
   557     thecode = _BlockInstPtr(self)->b_code;
       
   558 #ifdef NEW_BLOCK_CALL
   597 #ifdef NEW_BLOCK_CALL
   559     if (thecode != (OBJFUNC)nil) {
   598     if (thecode != (OBJFUNC)nil) {
   560 	RETURN ( (*thecode)(self COMMA_SND, a1, a2, a3, a4, a5, a6, a7) );
   599 	RETURN ( (*thecode)(self COMMA_SND, a1, a2, a3, a4, a5, a6, a7, a8) );
   561     }
   600     }
   562 # ifdef PASS_ARG_POINTER
   601 # ifdef PASS_ARG_POINTER
   563     RETURN ( __interpret(self, nargs, nil, nil COMMA_SND, nil, &a1) );
   602     RETURN ( __interpret(self, nargs, nil, nil COMMA_SND, nil, &a1) );
   564 # else
   603 # else
   565     RETURN ( interpret(self, nargs, nil, nil COMMA_SND, nil, 
   604     RETURN ( __interpret(self, nargs, nil, nil COMMA_SND, nil, a1, a2, a3, a4, a5, a6, a7, a8) );
   566 		       a1, a2, a3, a4, a5, a6, a7) );
   605 # endif
   567 # endif
   606 
   568 #else
   607 #else
   569     home = _BlockInstPtr(self)->b_home;
   608 
   570     if (thecode != (OBJFUNC)nil) {
       
   571 	RETURN ( (*thecode)(home COMMA_SND, a1, a2, a3, a4, a5, a6, a7) );
       
   572     }
       
   573 # ifdef PASS_ARG_POINTER
   609 # ifdef PASS_ARG_POINTER
   574     RETURN ( __interpret(self, nargs, nil, home COMMA_SND, nil, &a1) );
   610     RETURN ( __interpret(self, nargs, nil, home COMMA_SND, nil, &a1) );
   575 # else
   611 # else
   576     RETURN ( interpret(self, nargs, nil, home COMMA_SND, nil, 
   612     RETURN ( __interpret(self, nargs, nil, home COMMA_SND, nil, a1, a2, a3, a4, a5, a6, a7, a8) );
   577 		       a1, a2, a3, a4, a5, a6, a7) );
   613 # endif
   578 # endif
   614 
   579 #endif
   615 #endif
   580 
   616 
   581 error: ;
   617 error: ;
   582 %}
   618 %}
   583 .
   619 .