Comments (7)
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.
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.
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.
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.
See also: https://github.com/AssemblyScript/assemblyscript/wiki/Limitations
from assemblyscript.
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.
Closing this for now as the infrastructure is in place. Just let me know if more hooks are necessary :)
from assemblyscript.
Related Issues (20)
- Possible regression after the latest release HOT 3
- Getting ERR_MODULE_NOT_FOUND after recent PR, basic AssemblyScript example fails HOT 3
- incorrect variable resolving for class default initializer
- asc crash when use same name in class and namespace HOT 1
- missing diagnose for interface with initialized field
- compiler crash HOT 1
- Hello HOT 1
- AS supports WASMGC? HOT 6
- Blazor Web App (Server) .NET8.0 call Web API with MVC HOT 1
- Compiler failing at optimization step with a big .ts file HOT 13
- The results of arithmetic operations with u8 are not truncated to 8 bits, when assigned to f64 HOT 1
- Stale Memory Reads HOT 17
- I look at the source code and find that there is code related to wasmGC, will wasmGC be supported soon? HOT 1
- npx asinit .
- Support type alias as syntactic sugar for class HOT 4
- Incorrect overriden function call HOT 2
- `env` module isn't imported, using `moduleImports` and `--importMemory` together
- I hope compiling to native binary was added for AssemblyScript. HOT 1
- Loop and variable bug HOT 2
- as crash when try to alloc large data HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from assemblyscript.