This commit is contained in:
2025-04-27 10:34:53 -07:00
parent 70d35cf0e3
commit ba08245e02
25 changed files with 551 additions and 77 deletions

View File

@@ -1,7 +1,8 @@
#pragma once
#include <ehs/Types.h>
class Arctyx
class EHS_LIB_IO Arctyx
{
private:
static void Initialize();

View File

@@ -4,14 +4,16 @@
#include "Instruction.h"
class Architecture
class EHS_LIB_IO Architecture
{
private:
friend class Arctyx;
ehs::UInt_64 id;
ehs::Str_8 name;
ehs::Array<Instruction> instructions;
static ehs::Array<Architecture> architectures;
static ehs::Array<const Architecture *> architectures;
public:
Architecture();

View File

@@ -1,15 +0,0 @@
#pragma once
#include <ehs/Array.h>
#include "Token.h"
class Combination
{
private:
ehs::Array<TokenType> tokens;
public:
};

View File

@@ -1 +1,21 @@
#pragma once
#pragma once
#include <ehs/Array.h>
#include <ehs/Serializer.h>
#include "Architecture.h"
#include "Language.h"
#include "Symbol.h"
class Compiler
{
private:
const Architecture *architecture;
const Language *language;
ehs::Array<Symbol> symbols;
public:
Compiler();
Compiler(const Architecture *arch, const Language *lang);
};

View File

@@ -1,10 +1,16 @@
#pragma once
#include <ehs/Str.h>
#include <ehs/Types.h>
class Instruction
class Architecture;
class EHS_LIB_IO Instruction
{
private:
friend class Architecture;
Architecture *arch;
ehs::UInt_64 id;
ehs::Str_8 name;
ehs::UInt_8 size;
@@ -33,6 +39,8 @@ public:
Instruction &operator=(const Instruction &ins);
const Architecture *GetArchitecture() const;
ehs::UInt_64 GetId() const;
ehs::Str_8 GetName() const;

View File

@@ -0,0 +1,27 @@
#pragma once
#include <ehs/Array.h>
#include "Instruction.h"
#include "Token.h"
class EHS_LIB_IO Interpretation : public Token
{
private:
Instruction result;
public:
Interpretation() = default;
Interpretation(const TokenT &type, ehs::Str_8 value, Instruction result);
Interpretation(Interpretation &&other) noexcept;
Interpretation(const Interpretation &other);
Interpretation &operator=(Interpretation &&other) noexcept;
Interpretation &operator=(const Interpretation &other);
Instruction GetResult() const;
};

View File

@@ -3,7 +3,7 @@
#include "Instruction.h"
class Keyword
class EHS_LIB_IO Keyword
{
private:
ehs::Str_8 identifier;

View File

@@ -3,22 +3,28 @@
#include <ehs/Array.h>
#include <ehs/Str.h>
#include <ehs/Types.h>
#include <ehs/Version.h>
#include "Combination.h"
#include "Interpretation.h"
class Language
class EHS_LIB_IO Language
{
private:
friend class Arctyx;
ehs::UInt_64 id;
ehs::Str_8 name;
ehs::Array<ehs::Str_8> keywords;
ehs::Version version;
ehs::Char_8 eol;
ehs::Array<ehs::Char_8> separators;
ehs::Array<Combination> interpretations;
ehs::Array<Interpretation> interpretations;
static ehs::Array<const Language *> languages;
public:
Language();
Language(ehs::Str_8 name);
Language(ehs::Str_8 name, const ehs::Version &version);
Language(Language &&lang) noexcept;
@@ -32,4 +38,34 @@ public:
ehs::Str_8 GetName() const;
ehs::Version GetVersion() const;
void SetEOL(const ehs::Char_8 &newEOL);
ehs::Char_8 GetEOL() const;
ehs::Array<ehs::Char_8> GetSeparators() const;
bool HasSeparator(const ehs::Char_8 &separator) const;
bool AddSeparator(const ehs::Char_8 &separator);
ehs::Array<Interpretation> GetInterpretations() const;
bool HasInterpretation(const TokenT &type, const ehs::Str_8 &name) const;
const Interpretation *GetInterpretation(const TokenT &type, const ehs::Str_8 &name) const;
bool AddInterpretation(Interpretation interpretation);
static bool Has(const ehs::UInt_64 &id);
static bool Has(const ehs::Str_8 &name);
static const Language *Get(const ehs::UInt_64 &id);
static const Language *Get(const ehs::Str_8 &name);
static bool Add(Language lang);
};

View File

@@ -0,0 +1,44 @@
#pragma once
#include <ehs/Str.h>
#include <ehs/Types.h>
enum class SymbolType
{
UNKNOWN,
VARIABLE,
FUNCTION,
CLASS,
MEMBER,
METHOD
};
class Symbol
{
private:
SymbolType type;
ehs::UInt_64 id;
ehs::Str_8 name;
ehs::UInt_64 address;
public:
Symbol();
Symbol(const SymbolType &type, ehs::Str_8 name, const ehs::UInt_64 &address);
Symbol(Symbol &&other) noexcept;
Symbol(const Symbol &other);
Symbol &operator=(Symbol &&other) noexcept;
Symbol &operator=(const Symbol &other);
SymbolType GetType() const;
ehs::Str_8 GetName() const;
ehs::UInt_64 GetId() const;
ehs::UInt_64 GetAddress() const;
};

View File

@@ -2,8 +2,9 @@
#include <ehs/Str.h>
enum class TokenType : ehs::UInt_8
enum class TokenT : ehs::UInt_8
{
UNKNOWN,
VALUE,
KEYWORD,
IDENTIFIER,
@@ -11,16 +12,16 @@ enum class TokenType : ehs::UInt_8
COMPOUND_OPERATOR
};
class Token
class EHS_LIB_IO Token
{
private:
TokenType type;
TokenT type;
ehs::Str_8 value;
public:
Token();
Token(TokenType type, ehs::Str_8 value);
Token(const TokenT &type, ehs::Str_8 value);
Token(Token &&token) noexcept;
@@ -30,7 +31,7 @@ public:
Token &operator=(const Token &token);
TokenType GetType() const;
TokenT GetType() const;
ehs::Str_8 GetValue() const;
};

View File

@@ -17,7 +17,7 @@
#define ELF_64_BIT_HEADER_SIZE 64
#define ELF_32_BIT_HEADER_SIZE 52
class ELF
class EHS_LIB_IO ELF
{
private:
ehs::UInt_8 bitDepth;

View File

@@ -14,7 +14,7 @@
class ELF;
class ELF_Program
class EHS_LIB_IO ELF_Program
{
private:
friend class ELF;

View File

@@ -17,7 +17,7 @@
#define SECH_SIZE 64
class ELF_Section
class EHS_LIB_IO ELF_Section
{
private:
friend class ELF;

View File

@@ -74,7 +74,7 @@
#define SYMH_SIZE 24
class ELF_Sym
class EHS_LIB_IO ELF_Sym
{
private:
ehs::UInt_32 nameOffset;