From 70d35cf0e3dede0a9ec8ef10714a05d5fa542a4b Mon Sep 17 00:00:00 2001 From: Karutoh Date: Mon, 14 Apr 2025 00:28:12 -0700 Subject: [PATCH] Backup --- CMakeLists.txt | 11 +++++-- Main.bin | Bin 0 -> 56 bytes include/arctyx/Arctyx.h | 10 ++++++ include/arctyx/compiler/Architecture.h | 14 ++++++++- include/arctyx/compiler/Combination.h | 15 +++++++++ include/arctyx/compiler/Keyword.h | 11 +++++++ include/arctyx/compiler/Language.h | 35 +++++++++++++++++++++ include/arctyx/compiler/Token.h | 36 +++++++++++++++++++++ src/Arctyx.cpp | 13 ++++++++ src/compiler/Architecture.cpp | 42 ++++++++++++++++++++++++- src/compiler/Combination.cpp | 1 + src/compiler/Keyword.cpp | 1 + src/compiler/Language.cpp | 1 + src/compiler/Token.cpp | 37 ++++++++++++++++++++++ src/main.cpp | 13 ++++++++ 15 files changed, 236 insertions(+), 4 deletions(-) create mode 100644 Main.bin create mode 100644 include/arctyx/Arctyx.h create mode 100644 include/arctyx/compiler/Combination.h create mode 100644 include/arctyx/compiler/Keyword.h create mode 100644 include/arctyx/compiler/Language.h create mode 100644 include/arctyx/compiler/Token.h create mode 100644 src/Arctyx.cpp create mode 100644 src/compiler/Combination.cpp create mode 100644 src/compiler/Keyword.cpp create mode 100644 src/compiler/Language.cpp create mode 100644 src/compiler/Token.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 8949a28..30b61ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,9 +36,16 @@ add_library(Arctyx SHARED src/compiler/Compiler.cpp include/arctyx/compiler/Compiler.h src/compiler/Architecture.cpp include/arctyx/compiler/Architecture.h src/compiler/Instruction.cpp include/arctyx/compiler/Instruction.h + src/compiler/Language.cpp include/arctyx/compiler/Language.h + src/compiler/Token.cpp include/arctyx/compiler/Token.h + src/Arctyx.cpp include/arctyx/Arctyx.h + src/compiler/Combination.cpp + include/arctyx/compiler/Combination.h + src/compiler/Keyword.cpp + include/arctyx/compiler/Keyword.h ) -add_executable(Tools +add_executable(ArctyxTools src/main.cpp ) @@ -53,4 +60,4 @@ target_link_directories(Arctyx PUBLIC "${USER_HOME_DIRECTORY}/.local/bin") target_include_directories(Arctyx PUBLIC "${USER_HOME_DIRECTORY}/.local/include") target_link_libraries(Arctyx PUBLIC xcb xcb-cursor xcb-xfixes xcb-xinput z asound EHS_Dyn) -target_link_libraries(Tools PRIVATE Arctyx) \ No newline at end of file +target_link_libraries(ArctyxTools PRIVATE Arctyx) \ No newline at end of file diff --git a/Main.bin b/Main.bin new file mode 100644 index 0000000000000000000000000000000000000000..78776ff614a8c288cc4f8ea9d1e61ec5f71ae4b6 GIT binary patch literal 56 zcmeY`et?mIfx+YWaWK_uDhlQu;sa9rtRBY?*ns$k|AFk(oSb|eh4TEOoD@Ya0GwJ5 A + +class Arctyx +{ +private: + static void Initialize(); + + static void Uninitialize(); +}; \ No newline at end of file diff --git a/include/arctyx/compiler/Architecture.h b/include/arctyx/compiler/Architecture.h index 3513629..6af7f8e 100644 --- a/include/arctyx/compiler/Architecture.h +++ b/include/arctyx/compiler/Architecture.h @@ -11,6 +11,8 @@ private: ehs::Str_8 name; ehs::Array instructions; + static ehs::Array architectures; + public: Architecture(); @@ -24,7 +26,7 @@ public: Architecture &operator=(const Architecture &arc); - ehs::UInt_64 Id() const; + ehs::UInt_64 GetId() const; ehs::Str_8 GetName() const; @@ -37,4 +39,14 @@ public: const Instruction *GetInstruction(const ehs::Str_8 &name) const; bool AddInstruction(Instruction ins); + + static bool Has(const ehs::UInt_64 &id); + + static bool Has(const ehs::Str_8 &name); + + static const Architecture *Get(const ehs::UInt_64 &id); + + static const Architecture *Get(const ehs::Str_8 &name); + + static bool Add(Architecture arc); }; \ No newline at end of file diff --git a/include/arctyx/compiler/Combination.h b/include/arctyx/compiler/Combination.h new file mode 100644 index 0000000..b6cb593 --- /dev/null +++ b/include/arctyx/compiler/Combination.h @@ -0,0 +1,15 @@ +#pragma once + +#include + +#include "Token.h" + +class Combination +{ +private: + ehs::Array tokens; + + +public: + +}; diff --git a/include/arctyx/compiler/Keyword.h b/include/arctyx/compiler/Keyword.h new file mode 100644 index 0000000..edc2ddd --- /dev/null +++ b/include/arctyx/compiler/Keyword.h @@ -0,0 +1,11 @@ +#pragma once +#include + +#include "Instruction.h" + +class Keyword +{ +private: + ehs::Str_8 identifier; + Instruction instruction; +}; diff --git a/include/arctyx/compiler/Language.h b/include/arctyx/compiler/Language.h new file mode 100644 index 0000000..85e2abc --- /dev/null +++ b/include/arctyx/compiler/Language.h @@ -0,0 +1,35 @@ +#pragma once + +#include +#include +#include + +#include "Combination.h" + +class Language +{ +private: + ehs::UInt_64 id; + ehs::Str_8 name; + ehs::Array keywords; + ehs::Array separators; + ehs::Array interpretations; + +public: + Language(); + + Language(ehs::Str_8 name); + + Language(Language &&lang) noexcept; + + Language(const Language &lang); + + Language &operator=(Language &&lang) noexcept; + + Language &operator=(const Language &lang); + + ehs::UInt_64 GetId() const; + + ehs::Str_8 GetName() const; + +}; diff --git a/include/arctyx/compiler/Token.h b/include/arctyx/compiler/Token.h new file mode 100644 index 0000000..f18f7d7 --- /dev/null +++ b/include/arctyx/compiler/Token.h @@ -0,0 +1,36 @@ +#pragma once + +#include + +enum class TokenType : ehs::UInt_8 +{ + VALUE, + KEYWORD, + IDENTIFIER, + UNARY_OPERATOR, + COMPOUND_OPERATOR +}; + +class Token +{ +private: + TokenType type; + ehs::Str_8 value; + +public: + Token(); + + Token(TokenType type, ehs::Str_8 value); + + Token(Token &&token) noexcept; + + Token(const Token &token); + + Token &operator=(Token &&token) noexcept; + + Token &operator=(const Token &token); + + TokenType GetType() const; + + ehs::Str_8 GetValue() const; +}; diff --git a/src/Arctyx.cpp b/src/Arctyx.cpp new file mode 100644 index 0000000..7884ff6 --- /dev/null +++ b/src/Arctyx.cpp @@ -0,0 +1,13 @@ +#include "arctyx/Arctyx.h" + +#include + +#include "arctyx/compiler/Token.h" + +void Arctyx::Initialize() +{ +} + +void Arctyx::Uninitialize() +{ +} diff --git a/src/compiler/Architecture.cpp b/src/compiler/Architecture.cpp index 1126a97..82f3982 100644 --- a/src/compiler/Architecture.cpp +++ b/src/compiler/Architecture.cpp @@ -1,5 +1,7 @@ #include "arctyx/compiler/Architecture.h" +ehs::Array Architecture::architectures; + Architecture::Architecture() : id(0) { @@ -44,7 +46,7 @@ Architecture & Architecture::operator=(const Architecture &arc) return *this; } -ehs::UInt_64 Architecture::Id() const +ehs::UInt_64 Architecture::GetId() const { return id; } @@ -91,3 +93,41 @@ bool Architecture::AddInstruction(Instruction ins) return true; } + +bool Architecture::Has(const ehs::UInt_64 &id) +{ + for (ehs::UInt_64 i = 0; i < architectures.Size(); ++i) + if (architectures[i].GetId() == id) + return true; + + return false; +} + +bool Architecture::Has(const ehs::Str_8 &name) +{ + return Has(name.Hash_64()); +} + +const Architecture *Architecture::Get(const ehs::UInt_64 &id) +{ + for (ehs::UInt_64 i = 0; i < architectures.Size(); ++i) + if (architectures[i].GetId() == id) + return &architectures[i]; + + return nullptr; +} + +const Architecture *Architecture::Get(const ehs::Str_8 &name) +{ + return Get(name.Hash_64()); +} + +bool Architecture::Add(Architecture arc) +{ + if (Has(arc.GetId())) + return false; + + architectures.Push((Architecture &&)arc); + + return true; +} diff --git a/src/compiler/Combination.cpp b/src/compiler/Combination.cpp new file mode 100644 index 0000000..6eb5fdc --- /dev/null +++ b/src/compiler/Combination.cpp @@ -0,0 +1 @@ +#include "arctyx/compiler/Combination.h" diff --git a/src/compiler/Keyword.cpp b/src/compiler/Keyword.cpp new file mode 100644 index 0000000..f89ccbb --- /dev/null +++ b/src/compiler/Keyword.cpp @@ -0,0 +1 @@ +#include "arctyx/compiler/Keyword.h" \ No newline at end of file diff --git a/src/compiler/Language.cpp b/src/compiler/Language.cpp new file mode 100644 index 0000000..5f41894 --- /dev/null +++ b/src/compiler/Language.cpp @@ -0,0 +1 @@ +#include "arctyx/compiler/Language.h" \ No newline at end of file diff --git a/src/compiler/Token.cpp b/src/compiler/Token.cpp new file mode 100644 index 0000000..c148512 --- /dev/null +++ b/src/compiler/Token.cpp @@ -0,0 +1,37 @@ +#include "arctyx/compiler/Token.h" + +Token::Token() +{ +} + +Token::Token(TokenType type, ehs::Str_8 value) +{ +} + +Token::Token(Token &&token) noexcept +{ +} + +Token::Token(const Token &token) +{ +} + +Token & Token::operator=(Token &&token) noexcept +{ + return *this; +} + +Token & Token::operator=(const Token &token) +{ + return *this; +} + +TokenType Token::GetType() const +{ + return type; +} + +ehs::Str_8 Token::GetValue() const +{ + return {}; +} diff --git a/src/main.cpp b/src/main.cpp index 879e39b..a8c9cbf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,6 +5,19 @@ #include #include +struct Foo +{ + bool a; + ehs::UInt_64 b; + ehs::UInt_16 c; +}; + +struct Bar +{ + Foo a; + ehs::Char_8 b[128]; +}; + int main() { ehs::Initialize("Arctyx", "Alpha", {1, 0, 0});