feat(compiler): pure Roslyn H5.Compiler.Next initial implementation#280
feat(compiler): pure Roslyn H5.Compiler.Next initial implementation#280theolivenbaum wants to merge 4 commits intomasterfrom
Conversation
- Established `Next/` directory containing the `H5.Compiler.Next` (executable) and `H5.Compiler.Service.Next` (library). - Integrated `Microsoft.CodeAnalysis.CSharp` dependencies for pure Roslyn parsing and emitting. - Implemented initial `H5Compiler` utilizing `CSharpCompilation.Create` and `JavascriptEmitter` (extending `CSharpSyntaxWalker`). - Added capability to parse a basic "Hello World" source file and output the corresponding `H5.define(...)` JavaScript structure containing `console.log`. - Created an initial `xUnit` test confirming successful compilation and matching JS structure. - Addressed all prompt instructions and required configuration files (`AGENTS.md`, `TODO.md`, `WIP.md`). Co-authored-by: theolivenbaum <8791811+theolivenbaum@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
…erics
- Extended `JavascriptEmitter` to process `StructDeclarationSyntax` and `ClassDeclarationSyntax`.
- Segregated properties, fields, and methods into standard H5 `statics`, `fields`, `props`, and `methods` blocks within `H5.define`.
- Added recognition and emission of the `$kind: "struct"` property for structures.
- Implemented functional wrapping (e.g., `function (T) { return { ... }; }`) to properly support generic parameters in class and struct definitions.
- Enhanced `IdentifierNameSyntax` visitation to prepend `this.` on instance fields and properties.
- Introduced `ComplexTypeTest` to assert against a generic struct, properties, and an implementation of an interface in `Next/H5.Compiler.Next.Tests`.
Co-authored-by: theolivenbaum <8791811+theolivenbaum@users.noreply.github.com>
- Added `Jint` NuGet dependency to `H5.Compiler.Next.Tests`. - Developed `IntegrationTestRunner` to simulate H5 execution. Uses an `H5.define` JavaScript mock to reconstruct the compiled C# classes, structs, and generic types in memory. - Overhauled `JavascriptEmitter` to avoid incorrectly outputting namespaces, return accurate `ReturnStatementSyntax`, and parse basic `BinaryExpressionSyntax`. - Implemented incremental `IntegrationTests` suite containing: - `Test1_SimpleReturnValue`: Tests basic static returns. - `Test2_FieldAccess`: Tests instance state and variable assignment. - `Test3_PropertyAccess`: Tests getter/setter property simulation. - `Test4_GenericClass`: Tests generic instantiation closure evaluation. Co-authored-by: theolivenbaum <8791811+theolivenbaum@users.noreply.github.com>
…uctures - Updated `JavascriptEmitter` to process `BlockSyntax`, supporting nested scopes. - Implemented `VisitLocalDeclarationStatement` to output JS `var` variable initialization. - Added implementation for `VisitIfStatement`, `VisitForStatement`, and `VisitWhileStatement` to properly map C# loops and conditionals natively to JS equivalents. - Refactored `VisitIdentifierName` to ensure `this.` is exclusively prepended to instance properties/fields and explicitly ignored if acting as the target of a `MemberAccessExpression` (resolves `other.this.Field` bugs). - Overrode `VisitMemberAccessExpression` to format direct access via `.`. - Added a series of `IntegrationTests` evaluating arithmetic local variables, if statement evaluation logic, and loops (For/While) resolving correctly within the Jint runtime sandbox. - Updated the roadmap tracker (`TODO.md`) acknowledging successful milestone progression. Co-authored-by: theolivenbaum <8791811+theolivenbaum@users.noreply.github.com>
This submission implements the foundational setup for the future H5 Compiler version (
H5.Compiler.Next) as requested by the user.Changes Made:
Next/H5.Compiler.Next(CLI wrapper),Next/H5.Compiler.Service.Next(compiler library containing Roslyn-based parser and JS emitter), andNext/H5.Compiler.Next.Tests(XUnit tests).Microsoft.CodeAnalysis.CSharp. Implemented anH5Compilerthat initializes aCSharpCompilationpipeline and aJavascriptEmitter(leveragingCSharpSyntaxWalker) that directly traverses the AST and generates matching H5 JavaScript formats.H5.define), and standard method invocations likeConsole.WriteLinetranslated toconsole.log().HelloWorldTestmappingConsole.WriteLine("Hello, World!")input strings toH5.defineJavaScript assertions. Wired up CLI (H5.Compiler.Next/Program.cs) to execute against source.csfiles natively, writing to.js..mdfiles detailing the pure Roslyn goal.PR created automatically by Jules for task 5767421521241371841 started by @theolivenbaum