diff --git a/Common/LXC.h b/Common/LXC.h index 78e78b1..77c1243 100644 --- a/Common/LXC.h +++ b/Common/LXC.h @@ -13,10 +13,14 @@ // Standard libraries // #include +#include +#include #include #include #include #include +#include +#include // LXC util files // diff --git a/Common/modules/IO.h b/Common/modules/IO.h index f6373fb..1b6dae3 100644 --- a/Common/modules/IO.h +++ b/Common/modules/IO.h @@ -156,7 +156,16 @@ namespace LXC::Util requires Internal::HasLogStrFunc || Internal::Logable inline void PrintLn(T&& arg) { - if constexpr (Internal::HasLogStrFunc) + if constexpr (std::is_pointer_v) + { + if (arg != nullptr) _LIKELY + PrintLn(*arg); + + else + Internal::WriteImpl(std::cout, "Nullptr to: [", typeid(std::remove_pointer_t).name(), "]"); + } + + else if constexpr (Internal::HasLogStrFunc) Internal::WriteImpl(std::cout, arg.LogStr()); else @@ -176,12 +185,21 @@ namespace LXC::Util // Logs a singular argument to the log, calls Log() if it can on the object // template requires Internal::HasLogStrFunc || Internal::Logable - inline void Log(T arg) + inline void Log(T&& arg) { std::ofstream& log = Internal::Log(); if (log.is_open()) _UNLIKELY { - if constexpr (Internal::HasLogStrFunc) + if constexpr (std::is_pointer_v) + { + if (arg != nullptr) _LIKELY + Log(*arg); + + else + Internal::WriteImpl(log, "[LXC] Nullptr to: [", typeid(std::remove_pointer_t).name(), "]"); + } + + else if constexpr (Internal::HasLogStrFunc) Internal::WriteImpl(log, "[LXC] ", '{', arg.LogStr(), '}'); else diff --git a/LXC/LXC.cpp b/LXC/LXC.cpp index 1fa61f7..e0f8b07 100644 --- a/LXC/LXC.cpp +++ b/LXC/LXC.cpp @@ -69,6 +69,10 @@ int main(int argc, char** argv) // Turns the tokens into into an abstract syntax tree // Util::ReturnVal functionsAST = Parser::TurnTokensIntoAST(tokens); + if (functionsAST.Failed()) _UNLIKELY + { + Util::Stop(); + } return 0; }