Skip to content

Commit

Permalink
Update file structure
Browse files Browse the repository at this point in the history
  • Loading branch information
DolphyWind committed May 24, 2024
1 parent b8a587c commit 18eff00
Show file tree
Hide file tree
Showing 64 changed files with 201 additions and 155 deletions.
40 changes: 39 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,45 @@ if(NOT DEFINED CMAKE_BUILD_TYPE)
endif()
project(ElectraLang VERSION 1.0.0)

file(GLOB SOURCE_FILES "./src/*.cpp")
set(SOURCE_FILES
src/components/ArithmeticalUnit.cpp
src/components/Bomb.cpp
src/components/Cable.cpp
src/components/Cloner.cpp
src/components/CloningDynamicComponent.cpp
src/components/Component.cpp
src/components/ConditionalUnit.cpp
src/components/ConstantAdder.cpp
src/components/ConstantPusher.cpp
src/components/Eraser.cpp
src/components/FileCloser.cpp
src/components/FileOpener.cpp
src/components/FileReader.cpp
src/components/FileWriter.cpp
src/components/Key.cpp
src/components/NonCloningDynamicComponent.cpp
src/components/Portal.cpp
src/components/Printer.cpp
src/components/Reader.cpp
src/components/Reverser.cpp
src/components/StackChecker.cpp
src/components/StackSwitcher.cpp
src/components/Swapper.cpp

src/utility/Argparser.cpp
src/utility/FileDescriptorManager.cpp
src/utility/Global.cpp
src/utility/LineRange.cpp
src/utility/Logger.cpp
src/utility/StringUtilities.cpp

src/Current.cpp
src/Direction.cpp
src/Electra.cpp
src/Generator.cpp
src/main.cpp
)

add_executable(${TARGET_BINARY_NAME} ${SOURCE_FILES})

target_include_directories(${TARGET_BINARY_NAME} PUBLIC include)
Expand Down
6 changes: 3 additions & 3 deletions include/Current.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ SOFTWARE.
#include <memory>
#include <optional>

#include "Direction.hpp"
#include "Global.hpp"
#include <Direction.hpp>
#include <utility/Global.hpp>

// Instruction pointers of Electra
class Current
Expand Down Expand Up @@ -58,4 +58,4 @@ class Current
Direction m_direction = Direction::NONE;
Position m_position = {0, 0};
std::stack<Position> m_visitedPortalStack{};
};
};
8 changes: 4 additions & 4 deletions include/Electra.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ SOFTWARE.
#include <unordered_map>
#include <set>

#include <Component.hpp>
#include <components/Component.hpp>
#include <Generator.hpp>
#include <LineRange.hpp>
#include <ComponentInformation.hpp>
#include <utility/LineRange.hpp>
#include <utility/ComponentInformation.hpp>
#include <thirdparty/dylib/dylib.hpp>

typedef std::vector<Direction> GeneratorData;
Expand Down Expand Up @@ -148,4 +148,4 @@ class Electra

// Signal handling.
static void sigHandler([[maybe_unused]] int signal);
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ SOFTWARE.
#pragma once
#include <functional>

#include <Cable.hpp>
#include <components/Cable.hpp>

// Pops 2 values from current's stackPtr and passes them into m_func. Then pushes result back to the same stack.
// The first parameter that is popped is the first argument of m_func
Expand All @@ -41,4 +41,4 @@ class ArithmeticalUnit : public Cable
bool work(Current::Ptr current, std::vector<Current::Ptr>& currentVector) override;
private:
ArithmeticalFunc m_func;
};
};
4 changes: 2 additions & 2 deletions include/Bomb.hpp → include/components/Bomb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SOFTWARE.
*/

#pragma once
#include <Cable.hpp>
#include <components/Cable.hpp>

// Ends the program.
class Bomb : public Cable
Expand All @@ -33,4 +33,4 @@ class Bomb : public Cable
~Bomb() override = default;

