-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Haxe AST -> C# AST -> C# Printer #13
Comments
Sounds good, let's do it! |
Notes about my contributions so far:
I'm open to changes for anything, so don't hesitate to make big structure changes if necessary. It's hard to tell what is or isn't going to be necessary until it's being printed, so we'll just have to feel it out as we go. |
That was fast! This starting point looks good to me, and ok let's stick to Not sure about using classes for AST though, because you get some free perks when using typedefs, like being able to print their structure on console instead of just having I've read your note on |
On second though, you are probably right that we may not need to actually parse a whole extern class that we don't need to generate, especially if we are just passing an instance of extern type through some haxe code without inheriting from it. We can decide when we actually implement that |
I usually use classes for "heavy" data which might even be built and refined over time, and which is supposed to have an identity. So this seems like a good choice here. Regarding CSType, I'd make sure to design it in a way that allows you to easily implement |
I started working on migrating current code from
DirectToStringCompiler
toGenericCompiler
as well as make it use a printer instead of simply returning strings as expression. That (unfinished) work is in the generic-and-printer branch.The initial rationale was to print C# code directly from Haxe AST because it was assumed the two languages are pretty close, and differences could be handled by manipulating Haxe AST directly, but @Simn advised on Discord against doing that and instead suggested to add a step to generate C# AST and print from it, in order to be sure we can carry the information we need and avoid making wrong assumptions.
Simon's explanation for reference:
As we don't want to repeat the mistakes of previous C# target, I decided to follow that advice and will work on generating an actual C# AST and print from it. This certainly requires some more work than without the intermediate C# AST but I agree it's for the best, long term.
Thus I'm pausing what I started in the generic-and-printer branch (there are still a lot of C# printing snippets that will be useful for later), and will start working on a
Haxe AST -> C# AST -> C# Printer
version (on a new branch).This issue is there to let you know I'm working on this and keep track of the progress.
Current plan
(might change depending of how it goes when implementing it or from feedback in this issue):
CSTypedExpr
typedef which will be very similar to Haxe's TypedExpr, but modified as needed to match exactly the intended C# output. Do the same for any AST type needed to represent C# hierarchy (like ModuleType, ClassType etc...).GenericCompiler
that is typed to return C# AST instead of stringsCSPrinter
class that outputs C# code from this C# ASTTimeline
I want to take time to make this right, so no plan to rush it. However, this project is very important for me (because I need it for Ceramic) so I'll dedicate a good amount of time to work on that C# target in 2024. Initial iteration for that C# AST implementation might take several weeks, then from that point if it goes right it will be merged to
development
branch and contributions from more people could be easier to manage without too much overlap.A lot of work ahead, but exciting as well 😄
The text was updated successfully, but these errors were encountered: