Skip to content

Commit

Permalink
format code
Browse files Browse the repository at this point in the history
  • Loading branch information
pufferfish101007 committed Jan 20, 2024
1 parent a56ee9d commit d664e1c
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 62 deletions.
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,4 @@ macro_rules! make_hq_bad_proj {
column: column!()
}
}};
}
}
27 changes: 21 additions & 6 deletions src/ir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub struct IrProject {

impl TryFrom<Sb3Project> for IrProject {
type Error = HQError;

fn try_from(sb3: Sb3Project) -> Result<IrProject, Self::Error> {
let vars: Rc<RefCell<Vec<IrVar>>> = Rc::new(RefCell::new(
sb3.targets
Expand Down Expand Up @@ -954,20 +954,35 @@ pub fn step_from_top_block<'a>(
steps,
target_id.clone(),
)?;
if next_block.block_info().ok_or(make_hq_bug!(""))?.next.is_none() {
if next_block
.block_info()
.ok_or(make_hq_bug!(""))?
.next
.is_none()
{
next_id = last_nexts.pop();
} else {
next_id = next_block.block_info().ok_or(make_hq_bug!(""))?.next.clone();
next_id = next_block
.block_info()
.ok_or(make_hq_bug!(""))?
.next
.clone();
}
if ops.is_empty() { hq_bug!("assertion failed: !ops.is_empty()") };
if matches!(ops.last().ok_or(make_hq_bug!(""))?.opcode(), IrOpcode::hq_goto { .. }) {
if ops.is_empty() {
hq_bug!("assertion failed: !ops.is_empty()")
};
if matches!(
ops.last().ok_or(make_hq_bug!(""))?.opcode(),
IrOpcode::hq_goto { .. }
) {
next_id = None;
}
if next_id.is_none() {
break;
} else if let Some(block) = blocks.get(&next_id.clone().ok_or(make_hq_bug!(""))?) {
next_block = block;
} else if steps.contains_key(&(target_id.clone(), next_id.clone().ok_or(make_hq_bug!(""))?)) {
} else if steps.contains_key(&(target_id.clone(), next_id.clone().ok_or(make_hq_bug!(""))?))
{
ops.push(
IrOpcode::hq_goto {
step: Some((target_id.clone(), next_id.clone().ok_or(make_hq_bug!(""))?)),
Expand Down
2 changes: 1 addition & 1 deletion src/sb3.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#[cfg(feature = "buddy-alloc")]
mod alloc;

use crate::error::HQError;
use alloc::collections::BTreeMap;
use alloc::string::String;
use alloc::vec::Vec;
use crate::error::HQError;
use enum_field_getter::EnumFieldGetter;
use serde::{Deserialize, Serialize};
use serde_json::Value;
Expand Down
Loading

0 comments on commit d664e1c

Please sign in to comment.