partisan_gen_transform (partisan v6.0.0)

View Source

Orchestrator module that ties together partisan_otp_rewrite and partisan_otp_patches to generate partisan versions of OTP modules from installed OTP beam files.

Given an OTP module name (e.g. gen_server), this module extracts the abstract code from the installed beam file, applies mechanical AST rewrites, applies structural patches, compiles the result, and optionally loads it into the VM.

Summary

Functions

Transform a single OTP module into its partisan equivalent. Extracts abstract code, applies rewrites and patches, then compiles.

Generate all supported partisan OTP modules. Generates each module in dependency order, writes the .beam file to the ebin directory, and loads it into the VM. Returns ok on success or {error, [{Module, Reason}]} on failure.

Generate all modules into the specified ebin directory.

Transform, compile, and load the module into the runtime.

Returns the ordered list of modules to transform. Order matters: gen and proc_lib must be generated before gen_server.

Returns the major OTP version as an integer (e.g. 27, 28).

Functions

generate(OrigModule)

Transform a single OTP module into its partisan equivalent. Extracts abstract code, applies rewrites and patches, then compiles.

generate_all()

Generate all supported partisan OTP modules. Generates each module in dependency order, writes the .beam file to the ebin directory, and loads it into the VM. Returns ok on success or {error, [{Module, Reason}]} on failure.

generate_all(Dir)

Generate all modules into the specified ebin directory.

Writing the beam to Dir is best-effort. When this is called as the runtime fallback from partisan_app:start/2, the release's ebin is typically read-only — we still want to load the binary into memory because that is what makes the module callable for the running node. Persistence to disk only saves a regeneration on the next cold start.

generate_and_load(OrigModule)

Transform, compile, and load the module into the runtime.

modules()

Returns the ordered list of modules to transform. Order matters: gen and proc_lib must be generated before gen_server.

otp_major_version()

-spec otp_major_version() -> non_neg_integer().

Returns the major OTP version as an integer (e.g. 27, 28).