Nimbin[12]?SDL & Graphics / sdl_runtime_compiler / commits / 4c0743f

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

Rename vars

Christian Immanuel · 2026-06-21 11:19 · 4c0743fcb67831cba20290a4426cc41aa26455d2

 src/states/game_state.cpp | 158 +++++++++++++++++++++++-----------------------
 src/states/game_state.hpp |  13 ++--
 2 files changed, 86 insertions(+), 85 deletions(-)

diff --git a/src/states/game_state.cpp b/src/states/game_state.cpp
index 42b2f1a..4a9b8e2 100644
--- a/src/states/game_state.cpp
+++ b/src/states/game_state.cpp
@@ -48,48 +48,48 @@ GameState::GameState(size_t starting_level)
 
     _wall_labels     = Wall::Label::generate_All(World::get_BoxScale());
 
-    _editor = Text::Handler(Wall::Role::Editor, World::get_BoxScale(),
-                            Text::LayoutMode::Mono);
-    _editor.set_ShowNumbers(true, true);
+    _wall_editor     = Text::Handler(Wall::Role::Editor, World::get_BoxScale(),
+                                     Text::LayoutMode::Mono);
+    _wall_editor.set_ShowNumbers(true, true);
 
-    _text_walls = { &_editor };
+    _text_walls = { &_wall_editor };
 
-    _program = Text::Handler(Wall::Role::Program, World::get_BoxScale(),
+    _wall_program = Text::Handler(Wall::Role::Program, World::get_BoxScale(),
                              Text::LayoutMode::Snapped);
-    _program.set_Lexing      (false);
-    _program.set_ShowNumbers (false, false);
-    _program.set_DefaultStyle(Text::Token::depth_wall, 0.003f,
+    _wall_program.set_Lexing      (false);
+    _wall_program.set_ShowNumbers (false, false);
+    _wall_program.set_DefaultStyle(Text::Token::depth_wall, 0.003f,
                               static_cast<double>(ProgramSystem::line_height),
                               ConfigWall::free_space_dist);
-    _program.set_AppendBaseline(static_cast<double>(ProgramSystem::start_y));
-    _program.set_FaceMode      (Text::FaceMode::Pitch);
+    _wall_program.set_AppendBaseline(static_cast<double>(ProgramSystem::start_y));
+    _wall_program.set_FaceMode      (Text::FaceMode::Pitch);
 
-    _compiler = Text::Handler(Wall::Role::Compiler, World::get_BoxScale(),
+    _wall_compiler = Text::Handler(Wall::Role::Compiler, World::get_BoxScale(),
                               Text::LayoutMode::Snapped);
-    _compiler.set_Lexing      (false);
-    _compiler.set_ShowNumbers (false, false);
-    _compiler.set_DefaultStyle(Text::Token::depth_compiler, 0.003f,
-                               static_cast<double>(CompilerSystem::line_height),
-                               ConfigWall::free_space_dist);
-    _compiler.set_AppendBaseline(static_cast<double>(CompilerSystem::start_y));
-    _compiler.set_AppendColor(ConfigColor::white);
-    _compiler.set_FaceMode(Text::FaceMode::Pitch);
-
-    _info = Text::Handler(Wall::Role::Info, World::get_BoxScale(),
-                          Text::LayoutMode::Snapped);
-    _info.set_Lexing      (false);
-    _info.set_ShowNumbers (false, false);
-    _info.set_DefaultStyle(Text::Token::depth_wall, 0.003f,
-                           static_cast<double>(ConfigWall::text_line_spacing),
-                           ConfigWall::free_space_dist);
-    _info.set_AppendBaseline(World::get_FloorY<double>() + 1.0);
-    _info.set_AppendColor   (ConfigColor::white);
-    _info.set_FaceMode      (Text::FaceMode::Pitch);
-
-    _text_walls = { &_editor, &_program, &_compiler, &_info };
-
-    _ctx.editor_wall = &_editor;
-    _ctx.info_wall   = &_info;
+    _wall_compiler.set_Lexing      (false);
+    _wall_compiler.set_ShowNumbers (false, false);
+    _wall_compiler.set_DefaultStyle(Text::Token::depth_compiler, 0.003f,
+                                    static_cast<double>(CompilerSystem::line_height),
+                                    ConfigWall::free_space_dist);
+    _wall_compiler.set_AppendBaseline(static_cast<double>(CompilerSystem::start_y));
+    _wall_compiler.set_AppendColor(ConfigColor::white);
+    _wall_compiler.set_FaceMode(Text::FaceMode::Pitch);
+
+    _wall_info = Text::Handler(Wall::Role::Info, World::get_BoxScale(),
+                               Text::LayoutMode::Snapped);
+    _wall_info.set_Lexing      (false);
+    _wall_info.set_ShowNumbers (false, false);
+    _wall_info.set_DefaultStyle(Text::Token::depth_wall, 0.003f,
+                                static_cast<double>(ConfigWall::text_line_spacing),
+                                ConfigWall::free_space_dist);
+    _wall_info.set_AppendBaseline(World::get_FloorY<double>() + 1.0);
+    _wall_info.set_AppendColor   (ConfigColor::white);
+    _wall_info.set_FaceMode      (Text::FaceMode::Pitch);
+
+    _text_walls = { &_wall_editor, &_wall_program, &_wall_compiler, &_wall_info };
+
+    _ctx.editor_wall = &_wall_editor;
+    _ctx.info_wall   = &_wall_info;
 
     _pult_sys        = cpputils::make_unique<PultSystem>  ();
     _pult_sys->init(_ctx.scenery, _ctx.buttons, World::get_BoxScale());
@@ -217,9 +217,9 @@ GameState::on_Click()
 
                 if (_focus_role == Wall::Role::Editor) {
                     const Text::Handler::CursorHit hit =
-                        _editor.resolve_Impact(impact);
+                        _wall_editor.resolve_Impact(impact);
                     wallconnect_BeginEditor();
-                    _editor.place_CursorInsert(hit);
+                    _wall_editor.place_CursorInsert(hit);
                 }
                 else if (_focus_role == Wall::Role::Program) {
                     wallconnect_BeginProgram();
@@ -228,7 +228,7 @@ GameState::on_Click()
         }
         return;
     }
-    if (_editor.edit_Active()) {
+    if (_wall_editor.edit_Active()) {
         const Wall::Transform 
                      wall_transform = Wall::get_Transform(Wall::Role::Editor, World::get_BoxScale());
         const double wall_tans_x    = wall_transform.position.x;
@@ -239,11 +239,11 @@ GameState::on_Click()
             const double t = (wall_tans_x - cam_pos.x) / cam_fwd.x;
             if (t > 0.0) {
                 Vec3 impact { wall_tans_x, cam_pos.y + cam_fwd.y * t, cam_pos.z + cam_fwd.z * t };
-                if (_editor.cursor_AtImpact(impact)) return;
+                if (_wall_editor.cursor_AtImpact(impact)) return;
             }
         }
-        if (Text::Token::Data* tk = PickSystem::pick_WallToken(*_ctx.camera, _editor))
-            _editor.cursor_ToToken(tk);
+        if (Text::Token::Data* tk = PickSystem::pick_WallToken(*_ctx.camera, _wall_editor))
+            _wall_editor.cursor_ToToken(tk);
         return;
     }
 
@@ -270,7 +270,7 @@ GameState::on_Pick()
 
         _level_director-> record_PickedUp(base->text);
         base->set_Look       (ConfigColor::keep, Text::Token::depth_floor);
-        Wall::show_TokenInfo (_info, base->text);
+        Wall::show_TokenInfo (_wall_info, base->text);
         carry_BeginAnim      (std::move(base), true);
         return true;
     }
@@ -282,7 +282,7 @@ GameState::on_Pick()
 
         _level_director->record_PickedUp(word->text);
         word->set_Look      (ConfigColor::keep, Text::Token::depth_floor);
-        Wall::show_TokenInfo(_info, word->text);
+        Wall::show_TokenInfo(_wall_info, word->text);
         carry_BeginAnim     (std::move(word), false);
         return true;
     }
