Portable typed Morphir IR to MoonBit library generator
let input = @generator.Input::new("pricing", current_ir)
let output = @generator.generate(input)| Artifact | Purpose |
|---|---|
| moon.mod | Native module manifest with the SDK module requirement |
| moon.pkg | Only the SDK imports used by the generated code |
| library.mbt | Deterministic flattened declarations |
| symbols.10n | Binary Ion symbols, source identities, origins and metadata |
[backends.moonbit]
naming = "legacy-hex" # default: "readable"| Morphir type | MoonBit type and construction |
|---|---|
| morphir/SDK:int#int32 | int.Int32Value, checked SDK wrapper |
| morphir/SDK:basics#int | integer.Integer, constructed from the exact lexeme with integer.parse |
| morphir/SDK:basics#float | Double, constructed from its IEEE bits, including negative zero and subnormals |
| morphir/SDK:basics#bool | Bool |
| morphir/SDK:string#string | sdk.Text, constructed from UTF-16 code units |
| morphir/SDK:char#char | sdk.Character, constructed from UTF-16 code units |
| morphir/SDK:decimal#decimal | decimal.Decimal, constructed after exact coefficient/exponent validation |
| Unit | Unit |
mise exec -- moon test -p finos/morphir-moonbit \
-p finos/morphir-engine/data/generator-conformance --target all
mise exec -- bun install --frozen-lockfile
mise exec -- bun run build:runtimes
MOON_HOME="$HOME/.moon" mise exec -- node \
pkgs/morphir-moonbit/scripts/test-compiler.mts pkgs/morphir-sdkMOON_HOME="$HOME/.moon" mise run test:compilerpub(all) struct Input {
unit_id : String
ir : IRFile
metadata : Array[NodeMetadata]
annotations : Array[SymbolToken]
provenance : Array[Ion]
}pub(all) struct Limits {
max_declarations : Int
max_bytes : Int
}pub(all) struct Output {
project : Project
artifacts : Array[Artifact]
symbols : Array[Symbol]
invocations : Array[InvocationEntry]
invocation_codecs : String
invocation_types : Array[CustomType]
invocation_rejections : Array[(String, String)]
naming_style : NamingStyle
naming_facts : Interpretation
naming_allocations : Array[NamingAllocation]
warnings : Array[Warning]
}pub(all) struct Project {
module_name : String
root : String
members : Array[String]
dependencies : Array[Dependency]
} derive(Eq, Debug)fn generate(input : Input, limits? : Limits?, naming? : NamingStyle, metadata_capabilities? : Capabilities, cancelled? : () -> Bool) -> Output raise GenerationErrorfn invocation_driver(output : Output, entries : Array[String]) -> Array[Artifact] raise GenerationError