public abstract static class TruffleLanguage.LanguageReference<L extends TruffleLanguage> extends Object
TruffleLanguage.LanguageReference.create(Class)and are intended to be stored in static final fields and accessed at runtime using
TruffleLanguage.LanguageReference.get(Node)with the current
Node, if available, as parameter.
Example intended usage:
TruffleLanguage.ContextReference for a full usage example.
|Modifier||Constructor and Description|
Constructors for subclasses.
|Modifier and Type||Method and Description|
Creates a new instance of a langauge reference for an registered language.
Returns the current language instance associated with the current thread.
nullmay be provided. This method is designed to be called safely from compiled code paths. In order to maximize efficiency in compiled code paths, a partial evaluation constant and adopted node should be passed as parameter. If this is the case then the return context will get constant folded in compiled code paths if there is a only single context instance for the enclosing engine or lookup location/node.
The current language will not change for
roots of the current language. For roots of other
languages, e.g. if invoked through the interoperability protocol, the language might
change between consecutive executions. It is recommended to *not* cache values of the
language in the AST to reduce footprint. Getting it through a language reference will
either constant fold or be very efficient in compiled code paths.
for a full usage example
public static <T extends TruffleLanguage<?>> TruffleLanguage.LanguageReference<T> create(Class<T> languageClass)
IllegalArgumentExceptionif the provided language class is not
registered. Guaranteed to always return the same context reference for a given language class.
TruffleLanguage.LanguageReference for a usage example.