mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +01:00
Factor AllocationId out of Address (#916)
This lets us statically distinguish between code that works with arbitrary `Address`es and code that can only work with pointers to separately-allocated storage, and so we no longer need to worry about the latter code crashing at run-time (as `Heap::Deallocate` did) or silently doing the wrong thing (as `Heap::PrintAddress` did) if it's given the wrong kind of `Address`.
This commit is contained in:
@@ -338,8 +338,6 @@ auto ValueEqual(Nonnull<const Value*> v1, Nonnull<const Value*> v2,
|
||||
return cast<IntValue>(*v1).value() == cast<IntValue>(*v2).value();
|
||||
case Value::Kind::BoolValue:
|
||||
return cast<BoolValue>(*v1).value() == cast<BoolValue>(*v2).value();
|
||||
case Value::Kind::PointerValue:
|
||||
return cast<PointerValue>(*v1).value() == cast<PointerValue>(*v2).value();
|
||||
case Value::Kind::FunctionValue: {
|
||||
std::optional<Nonnull<const Statement*>> body1 =
|
||||
cast<FunctionValue>(*v1).declaration().body();
|
||||
@@ -396,6 +394,9 @@ auto ValueEqual(Nonnull<const Value*> v1, Nonnull<const Value*> v2,
|
||||
case Value::Kind::BindingPlaceholderValue:
|
||||
case Value::Kind::AlternativeConstructorValue:
|
||||
case Value::Kind::ContinuationValue:
|
||||
case Value::Kind::PointerValue:
|
||||
// TODO: support pointer comparisons once we have a clearer distinction
|
||||
// between pointers and lvalues.
|
||||
FATAL() << "ValueEqual does not support this kind of value: " << *v1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user