Replace int lines with file-associated SourceLocations (#779)

Most interesting changes should be ast/source_location.h and syntax/parse_and_lex_context.h
This commit is contained in:
Jon Meow
2021-08-26 10:07:16 -07:00
committed by GitHub
parent 33daf64329
commit 3ec550a85f
46 changed files with 607 additions and 518 deletions
+9 -9
View File
@@ -21,21 +21,21 @@ auto Heap::AllocateValue(const Value* v) -> Address {
return a;
}
auto Heap::Read(const Address& a, int line_num) -> const Value* {
this->CheckAlive(a, line_num);
return values_[a.index]->GetField(a.field_path, line_num);
auto Heap::Read(const Address& a, SourceLocation loc) -> const Value* {
this->CheckAlive(a, loc);
return values_[a.index]->GetField(a.field_path, loc);
}
void Heap::Write(const Address& a, const Value* v, int line_num) {
void Heap::Write(const Address& a, const Value* v, SourceLocation loc) {
CHECK(v != nullptr);
this->CheckAlive(a, line_num);
values_[a.index] = values_[a.index]->SetField(a.field_path, v, line_num);
this->CheckAlive(a, loc);
values_[a.index] = values_[a.index]->SetField(a.field_path, v, loc);
}
void Heap::CheckAlive(const Address& address, int line_num) {
void Heap::CheckAlive(const Address& address, SourceLocation loc) {
if (!alive_[address.index]) {
FATAL_RUNTIME_ERROR(line_num) << "undefined behavior: access to dead value "
<< *values_[address.index];
FATAL_RUNTIME_ERROR(loc) << "undefined behavior: access to dead value "
<< *values_[address.index];
}
}