Support for as operator and user-defined As impls. (#1476)

This commit is contained in:
Richard Smith
2022-07-21 13:16:18 -07:00
committed by GitHub
parent a96ae98155
commit 93e19649aa
20 changed files with 208 additions and 12 deletions
+9
View File
@@ -176,6 +176,15 @@ auto ActionStack::Spawn(std::unique_ptr<Action> child, RuntimeScope scope)
return Success();
}
auto ActionStack::ReplaceWith(std::unique_ptr<Action> replacement)
-> ErrorOr<Success> {
std::unique_ptr<Action> old = todo_.Pop();
CARBON_CHECK(replacement->kind() == old->kind())
<< "ReplaceWith can't change action kind";
todo_.Push(std::move(replacement));
return Success();
}
auto ActionStack::RunAgain() -> ErrorOr<Success> {
Action& action = *todo_.Top();
action.set_pos(action.pos() + 1);