Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
sbillig committed May 19, 2022
1 parent b86c21d commit 814ea20
Show file tree
Hide file tree
Showing 23 changed files with 242 additions and 497 deletions.
1 change: 0 additions & 1 deletion crates/analyzer/src/traversal/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ fn func_stmt(scope: &mut BlockScope, stmt: &Node<fe::FuncStmt>) -> Result<(), Fa
Unsafe { .. } => unsafe_block(scope, stmt),
Assert { .. } => assert(scope, stmt),
Expr { value } => expressions::expr(scope, value, None).map(|_| ()),
Pass => Ok(()),
Revert { .. } => revert(scope, stmt),
Break | Continue => {
loop_flow_statement(scope, stmt);
Expand Down
8 changes: 2 additions & 6 deletions crates/lowering/src/ast_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ where
body: map_body(body, map_fn),
},
// See comment below for why no catch all should be used here
FuncStmt::Pass | FuncStmt::Break | FuncStmt::Continue => stmt.kind,
FuncStmt::Break | FuncStmt::Continue => stmt.kind,
}
.into_traceable_node(stmt.original_id);

Expand Down Expand Up @@ -426,9 +426,7 @@ pub fn inject_before_expression(
transformed_body.push(stmt.clone())
}
}
FuncStmt::Break | FuncStmt::Continue | FuncStmt::Pass => {
transformed_body.push(stmt.clone())
}
FuncStmt::Break | FuncStmt::Continue => transformed_body.push(stmt.clone()),
}
}
transformed_body
Expand Down Expand Up @@ -822,7 +820,6 @@ mod tests {
assert_eq!(
to_code(&original_body),
"if true {
} else {
1 if true else 1 if true else 2
}"
Expand All @@ -833,7 +830,6 @@ mod tests {
assert_eq!(
to_code(&body),
"if true {
} else {
return
1 if true else 1 if true else 2
Expand Down
2 changes: 1 addition & 1 deletion crates/lowering/src/mappers/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ fn func_stmt(context: &mut FnContext, stmt: Node<fe::FuncStmt>) -> Vec<Node<fe::
fe::FuncStmt::Expr { value } => vec![fe::FuncStmt::Expr {
value: expressions::expr(context, value),
}],
fe::FuncStmt::Pass | fe::FuncStmt::Break | fe::FuncStmt::Continue => vec![stmt.kind],
fe::FuncStmt::Break | fe::FuncStmt::Continue => vec![stmt.kind],
fe::FuncStmt::Revert { error } => vec![fe::FuncStmt::Revert {
error: error.map(|expr| expressions::expr(context, expr)),
}],
Expand Down
9 changes: 2 additions & 7 deletions crates/lowering/tests/snapshots/lowering__module_const.snap
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,10 @@ contract Foo {
let my_array: Array<u256, 2> = list_expr_array_u256_2(3, 10)
let my_tuple: $tuple_u256_u256_ = $tuple_u256_u256_(item0: 3, item1: 10)
let my_bar: Bar = Bar(val: 3)
while 3 > 4 {

}
for x in list_expr_array_u256_2(3, 10) {

}
while 3 > 4 {}
for x in list_expr_array_u256_2(3, 10) {}
self.table[10] = 3
if 3 == 10 {

} else if 10 == 10 {
return 3 * 10
} else if true {
Expand Down
6 changes: 0 additions & 6 deletions crates/mir/src/lower/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,6 @@ impl<'db, 'a> BodyLowerHelper<'db, 'a> {
self.lower_expr(value);
}

ast::FuncStmt::Pass => {
// TODO: Generate appropriate error message.
let arg = self.make_unit();
self.builder.revert(arg, stmt.into());
}

ast::FuncStmt::Break => {
let exit = self.scope().loop_exit(&self.scopes);
self.builder.jump(exit, stmt.into())
Expand Down
Loading

0 comments on commit 814ea20

Please sign in to comment.