mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 10:21:04 +01:00
Store named constant values in the AST (#1011)
This enables us to stop using `Env` in the typechecker. As a byproduct, this commit also restructures the interpreter to handle run-time global initialization as part of ordinary execution, using the Action stack.
This commit is contained in:
@@ -61,6 +61,7 @@ class Pattern : public AstNode {
|
||||
auto has_static_type() const -> bool { return static_type_.has_value(); }
|
||||
|
||||
// The value of this pattern. Cannot be called before typechecking.
|
||||
// TODO rename to avoid confusion with BindingPattern::constant_value
|
||||
auto value() const -> const Value& { return **value_; }
|
||||
|
||||
// Sets the value of this pattern. Can only be called once, during
|
||||
@@ -122,6 +123,10 @@ class BindingPattern : public Pattern {
|
||||
|
||||
auto value_category() const -> ValueCategory { return ValueCategory::Var; }
|
||||
|
||||
auto constant_value() const -> std::optional<Nonnull<const Value*>> {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string name_;
|
||||
Nonnull<Pattern*> type_;
|
||||
|
||||
Reference in New Issue
Block a user