Skip to content

Commit

Permalink
lint(all): lint
Browse files Browse the repository at this point in the history
  • Loading branch information
hanmindev committed Feb 8, 2024
1 parent e05d339 commit e003570
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 30 deletions.
52 changes: 29 additions & 23 deletions src/front/mergers/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::front::ast_types::{
use crate::front::mergers::convert::context::Context;
use crate::front::mergers::definition_table::DefinitionTable;
use crate::middle::format::ir_types::{
Address, CheckVal, CompareOp, CompareVal, Cond, IrBlock, IrFnCall, IrFnDef, IrIf,
Address, CheckVal, Cond, IrBlock, IrFnCall, IrFnDef, IrIf,
IrScoreOperation, IrScoreOperationType, IrScoreSet, IrStatement, IrUnless,
};
use crate::middle::format::types::GlobalName;
Expand Down Expand Up @@ -622,17 +622,20 @@ mod tests {

let mut program = program_merger.export_program();

assert_eq!(test_calculation(
&program
.function_definitions
.get("pkg/root/0_main")
.unwrap()
.body,
&Address {
name: AddressOrigin::User("pkg/root/0_b".to_string()),
offset: 0,
},
), 11);
assert_eq!(
test_calculation(
&program
.function_definitions
.get("pkg/root/0_main")
.unwrap()
.body,
&Address {
name: AddressOrigin::User("pkg/root/0_b".to_string()),
offset: 0,
},
),
11
);
}

#[test]
Expand All @@ -649,16 +652,19 @@ mod tests {

let mut program = program_merger.export_program();

assert_eq!(test_calculation(
&program
.function_definitions
.get("pkg/root/0_main")
.unwrap()
.body,
&Address {
name: AddressOrigin::User("pkg/root/0_a".to_string()),
offset: 0,
},
), 25);
assert_eq!(
test_calculation(
&program
.function_definitions
.get("pkg/root/0_main")
.unwrap()
.body,
&Address {
name: AddressOrigin::User("pkg/root/0_a".to_string()),
offset: 0,
},
),
25
);
}
}
7 changes: 3 additions & 4 deletions src/front/mergers/convert/context.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::cmp::Reverse;
use std::collections::{BinaryHeap, HashSet};
use crate::front::ast_types::{GlobalResolvedName, NamePath, Reference};
use crate::front::mergers::convert::global_name_updater;
use crate::front::mergers::definition_table::DefinitionTable;
use crate::middle::format::ir_types::{Address, AddressOrigin};
use std::cmp::Reverse;
use std::collections::{BinaryHeap, HashSet};
use std::rc::Rc;

struct VarGenerator {
Expand Down Expand Up @@ -59,7 +59,6 @@ impl ConstGenerator {
}
}


pub struct Context<'a> {
pub fn_name: String,
block_count: u32,
Expand All @@ -72,7 +71,7 @@ impl Context<'_> {
pub fn new<'a>(
fn_name: &str,
definition_table: &'a DefinitionTable<Rc<GlobalResolvedName>>,
const_generator: &'a mut ConstGenerator
const_generator: &'a mut ConstGenerator,
) -> Context<'a> {
Context {
fn_name: fn_name.to_string(),
Expand Down
2 changes: 1 addition & 1 deletion src/front/mergers/program.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use crate::front::ast_retriever::retriever::FileRetriever;
use crate::front::file_system::fs::FileSystem;
use crate::front::mergers::convert::context::ConstGenerator;
use crate::front::mergers::convert::{convert_fn, global_name_updater};
use crate::front::mergers::definition_table::DefinitionTable;
use crate::front::mergers::package::{Package, Packager};
use crate::middle::format::types::Program;
use std::collections::{HashMap, HashSet};
use std::marker::PhantomData;
use std::rc::Rc;
use crate::front::mergers::convert::context::ConstGenerator;

pub struct ProgramMerger<R> {
root_package: String,
Expand Down
9 changes: 7 additions & 2 deletions src/middle/format/ir_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,15 @@ impl IrBlock {

impl std::fmt::Display for IrBlock {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "fn {} block {} {{\n", self.get_fn_name(), self.fn_block_index)?;
write!(
f,
"fn {} block {} {{\n",
self.get_fn_name(),
self.fn_block_index
)?;
for statement in &self.statements {
write!(f, " {:?}\n", statement)?;
}
write!(f, "}}")
}
}
}

0 comments on commit e003570

Please sign in to comment.