Add StrCat support and update hello-zig to support dev backend

This commit is contained in:
Brendan Hansknecht 2021-09-18 15:55:04 -07:00
parent 2f24067267
commit d1021d652d
6 changed files with 186 additions and 94 deletions

View file

@ -93,12 +93,8 @@ where
for (layout, sym) in proc.args {
self.set_layout_map(*sym, layout)?;
}
// let start = std::time::Instant::now();
self.scan_ast(&proc.body);
self.create_free_map();
// let duration = start.elapsed();
// println!("Time to calculate lifetimes: {:?}", duration);
// println!("{:?}", self.last_seen_map());
self.build_stmt(&proc.body, &proc.ret_layout)?;
self.finalize()
}
@ -119,6 +115,11 @@ where
self.free_symbols(stmt)?;
Ok(())
}
Stmt::Refcounting(_modify, following) => {
// TODO: actually deal with refcounting. For hello world, we just skipped it.
self.build_stmt(following, ret_layout)?;
Ok(())
}
Stmt::Switch {
cond_symbol,
cond_layout,
@ -298,6 +299,13 @@ where
arg_layouts,
ret_layout,
),
Symbol::STR_CONCAT => self.build_run_low_level(
sym,
&LowLevel::StrConcat,
arguments,
arg_layouts,
ret_layout,
),
x if x
.module_string(&self.env().interns)
.starts_with(ModuleName::APP) =>
@ -470,6 +478,13 @@ where
arg_layouts,
ret_layout,
),
LowLevel::StrConcat => self.build_fn_call(
sym,
bitcode::STR_CONCAT.to_string(),
args,
arg_layouts,
ret_layout,
),
x => Err(format!("low level, {:?}. is not yet implemented", x)),
}
}