hare::unit +linux +x86_64

Index

Types

type _return;
type access;
type access_field;
type access_index;
type access_object;
type access_tuple;
type binding;
type bindings;
type compound;
type constant;
type decl;
type decl_func;
type expr;
type object;
type object_kind;
type scope;
type scope_class;
type unit;

Errors

type error;

Constants

// Undocumented constants:
const SCOPE_BUCKETS: size;

Functions

fn check(*types::typestore, ast::ident, const []ast::subunit) (unit | error);

// Undocumented functions:
fn unit_finish(unit) void;

Types

type _return[link]

type _return = nullable *expr;

A return expression, i.e. return <value>

type access[link]

type access = (access_object | access_field | access_index | access_tuple);

An access expression.

type access_field[link]

type access_field = struct {
	object: *expr,
	field: const *types::struct_field,
};

An access expression for a struct field.

type access_index[link]

type access_index = struct {
	object: *expr,
	index: *expr,
};

An access expression for a slice or array index.

type access_object[link]

type access_object = *object;

An access expression for an object.

type access_tuple[link]

type access_tuple = struct {
	object: *expr,
	value: const *types::tuple_value,
};

An access expression for a tuple value.

type binding[link]

type binding = struct {
	object: *object,
	init: *expr,
};

A single variable biding.

foo: int = bar

type bindings[link]

type bindings = []binding;

A list of variable bindings.

type compound[link]

type compound = []*expr;

A compound expression, i.e. { ... }

type constant[link]

type constant = (...ast::value | i64 | u64 |
f64);

The value of a constant expression.

type decl[link]

type decl = struct {
	exported: bool,
	start: lex::location,
	end: lex::location,
	decl: (decl_func | void),
};

A declaration within a unit.

type decl_func[link]

type decl_func = struct {
	symbol: str,
	ident: ast::ident,
	prototype: const *types::_type,
	body: nullable *expr,
	attrs: ast::fndecl_attrs,
};

A function declaration.

type expr[link]

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[link]

type object = struct {
	kind: object_kind,
	hash: u64,
	// The fully qualified identifier
ident: ast::ident, // Local name, if different from the fully qualified identifier
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[link]

type object_kind = enum {
	BIND,
	CONST,
	DECL,
	TYPE,

};

What sort of object is represented.

type scope[link]

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[link]

type scope_class = enum {
	COMPOUND,
	ENUM,
	FUNC,
	LOOP,
	MATCH,
	SUBUNIT,
	UNIT,

};

What kind of scope is represented.

type unit[link]

type unit = struct {
	ident: ast::ident,
	decls: []decl,
};

A single compilation unit, representing all of the members of a namespace.

Errors

type error[link]

type error = !(types::error | void);

TODO: More errors

Constants

def SCOPE_BUCKETS[link]

Show undocumented member
def SCOPE_BUCKETS: size;

Functions

fn check[link]

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[link]

Show undocumented member
fn unit_finish(unit: unit) void;