Implement part of the AST structure
This commit is contained in:
15
src/ast/nodes/RegNode.cpp
Normal file
15
src/ast/nodes/RegNode.cpp
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
//
|
||||||
|
// Created by christoph on 21.03.23.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "RegNode.h"
|
||||||
|
|
||||||
|
RegNode::RegNode(uint8_t reg) : reg(reg) {}
|
||||||
|
|
||||||
|
auto RegNode::compile() const -> uint8_t {
|
||||||
|
if (reg > 0b110) {
|
||||||
|
throw "Compile Error: Invalid Register!";
|
||||||
|
}
|
||||||
|
|
||||||
|
return reg;
|
||||||
|
}
|
22
src/ast/nodes/RegNode.h
Normal file
22
src/ast/nodes/RegNode.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
//
|
||||||
|
// Created by christoph on 21.03.23.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef LOGISIMASSEMBLER_REGNODE_H
|
||||||
|
#define LOGISIMASSEMBLER_REGNODE_H
|
||||||
|
|
||||||
|
#include "../Node.h"
|
||||||
|
|
||||||
|
class RegNode : public Node {
|
||||||
|
public:
|
||||||
|
RegNode(uint8_t reg);
|
||||||
|
|
||||||
|
~RegNode() override = default;
|
||||||
|
|
||||||
|
[[nodiscard]] auto compile() const -> uint8_t override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint8_t reg;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //LOGISIMASSEMBLER_REGNODE_H
|
9
src/ast/nodes/RootNode.cpp
Normal file
9
src/ast/nodes/RootNode.cpp
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
//
|
||||||
|
// Created by christoph on 21.03.23.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "RootNode.h"
|
||||||
|
|
||||||
|
auto RootNode::compile() const -> uint8_t {
|
||||||
|
return 0;
|
||||||
|
}
|
19
src/ast/nodes/RootNode.h
Normal file
19
src/ast/nodes/RootNode.h
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
//
|
||||||
|
// Created by christoph on 21.03.23.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef LOGISIMASSEMBLER_ROOTNODE_H
|
||||||
|
#define LOGISIMASSEMBLER_ROOTNODE_H
|
||||||
|
|
||||||
|
#include "../Node.h"
|
||||||
|
|
||||||
|
class RootNode : public Node {
|
||||||
|
public:
|
||||||
|
RootNode() = default;
|
||||||
|
|
||||||
|
~RootNode() override = default;
|
||||||
|
|
||||||
|
[[nodiscard]] auto compile() const -> uint8_t override;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //LOGISIMASSEMBLER_ROOTNODE_H
|
Reference in New Issue
Block a user