SvPortSim.Verilator.Wrapper.JsonLiteral (SvPortSim v0.1.0)

Copy Markdown View Source

Encodes deterministic JSON literals and escaped C++ string-literal bodies for generated Verilator wrapper sources.

json/1 intentionally supports only the value shapes emitted by the wrapper generator: nil, booleans, integers, strings, lists, and maps. Map keys are stringified and sorted so generated metadata is deterministic.

cpp_string/1 escapes a string body for insertion inside an existing C++ string literal. It does not add surrounding quotes.

Summary

Functions

Escapes a string body for insertion inside a C++ string literal.

Encodes a deterministic compact JSON literal.

Types

json_value()

@type json_value() ::
  nil
  | boolean()
  | integer()
  | String.t()
  | [json_value()]
  | %{optional(term()) => json_value()}

Functions

cpp_string(value)

@spec cpp_string(String.t()) :: String.t()

Escapes a string body for insertion inside a C++ string literal.

The returned value is not surrounded with quotes.

json(value)

@spec json(json_value()) :: String.t()

Encodes a deterministic compact JSON literal.