Add Array Expression to MIR

This commit is contained in:
Sofia 2025-07-13 18:37:18 +03:00
parent 587ab8afd5
commit ad20fefabc
6 changed files with 17 additions and 0 deletions

View File

@ -334,6 +334,7 @@ impl mir::Expression {
}
}
mir::ExprKind::Index(expression, _) => todo!("codegen for index expression"),
mir::ExprKind::Array(expressions) => todo!("codegen for array expression"),
}
}
}

View File

@ -132,6 +132,18 @@ impl Display for ExprKind {
Display::fmt(&expression, f)?;
write_index(f, *idx)
}
ExprKind::Array(expressions) => {
f.write_char('[')?;
let mut iter = expressions.iter();
if let Some(item) = iter.next() {
Display::fmt(item, f);
while let Some(item) = iter.next() {
f.write_str(", ")?;
Display::fmt(item, f)?;
}
}
f.write_char(']')
}
}
}
}

View File

@ -209,6 +209,7 @@ pub struct Import(pub String, pub Metadata);
pub enum ExprKind {
Variable(NamedVariableRef),
Index(Box<Expression>, u64),
Array(Vec<Expression>),
Literal(Literal),
BinOp(BinaryOperator, Box<Expression>, Box<Expression>),
FunctionCall(FunctionCall),

View File

@ -374,6 +374,7 @@ impl Expression {
}
ExprKind::Block(block) => block.typecheck(state, &hints, hint_t),
ExprKind::Index(expression, _) => todo!("typechecking for index expression"),
ExprKind::Array(expressions) => todo!("typechecking for array expression"),
}
}
}

View File

@ -261,6 +261,7 @@ impl Expression {
}
}
ExprKind::Index(expression, _) => todo!("type inference for index expression"),
ExprKind::Array(expressions) => todo!("type inference for array expression"),
}
}
}

View File

@ -87,6 +87,7 @@ impl ReturnType for Expression {
FunctionCall(fcall) => fcall.return_type(),
If(expr) => expr.return_type(),
Index(expression, _) => todo!("return type for index"),
Array(expressions) => todo!("return type for array expression"),
}
}
}