summaryrefslogtreecommitdiff
path: root/frontend/result.cc
blob: aca9c5ef2c9d20dea8109171c797eac6c2cb6ae0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* Miscellaneous types used across stage boundaries.
   Copyright (C) 2025 Free Software Foundation, Inc.

GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.

GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.  */

#include "elna/frontend/result.h"

namespace elna::frontend
{
    error::error(const char *path, const struct position position)
        : position(position), path(path)
    {
    }

    std::size_t error::line() const noexcept
    {
        return this->position.line;
    }

    std::size_t error::column() const noexcept
    {
        return this->position.column;
    }

    error_container::error_container(const char *input_file)
        : input_file(input_file)
    {
    }

    std::deque<std::unique_ptr<error>>& error_container::errors()
    {
        return m_errors;
    }

    bool error_container::has_errors() const
    {
        return !m_errors.empty();
    }

    bool identifier_definition::operator==(const identifier_definition& that) const
    {
        return *this == that.name;
    }

    bool identifier_definition::operator==(const std::string& that) const
    {
        return this->name == that;
    }
}

std::size_t std::hash<elna::frontend::identifier_definition>::operator()(
        const elna::frontend::identifier_definition& key) const
{
    return std::hash<std::string>{}(key.name);
}