Skip to content

Commit

Permalink
Fix indentation in source-manager.
Browse files Browse the repository at this point in the history
  • Loading branch information
dvander committed Sep 29, 2023
1 parent c646997 commit 8ad5a00
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 59 deletions.
13 changes: 0 additions & 13 deletions compiler/source-location.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,3 @@ class SourceLocation
private:
uint32_t id_;
};

struct SourceRange
{
SourceLocation start;
SourceLocation end;

SourceRange()
{}
SourceRange(const SourceLocation& start, const SourceLocation& end)
: start(start),
end(end)
{}
};
2 changes: 1 addition & 1 deletion compiler/source-manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ std::shared_ptr<SourceFile> SourceManager::Open(const std::string& path,
{
auto file = std::make_shared<SourceFile>();
if (!file->Open(path))
return nullptr;
return nullptr;

size_t loc_index;
if (!TrackExtents(file->size(), &loc_index)) {
Expand Down
90 changes: 45 additions & 45 deletions compiler/source-manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,56 +45,56 @@ struct token_pos_t {
// trackFile() or trackMacro().
struct LREntry
{
// Starting id for this source range.
uint32_t id;
// Starting id for this source range.
uint32_t id;

private:
// If we're creating a range from an #include, this is the location in the
// parent file we were #included from, if any.
//
// If we're creating a range for macro insertion, this is where we started
// inserting tokens.
SourceLocation parent_;
// If we're creating a range from an #include, this is the location in the
// parent file we were #included from, if any.
//
// If we're creating a range for macro insertion, this is where we started
// inserting tokens.
SourceLocation parent_;

// If we included from a file, this is where we included.
std::shared_ptr<SourceFile> file_;
// If we included from a file, this is where we included.
std::shared_ptr<SourceFile> file_;

public:
LREntry()
: id(0)
{}

bool valid() const {
return id != 0;
}

void init(const SourceLocation& parent, std::shared_ptr<SourceFile> file) {
this->parent_ = parent;
this->file_ = std::move(file);
}

std::shared_ptr<SourceFile> file() const {
return file_;
}
const SourceLocation& parent() const {
return parent_;
}

uint32_t length() const {
return file_->size();
}

bool owns(const SourceLocation& loc) const {
if (loc.offset() >= id && loc.offset() <= id + length())
return true;
return false;
}

SourceLocation FilePos(uint32_t offset) const {
assert(file_);
assert(offset <= file_->size());
return SourceLocation::FromFile(id, offset);
}
LREntry()
: id(0)
{}

bool valid() const {
return id != 0;
}

void init(const SourceLocation& parent, std::shared_ptr<SourceFile> file) {
this->parent_ = parent;
this->file_ = std::move(file);
}

std::shared_ptr<SourceFile> file() const {
return file_;
}
const SourceLocation& parent() const {
return parent_;
}

uint32_t length() const {
return file_->size();
}

bool owns(const SourceLocation& loc) const {
if (loc.offset() >= id && loc.offset() <= id + length())
return true;
return false;
}

SourceLocation FilePos(uint32_t offset) const {
assert(file_);
assert(offset <= file_->size());
return SourceLocation::FromFile(id, offset);
}
};

class SourceManager final
Expand Down

0 comments on commit 8ad5a00

Please sign in to comment.