Internal Architecture#
C2PO is now organized around a command registry and shared compiler state, instead of a single hard-coded pass list.
At runtime, c2po/main.py builds a CommandConsole with:
a
cpt.Program(current specification graph)a
cpt.Context(symbol tables, mappings, stats, solver paths, assembly output, etc.)all registered commands from
c2po/command.pyand module-level command registrations
The same command system is used by:
interactive REPL mode (
--interactive)script mode (
--script)top-level CLI mode (
--spec ...) via a generated temporary script
Compilation Flow#
In CLI mode (c2po.main.cli), behavior is assembled from command invocations based on flags.
The typical flow is:
Parse input (
parse_c2poorparse_mltl)Optional trace/map parsing (
parse_trace,parse_map)Type check (
type_check)Desugar (
desugar)Optional optimization stage (
optimize_eqsatoroptimize_rewrites)Optional transforms (
remove_extended_operators,optimize_cse)Optional SMT checks (
check_sat)Lowering for assembly (
multi_operators_to_binary,remove_extended_operators)Assembly/output (
assemble, optional bounds writers)
Composite commands (for example compile and assemble) are defined in code and expand into
ordered subcommands.
Guard Conditions#
Commands can declare guard preconditions (for example: DESUGARED, COMPUTED_ATOMICS,
ONLY_BINARY_OPERATORS). Guard checks are centralized in c2po/command.py.
If a guard fails in REPL/script mode, C2PO reports the missing condition and suggests commands that typically satisfy it.
Serialization and Output#
Serialization/output capabilities are commands, not a separate pipeline stage. Common ones:
write_c2powrite_mltlwrite_prefixwrite_pickleassemble(binary + optional assembly text)write_bounds_c/write_bounds_rust