ExtendedInstruction2Context< T0, T1 > Class Template Reference

Extended instruction which takes 2 parameters and is implemented using a functor. More...

#include <ExtendedInstruction.h>

Inheritance diagram for ExtendedInstruction2Context< T0, T1 >:

ExtendedInstruction Instruction List of all members.

Public Types

typedef void(*) Functor (boost::scoped_ptr< ExtendedInstructionContext > &ctx, RegisterRef< T0 > *const reg0, RegisterRef< T1 > *const reg1)
 The type of functor used to implement this extended instruction.
typedef FunctorExtendedInstructionDef<
ExtendedInstruction2Context<
T0, T1 > > 
DefT
 The specific type of the definition of this instruction.

Public Member Functions

 ExtendedInstruction2Context (DefT &def, RegisterRef< T0 > *const reg0, RegisterRef< T1 > *const reg1)
void describe (string &out, bool values) const
void exec (TProgramCounter &pc) const
const char * longName () const
const char * shortName () const

Static Public Member Functions

static ExtendedInstruction2Context<
T0, T1 > * 
create (DefT &def, vector< RegisterReference * > const &regRefs)

Protected Member Functions

ExtendedInstructionDef const & getDef () const
void describeHelper (string &out, bool values, const char *longName, const char *shortName, RegisterReference *result, RegisterReference *op1, RegisterReference *op2) const

Static Protected Member Functions

template<typename T>
static void describeArg (string &out, bool values, RegisterRef< T > *const reg)

Private Attributes

DefT _def
boost::scoped_ptr< ExtendedInstructionContext_ctx
RegisterRef< T0 > * _reg0
RegisterRef< T1 > * _reg1

Friends

class fennel::Calculator

Detailed Description

template<typename T0, typename T1>
class ExtendedInstruction2Context< T0, T1 >

Extended instruction which takes 2 parameters and is implemented using a functor.

Also provides a pointer for caching context.

Definition at line 564 of file ExtendedInstruction.h.


Member Typedef Documentation

template<typename T0, typename T1>
typedef void(*) ExtendedInstruction2Context< T0, T1 >::Functor(boost::scoped_ptr< ExtendedInstructionContext > &ctx, RegisterRef< T0 > *const reg0, RegisterRef< T1 > *const reg1)

The type of functor used to implement this extended instruction.

For example, if T0 is 'int' and T1 is 'double', then we will require a function such as

void execute(
     RegisterRef<int>* reg0,
     RegisterRef<double>* reg1)
 

Definition at line 577 of file ExtendedInstruction.h.

template<typename T0, typename T1>
typedef FunctorExtendedInstructionDef<ExtendedInstruction2Context<T0,T1> > ExtendedInstruction2Context< T0, T1 >::DefT

The specific type of the definition of this instruction.

Definition at line 586 of file ExtendedInstruction.h.


Constructor & Destructor Documentation

template<typename T0, typename T1>
ExtendedInstruction2Context< T0, T1 >::ExtendedInstruction2Context ( DefT def,
RegisterRef< T0 > *const  reg0,
RegisterRef< T1 > *const  reg1 
) [inline, explicit]

Definition at line 603 of file ExtendedInstruction.h.

00607         : _def(def),
00608           _ctx(0),
00609           _reg0(reg0),
00610           _reg1(reg1)
00611     {}


Member Function Documentation

template<typename T0, typename T1>
ExtendedInstructionDef const& ExtendedInstruction2Context< T0, T1 >::getDef (  )  const [inline, protected, virtual]

Implements ExtendedInstruction.

Definition at line 596 of file ExtendedInstruction.h.

References ExtendedInstruction2Context< T0, T1 >::_def.

00597     {
00598         return _def;
00599     }

template<typename T0, typename T1>
static ExtendedInstruction2Context<T0,T1>* ExtendedInstruction2Context< T0, T1 >::create ( DefT def,
vector< RegisterReference * > const &  regRefs 
) [inline, static]

Definition at line 613 of file ExtendedInstruction.h.

00616     {
00617         assert(regRefs.size() == 2);
00618         return new ExtendedInstruction2Context<T0,T1>(
00619             def,
00620             static_cast<RegisterRef<T0> *>(regRefs[0]),
00621             static_cast<RegisterRef<T1> *>(regRefs[1]));
00622     }

template<typename T0, typename T1>
void ExtendedInstruction2Context< T0, T1 >::describe ( string &  out,
bool  values 
) const [inline, virtual]

Implements Instruction.

Definition at line 625 of file ExtendedInstruction.h.