@@ -308,7 +308,7 @@ GameState::on_DropLast()
     _anims_drop.push_back(std::move(drop));
 
     if (!_carried.empty()) {
-        Wall::show_TokenInfo(_info, _carried.last->word->text);
+        Wall::show_TokenInfo(_wall_info, _carried.last->word->text);
     }
     else _level_director->show_Details(_ctx);
 
@@ -337,7 +337,7 @@ GameState::on_ShootOne()
                              _ctx.camera->fwd, _ctx.camera->pos, aim);
 
     if (!_carried.empty() && _carried.last && _carried.last->word) {
-        Wall::show_TokenInfo(_info, _carried.last->word->text);
+        Wall::show_TokenInfo(_wall_info, _carried.last->word->text);
     }
     else _level_director->show_Details(_ctx);
 
@@ -380,7 +380,7 @@ std::string
 GameState::editor_Source() const
 {
     std::string src;
-    for (const std::string& l : _editor.as_Lines())
+    for (const std::string& l : _wall_editor.as_Lines())
         { src += l; src += '\n'; }
     return src;
 }
@@ -399,10 +399,10 @@ void GameState::on_Compile() {
         if (!path.empty() && !stripped.empty())
             SourceTokens::write_File(path, src);
 
-        _dyn_loader_sys->build(_compiler, src, true);
+        _dyn_loader_sys->build(_wall_compiler, src, true);
     }
     else {
-        _compiler_sys->compile(_compiler, src);
+        _compiler_sys->compile(_wall_compiler, src);
     }
 }
 
