submodule
import std::rust_derive
type Program: {
main: Expr,
defs: [TyDef]
}
type Expr: {
kind: ExprKind,
ty: Ty,
}
@rust_derive(["Debug", "Clone", "enum_as_inner::EnumAsInner"])
type ExprKind: enum {
pointer: Pointer,
literal: Literal,
call: Call,
function: Function,
tuple: [TupleField],
array: [Expr],
enum_variant: EnumVariant,
enum_tag: EnumTag,
enum_unwrap: EnumUnwrap,
tuple_lookup: TupleLookup,
binding: Binding,
switch: [SwitchBranch],
}
@rust_derive(["Debug", "Clone", "enum_as_inner::EnumAsInner"])
type Pointer: enum {
`external`: ExternalPtr,
binding: Uint32,
parameter: ParameterPtr,
}
type ExternalPtr: {
id: Text,
}
@rust_derive(["Debug", "Clone"])
type ParameterPtr: {
function_id: Uint32,
param_position: Uint8,
}
@rust_derive(["Debug", "Clone", "PartialEq", "enum_as_inner::EnumAsInner"])
type Literal: enum {
prim8: Uint8,
prim16: Uint16,
prim32: Uint32,
prim64: Uint64,
text: Text,
}
type Call: {
function: Expr,
args: [Expr],
}
type Function: {
id: Uint32,
body: Expr,
}
type TupleField: {
expr: Expr,
unpack: Bool,
}
type EnumVariant: {
tag: Uint64,
inner: Expr,
}
type EnumTag: {
subject: Expr,
}
type EnumUnwrap: {
subject: Expr,
tag: Uint64,
}
type TupleLookup: {
base: Expr,
position: Uint16,
}
type Binding: {
id: Uint32,
expr: Expr,
main: Expr,
}
# Contract: switch is guaranteed to match at least one branch
type SwitchBranch: {
condition: Expr,
value: Expr,
}
type TyDef: {
name: Path,
ty: Ty,
}
@rust_derive(["Debug", "Clone"])
type Ty: {
kind: TyKind,
layout: TyLayout?,
name: Text?,
variants_recursive: [Uint16],
}
@rust_derive(["Debug", "Clone", "PartialEq", "enum_as_inner::EnumAsInner"])
type TyKind: enum {
primitive: TyPrimitive,
tuple: [TyTupleField],
array: Ty,
`enum`: [TyEnumVariant],
function: TyFunction,
ident: Path,
}
@rust_derive(["Debug", "Clone", "Copy", "PartialEq", "Eq", "Hash"])
type TyPrimitive: enum {
prim8,
prim16,
prim32,
prim64,
}
@rust_derive(["Debug", "Clone", "PartialEq"])
type TyTupleField: {
name: Text?,
ty: Ty,
}
@rust_derive(["Debug", "Clone", "PartialEq"])
type TyEnumVariant: {
name: Text,
ty: Ty,
}
@rust_derive(["Debug", "Clone", "PartialEq", "Default"])
type TyLayout: {
head_size: Uint32,
body_ptrs: [Uint32],
}
@rust_derive(["Debug", "Clone", "PartialEq"])
type TyFunction: {
params: [Ty],
body: Ty
}
@rust_derive(["Debug", "Clone", "PartialEq", "Eq", "PartialOrd", "Ord", "Hash"])
type Path: [Text]
type Module: {
decls: [{name: Text, decl: Decl}],
}
type Decl: enum {
mod: Module,
ty: Ty,
var: Ty,
}