feat(solver-bootstrap): step 3 — core-ids-and-diagnostics
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
#include <fesa/core/source_location.hpp>
|
||||
|
||||
namespace fesa {
|
||||
|
||||
enum class DiagnosticStage {
|
||||
io,
|
||||
syntax,
|
||||
semantic,
|
||||
model,
|
||||
equation,
|
||||
solver,
|
||||
results,
|
||||
validation
|
||||
};
|
||||
|
||||
enum class Severity { warning, error };
|
||||
|
||||
struct Diagnostic final {
|
||||
DiagnosticStage stage;
|
||||
Severity severity;
|
||||
std::string code;
|
||||
std::string message;
|
||||
std::optional<SourceLocation> source;
|
||||
};
|
||||
|
||||
} // namespace fesa
|
||||
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include <compare>
|
||||
#include <cstdint>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace fesa {
|
||||
|
||||
template <class Tag>
|
||||
class EntityId final {
|
||||
public:
|
||||
explicit constexpr EntityId(const std::int64_t value) : value_{value} {
|
||||
if (value < 0) {
|
||||
throw std::invalid_argument{"EntityId value must not be negative."};
|
||||
}
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr std::int64_t value() const noexcept {
|
||||
return value_;
|
||||
}
|
||||
|
||||
auto operator<=>(const EntityId&) const = default;
|
||||
|
||||
private:
|
||||
std::int64_t value_;
|
||||
};
|
||||
|
||||
} // namespace fesa
|
||||
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <filesystem>
|
||||
|
||||
namespace fesa {
|
||||
|
||||
struct SourceLocation final {
|
||||
std::filesystem::path file;
|
||||
std::size_t line;
|
||||
std::size_t column;
|
||||
};
|
||||
|
||||
} // namespace fesa
|
||||
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <fesa/core/diagnostic.hpp>
|
||||
|
||||
namespace fesa {
|
||||
|
||||
struct Status final {
|
||||
bool succeeded;
|
||||
std::vector<Diagnostic> diagnostics;
|
||||
};
|
||||
|
||||
} // namespace fesa
|
||||
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace fesa {
|
||||
|
||||
struct Vec3 final {
|
||||
double x;
|
||||
double y;
|
||||
double z;
|
||||
};
|
||||
|
||||
[[nodiscard]] inline bool is_finite(const Vec3 value) noexcept {
|
||||
return std::isfinite(value.x) && std::isfinite(value.y) &&
|
||||
std::isfinite(value.z);
|
||||
}
|
||||
|
||||
} // namespace fesa
|
||||
Reference in New Issue
Block a user