Ragex. Cure. Loader
(Ragex v0.36.2)
View Source
Loads the Cure compiler modules from the cure escript, without clobbering
modules the host application already has.
The released cure executable is an escript whose archive embeds Cure's own
beams together with its dependencies (for example an older Metastatic).
Metastatic.Adapters.Cure.ToMeta has a fallback that extracts that archive
and force-loads every beam whose path mentions "cure". That replaces the
host's Metastatic.Adapters.Cure with the older embedded copy, which can lack
functions such as parse/1.
This module is a safer replacement for that fallback: a beam is loaded only
when no module of that name is already loaded or reachable on the code path.
Running it before Metastatic's own fallback makes Cure.Compiler.Lexer and
Cure.Compiler.Parser available, so the fallback never runs.
Summary
Functions
Ensures the Cure compiler is available, loading it from the cure escript
when necessary.
Loads the given {filename, binary} entries (as returned by
:zip.extract/2 with :memory), skipping non-beam files and any module that
is already loaded or available on the code path.
Returns true when the Cure compiler has been fully loaded or verified as
loadable by ensure_loaded/0.
Functions
@spec ensure_loaded() :: :ok | {:error, :cure_not_available}
Ensures the Cure compiler is available, loading it from the cure escript
when necessary.
Concurrent callers are serialized: all of them wait for a single load to finish and none returns before every beam has been loaded.
Returns
:okwhen the Cure lexer and parser are available{:error, :cure_not_available}otherwise
Loads the given {filename, binary} entries (as returned by
:zip.extract/2 with :memory), skipping non-beam files and any module that
is already loaded or available on the code path.
Returns the list of modules that were loaded.
@spec loaded?() :: boolean()
Returns true when the Cure compiler has been fully loaded or verified as
loadable by ensure_loaded/0.
This is deliberately conservative: it never returns true while another
process is still in the middle of loading the compiler.