Method.st
changeset 49 f1c2d75f2eb6
parent 44 b262907c93ea
child 56 be0ed17e6f85
--- a/Method.st	Sat Feb 05 13:19:13 1994 +0100
+++ b/Method.st	Sat Feb 05 13:23:03 1994 +0100
@@ -23,7 +23,7 @@
 COPYRIGHT (c) 1989 by Claus Gittinger
              All Rights Reserved
 
-$Header: /cvs/stx/stx/libbasic/Method.st,v 1.9 1994-01-16 03:42:41 claus Exp $
+$Header: /cvs/stx/stx/libbasic/Method.st,v 1.10 1994-02-05 12:22:08 claus Exp $
 written spring 89 by claus
 '!
 
@@ -83,8 +83,11 @@
 code
     "return code field - since its a non-object return address as integer"
 %{
-    RETURN ( _MKSMALLINT((int)(_MethodInstPtr(self)->m_code)) );
-%}
+    if (_MethodInstPtr(self)->m_code != (OBJFUNC)0) {
+        RETURN ( _MKSMALLINT((int)(_MethodInstPtr(self)->m_code)) );
+    }
+%}.
+    ^ nil
 !
 
 code:anAddress
@@ -92,13 +95,11 @@
      should only be done by compiler.
      Smalltalk can crash badly if playing around here ..."
 %{
-    if (_isSmallInteger(anAddress)) {
-        _MethodInstPtr(self)->m_code = (OBJFUNC)_intVal(anAddress);
-        RETURN ( self );
-    }
+    if (_isSmallInteger(anAddress))
+        _INST(code) = (OBJ)(_intVal(anAddress));
+    else
+        _INST(code) = nil;
 %}
-.
-    self primitiveFailed
 !
 
 source
@@ -256,8 +257,9 @@
 
 numberOfMethodArgs:aNumber
     "currently, the number of arguments is NOT remembered in
-     methods, but this will be added to allow for more checking
-     in perform:.
+     methods, but this will be added soon 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.
@@ -270,6 +272,17 @@
     ]
 !
      
+numberOfMethodArgs
+    "return the number of arguments, the method expects." 
+
+    "
+     The current implementation simply counts the arguments from
+     the methods source - future versions will include this information
+     in the flag instVar, for more protection in #perform:"
+
+    ^ self methodArgNames size
+!
+
 numberOfMethodVars:aNumber
     "set the number of method variables. 
      Warning: playing around here with incorrect values 
@@ -288,6 +301,21 @@
     flags := newFlags
 !
 
+numberOfMethodVars
+    "return the number of method local variables. 
+     Do not depend on the returned value - future optimizations
+     may change things here.
+     - for debugging only."
+
+%{  /* NOCONTEXT */
+    /* made this a primitive to get define in stc.h */
+
+    int flagBits = _intVal(_INST(flags));
+
+    RETURN (_MKSMALLINT((flagBits & F_NVARS) >> F_NVARSHIFT));
+%}
+!
+
 stackSize:aNumber
     "set the depth of the local stack.
      Warning: playing around here with incorrect values 
@@ -304,6 +332,21 @@
 %}
 .
     flags := newFlags
+!
+
+stackSize
+    "return the number of temporaries needed as stack in the context. 
+     Do not depend on the returned value - future optimizations
+     may change things here.
+     - for debugging only."
+
+%{  /* NOCONTEXT */
+    /* made this a primitive to get define in stc.h */
+
+    int flagBits = _intVal(_INST(flags));
+
+    RETURN (_MKSMALLINT((flagBits & F_NSTACK) >> F_NSTACKSHIFT));
+%}
 ! !
 
 !Method methodsFor:'queries'!