Module Sarek_native_gen_base

Expression Generation

module IntSet : sig ... end

Mutable variable tracking. We track which variable IDs are mutable so that TEVar can dereference them.

module StringSet : sig ... end

Set of inline type names for first-class module approach

type gen_context = {
  1. mut_vars : IntSet.t;
    (*

    Variable IDs that are mutable (need dereferencing)

    *)
  2. inline_types : StringSet.t;
    (*

    Type names that use first-class module accessors

    *)
  3. current_module : string option;
    (*

    Current module name for same-module type detection

    *)
  4. gen_mode : Sarek_native_intrinsics.gen_mode;
    (*

    Generation mode - affects how thread indices are accessed

    *)
  5. use_native_arg : bool;
    (*

    When true, vector params are accessor objects (v#get i, v#set i x) instead of Vector.t (Vector.get v i, Vector.kernel_set v i x)

    *)
}

Expression generation context

val empty_ctx : gen_context

Empty generation context

val is_same_module : gen_context -> string -> bool

Check if a qualified type name is from the current module. For "Test_registered_variant.color", returns true if current_module is "Test_registered_variant".

val types_module_var : string

The name of the first-class module variable

First-Class Module Name Helpers

val field_getter_name : string -> string -> string

Generate accessor function name for a field getter

val record_maker_name : string -> string

Generate constructor function name for a record

val variant_ctor_name : string -> string -> string

Generate constructor function name for a variant constructor

val gen_literal : loc:Ppxlib.location -> Sarek_typed_ast.texpr -> Ppxlib.expression
val gen_variable : loc:Ppxlib__.Location.t -> ctx:gen_context -> string -> int -> Ppxlib.expression

Generate variable reference (local, module-level, qualified)

val custom_descriptor_expr : ?current_module:Stdlib.String.t -> loc:Ppxlib__.Location.t -> string -> Ppxlib__.Import.expression
val is_inline_type : StringSet.t option -> StringSet.elt -> bool
val sanitize_ident : string -> string
val inline_type_id_method : string -> string
val inline_vector_type_id_method : string -> string
val inline_type_id_expr : loc:Ppxlib__.Location.t -> ids_var:string -> string -> Ppxlib__.Import.expression
val inline_vector_type_id_expr : loc:Ppxlib__.Location.t -> ids_var:string -> string -> Ppxlib__.Import.expression
val vector_type_id_expr : ?current_module:Stdlib.String.t -> ?inline_types:StringSet.t -> ?inline_ids_var:string -> loc:Ppxlib.location -> Sarek_types.typ -> Ppxlib_ast.Ast.expression
val custom_type_id_expr : ?current_module:Stdlib.String.t -> ?inline_types:StringSet.t -> ?inline_ids_var:string -> loc:Ppxlib.location -> Sarek_types.typ -> Ppxlib_ast.Ast.expression