--- a/CompiledCode.st Fri Jun 05 18:09:05 2015 +0200
+++ b/CompiledCode.st Fri Jun 05 18:09:24 2015 +0200
@@ -540,11 +540,12 @@
!
numberOfMethodArgs
+ <resource: #obsolete>
"return the number of arguments, the method expects.
- This method is left for backward compatibility - use #numArgs."
+ This method is left for backward compatibility - use #argumentCount."
- "/ self obsoleteMethodWarning:'use numArgs'.
- ^ self numArgs
+ "/ self obsoleteMethodWarning:'use argumentCount'.
+ ^ self argumentCount
"Modified: / 30.1.1999 / 14:55:27 / cg"
"Created: / 30.1.1999 / 14:55:47 / cg"
@@ -991,11 +992,11 @@
With a normal send, this error cannot happen."
^ WrongNumberOfArgumentsError
- raiseRequestWith:self
- errorString:(' - %1 got %2 arg(s) where %3 expected'
- bindWith:self printString "/ self class name
- with:numArgsGiven
- with:self numArgs)
+ raiseRequestWith:self
+ errorString:(' - %1 got %2 arg(s) where %3 expected'
+ bindWith:self printString "/ self class name
+ with:numArgsGiven
+ with:self argumentCount)
"
2 perform:#+
@@ -1105,24 +1106,24 @@
%{
#ifdef __SCHTEAM__
{
- int numArgs = 0;
- STVector v = null;
+ int numArgs = 0;
+ STVector v = null;
- if (argArray != STObject.Nil) {
- v = argArray.asSTVector();
- numArgs = v.vectorLength();
- }
+ if (argArray != STObject.Nil) {
+ v = argArray.asSTVector();
+ numArgs = v.vectorLength();
+ }
- STCallable me = (STCompiledMethod)self.smalltalkCheckNumberOfArgs(1+numArgs);
+ STCallable me = (STCompiledMethod)self.smalltalkCheckNumberOfArgs(1+numArgs);
- __c__.push(anObject);
- for (int i=0; i<numArgs; i++) {
- __c__.push( v.vectorRef(i) );
- }
- // the selector and searchClass args are not needed/passed
- // the virtualSender is (currently) not supported
- // (this is cosmetics only; therefore it's done later)
- return __c__.TAILCALL_nPUSHED( me, 1+numArgs);
+ __c__.push(anObject);
+ for (int i=0; i<numArgs; i++) {
+ __c__.push( v.vectorRef(i) );
+ }
+ // the selector and searchClass args are not needed/passed
+ // the virtualSender is (currently) not supported
+ // (this is cosmetics only; therefore it's done later)
+ return __c__.TAILCALL_nPUSHED( me, 1+numArgs);
}
/* NOT REACHED */
#else
@@ -1136,286 +1137,286 @@
* args must be an array, or nil
*/
if (__isArrayLike(argArray)) {
- nargs = __arraySize(argArray);
- ap = __ArrayInstPtr(argArray)->a_element;
+ nargs = __arraySize(argArray);
+ ap = __ArrayInstPtr(argArray)->a_element;
} else {
- if (argArray != nil) {
- goto badArgs;
- }
- nargs = 0;
- ap = (OBJ *)0;
+ if (argArray != nil) {
+ goto badArgs;
+ }
+ nargs = 0;
+ ap = (OBJ *)0;
}
# ifdef F_NARGS
if (((__intVal(__INST(flags)) & F_NARGS) >> F_NARGSHIFT) == nargs)
# endif
{
- code = __MethodInstPtr(self)->m_code;
- if (aClass == nil) {
- searchClass = dummy.ilc_class = __Class(anObject);
- } else {
- searchClass = dummy.ilc_class = aClass;
- }
+ code = __MethodInstPtr(self)->m_code;
+ if (aClass == nil) {
+ searchClass = dummy.ilc_class = __Class(anObject);
+ } else {
+ searchClass = dummy.ilc_class = aClass;
+ }
- if (nargs <= 15) {
- OBJ rslt;
+ if (nargs <= 15) {
+ OBJ rslt;
# ifdef CONTEXT_DEBUG
- OBJ sav = __thisContext;
+ OBJ sav = __thisContext;
# endif
- /*
- * add virtual sender (unwinding) here later,
- * to allow hiding contexts in lazy methods.
- * (this is cosmetics only; therefore its done later)
- */
- if (code) {
- /* compiled code */
- switch (nargs) {
- case 0:
- rslt = (*code)(anObject, aSymbol, searchClass, &dummy);
- break;
+ /*
+ * add virtual sender (unwinding) here later,
+ * to allow hiding contexts in lazy methods.
+ * (this is cosmetics only; therefore its done later)
+ */
+ if (code) {
+ /* compiled code */
+ switch (nargs) {
+ case 0:
+ rslt = (*code)(anObject, aSymbol, searchClass, &dummy);
+ break;
- case 1:
- rslt = (*code)(anObject, aSymbol, searchClass, &dummy, ap[0]);
- break;
+ case 1:
+ rslt = (*code)(anObject, aSymbol, searchClass, &dummy, ap[0]);
+ break;
- case 2:
- rslt = (*code)(anObject, aSymbol, searchClass, &dummy, ap[0], ap[1]);
- break;
+ case 2:
+ rslt = (*code)(anObject, aSymbol, searchClass, &dummy, ap[0], ap[1]);
+ break;
- case 3:
- rslt = (*code)(anObject, aSymbol, searchClass, &dummy, ap[0], ap[1], ap[2]);
- break;
+ case 3:
+ rslt = (*code)(anObject, aSymbol, searchClass, &dummy, ap[0], ap[1], ap[2]);
+ break;
- case 4:
- rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
- ap[0], ap[1], ap[2], ap[3]);
- break;
+ case 4:
+ rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
+ ap[0], ap[1], ap[2], ap[3]);
+ break;
- case 5:
- rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
- ap[0], ap[1], ap[2], ap[3], ap[4]);
- break;
+ case 5:
+ rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
+ ap[0], ap[1], ap[2], ap[3], ap[4]);
+ break;
- case 6:
- rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
- ap[0], ap[1], ap[2], ap[3], ap[4], ap[5]);
- break;
+ case 6:
+ rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
+ ap[0], ap[1], ap[2], ap[3], ap[4], ap[5]);
+ break;
- case 7:
- rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
- ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6]);
- break;
+ case 7:
+ rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
+ ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6]);
+ break;
- case 8:
- rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
- ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7]);
- break;
+ case 8:
+ rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
+ ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7]);
+ break;
- case 9:
- rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
- ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8]);
- break;
+ case 9:
+ rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
+ ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8]);
+ break;
- case 10:
- rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
- ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8],
- ap[9]);
- break;
+ case 10:
+ rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
+ ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8],
+ ap[9]);
+ break;
- case 11:
- rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
- ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8],
- ap[9], ap[10]);
- break;
+ case 11:
+ rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
+ ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8],
+ ap[9], ap[10]);
+ break;
- case 12:
- rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
- ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8],
- ap[9], ap[10], ap[11]);
- break;
+ case 12:
+ rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
+ ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8],
+ ap[9], ap[10], ap[11]);
+ break;
- case 13:
- rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
- 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]);
- break;
+ case 13:
+ rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
+ 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]);
+ break;
- case 14:
- rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
- 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]);
- break;
+ case 14:
+ rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
+ 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]);
+ break;
- case 15:
- rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
- 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]);
- break;
- }
- } else {
- /* interpreted code */
+ case 15:
+ rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
+ 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]);
+ break;
+ }
+ } else {
+ /* interpreted code */
# ifdef PASS_ARG_POINTER
- rslt = __interpret(self, nargs, anObject, aSymbol, searchClass, &dummy, ap);
+ rslt = __interpret(self, nargs, anObject, aSymbol, searchClass, &dummy, ap);
# else
- switch (nargs) {
- case 0:
- rslt = __interpret(self, 0, anObject, aSymbol, searchClass, &dummy);
- break;
+ switch (nargs) {
+ case 0:
+ rslt = __interpret(self, 0, anObject, aSymbol, searchClass, &dummy);
+ break;
- case 1:
- rslt = __interpret(self, 1, anObject, aSymbol, searchClass, &dummy,
- ap[0]);
- break;
+ case 1:
+ rslt = __interpret(self, 1, anObject, aSymbol, searchClass, &dummy,
+ ap[0]);
+ break;
- case 2:
- rslt = __interpret(self, 2, anObject, aSymbol, searchClass, &dummy,
- ap[0], ap[1]);
- break;
+ case 2:
+ rslt = __interpret(self, 2, anObject, aSymbol, searchClass, &dummy,
+ ap[0], ap[1]);
+ break;
- case 3:
- rslt = __interpret(self, 3, anObject, aSymbol, searchClass, &dummy,
- ap[0], ap[1], ap[2]);
- break;
+ case 3:
+ rslt = __interpret(self, 3, anObject, aSymbol, searchClass, &dummy,
+ ap[0], ap[1], ap[2]);
+ break;
- case 4:
- rslt = __interpret(self, 4, anObject, aSymbol, searchClass, &dummy,
- ap[0], ap[1], ap[2], ap[3]);
- break;
+ case 4:
+ rslt = __interpret(self, 4, anObject, aSymbol, searchClass, &dummy,
+ ap[0], ap[1], ap[2], ap[3]);
+ break;
- case 5:
- rslt = __interpret(self, 5, anObject, aSymbol, searchClass, &dummy,
- ap[0], ap[1], ap[2], ap[3], ap[4]);
- break;
+ case 5:
+ rslt = __interpret(self, 5, anObject, aSymbol, searchClass, &dummy,
+ ap[0], ap[1], ap[2], ap[3], ap[4]);
+ break;
- case 6:
- rslt = __interpret(self, 6, anObject, aSymbol, searchClass, &dummy,
- ap[0], ap[1], ap[2], ap[3], ap[4], ap[5]);
- break;
+ case 6:
+ rslt = __interpret(self, 6, anObject, aSymbol, searchClass, &dummy,
+ ap[0], ap[1], ap[2], ap[3], ap[4], ap[5]);
+ break;
- case 7:
- rslt = __interpret(self, 7, anObject, aSymbol, searchClass, &dummy,
- ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6]);
- break;
+ case 7:
+ rslt = __interpret(self, 7, anObject, aSymbol, searchClass, &dummy,
+ ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6]);
+ break;
- case 8:
- rslt = __interpret(self, 8, anObject, aSymbol, searchClass, &dummy,
- ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6],
- ap[7]);
- break;
+ case 8:
+ rslt = __interpret(self, 8, anObject, aSymbol, searchClass, &dummy,
+ ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6],
+ ap[7]);
+ break;
- case 9:
- rslt = __interpret(self, 9, anObject, aSymbol, searchClass, &dummy,
- ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6],
- ap[7], ap[8]);
- break;
+ case 9:
+ rslt = __interpret(self, 9, anObject, aSymbol, searchClass, &dummy,
+ ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6],
+ ap[7], ap[8]);
+ break;
- case 10:
- rslt = __interpret(self, 10, anObject, aSymbol, searchClass, &dummy,
- ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6],
- ap[7], ap[8], ap[9]);
- break;
+ case 10:
+ rslt = __interpret(self, 10, anObject, aSymbol, searchClass, &dummy,
+ ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6],
+ ap[7], ap[8], ap[9]);
+ break;
- case 11:
- rslt = __interpret(self, 11, anObject, aSymbol, searchClass, &dummy,
- ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6],
- ap[7], ap[8], ap[9], ap[10]);
- break;
+ case 11:
+ rslt = __interpret(self, 11, anObject, aSymbol, searchClass, &dummy,
+ ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6],
+ ap[7], ap[8], ap[9], ap[10]);
+ break;
- case 12:
- rslt = __interpret(self, 12, anObject, aSymbol, searchClass, &dummy,
- ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6],
- ap[7], ap[8], ap[9], ap[10], ap[11]);
- break;
+ case 12:
+ rslt = __interpret(self, 12, anObject, aSymbol, searchClass, &dummy,
+ ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6],
+ ap[7], ap[8], ap[9], ap[10], ap[11]);
+ break;
- case 13:
- rslt = __interpret(self, 13, anObject, aSymbol, searchClass, &dummy,
- 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]);
- break;
+ case 13:
+ rslt = __interpret(self, 13, anObject, aSymbol, searchClass, &dummy,
+ 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]);
+ break;
- case 14:
- rslt = __interpret(self, 14, anObject, aSymbol, searchClass, &dummy,
- 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]);
- break;
+ case 14:
+ rslt = __interpret(self, 14, anObject, aSymbol, searchClass, &dummy,
+ 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]);
+ break;
- case 15:
- rslt = __interpret(self, 15, anObject, aSymbol, searchClass, &dummy,
- 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]);
- break;
- }
+ case 15:
+ rslt = __interpret(self, 15, anObject, aSymbol, searchClass, &dummy,
+ 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]);
+ break;
+ }
# endif
- }
+ }
# ifdef CONTEXT_DEBUG
- if (sav != __thisContext) {
- if (code) {
- printf("CONTEXT BOTCH after execution of %x\n", code);
- } else {
- printf("CONTEXT BOTCH after execution of interpreted method\n");
- printf("code now: %x\n", __MethodInstPtr(self)->m_code);
- }
- printf("context before:\n");
- __dumpObject__(sav, __LINE__);
- printf("context now:\n");
- __dumpObject__(__thisContext, __LINE__);
- }
+ if (sav != __thisContext) {
+ if (code) {
+ printf("CONTEXT BOTCH after execution of %x\n", code);
+ } else {
+ printf("CONTEXT BOTCH after execution of interpreted method\n");
+ printf("code now: %x\n", __MethodInstPtr(self)->m_code);
+ }
+ printf("context before:\n");
+ __dumpObject__(sav, __LINE__);
+ printf("context now:\n");
+ __dumpObject__(__thisContext, __LINE__);
+ }
# endif
- RETURN (rslt);
- }
+ RETURN (rslt);
+ }
}
badArgs: ;
#endif /* not SCHTEAM */
%}.
(argArray isArray) ifFalse:[
- (self numArgs ~~ 0
- or:[argArray notNil]) ifTrue:[
- "
- arguments must be either nil or an array
- "
- ^ self badArgumentArray:argArray
- ]
+ (self argumentCount ~~ 0
+ or:[argArray notNil]) ifTrue:[
+ "
+ arguments must be either nil or an array
+ "
+ ^ self badArgumentArray:argArray
+ ]
].
(argArray size ~~ self numArgs) ifTrue:[
- "
- the method expects a different number of arguments
- "
- ^ self wrongNumberOfArguments:argArray size
+ "
+ the method expects a different number of arguments
+ "
+ ^ self wrongNumberOfArguments:argArray size
].
"/ if the VM only supports a limited number of arguments in sends (ST/X: 15)
argArray size > self class maxNumberOfArguments ifTrue:[
- ^ self tooManyArguments
+ ^ self tooManyArguments
].
^ self primitiveFailed
"
(Float compiledMethodAt:#+)
- valueWithReceiver:1.0 arguments:#(2.0)
+ valueWithReceiver:1.0 arguments:#(2.0)
'the next example is a wrong one - which is detected by True's method ...'.
(True compiledMethodAt:#printString)
- valueWithReceiver:false arguments:nil
+ valueWithReceiver:false arguments:nil
'the next example is a wrong one - it is nowhere detected
and a wrong value returned ...'.
(Point compiledMethodAt:#x)
- valueWithReceiver:(1->2) arguments:nil
+ valueWithReceiver:(1->2) arguments:nil
'the next example is VERY bad one - it is nowhere detected
and may crash the system WARNING: save your work before doing this ...'.
(Point compiledMethodAt:#x)
- valueWithReceiver:(Object new) arguments:nil
+ valueWithReceiver:(Object new) arguments:nil
'the next example is a wrong one - which is detected here ...'.
(Object compiledMethodAt:#printOn:)
- valueWithReceiver:false arguments:nil
+ valueWithReceiver:false arguments:nil
'the next example is a wrong one - which is detected here ...'.
(Object compiledMethodAt:#printOn:)
- valueWithReceiver:false arguments:#()
+ valueWithReceiver:false arguments:#()
"
"Modified: / 07-10-2011 / 13:58:21 / cg"
@@ -1994,13 +1995,14 @@
!CompiledCode class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/CompiledCode.st,v 1.129 2015-05-31 09:24:36 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/CompiledCode.st,v 1.130 2015-06-05 16:09:24 stefan Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic/CompiledCode.st,v 1.129 2015-05-31 09:24:36 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/CompiledCode.st,v 1.130 2015-06-05 16:09:24 stefan Exp $'
!
version_SVN
^ '$ Id: CompiledCode.st 10643 2011-06-08 21:53:07Z vranyj1 $'
! !
+