References ExtendedInstruction2Context< T0, T1 >::_def, ExtendedInstruction2Context< T0, T1 >::_reg0, ExtendedInstruction2Context< T0, T1 >::_reg1, ExtendedInstruction::describeArg(), and ExtendedInstructionDef::getSignature().

00626     {
00627         out = "CALL '";
00628         out += _def.getSignature();
00629         out += "' ";
00630         describeArg(out, values, _reg0);
00631         out += ", ";
00632         describeArg(out, values, _reg1);
00633     }

template<typename T0, typename T1>
void ExtendedInstruction2Context< T0, T1 >::exec ( TProgramCounter pc  )  const [inline, virtual]

Implements Instruction.

Definition at line 634 of file ExtendedInstruction.h.

References ExtendedInstruction2Context< T0, T1 >::_ctx, ExtendedInstruction2Context< T0, T1 >::_def, FunctorExtendedInstructionDef< T >::_functor, ExtendedInstruction2Context< T0, T1 >::_reg0, and ExtendedInstruction2Context< T0, T1 >::_reg1.

00635     {
00636         pc++;
00637         try {
00638             // TODO: Remove this const cast. Ugly, but exec is defined as const
00639             // TODO: in virtual above.
00640             (*_def._functor)(
00641                 const_cast<boost::scoped_ptr<ExtendedInstructionContext>& >(
00642                     _ctx),
00643                 _reg0,
00644                 _reg1);
00645         } catch (char const * str) {
00646             throw CalcMessage(str, pc - 1);
00647         }
00648     }

template<typename T>
static void ExtendedInstruction::describeArg ( string &  out,
bool  values,
RegisterRef< T > *const  reg 
) [inline, static, protected, inherited]

Definition at line 163 of file ExtendedInstruction.h.

References RegisterRef< TMPLT >::isNull(), RegisterReference::toString(), and RegisterRef< TMPLT >::valueToString().

Referenced by ExtendedInstruction5Context< T0, T1, T2, T3, T4 >::describe(), ExtendedInstruction5< T0, T1, T2, T3, T4 >::describe(), ExtendedInstruction4Context< T0, T1, T2, T3 >::describe(), ExtendedInstruction4< T0, T1, T2, T3 >::describe(), ExtendedInstruction3Context< T0, T1, T2 >::describe(), ExtendedInstruction3< T0, T1, T2 >::describe(), ExtendedInstruction2Context< T0, T1 >::describe(), ExtendedInstruction2< T0, T1 >::describe(), ExtendedInstruction1Context< T0 >::describe(), and ExtendedInstruction1< T0 >::describe().

00167     {
00168         out += reg->toString();
00169         if (values) {
00170             out += " ( ";
00171             if (reg->isNull()) {
00172                 out += "NULL";
00173             } else {
00174                 out += reg->valueToString();
00175             }
00176             out += " ) ";
00177         }
00178     }

const char* ExtendedInstruction::longName (  )  const [inline, inherited]

Definition at line 186 of file ExtendedInstruction.h.

00187     {
00188         return const_cast<ExtendedInstructionDef &>(getDef()).getName().c_str();
00189     }

const char* ExtendedInstruction::shortName (  )  const [inline, inherited]

Definition at line 191 of file ExtendedInstruction.h.

00192     {
00193         return const_cast<ExtendedInstructionDef &>(getDef()).getName().c_str();
00194     }

void Instruction::describeHelper ( string &  out,
bool  values,
const char *  longName,
const char *  shortName,
RegisterReference result,
RegisterReference op1,
RegisterReference op2 
) const [inline, protected, inherited]

Definition at line 68 of file Instruction.h.

References RegisterReference::isNull(), RegisterReference::isValid(), RegisterReference::toString(), and RegisterReference::valueToString().

