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

Function get_names

cranelift/module/src/module.rs:484–512  ·  view source on GitHub ↗
(
        functions: &PrimaryMap<FuncId, FunctionDeclaration>,
        data_objects: &PrimaryMap<DataId, DataDeclaration>,
    )

Source from the content-addressed store, hash-verified

482 use std::fmt;
483
484 fn get_names<E: Error>(
485 functions: &PrimaryMap<FuncId, FunctionDeclaration>,
486 data_objects: &PrimaryMap<DataId, DataDeclaration>,
487 ) -> Result<HashMap<String, FuncOrDataId>, E> {
488 let mut names = HashMap::new();
489 for (func_id, decl) in functions.iter() {
490 if let Some(name) = &decl.name {
491 let old = names.insert(name.clone(), FuncOrDataId::Func(func_id));
492 if old.is_some() {
493 return Err(E::invalid_value(
494 Unexpected::Other("duplicate name"),
495 &"FunctionDeclaration's with no duplicate names",
496 ));
497 }
498 }
499 }
500 for (data_id, decl) in data_objects.iter() {
501 if let Some(name) = &decl.name {
502 let old = names.insert(name.clone(), FuncOrDataId::Data(data_id));
503 if old.is_some() {
504 return Err(E::invalid_value(
505 Unexpected::Other("duplicate name"),
506 &"DataDeclaration's with no duplicate names",
507 ));
508 }
509 }
510 }
511 Ok(names)
512 }
513
514 impl Serialize for ModuleDeclarations {
515 fn serialize<S: Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {

Callers 2

visit_seqMethod · 0.85
visit_mapMethod · 0.85

Calls 8

DataClass · 0.85
OkFunction · 0.85
newFunction · 0.50
FuncClass · 0.50
iterMethod · 0.45
insertMethod · 0.45
cloneMethod · 0.45
is_someMethod · 0.45

Tested by

no test coverage detected