bool work(Current::Ptr current, std::vector<Current::Ptr>& currentVector) override;
};
};
4 changes: 2 additions & 2 deletions include/Cable.hpp → include/components/Cable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SOFTWARE.
*/

#pragma once
#include <Component.hpp>
#include <components/Component.hpp>

// Clones the currents if the cable is multi-directional.
class Cable : public Component
Expand All @@ -35,4 +35,4 @@ class Cable : public Component
bool work(Current::Ptr current, std::vector<Current::Ptr>& currentVector) override;
private:
bool m_is_one_directional = false;
};
};
4 changes: 2 additions & 2 deletions include/Cloner.hpp → include/components/Cloner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SOFTWARE.
*/

#pragma once
#include <Cable.hpp>
#include <components/Cable.hpp>

// Pops the top value of the current's stackPtr and pushes it back onto same stack twice.
// If there are no values on the stack it does nothing.
Expand All @@ -34,4 +34,4 @@ class Cloner : public Cable
~Cloner() override = default;

bool work(Current::Ptr current, std::vector<Current::Ptr>& currentVector) override;
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ SOFTWARE.
#pragma once
#include <functional>

#include <Cable.hpp>
#include <components/Cable.hpp>

class CloningDynamicComponent : public Cable
{
Expand All @@ -38,4 +38,4 @@ class CloningDynamicComponent : public Cable
bool work(Current::Ptr current, std::vector<Current::Ptr>& currentVector) override;
private:
WorkFunctionType m_workFunc;
};
};
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SOFTWARE.
*/

#pragma once
#include <Cable.hpp>
#include <components/Cable.hpp>

// Pops the value on top of the current's stackPtr, and compares it with m_targetValue. If the result is true, lets current pass.
// Otherwise, kills the current. Inverted Conditional units does the opposite.
Expand All @@ -40,4 +40,4 @@ class ConditionalUnit : public Cable
bool m_checkEqual;
bool m_checkLess;
bool m_checkGreater;
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SOFTWARE.
*/

#pragma once
#include <Cable.hpp>
#include <components/Cable.hpp>

// Pops the value on top of the current's stackPtr adds m_constant to it and pushes it back to the current's stackPtr.
// If there is no value on the current's stackPtr, it does nothing.
Expand All @@ -36,4 +36,4 @@ class ConstantAdder : public Cable
bool work(Current::Ptr current, std::vector<Current::Ptr>& currentVector) override;
private:
var_t m_constant;
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SOFTWARE.
*/

#pragma once
#include <Cable.hpp>
#include <components/Cable.hpp>

// Pushes m_constant to the current's stackPtr.
class ConstantPusher : public Cable
Expand All @@ -35,4 +35,4 @@ class ConstantPusher : public Cable
bool work(Current::Ptr current, std::vector<Current::Ptr>& currentVector) override;
private:
var_t m_constant;
};
};
4 changes: 2 additions & 2 deletions include/Eraser.hpp → include/components/Eraser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SOFTWARE.
*/

#pragma once
#include <Cable.hpp>
#include <components/Cable.hpp>

// Pops the top value from the current's stackPtr.
class Eraser : public Cable
Expand All @@ -33,4 +33,4 @@ class Eraser : public Cable
~Eraser() override = default;

bool work(Current::Ptr current, std::vector<Current::Ptr>& currentVector) override;
};
};
4 changes: 2 additions & 2 deletions include/FileCloser.hpp → include/components/FileCloser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#include <Cable.hpp>
#include <components/Cable.hpp>

class FileCloser : public Cable
{
Expand All @@ -31,4 +31,4 @@ class FileCloser : public Cable
~FileCloser() override = default;

bool work(Current::Ptr current, std::vector<Current::Ptr>& currentVector) override;
};
};
4 changes: 2 additions & 2 deletions include/FileOpener.hpp → include/components/FileOpener.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#include <Cable.hpp>
#include <components/Cable.hpp>

