Skip to content

Commit

Permalink
progress
Browse files Browse the repository at this point in the history
  • Loading branch information
edg-l committed Mar 27, 2024
1 parent 1a1faf8 commit 39fc7f2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/target
/target_ed
playground/

/*.ll
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ pub fn factorial(n: i32) -> i32 {
return n * factorial(n - 1);
}
}

mod hello {
pub fn world(ptr: *const u8) -> u8 {
return *ptr;
}
}
```

## edb: The edlang builder
Expand Down
19 changes: 16 additions & 3 deletions lib/edlang_codegen_llvm/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,7 @@ pub fn compile(session: &Session, program: &ProgramBody) -> Result<PathBuf, Box<
"edlang-sdk",
);

let di_namespace = di_builder
.create_namespace(di_unit.get_file().as_debug_info_scope(), &module.name, true)
.as_debug_info_scope();
let di_namespace = di_unit.get_file().as_debug_info_scope();

let mut module_ctx = ModuleCompileCtx {
ctx,
Expand Down Expand Up @@ -209,13 +207,28 @@ pub fn compile(session: &Session, program: &ProgramBody) -> Result<PathBuf, Box<
fn compile_module(ctx: &mut ModuleCompileCtx, module_id: DefId) {
let module = ctx.ctx.program.modules.get(&module_id).unwrap();
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() {
compile_fn_signature(ctx, *id, true);
}

for id in module.modules.iter() {
compile_module(ctx, *id);
}

for id in module.functions.iter() {
compile_fn(ctx, *id).unwrap();
}

ctx.di_namespace = di_namespace;
}

fn compile_fn_signature(ctx: &ModuleCompileCtx<'_, '_>, fn_id: DefId, is_definition: bool) {
Expand Down
2 changes: 1 addition & 1 deletion lib/edlang_ir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl Body {
}

format!(
"{}@{}@{}",
"{}${}${}",
self.name, self.def_id.program_id, self.def_id.id
)
}
Expand Down

0 comments on commit 39fc7f2

Please sign in to comment.