-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFrame.h
More file actions
55 lines (41 loc) · 1.93 KB
/
Frame.h
File metadata and controls
55 lines (41 loc) · 1.93 KB
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
#ifndef NOBLE_COMPILER_FRAME_H_INCLUDED
#define NOBLE_COMPILER_FRAME_H_INCLUDED
#include "NobleCore/Value.h"
#include "NobleCore/List.h"
#include "NobleCore/Op.h"
#include "NobleCore/Translation.h"
using namespace Noble::Core::Runtime;
using namespace Noble::Core;
namespace Noble::Compiler
{
/// @brief Contains Noble Assembly Language Sequence (NAL) information and translation methods.
class Frame
{
public:
/// @brief Writes an op to this frame's underlying array
void WriteOp(const Op::Type& op);
/// @brief Writes an address into the frame's underlying array, returns the index of the written address
Address::Single WriteAddress(const Address::Single& address);
void WriteAddress(const Address::Single& address, const Address::Single& addressIndex);
/// @brief Writes the value to the ops array.
void WriteConstant(ValueType value);
/// @brief Returns the op at the specified address
[[nodiscard]] Op::Type ReadOp(const Address::Single& address);
/// @brief Reads ops from the specified address and returns them as an address
[[nodiscard]] Address::Single ReadAddress(const Address::Single &address) const;
/// @brief Reads a constant at the given address.
[[nodiscard]] const ValueType& ReadConstant(Address::Single address) const;
/// @brief Adds a constant to this frame
Address::Single AddConstant(ValueType value);
/// @brief Get a const ref to the ops array
[[nodiscard]] const List<Op::Type>& GetOps() const;
/// @brief Get a const ref to the constants array
[[nodiscard]] const List<ValueType>& GetConstants() const;
protected:
/// @brief Storage for reading/writing ops in the compiler
List<Op::Type> ops;
/// @brief Storage for the constants used in this frame
List<ValueType> constants;
};
}
#endif //NOBLE_COMPILER_FRAME_H_INCLUDED