Change Alternative to a class (#853)

Revives BisonWrap because this seems a reasonable use of it (avoiding the need to have an std::optional or pointer for Alternative, both of which I thought could be unclear about the intent).
This commit is contained in:
Jon Meow
2021-09-27 09:05:22 -07:00
committed by GitHub
parent 6ab2bff69c
commit 721743bc58
7 changed files with 84 additions and 22 deletions
@@ -151,9 +151,9 @@ void Interpreter::InitEnv(const Declaration& d, Env* env) {
case Declaration::Kind::ChoiceDeclaration: {
const auto& choice = cast<ChoiceDeclaration>(d);
VarValues alts;
for (const auto& [name, signature] : choice.Alternatives()) {
auto t = InterpExp(Env(arena), signature);
alts.push_back(make_pair(name, t));
for (const auto& alternative : choice.Alternatives()) {
auto t = InterpExp(Env(arena), &alternative.signature());
alts.push_back(make_pair(alternative.name(), t));
}
auto ct = arena->New<ChoiceType>(choice.Name(), std::move(alts));
auto a = heap.AllocateValue(ct);