Skip to main content

collect_direct_fn_calls

Function collect_direct_fn_calls 

Source
pub fn collect_direct_fn_calls(
    content: &[Expr],
    self_type: Option<&str>,
    calls: &mut Vec<SmolStr>,
)
Expand description

Collects the functions the given code calls by name.

self_type is the type a method’s body is compiled against, so a call the body makes on its own receiver (self.down(n - 1)) is recorded under the mangled name that method resolves to (Box#down). It is None for an ordinary function, whose self names no receiver. A call on any other receiver is left out: which function it reaches depends on the receiver’s type, which only the call site knows.

What this list is for is recursion: a function that can reach itself through it is compiled as a call rather than inlined, so a method that calls itself is compiled the way a recursive function is.

§Panics

Panics when a FunctionCall node carries an empty namespace path, which the parser never produces.