Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

Commit

Permalink
feat: handle other statement types and pushes/
Browse files Browse the repository at this point in the history
  • Loading branch information
igorline committed Oct 5, 2023
1 parent 94f5bc6 commit 9dc6f61
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions huff_parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,12 +525,26 @@ impl Parser {
let (body_statements_take, body_statements_return) =
macro_statements.iter().fold((0i16, 0i16), |acc, st| {
let (statement_takes, statement_returns) = match st.ty {
StatementType::Literal(_) => (0i8, 1i8),
StatementType::Literal(_) |
StatementType::Constant(_) |
StatementType::BuiltinFunctionCall(_) |
StatementType::ArgCall(_) |
StatementType::LabelCall(_) => (0i8, 1i8),
StatementType::Opcode(opcode) => {
let stack_changes = opcode.stack_changes();
(stack_changes.0 as i8, stack_changes.1 as i8)
if opcode.is_value_push() {
(0i8, 0i8)
} else {
let stack_changes = opcode.stack_changes();
(stack_changes.0 as i8, stack_changes.1 as i8)
}
}
StatementType::Label(_) => (0i8, 0i8),
StatementType::MacroInvocation(_) => {
todo!()
}
StatementType::Code(_) => {
todo!("should throw error")
}
_ => (0i8, 0i8),
};

// acc.1 is always non negative
Expand Down

0 comments on commit 9dc6f61

Please sign in to comment.