This commit is contained in:
Chris Fallin 2023-02-28 16:33:39 -08:00
parent 1c0b2964af
commit 6508cc9078
2 changed files with 7 additions and 8 deletions

View file

@ -586,8 +586,7 @@ pub fn compile(module: &Module<'_>) -> anyhow::Result<Vec<u8>> {
for (func, func_decl) in module.funcs.entries().skip(num_func_imports) {
match func_decl {
FuncDecl::Import(_, _) => anyhow::bail!("Import comes after func with body: {}", func),
FuncDecl::Lazy(sig, _, _)
| FuncDecl::Body(sig, _, _) => {
FuncDecl::Lazy(sig, _, _) | FuncDecl::Body(sig, _, _) => {
funcs.function(sig.index() as u32);
}
FuncDecl::None => panic!("FuncDecl::None at compilation time"),

View file

@ -75,18 +75,18 @@ impl<'a> FuncDecl<'a> {
pub fn name(&self) -> &str {
match self {
FuncDecl::Body(_, name, _)
| FuncDecl::Lazy(_, name, _)
| FuncDecl::Import(_, name) => &name[..],
FuncDecl::Body(_, name, _) | FuncDecl::Lazy(_, name, _) | FuncDecl::Import(_, name) => {
&name[..]
}
FuncDecl::None => panic!("No name for FuncDecl::None"),
}
}
pub fn set_name(&mut self, new_name: &str) {
match self {
FuncDecl::Body(_, name, _)
| FuncDecl::Lazy(_, name, _)
| FuncDecl::Import(_, name) => *name = new_name.to_owned(),
FuncDecl::Body(_, name, _) | FuncDecl::Lazy(_, name, _) | FuncDecl::Import(_, name) => {
*name = new_name.to_owned()
}
FuncDecl::None => panic!("No name for FuncDecl::None"),
}
}