Skip to content

Commit

Permalink
Purge the compiler of codegen::Expression::List (#1551)
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasSte authored Sep 26, 2023
1 parent 614d413 commit de3f10c
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 23 deletions.
1 change: 0 additions & 1 deletion src/codegen/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -987,7 +987,6 @@ impl ControlFlowGraph {
Expression::GetRef { expr, .. } => {
format!("(deref {}", self.expr_to_string(contract, ns, expr))
}
_ => panic!("{expr:?}"),
}
}

Expand Down
12 changes: 2 additions & 10 deletions src/codegen/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1077,16 +1077,6 @@ pub fn expression(
ty: ty.clone(),
var_no: *var_no,
},
ast::Expression::List {
loc,
list: elements,
} => Expression::List {
loc: *loc,
exprs: elements
.iter()
.map(|e| expression(e, cfg, contract_no, func, ns, vartab, opt))
.collect::<Vec<Expression>>(),
},
ast::Expression::GetRef { loc, ty, expr: exp } => Expression::GetRef {
loc: *loc,
ty: ty.clone(),
Expand Down Expand Up @@ -1151,6 +1141,8 @@ pub fn expression(
ty,
}
}

ast::Expression::List { .. } => unreachable!("List shall not appear in the CFG"),
}
}

Expand Down
11 changes: 0 additions & 11 deletions src/codegen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,10 +502,6 @@ pub enum Expression {
ty: Type,
exprs: Vec<Expression>,
},
List {
loc: pt::Loc,
exprs: Vec<Expression>,
},
Less {
loc: pt::Loc,
signed: bool,
Expand Down Expand Up @@ -718,7 +714,6 @@ impl CodeLocation for Expression {
| Expression::StringCompare { loc, .. }
| Expression::StringConcat { loc, .. }
| Expression::FunctionArg { loc, .. }
| Expression::List { loc, .. }
| Expression::ShiftRight { loc, .. }
| Expression::ShiftLeft { loc, .. }
| Expression::RationalNumberLiteral { loc, .. }
Expand Down Expand Up @@ -882,12 +877,6 @@ impl RetrieveType for Expression {
| Expression::StringCompare { .. }
| Expression::LessEqual { .. } => Type::Bool,

Expression::List { exprs, .. } => {
assert_eq!(exprs.len(), 1);

exprs[0].ty()
}

Expression::AdvancePointer { .. } => Type::BufferPointer,
Expression::FormatString { .. } => Type::String,
Expression::Poison => unreachable!("Expression does not have a type"),
Expand Down
1 change: 0 additions & 1 deletion src/emit/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1843,7 +1843,6 @@ pub(super) fn expression<'a, T: TargetRuntime<'a> + ?Sized>(
}

Expression::RationalNumberLiteral { .. }
| Expression::List { .. }
| Expression::Undefined { .. }
| Expression::Poison
| Expression::BytesCast { .. } => {
Expand Down

0 comments on commit de3f10c

Please sign in to comment.