Nimbin[12]?SDL & Graphics / sdl_runtime_compiler / src/systems/compiler_system.hpp

sdl_runtime_compiler git · main

SDL3 game for running and compiling code at runtime

sdl3 c++ compiler dlopen cmake · first commit 2026-04-19 · last commit 2026-07-03 (3 months ago) · synced 3 days ago · upstream: git.ide3.de/hsnr/sdl-runtime-compiler

C++ 72.3% C 26.2%
git clone https://git.christianimmanuel.de/sdl-graphics/sdl_runtime_compiler.gitwget https://git.christianimmanuel.de/sdl-graphics/sdl_runtime_compiler/archive/sdl_runtime_compiler.tar.gz
src/systems/compiler_system.hpp 934 B · 42 lines raw
#pragma once

#include <atomic>
#include <cstdio>
#include <mutex>
#include <string>
#include <thread>

#include "entities/world.hpp"
#include "text/handler.hpp"
#include "utils/globals.hpp"

namespace
Nimbin
{

struct CompilerSystem
{
private:
    DynArray<std::string> _pending;
    std::thread           _worker;
    std::mutex            _mtx;
    std::atomic<bool>     _running{false};
    int                   _count  {0};

    void        push_Line  (Text::Handler& out, const std::string& line);
    static void run_Compile(CompilerSystem* self, std::string src);
public:
    static inline float line_height = 0.4f;
    static inline float start_y     = World::get_FloorY()+1;

    bool last_compile_ok{false};

    void update    (Text::Handler& out);
    void compile   (Text::Handler& out, const std::string& src);

    bool is_Running() const { return _running.load(); }

    ~CompilerSystem();
};

} // namespace Nimbin