hare::unit
Index
Types
type _return = nullable *expr;
type access = (access_object | access_field | access_index | access_tuple);
type access_field = struct {
object: *expr,
field: const *types::struct_field,
};
type access_index = struct {
object: *expr,
index: *expr,
};
type access_object = *object;
type access_tuple = struct {
object: *expr,
value: const *types::tuple_value,
};
type binding = struct {
object: *object,
init: *expr,
};
type bindings = []binding;
type compound = []*expr;
type constant = (...ast::value | i64 | u64 | f64);
type decl = struct {
exported: bool,
start: lex::location,
end: lex::location,
decl: (decl_func | void),
};
type decl_func = struct {
symbol: str,
ident: ast::ident,
prototype: const *types::_type,
body: nullable *expr,
attrs: ast::fndecl_attr,
};
type expr = struct {
start: lex::location,
end: lex::location,
result: const *types::_type,
terminates: bool,
expr: (access | bindings | compound | constant | _return),
};
type object = struct {
kind: object_kind,
hash: u64,
ident: ast::ident,
name: ast::ident,
_type: const *types::_type,
};
type object_kind = enum {
BIND,
CONST,
DECL,
TYPE,
};
type scope = struct {
class: scope_class,
parent: nullable *scope,
objects: []object,
hashmap: [SCOPE_BUCKETS][]*object,
};
type scope_class = enum {
COMPOUND,
ENUM,
FUNC,
LOOP,
MATCH,
SUBUNIT,
UNIT,
};
type unit = struct {
ident: ast::ident,
decls: []decl,
};
Errors
type error = !(types::error | void);
Constants
def SCOPE_BUCKETS: size = 4096;
Functions
fn check(store: *types::typestore, ident: ast::ident, subunits: const []ast::subunit) (unit | error);
fn unit_finish(unit: unit) void;
Types
type _return
type _return = nullable *expr;
A return expression, i.e. return <value>
type access
type access = (access_object | access_field | access_index | access_tuple);
An access expression.
type access_field
type access_field = struct {
object: *expr,
field: const *types::struct_field,
};
An access expression for a struct field.
type access_index
type access_index = struct {
object: *expr,
index: *expr,
};
An access expression for a slice or array index.
type access_object
type access_object = *object;
An access expression for an object.
type access_tuple
type access_tuple = struct {
object: *expr,
value: const *types::tuple_value,
};
An access expression for a tuple value.
type binding
type binding = struct {
object: *object,
init: *expr,
};
A single variable biding.
foo: int = bar
type bindings
type bindings = []binding;
A list of variable bindings.
type compound
type compound = []*expr;
A compound expression, i.e. { ... }
type constant
type constant = (...ast::value | i64 | u64 | f64);
The value of a constant expression.
type decl
type decl = struct {
exported: bool,
start: lex::location,
end: lex::location,
decl: (decl_func | void),
};
A declaration within a unit.
type decl_func
type decl_func = struct {
symbol: str,
ident: ast::ident,
prototype: const *types::_type,
body: nullable *expr,
attrs: ast::fndecl_attr,
};
A function declaration.
type expr
type expr = struct {
start: lex::location,
end: lex::location,
result: const *types::_type,
terminates: bool,
expr: (access | bindings | compound | constant | _return),
};
A type-checked and validated Hare expression.
type object
type object = struct {
kind: object_kind,
hash: u64,
ident: ast::ident,
name: ast::ident,
_type: const *types::_type,
};
An object is a named object in a scope, such as a binding, type, or declaration.
type object_kind
type object_kind = enum {
BIND,
CONST,
DECL,
TYPE,
};
What sort of object is represented.
type scope
type scope = struct {
class: scope_class,
parent: nullable *scope,
objects: []object,
hashmap: [SCOPE_BUCKETS][]*object,
};
A scope is a member of a hierarchy of storage containers which hold named objects, such as variables or function parameters.
type scope_class
type scope_class = enum {
COMPOUND,
ENUM,
FUNC,
LOOP,
MATCH,
SUBUNIT,
UNIT,
};
What kind of scope is represented.
type unit
type unit = struct {
ident: ast::ident,
decls: []decl,
};
A single compilation unit, representing all of the members of a namespace.
Errors
type error
type error = !(types::error | void);
TODO: More errors
Constants
def SCOPE_BUCKETS
Show undocumented member
def SCOPE_BUCKETS: size = 4096;
Functions
fn check
fn check(store: *types::typestore, ident: ast::ident, subunits: const []ast::subunit) (unit | error);
Type checks a set of hare::ast::subunits and determines if it is logically consistent, then returns the corresponding unit, which from then on is guaranteed to be compilable.
fn unit_finish
Show undocumented member
fn unit_finish(unit: unit) void;