Add Array Expression to MIR
This commit is contained in:
parent
587ab8afd5
commit
ad20fefabc
@ -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"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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(']')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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),
|
||||
|
@ -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"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -261,6 +261,7 @@ impl Expression {
|
||||
}
|
||||
}
|
||||
ExprKind::Index(expression, _) => todo!("type inference for index expression"),
|
||||
ExprKind::Array(expressions) => todo!("type inference for array expression"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user