Files
Fig/src/Core/SourceLocations.hpp
2026-02-17 14:13:57 +08:00

59 lines
1.6 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*!
@file src/Core/SourceLocations
@brief SourcePosition + SourceLocation定义全局代码定位
@author PuqiAR (im@puqiar.top)
@date 2026-02-14
*/
#pragma once
#include <Deps/Deps.hpp>
namespace Fig
{
struct SourcePosition
{
size_t line, column, tok_length;
SourcePosition() { line = column = tok_length = 0; }
SourcePosition(size_t _line, size_t _column, size_t _tok_length)
{
line = _line;
column = _column;
tok_length = _tok_length;
}
};
struct SourceLocation
{
SourcePosition sp;
Deps::String fileName;
Deps::String packageName;
Deps::String functionName;
SourceLocation() {}
SourceLocation(SourcePosition _sp,
Deps::String _fileName,
Deps::String _packageName,
Deps::String _functionName)
{
sp = std::move(_sp);
fileName = std::move(_fileName);
packageName = std::move(_packageName);
functionName = std::move(_functionName);
}
SourceLocation(size_t line,
size_t column,
size_t tok_length,
Deps::String _fileName,
Deps::String _packageName,
Deps::String _functionName)
{
sp = SourcePosition(line, column, tok_length);
fileName = std::move(_fileName);
packageName = std::move(_packageName);
functionName = std::move(_functionName);
}
};
}; // namespace Fig