Giter Site home page Giter Site logo

Comments (7)

dcodeIO avatar dcodeIO commented on May 18, 2024 3

Regarding the commit above, there is now a way to provide transforms with the --transform option to asc. This basically loads a node module that then exports hooks the compiler will call on specific occasions. The only hook for now is afterParse which calls the transform with the parser instance that contains the parsed sources, prior to initializing the program from it. It's relatively easy to add more hooks, of course, but I didn't want to go overboard with that so let me know if there's something specific you'd need.

from assemblyscript.

dcodeIO avatar dcodeIO commented on May 18, 2024 2

I see, thanks. AssemblyScript has an AST representation as well, so transforming it prior to the final compilation step shouldn't be a big deal. There is also the Program that wraps the higher level IR created from the AST. That's where built-in functionality is combined with the processed source information, which is the last step before compilation is finally performed.

Not directly "planning", though, because there's still so much to do, but not impossible either.

from assemblyscript.

dcodeIO avatar dcodeIO commented on May 18, 2024

If I understand this correctly, custom transformers do not look AOT-compatible. More like something that requires the language to be highly dynamic.

from assemblyscript.

dcodeIO avatar dcodeIO commented on May 18, 2024

On a second thought, something similar might be possible if there was an API to plug in custom built-ins that have full access to the compiler's type information and transform such code at compile time.

from assemblyscript.

dcodeIO avatar dcodeIO commented on May 18, 2024

See also: https://github.com/AssemblyScript/assemblyscript/wiki/Limitations

from assemblyscript.

TomMarius avatar TomMarius commented on May 18, 2024

Custom transformer is a function plugged into the compilation process. It takes the AST of the program and returns a new (or the same) AST. It has nothing to do with anything dynamic; other statically typed languages have this sort of plugin functionality as well.

from assemblyscript.

dcodeIO avatar dcodeIO commented on May 18, 2024

Closing this for now as the infrastructure is in place. Just let me know if more hooks are necessary :)

from assemblyscript.

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.