@Retention(value=RUNTIME) @Target(value=TYPE) public static @interface TruffleLanguage.Registration
Polyglot
API. By annotating your implementation of TruffleLanguage by this annotation the
language can be discovered on the class path.| Modifier and Type | Optional Element and Description |
|---|---|
String[] |
byteMimeTypes
List of MIME types supported by this language which sources should be interpreted as
byte based sources. |
String[] |
characterMimeTypes
List of MIME types supported by this language which sources should be interpreted as
character based sources. |
TruffleLanguage.ContextPolicy |
contextPolicy
Defines the supported policy for reusing
languages per context. |
String |
defaultMimeType
Returns the default MIME type of this language.
|
String[] |
dependentLanguages
Specifies a list of languages that this language depends on.
|
Class<? extends TruffleFile.FileTypeDetector>[] |
fileTypeDetectors
Declarative list of
TruffleFile.FileTypeDetector classes provided by this
language. |
String |
id
Unique id of your language.
|
String |
implementationName
Unique name of your language implementation.
|
boolean |
interactive
Specifies if the language is suitable for interactive evaluation of
sources. |
boolean |
internal
Returns
true if this language is intended for internal use only. |
String |
name
Unique name of your language.
|
boolean |
needsAllEncodings
Returns
true if the language uses TruffleStrings with encodings not
present in the following list. |
org.graalvm.polyglot.SandboxPolicy |
sandbox
Specifies the most strict sandbox policy in which the language can be used.
|
Class<?>[] |
services
Declarative list of classes this language is known to provide.
|
String |
version
Unique string identifying the language version.
|
String |
website
A link to a website with more information about the language.
|
public abstract String id
public abstract String name
Language.getName() getter.public abstract String implementationName
public abstract String version
Language.getVersion() getter. It inherits from
Engine.getVersion() by default.public abstract String defaultMimeType
character or byte based MIME
types.
The default MIME type is mandatory if more than one supported MIME type was specified. If
no default MIME type and no supported MIME types were specified then all sources for this
language will be interpreted as character based sources.
LanguageInfo.getDefaultMimeType(),
Language.getDefaultMimeType(),
TruffleLanguage.Registration.characterMimeTypes(),
TruffleLanguage.Registration.byteMimeTypes()public abstract String[] characterMimeTypes
character based sources. Languages may use MIME types to
differentiate supported source kinds. If a MIME type is declared as supported then the
language needs to be able to parse sources
of this kind. If only one supported MIME type was specified by a language then it will be
used as default MIME type. If no supported character and byte
based MIME types are specified then all sources will be interpreted as
character based.TruffleLanguage.Registration.defaultMimeType(),
TruffleLanguage.Registration.byteMimeTypes()public abstract String[] byteMimeTypes
byte based sources. Languages may use MIME types to
differentiate supported source kinds. If a MIME type is declared as supported then the
language needs to be able to parse sources
of this kind. If only one supported MIME type was specified by a language then it will be
used as default MIME type. If no supported character and byte
based MIME types are specified then all sources will be interpreted as
character based.TruffleLanguage.Registration.defaultMimeType(),
TruffleLanguage.Registration.characterMimeTypes()public abstract boolean interactive
sources. Interactive languages should be displayed in interactive
environments and presented to the user. The default value of this attribute is
true assuming majority of the languages is interactive. Change the value to
false to opt-out and turn your language into non-interactive one.true if the language should be presented to end-user in an
interactive environmentpublic abstract boolean internal
true if this language is intended for internal use only. Internal
languages cannot be used in the host environment directly, they can only be used from
other languages or from instruments.public abstract String[] dependentLanguages
TruffleLanguage.Registration.id(). This has the following effects:
restricted.
finalized.
disposed.
Non-internal languages implicitly depend on all internal languages.
Therefore by default non-internal languages are disposed and finalized before internal
languages.
Dependent languages should be parsed with TruffleLanguage.Env.parseInternal(Source, String...) as
the embedder might choose to disable access to it for
TruffleLanguage.Env.parsePublic(Source, String...).
Dependent languages references are optional. If a dependent language is not installed and
the language needs to fail in such a case then the language should fail on
context initialization. Cycles in
dependencies will cause an IllegalStateException when one of the cyclic languages
is initialized.
public abstract TruffleLanguage.ContextPolicy contextPolicy
languages per context.
I.e. the policy specifies the degree of sharing that is allowed between multiple language
contexts. The default policy is exclusive. Every language
is encouraged to try to support a context policy that is as permissive as possible, where
exclusive is the least and shared is the most permissive policy. Parse
caching is scoped per language instance, therefore the context
policy influences its behavior.
The context policy applies to contexts that were created using the
polyglot API as well as for inner contexts. The context policy does not apply to nodes that were created using the
Truffle interop protocol. Therefore, interop message nodes always need to be prepared to
be used with policy TruffleLanguage.ContextPolicy.SHARED.
TruffleLanguage.parse(ParsingRequest)public abstract Class<?>[] services
createContext method and instantiate and register all here in defined services.
Languages automatically get created but not yet initialized when their registered
service is
requested.
public abstract Class<? extends TruffleFile.FileTypeDetector>[] fileTypeDetectors
TruffleFile.FileTypeDetector classes provided by this
language.
The language has to support all MIME types recognized by the registered
file type detectors.
public abstract boolean needsAllEncodings
true if the language uses TruffleStrings with encodings not
present in the following list.
UTF-8UTF-16UTF-32ISO-8859-1US-ASCIIBYTESpublic abstract String website
The link can contain the following substitutions:
${graalvm-version}${graalvm-version:format}. See Version.format(java.lang.String).
${graalvm-website-version}public abstract org.graalvm.polyglot.SandboxPolicy sandbox
ISOLATED policy, it can be used in a context configured
with sandbox policy TRUSTED, CONSTRAINED or ISOLATED. But it
cannot be used in a context configured with the UNTRUSTED sandbox policy.SandboxPolicy