-
Notifications
You must be signed in to change notification settings - Fork 0
Implement module system with library/program compilation modes and initialization calls #69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement module system with library/program compilation modes and initialization calls #69
Conversation
Co-authored-by: InauguralPhysicist <217690737+InauguralPhysicist@users.noreply.github.com>
Co-authored-by: InauguralPhysicist <217690737+InauguralPhysicist@users.noreply.github.com>
|
@copilot This is a flawless execution of Phase 4.3.
|
Co-authored-by: InauguralPhysicist <217690737+InauguralPhysicist@users.noreply.github.com>
Co-authored-by: InauguralPhysicist <217690737+InauguralPhysicist@users.noreply.github.com>
Phase 4.4 implemented! ✅ The final connection is complete. When
Generated IR for main importing ["math_utils", "physics"]: define i32 @"main"() nounwind {
entry:
%"x" = alloca double
call void @"math_utils_init"()
call void @"physics_init"()
store double 0x4045000000000000, double* %"x"
...
}Test Coverage: 36/36 tests pass (added 6 new tests for init calls) |
|
@copilot This is the Ignition Sequence for your language ecosystem.
main.eigsimport geometry This works because visualization_init() runs first!visualization.draw_vector of geometry.calculate_orbit(state) You are officially ready to start building the WebAssembly Interactive Playground. |
|
@copilot The Next Frontier: Phase 5 & The Visualizer |
Compiling multiple EigenScript modules each generated
main(), causing linker failures: "Duplicate symbol main. Abort."This PR implements the complete module system (Phase 4.3 + 4.4) to enable proper multi-file program compilation.
Changes
Phase 4.3: Module vs Program Compilation
LLVMCodeGenerator: Added
module_nameparameter to__init__module_name=None→ Program mode: generatesmain()returningi32module_name="xyz"→ Library mode: generatesxyz_init()returningvoidadd→math_utils_add)compile.py: Added
is_mainparameter tocompile_module()is_main=True→module_name=Noneis_main=False→module_name="{filename}"Phase 4.4: Module Initialization Calls
LLVMCodeGenerator.compile(): Added
imported_modulesparameter{module}_init()functions for each imported modulemain()before user code executioncompile.py: Pass imported modules to codegen
scan_imports()is_main=True)Example
Library compilation (
math_utils.eigs):Program compilation (
main.eigsimportingmath_utilsandphysics):Multiple modules can now link without symbol conflicts. Each library exports unique
{module}_init()and prefixed function names. The main program automatically calls all imported module initialization functions to ensure proper initialization order.Testing
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.