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:
Geoff Romer
2021-10-27 16:40:17 -07:00
committed by GitHub
parent 0da907fd2a
commit 0df9e8666c
8 changed files with 85 additions and 66 deletions
+3 -2
View File
@@ -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;
}
}