5 #ifndef V8_TORQUE_SOURCE_POSITIONS_H_ 6 #define V8_TORQUE_SOURCE_POSITIONS_H_ 10 #include "src/torque/contextual.h" 18 explicit SourceId(
int id) : id_(
id) {}
29 DECLARE_CONTEXTUAL_VARIABLE(CurrentSourceFile,
SourceId)
35 static const std::string& GetSource(
SourceId source) {
36 return Get().sources_[source.id_];
39 static SourceId AddSource(std::string path) {
40 Get().sources_.push_back(std::move(path));
41 return SourceId(static_cast<int>(Get().sources_.size()) - 1);
45 std::vector<std::string> sources_;
49 return SourceFileMap::GetSource(pos.source) +
":" +
50 std::to_string(pos.line + 1) +
":" + std::to_string(pos.column + 1);
53 inline std::ostream& operator<<(std::ostream& out,
SourcePosition pos) {
54 return out << PositionAsString(pos);
61 #endif // V8_TORQUE_SOURCE_POSITIONS_H_