Conversation
There was a problem hiding this comment.
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' |
There was a problem hiding this comment.
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`) |
There was a problem hiding this comment.
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`) |
There was a problem hiding this comment.
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.