MCPcopy Create free account
hub / github.com/bytecodealliance/wit-bindgen / mbt_sig

Method mbt_sig

crates/moonbit/src/pkg.rs:314–352  ·  view source on GitHub ↗
(
        &mut self,
        this: &str,
        func: &Function,
        ignore_param: bool,
    )

Source from the content-addressed store, hash-verified

312 }
313
314 pub(crate) fn mbt_sig(
315 &mut self,
316 this: &str,
317 func: &Function,
318 ignore_param: bool,
319 ) -> MoonbitSignature {
320 let name = match func.kind {
321 FunctionKind::Freestanding => func.name.to_moonbit_ident(),
322 FunctionKind::Constructor(_) => {
323 func.name.replace("[constructor]", "").to_moonbit_ident()
324 }
325 _ => func.name.split(".").last().unwrap().to_moonbit_ident(),
326 };
327 let type_name = match func.kind.resource() {
328 Some(ty) => {
329 format!("{}::", self.type_constructor(this, &Type::Id(ty)))
330 }
331 None => "".into(),
332 };
333
334 let params = func
335 .params
336 .iter()
337 .map(|Param { name, ty, .. }| {
338 let name = if ignore_param {
339 format!("_{}", name.to_moonbit_ident())
340 } else {
341 name.to_moonbit_ident()
342 };
343 (name, *ty)
344 })
345 .collect::<Vec<_>>();
346
347 MoonbitSignature {
348 name: format!("{type_name}{name}"),
349 params,
350 result_type: func.result,
351 }
352 }
353
354 pub(crate) fn world_name(resolve: &Resolve, world: WorldId) -> String {
355 format!("world.{}", resolve.worlds[world].name.to_lower_camel_case())

Callers 2

importMethod · 0.80
exportMethod · 0.80

Calls 3

to_moonbit_identMethod · 0.80
mapMethod · 0.80
iterMethod · 0.45

Tested by

no test coverage detected