Commit Graph

1276 Commits

Author SHA1 Message Date
Tristan B. Velloza Kildaire d1460cc758 TypeChecker (unittests)
- Fixed missing `sourceFile` argument to various `Compiler` constructors
- Fixed the module obtaining in one of the tests
2024-04-07 12:15:01 +02:00
Tristan B. Velloza Kildaire 0a3a543f98 Merge branch 'vardec_varass_dependency' into feature/multi_module 2024-04-07 12:11:03 +02:00
Tristan B. Velloza Kildaire 89234138f4 DGen
- Removed old commented-out code from `emitExterns(File modOut, Module mod)`
2024-04-07 12:03:59 +02:00
Tristan B. Velloza Kildaire 92c464a8ab Test cases
- Updated to show use of extern variables
2024-04-01 22:15:58 +02:00
Tristan B. Velloza Kildaire e41c3a8d88 Dgen
- Added `generateSignature_Variable(Variable var)` which generates JUST a variable signature (with symbol mapping)
- `emitExterns(File modOut, Module mod)` now also generates extern statements for global variables
2024-04-01 22:14:55 +02:00
Tristan B. Velloza Kildaire 800f06da5f
Feature: Variable usage checker (#32)
* Dependency

- 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

* Dependency

- When handling a standalone assignment to a variable increment it's reference count
- This was updated in the handling of `VariableAssignmentStdAlone`

* Dependency

- Make variable declaration count as the first reference

* Dependency

- VAriables that appear in expressions must increase the ref count

* Dependency

- Added `getUnusedVariables()` which returns all variables which were declared but not used

* TypeChecker

- 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`

* Commands

- Added commands to `TypeCheckerBase!()` mixin template
- Added `TypeCheckerInit(Compiler compiler)`
- Use the template in both `compile` command and the`typecheck` command

* TypeChecker

- We now respect the `typecheck:warnUnusedVars` option

* TypeChecker

- Added `doPostChecks()`
- Moved the reference counting code to `doPostChecks()`

* Configuration

- `defaultConfig()` now adds an entry for `typecheck:warnUnusedVars` set to `true`

* TypeChecker

- Use `getName()` on the `Variable` when printing out the names of unused variables

* Compiler

- Made `gibFileData(string sourceFile)` public
- Added `getTypeChecker()` to the `Compiler` class

* TypeChecker (unittests)

- Added a positive test case unittest for the unused variables detection mechanism

* TypeChecker (unittests)

- Check the variable is equal to the one we are looking for (`j`)

* TypeChecker (unittests)

- Added a negative test case for the unused variables detection mechanism

* Pipelines

- Added tests for `unused_vars.t` and `unused_vars_none.t`

* TypeChecker

- Fixed message which prints out when an unused variable is detected

* Merge branch 'vardec_varass_dependency' into feature/unused_vars_detection
2024-04-01 21:55:56 +02:00
Tristan B. Velloza Kildaire e1fbdde91c Parser
- Removed unused method `doImport(string moduleName)`
2024-04-01 20:56:48 +02:00
Tristan B. Velloza Kildaire 29653d8f32 Parser
- Removed now-completed TODO
2024-04-01 19:36:28 +02:00
Tristan B. Velloza Kildaire f206db04f2 ModuleManager
- Fixed bug in `validate(string searchPath)` which would not check if a path existed
2024-04-01 14:01:25 +02:00
Tristan B. Velloza Kildaire 622d06c4e3 Commands
- Added `ParseBase` mixin template, this contains the support for `--paths` command-line option
- `compileCommand` now mixes in `ParseBase` and `TypeCheckerBase` and initializes the `ParseBaseInit()` as well
- `parseCommand` now mixes in `ParseBase` and initializes the `ParseBaseInit()` as well
- `typecheckCommand` now mixes in `ParseBase` and `TypeCheckerBase` and initializes the `ParseBaseInit()` as well
2024-04-01 13:56:36 +02:00
Tristan B. Velloza Kildaire 0444b70a9c Compiler
- Added documentation to `getModMan()`
2024-04-01 13:54:40 +02:00
Tristan B. Velloza Kildaire 1cc862bd3e Small docs
- Yebop
2024-04-01 13:54:23 +02:00
Tristan B. Velloza Kildaire 2a0fc365ab Configuration
- Cleaned up the configuration code which initially creates the `ConfigEntry` for `modman:path`
2024-04-01 13:54:06 +02:00
Tristan B. Velloza Kildaire 95f14450fa ModuleManager
- Fixed bug in `findAllTFilesShallow(string directory)` whereby we would never check `directory` to be a valid path nor even a path (if valid) to a directory - which is required in order to run `dirEntries(...)` on it
2024-04-01 13:51:34 +02:00
Tristan B. Velloza Kildaire ec341039de Parser
- `moduleFilePath` is no longer an optional argument
2024-03-31 23:37:48 +02:00
Tristan B. Velloza Kildaire 0ffacf2b45 Small docs
- Added new one to work on soon
2024-03-31 23:28:42 +02:00
Tristan B. Velloza Kildaire 7215d2399a Parser (unittests)
- Comments unittests disabled for now
2024-03-31 23:28:28 +02:00
Tristan B. Velloza Kildaire d2cb5ca4cb ModuleManager
- Removed `slashToDot(string strIn)`
- Removed `skimModuleDeclaredName(string modulePath, ref string skimmedName)`
2024-03-31 23:27:32 +02:00
Tristan B. Velloza Kildaire 2609d08b0a Configuration
- Added default config option of `modman:strict_headers` and set it to `false`
2024-03-31 23:26:09 +02:00
Tristan B. Velloza Kildaire 70337d62af Parser
- Added doc
2024-03-31 22:09:29 +02:00
Tristan B. Velloza Kildaire 9e63dc32c0 test cases
- Updated `a.t` to use a multi-line import
2024-03-31 22:00:57 +02:00
Tristan B. Velloza Kildaire 09e597d8a0 Parser
- Make `doImport(string)` now use `doImports(string[])`
- `parseImport()` now supports multi-line imports
2024-03-31 22:00:29 +02:00
Tristan B. Velloza Kildaire cce1f2f610 Parser
- Updated `doImport(string)`
2024-03-31 21:47:29 +02:00
Tristan B. Velloza Kildaire b3e18409b5 Revert "Pipelines"
This reverts commit 73efdf9d4c.
2024-03-31 21:25:47 +02:00
Tristan B. Velloza Kildaire 73efdf9d4c Pipelines
- test to make sure
2024-03-31 21:25:32 +02:00
Tristan B. Velloza Kildaire 5467962398 Pipelines
- try this?
2024-03-31 21:23:15 +02:00
Tristan B. Velloza Kildaire 435b3d5179 Pipelines
- But don't fail after running it lmao
2024-03-31 21:16:05 +02:00
Tristan B. Velloza Kildaire 79a56ad248 Pipelines
- Smh, fixed
2024-03-31 21:13:11 +02:00
Tristan B. Velloza Kildaire 4f6441fa7a Pipelines
- No, actual fix is `-e` as we want to exit on first bad command (non-zero exit code)
2024-03-31 21:10:25 +02:00
Tristan B. Velloza Kildaire aa7ce07e3b Pipelines
- FIXED it (removed set e in wrong place)
- Added test for `a.t` (multi-module) test
2024-03-31 21:08:27 +02:00
Tristan B. Velloza Kildaire 5a95f8c240 Pipelines
- Added test for `a.t` (multi-module) test
2024-03-31 21:07:24 +02:00
Tristan B. Velloza Kildaire 5c7a22e772 Pipelines
- Added test for `a.t` (multi-module) test
2024-03-31 21:04:50 +02:00
Tristan B. Velloza Kildaire 86e16b4044 Parsing (unittests)
- Added a test which tests out the multi-module support by testing `a.t`/`b.t` and `niks/c.t` in a unittest itself
2024-03-31 20:57:41 +02:00
Tristan B. Velloza Kildaire 4ae8f0ff73 Parser
- Refactored importing code into `doImport(string)`
2024-03-31 20:42:07 +02:00
Tristan B. Velloza Kildaire b6f15b3953 Resolution
- Neatened up
- Removed check for `statement !is null` from `resolveWithin(..., ...)` because that should honestly never be the case. In the case it ever is stuff would still work, but it won't
- Formatted code
- Added docs
2024-03-31 20:36:52 +02:00
Tristan B. Velloza Kildaire 0ba8ec9dbe Parser
- Cleaned up imports
- Removed unused global `curModule`
- Cleaned up in general
2024-03-31 20:34:13 +02:00
Tristan B. Velloza Kildaire a603db0b2b Small docs
- Added code insertion
2024-03-31 20:10:42 +02:00
Tristan B. Velloza Kildaire 0f3dfcd545 Small docs
- Added code excerpt
2024-03-31 19:38:42 +02:00
Tristan B. Velloza Kildaire e53beee326 Small docs
- Finioshed resolver docs
2024-03-31 19:27:56 +02:00
Tristan B. Velloza Kildaire 2e4cccaf4d Small docs
- Updated
2024-03-31 19:15:20 +02:00
Tristan B. Velloza Kildaire eb19e4baf6 Smal docs
- Updated
2024-03-29 21:57:44 +02:00
Tristan B. Velloza Kildaire 1a05ab3dee Small docs
- Fixed run onlines
2024-03-29 21:51:15 +02:00
Tristan B. Velloza Kildaire 3ab39c737f Samll docs
- netaened up
2024-03-29 21:47:19 +02:00
Tristan B. Velloza Kildaire e0af3fc2a3 Small docs
- Added examples
2024-03-29 21:16:48 +02:00
Tristan B. Velloza Kildaire 54278bda4f Small doc
- Added more information
2024-03-29 21:01:42 +02:00
Tristan B. Velloza Kildaire 3a8499ea18 Small docsd
- Updated
2024-03-29 16:59:41 +02:00
Tristan B. Velloza Kildaire dc703f6d57 Resolver
- Fixed the typos in some documentation
- `generateNameBest(Entity entity)` now relies on `generateName(Container, Entity)`'s special handling of `Program`'s in order to achieve its goal.
- Cleaned up `generateName(Container, Entity)`
- `generateName_Internal(...)` is now `generateName0(...)`
2024-03-29 16:59:19 +02:00
Tristan B. Velloza Kildaire 170cb515fd Small docs
- TYpo fix
2024-03-29 14:07:17 +02:00
Tristan B. Velloza Kildaire 68710665f4 Small docs
- updated
2024-03-29 14:06:49 +02:00
Tristan B. Velloza Kildaire 89def29b4e Small doc
- Added more documentation on the `Resolver`
2024-03-29 13:47:12 +02:00