#ifndef __Trace_h__
#define __Trace_h__

#include <stdio.h>
#include "mangle.h"

aspect Trace
 { 
      pointcut virtual methods() = 0;

   public:

      advice methods () : before ()
       { 
         printf ("before \"%s\"\n", JoinPoint::signature ()); 
         printf("  Type: %s ID=%d Type=%d", JoinPoint::type(),
		JoinPoint::id(), JoinPoint::jptype()); 
         printf(" (%p -> %p)\n", tjp->that(), tjp->target());
	 for (int i = 0; i < JoinPoint::args(); i++) 
	  {
	    printf("    arg(%d): ", i);
	    demangleandprint(JoinPoint::argtype(i));
            printf(" = ");
	    printvalue(tjp->arg(i),JoinPoint::argtype(i));
	    printf("\n");
	  } 
         printf("    Result: ");
	 demangleandprint(JoinPoint::resulttype());
         printf(" = ");
         printvalue(tjp->result(), JoinPoint::resulttype());
         printf("\n");
       }

      advice methods () : after ()
       { 
	 printf ("after \"%s\"\n", JoinPoint::signature ()); 
         printf("    Result: ");
	 demangleandprint(JoinPoint::resulttype());
         printf(" = ");
         printvalue(tjp->result(), JoinPoint::resulttype());
         printf("\n");
       }

 };

#endif // __Trace_h__
