lang::name_text

lang/src/name_text.mo

Pure name-text conversions between a source name and its unqualified (or bare) spelling.

This is the ONE boundary both the front end and the compiler backend use. It deliberately depends on nothing but the ambient String primitives: lang needs these helpers to judge references, and codegen needs them to build symbols. Keeping the leaf free of lang::types is what lets codegen import it without making lang depend on codegen -- the cycle codegen-mote-extraction Phase 1 cuts.

The byte-wise forms are deliberate, not incidental: String.slice's third argument is a LENGTH, and symbols.mo records two real bugs from getting that wrong. String.get scans without allocating.

defunqualify_def_name#
pub def unqualify_def_name (s : String) : String

The source name inside a qualified symbol -- init.string::String.beq back to String.beq. Splits at the LAST ::: a def key has one, and a constructor key (owner::ctor) has the bare constructor after its last one. A name that was never qualified (a synthesized or already-flat one) comes back unchanged, so this is safe to apply anywhere a source-level name is wanted.

defstring_matches_bare#
pub def string_matches_bare (s : String) (bare : String) : Bool

Does s equal bare, or spell it qualified (module::bare -- the part after the LAST ::, exactly what unqualify_def_name keeps)? The no-allocation twin of String.beq (unqualify_def_name s) bare: a byte comparison per position instead of a slice per position, for the hot paths (class_name_eq, carrier_id_eq) that run per instance/class comparison.

defglobal_key_join#
pub def global_key_join (module_text : String) (name_text : String) : String

Join a module text and a name text into the canonical whole-program key. :: cannot occur in an identifier, so the LAST :: is the module/name boundary (global_key_module_text/global_key_name_text split it back). A module path's own dots are part of module_text; never split on ..

defglobal_key_is_qualified#
pub def global_key_is_qualified (s : String) : Bool
defglobal_key_module_text#
pub def global_key_module_text (s : String) : Option String
defglobal_key_name_text#
pub def global_key_name_text (s : String) : Option String
defctor_key_join#
pub def ctor_key_join (owner_key : String) (ctor : String) : String

A constructor key: the owner's canonical key plus the constructor identifier. Its last :: names the constructor, so ctor_key_join's output must go to the ctor helpers, never to global_key_module_text.

defctor_arity_key#
pub def ctor_arity_key (owner_key : String) (ctor : String) (arity : I64) : String

The constructor tag-map key: owner + ctor + arity. # cannot occur in an identifier, so it separates the numeric arity without aliasing an identifier that ends in digits.