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: Multi-module support #31

Merged
merged 272 commits into from Apr 8, 2024

Conversation

deavmi
Copy link
Contributor

@deavmi deavmi commented Aug 27, 2023

Please see this.

@deavmi deavmi added enhancement New feature or request help wanted Extra attention is needed labels Aug 27, 2023
@deavmi deavmi self-assigned this Aug 27, 2023
@deavmi deavmi changed the base branch from master to vardec_varass_dependency August 27, 2023 11:31
- `findModulesInDirectory(string directory)` now replaces all the `/` with `.`'s
- Added stub `ModuleManager`
- Added `validate(string searchPath)`
- Added `validate(string[] searchPaths)`
- Added a constructor

ModMan (unitests)

- Added a positive unittest
- Added negative test case example
- Moved to new package
- Added exception class

ModuleManager

- Throw an exception ( a `ModuleManagerError`), if one of the search paths is invalid during construction
- Added a package for easy importing
- Calling `defaultConfig()` will now add an entry of type `ARRAY` with key `modman:path` and the starting value is just an array with a single element being the current working directory
- On construction of a `Compiler` we now construct a `ModuleManager` with the list of paths provided
- Cleaned up imports
- Added another TODO
- Constructor now takes in an instance of `Program` (but by default it is `null`)
- Added a `toString()` for `Program`
- We now create an instance of `Program` on construction
- We pass a `Compiler` to the parser
- Added `getProgram()`

Parser

- Accept an instance of `Compiler`
- Print out some debug information about the program in `parseImport(string)`
- Added `getModMan()` method
- Import `ModuleEntry`

ModMan

- Added `ModuleEntry`
- Added `getModulesInDirectory(string directory, bool recurse = false)` which can resolve all the `ModuleEntry`(s) in a given directory (with optional recursion)
- Added `search(string curModDir, string name, ref ModuleEntry found)` for searching for a module in a given directory (and then all search paths)
- If the compile-time flag of `DBG_MODMAN` is passed then only print debug text
- Added support for recursing down and fixed how it is done in `getModulesInDirectory(string directory, bool recurse = false)`
- Removed old module searching code
- Added a TODO for ACTUAL parsing that is still to be done
- Added `ModuleManager`-based code for doing module lookups

Test cases

- Updated `modules/a.t`
- Store current module globally (not sure if we need to)
- WIP: Work on module header name validation
- Removed `findModulesFromStartingPath(string startingModulePath)`
- Removed `findModulesInDirectory(string directory)`
- Removed `slashToDot(string strIn)`

ModuleManager

- Added `isValidModuleDeclaration(string, string, string)` (still a work-in-progress)
- Added `slashToDot(string strIn)`
- Updated testing files `a.t`, `b.t`, `z.t` and `niks/c.t`
- `defaultConfig()` now adds NOTHING to the default search path (just for now)
- The constructor now takes in an instance of the `Compiler`
- Added new method `entries()` which calls `entries(string[])` with the given search paths from the compiler config entry but also tacks on the current working directory
- Added `entriesWithInitial(string initialModulePath)` which, given a path to a module initially, will extract said module's containing directory and tack that onto the search paths and then call `entries(string[])` with that
- Implemented `entries(string[])` which currently recurses down the given directories discovering all files that end with `.t` and of which have a module header (if not an error is thrown) and then creates a `ModuleEntry` per each mapping their absolute path to their skimmed-off module name
- Added an `expect(SymbolType, Token)` so that we can throw `SyntaxError`'s (with a `null`-parser)
- Added `skimModuleDeclaredName(string, ref string)` which skims the module's header for the module's name, setting it in the `ref`-based parameter if parsed correcttly, else returns `false`
- (WIP) Made `isValidModuleDeclaration(string, string, string)` return `true`
- Now pass in the `Compiler` to the `ModuleManager` constructor
- Added testing code to `parseImport(string)` which tests the new module discovery/mapping mechanism of `ModuleManager`
- It purposefully crashes at the end to prevent it from running the old code
- Added a TODO regarding allowing multiple modules to be specified on the command-line in the future
deavmi added 28 commits April 1, 2024 13:51
- 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
- Cleaned up the configuration code which initially creates the `ConfigEntry` for `modman:path`
- Yebop
- Added documentation to `getModMan()`
- 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
- Fixed bug in `validate(string searchPath)` which would not check if a path existed
- Removed now-completed TODO
- Removed unused method `doImport(string moduleName)`
- 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
- Updated to show use of extern variables
- Removed old commented-out code from `emitExterns(File modOut, Module mod)`
- Fixed missing `sourceFile` argument to various `Compiler` constructors
- Fixed the module obtaining in one of the tests
- Documented
- Removed old mapper
- Removed old mapper
- Removed old definition
- Renamed
- Moved from `api.d` to `core.d`
- Documented
- Cleaned up
- When generating symbols for `Variable`, if it IS `isExternal()` then do not symbol map, else symbol map
- When generating `extern ...` statements for a given `Module` only tack on the `extern` to the emit if it is NOT `isExternal()` (if it is not a TLang externed variable/function). This is because those would already have them via the call to the signature generation function. This updates the `emitxterns(Module, File)` method.
- When generating signatures for `Variable`(s) ensure that ones which have `isExternal()` return `true` have `extern ...` added to the front og the generated signature. This updates the `generateSignature_Variable(Variable var)` method.
- Removed now-completed TODO
- Removed random ass note
- Documented

HashMapper

- Removed `.dup` which is no longer needed
- Cleaned up
- Documented
@deavmi
Copy link
Contributor Author

deavmi commented Apr 7, 2024

Ready to merge ✔️

@deavmi deavmi merged commit ef78a15 into vardec_varass_dependency Apr 8, 2024
12 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 help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant