aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/operand.h
blob: f27bc94421ed1209b44db4c07140d7650ac73423 (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
/* This file is part of the sirit project.
 * Copyright (c) 2018 ReinUsesLisp
 * This software may be used and distributed according to the terms of the GNU
 * Lesser General Public License version 3 or any later version.
 */

#pragma once

#include <cstddef>
#include "common_types.h"
#include "stream.h"

namespace Sirit {

enum class OperandType { Invalid, Op, Number, String };

class Operand {
public:
    Operand();
    virtual ~Operand();

    virtual void Fetch(Stream& stream) const;
    virtual u16 GetWordCount() const;

    virtual bool operator==(const Operand& other) const;
    bool operator!=(const Operand& other) const;

    virtual std::size_t Hash() const;

    OperandType GetType() const;

protected:
    OperandType operand_type{};
};

} // namespace Sirit

namespace std {

template <>
struct hash<Sirit::Operand> {
    std::size_t operator()(const Sirit::Operand& operand) const noexcept {
        return operand.Hash();
    }
};

} // namespace std