class FileOpener : public Cable
{
Expand All @@ -33,4 +33,4 @@ class FileOpener : public Cable
bool work(Current::Ptr current, std::vector<Current::Ptr>& currentVector) override;
private:
bool m_appendMode;
};
};
4 changes: 2 additions & 2 deletions include/FileReader.hpp → include/components/FileReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SOFTWARE.
*/

#pragma once
#include <Cable.hpp>
#include <components/Cable.hpp>

class FileReader : public Cable
{
Expand All @@ -32,4 +32,4 @@ class FileReader : public Cable
~FileReader() override = default;

bool work(Current::Ptr current, std::vector<Current::Ptr>& currentVector) override;
};
};
4 changes: 2 additions & 2 deletions include/FileWriter.hpp → include/components/FileWriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#include <Cable.hpp>
#include <components/Cable.hpp>

class FileWriter : public Cable
{
Expand All @@ -31,4 +31,4 @@ class FileWriter : public Cable
~FileWriter() override = default;

bool work(Current::Ptr current, std::vector<Current::Ptr>& currentVector) override;
};
};
4 changes: 2 additions & 2 deletions include/Key.hpp → include/components/Key.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SOFTWARE.
*/

#pragma once
#include <Cable.hpp>
#include <components/Cable.hpp>
#include <string>

// Holds flown currents still until it is activated. To activate a key, a current has to touch it from its activator directions.
Expand All @@ -38,4 +38,4 @@ class Key : public Cable
std::vector<Direction> m_activatorDirections;
std::vector<std::u32string>& m_sourceCode;
char32_t m_transformTo;
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ SOFTWARE.
#pragma once
#include <functional>

#include <Component.hpp>
#include <components/Component.hpp>

class NonCloningDynamicComponent : public Component
{
Expand All @@ -38,4 +38,4 @@ class NonCloningDynamicComponent : public Component
bool work(Current::Ptr current, std::vector<Current::Ptr>& currentVector) override;
private:
WorkFunctionType m_workFunc;
};
};
4 changes: 2 additions & 2 deletions include/Portal.hpp → include/components/Portal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SOFTWARE.
*/

#pragma once
#include <Component.hpp>
#include <components/Component.hpp>

// Teleports currents around.
class Portal : public Component
Expand All @@ -35,4 +35,4 @@ class Portal : public Component
bool work(Current::Ptr current, std::vector<Current::Ptr>& currentVector) override;
private:
Position m_originalPosition;
};
};
4 changes: 2 additions & 2 deletions include/Printer.hpp → include/components/Printer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SOFTWARE.
*/

#pragma once
#include <Cable.hpp>
#include <components/Cable.hpp>

// Pops the value on top of the current's stackPtr and prints it on screen as number. If m_printAsUchar is true it prints it as a char_t.
// If there is no top value, it does nothing.
Expand All @@ -36,4 +36,4 @@ class Printer : public Cable
bool work(Current::Ptr current, std::vector<Current::Ptr>& currentVector) override;
private:
bool m_printAsChar = false;
};
};
4 changes: 2 additions & 2 deletions include/Reader.hpp → include/components/Reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SOFTWARE.
*/

#pragma once
#include <Cable.hpp>
#include <components/Cable.hpp>

// Takes input from user and pushes it on top of the current's stackPtr.
class Reader : public Cable
Expand All @@ -35,4 +35,4 @@ class Reader : public Cable
bool work(Current::Ptr current, std::vector<Current::Ptr>& currentVector) override;
private:
bool m_getInputAsChar = false;
};
};
4 changes: 2 additions & 2 deletions include/Reverser.hpp → include/components/Reverser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SOFTWARE.
*/

#pragma once
#include <Cable.hpp>
#include <components/Cable.hpp>

// Reverses the current's stackPtr.
class Reverser : public Cable
Expand All @@ -33,4 +33,4 @@ class Reverser : public Cable
~Reverser() override = default;

bool work(Current::Ptr current, std::vector<Current::Ptr>& currentVector) override;
};
};
Loading

0 comments on commit 18eff00

Please sign in to comment.