diff --git a/src/headers/Yerbacon.hpp b/src/headers/Yerbacon.hpp index adb5abd..524ad74 100644 --- a/src/headers/Yerbacon.hpp +++ b/src/headers/Yerbacon.hpp @@ -65,10 +65,6 @@ namespace Yerbacon { }; } -#include -template -constexpr T& pointerAs(const std::unique_ptr& ptr) { return reinterpret_cast(*ptr); } - #undef YBCON_VERSION #undef YBCON_FLAGS #undef YBCON_COMPILER diff --git a/src/headers/parsing/ParseComponents.hpp b/src/headers/parsing/ParseComponents.hpp index 76950f7..f4e5877 100644 --- a/src/headers/parsing/ParseComponents.hpp +++ b/src/headers/parsing/ParseComponents.hpp @@ -20,7 +20,7 @@ struct ParseComponent { virtual ~ParseComponent() = default; }; -struct NamedIdentifier: ParseComponent { +struct NamedIdentifier: virtual ParseComponent { const string name; explicit NamedIdentifier(string_view nameText): name(nameText) {} }; @@ -28,7 +28,7 @@ struct NamedIdentifier: ParseComponent { typedef unique_ptr component_ptr; #define IS_PARSECOMPONENT IS(ParseComponent) -class ParseTree: public ParseComponent { +class ParseTree: public virtual ParseComponent { mutable vector subComponents; using array_type = decltype(subComponents); using iterator = array_type::iterator; @@ -61,7 +61,7 @@ public: vector filteredComponents; for_each(cbegin(), cend(), [&filteredComponents](const component_ptr& it) { if (it->getId() == typeid(T)) { - filteredComponents.push_back(reinterpret_cast(it.get())); + filteredComponents.push_back(dynamic_cast(it.get())); } }); return filteredComponents; diff --git a/src/headers/transpiler/Target.hpp b/src/headers/transpiler/Target.hpp index bc39d17..a3f65dd 100644 --- a/src/headers/transpiler/Target.hpp +++ b/src/headers/transpiler/Target.hpp @@ -66,7 +66,7 @@ protected: } typedef function task; #define make_task_base(start, type, captures, function_body) make_pair(type_index(typeid(type)), [captures](const ParseTree& parsedTree, unsigned int& index) { start; function_body }) - #define make_task_base_R(T, C, F) make_task_base(const T& parseComponent = pointerAs(parsedTree[index]), T, C, F) + #define make_task_base_R(T, C, F) make_task_base(const T& parseComponent = dynamic_cast(*parsedTree[index]), T, C, F) #define make_task(T, F) make_task_base_R(T, this, F) #define make_task_noR(T, F) make_task_base(,T, this, F) #define make_nonlocal_task(T, F) make_task_base_R(T, , F)