vyrn

std/symbolmap

5 exports, from std/symbolmap.vyrn.

The symbol map of a generated module: for each exported symbol, the source declaration it stands for and any derived facts.

import { symbol, strField, mapJson, symbolMapFn } from "std/symbolmap"

The map is a symbolMap<Slug>() -> String export baked into the module, so the generator cache, keyed by content, cannot let it go stale. Third-party tools read this JSON:

{ "module": "client(./server/api)",
  "symbols": [ { "name": "pastes.list",
                 "origin": { "file": "server/api/pastes.vyrn", "line": 8,
                             "col": 11, "name": "list" },
                 "derived": { "kind": "rpc", "path": "/_/pastes/list" } } ] }

derived is whatever Json the generator puts there; an empty one is omitted.

Dependencies

The import graph shows the whole library.

Imports
Imported by
type Symbol = { name: String, origin: Origin, derived: Array<JsonField> }

One mapped symbol. origin is the Origin reflection handed the generator, not one the generator reconstructed.

fn symbol(name: String, origin: Origin, derived: consume Array<JsonField>) -> Symbol

derived is [] for a symbol with nothing derived about it.

fn mapJson(module: String, symbols: Array<Symbol>) -> String

The map document for the generator call module, as compact JSON, symbols in emission order.

gen fn symbolMapFn(module: String, symbols: Array<Symbol>) -> String

The map declaration to append to a generated module.

The JSON goes through a code quote: \{json} sits in expression position, so the compiler's own escaping makes it a string literal, with no second escaper to disagree with the lexer. The reader finds the declaration by the symbolMap prefix, since mapSlug names it.

Tests

2 test blocks in std/symbolmap.vyrn. CI runs all of them.

Test names
  • a slug distinguishes paths that differ only outside ASCII
  • an ASCII path keeps the slug it always had

Examples

    No example program imports this module.