-
Notifications
You must be signed in to change notification settings - Fork 4
Transpiler #64
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
Transpiler #64
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a Transpiler abstract base class to refactor the existing shell transpilation logic, creating a cleaner separation of concerns and improving code organization.
- Creates an abstract
Transpilerclass with common transpilation functionality and module management - Refactors the existing
Transpilerclass inshell.tsto extend the new base class asShellTranspiler - Moves shared transpilation logic (file reading, module caching, session management) into the base class
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| server/src/transpiler/transpiler.ts | Introduces the abstract Transpiler base class with common transpilation functionality |
| server/src/transpiler/shell.ts | Refactors the existing transpiler implementation to extend the new base class and removes duplicate code |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
server/src/transpiler/transpiler.ts
Outdated
|
|
||
| getBaseGlobalNames() { | ||
| if (!this.baseGlobalNames) | ||
| throw 'baseGlobalNames is not set' |
Copilot
AI
Sep 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use proper Error objects instead of throwing strings. Replace with throw new Error('baseGlobalNames is not set').
| throw 'baseGlobalNames is not set' | |
| throw new Error('baseGlobalNames is not set') |
| execSync(`cc -DTEST64 -O2 -shared -fPIC -o ${this.cRuntimeSo} ${cRuntimeC} ${cFile}`) | ||
| execSync(`cc -DTEST64 -O2 -o ${dir}/shell ${shellC} ${this.cRuntimeSo} -lm -ldl`) |
Copilot
AI
Sep 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using this.cRuntimeSo in a static method will cause an error since this is not available in static context. Use ShellTranspiler.cRuntimeSo instead.
| execSync(`cc -DTEST64 -O2 -shared -fPIC -o ${this.cRuntimeSo} ${cRuntimeC} ${cFile}`) | |
| execSync(`cc -DTEST64 -O2 -o ${dir}/shell ${shellC} ${this.cRuntimeSo} -lm -ldl`) | |
| execSync(`cc -DTEST64 -O2 -shared -fPIC -o ${ShellTranspiler.cRuntimeSo} ${cRuntimeC} ${cFile}`) | |
| execSync(`cc -DTEST64 -O2 -o ${dir}/shell ${shellC} ${ShellTranspiler.cRuntimeSo} -lm -ldl`) |
| execSync(`cc -DTEST64 -O2 -shared -fPIC -o ${this.cRuntimeSo} ${cRuntimeC} ${cFile}`) | ||
| execSync(`cc -DTEST64 -O2 -o ${dir}/shell ${shellC} ${this.cRuntimeSo} -lm -ldl`) |
Copilot
AI
Sep 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using this.cRuntimeSo in a static method will cause an error since this is not available in static context. Use ShellTranspiler.cRuntimeSo instead.
| execSync(`cc -DTEST64 -O2 -shared -fPIC -o ${this.cRuntimeSo} ${cRuntimeC} ${cFile}`) | |
| execSync(`cc -DTEST64 -O2 -o ${dir}/shell ${shellC} ${this.cRuntimeSo} -lm -ldl`) | |
| execSync(`cc -DTEST64 -O2 -shared -fPIC -o ${ShellTranspiler.cRuntimeSo} ${cRuntimeC} ${cFile}`) | |
| execSync(`cc -DTEST64 -O2 -o ${dir}/shell ${shellC} ${ShellTranspiler.cRuntimeSo} -lm -ldl`) |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
No description provided.