if (LHS != lhs)
return (UnOpInit::get(getOpcode(), lhs, getType()))
->Fold(R.getCurrentRecord());
- return Fold(R.getCurrentRecord());
+ return const_cast<UnOpInit *>(this);
}
std::string UnOpInit::getAsString() const {
if (LHS != lhs || RHS != rhs)
return (BinOpInit::get(getOpcode(), lhs, rhs, getType()))
->Fold(R.getCurrentRecord());
- return Fold(R.getCurrentRecord());
+ return const_cast<BinOpInit *>(this);
}
std::string BinOpInit::getAsString() const {
if (LHS != lhs || MHS != mhs || RHS != rhs)
return (TernOpInit::get(getOpcode(), lhs, mhs, rhs, getType()))
->Fold(R.getCurrentRecord());
- return Fold(R.getCurrentRecord());
+ return const_cast<TernOpInit *>(this);
}
std::string TernOpInit::getAsString() const {
}
if (LHS->getType() != StringRecTy::get()) {
- LHS = UnOpInit::get(UnOpInit::CAST, LHS, StringRecTy::get());
+ LHS = dyn_cast<TypedInit>(
+ UnOpInit::get(UnOpInit::CAST, LHS, StringRecTy::get())
+ ->Fold(CurRec));
+ if (!LHS) {
+ Error(PasteLoc, Twine("can't cast '") + LHS->getAsString() +
+ "' to string");
+ return nullptr;
+ }
}
TypedInit *RHS = nullptr;
}
if (RHS->getType() != StringRecTy::get()) {
- RHS = UnOpInit::get(UnOpInit::CAST, RHS, StringRecTy::get());
+ RHS = dyn_cast<TypedInit>(
+ UnOpInit::get(UnOpInit::CAST, RHS, StringRecTy::get())
+ ->Fold(CurRec));
+ if (!RHS) {
+ Error(PasteLoc, Twine("can't cast '") + RHS->getAsString() +
+ "' to string");
+ return nullptr;
+ }
}
break;