#ifndef __TRACE_AH__ #define __TRACE_AH__ #include #include "namemap.h" using namespace std; template struct IdxPrinter { inline static void print( TJP *tjp ) { IdxPrinter::print( tjp ); cout << "[" << tjp->template idx() << "|" << TJP::template Dim::Size << "]"; } }; template struct IdxPrinter { inline static void print( TJP *tjp ) {} }; template struct ValPrinter { inline static void print( T e ) { cout << " < " << e << " >"; } }; template struct ValPrinter { inline static void print( T a[D] ) { cout << " < "; NameMap::mangle_arraypart( a ); cout << "[" << D << "] >"; } }; template struct ValPrinter { inline static void print( T* p ) { cout << " < ~~ADDR~~ >"; } }; template<> struct ValPrinter< map > { inline static void print( map &m ) { cout << " < ~~OBJ~~ >"; } }; aspect Tracer { template inline void print_indices( TJP *tjp ) { IdxPrinter::print( tjp ); } template inline void print_entity( TJP *tjp ) { cout << tjp->signature() << " @ "; NameMap::mangle_arraypart( tjp->entity() ); ValPrinter::print( *tjp->entity() ); if( tjp->target() ) { const char * name = NameMap::objs[ tjp->target() ].first; cout << " -> " << ( name ? name : "" ); } if( tjp->array() ) { const char * name = NameMap::arrays[ tjp->array() ].first; cout << " | " << ( name ? name : "" ); print_indices( tjp ); } } #define INCTJP tjp->entity(); tjp->signature(); tjp->target(); tjp->array(); pointcut ignore() = within( "NameMap" ); advice get( "% ...::%" ) && ! ignore() : before() { INCTJP cout << "~~~ Get: "; print_entity( tjp ); cout << endl; } advice set( "% ...::%" ) && ! ignore() : before() { INCTJP cout << "~~~ Set: "; print_entity( tjp ); cout << " := " << *( tjp->template arg<0>() ); cout << endl; } advice ref( "% ...::%" ) && ! ignore() : before() { INCTJP cout << "~~~ Ref: "; print_entity( tjp ); cout << endl; } advice get( alias( "% ...::%" ) ) && ! ignore() : before() { INCTJP cout << "~~~ Get (alias): "; print_entity( tjp ); cout << endl; } advice set( alias( "% ...::%" ) ) && ! ignore() : before() { INCTJP cout << "~~~ Set (alias): "; print_entity( tjp ); cout << " := " << *( tjp->template arg<0>() ); cout << endl; } }; #endif