Skip to content
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

⚡ Feature: Variable usage checker #32

Merged
merged 19 commits into from Apr 1, 2024

Conversation

deavmi
Copy link
Contributor

@deavmi deavmi commented Nov 3, 2023

Please see this for more information.

- Added `varRefCounts` which maps a given `Variable` to its reference count. This includes the declaration thereof.
- Added `touch(Variable variable)` which Increments the given variable's reference count
- When handling a standalone assignment to a variable increment it's reference count
- This was updated in the handling of `VariableAssignmentStdAlone`
- Make variable declaration count as the first reference
- VAriables that appear in expressions must increase the ref count
- Added `getUnusedVariables()` which returns all variables which were declared but not used
@deavmi deavmi added the enhancement New feature or request label Nov 3, 2023
@deavmi deavmi self-assigned this Nov 3, 2023
- Moved the reference counting mechanism into the `TypeChecker` to avoid problem of seperate `DNodeGenerator` instances having their own seperate counts
- We now check the reference count values after function definition processing so as to get a proper count

Dependency

- Use the reference counting from `TypeChecker`
- Removed reference counting code

Test cases

- Added a positive case in the form of `unused_vars.t`
- Added a negative case in the form of `unused_vars_none.t`
- Added commands to `TypeCheckerBase!()` mixin template
- Added `TypeCheckerInit(Compiler compiler)`
- Use the template in both `compile` command and the`typecheck` command
- We now respect the `typecheck:warnUnusedVars` option
- Added `doPostChecks()`
- Moved the reference counting code to `doPostChecks()`
@deavmi deavmi changed the title 🧠 Ideation: Variable usage checker ⚡ Feature: Variable usage checker Nov 4, 2023
- `defaultConfig()` now adds an entry for `typecheck:warnUnusedVars` set to `true`
- Use `getName()` on the `Variable` when printing out the names of unused variables
- Made `gibFileData(string sourceFile)` public
- Added `getTypeChecker()` to the `Compiler` class
- Added a positive test case unittest for the unused variables detection mechanism
- Check the variable is equal to the one we are looking for (`j`)
- Added a negative test case for the unused variables detection mechanism
- Added tests for `unused_vars.t` and `unused_vars_none.t`
- Fixed message which prints out when an unused variable is detected
@deavmi
Copy link
Contributor Author

deavmi commented Apr 1, 2024

Merging...

@deavmi deavmi merged commit 800f06d into vardec_varass_dependency Apr 1, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant