2024-12-27 10:51:46 +01:00
|
|
|
// This Source Code Form is subject to the terms of the Mozilla Public License
|
|
|
|
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
|
|
|
// obtain one at http://mozilla.org/MPL/2.0/.
|
2024-12-23 13:54:11 +01:00
|
|
|
#include "elna/source/result.h"
|
2024-12-21 00:08:48 +01:00
|
|
|
|
2024-12-23 13:54:11 +01:00
|
|
|
namespace elna
|
|
|
|
{
|
|
|
|
namespace source
|
2024-12-21 00:08:48 +01:00
|
|
|
{
|
2024-12-27 10:51:46 +01:00
|
|
|
error::error(const char *path, const position position)
|
|
|
|
: m_position(position), path(path)
|
2024-12-21 00:08:48 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
std::size_t error::line() const noexcept
|
|
|
|
{
|
|
|
|
return this->m_position.line;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::size_t error::column() const noexcept
|
|
|
|
{
|
|
|
|
return this->m_position.column;
|
|
|
|
}
|
|
|
|
|
2024-12-27 10:51:46 +01:00
|
|
|
name_collision::name_collision(const std::string& name, const char *path,
|
2024-12-21 14:05:27 +01:00
|
|
|
const position current, const position previous)
|
|
|
|
: error(path, current), name(name), previous(previous)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string name_collision::what() const
|
|
|
|
{
|
|
|
|
return "Name '" + name + "' was already defined";
|
|
|
|
}
|
|
|
|
|
2024-12-23 13:54:11 +01:00
|
|
|
type_mismatch::type_mismatch(std::shared_ptr<const type> got, operation kind,
|
2024-12-27 10:51:46 +01:00
|
|
|
const char *path, const struct position position)
|
2024-12-21 14:05:27 +01:00
|
|
|
: error(path, position), kind(kind), got(got)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string type_mismatch::what() const
|
|
|
|
{
|
|
|
|
return "Type cannot be used here.";
|
|
|
|
}
|
2024-12-21 00:08:48 +01:00
|
|
|
}
|
2024-12-23 13:54:11 +01:00
|
|
|
}
|