@@ -410,7 +410,7 @@ void GameState::on_Compile() {
 void
 GameState::on_Run()
 {
-    _program_sys->run(_program);
+    _program_sys->run(_wall_program);
 }
 
 
@@ -525,7 +525,7 @@ GameState::projectile_FeedProgramInput(ProjectileResult& result)
     if (!line.empty())
         _program_sys->feed_Input(line);
 
-    _program_sys->echo_Words(_program, result.words);
+    _program_sys->echo_Words(_wall_program, result.words);
 }
 
 
@@ -576,13 +576,13 @@ GameState::projectile_LandOnWall(ProjectileResult& result)
         impact.y *= inv;
         impact.z *= inv;
 
-        _editor.attach(std::move(edit_block), impact);
+        _wall_editor.attach(std::move(edit_block), impact);
     }
 
     { FP_ZONE("flush.append");
-        if (!prog_block.empty()) _program .append_Tokens(std::move(prog_block));
-        if (!comp_block.empty()) _compiler.append_Tokens(std::move(comp_block));
-        if (!info_block.empty()) _info    .append_Tokens(std::move(info_block));
+        if (!prog_block.empty()) _wall_program .append_Tokens(std::move(prog_block));
+        if (!comp_block.empty()) _wall_compiler.append_Tokens(std::move(comp_block));
+        if (!info_block.empty()) _wall_info    .append_Tokens(std::move(info_block));
     }
 }
 
@@ -659,9 +659,9 @@ GameState::projectile_LandOnWallText(ProjectileResult& result)
 
     if (idx >= Text::Handler::HIT_BASE) {
         const size_t lid   = Text::Handler::line_Of(idx);
-        const double delta = _editor.scroll_DeltaToEye(lid, _ctx.camera->pos.y);
-        _editor.scroll(delta);
-        _editor.bounce(lid);
+        const double delta = _wall_editor.scroll_DeltaToEye(lid, _ctx.camera->pos.y);
+        _wall_editor.scroll(delta);
+        _wall_editor.bounce(lid);
         projectile_LandOnFloor(result);
         return;
     }
@@ -731,16 +731,16 @@ GameState::update_Input(FrameInput& input, double dt)
 
     if (target == Wall::Connection::Target::Editor) {
         { FP_ZONE("handle_input.Editor");
-            Text::Handler::EditReq req = _editor.feed_Keys(input.vim_keys, _ctx.camera->pos.y);
+            Text::Handler::EditReq req = _wall_editor.feed_Keys(input.vim_keys, _ctx.camera->pos.y);
             input.vim_keys.clear();
             switch (req) {
                 case Text::Handler::EditReq::Write:
-                    _editor.mark_Saved();
+                    _wall_editor.mark_Saved();
                     break;
                 case Text::Handler::EditReq::WriteQuit:
                 case Text::Handler::EditReq::Exit:
                 case Text::Handler::EditReq::Discard:
-                    _editor.end_Edit();
+                    _wall_editor.end_Edit();
                     _wall_connection.end();
                     _frame_input.capture_vim = false;
                     _focus_locked            = false;
@@ -833,34 +833,34 @@ GameState::update_Objects(double dt, const GlRenderer* gl)
 void
 GameState::update_Compiler()
 {
-    _compiler_sys->update(_compiler);
+    _compiler_sys->update(_wall_compiler);
     if (_compiler_sys->last_compile_ok) {
         _compiler_sys->last_compile_ok = false;
         _level_director->record_CompileOk();
     }
 
     // TODO: the dyn path may still blocks the frame in dyn_Apply
-    _dyn_loader_sys->update(_compiler);
+    _dyn_loader_sys->update(_wall_compiler);
     if (_dyn_loader_sys->last_build_ok) {
         _dyn_loader_sys->last_build_ok = false;
         dyn_Apply(_dyn_loader_sys->load_Objects());
         SourceTokens::copy_File(sandbox_CanonicalPath(), sandbox_BackupPath());
     }
 
-    _program_sys->update(_program);
+    _program_sys->update(_wall_program);
 }
 
 
 void
 GameState::update_Highlighting()
 {
-    if (_editor.is_Dirty())
-        _highlight_sys->request(_editor.render_Source(), _editor.generation());
+    if (_wall_editor.is_Dirty())
+        _highlight_sys->request(_wall_editor.render_Source(), _wall_editor.generation());
 
     DynArray<Text::HiSpan> spans;
     uint64_t gen;
     if (_highlight_sys->poll(spans, gen))
-        _editor.apply_Highlight(spans, gen);
+        _wall_editor.apply_Highlight(spans, gen);
 }
 
 
@@ -1033,7 +1033,7 @@ GameState::update_Physics(double dt)
             }
         }
 
-        for (const Text::Handler::NumberHit& nh : _editor.number_Hitboxes())
+        for (const Text::Handler::NumberHit& nh : _wall_editor.number_Hitboxes())
             wall_text_hits.push_back({
                     nh.aabb_Min,
                     nh.aabb_Max,
@@ -1221,7 +1221,7 @@ GameState::sandbox_LoadFileToWall()
     if (!cur .empty()) lines.push_back(cur);
     if (lines.empty()) lines.push_back("");
 
-    _editor.set_Lines(lines);
+    _wall_editor.set_Lines(lines);
 }
 
 
@@ -1306,12 +1306,12 @@ GameState::wallconnect_BeginProgram()
 void
 GameState::wallconnect_BeginEditor()
 {
-    _editor.begin_Edit(_ctx.camera->pos.y);
+    _wall_editor.begin_Edit(_ctx.camera->pos.y);
 
     _frame_input.capture_vim = true;
     _frame_input.vim_keys.clear();
 
-    _wall_connection.begin_Editor(_pult_sys->get_ConnectEditorPos(), _editor);
+    _wall_connection.begin_Editor(_pult_sys->get_ConnectEditorPos(), _wall_editor);
 }
 
 
@@ -1327,12 +1327,12 @@ GameState::on_WallConnectSubmit()
         for (const char* h : { ":exit            leave the connection",
                                "ctrl+WASD        move while connected",
                                "<text> + Enter   send a line to the program (stdin)" })
-            _program_sys->echo_Input(_program, h);
+            _program_sys->echo_Input(_wall_program, h);
         return;
     }
 
     _program_sys->feed_Input(line);
-    _program_sys->echo_Input(_program, line);
+    _program_sys->echo_Input(_wall_program, line);
 }
 
 
