--- a/Method.st Sun Jan 16 04:38:33 1994 +0100
+++ b/Method.st Sun Jan 16 04:47:41 1994 +0100
@@ -23,7 +23,7 @@
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libbasic/Method.st,v 1.8 1994-01-12 19:09:20 claus Exp $
+$Header: /cvs/stx/stx/libbasic/Method.st,v 1.9 1994-01-16 03:42:41 claus Exp $
written spring 89 by claus
'!
@@ -43,6 +43,8 @@
The flags field defines things like the number of method-locals,
method arguments and stack size need (for interpreted methods).
+Do not depend on any value in the flags field - it may change without
+notice.
WARNING: layout known by compiler and runtime system - dont change
"
@@ -54,6 +56,12 @@
"this class is known by the run-time-system"
^ self == Method
+!
+
+maxNumberOfArguments
+ "this limit will be removed in one of the next versions ..."
+
+ ^ 12 "cannot be easily changed"
! !
!Method methodsFor:'accessing'!
@@ -213,21 +221,24 @@
!
flags
- "return the flags (number of method variables, stacksize)"
+ "return the flags (number of method variables, stacksize etc.).
+ Dont depend on the values in the flag field - it may change
+ without notice."
^ flags
!
flags:newFlags
"set the flags (number of method variables, stacksize)
- - should only be done by the compiler"
+ - for use by the compiler only"
flags := newFlags
!
dynamic:aBoolean
"set the flag bit stating that the machine code was created
- dynamically and should be flushed on image-restart"
+ dynamically and should be flushed on image-restart.
+ - for use by compiler only."
|newFlags|
@@ -243,9 +254,27 @@
flags := newFlags
!
+numberOfMethodArgs:aNumber
+ "currently, the number of arguments is NOT remembered in
+ methods, but this will be added to allow for more checking
+ in perform:.
+ The limitation in the max. number of arguments is due to the
+ missing SENDxx functions in the VM. This too will be removed
+ in a later release, allowing any number of arguments.
+ - for use by compiler only."
+
+ aNumber > self class maxNumberOfArguments ifTrue:[
+ self error:('methods support a maximum of ' ,
+ self class maxNumberOfArguments printString ,
+ ' arguments')
+ ]
+!
+
numberOfMethodVars:aNumber
- "set the number of method variables
- - should only be done by the compiler"
+ "set the number of method variables.
+ Warning: playing around here with incorrect values
+ may crash smalltalk badly.
+ - for use by compiler only."
|newFlags|
@@ -260,8 +289,10 @@
!
stackSize:aNumber
- "set the depth of the local stack
- - should only be done by the compiler"
+ "set the depth of the local stack.
+ Warning: playing around here with incorrect values
+ may crash smalltalk badly.
+ - for use by compiler only."
|newFlags|
@@ -279,8 +310,8 @@
containingClass
"return the class I am defined in
- - stupid, there is no information of the containing class in the method,
- so we have to search here."
+ - stupid, there is no information of the containing class
+ in the method, so we have to search here."
Smalltalk allBehaviorsDo:[:aClass |
(aClass containsMethod:self) ifTrue:[^ aClass]
@@ -290,7 +321,7 @@
methodArgNames
"return a collection with the methods argument names.
- Uses Parser to parse methods source."
+ Uses Parser to parse methods source and extract the names."
|parser sourceString|
@@ -307,7 +338,7 @@
methodVarNames
"return a collection with the methods local-variable names.
- Uses Parser to parse methods source."
+ Uses Parser to parse methods source and extract the names."
|parser sourceString|
@@ -324,7 +355,7 @@
methodArgAndVarNames
"return a collection with the methods argument and variable names.
- Uses Parser to parse methods source."
+ Uses Parser to parse methods source and extract the names."
|parser sourceString argNames varNames|
@@ -344,7 +375,8 @@
!
methodComment
- "return the methods comment, nil if there is none"
+ "return the methods first comment, nil if there is none.
+ This is a somewhat stupid implementation."
|text line nQuote index qIndex qIndex2 comment|
@@ -391,7 +423,8 @@
"return true, if this method contains a message-send
with aSelectorSymbol as selector.
- due to the simple check in the literal array, also simple uses
- of aSelectorSymbol as symbol will return true."
+ of aSelectorSymbol as symbol will return true.
+ Should ask compiler, if there is really a send."
^ self referencesGlobal:aSelectorSymbol
! !
@@ -400,7 +433,8 @@
invalidMethod
"this error is triggered by the interpreter when an invalid method
- is about to be executed.
+ is about to be executed, by sending the bad method this message.
+
When recompiling classes after a definition-change, all
uncompilable methods will be bound to this method here,
so that evaluating such an uncompilable method will trigger an error.
@@ -432,10 +466,14 @@
Perform the receiver-method on anObject as receiver and argArray as
arguments. This does NO message lookup at all and mimics a
traditional function call.
- This method is provided for debugging- and breakpoint-support (replacing a method
- by a stup and recalling the original) not for general use.
- The receiver must be a method compiled in anObjects class or one of its superclasses
- - otherwise strange things (and also strange crashes) can occur. BE WARNED."
+ This method is provided for debugging- and breakpoint-support
+ (replacing a method by a stup and recalling the original),
+ not for general use.
+ The receiver must be a method compiled in anObjects class or one of its
+ superclasses
+ - otherwise strange things (and also strange crashes) can occur.
+ The system is NOT always detecting a wrong method/receiver combination.
+ BE WARNED."
%{
OBJFUNC code;
@@ -471,42 +509,42 @@
case 4:
RETURN ( (*code)(anObject, nil, SND_COMMA searchClass, &dummy,
- ap[0], ap[1], ap[2], ap[3]) );
+ ap[0], ap[1], ap[2], ap[3]) );
case 5:
RETURN ( (*code)(anObject, nil, SND_COMMA searchClass, &dummy,
- ap[0], ap[1], ap[2], ap[3], ap[4]) );
+ ap[0], ap[1], ap[2], ap[3], ap[4]) );
case 6:
RETURN ( (*code)(anObject, nil, SND_COMMA searchClass, &dummy,
- ap[0], ap[1], ap[2], ap[3], ap[4], ap[5]) );
+ ap[0], ap[1], ap[2], ap[3], ap[4], ap[5]) );
case 7:
RETURN ( (*code)(anObject, nil, SND_COMMA searchClass, &dummy,
- ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6]) );
+ ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6]) );
case 8:
RETURN ( (*code)(anObject, nil, SND_COMMA searchClass, &dummy,
- ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7]) );
+ ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7]) );
case 9:
RETURN ( (*code)(anObject, nil, SND_COMMA searchClass, &dummy,
- ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8]) );
+ ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8]) );
case 10:
RETURN ( (*code)(anObject, nil, SND_COMMA searchClass, &dummy,
- ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8],
- ap[9]) );
+ ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8],
+ ap[9]) );
case 11:
RETURN ( (*code)(anObject, nil, SND_COMMA 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[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8],
+ ap[9], ap[10]) );
case 12:
RETURN ( (*code)(anObject, nil, SND_COMMA 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[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8],
+ ap[9], ap[10], ap[11]) );
}
%}
.
@@ -515,10 +553,9 @@
].
^ self error:'too many arguments'
- "(String compiledMethodAt:#print) valueWithReceiver:'hello' arguments:#()"
"(Float compiledMethodAt:#+) valueWithReceiver:1.0 arguments:#(2.0)"
- "the next example is a wrong one - but will not crash the system ..."
- "(True compiledMethodAt:#printString) valueWithReceiver:false arguments:nil"
+ "the next example is a wrong one - which is detected by True's method ..."
+ "(True compiledMethodAt:#printString) valueWithReceiver:false arguments:nilfalse"
! !
!Method methodsFor:'printing'!