Giter Club home page Giter Club logo

Comments (4)

sidkshatriya avatar sidkshatriya commented on July 23, 2024

By simplelanguage I mean, of course, https://github.com/graalvm/simplelanguage

from sulong.

chumer avatar chumer commented on July 23, 2024

The Truffle way of calling into other languages from an existing Language is using
TruffleLanguage.Env#parse(Source). It will return a CallTarget that represents that function. The language is identified using the mime-type of the Source object.
This can be done using the SLContext, which stores TruffleLanguage.Env instance anywhere you want inside SimpleLanguage. If you want the enable the Truffle inliner to optimize across this boundary you need to wrap it into a DirectCallNode using DirectCallNode#create(CallTarget), embed it into the AST and call it.

I will let the Sulong people comment on potential specifics to their language.

from sulong.

chrisseaton avatar chrisseaton commented on July 23, 2024

Interop with Sulong is complicated by the fact that it most people do not want to eval snippets of LLVM IR (which is what Sulong expects). When we use Sulong to run C extensions from JRuby, we eval the IR compiled from the C and then look up the C extension initialisation function, which has a known name, and execute that.

You may want to do something quite different, so it may be best to give us some pseudo code of the SL and C (or some other language?) that you want to run and how you imagine you'd like to write the interop code. Then we can help you shape that into something that works.

from sulong.

chumer avatar chumer commented on July 23, 2024

Oh I forgot. Another way of doing is by exporting a symbol in sulong and import it using TruffleLanguage.Env#importSymbol. If the symbol represents a function in Sulong and implements TruffleObject, we can call it using interop. SimpleLanguage supports to call foreign functions just as any other function. See SLDispatchNode#doForeign for details, how thats achieved.

from sulong.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.