Skip to content

Commit

Permalink
Code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
gzanitti committed Aug 29, 2023
1 parent b34abf8 commit 1ecb7dc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
17 changes: 5 additions & 12 deletions etk-asm/src/parse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use self::{
};
use crate::ast::Node;
use crate::ops::AbstractOp;
use etk_ops::prague::{Op, RJump, RJumpV, RJumpI};
use etk_ops::prague::{Op, RJump, RJumpI, RJumpV};
use num_bigint::BigInt;
use pest::{iterators::Pair, Parser};

Expand Down Expand Up @@ -87,19 +87,12 @@ fn parse_relative_jump(pair: Pair<Rule>) -> Result<AbstractOp, ParseError> {
let expr = expression::parse(operand)?;

let spec = match pair.as_rule() {
Rule::rjump => {
Op::RJump(RJump(expr.try_into().unwrap()))
}
Rule::rjumpi => {
Op::RJumpI(RJumpI(expr.try_into().unwrap()))
}
Rule::rjumpv => {
Op::RJumpV(RJumpV(expr.try_into().unwrap()))

}
Rule::rjump => Op::RJump(RJump(expr.try_into().unwrap())),
Rule::rjumpi => Op::RJumpI(RJumpI(expr.try_into().unwrap())),
Rule::rjumpv => Op::RJumpV(RJumpV(expr.try_into().unwrap())),
_ => unreachable!(),
};

Ok(AbstractOp::Op(spec))
}

Expand Down
9 changes: 4 additions & 5 deletions etk-dasm/src/blocks/annotated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,6 @@ impl<'a> Annotator<'a> {
Op::RJump(RJump(imm)) => {
let dest = Expr::pc(pc as u16).add(&Expr::constant(imm));
return Some(Exit::Unconditional(dest));

}

Op::RJumpI(RJumpI(imm)) => {
Expand All @@ -679,15 +678,15 @@ impl<'a> Annotator<'a> {
Op::RJumpV(RJumpV(imm)) => {
let max_index = &Expr::constant(&imm[0..8]);
let relative_offset = &Expr::constant(&imm[8..16]);

let case = stack.pop();

let when_false = pc + 1;

let table_position = case.mul(&Expr::constant([32])); // case as postition in table
let relative_jump = table_position.add(relative_offset); // relative_offset[case]
let when_true = relative_jump.add(&Expr::pc(pc as u16)); // pc + relative_offset[case]

let condition = Expr::gt(&case, max_index);
return Some(Exit::Branch {
when_false,
Expand Down

0 comments on commit 1ecb7dc

Please sign in to comment.