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 #base TypeInfo {
    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 #base TypeInfo {
    bit_count: s32;
}

Detailed information about real types: f32, f64.

Members

File: a.bl

TypeInfoFn

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

Detailed information about function types.

Members

File: a.bl

TypeInfoFnGroup

TypeInfoFnGroup :: struct #base TypeInfo {
    variants: []*TypeInfoFn;
}

Detailed information about function group and contained possible overloads.

Members

File: a.bl

TypeInfoPtr

TypeInfoPtr :: struct #base TypeInfo {
    pointee_type: *TypeInfo;
}

Detailed information about pointer types.

Members

File: a.bl

TypeInfoArray

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

Detailed information about array types.

Members

File: a.bl

TypeInfoStruct

TypeInfoStruct :: struct #base TypeInfo {
    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 #base TypeInfo {
    name: string_view;
    base_type: *TypeInfo;
    variants: []TypeInfoEnumVariant;
    is_flags: bool;
}

Detailed information about enumerator types.

Members

File: a.bl

TypeInfoVoid

TypeInfoVoid :: struct #base TypeInfo {
}

Placeholder for information about void type.

File: a.bl

TypeInfoNull

TypeInfoNull :: struct #base TypeInfo {
}

Placeholder for information about null type.

File: a.bl

TypeInfoString

TypeInfoString :: struct #base TypeInfo {
}

Placeholder for information about string type.

File: a.bl

TypeInfoType

TypeInfoType :: struct #base TypeInfo {
}

Placeholder for information about type type.

File: a.bl

TypeInfoBool

TypeInfoBool :: struct #base TypeInfo {
}

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;
    _internal: *u8;
}

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

Warning: Function is marked as obsolete. Since 0.14.0; Use 'enum_variant_count' in 'std/type_utils' module.

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

Warning: Function is marked as obsolete. Since 0.14.0; Use 'enum_variant_name' in 'std/type_utils' module.

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

Resolve enum variant name.

File: a.bl

enum_variant_value

Warning: Function is marked as obsolete. Since 0.14.0; Use 'enum_variant_value' in 'std/type_utils' module.

enum_variant_value :: fn (T: type, index: s64) T #inline

Resolve enum variant value.

File: a.bl

is_number

Warning: Function is marked as obsolete. Since 0.14.0; Use 'is_number' in 'std/type_utils' module.

is_number :: fn (T: type) bool

Returns true if the T type is an integer type.

File: a.bl

is_real

Warning: Function is marked as obsolete. Since 0.14.0; Use 'is_real' in 'std/type_utils' module.

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

Warning: Function is marked as obsolete. Since 0.14.0; Use 'is_real_or_number' in 'std/type_utils' module.

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

Warning: Function is marked as obsolete. Since 0.14.0; Use 'is_signed_number' in 'std/type_utils' module.

is_signed_number :: fn (T: type) bool

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

File: a.bl

is_pointer

Warning: Function is marked as obsolete. Since 0.14.0; Use 'is_pointer' in 'std/type_utils' module.

is_pointer :: fn (T: type) bool

Returns true if the T type is a pointer type.

File: a.bl

is_function

Warning: Function is marked as obsolete. Since 0.14.0; Use 'is_function' in 'std/type_utils' module.

is_function :: fn (T: type) bool

Returns true if the T type is a function type.

File: a.bl

is_struct

Warning: Function is marked as obsolete. Since 0.14.0; Use 'is_struct' in 'std/type_utils' module.

is_struct :: fn (T: type) bool

Returns true if the T type is a struct type.

File: a.bl

typeid

Warning: Function is marked as obsolete. Since 0.14.0; Use 'typeid' in 'std/type_utils' module.

typeid :: fn (v: type) u64

Returns unique type identificator in compile-time.

File: a.bl

is_enum

Warning: Function is marked as obsolete. Since 0.14.0; Use 'is_enum' in 'std/type_utils' module.

is_enum :: fn (T: type) bool

Returns true if the T type is an enumerator type.

File: a.bl

number_type

Warning: Function is marked as obsolete. Since 0.14.0; Use 'number_type' in 'std/type_utils' module.

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

Warning: Function is marked as obsolete. Since 0.14.0; Use 'has_member' in 'std/type_utils' module.

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

Warning: Function is marked as obsolete. Since 0.14.0; Use 'has_member' in 'std/type_utils' module.

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

File: a.bl

struct_count

Warning: Function is marked as obsolete. Since 0.14.0; Use 'struct_member_count' in 'std/type_utils' module.

struct_count :: fn (TStruct: type) s32

File: a.bl

member_offset_bytes

Warning: Function is marked as obsolete. Since 0.14.0; Use 'member_offset_bytes' in 'std/type_utils' module.

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

Warning: Function is marked as obsolete. Since 0.14.0; Use 'member_offset_bytes' in 'std/type_utils' module.

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

File: a.bl

member_offset_bytes2

Warning: Function is marked as obsolete. Since 0.14.0; Use 'member_offset_bytes' in 'std/type_utils' module.

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

File: a.bl

member_ptr

member_ptr :: fn { 
    member_ptr_impl; 
    member_ptr_impl2; 
}

File: a.bl