as-pect / visitor-as

Visitor utilities for AssemblyScript compiler transforms
Apache License 2.0
37 stars 11 forks source link

feat: added necessary AS compiler to AS to make a AS transformer #12

Closed willemneal closed 1 year ago

yjhmelody commented 3 years ago

Why add such much code ?

willemneal commented 3 years ago

Because I copied the source files from the compiler. Eventually the compiler will be broken up into more granular modules, but until then I just copied them here to compile to AS.

yjhmelody commented 3 years ago

It seems that assemblyscript did not upload the as version of the compiler part of the code

yjhmelody commented 3 years ago

@willemneal Hi. In fact, I have not officially started this grant project, because assemblyscript does not seem to export the assemblyscript version of the compiler API.

willemneal commented 3 years ago

@yjhmelody That's why I copied them here. You don't need the full compiler API just the AST and transform API. We should schedule a time to talk in more depth about this.

yjhmelody commented 3 years ago

@willemneal transform seems to currently only support nodejs. And I think the transform API really does not need to be done in an AST visitor library

willemneal commented 3 years ago

@yjhmelody:

Here are my thoughts on how to achieve this in the short term. For now, the compiler's frontend will continue to be in JS. So we need just one transform that this library will provide.

The outer transform will do the following:

yjhmelody commented 3 years ago

@willemneal

Do you want to implement a pure AS version of transform? Why doesn't this wait for the official build-in? I want to implement an as version of AST visitor alone, and there is no problem. But if we want to implement transform, we need to communicate more details, which is a bit unacceptable, and I think this should be implemented by the AS official, after all, the official has provided platform-independent Transform interfaces (like writeFile/readFile), but it's seem that I do not see this piece of relevant progress.

And even if it really needs to be implemented, I personally think this can be completely split into 2 libs.

Like I use as-visitor now, but I don’t use its Transform related API.

willemneal commented 3 years ago

@yjhmelody The more I think about it you are correct. We should move this work and make a PR to the main repo. I will be available early tomorrow for me. If you can find me on discord we can sync on the next steps. Otherwise I'll write up my ideas tomorrow morning.

yjhmelody commented 3 years ago

@willemneal Well, I created a new repo https://github.com/yjhmelody/as-visitor

I plan to make BaseVisitor based on BaseTransformVisitor. I think the ability of BaseTransformVisitor is a superset of BaseVisitor. If I don’t do this, there may be subtle differences between the two interfaces. At present, there are such subtle differences in the visitor-as code