Finished this refactor

This commit is contained in:
greg 2018-11-02 19:54:04 -07:00
parent cab4702bd6
commit e71d404071

View File

@ -373,8 +373,11 @@ impl<'a> State<'a> {
let cond = self.expression(Node::Expr(cond))?; let cond = self.expression(Node::Expr(cond))?;
for alt in alternatives { for alt in alternatives {
// no matter what type of condition we have, ignore alternative if the guard evaluates false // no matter what type of condition we have, ignore alternative if the guard evaluates false
if let Some(guard_expr) = alt.guard { if let Some(ref guard_expr) = alt.guard {
let guard_expr = guard_expr.clone().replace_conditional_target_sigil(&cond); let guard_expr = match &cond {
Node::Expr(ref e) => guard_expr.clone().replace_conditional_target_sigil(e),
_ => guard_expr.clone()
};
match self.expression(guard_expr.to_node())? { match self.expression(guard_expr.to_node())? {
Node::Expr(Expr::Lit(::reduced_ast::Lit::Bool(true))) => (), Node::Expr(Expr::Lit(::reduced_ast::Lit::Bool(true))) => (),
_ => continue, _ => continue,
@ -382,8 +385,8 @@ impl<'a> State<'a> {
} }
match cond { match cond {
Node::PrimObject { tag, items, .. } => { Node::PrimObject { ref tag, ref items, .. } => {
if alt.tag.map(|t| t == tag).unwrap_or(true) { if alt.tag.map(|t| t == *tag).unwrap_or(true) {
let mut inner_state = State { let mut inner_state = State {
values: self.values.new_scope(None), values: self.values.new_scope(None),
symbol_table_handle: self.symbol_table_handle.clone(), symbol_table_handle: self.symbol_table_handle.clone(),
@ -406,7 +409,7 @@ impl<'a> State<'a> {
Node::PrimTuple { .. } => { Node::PrimTuple { .. } => {
return Err(format!("Prim tuple not done")) return Err(format!("Prim tuple not done"))
}, },
Node::Expr(e) => { Node::Expr(ref _e) => {
if let None = alt.tag { if let None = alt.tag {
return self.block(alt.item) return self.block(alt.item)
} }