Unify Action and Scope stacks, and eliminate Frame (#880)

Co-authored-by: Jon Meow <46229924+jonmeow@users.noreply.github.com>
This commit is contained in:
Geoff Romer
2021-10-21 14:55:41 -07:00
committed by GitHub
co-authored by Jon Meow
parent 44154c8663
commit 3bec7f8dc0
13 changed files with 450 additions and 329 deletions
+7 -7
View File
@@ -21,6 +21,8 @@
namespace Carbon {
class Action;
// Abstract base class of all AST nodes representing values.
//
// Value and its derived classes support LLVM-style RTTI, including
@@ -106,8 +108,6 @@ struct StructElement {
Nonnull<const Value*> value;
};
struct Frame; // Used by continuation.
// An integer value.
class IntValue : public Value {
public:
@@ -489,21 +489,21 @@ class VariableType : public Value {
// fragment, which is exposed by `Stack()`.
class ContinuationValue : public Value {
public:
explicit ContinuationValue(Nonnull<std::vector<Nonnull<Frame*>>*> stack)
explicit ContinuationValue(Nonnull<std::vector<Nonnull<Action*>>*> stack)
: Value(Kind::ContinuationValue), stack_(stack) {}
static auto classof(const Value* value) -> bool {
return value->kind() == Kind::ContinuationValue;
}
// The call stack of the suspended continuation, starting with the top
// frame (the reverse of the usual order). Note that this provides mutable
// The todo stack of the suspended continuation, starting with the top
// Action (the reverse of the usual order). Note that this provides mutable
// access, even when *this is const, because of the reference-like semantics
// of ContinuationValue.
auto stack() const -> std::vector<Nonnull<Frame*>>& { return *stack_; }
auto stack() const -> std::vector<Nonnull<Action*>>& { return *stack_; }
private:
Nonnull<std::vector<Nonnull<Frame*>>*> stack_;
Nonnull<std::vector<Nonnull<Action*>>*> stack_;
};
// The String type.