Builtin

Compiler builtins are automatically loaded into every assembly.

Current running platform

Platform :: enum s32 {
    UNKNOWN;
    WINDOWS;
    DARWIN;
    LINUX;
}

PLATFORM :: <SET_BY_COMPILER>;

Current running architecture

Arch :: enum s32 {
    UNKNOWN;
    X86_64;
    AARCH64;
    ARM64;
}

ARCH :: <SET_BY_COMPILER>;

Current running environment

Env :: enum s32 {
    UNKNOWN;
    MSVC;
    GNU;
    MUSL;
}

ENV :: <SET_BY_COMPILER>;

Compiler version

BLC_VER_MAJOR : s32 : <SET_BY_COMPILER>;
BLC_VER_MINOR : s32 : <SET_BY_COMPILER>;
BLC_VER_PATCH : s32 : <SET_BY_COMPILER>;

string_view

string_view :: []u8

Builtin string slice.

File: a.bl

TypeKind

TypeKind :: enum {
    TYPE = 1;
    VOID = 2;
    INT = 3;
    REAL = 4;
    FN = 5;
    PTR = 6;
    BOOL = 7;
    ARRAY = 8;
    STRUCT = 9;
    ENUM = 10;
    NULL = 11;
    STRING = 12;
    FN_GROUP = 16;
}

TypeKind describes kind of BL type returned in TypeInfo structure. This value can be used for safe casting.

Variants

File: a.bl

TypeInfo

TypeInfo :: struct {
    kind: TypeKind;
    size_bytes: usize;
    alignment: usize;
}

Base TypeInfo structure returned by typeinfo operator. This structure pointer can be casted to child type to get more descriptive information about the type.

Members

File: a.bl

TypeInfoInt

TypeInfoInt :: struct {
    bit_count: s32;
    is_signed: bool;
}

Detailed information about integer types: s8, s16, s32, s64, u8, u16, u32, u64, usize.

Members

File: a.bl

TypeInfoReal

TypeInfoReal :: struct {
    bit_count: s32;
}

Detailed information about real types: f32, f64.

Members

File: a.bl

TypeInfoFn

TypeInfoFn :: struct {
    args: []TypeInfoFnArg;
    ret_type: *TypeInfo;
    is_vargs: bool;
}

Detailed information about function types.

Members

File: a.bl

TypeInfoFnGroup

TypeInfoFnGroup :: struct {
    variants: []*TypeInfoFn;
}

Detailed information about function group and contained possible overloads.

Members

File: a.bl

TypeInfoPtr

TypeInfoPtr :: struct {
    pointee_type: *TypeInfo;
}

Detailed information about pointer types.

Members

File: a.bl

TypeInfoArray

TypeInfoArray :: struct {
    name: string_view;
    elem_type: *TypeInfo;
    len: s64;
}

Detailed information about array types.

Members

File: a.bl

TypeInfoStruct

TypeInfoStruct :: struct {
    name: string_view;
    members: []TypeInfoStructMember;
    is_slice: bool;
    is_union: bool;
    is_dynamic_array: bool;
}

Detailed information about structure types.

Members

File: a.bl

TypeInfoEnum

TypeInfoEnum :: struct {
    name: string_view;
    base_type: *TypeInfo;
    variants: []TypeInfoEnumVariant;
    is_flags: bool;
}

Detailed information about enumerator types.

Members

File: a.bl

TypeInfoVoid

TypeInfoVoid :: struct {
}

Placeholder for information about void type.

File: a.bl

TypeInfoNull

TypeInfoNull :: struct {
}

Placeholder for information about null type.

File: a.bl

TypeInfoString

TypeInfoString :: struct {
}

Placeholder for information about string type.

File: a.bl

TypeInfoType

TypeInfoType :: struct {
}

Placeholder for information about type type.

File: a.bl

TypeInfoBool

TypeInfoBool :: struct {
}

Placeholder for information about bool type.

File: a.bl

TypeInfoStructMember

TypeInfoStructMember :: struct {
    name: string_view;
    base_type: *TypeInfo;
    offset_bytes: s32;
    index: s32;
    tag: u64;
    is_base: bool;
}

Detailed information about structure member.

Members

Foo :: struct {
    i: s32 #tag 123;
    j: s32 #tag 321;
};

File: a.bl

TypeInfoEnumVariant

TypeInfoEnumVariant :: struct {
    name: string_view;
    value: s64;
}

Detailed information about enumerator variant.

Members

File: a.bl

TypeInfoFnArg

TypeInfoFnArg :: struct {
    name: string_view;
    base_type: *TypeInfo;
}

