hare::unit+x86_64 +linux

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,
	// TODO: Other decl types
	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,
	// The fully qualified identifier
	ident: ast::ident,
	// Local name, if different from the fully qualified identifier
	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

// Undocumented constants:
def SCOPE_BUCKETS: size = 4096;

Functions

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

// Undocumented functions:
fn unit_finish(unit: 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,
	// TODO: Other decl types
	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_attr,
};

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 = 4096;

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;