mirror of
https://github.com/edg-l/edlang.git
synced 2024-11-22 16:08:24 +00:00
style
This commit is contained in:
parent
1208f25975
commit
82940755d8
24
Cargo.lock
generated
24
Cargo.lock
generated
|
@ -156,9 +156,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap"
|
name = "clap"
|
||||||
version = "4.2.7"
|
version = "4.3.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "34d21f9bf1b425d2968943631ec91202fe5e837264063503708b83013f8fc938"
|
checksum = "93aae7a4192245f70fe75dd9157fc7b4a5bf53e88d30bd4396f7d8f9284d5acc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap_builder",
|
"clap_builder",
|
||||||
"clap_derive",
|
"clap_derive",
|
||||||
|
@ -167,9 +167,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_builder"
|
name = "clap_builder"
|
||||||
version = "4.2.7"
|
version = "4.3.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "914c8c79fb560f238ef6429439a30023c862f7a28e688c58f7203f12b29970bd"
|
checksum = "4f423e341edefb78c9caba2d9c7f7687d0e72e89df3ce3394554754393ac3990"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anstream",
|
"anstream",
|
||||||
"anstyle",
|
"anstyle",
|
||||||
|
@ -180,9 +180,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_derive"
|
name = "clap_derive"
|
||||||
version = "4.2.0"
|
version = "4.3.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3f9644cd56d6b87dbe899ef8b053e331c0637664e9e21a33dfcdc36093f5c5c4"
|
checksum = "191d9573962933b4027f932c600cd252ce27a8ad5979418fe78e43c07996f27b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"heck",
|
"heck",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
|
@ -192,9 +192,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_lex"
|
name = "clap_lex"
|
||||||
version = "0.4.1"
|
version = "0.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8a2dd5a6fe8c6e3502f568a6353e5273bbb15193ad9a89e457b9970798efbea1"
|
checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "color-eyre"
|
name = "color-eyre"
|
||||||
|
@ -497,9 +497,9 @@ checksum = "ece97ea872ece730aed82664c424eb4c8291e1ff2480247ccf7409044bc6479f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "llvm-sys"
|
name = "llvm-sys"
|
||||||
version = "150.0.5"
|
version = "160.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "64be8a29d08e3165e4ed989b80cbc6b52104c543f16e272b83e2dedb749e81e6"
|
checksum = "4f0f91af3fe5727f40c3bab7c3f7604d91db6c094a0be796e9700952e5f1017f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
|
@ -688,9 +688,9 @@ checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.56"
|
version = "1.0.58"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435"
|
checksum = "fa1fb82fc0c281dd9671101b66b771ebbe1eaf967b96ac8740dcba4b70005ca8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
|
@ -12,14 +12,14 @@ categories = ["compilers"]
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "4.2.7", features = ["derive"] }
|
clap = { version = "4.3.0", features = ["derive"] }
|
||||||
color-eyre = "0.6.2"
|
color-eyre = "0.6.2"
|
||||||
itertools = "0.10.5"
|
itertools = "0.10.5"
|
||||||
lalrpop-util = { version = "0.20.0", features = ["lexer"] }
|
lalrpop-util = { version = "0.20.0", features = ["lexer"] }
|
||||||
regex = "1.8.1"
|
regex = "1.8.1"
|
||||||
tracing = "0.1.37"
|
tracing = "0.1.37"
|
||||||
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
|
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
|
||||||
inkwell = { version = "0.2.0", features = ["llvm15-0"] }
|
inkwell = { version = "0.2.0", features = ["llvm16-0"] }
|
||||||
annotate-snippets = { version = "0.9.1", features = ["color"] }
|
annotate-snippets = { version = "0.9.1", features = ["color"] }
|
||||||
logos = "0.13.0"
|
logos = "0.13.0"
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
fn main(x: i32) -> i32 {
|
fn main(x: i32, z: i32) -> i32 {
|
||||||
let y = 0;
|
let y = 0;
|
||||||
if x == 5 {
|
if x == 5 {
|
||||||
|
if x == z {
|
||||||
y = 2 * x;
|
y = 2 * x;
|
||||||
|
} else {
|
||||||
|
y = z;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
y = 3 * x;
|
y = 3 * x;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
use std::{
|
use std::{
|
||||||
collections::{HashMap, HashSet},
|
collections::HashMap,
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
todo,
|
todo,
|
||||||
};
|
};
|
||||||
|
|
||||||
use color_eyre::Result;
|
use color_eyre::Result;
|
||||||
use inkwell::{
|
use inkwell::{
|
||||||
basic_block::BasicBlock,
|
|
||||||
builder::Builder,
|
builder::Builder,
|
||||||
context::Context,
|
context::Context,
|
||||||
module::Module,
|
module::Module,
|
||||||
|
@ -41,12 +40,6 @@ pub struct CodeGen<'ctx> {
|
||||||
ast: ast::Program,
|
ast: ast::Program,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
|
||||||
struct BlockInfo<'a> {
|
|
||||||
pub blocks: Vec<BasicBlock<'a>>,
|
|
||||||
pub current_block: usize,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'ctx> CodeGen<'ctx> {
|
impl<'ctx> CodeGen<'ctx> {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
context: &'ctx Context,
|
context: &'ctx Context,
|
||||||
|
@ -221,7 +214,7 @@ impl<'ctx> CodeGen<'ctx> {
|
||||||
self.builder.build_conditional_branch(
|
self.builder.build_conditional_branch(
|
||||||
condition.into_int_value(),
|
condition.into_int_value(),
|
||||||
if_block,
|
if_block,
|
||||||
if let Some(else_body) = else_body {
|
if else_body.is_some() {
|
||||||
else_block
|
else_block
|
||||||
} else {
|
} else {
|
||||||
merge_block
|
merge_block
|
||||||
|
@ -231,9 +224,8 @@ impl<'ctx> CodeGen<'ctx> {
|
||||||
let mut variables_if = variables.clone();
|
let mut variables_if = variables.clone();
|
||||||
self.builder.position_at_end(if_block);
|
self.builder.position_at_end(if_block);
|
||||||
for s in body {
|
for s in body {
|
||||||
self.compile_statement(s, &mut variables_if);
|
self.compile_statement(s, &mut variables_if)?;
|
||||||
}
|
}
|
||||||
// should we set the builder at the end of the if_block again?
|
|
||||||
self.builder.build_unconditional_branch(merge_block);
|
self.builder.build_unconditional_branch(merge_block);
|
||||||
if_block = self.builder.get_insert_block().unwrap(); // update for phi
|
if_block = self.builder.get_insert_block().unwrap(); // update for phi
|
||||||
|
|
||||||
|
@ -242,9 +234,8 @@ impl<'ctx> CodeGen<'ctx> {
|
||||||
self.builder.position_at_end(else_block);
|
self.builder.position_at_end(else_block);
|
||||||
|
|
||||||
for s in else_body {
|
for s in else_body {
|
||||||
self.compile_statement(s, &mut variables_else);
|
self.compile_statement(s, &mut variables_else)?;
|
||||||
}
|
}
|
||||||
// should we set the builder at the end of the if_block again?
|
|
||||||
self.builder.build_unconditional_branch(merge_block);
|
self.builder.build_unconditional_branch(merge_block);
|
||||||
else_block = self.builder.get_insert_block().unwrap(); // update for phi
|
else_block = self.builder.get_insert_block().unwrap(); // update for phi
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue