Git Product home page Git Product logo

Comments (4)

jtulach avatar jtulach commented on May 18, 2024

I am currently working on cleanup of Source creation sequence. I am going to introduce Source.Builder, draft is available at https://github.com/jtulach/truffle/tree/SourceBuilder

The builder will not use any caching - e.g. your point 2 will be satisfied.

I find the description of point 1 a little bit too vague (unless it means "set the URI for a Source") - hard to guess whether my work satisfies it.

from graal.

pniederw avatar pniederw commented on May 18, 2024

To give some more background, I replaced 1 and 2 with my own code because:

  1. I wanted Source to behave uniformly regardless of which origin it was loaded from, in terms of eager vs. lazy loading, caching, etc.
  2. I wanted to support the following different kinds of source code origins specific to my language: URL, File, class path, standard library, REPL input, literal text
  3. I wanted to easily determine the origin of a piece of source code and query its origin-specific attributes (e.g. to perform permission checks and to resolve relative script includes in an origin-specific way), without having to reconstruct this information from a Source's answers to getURL, getPath, getName, etc. (which is brittle).
  4. I wanted to have my own implementations for loading code from an origin (e.g. to perform permission checks and to leverage non-blocking IO).
  5. I needed to have my own representation of source (origin) anyway, as leaking Truffle classes from my APIs wasn't an option.

To satisfy these requirements, I currently do the following: I do my own loading/caching, exclusively use Source.fromText to create Source objects, and keep origin-specific information about the source in an IdentityHashMap for later lookup. This works reasonably well. However, I'd rather not have to use IdentityHashMap, and complications arise when I need to process a Source that wasn't created by my own code. (I'd like to support this in order to be a good Truffle citizen.)

The following enhancements to Source could make it a more versatile abstraction and a better fit for my needs:

  1. Allow to attach opaque meta-information to a Source.
  2. Allow to easily determine which kind of built-in origin (fromURL, fromFilename, fromText, etc.) it was loaded from and what the origin-specific attributes are.

I also considered proposing a first-class, user-extensible notion of source origin, but this might not work so well in a polyglot setting.

from graal.

jtulach avatar jtulach commented on May 18, 2024

After jtulach@872a1e9 the origin is taken uniformly, I'd say.

The additional meta-information is out of scope for the current "builder" change, but it is an interesting idea. Similar to: when a co-located source is about to be loaded (think of importScript('rel.js')) shouldn't that request be handled by the one who created the source that contains the importScript?

from graal.

chumer avatar chumer commented on May 18, 2024

Looks like a stale issue where most issues are already resolved. Please reopen if addition work is necessary.

from graal.

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.