submodule
import std::rust_derive
type Program: {
externals: [ExternalSymbol],
main: Expr,
defs: [project::ir::TyDef],
}
@rust_derive(["Debug", "Clone", "PartialEq", "Eq", "Hash"])
type ExternalSymbol: {
id: Text,
layout_args: [Uint32],
}
type Expr: {
kind: ExprKind,
}
@rust_derive(["Debug", "Clone", "enum_as_inner::EnumAsInner"])
type ExprKind: enum {
pointer: Sid,
literal: [Uint8],
call: Call,
function: Function,
tuple: `Tuple`,
array: Array,
enum_variant: EnumVariant,
offset: Offset,
deref: Deref,
binding: Binding,
switch: [SwitchBranch],
}
## Symbol id.
## - 0b00xxxxxx - external
## - 0b01xxxxxx - local bindings
## - 0b10xxxxxx - function scopes
## - 0b11xxxxxx - unused
@rust_derive(["Debug", "Clone", "Copy", "PartialEq", "Eq", "Hash"])
type Sid: Uint32
type Call: {
function: Expr,
args: [Expr],
}
type Function: {
symbol_ns: Sid,
# can contain function parameters prefixed with symbol_ns
body: Expr,
}
type Tuple: {
fields: [TupleField],
field_layouts: [TyLayout]
}
type TupleField: {
expr: Expr,
unpack: Uint8,
}
type Array: {
item_layout: TyLayout,
items: [Expr],
}
type EnumVariant: {
tag: [Uint8],
inner_bytes: Uint8,
has_ptr: Bool,
padding_bytes: Uint8,
inner: Expr,
}
type Offset: {
base: Expr,
offset: Uint32,
}
type Deref: {
ptr: Expr,
}
type Binding: {
symbol: Sid,
expr: Expr,
main: Expr,
}
type SwitchBranch: {
condition: Expr,
value: Expr,
}
@rust_derive(["Debug", "Clone", "PartialEq", "Default"])
type TyLayout: {
head_size: Uint32,
body_ptrs: [Uint32],
}