MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / declare_function

Method declare_function

cranelift/filetests/src/function_runner.rs:184–205  ·  view source on GitHub ↗

Declares a function an registers it as a linkable and callable target internally

(&mut self, func: &Function)

Source from the content-addressed store, hash-verified

182
183 /// Declares a function an registers it as a linkable and callable target internally
184 pub fn declare_function(&mut self, func: &Function) -> Result<()> {
185 let next_id = self.defined_functions.len() as u32;
186 match self.defined_functions.entry(func.name.clone()) {
187 Entry::Occupied(_) => {
188 anyhow::bail!("Duplicate function with name {} found!", &func.name)
189 }
190 Entry::Vacant(v) => {
191 let name = func.name.to_string();
192 let func_id =
193 self.module
194 .declare_function(&name, Linkage::Local, &func.signature)?;
195
196 v.insert(DefinedFunction {
197 new_name: UserExternalName::new(TESTFILE_NAMESPACE, next_id),
198 signature: func.signature.clone(),
199 func_id,
200 });
201 }
202 };
203
204 Ok(())
205 }
206
207 /// Renames the function to its new [UserExternalName], as well as any other function that
208 /// it may reference.

Callers 3

add_functionsMethod · 0.45
nopFunction · 0.45

Calls 7

OkFunction · 0.85
newFunction · 0.50
lenMethod · 0.45
entryMethod · 0.45
cloneMethod · 0.45
to_stringMethod · 0.45
insertMethod · 0.45

Tested by 1

nopFunction · 0.36