package sdk
Type Members
- final class Adapters extends AnyRef
Finds the adapter that links against the compiler on this class path.
Finds the adapter that links against the compiler on this class path.
Selection is by linkage, not by version string. Instantiating an adapter forces the JVM to resolve the compiler types it binds to, so an adapter written for an AST this compiler does not have fails here, in a controlled place, instead of part-way through a measurement. A fork reporting an unfamiliar version may still link; a compiler reporting a familiar one may not. The JVM knows, and it is cheaper to ask it than to maintain a table of which versions are secretly compatible.
Loaded by name so that nothing outside this method mentions an adapter class. The phase that runs without a compiler on its class path can hold a reference to
CompilerModelall day; it never loads anything that would need Scala or Flix to resolve. - trait CompilerModel extends AnyRef
The stable ABI, because
flix.jardoes not have one.The stable ABI, because
flix.jardoes not have one.Flix's internals carry no compatibility promise:
Bootstrap,TypedAstand everything under them may be reorganised in any release, and have been. A plugin that spreads knowledge of those types through its own code inherits that instability everywhere, and every new compiler becomes an edit in a dozen places.So the instability is confined instead. This interface is the only thing the rest of the plugin knows about a compiler, and it is Java, and versionless on purpose: everything crossing it is a string, a number or a boolean. One implementation per Flix generation sits behind it, written against that generation's AST, and nothing outside those implementations imports
ca.uwaterloo.flix.Per declaration, not aggregate. An earlier version returned totals, which was enough to print a summary and useless for anything else: a finding has to name a file and a line, a ranking has to compare definitions to each other, and "the worst three" cannot be recovered from a sum. Returning records costs nothing in coupling — none of them mention a compiler type — and is what lets every smell, format and ranking live outside the adapter.
Implementing one
Implementations must be instantiable with a public no-argument constructor and named in
Adapters. They are loaded reflectively by name, which is what keeps them off the class path of the phase that has no compiler: an adapter is only ever loaded in a JVM that already has the compiler it was written for.