Detailed information about function's argument.

Members

File: a.bl

Any

Any :: struct {
    type_info: *TypeInfo;
    data: *u8;
}

Any type is special builtin type used for passing value of "any" type as function argument.

Members

File: a.bl

TestCase

TestCase :: struct {
    func: *fn () ;
    name: string_view;
    file: string_view;
    line: s32;
}

Type of test case record found during compilation.

Members

File: a.bl

CodeLocation

CodeLocation :: struct {
    file: string_view;
    line: s32;
    function: string_view;
    hash: u32;
}

Type of source code location used by #call_location directive.

Example

foo :: fn (loc: *CodeLocation = #call_location) {
    print("%\n", @loc);
}

main :: fn () s32 {
    foo();
    return 0;
}

Members

File: a.bl

PrintLogFn

PrintLogFn :: *fn (kind: PrintLogKind, file: string_view, line: s32, format: string_view, args: ...) 

Type of print log function.

Arguments

File: a.bl

AbortFn

AbortFn :: *fn () 

File: a.bl

AssertFn

AssertFn :: *fn (message: string_view, loc: *CodeLocation) 

File: a.bl

Context

Context :: struct {
    print_log_fn: PrintLogFn;
    abort_fn: AbortFn;
    assert_fn: AssertFn;
    allocator: *Allocator;
    temporary_allocator: *Allocator;
    _assert_handled: bool;
}

Global application context. This structure provides possibility to override common operations done on the compiler internal level or on the user code level.

Members

File: a.bl

application_context

application_context := 

Default application context. Implicit context is compiler internal global variable containing basic context for the whole assembly. This variable is mutable and can be modified by user code. For example we can replace default memory allocator with custom one, this will affect all memory allocations made after.

File: a.bl

command_line_arguments

command_line_arguments : []string_view = 

Contains all arguments passed from command line. First argument is executable name.

File: a.bl

enum_count

enum_count :: fn (T: type) s64

Compile-time helper function resolving count of enumerator variants, passed type 'T' must be an enumerator type (checked by assert).

File: a.bl

enum_variant_name

enum_variant_name :: fn (T: type, index: s64) string_view #inline

File: a.bl

is_number

is_number :: fn (T: type) bool

Returns true if the T type is an integer type.

File: a.bl

is_real

is_real :: fn (T: type) bool

Returns true if the T type is an floating point number type.

File: a.bl

is_real_or_number

is_real_or_number :: fn (T: type) bool

Returns true if the T type is an integer or floating point number type (f32 or f64).

File: a.bl

is_signed_number

is_signed_number :: fn (T: type) bool

Returns true if the T type is a signed integer type.

File: a.bl

is_pointer

is_pointer :: fn (T: type) bool

Returns true if the T type is a pointer type.

File: a.bl

is_function

is_function :: fn (T: type) bool

Returns true if the T type is a function type.

File: a.bl

is_struct

is_struct :: fn (T: type) bool

Returns true if the T type is a struct type.

File: a.bl

typeid

typeid :: fn (v: type) u64

Returns unique type identificator in compile-time.

File: a.bl

is_enum

is_enum :: fn (T: type) bool

Returns true if the T type is an enumerator type.

File: a.bl

number_type

number_type :: fn (size_bytes: usize, is_signed: bool) type

Returns signed or unsigned builtin number type of the requested size. The size_bytes must be 1, 2, 4 or 8 Bytes.

File: a.bl

has_member

has_member :: fn (TStruct: type, member_name: string_view) bool

Check in compile-time whether structure type TStruct contains member called member_name.

File: a.bl

has_member2

has_member2 :: fn (TStruct: type, member_name: string_view) bool

File: a.bl

struct_count

struct_count :: fn (TStruct: type) s32

File: a.bl

member_offset_bytes

member_offset_bytes :: fn (TStruct: type, path: string_view) s64

Calculate offset of member ad path starting from TStruct root. Each member in the pash is supposed to be separated by '/'.

Example

number
foo/number
foo/bar/number

File: a.bl

member_offset_bytes_comptime

member_offset_bytes_comptime :: fn (TStruct: type, path: string_view) s64

File: a.bl

member_offset_bytes2

member_offset_bytes2 :: fn (type_info: *TypeInfoStruct, path: string_view) s64

File: a.bl

member_ptr

member_ptr :: fn { 
    fn (base_ptr: *u8, member: *TypeInfoStructMember) *u8; 
    fn (TMember: type, base_ptr: *?T, member_name: string_view) *TMember; 
} #inline

File: a.bl