Skip to content

Commit

Permalink
chore(rivetc.codegen): format code
Browse files Browse the repository at this point in the history
  • Loading branch information
StunxFS committed Nov 12, 2023
1 parent fe61cbe commit 3d75cd2
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions rivetc/src/codegen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2330,7 +2330,9 @@ def gen_expr(self, expr, custom_tmp = None):
self.gen_expr(self.while_continue_expr)
self.cur_fn.add_br(self.loop_entry_label)
else:
self.gen_defer_stmts(scope = expr.scope, run_defer_previous = True)
self.gen_defer_stmts(
scope = expr.scope, run_defer_previous = True
)
self.cur_fn.add_br(self.loop_exit_label)
return ir.Skip()
elif isinstance(expr, ast.ReturnExpr):
Expand All @@ -2343,7 +2345,9 @@ def gen_expr(self, expr, custom_tmp = None):
ir.Name("result")
), ir.IntLit(ir.UINT8_T, "1")
)
self.gen_defer_stmts(scope = expr.scope, run_defer_previous = True)
self.gen_defer_stmts(
scope = expr.scope, run_defer_previous = True
)
self.cur_fn.add_ret_void()
elif expr.has_expr:
is_array = self.cur_fn_ret_typ.symbol().kind == TypeKind.Array
Expand All @@ -2366,13 +2370,19 @@ def gen_expr(self, expr, custom_tmp = None):
expr_ = tmp
if wrap_result:
expr_ = self.result_value(self.cur_fn_ret_typ, expr_)
self.gen_defer_stmts(scope = expr.scope, run_defer_previous = True)
self.gen_defer_stmts(
scope = expr.scope, run_defer_previous = True
)
self.cur_fn.add_ret(expr_)
elif wrap_result:
self.gen_defer_stmts(scope = expr.scope, run_defer_previous = True)
self.gen_defer_stmts(
scope = expr.scope, run_defer_previous = True
)
self.cur_fn.add_ret(self.result_void(self.cur_fn_ret_typ))
else:
self.gen_defer_stmts(scope = expr.scope, run_defer_previous = True)
self.gen_defer_stmts(
scope = expr.scope, run_defer_previous = True
)
self.cur_fn.add_ret_void()
return ir.Skip()
elif isinstance(expr, ast.ThrowExpr):
Expand Down Expand Up @@ -2461,8 +2471,10 @@ def gen_defer_stmts(
):
for i in range(len(self.cur_fn_defer_stmts) - 1, -1, -1):
defer_stmt = self.cur_fn_defer_stmts[i]
if not ((run_defer_previous and scope.start >= defer_stmt.scope.start) or
(scope.start == defer_stmt.scope.start)):
if not (
(run_defer_previous and scope.start >= defer_stmt.scope.start)
or (scope.start == defer_stmt.scope.start)
):
continue
if defer_stmt.mode == ast.DeferMode.ERROR and not gen_errdefer:
# Should be run only when an error occurs
Expand Down

0 comments on commit 3d75cd2

Please sign in to comment.