ComplexAPFloat() : Real(0.0), Imag(0.0) {}
};
- struct LValue {
+ struct LV {
Expr* Base;
uint64_t Offset;
};
APValue(const APValue &RHS) : Kind(Uninitialized) {
*this = RHS;
}
+ APValue(Expr* B, uint64_t O) : Kind(Uninitialized) {
+ MakeLValue(); setLValue(B, O);
+ }
~APValue() {
MakeUninit();
}
bool isFloat() const { return Kind == Float; }
bool isComplexSInt() const { return Kind == ComplexSInt; }
bool isComplexFloat() const { return Kind == ComplexFloat; }
+ bool isLValue() const { return Kind == LValue; }
const APSInt &getSInt() const {
assert(isSInt() && "Invalid accessor");
assert(isComplexFloat() && "Invalid accessor");
return ((const ComplexAPFloat*)(const void*)Data)->Imag;
}
+ Expr* getLValueBase() const {
+ assert(isLValue() && "Invalid accessor");
+ return ((const LV*)(const void*)Data)->Base;
+ }
+ uint64_t getLValueOffset() const {
+ assert(isLValue() && "Invalid accessor");
+ return ((const LV*)(const void*)Data)->Offset;
+ }
void setSInt(const APSInt &I) {
assert(isSInt() && "Invalid accessor");
((ComplexAPFloat*)(void*)Data)->Real = R;
((ComplexAPFloat*)(void*)Data)->Imag = I;
}
+ void setLValue(Expr *B, uint64_t O) {
+ assert(isLValue() && "Invalid accessor");
+ ((LV*)(void*)Data)->Base = B;
+ ((LV*)(void*)Data)->Offset = O;
+ }
const APValue &operator=(const APValue &RHS) {
if (Kind != RHS.Kind) {
MakeComplexSInt();
else if (RHS.isComplexFloat())
MakeComplexFloat();
+ else if (RHS.isLValue())
+ MakeLValue();
}
if (isSInt())
setSInt(RHS.getSInt());
setComplexSInt(RHS.getComplexSIntReal(), RHS.getComplexSIntImag());
else if (isComplexFloat())
setComplexFloat(RHS.getComplexFloatReal(), RHS.getComplexFloatImag());
+ else if (isLValue())
+ setLValue(RHS.getLValueBase(), RHS.getLValueOffset());
return *this;
}
((ComplexAPSInt*)(void*)Data)->~ComplexAPSInt();
else if (Kind == ComplexFloat)
((ComplexAPFloat*)(void*)Data)->~ComplexAPFloat();
+ else if (Kind == LValue) {
+ ((LV*)(void*)Data)->~LV();
+ }
}
void MakeSInt() {
assert(isUninit() && "Bad state change");
new ((ComplexAPFloat*)(void*)Data) ComplexAPFloat();
Kind = ComplexFloat;
}
+ void MakeLValue() {
+ assert(isUninit() && "Bad state change");
+ new ((LV*)(void*)Data) LV();
+ Kind = LValue;
+ }
};
}