from ScEpTIC.AST.transformations.ratchet.checkpoint_placer import CheckpointPlacer from ScEpTIC.AST.transformations.ratchet.checkpoint_registers_optimization import RegisterSavingOptimization def apply_transformation(functions, vmstate, f_declarations): """ Apply ratchet transformation :param functions: ScEpTIC AST functions :param vmstate: vmstate """ config = vmstate.config.ast_transformations.ratchet functions_with_outside_frame_accesses = config.functions_with_outside_frame_accesses checkpoint_function_name = vmstate.config.state_retention.state_save_function_name checkpoint_placer = CheckpointPlacer(functions, functions_with_outside_frame_accesses, checkpoint_function_name) checkpoint_placer.place_checkpoints() if config.optimize_saved_registers: checkpoint_register_optimization = RegisterSavingOptimization(checkpoint_placer) checkpoint_register_optimization.set_checkpoints_registers()