Skip to content

Aleksisch/split program context#2605

Merged
borisbat merged 3 commits intomasterfrom
aleksisch/split-program-context
May 8, 2026
Merged

Aleksisch/split program context#2605
borisbat merged 3 commits intomasterfrom
aleksisch/split-program-context

Conversation

@aleksisch
Copy link
Copy Markdown
Collaborator

In order to have small runtime library we should clearly separate object files.

This PR continues work in this direction. After extracting serialize from ast node, we split Program from ast.cpp and Context from simulate.cpp. So, they may end up in different libraries.

aleksisch added 2 commits May 8, 2026 12:52
Ast should not contain implementation for program. We can use it
without Program.
Context should not depend on simulate. We can use context
without simulation.
@aleksisch aleksisch force-pushed the aleksisch/split-program-context branch from d490e6a to a11cb6a Compare May 8, 2026 10:24
Rececntly we wrongly changed CMakeXxdImpl. Now it points to
correct path.
@aleksisch aleksisch force-pushed the aleksisch/split-program-context branch from a11cb6a to 3aa2bb0 Compare May 8, 2026 10:25
@borisbat borisbat requested a review from Copilot May 8, 2026 15:11
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR continues the effort to reduce the runtime library footprint by splitting large compilation units, extracting Context out of src/simulate/simulate.cpp and Program out of src/ast/ast.cpp so they can be built/linked into different libraries as needed.

Changes:

  • Moved das::Context implementation (and debug-agent globals/helpers) from src/simulate/simulate.cpp into new src/runtime/context.cpp.
  • Moved das::Program implementation from src/ast/ast.cpp into new src/ast/ast_program.cpp.
  • Updated CMake sources list and adjusted the XXD helper to use a function + a different script path mechanism (and bumped CMake minimum version).

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/simulate/simulate.cpp Removes Context + debug-agent implementation from this TU to enable finer-grained linking.
src/runtime/context.cpp New TU containing Context and debug-agent implementation previously in simulate.cpp.
src/ast/ast.cpp Removes Program implementation so AST code can be split into smaller object files.
src/ast/ast_program.cpp New TU containing Program implementation previously in ast.cpp.
CMakeLists.txt Registers new source files and bumps minimum required CMake version.
CMakeCommon.txt Refactors CMAKE_TEXT_XXD from macro→function and changes how CMakeXxdImpl.txt is referenced.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/runtime/context.cpp
@@ -0,0 +1,1237 @@
#include "daScript/simulate/simulate.h"
#include "daScript/ast/ast.h"
#include "daScript/misc/fpe.h"
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit only copies existing code. I suggest to not make any modifications in it.

Comment thread src/runtime/context.cpp
sharedSize = ctx.sharedSize;
shared = ctx.shared;
sharedOwner = false;
// functoins
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit only copies existing code. I suggest to not make any modifications to it.

Comment thread CMakeCommon.txt
Comment on lines +270 to 285
function(CMAKE_TEXT_XXD project_name file_name)
add_custom_command(
DEPENDS ${file_name}
OUTPUT ${file_name}.inc
VERBATIM
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -DFILE_TYPE:STRING="TEXT" -DINPUT_FILE_NAME:STRING=${file_name}
-P ${CMAKE_SOURCE_DIR}/CMakeXxdImpl.txt
-P ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/CMakeXxdImpl.txt
)

list(APPEND XXD_DEPENDS_LIST_${project_name} ${file_name}.inc)
set(XXD_DEPENDS_LIST_${project_name} ${XXD_DEPENDS_LIST_${project_name}} ${file_name}.inc PARENT_SCOPE)
execute_process(
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -DFILE_TYPE:STRING="TEXT" -DINPUT_FILE_NAME:STRING=${file_name}
-P ${CMAKE_SOURCE_DIR}/CMakeXxdImpl.txt
-P ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/CMakeXxdImpl.txt
)
Comment thread CMakeLists.txt
@@ -1,4 +1,4 @@
cmake_minimum_required (VERSION 3.16)
cmake_minimum_required (VERSION 3.17)
@borisbat borisbat merged commit 58941bb into master May 8, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants