pub(crate) mod context;
pub(crate) mod detection;
pub(crate) mod types;
mod policy;
pub(crate) mod ffi;
pub(crate) mod bindings;
pub(crate) mod tce;
pub(crate) mod marshal;
pub(crate) mod peephole;
pub(crate) mod stmt;
pub(crate) mod expr;
pub(crate) mod program;
pub use context::{RefinementContext, VariableCapabilities, empty_var_caps};
pub use detection::{collect_async_functions, collect_pipe_sender_params, collect_pipe_vars};
pub use program::codegen_program;
pub use ffi::generate_c_header;
pub use bindings::{generate_python_bindings, generate_typescript_bindings};
pub use expr::{codegen_expr, codegen_assertion, codegen_term};
pub use stmt::codegen_stmt;
pub(crate) use ffi::{
CAbiClass, classify_type_for_c_abi, has_wasm_exports, has_c_exports, has_c_exports_with_text,
codegen_c_accessors, collect_c_export_ref_structs, collect_c_export_reference_types,
collect_c_export_value_type_structs, codegen_logos_runtime_preamble, mangle_type_for_c,
map_type_to_c_header, map_field_type_to_c,
};
pub(crate) use expr::{
codegen_expr_with_async, codegen_expr_boxed, codegen_expr_boxed_with_strings,
codegen_expr_boxed_with_types, codegen_interpolated_string, codegen_literal,
codegen_expr_with_async_and_strings, is_definitely_string_expr_with_vars,
is_definitely_string_expr, is_definitely_numeric_expr, collect_string_concat_operands,
};
pub(crate) use stmt::{get_root_identifier, is_copy_type, has_copy_element_type, has_copy_value_type};
pub(crate) use peephole::{
try_emit_for_range_pattern, try_emit_vec_fill_pattern, try_emit_swap_pattern,
try_emit_seq_copy_pattern, try_emit_seq_from_slice_pattern,
try_emit_bare_slice_push_pattern,
try_emit_vec_with_capacity_pattern, try_emit_merge_capacity_pattern,
try_emit_string_with_capacity_pattern,
try_emit_rotate_left_pattern,
try_emit_buffer_reuse_while,
body_mutates_collection, body_modifies_var, exprs_equal,
};
pub(crate) use types::is_recursive_field;
pub(crate) fn is_rust_keyword(name: &str) -> bool {
matches!(name,
"as" | "async" | "await" | "break" | "const" | "continue" | "crate" |
"dyn" | "else" | "enum" | "extern" | "false" | "fn" | "for" | "if" |
"impl" | "in" | "let" | "loop" | "match" | "mod" | "move" | "mut" |
"pub" | "ref" | "return" | "self" | "Self" | "static" | "struct" |
"super" | "trait" | "true" | "type" | "unsafe" | "use" | "where" |
"while" | "abstract" | "become" | "box" | "do" | "final" | "macro" |
"override" | "priv" | "try" | "typeof" | "unsized" | "virtual" | "yield"
)
}
pub(crate) fn escape_rust_ident(name: &str) -> String {
if is_rust_keyword(name) {
format!("r#{}", name)
} else {
name.to_string()
}
}