Beginnings of a working compiler.
This commit is contained in:
@@ -1,9 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <ehs/Array.h>
|
||||
#include <ehs/Serializer.h>
|
||||
#include <ehs/Str.h>
|
||||
#include <ehs/Types.h>
|
||||
|
||||
#include "Token.h"
|
||||
|
||||
class Instruction;
|
||||
class Architecture;
|
||||
class Compiler;
|
||||
class Language;
|
||||
|
||||
typedef ehs::Serializer<ehs::UInt_64> (*TranslateIns)(const Instruction *, const ehs::Byte *);
|
||||
|
||||
class EHS_LIB_IO Instruction
|
||||
{
|
||||
@@ -13,23 +22,12 @@ private:
|
||||
Architecture *arch;
|
||||
ehs::UInt_64 id;
|
||||
ehs::Str_8 name;
|
||||
ehs::UInt_8 size;
|
||||
ehs::Byte *code;
|
||||
TranslateIns translation;
|
||||
|
||||
public:
|
||||
~Instruction();
|
||||
|
||||
Instruction();
|
||||
|
||||
Instruction(ehs::Str_8 name, const ehs::UInt_8 &size, ehs::Byte *code);
|
||||
|
||||
Instruction(ehs::Str_8 name, const ehs::UInt_64 &code);
|
||||
|
||||
Instruction(ehs::Str_8 name, const ehs::UInt_32 &code);
|
||||
|
||||
Instruction(ehs::Str_8 name, const ehs::UInt_16 &code);
|
||||
|
||||
Instruction(ehs::Str_8 name, const ehs::UInt_8 &code);
|
||||
Instruction(ehs::Str_8 name);
|
||||
|
||||
Instruction(Instruction &&ins) noexcept;
|
||||
|
||||
@@ -45,7 +43,32 @@ public:
|
||||
|
||||
ehs::Str_8 GetName() const;
|
||||
|
||||
ehs::UInt_8 GetSize() const;
|
||||
void SetTranslation(TranslateIns newTranslation);
|
||||
|
||||
ehs::Byte *GetCode() const;
|
||||
ehs::Serializer<ehs::UInt_64> Translate(const ehs::Byte *data) const;
|
||||
};
|
||||
|
||||
struct AssignBase
|
||||
{
|
||||
const ehs::UInt_8 type = 0;
|
||||
};
|
||||
|
||||
struct AssignRR
|
||||
{
|
||||
AssignBase base = {
|
||||
1
|
||||
};
|
||||
bool isDstAddress = false;
|
||||
ehs::UInt_64 dstReg = 0;
|
||||
bool isSrcAddress = false;
|
||||
ehs::UInt_64 srcReg = 0;
|
||||
};
|
||||
|
||||
struct AssignRI
|
||||
{
|
||||
AssignBase base = {
|
||||
2
|
||||
};
|
||||
ehs::UInt_64 dstReg = 0;
|
||||
ehs::UInt_64 srcImm = 0;
|
||||
};
|
Reference in New Issue
Block a user