mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Clarify and simplify handling of lvalues (#956)
- Rename `PointerValue` to `LValue` to reflect how it's actually used. We can introduce a `PointerValue` type when we add support for actual pointer values. - Remove support for pattern assignment. It's unclear if Carbon will support this, and even if we do, it raises questions that should first be addressed in a language proposal, like "is the left-hand side of `(x, y) = (1, 2)` an lvalue, or a pattern, or both, or something else entirely?"
This commit is contained in:
@@ -36,7 +36,7 @@ class Value {
|
||||
enum class Kind {
|
||||
IntValue,
|
||||
FunctionValue,
|
||||
PointerValue,
|
||||
LValue,
|
||||
BoolValue,
|
||||
StructValue,
|
||||
NominalClassValue,
|
||||
@@ -132,17 +132,17 @@ class FunctionValue : public Value {
|
||||
Nonnull<const FunctionDeclaration*> declaration_;
|
||||
};
|
||||
|
||||
// A pointer value.
|
||||
class PointerValue : public Value {
|
||||
// The value of a location in memory.
|
||||
class LValue : public Value {
|
||||
public:
|
||||
explicit PointerValue(Address value)
|
||||
: Value(Kind::PointerValue), value_(std::move(value)) {}
|
||||
explicit LValue(Address value)
|
||||
: Value(Kind::LValue), value_(std::move(value)) {}
|
||||
|
||||
static auto classof(const Value* value) -> bool {
|
||||
return value->kind() == Kind::PointerValue;
|
||||
return value->kind() == Kind::LValue;
|
||||
}
|
||||
|
||||
auto value() const -> const Address& { return value_; }
|
||||
auto address() const -> const Address& { return value_; }
|
||||
|
||||
private:
|
||||
Address value_;
|
||||
|
||||
Reference in New Issue
Block a user