(
&mut self,
this: &str,
func: &Function,
ignore_param: bool,
)
| 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()) |
no test coverage detected