Handle identifier value category properly. (#986)

This commit is contained in:
Geoff Romer
2021-12-15 13:27:36 -08:00
committed by GitHub
parent daf8729a75
commit c89ce1d570
9 changed files with 99 additions and 48 deletions
+9
View File
@@ -15,6 +15,7 @@
#include "executable_semantics/ast/source_location.h"
#include "executable_semantics/ast/statement.h"
#include "executable_semantics/ast/static_scope.h"
#include "executable_semantics/ast/value_category.h"
#include "executable_semantics/common/nonnull.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/Support/Compiler.h"
@@ -106,6 +107,8 @@ class GenericBinding : public AstNode {
// and after typechecking it's guaranteed to be true.
auto has_static_type() const -> bool { return static_type_.has_value(); }
auto value_category() const -> ValueCategory { return ValueCategory::Let; }
private:
std::string name_;
Nonnull<Expression*> type_;
@@ -228,6 +231,8 @@ class FunctionDeclaration : public Declaration {
auto body() const -> std::optional<Nonnull<const Block*>> { return body_; }
auto body() -> std::optional<Nonnull<Block*>> { return body_; }
auto value_category() const -> ValueCategory { return ValueCategory::Let; }
private:
std::string name_;
std::vector<Nonnull<GenericBinding*>> deduced_parameters_;
@@ -253,6 +258,8 @@ class ClassDeclaration : public Declaration {
auto name() const -> const std::string& { return name_; }
auto members() const -> llvm::ArrayRef<Nonnull<Member*>> { return members_; }
auto value_category() const -> ValueCategory { return ValueCategory::Let; }
private:
std::string name_;
std::vector<Nonnull<Member*>> members_;
@@ -304,6 +311,8 @@ class ChoiceDeclaration : public Declaration {
return alternatives_;
}
auto value_category() const -> ValueCategory { return ValueCategory::Let; }
private:
std::string name_;
std::vector<Nonnull<AlternativeSignature*>> alternatives_;