rename Unreachable -> Rethrow

This commit is contained in:
Folkert 2021-01-07 20:19:12 +01:00
parent 9dd02ea090
commit e005dbde4c
5 changed files with 15 additions and 20 deletions

View file

@ -1494,9 +1494,9 @@ pub fn build_exp_stmt<'a, 'ctx, 'env>(
call,
layout,
pass,
fail: roc_mono::ir::Stmt::Unreachable,
fail: roc_mono::ir::Stmt::Rethrow,
} => {
// when the fail case is just Unreachable, there is no cleanup work to do
// when the fail case is just Rethrow, there is no cleanup work to do
// so we can just treat this invoke as a normal call
let stmt =
roc_mono::ir::Stmt::Let(*symbol, Expr::Call(call.clone()), layout.clone(), pass);
@ -1561,7 +1561,7 @@ pub fn build_exp_stmt<'a, 'ctx, 'env>(
}
},
Unreachable => {
Rethrow => {
cxa_rethrow_exception(env);
// used in exception handling

View file

@ -170,7 +170,7 @@ impl<'a> ParamMap<'a> {
}
Inc(_, _) | Dec(_, _) => unreachable!("these have not been introduced yet"),
Ret(_) | Unreachable | Jump(_, _) | RuntimeError(_) => {
Ret(_) | Rethrow | Jump(_, _) | RuntimeError(_) => {
// these are terminal, do nothing
}
}
@ -515,7 +515,7 @@ impl<'a> BorrowInfState<'a> {
}
Inc(_, _) | Dec(_, _) => unreachable!("these have not been introduced yet"),
Ret(_) | RuntimeError(_) | Unreachable => {
Ret(_) | RuntimeError(_) | Rethrow => {
// these are terminal, do nothing
}
}

View file

@ -50,7 +50,7 @@ pub fn occuring_variables(stmt: &Stmt<'_>) -> (MutSet<Symbol>, MutSet<Symbol>) {
result.insert(*symbol);
}
Unreachable => {}
Rethrow => {}
Inc(symbol, cont) | Dec(symbol, cont) => {
result.insert(*symbol);
@ -792,7 +792,7 @@ impl<'a> Context<'a> {
}
}
Unreachable => (stmt, MutSet::default()),
Rethrow => (stmt, MutSet::default()),
Jump(j, xs) => {
let empty = MutSet::default();
@ -953,7 +953,7 @@ pub fn collect_stmt(
vars
}
Unreachable => vars,
Rethrow => vars,
RuntimeError(_) => vars,
}

View file

@ -762,7 +762,7 @@ pub enum Stmt<'a> {
ret_layout: Layout<'a>,
},
Ret(Symbol),
Unreachable,
Rethrow,
Inc(Symbol, &'a Stmt<'a>),
Dec(Symbol, &'a Stmt<'a>),
Join {
@ -911,11 +911,6 @@ pub enum CallType<'a> {
},
}
// x = f a b c; S
//
//
// invoke x = f a b c in S else Unreachable
#[derive(Clone, Debug, PartialEq)]
pub enum Expr<'a> {
Literal(Literal<'a>),
@ -1133,7 +1128,7 @@ impl<'a> Stmt<'a> {
symbol,
call,
pass,
fail: Stmt::Unreachable,
fail: Stmt::Rethrow,
..
} => alloc
.text("let ")
@ -1166,7 +1161,7 @@ impl<'a> Stmt<'a> {
.append(symbol_to_doc(alloc, *symbol))
.append(";"),
Unreachable => alloc.text("unreachable;"),
Rethrow => alloc.text("unreachable;"),
Switch {
cond_symbol,
@ -4572,7 +4567,7 @@ fn substitute_in_stmt_help<'a>(
}
}
Unreachable => None,
Rethrow => None,
RuntimeError(_) => None,
}
@ -5293,7 +5288,7 @@ fn build_call<'a>(
hole: &'a Stmt<'a>,
) -> Stmt<'a> {
if can_throw_exception(&call) {
let fail = env.arena.alloc(Stmt::Unreachable);
let fail = env.arena.alloc(Stmt::Rethrow);
Stmt::Invoke {
symbol: assigned,
call,

View file

@ -102,7 +102,7 @@ fn insert_jumps<'a>(
pass: Stmt::Ret(rsym),
..
} if needle == *fsym && symbol == rsym => {
debug_assert_eq!(fail, &&Stmt::Unreachable);
debug_assert_eq!(fail, &&Stmt::Rethrow);
// replace the call and return with a jump
@ -237,7 +237,7 @@ fn insert_jumps<'a>(
None => None,
},
Unreachable => None,
Rethrow => None,
Ret(_) => None,
Jump(_, _) => None,
RuntimeError(_) => None,