This commit is contained in:
Edgar 2024-03-27 12:08:48 +01:00
parent 1a1faf81f2
commit 39fc7f2b9f
No known key found for this signature in database
GPG key ID: 70ADAE8F35904387
4 changed files with 25 additions and 4 deletions

2
.gitignore vendored
View file

@ -1,3 +1,5 @@
/target /target
/target_ed /target_ed
playground/ playground/
/*.ll

View file

@ -17,6 +17,12 @@ pub fn factorial(n: i32) -> i32 {
return n * factorial(n - 1); return n * factorial(n - 1);
} }
} }
mod hello {
pub fn world(ptr: *const u8) -> u8 {
return *ptr;
}
}
``` ```
## edb: The edlang builder ## edb: The edlang builder

View file

@ -144,9 +144,7 @@ pub fn compile(session: &Session, program: &ProgramBody) -> Result<PathBuf, Box<
"edlang-sdk", "edlang-sdk",
); );
let di_namespace = di_builder let di_namespace = di_unit.get_file().as_debug_info_scope();
.create_namespace(di_unit.get_file().as_debug_info_scope(), &module.name, true)
.as_debug_info_scope();
let mut module_ctx = ModuleCompileCtx { let mut module_ctx = ModuleCompileCtx {
ctx, ctx,
@ -209,13 +207,28 @@ pub fn compile(session: &Session, program: &ProgramBody) -> Result<PathBuf, Box<
fn compile_module(ctx: &mut ModuleCompileCtx, module_id: DefId) { fn compile_module(ctx: &mut ModuleCompileCtx, module_id: DefId) {
let module = ctx.ctx.program.modules.get(&module_id).unwrap(); let module = ctx.ctx.program.modules.get(&module_id).unwrap();
trace!("compiling module: {:?}", module_id); trace!("compiling module: {:?}", module_id);
let di_namespace = ctx.di_namespace;
if module.name != "lib" {
ctx.di_namespace = ctx
.di_builder
.create_namespace(di_namespace, &module.name, true)
.as_debug_info_scope();
}
for id in module.functions.iter() { for id in module.functions.iter() {
compile_fn_signature(ctx, *id, true); compile_fn_signature(ctx, *id, true);
} }
for id in module.modules.iter() {
compile_module(ctx, *id);
}
for id in module.functions.iter() { for id in module.functions.iter() {
compile_fn(ctx, *id).unwrap(); compile_fn(ctx, *id).unwrap();
} }
ctx.di_namespace = di_namespace;
} }
fn compile_fn_signature(ctx: &ModuleCompileCtx<'_, '_>, fn_id: DefId, is_definition: bool) { fn compile_fn_signature(ctx: &ModuleCompileCtx<'_, '_>, fn_id: DefId, is_definition: bool) {

View file

@ -101,7 +101,7 @@ impl Body {
} }
format!( format!(
"{}@{}@{}", "{}${}${}",
self.name, self.def_id.program_id, self.def_id.id self.name, self.def_id.program_id, self.def_id.id
) )
} }