mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 11:11:05 +01:00
Switch Value to Ptr (#799)
Co-authored-by: Geoff Romer <gromer@google.com>
This commit is contained in:
committed by
GitHub
co-authored by
Geoff Romer
parent
31b4f1e7ac
commit
0601f5620b
@@ -9,25 +9,23 @@
|
||||
|
||||
namespace Carbon {
|
||||
|
||||
auto Heap::AllocateValue(const Value* v) -> Address {
|
||||
auto Heap::AllocateValue(Ptr<const Value> v) -> Address {
|
||||
// Putting the following two side effects together in this function
|
||||
// ensures that we don't do anything else in between, which is really bad!
|
||||
// Consider whether to include a copy of the input v in this function
|
||||
// or to leave it up to the caller.
|
||||
CHECK(v != nullptr);
|
||||
Address a(values_.size());
|
||||
values_.push_back(v);
|
||||
alive_.push_back(true);
|
||||
return a;
|
||||
}
|
||||
|
||||
auto Heap::Read(const Address& a, SourceLocation loc) -> const Value* {
|
||||
auto Heap::Read(const Address& a, SourceLocation loc) -> Ptr<const Value> {
|
||||
this->CheckAlive(a, loc);
|
||||
return values_[a.index]->GetField(a.field_path, loc);
|
||||
}
|
||||
|
||||
void Heap::Write(const Address& a, const Value* v, SourceLocation loc) {
|
||||
CHECK(v != nullptr);
|
||||
void Heap::Write(const Address& a, Ptr<const Value> v, SourceLocation loc) {
|
||||
this->CheckAlive(a, loc);
|
||||
values_[a.index] = values_[a.index]->SetField(a.field_path, v, loc);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user