#include <RegisterReference.h>
Inheritance diagram for RegisterReference:
Public Types | |
enum | ERegisterSet { EFirstSet = 0, ELiteral = 0, EInput = 1, EOutput = 2, ELocal = 3, EStatus = 4, ELastSet, EUnknown = 1000 } |
Index all register sets. More... | |
enum | EProperties { EPropNone = 0, EPropReadOnly = 1, EPropCachePointer = 2, EPropPtrReset = 4, EPropByRefOnly = 8 } |
Properties control behavior of RegisterReference. More... | |
Public Member Functions | |
RegisterReference () | |
Constructor for an invalid RegisterReference. | |
RegisterReference (ERegisterSet set, unsigned long index, StandardTypeDescriptorOrdinal datatype) | |
Constructor for a valid RegisterReference. | |
virtual | ~RegisterReference () |
void | setCalc (Calculator *calcP) |
Provides a pointer to encapsulating Calculator. | |
void | cachePointer () |
Performs pre-execution optimizations. | |
ERegisterSet | setIndex () const |
Returns set index. | |
unsigned long | index () const |
Returns register index within a set. | |
bool | isValid () const |
Is this a valid RegisterReference? | |
StandardTypeDescriptorOrdinal | type () const |
Returns type information. | |
string | toString () const |
Provides a nicely formatted string describing this register. | |
virtual string | valueToString () const=0 |
Returns current value of register. | |
virtual bool | isNull () const=0 |
Is the register currently set to NULL? | |
DynamicParamManager * | getDynamicParamManager () const |
Gets the DynamicParamManager belonging to the Calculator. | |
TupleDatum * | getBinding (bool resetFromNull=false) const |
gets the register binding | |
Static Public Member Functions | |
static string | getSetName (ERegisterSet set) |
Returns a string describing the register set. | |
static string | toString (ERegisterSet set, unsigned long index) |
Provides a nicely formatted string describing the register for the specified set and index. | |
Static Public Attributes | |
static const uint32_t | KLiteralSetDefault |
Literal set can be cached, and really should be read only. | |
static const uint32_t | KInputSetDefault = EPropReadOnly |
Input must be read only. Caching doesn't make sense for input. | |
static const uint32_t | KOutputSetDefault = EPropNone |
Caching doesn't make sense for output. | |
static const uint32_t | KLocalSetDefault |
Local set can be cached, and must reset pointers if Calculator::exec() is to be called again and NULLs are written or pointers are moved. | |
static const uint32_t | KStatusSetDefault = EPropNone |
Status register can be cached if it is never re-bound. | |
Protected Member Functions | |
void | setDefaultProperties () |
Defines default properties for registers based on register set. | |
Protected Attributes | |
const ERegisterSet | mSetIndex |
Register set index. | |
const unsigned long | mIndex |
Register index within a register set. | |
const StandardTypeDescriptorOrdinal | mType |
Underlying type of register. | |
TRegisterSetP | mRegisterSetP |
Array of pointers to register set bindings. | |
TRegisterSetDescP | mRegisterSetDescP |
Array of pointers to register set descriptors. | |
vector< RegisterReference * > * | mResetP |
RegisterReferences that will be reset before next exec. | |
bool | mCachePtrModified |
Cached pointer was set to null or moved. | |
PBuffer | mPData |
Cached and/or duplicated data pointer. | |
TupleStorageByteLength | mCbData |
Cached and/or duplicated length of mPData;. | |
TupleStorageByteLength | mCbStorage |
Cached and/or duplicated capacity of mPData;. | |
TRegisterRefProp | mProp |
Behavior properties of this register. | |
DynamicParamManager * | mPDynamicParamManager |
The DynamicParamManager set after a call to setCalc. |
Base class provides non-templated interface to RegisterRef.
Optionally optimizes subsequent reads and writes and resets pointers.
To provide different properties in RegisterReferences, such as read-only access, and resetability, in a "clean" way would require run-time-polymorphism in the Instruction tree. At this point the extra overhead of function pointers and vtables doesn't seem like the best choice for this performance critical object. So, for the moment, object properties will be internal-state-based vs. object-type-based.
Definition at line 113 of file RegisterReference.h.
Index all register sets.
EFirstSet | |
ELiteral | |
EInput | |
EOutput | |
ELocal | |
EStatus | |
ELastSet | Insert new register set before this entry. |
EUnknown |
Definition at line 117 of file RegisterReference.h.
00117 { 00118 EFirstSet = 0, 00119 ELiteral = 0, 00120 EInput = 1, 00121 EOutput = 2, 00122 ELocal = 3, 00123 EStatus = 4, 00124 ELastSet, 00125 EUnknown = 1000 00126 };
Properties control behavior of RegisterReference.
Note: Values are powers of two to allow bitmasking.
EPropNone | No properties set. |
EPropReadOnly |
Prevent writes and re-pointing pData.
Enforced only through assert() |
EPropCachePointer | Keep a pointer to data instead of just in time indexing. |
EPropPtrReset | Journal pointer changes to allow resetting. |
EPropByRefOnly |
No memory associated.
Can only be repointed to other registers. See Calculator::outputRegisterByReference(). |
Definition at line 172 of file RegisterReference.h.
00172 { 00173 EPropNone = 0, 00174 EPropReadOnly = 1, 00175 00176 EPropCachePointer = 2, 00177 00178 EPropPtrReset = 4, 00179 EPropByRefOnly = 8 00180 00181 00182 };
RegisterReference::RegisterReference | ( | ) | [inline, explicit] |
Constructor for an invalid RegisterReference.
Definition at line 130 of file RegisterReference.h.
00131 : mSetIndex(EUnknown), 00132 mIndex(0), 00133 mType(STANDARD_TYPE_END_NO_UNICODE), 00134 mPData(0), 00135 mCbData(0), 00136 mCbStorage(0), 00137 mPDynamicParamManager(0) 00138 { 00139 mProp = EPropNone; 00140 }
RegisterReference::RegisterReference | ( | ERegisterSet | set, | |
unsigned long | index, | |||
StandardTypeDescriptorOrdinal | datatype | |||
) | [inline, explicit] |
Constructor for a valid RegisterReference.
set | Register set | |
index | Register with a given set | |
datatype | The type of the underlying data. |
Definition at line 148 of file RegisterReference.h.
00152 : mSetIndex(set), 00153 mIndex(index), 00154 mType(datatype), 00155 mPData(0), 00156 mCbData(0), 00157 mCbStorage(0), 00158 mPDynamicParamManager(0) 00159 { 00160 assert(mSetIndex < ELastSet); 00161 assert(mSetIndex >= EFirstSet); 00162 setDefaultProperties(); 00163 }
virtual RegisterReference::~RegisterReference | ( | ) | [inline, virtual] |
void RegisterReference::setCalc | ( | Calculator * | calcP | ) |
Provides a pointer to encapsulating Calculator.
Must be in .cpp file for recursive include requirement reasons. Refers to Calculator and RegisterReference objects. See also Calculator::outputRegisterByReference().
See Calculator::outputRegisterByReference()
Definition at line 79 of file RegisterReference.cpp.
References EOutput, EPropByRefOnly, EPropReadOnly, Calculator::getDynamicParamManager(), Calculator::mOutputRegisterByReference, mPDynamicParamManager, mProp, Calculator::mRegisterReset, Calculator::mRegisterSetBinding, mRegisterSetDescP, Calculator::mRegisterSetDescriptor, mRegisterSetP, mResetP, and mSetIndex.
Referenced by Calculator::appendRegRef().
00079 { 00080 mRegisterSetP = calcP->mRegisterSetBinding; 00081 mRegisterSetDescP = calcP->mRegisterSetDescriptor; 00082 mResetP = &(calcP->mRegisterReset); 00083 mPDynamicParamManager = calcP->getDynamicParamManager(); 00084 if (mSetIndex == EOutput && calcP->mOutputRegisterByReference) { 00086 mProp |= (EPropByRefOnly | EPropReadOnly); 00087 } 00088 }
void RegisterReference::cachePointer | ( | ) |
Performs pre-execution optimizations.
If CachePointer or PtrReset properties are set, save a pointer directly to the data.
Definition at line 91 of file RegisterReference.cpp.
References TupleDatum::cbData, EPropCachePointer, EPropPtrReset, getBinding(), mCachePtrModified, mCbData, mCbStorage, mIndex, mPData, mProp, mRegisterSetDescP, mSetIndex, and TupleDatum::pData.
Referenced by Calculator::bind(), and Calculator::exec().
00091 { 00092 if (mProp & (EPropCachePointer | EPropPtrReset)) { 00093 TupleDatum *bind = getBinding(); 00094 mPData = const_cast<PBuffer>(bind->pData); 00095 mCbData = bind->cbData; 00096 00097 // Next 3 lines clarify complex 4th line: 00098 // TupleDescriptor* tupleDescP = mRegisterSetDescP[mSetIndex]; 00099 // TupleAttributeDescriptor* attrP = &((*tupleDescP)[mIndex]); 00100 // mCbStorage = attrP->cbStorage; 00101 mCbStorage = ((*(mRegisterSetDescP[mSetIndex]))[mIndex]).cbStorage; 00102 mCachePtrModified = false; 00103 } 00104 }
ERegisterSet RegisterReference::setIndex | ( | ) | const [inline] |
Returns set index.
Definition at line 217 of file RegisterReference.h.
Referenced by Calculator::appendRegRef().
00218 { 00219 return mSetIndex; 00220 }
unsigned long RegisterReference::index | ( | ) | const [inline] |
Returns register index within a set.
Definition at line 222 of file RegisterReference.h.
00223 { 00224 return mIndex; 00225 }
bool RegisterReference::isValid | ( | ) | const [inline] |
Is this a valid RegisterReference?
Definition at line 227 of file RegisterReference.h.
Referenced by JumpInstruction::describeHelper(), and Instruction::describeHelper().
StandardTypeDescriptorOrdinal RegisterReference::type | ( | ) | const [inline] |
Returns type information.
Definition at line 232 of file RegisterReference.h.
Referenced by WinAggHistogramStrA::addRow(), castApproxToStrA(), castBooleanToStrA(), CastDateTimeToInt64(), CastDateToStrA(), castExactToStrA(), CastStrAToDate(), CastStrAToTime(), CastStrAToTimestamp(), castStrToApproxA(), castStrToBinaryA(), castStrToBooleanA(), castStrToCharA(), castStrToExactA(), castStrToVarBinaryA(), castStrToVarCharA(), CastTimestampToStrA(), CastTimeToStrA(), CurrentTime(), CurrentTimestamp(), WinAggHistogramStrA::dropRow(), CalcAssembler::getRegisterType(), histogramAlloc(), LocalTime(), LocalTimestamp(), mathAbs(), mathLn(), mathLog10(), mathPow(), strCpyA(), strLenBitA(), strLenCharA(), strLenOctA(), strLikeEscapeA(), strOverlayA4(), strOverlayA5(), strPosA(), strSimilarEscapeA(), strSubStringA3(), strSubStringA4(), strToLowerA(), strToUpperA(), and strTrimA().
00232 { 00233 return mType; 00234 }
static string RegisterReference::getSetName | ( | ERegisterSet | set | ) | [inline, static] |
Returns a string describing the register set.
Definition at line 237 of file RegisterReference.h.
Referenced by CalcAssembler::getRegister().
00238 { 00239 switch (set) { 00240 case ELiteral: 00241 return "C"; 00242 case ELocal: 00243 return "L"; 00244 case EInput: 00245 return "I"; 00246 case EOutput: 00247 return "O"; 00248 case EStatus: 00249 return "S"; 00250 default: 00251 throw std::invalid_argument( 00252 "fennel/calculator/RegisterReference::getSetName"); 00253 } 00254 }
static string RegisterReference::toString | ( | ERegisterSet | set, | |
unsigned long | index | |||
) | [inline, static] |
Provides a nicely formatted string describing the register for the specified set and index.
Definition at line 259 of file RegisterReference.h.
Referenced by CalcAssembler::createInstruction(), ExtendedInstruction::describeArg(), JumpInstruction::describeHelper(), and Instruction::describeHelper().
00260 { 00261 ostringstream ostr(""); 00262 ostr << getSetName(set) << index; 00263 return ostr.str(); 00264 }
string RegisterReference::toString | ( | ) | const |
Provides a nicely formatted string describing this register.
Definition at line 133 of file RegisterReference.cpp.
References mIndex, and mSetIndex.
Referenced by CalcAssembler::bindRegisterValue(), and CalcAssembler::createRegisterReference().
virtual string RegisterReference::valueToString | ( | ) | const [pure virtual] |
Returns current value of register.
Implemented in RegisterRef< TMPLT >, RegisterRef< T0 >, RegisterRef< PointerSizeT >, RegisterRef< T1 >, RegisterRef< T2 >, RegisterRef< OP2T >, RegisterRef< T3 >, RegisterRef< T4 >, RegisterRef< RESULT_T >, RegisterRef< SOURCE_T >, RegisterRef< PTR_TYPE >, RegisterRef< bool >, RegisterRef< unsigned __int32 >, and RegisterRef< char * >.
Referenced by Instruction::describeHelper().
virtual bool RegisterReference::isNull | ( | ) | const [pure virtual] |
Is the register currently set to NULL?
Implemented in RegisterRef< TMPLT >, RegisterRef< T0 >, RegisterRef< PointerSizeT >, RegisterRef< T1 >, RegisterRef< T2 >, RegisterRef< OP2T >, RegisterRef< T3 >, RegisterRef< T4 >, RegisterRef< RESULT_T >, RegisterRef< SOURCE_T >, RegisterRef< PTR_TYPE >, RegisterRef< bool >, RegisterRef< unsigned __int32 >, and RegisterRef< char * >.
Referenced by Instruction::describeHelper().
DynamicParamManager* RegisterReference::getDynamicParamManager | ( | ) | const [inline] |
Gets the DynamicParamManager belonging to the Calculator.
Definition at line 274 of file RegisterReference.h.
00274 { 00275 assert(mPDynamicParamManager); 00276 return mPDynamicParamManager; 00277 }
TupleDatum* RegisterReference::getBinding | ( | bool | resetFromNull = false |
) | const [inline] |
gets the register binding
resetFromNull,: | if the register is null, reset the address to the target buffer so the value can be changed. |
Definition at line 282 of file RegisterReference.h.
References TupleDatum::pData.
Referenced by add(), WinAggHistogramStrA::addRow(), avg(), cachePointer(), count(), drop(), firstValue(), histogramAlloc(), RegisterRef< char * >::isNull(), lastValue(), RegisterRef< char * >::length(), max(), min(), RegisterRef< char * >::pointer(), RegisterRef< char * >::refer(), sum(), RegisterRef< char * >::toNull(), and RegisterRef< char * >::value().
00282 { 00283 // validate indexes 00284 assert(mRegisterSetP); 00285 assert(mSetIndex < ELastSet); 00286 assert(mRegisterSetP[mSetIndex]); 00287 RegisterSetBinding* rsb = mRegisterSetP[mSetIndex]; 00288 TupleDatum& bind = (*rsb)[mIndex]; 00289 if (resetFromNull) { 00290 if (!bind.pData) { 00291 bind.pData = mRegisterSetP[mSetIndex]->getTargetAddr(mIndex); 00292 } 00293 } 00294 return &bind; 00295 }
void RegisterReference::setDefaultProperties | ( | ) | [protected] |
Defines default properties for registers based on register set.
Definition at line 107 of file RegisterReference.cpp.
References EInput, ELiteral, ELocal, EOutput, EPropNone, EStatus, KInputSetDefault, KLiteralSetDefault, KLocalSetDefault, KOutputSetDefault, KStatusSetDefault, mProp, and mSetIndex.
00108 { 00109 switch (mSetIndex) { 00110 case ELiteral: 00111 mProp = KLiteralSetDefault; 00112 break; 00113 case EInput: 00114 mProp = KInputSetDefault; 00115 break; 00116 case EOutput: 00117 mProp = KOutputSetDefault; 00118 break; 00119 case ELocal: 00120 mProp = KLocalSetDefault; 00121 break; 00122 case EStatus: 00123 mProp = KStatusSetDefault; 00124 break; 00125 default: 00126 mProp = EPropNone; 00127 } 00128 }
const uint32_t RegisterReference::KLiteralSetDefault [static] |
Initial value:
Literal set can be cached, and really should be read only.
Definition at line 186 of file RegisterReference.h.
Referenced by setDefaultProperties().
const uint32_t RegisterReference::KInputSetDefault = EPropReadOnly [static] |
Input must be read only. Caching doesn't make sense for input.
Definition at line 190 of file RegisterReference.h.
Referenced by setDefaultProperties().
const uint32_t RegisterReference::KOutputSetDefault = EPropNone [static] |
Caching doesn't make sense for output.
Definition at line 193 of file RegisterReference.h.
Referenced by setDefaultProperties().
const uint32_t RegisterReference::KLocalSetDefault [static] |
Initial value:
Local set can be cached, and must reset pointers if Calculator::exec() is to be called again and NULLs are written or pointers are moved.
Definition at line 197 of file RegisterReference.h.
Referenced by setDefaultProperties().
const uint32_t RegisterReference::KStatusSetDefault = EPropNone [static] |
Status register can be cached if it is never re-bound.
Definition at line 201 of file RegisterReference.h.
Referenced by setDefaultProperties().
const ERegisterSet RegisterReference::mSetIndex [protected] |
Register set index.
Definition at line 299 of file RegisterReference.h.
Referenced by cachePointer(), RegisterRef< char * >::length(), setCalc(), setDefaultProperties(), RegisterRef< char * >::storage(), and toString().
const unsigned long RegisterReference::mIndex [protected] |
Register index within a register set.
Definition at line 302 of file RegisterReference.h.
Referenced by cachePointer(), RegisterRef< char * >::length(), RegisterRef< char * >::storage(), and toString().
const StandardTypeDescriptorOrdinal RegisterReference::mType [protected] |
Underlying type of register.
Definition at line 305 of file RegisterReference.h.
Referenced by RegisterRef< char * >::pointer(), RegisterRef< char * >::stringLength(), and RegisterRef< char * >::valueToString().
TRegisterSetP RegisterReference::mRegisterSetP [protected] |
Array of pointers to register set bindings.
Used as starting point to index through sets and registers.
Definition at line 310 of file RegisterReference.h.
Referenced by setCalc(), and RegisterRef< char * >::storage().
Array of pointers to register set descriptors.
Used as starting point to index through sets and registers.
Definition at line 315 of file RegisterReference.h.
Referenced by cachePointer(), RegisterRef< char * >::length(), setCalc(), and RegisterRef< char * >::storage().
vector<RegisterReference *>* RegisterReference::mResetP [protected] |
RegisterReferences that will be reset before next exec.
Points to Calculator. Appended to iff PtrReset property is set.
Definition at line 320 of file RegisterReference.h.
Referenced by RegisterRef< char * >::pointer(), setCalc(), and RegisterRef< char * >::toNull().
bool RegisterReference::mCachePtrModified [protected] |
Cached pointer was set to null or moved.
Definition at line 323 of file RegisterReference.h.
Referenced by cachePointer(), RegisterRef< char * >::pointer(), and RegisterRef< char * >::toNull().
PBuffer RegisterReference::mPData [protected] |
Cached and/or duplicated data pointer.
Only valid if CachePointer or PtrReset property is set.
Definition at line 328 of file RegisterReference.h.
Referenced by cachePointer(), RegisterRef< char * >::isNull(), RegisterRef< char * >::length(), RegisterRef< char * >::pointer(), RegisterRef< char * >::refer(), RegisterRef< char * >::toNull(), and RegisterRef< char * >::value().
TupleStorageByteLength RegisterReference::mCbData [protected] |
Cached and/or duplicated length of mPData;.
Only valid if CachePointer or PtrReset property is set.
Definition at line 333 of file RegisterReference.h.
Referenced by cachePointer(), RegisterRef< char * >::length(), RegisterRef< char * >::pointer(), and RegisterRef< char * >::toNull().
TupleStorageByteLength RegisterReference::mCbStorage [protected] |
Cached and/or duplicated capacity of mPData;.
Only valid if CachePointer or PtrReset property is set.
Definition at line 338 of file RegisterReference.h.
Referenced by cachePointer(), RegisterRef< char * >::length(), and RegisterRef< char * >::storage().
TRegisterRefProp RegisterReference::mProp [protected] |
Behavior properties of this register.
Definition at line 341 of file RegisterReference.h.
Referenced by cachePointer(), RegisterRef< char * >::isNull(), RegisterRef< char * >::isNullable(), RegisterRef< char * >::length(), RegisterRef< char * >::pointer(), RegisterRef< char * >::refer(), setCalc(), setDefaultProperties(), RegisterRef< char * >::storage(), RegisterRef< char * >::toNull(), and RegisterRef< char * >::value().
The DynamicParamManager set after a call to setCalc.
Definition at line 344 of file RegisterReference.h.
Referenced by setCalc().