MCPcopy Create free account
hub / github.com/vercel/vercel / crate_from_symbol

Function crate_from_symbol

packages/python-analysis/scripts/profile-wasm.py:355–374  ·  view source on GitHub ↗

Extract the originating crate name from a demangled Rust symbol. Demangled symbols look like: uv_pep508::marker::simplify::collect_dnf core::num::flt2dec::strategy::dragon::format_shortest as core::fmt::Display>::fmt .rodata.core::num::dec2flt:

(symbol)

Source from the content-addressed store, hash-verified

353
354
355def crate_from_symbol(symbol):
356 """Extract the originating crate name from a demangled Rust symbol.
357
358 Demangled symbols look like:
359 uv_pep508::marker::simplify::collect_dnf
360 core::num::flt2dec::strategy::dragon::format_shortest
361 <uv_pep508::Requirement<T> as core::fmt::Display>::fmt
362 .rodata.core::num::dec2flt::table::POWER_OF_FIVE_128
363 .rodata..Lanon.f2a1a4d36baa2f0507e070ce676efac8.547
364 """
365 # Strip .rodata. prefix from data segment symbols
366 s = re.sub(r"^\.rodata\.", "", symbol)
367 # Skip anonymous data segments — no crate info available
368 if s.startswith(".Lanon.") or s.startswith("anon."):
369 return None
370 s = s.lstrip("<")
371 m = re.match(r"([a-zA-Z_][a-zA-Z0-9_]*)::", s)
372 if m:
373 return m.group(1)
374 return None
375
376
377# ---------------------------------------------------------------------------

Callers 1

demangle_symbolsFunction · 0.85

Calls 3

lstripMethod · 0.80
groupMethod · 0.80
matchMethod · 0.45

Tested by

no test coverage detected