Implement IndirectValue (#588)

Also updates `FieldAccess` to use `IndirectValue`, as an example.
This commit is contained in:
Geoff Romer
2021-06-24 11:26:28 -07:00
committed by GitHub
parent 85cfb3b930
commit 6ca6822157
8 changed files with 265 additions and 7 deletions
+2 -2
View File
@@ -162,7 +162,7 @@ auto Expression::MakeGetField(int line_num, const Expression* exp,
std::string field) -> const Expression* {
auto* e = new Expression();
e->line_num = line_num;
e->value = FieldAccess({.aggregate = exp, .field = std::move(field)});
e->value = FieldAccess({.aggregate = *exp, .field = std::move(field)});
return e;
}
@@ -258,7 +258,7 @@ void PrintExp(const Expression* e) {
std::cout << "]";
break;
case ExpressionKind::GetField:
PrintExp(e->GetFieldAccess().aggregate);
PrintExp(e->GetFieldAccess().aggregate.GetPointer());
std::cout << ".";
std::cout << e->GetFieldAccess().field;
break;