mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 18:21:16 +01:00
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:
committed by
GitHub
co-authored by
Jon Meow
parent
44154c8663
commit
3bec7f8dc0
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user