/** * Returns an additional service provided by the given language, specified by type. If an * language is not loaded, it will not be automatically loaded by requesting a service. In * order to ensure a language to be loaded at least one {@link Source} must be * {@link #parse(Source, String...) parsed} first. * * @param <S> the requested type * @param language the language to query * @param type the class of the requested type * @return the registered service or <code>null</code> if none is found * @since 0.26 */ @TruffleBoundary public <S> S lookup(@SuppressWarnings("hiding") LanguageInfo language, Class<S> type) { if (this.language == language) { throw new IllegalArgumentException("Cannot request services from the current language."); } TruffleLanguage<?> otherSpi = AccessAPI.nodesAccess().getLanguageSpi(language); return otherSpi.lookup(type); }
@Override public boolean isThreadAccessAllowed(LanguageInfo language, Thread thread, boolean singleThread) { return AccessAPI.nodesAccess().getLanguageSpi(language).isThreadAccessAllowed(thread, singleThread); }
/** * Returns the home location for this language. This corresponds to the directory in which the * Jar file is located, if run from a Jar file. For an AOT compiled binary, this corresponds to * the location of the language files in the default GraalVM distribution layout. executable or * shared library. * * @since 1.0 */ protected final String getLanguageHome() { return AccessAPI.engineAccess().getLanguageHome(AccessAPI.nodesAccess().getEngineObject(languageInfo)); }
@Override public void initializeLanguage(LanguageInfo language, TruffleLanguage<?> impl, boolean legacyLanguage) { AccessAPI.nodesAccess().setLanguageSpi(language, impl); impl.initialize(language, legacyLanguage); }
@Override public <S> S lookup(LanguageInfo language, Class<S> type) { return TruffleLanguage.AccessAPI.nodesAccess().getLanguageSpi(language).lookup(type); }