Skip to content

Commit

Permalink
hacking
Browse files Browse the repository at this point in the history
  • Loading branch information
g-r-a-n-t committed Jun 23, 2022
1 parent 637b502 commit 6252820
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
8 changes: 4 additions & 4 deletions crates/analyzer/src/traversal/expressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,20 +141,20 @@ pub fn expr_list(

pub fn expr_repeat(
context: &mut dyn AnalyzerContext,
value: Node<fe::Expr>,
len: Node<fe::Expr>,
value: &Node<fe::Expr>,
len: &Node<fe::Expr>,
expected_type: Option<&Array>,
) -> Result<ExpressionAttributes, FatalError> {
let value = assignable_expr(context, &value, None)?;
let len = if let Constant::Int(len) = eval_expr(context, &len) {
let len = if let Constant::Int(len) = eval_expr(context, &len)? {
len
} else {
panic!("shit")
};

let array_typ = Array {
size: len.to_usize().unwrap(),
inner: value.typ,
inner: Box::new(value.typ),
};

Ok(ExpressionAttributes {
Expand Down
15 changes: 15 additions & 0 deletions crates/mir/src/lower/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,21 @@ impl<'db, 'a> BodyLowerHelper<'db, 'a> {
self.builder.aggregate_construct(ty, args, expr.into())
}

ast::Expr::Repeat { value, len } => {
let array_type = if let Type::Array(array_type) = self.analyzer_body.expressions[&expr.id].typ.clone() {
array_type
} else {
panic!("shit");
};

let args = (0..array_type.size)
.into_iter()
.map(|_| self.lower_expr_to_value(value))
.collect();
let ty = self.expr_ty(expr);
self.builder.aggregate_construct(ty, args, expr.into())
}

ast::Expr::Bool(b) => {
let imm = self.builder.make_imm_from_bool(*b, ty);
self.builder.bind(imm, expr.into())
Expand Down

0 comments on commit 6252820

Please sign in to comment.