[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Advising methods in TI Scheme




>>  1) I started writing a program with lots of methods. Now it start loosing
>>     "track".
>>    -> How can I trace methods in Ti scheme?
>>      i.e. is there an elegant way of doing it ?


The procedure %sc-method-env returns the environment containing
the methods of a class. By using this and advise-entry and advise-exit
different tracing macros can be written.

For example, we can write a special form trace-method-entry to trace 
the entry of method m1 of class class1.

(trace-method-entry m1 class1)

=>

(macro trace-method-entry 
  (lambda (e)
    (let ((method (cadr e))
	  (class  (caddr e)))
      `(ADVISE-ENTRY 
         (ACCESS ,method (%sc-method-env ,class))
         (lambda (p a e)
           (writeln " The method " ',method " of class " ',class 
                    " is called with " a))))))

Similarly one can write a macro to trace exits.



- amitabh