Referenced by PointerToNull< PTR_TYPE >::describe(), PointerRef< PTR_TYPE >::describe(), PointerMove< PTR_TYPE >::describe(), PointerSub< PTR_TYPE >::describe(), PointerAdd< PTR_TYPE >::describe(), PointerPutSize< PTR_TYPE >::describe(), NativeToNull< TMPLT >::describe(), NativeRef< TMPLT >::describe(), NativeMove< TMPLT >::describe(), NativeRound< TMPLT >::describe(), NativeNeg< TMPLT >::describe(), NativeDiv< TMPLT >::describe(), NativeMul< TMPLT >::describe(), NativeSub< TMPLT >::describe(), NativeAdd< TMPLT >::describe(), PointerGetMaxSize< PTR_TYPE >::describe(), PointerGetSize< PTR_TYPE >::describe(), IntegralNativeShiftRight< TMPLT >::describe(), IntegralNativeShiftLeft< TMPLT >::describe(), IntegralNativeOr< TMPLT >::describe(), IntegralNativeAnd< TMPLT >::describe(), IntegralNativeMod< TMPLT >::describe(), CastCast< RESULT_T, SOURCE_T >::describe(), BoolPointerIsNotNull< PTR_TYPE >::describe(), BoolPointerIsNull< PTR_TYPE >::describe(), BoolPointerLessEqual< PTR_TYPE >::describe(), BoolPointerLess< PTR_TYPE >::describe(), BoolPointerGreaterEqual< PTR_TYPE >::describe(), BoolPointerGreater< PTR_TYPE >::describe(), BoolPointerNotEqual< PTR_TYPE >::describe(), BoolPointerEqual< PTR_TYPE >::describe(), BoolNativeIsNotNull< TMPLT >::describe(), BoolNativeIsNull< TMPLT >::describe(), BoolNativeLessEqual< TMPLT >::describe(), BoolNativeLess< TMPLT >::describe(), BoolNativeGreaterEqual< TMPLT >::describe(), BoolNativeGreater< TMPLT >::describe(), BoolNativeNotEqual< TMPLT >::describe(), BoolNativeEqual< TMPLT >::describe(), BoolToNull::describe(), BoolIsNotNull::describe(), BoolIsNull::describe(), BoolLessEqual::describe(), BoolLess::describe(), BoolGreaterEqual::describe(), BoolGreater::describe(), BoolNotEqual::describe(), BoolEqual::describe(), BoolIsNot::describe(), BoolIs::describe(), BoolRef::describe(), BoolMove::describe(), BoolNot::describe(), BoolAnd::describe(), and BoolOr::describe().

00076     {
00077         out = longName;
00078         out += ": ";
00079         out += result->toString();
00080         if (values) {
00081             out += " ( ";
00082             if (result->isNull()) {
00083                 out += "NULL";
00084             } else {
00085                 out += result->valueToString();
00086             }
00087             out += " ) ";
00088         }
00089         out += " = ";
00090 
00091         if (!op2 || !op2->isValid()) {  // if < 2 operands
00092             out += " ";
00093             out += shortName;
00094             out += " ";
00095         }
00096         if (op1 && op1->isValid()) {  // 1 or 2 operands
00097             out += op1->toString();
00098             if (values) {
00099                 out += " ( ";
00100                 if (op1->isNull()) {
00101                     out += "NULL";
00102                 } else {
00103                     out += op1->valueToString();
00104                 }
00105                 out += " ) ";
00106             }
00107         }
00108         if (op2 && op2->isValid()) {  // 2 operands
00109             out += " ";
00110             out += shortName;
00111             out += " ";
00112             out += op2->toString();
00113             if (values) {
00114                 out += " ( ";
00115                 if (op2->isNull()) {
00116                     out += "NULL";
00117                 } else {
00118                     out += op2->valueToString();
00119                 }
00120                 out += " ) ";
00121             }
00122         }
00123     }


Friends And Related Function Documentation

friend class fennel::Calculator [friend, inherited]

Definition at line 64 of file Instruction.h.


Member Data Documentation

template<typename T0, typename T1>
DefT ExtendedInstruction2Context< T0, T1 >::_def [private]

Definition at line 589 of file ExtendedInstruction.h.

Referenced by ExtendedInstruction2Context< T0, T1 >::describe(), ExtendedInstruction2Context< T0, T1 >::exec(), and ExtendedInstruction2Context< T0, T1 >::getDef().

template<typename T0, typename T1>
boost::scoped_ptr<ExtendedInstructionContext> ExtendedInstruction2Context< T0, T1 >::_ctx [private]

Definition at line 590 of file ExtendedInstruction.h.

Referenced by ExtendedInstruction2Context< T0, T1 >::exec().

template<typename T0, typename T1>
RegisterRef<T0>* ExtendedInstruction2Context< T0, T1 >::_reg0 [private]

Definition at line 591 of file ExtendedInstruction.h.

Referenced by ExtendedInstruction2Context< T0, T1 >::describe(), and ExtendedInstruction2Context< T0, T1 >::exec().

template<typename T0, typename T1>
RegisterRef<T1>* ExtendedInstruction2Context< T0, T1 >::_reg1 [private]

Definition at line 592 of file ExtendedInstruction.h.

Referenced by ExtendedInstruction2Context< T0, T1 >::describe(), and ExtendedInstruction2Context< T0, T1 >::exec().


The documentation for this class was generated from the following file:
Generated on Mon Jun 22 04:00:31 2009 for Fennel by  doxygen 1.5.1