Module Sarek_native_helpers

Location Conversion

val ppxlib_loc_of_sarek : Sarek_ast.loc -> Ppxlib.location

Convert Sarek_ast.loc to Ppxlib.location.

Must agree with Sarek_ast.loc_to_ppxlib: pos_cnum is an ABSOLUTE byte offset and pos_bol the offset of the line's first byte, so both have to be carried through. Dropping pos_bol makes the compiler echo bytes from the top of the file under a diagnostic that names a different line (#97).

Expression Helpers

val evar : loc:Ppxlib__.Location.t -> string -> Ppxlib__.Import.expression

Helper to create an identifier expression

val evar_qualified : loc:Ppxlib__.Location.t -> string list -> string -> Ppxlib__.Import.expression

Helper to create a qualified identifier expression

Variable Naming

val var_name : int -> string

Create a unique name for a variable by id

val mut_var_name : int -> string

Create a unique name for a mutable variable by id

val state_var : string

Thread state variable name - bound in kernel wrapper

val shared_var : string

Shared memory variable name - bound in block wrapper

Default Value Generation

val default_value_for_type : loc:Ppxlib.location -> Sarek_types.typ -> Ppxlib.expression

Generate default value expression for a given type. Used for array initialization and other contexts where a default is needed.