aboutsummaryrefslogtreecommitdiff
path: root/cm/ex01.lua
blob: 636ea2a3a85dc3982ce485673af38acad1a042f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
-- Environment is loaded with the utils (as metatable.__index)
-- Global vars (aka properties on env) will be read as decls

-- name implied by property key here
Bar = _struct({
    -- _t: Loads another type by its name. Return the type, or a placeholder if the type is not yet available
    --     Useful recursive definitions
    --     Undefined type errors generated on the referential resolution pass (i.e. not immediately)
    field1 = _t("i32"),
    field2 = _t("string"),
    -- Deferred loading as described above
    compound_field = _t("Foo"),
})

uint32 = _alias(_t("u32"))

-- Note, defined after Bar!
Foo = _struct({
    n = _t("i32"),
})