add NullPointer to mono::ir::Expr

This commit is contained in:
Folkert 2023-03-30 19:57:16 +02:00
parent 63cdd00d13
commit 09779f65ad
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
9 changed files with 28 additions and 3 deletions

View file

@ -761,7 +761,7 @@ impl<'a> BorrowInfState<'a> {
Call(call) => self.collect_call(interner, param_map, z, call),
Literal(_) | RuntimeErrorFunction(_) => {}
Literal(_) | NullPointer | RuntimeErrorFunction(_) => {}
StructAtIndex { structure: x, .. } => {
// if the structure (record/tag/array) is owned, the extracted value is

View file

@ -390,6 +390,7 @@ impl<'a, 'r> Ctx<'a, 'r> {
fn check_expr(&mut self, e: &Expr<'a>) -> Option<InLayout<'a>> {
match e {
Expr::Literal(_) => None,
Expr::NullPointer => None,
Expr::Call(call) => self.check_call(call),
&Expr::Tag {
tag_layout,

View file

@ -213,7 +213,7 @@ pub fn occurring_variables_expr(expr: &Expr<'_>, result: &mut MutSet<Symbol>) {
result.insert(*symbol);
}
EmptyArray | RuntimeErrorFunction(_) | Literal(_) => {}
EmptyArray | RuntimeErrorFunction(_) | Literal(_) | NullPointer => {}
GetTagId {
structure: symbol, ..
@ -946,7 +946,7 @@ impl<'a, 'i> Context<'a, 'i> {
self.arena.alloc(Stmt::Let(z, v, l, b))
}
EmptyArray | Literal(_) | Reset { .. } | RuntimeErrorFunction(_) => {
EmptyArray | Literal(_) | Reset { .. } | NullPointer | RuntimeErrorFunction(_) => {
// EmptyArray is always stack-allocated function pointers are persistent
self.arena.alloc(Stmt::Let(z, v, l, b))
}

View file

@ -1878,6 +1878,7 @@ pub enum Expr<'a> {
arguments: &'a [Symbol],
},
Struct(&'a [Symbol]),
NullPointer,
StructAtIndex {
index: u64,
@ -2016,6 +2017,7 @@ impl<'a> Expr<'a> {
.append(alloc.space())
.append(alloc.intersperse(it, " "))
}
NullPointer => alloc.text("NullPointer"),
Reuse {
symbol,
tag_id,
@ -7462,6 +7464,8 @@ fn substitute_in_expr<'a>(
}
}
NullPointer => None,
Reuse { .. } | Reset { .. } => unreachable!("reset/reuse have not been introduced yet"),
Struct(args) => {

View file

@ -319,6 +319,7 @@ fn insert_reset<'a>(
}
Literal(_)
| NullPointer
| Call(_)
| Tag { .. }
| Struct(_)
@ -839,6 +840,7 @@ fn has_live_var<'a>(jp_live_vars: &JPLiveVarMap, stmt: &'a Stmt<'a>, needle: Sym
fn has_live_var_expr<'a>(expr: &'a Expr<'a>, needle: Symbol) -> bool {
match expr {
Expr::Literal(_) => false,
Expr::NullPointer => false,
Expr::Call(call) => has_live_var_call(call, needle),
Expr::Array { elems: fields, .. } => {
for element in fields.iter() {