com.oracle.truffle.api.library
Truffle Libraries allow language implementations to use polymorphic dispatch for receiver types with support for implementation specific caching/profiling and customization of the dispatch. Libraries enable modularity and encapsulation for representation types in language implementations.
Before reading the javadoc make sure you have read the tutorial.
Start learning Truffle Libraries by reading the following articles:
Librariesspecify the set of available messages i.e. the protocol.Exportsimplement a library for a receiver type.Automatic dispatching using @CachedLibrary allows to call library messages with concrete receiver and parameters from nodes using the
specializationDSL.Manual dispatching using the LibraryFactory allows to perform slow-path calls and custom inline cache implementations.
Advanced Features:
The
ReflectionLibraryallows to reflectively export and call messages without binary dependency to a library. It also allows to implement library agnostic proxies.The
DynamicDispatchLibraryallows to implement receivers that dynamically dispatch to exported message implementations.
See also
Classes
public abstract class DynamicDispatchLibraryA library that allows to dynamically dispatch to export library classes.
public abstract class LibraryBase class for all Truffle library specifications.
public abstract class LibraryExportBase class for generated export classes.
protected interface .DelegateExportInternal interface for generated code only.
public abstract class LibraryFactoryLibrary factories allow to create instances of libraries used to call library messages.
public abstract class MessageRepresents a description of library message.
public abstract class ReflectionLibraryThe reflection library allows to send to and proxy messages of receivers.
Annotations
public @interface CachedLibraryThe cached library annotation allows to use
Truffle Librariesconveniently inspecializationsorexported messages.public @interface ExportLibraryAllows to export messages of Truffle libraries.
public @interface .RepeatRepeat annotation for
ExportLibrary.
public @interface ExportMessageExports the annotated method or class as library message.
public @interface .IgnoreExplicitly ignores warning messages originating from the
ExportLibraryannotation.public @interface .RepeatNo description.
public @interface GenerateLibraryLibraries are specified with
publicandabstractJava classes that extend the Library class and are annotated by@GenerateLibrary.public @interface .AbstractMakes a library message abstract, but allows to keep a default implementation.
public @interface .DefaultExportSpecifies
libraryimplementations provided by default as a fallback.