fill in StructType::getDummyValue()
MODIFY
ir/instr.cpp
ir/instr.cpp
@@ -533,12 +533,10 @@ void FnCall::addArg(Value &arg) {
}
void FnCall::print(ostream &os) const {
- auto printType = [](auto &t) {
- auto type = t.toString();
- return type.empty() ? type : type + ' ';
- };
-
- os << getName() << " = call " << printType(getType()) << fnName << '(';
+ auto type = getType().toString();
+ if (!type.empty())
+ type += ' ';
+ os << getName() << " = call " << type << fnName << '(';
bool first = true;
for (auto arg : args) {

MODIFY
ir/type.cpp
ir/type.cpp
@@ -303,8 +303,18 @@ unsigned StructType::bits() const {
}
expr StructType::getDummyValue() const {
- // TODO
- return {};
+ expr res;
+ bool first = true;
+ // TODO: what if a function returns a struct with no children?
+ for (auto c : children) {
+ if (first) {
+ res = c->getDummyValue();
+ first = false;
+ } else {
+ res = res.concat(c->getDummyValue());
+ }
+ }
+ return res;
}
expr StructType::getTypeConstraints() const {

fill in StructType::getDummyValue()