@@ -1350,15 +1350,15 @@ GameState::on_WallConnectExit()
 void
 GameState::on_EditorClear()
 {
-    _editor.clear_ToFloor(_ctx.words);
+    _wall_editor.clear_ToFloor(_ctx.words);
 }
 
 
 void
 GameState::on_EditorScroll(int8_t dt)
 {
-    if (dt > 0) _editor.scroll( ConfigWall::scroll_step);
-    else        _editor.scroll(-ConfigWall::scroll_step);
+    if (dt > 0) _wall_editor.scroll( ConfigWall::scroll_step);
+    else        _wall_editor.scroll(-ConfigWall::scroll_step);
 }
 
 
@@ -1366,10 +1366,10 @@ Text::Handler*
 GameState::get_Handler(Wall::Role r)
 {
     switch (r) {
-        case Wall::Role::Editor:   return &_editor;
-        case Wall::Role::Program:  return &_program;
-        case Wall::Role::Compiler: return &_compiler;
-        case Wall::Role::Info:     return &_info;
+        case Wall::Role::Editor:   return &_wall_editor;
+        case Wall::Role::Program:  return &_wall_program;
+        case Wall::Role::Compiler: return &_wall_compiler;
+        case Wall::Role::Info:     return &_wall_info;
     }
     return nullptr;
 }
diff --git a/src/states/game_state.hpp b/src/states/game_state.hpp
index 29247f6..4b85c46 100644
--- a/src/states/game_state.hpp
+++ b/src/states/game_state.hpp
@@ -33,17 +33,18 @@
 
 class GameState : public IState
 {
-    Text::Handler      _editor;
-    Text::Handler      _program;
-    Text::Handler      _compiler;
-    Text::Handler      _info;
+    Text::Handler      _wall_editor;
+    Text::Handler      _wall_program;
+    Text::Handler      _wall_compiler;
+    Text::Handler      _wall_info;
     Wall::Connection   _wall_connection;
     CarriedLine        _carried;
     FrameInput         _frame_input;
     GameContext        _ctx;
 
+    DynArray<Text::Token::Data*>
+                             _typing_words;
     DynArray<GameObject*>    _dyn_scenery;
-    DynArray<Text::Token::Data*>        _typing_words;
     DynArray<Vec3>           _freelook_return_from;
     DynArray<Projectile>     _projectiles;
     DynArray<Wall::Label>    _wall_labels;
@@ -62,7 +63,7 @@ class GameState : public IState
 
 
     cpputils::unique_ptr<HintSystem>         _hint_sys;
-    cpputils::unique_ptr<Level::Director>      _level_director;
+    cpputils::unique_ptr<Level::Director>    _level_director;
     cpputils::unique_ptr<CelebrationSystem>  _celebration_sys;
     cpputils::unique_ptr<PlateSystem>        _plate_sys;
     cpputils::unique_ptr<PultSystem>         _pult_sys;