version and fix no return

This commit is contained in:
Edgar 2024-02-17 17:29:18 +01:00
parent 819a70d9f5
commit ff0b6fb995
No known key found for this signature in database
GPG key ID: 70ADAE8F35904387
15 changed files with 74 additions and 38 deletions

20
Cargo.lock generated
View file

@ -297,21 +297,21 @@ dependencies = [
[[package]]
name = "edlang"
version = "0.0.1-alpha.6"
version = "0.0.1-alpha.7"
dependencies = [
"edlang_driver",
]
[[package]]
name = "edlang_ast"
version = "0.0.1-alpha.6"
version = "0.0.1-alpha.7"
dependencies = [
"edlang_span",
]
[[package]]
name = "edlang_check"
version = "0.0.1-alpha.6"
version = "0.0.1-alpha.7"
dependencies = [
"ariadne",
"edlang_ast",
@ -320,7 +320,7 @@ dependencies = [
[[package]]
name = "edlang_codegen_llvm"
version = "0.0.1-alpha.6"
version = "0.0.1-alpha.7"
dependencies = [
"edlang_ir",
"edlang_parser",
@ -333,7 +333,7 @@ dependencies = [
[[package]]
name = "edlang_driver"
version = "0.0.1-alpha.6"
version = "0.0.1-alpha.7"
dependencies = [
"ariadne",
"clap",
@ -353,7 +353,7 @@ dependencies = [
[[package]]
name = "edlang_ir"
version = "0.0.1-alpha.6"
version = "0.0.1-alpha.7"
dependencies = [
"edlang_span",
"smallvec",
@ -361,7 +361,7 @@ dependencies = [
[[package]]
name = "edlang_lowering"
version = "0.0.1-alpha.6"
version = "0.0.1-alpha.7"
dependencies = [
"edlang_ast",
"edlang_ir",
@ -370,7 +370,7 @@ dependencies = [
[[package]]
name = "edlang_parser"
version = "0.0.1-alpha.6"
version = "0.0.1-alpha.7"
dependencies = [
"ariadne",
"edlang_ast",
@ -383,14 +383,14 @@ dependencies = [
[[package]]
name = "edlang_session"
version = "0.0.1-alpha.6"
version = "0.0.1-alpha.7"
dependencies = [
"ariadne",
]
[[package]]
name = "edlang_span"
version = "0.0.1-alpha.6"
version = "0.0.1-alpha.7"
[[package]]
name = "either"

View file

@ -1,6 +1,6 @@
[package]
name = "edlang"
version = "0.0.1-alpha.6"
version = "0.0.1-alpha.7"
authors = ["Edgar Luque <edgar@edgarluque.com>"]
description = "A experimental language using LLVM."
edition = "2021"
@ -14,4 +14,4 @@ repository = "https://github.com/edg-l/edlang"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
edlang_driver = { version = "0.0.1-alpha.6", path = "../../lib/edlang_driver" }
edlang_driver = { version = "0.0.1-alpha.7", path = "../../lib/edlang_driver" }

View file

@ -1,6 +1,6 @@
[package]
name = "edlang_ast"
version = "0.0.1-alpha.6"
version = "0.0.1-alpha.7"
authors = ["Edgar Luque <edgar@edgarluque.com>"]
description = "edlang AST"
edition = "2021"
@ -13,4 +13,4 @@ repository = "https://github.com/edg-l/edlang"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
edlang_span = { version = "0.0.1-alpha.6", path = "../edlang_span" }
edlang_span = { version = "0.0.1-alpha.7", path = "../edlang_span" }

View file

@ -1,6 +1,6 @@
[package]
name = "edlang_check"
version = "0.0.1-alpha.6"
version = "0.0.1-alpha.7"
authors = ["Edgar Luque <edgar@edgarluque.com>"]
description = "edlang check"
edition = "2021"
@ -14,5 +14,5 @@ repository = "https://github.com/edg-l/edlang"
[dependencies]
ariadne = { version = "0.4.0", features = ["auto-color"] }
edlang_ast = { version = "0.0.1-alpha.6", path = "../edlang_ast" }
edlang_ast = { version = "0.0.1-alpha.7", path = "../edlang_ast" }
tracing = { workspace = true }

View file

@ -1,6 +1,6 @@
[package]
name = "edlang_codegen_llvm"
version = "0.0.1-alpha.6"
version = "0.0.1-alpha.7"
authors = ["Edgar Luque <edgar@edgarluque.com>"]
description = "edlang LLVM codegen"
edition = "2021"
@ -13,10 +13,10 @@ repository = "https://github.com/edg-l/edlang"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
edlang_ir = { version = "0.0.1-alpha.6", path = "../edlang_ir" }
edlang_parser = { version = "0.0.1-alpha.6", path = "../edlang_parser" }
edlang_session = { version = "0.0.1-alpha.6", path = "../edlang_session" }
edlang_ir = { version = "0.0.1-alpha.7", path = "../edlang_ir" }
edlang_parser = { version = "0.0.1-alpha.7", path = "../edlang_parser" }
edlang_session = { version = "0.0.1-alpha.7", path = "../edlang_session" }
llvm-sys = "170.0.1"
inkwell = { git = "https://github.com/TheDan64/inkwell", rev = "c044e3cd8d92972ca75b374fb6c5a2794f5b53ca", features = ["llvm17-0"] }
tracing = { workspace = true }
edlang_span = { version = "0.0.1-alpha.6", path = "../edlang_span" }
edlang_span = { version = "0.0.1-alpha.7", path = "../edlang_span" }

View file

@ -1,6 +1,6 @@
[package]
name = "edlang_driver"
version = "0.0.1-alpha.6"
version = "0.0.1-alpha.7"
authors = ["Edgar Luque <edgar@edgarluque.com>"]
description = "edlang compiler driver library"
edition = "2021"
@ -16,13 +16,13 @@ repository = "https://github.com/edg-l/edlang"
ariadne = { version = "0.4.0", features = ["auto-color"] }
clap = { version = "4.4.16", features = ["derive"] }
color-eyre = "0.6.2"
edlang_ast = { version = "0.0.1-alpha.6", path = "../edlang_ast" }
edlang_check = { version = "0.0.1-alpha.6", path = "../edlang_check" }
edlang_codegen_llvm = { version = "0.0.1-alpha.6", path = "../edlang_codegen_llvm" }
edlang_ir = { version = "0.0.1-alpha.6", path = "../edlang_ir" }
edlang_lowering = { version = "0.0.1-alpha.6", path = "../edlang_lowering" }
edlang_parser = { version = "0.0.1-alpha.6", path = "../edlang_parser" }
edlang_session = { version = "0.0.1-alpha.6", path = "../edlang_session" }
edlang_ast = { version = "0.0.1-alpha.7", path = "../edlang_ast" }
edlang_check = { version = "0.0.1-alpha.7", path = "../edlang_check" }
edlang_codegen_llvm = { version = "0.0.1-alpha.7", path = "../edlang_codegen_llvm" }
edlang_ir = { version = "0.0.1-alpha.7", path = "../edlang_ir" }
edlang_lowering = { version = "0.0.1-alpha.7", path = "../edlang_lowering" }
edlang_parser = { version = "0.0.1-alpha.7", path = "../edlang_parser" }
edlang_session = { version = "0.0.1-alpha.7", path = "../edlang_session" }
tracing = { workspace = true }
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }

View file

@ -8,6 +8,7 @@ mod common;
#[test_case(include_str!("programs/basic_ifs.ed"), "basic_ifs", false, 9, &[] ; "basic_ifs")]
#[test_case(include_str!("programs/while.ed"), "while", false, 10, &[] ; "r#while")]
#[test_case(include_str!("programs/factorial.ed"), "factorial", false, 24, &[] ; "factorial")]
#[test_case(include_str!("programs/refs.ed"), "refs", false, 2, &[] ; "refs")]
#[test_case(TEST_ADD, "TEST_ADD", false, 2, &[] ; "TEST_ADD")]
#[test_case(TEST_SUB, "TEST_SUB", false, 1, &[] ; "TEST_SUB")]
#[test_case(TEST_MUL, "TEST_MUL", false, 4, &[] ; "TEST_MUL")]

View file

@ -0,0 +1,13 @@
mod Main {
pub fn main() -> i64 {
let mut a: i64 = 0;
hello(&mut a);
return a;
}
pub fn hello(a: &mut i32) {
*a = 2;
}
}

View file

@ -1,6 +1,6 @@
[package]
name = "edlang_ir"
version = "0.0.1-alpha.6"
version = "0.0.1-alpha.7"
authors = ["Edgar Luque <edgar@edgarluque.com>"]
description = "edlang IR"
edition = "2021"
@ -13,5 +13,5 @@ repository = "https://github.com/edg-l/edlang"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
edlang_span = { version = "0.0.1-alpha.6", path = "../edlang_span" }
edlang_span = { version = "0.0.1-alpha.7", path = "../edlang_span" }
smallvec = "1.13.1"

View file

@ -1,6 +1,6 @@
[package]
name = "edlang_lowering"
version = "0.0.1-alpha.6"
version = "0.0.1-alpha.7"
authors = ["Edgar Luque <edgar@edgarluque.com>"]
description = "edlang lowering"
edition = "2021"
@ -13,6 +13,6 @@ repository = "https://github.com/edg-l/edlang"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
edlang_ast = { version = "0.0.1-alpha.6", path = "../edlang_ast" }
edlang_ir = { version = "0.0.1-alpha.6", path = "../edlang_ir" }
edlang_ast = { version = "0.0.1-alpha.7", path = "../edlang_ast" }
edlang_ir = { version = "0.0.1-alpha.7", path = "../edlang_ir" }
tracing.workspace = true

View file

@ -159,6 +159,15 @@ fn lower_function(ctx: BuildCtx, func: &ast::Function, module_id: DefId) -> Buil
lower_statement(&mut builder, stmt, &ret_ty.kind);
}
if !builder.statements.is_empty() {
let statements = std::mem::take(&mut builder.statements);
builder.body.blocks.push(BasicBlock {
statements: statements.into(),
terminator: Terminator::Return,
terminator_span: None,
});
}
let (mut ctx, body) = (builder.ctx, builder.body);
ctx.unresolved_function_signatures.remove(&body.def_id);
ctx.body.functions.insert(body.def_id, body);

View file

@ -1,6 +1,6 @@
[package]
name = "edlang_parser"
version = "0.0.1-alpha.6"
version = "0.0.1-alpha.7"
authors = ["Edgar Luque <edgar@edgarluque.com>"]
description = "edlang parser"
edition = "2021"
@ -14,7 +14,7 @@ repository = "https://github.com/edg-l/edlang"
[dependencies]
ariadne = { version = "0.4.0", features = ["auto-color"] }
edlang_ast = { version = "0.0.1-alpha.6", path = "../edlang_ast" }
edlang_ast = { version = "0.0.1-alpha.7", path = "../edlang_ast" }
itertools = "0.12.0"
lalrpop-util = { version = "0.20.0", features = ["lexer"] }
logos = "0.14.0"

View file

@ -1,6 +1,6 @@
[package]
name = "edlang_session"
version = "0.0.1-alpha.6"
version = "0.0.1-alpha.7"
authors = ["Edgar Luque <edgar@edgarluque.com>"]
description = "edlang session"
edition = "2021"

View file

@ -1,6 +1,6 @@
[package]
name = "edlang_span"
version = "0.0.1-alpha.6"
version = "0.0.1-alpha.7"
authors = ["Edgar Luque <edgar@edgarluque.com>"]
description = "edlang span"
edition = "2021"

13
programs/refs.ed Normal file
View file

@ -0,0 +1,13 @@
mod Main {
pub fn main() -> i64 {
let mut a: i64 = 0;
hello(&mut a);
return a;
}
pub fn hello(a: &mut i32) {
*a = 2;
}
}