Perk.Codegen
Generates C code given a parsed Perk program.
val lambdas_hashmap :
(Ast.expr_a, string * string * string list * string) Stdlib.Hashtbl.t
table of lambdas: Lambda expression, identifier, generated code, capture list, type_descriptor
val fundecl_symbol_table : (Ast.perkident, Ast.perktype) Stdlib.Hashtbl.t
Symbol table of function declarations
val archetype_hashtable :
(string, (string, Ast.perktype) Stdlib.Hashtbl.t) Stdlib.Hashtbl.t
hashtable of archetypes
val add_archetype : string -> (string, Ast.perktype) Stdlib.Hashtbl.t
Adds a new archetype with name name
to the archetype hastable
val get_archetype : string -> (string, Ast.perktype) Stdlib.Hashtbl.t
val add_binding_to_archetype : string -> Ast.perkident -> Ast.perktype -> unit
adds the binding (id, typ)
to archetype with name name
val codegen_functional : is_lambda:bool -> Ast.expr_a -> string
codegens a function or a lambda
val bind_function_type : Ast.perkident -> Ast.perktype -> unit
Binds a function type to the fundecl_symbol_table
.
val codegen_program : Ast.topleveldef_a list -> string
Transforms a perk program into a string containing the corresponding C program.
val codegen_topleveldef : Ast.topleveldef_a -> string
Generates code for a top level definition.
val codegen_command : Ast.command_a -> int -> string
Generates code for perk commands.
val codegen_def :
Ast.perkvardesc ->
Ast.expr_a ->
Ast.perktype option ->
string ->
string
Generates code for perk definitions.
val codegen_decl : Ast.perkvardesc -> string
Generates code for perk declaration.
val codegen_fundef :
Ast.perktype ->
Ast.perkident ->
Ast.perkvardesc list ->
Ast.command_a ->
string
Generates code for perk function definitions.
val codegen_type : ?expand:bool -> Ast.perktype -> string
transforms a perktype into a C type
val codegen_attr : Ast.perktype_attribute -> string
Codegens perk attributes.
val codegen_qual : Ast.perktype_qualifier -> string
Codegens perk qualifiers.
val codegen_expr_and_letindefs : Ast.expr_a -> string * string
Codegens perk expressions (first output string), also returning the code that declares the fresh variables used in generating let...in-like expressions (second output string).
val codegen_expr : Ast.expr_a -> string
Codegen expressions.
val codegen_binop : Ast.binop -> string
generates code for binary operators
val codegen_preunop : Ast.preunop -> string
generates code for prefix unary operators
val codegen_postunop : Ast.postunop -> string
generates code for postfix unary operators
val codegen_fundecl : Ast.perkident -> Ast.perktype -> string
generates code for function declarations
val codegen_type_definition : Ast.perktype -> string
Generates code for type definitions.
val codegen_lambda_environment : Ast.perkvardesc list -> bool * string * string
val codegen_lambda_capture : Ast.perktype -> string