refactoring - #71
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the mini JavaScript engine by replacing magic-number value-type tags with named constants and extracting several built-in behaviors (globals + array methods) into dedicated classes to simplify the core interpreter logic.
Changes:
- Introduces
zif_mjs=>c_type_*constants for runtime value typing (undefined/number/string/bool/function/null/object/array/regex/getter). - Extracts built-ins into
zcl_mjs_builtins(Boolean/RegExp/JSON.stringify/console.log/Object.keys/Object.defineProperty/Date.now/Set.has/new Set). - Extracts array method handling into
zcl_mjs_arr_methodsand centralizesToPrimitivecoercion withzcl_mjs=>to_primitive.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/zif_mjs.intf.abap | Adds named constants for runtime value-type tags. |
| src/zcl_mjs.clas.abap | Refactors interpreter to use constants; extracts built-ins/array methods; adds to_primitive; makes call_function public for callbacks. |
| src/zcl_mjs_val.clas.abap | Updates value boxing/conversion helpers to use c_type_* constants. |
| src/zcl_mjs_env.clas.abap | Uses c_type_undefined for missing bindings. |
| src/zcl_mjs_builtins.clas.xml | Adds class metadata for new built-ins helper class. |
| src/zcl_mjs_builtins.clas.abap | Implements extracted built-ins (Boolean/RegExp/JSON/console/Date/Object/Set helpers). |
| src/types/zcl_mjs_string.clas.abap | Replaces regex/array magic numbers with c_type_* constants. |
| src/types/zcl_mjs_json.clas.abap | Replaces magic numbers with c_type_* constants in JSON stringify. |
| src/types/zcl_mjs_arr_methods.clas.xml | Adds class metadata for new array-methods helper class. |
| src/types/zcl_mjs_arr_methods.clas.abap | Implements extracted array methods (push/map/find/filter/splice/sort). |
| package.json | Updates @abaplint/* dependency versions. |
| package-lock.json | Locks updated @abaplint/* dependency versions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.