- Documented the class and some new and existing
- Implemented a version of `resolveWithin(...)` which now takes in a `Predicate!(Entity)` instead of a name and then uses that as the final matching step when iterating over the given `Container`'s `Statement[]` (the container's immediate body)
- Implemented `derive_nameMatch(string name)` which returns a `Predicate!(Entity)` closure which matches based on names
- Updated `resolveWithin(Container, string)` to make use of these above two changes
- A similar change including the above rework and predicate derivation has been done for `resolveUp(...)`, of which there is now a version available as `resolveUp(Container, Predicate!(Entity))`
- Stub version of `resolveBest(Container c, Predicate!(Entity) d)` added but not implemented yet
- Added some unsued types and methods, `SearchCtx` and `findFrom!(...)(...)` respectively
- Added `derive_functionAccMod(AccessorType)` (this is to be moved into `DGen` as that is where it is needed)
- When we find an entrypoint use `a` mode when opening the file for it, `w` mode would wipe the previously written C source code
- Also added a note regarding this branch (if-else) above
- Updated error message when no entry point (and not a test file) is found
- Fixed `emitStaticAllocations(File modOut, Module mod)` to select the static init queue using the provided `Module`
- Fixed `emitFunctionPrototypes(File modOut, Module mod)` and `emitFunctionDefinitions(File modOut, Module mod)` to use the inheritted `CodeEmitter` methods correctly by passing in a `Module`, similar changes affecting the `TypeChecker` are now conformed to in s similar manner
- Fixed `emitFunctionPrototype(File modOut, Module mod, string functionName)` and `emitFunctionDefinition(File modOut, Module mod, string functionName)` to select the function definition queue of the given `functionName` by the given `Module`
- Fixed `emitCodeQueue(File modOut, Module mod)` to select the globals queue by `Module`
- Added some comments about future features to `emitEntrypoint(File modOut, Module mod)`
- Selecting a queue now requires an owner `Module` and it will also, when the `QueueType` is set to `FUNCTION_DEF_QUEUE`, copy over the correct `Instruction[][string]` and then, furthermore, select the correct `Instruction[]` out of it and set that as the current code queue
- Updated `getFunctionDefinitionsCount(Module owner)` and `getFunctionDefinitionNames(Module owner)` to select the correct `Instruction[][string]` when called
- We now get all of the top-level `DNode` (dependency nodes) and then from there onwards we `performLinearization()` -> `getLinearizedNoes()` -> `doTypeCheck(DNode[])`, at each stage collecting the global code queue, the function definitions (each of their code queues) and the static init queues. These are then collected ina `ModuleQueue` for the respective `Module` being processed
- Added methods `getModQueueFor(Module owner)`, `scratchToModQueue(Module owner)`, `funcScratchToModQueue(Module owner, FunctionData fd)` and `initsScratchToModQueue(Module owner)`
- Updated the following methods to make use of the `ModuleQueue`(s) available by selecting by an owner `Module`: `getGlobalCodeQueue(Module owner)`, `getFunctionBodyCodeQueues(Module owner)` and `getInitQueue(Module owner)`
ModuleQueue
- Added new type
- Added `Module`-based ownership model
- Implemented methods `setOwner(Module mod)` and `getOwner()`
- Implemented method `getName()`
DNodeGenerator
- When processing a function definition (a `Function`) we now will call `addFunctionDef` with the owner of this `Function`, this is done by making use of the `Module root` which is set in such a case (and others) when entering the `generalPass(Module, Context)` method
- Removed `deprecated_getModule()`
- Removed old `modulle` field
- Cleaned up field definition section
- Removed old usages of `modulle` and now rooting at the now-new topmost `Container`; the `Program`
* IPoolManager
- Added new interface
* Pool
- Added missing imports
* IPoolManager
- Moved to the `interfaces` module
* IPoolManager
- Updated API to take in a `DNodeGenerator` as the first argument to `pool(..., ...)`
* Revert "IPoolManager"
This reverts commit 4f92a29da2.
* PoolManager
- Added an implementation of the `IPoolManager` interface
* DNodeGenerator
- Now constructs a new `IPoolManager` on constructions
* IPoolManager
- Added a templatised variant of the `pool(Statement)` method
* PoolManager
- Added a templatised variant of the `pool(Statement)` method
- The `pool(Statement)` method now uses the `poolT!(DNodeType, EntityType)(EntityType)` method
* IPoolManager
- Removed the templatised `poolT!(DNodeType, EntityType)(EntityType)` method
- Added `poolExpression(Expression expression)`
- Added `poolVariable(Variable variable)`
- Added `poolStaticVariable(Variable variable)`
- Added `poolFuncDec(Function func)`
* IPoolManager
- Removed uneeded import
* PoolManager
- Removed the templatised `poolT!(DNodeType, EntityType)(EntityType)` method
- Implemented `poolExpression(Expression expression)`
- Implemented `poolVariable(Variable variable)`
- Implemented `poolStaticVariable(Variable variable)`
- Implemented `poolFuncDec(Function func)`
* ExpressionDNode
- No longer takes in a `DNodeGenerator`
AccessDNode
- No longer takes in a `DNodeGenerator`
- Save the incoming `Entity`
- Updated `initName()` to use the `toString()` of the `Entity`
ClassVirtualInit
- No longer takes in a `DNodeGenerator`
- Save the incoming `Clazz`
- Updated `initName()` to use the `toString()` of the `Clazz`
ClassStaticNode
- No longer takes in a `DNodeGenerator`
- Save the incoming `Clazz`
- Updated `initName()` to use the `toString()` of the `Clazz`
ObjectInitializationNode
- No longer takes in a `DNodeGenerator`
VariableNode
- No longer takes in a `DNodeGenerator`
- Updated `initName()` to use the `toString()` of the `Variable`
FuncDecNode
- No longer takes in a `DNodeGenerator`
- Updated `initName()` to use the `toString()` of the `Function`
ModuleVariableDeclaration
- No longer takes in a `DNodeGenerator`
- Updated `initName()` to use the `toString()` of the `Variable`
StaticVariableDeclaration
- No longer takes in a `DNodeGenerator`
- Updated `initName()` to use the `toString()` of the `Variable`
VariableAssignmentNode
- No longer takes in a `DNodeGenerator`
- Updated `initName()` to use the `toString()` of the `VariableAssignment`
* PoolManager
- No longer takes in a `DNodeGenerator` for its constructor
- We no longer require it
- No longer pass a `DNodeGenerator` to the `DNodeType(...)`s created in `poolT!(...)(...)`
PoolManager (unittests)
- Updated unittests
* Depencency (module)
- The `addFunctionDef(...)` method now takes in an extra first argument which is the `IPoolManager` it
should use when it constructs its `DFunctionInnerGenerator`
DNode
- Removed the `DNodeGenerator` instance (i.e. the `dnodegen` field)
- Removed the `Resolver` instance (i.e. the `resolver` field)
- Calling `pool(Statement entity)` will now forward that call to the `IPoolManager`'s `pool(Statement)`
- Calling `DNodeType poolT(DNodeType, EntityType)(EntityType entity)` will now forward that call to the `IPoolManager`'s `pool(Statement)` with the correct types decided at compile-time using static if's
- `objectInitialize(Clazz clazz, NewExpression newExpression)` now constructs a `ObjectInitializationNode` with
its new API
- `pool_module_vardec(Variable entity)` now constructs a `ModuleVariableDeclaration` with its new API
- When `generalStatement(Container c, Context context, Statement entity)` comes across a function definition
(i.e. a `Function`) and has to add its function definition it now uses the updated `addFunctionDef(...)`
- `poolClassStatic(Clazz clazz)` now constructs a `ClassStaticNode` with its new API
DFunctionInnerGenerator
- Constructor now accepts an `IPoolManager` instance
DNodeGenerator
- Constructor now accepts an `IPoolManager` instance
- We now use the `IPoolManager` as our pooling mechanism
* TypeChecker
- When we call `dependencyCheck()` we now first construct the pooling mechanism we want to use
by constructing some kind-of `IPoolManager`, we then pass this to the constructor for the
`DNodeGenerator`
* IPoolManager
- Added `poolModuleVariableDeclaration(Variable variable)`
* PoolManager
- Impemented `poolModuleVariableDeclaration(Variable variable)`
* DNodeGenerator
- `pool_module_vardec(Variable entity)` now calls `poolModuleVariableDeclaration(Variable)` from `IPoolManager`
- Removed the static `nodePool`
* IPoolManager
- Added some stuff
* IPoolManager
- Nah, removed that
* IPoolManager
- Added `poolClassStatic(Clazz clazz)`
* PoolManager
- Implemented `poolClassStatic(Clazz clazz)`
* DNodeGenerator
- Calling `poolClassStatic(Clazz clazz)` now calls `IPoolManager`'s `poolClassStatic(Clazz)`
* IPoolManager
- Documented module
* PoolManager
- Documented module
* Merge branch 'vardec_varass_dependency' into feature/poolmngr
- Use `else` rather than hard coding all test cases. This will only be used if no main module is found AND testing is enabled - so it should be a safe bet
* IFuncDefStore
- Added new interface
* FuncDefStore
- Implemented new `IFuncDefStore` type
* FuncDefStore
- The constructor now takes in a `TypeChecker` instance
- Implemented `addFunctionDef(Function func)`
* FuncDefStore
- Added a TODO + some code for a future naming setup I want to se
* IPoolManager
- Added documentation
- Added new method `grabFunctionDef(string name)` to the API
* FuncDefStoreException
- Added new exception type
* IPoolManager
- Added more docs for `grabFunctionDef(string name)`
* FuncDefStore
- Pass in ourselves (a `IFuncDefStore`) into the `DFunctionInnerGenerator` when adding a function definition
- Implemented `grabFunctionDef(string name)` from the updated `IFuncDefStore` API
* DNodeGenerator
- Constructor now takes in a `IFuncDefStore`
- When we encounter a `Function` we will add it to the store of function definitions
by using the new `IFuncDefStore` (instead of the old `addFunctionDef(TypeChecker, Function)`
- Removed unused method `saveFunctionDefinitionNode(DNode funcDefNode)`
- Removed unused method `retrieveFunctionDefinitionNode(string functionAbsolutePath)`
- Removed the old method `addFunctionDef(TypeChecker tc, Function func)` (as we are now using the `IFuncDefStore`)
- Removed the `clearFuncDefs()` as we are now using the `IFuncDefStore`
- Removed the `grabFunctionDefs()` as we are now using the `IFuncDefStore`
- Removed the `FunctionData[string]` as we are now using the `IFuncDefStore`
DFunctionInnerGenerator
- Constructor now takes in a `IFuncDefStore`
* TypeChecker
- `dependencyCheck()` no lomger calls the removed `clearFuncDefs()` from the `dependency.core` module
- `dependencyCheck()` now constructs a new `IFuncDefStore` and then passes it into the `DNodeGenerator`
when dependency generation needs to occur
* IFuncDefStore
- Added module-level documentation
* FuncDefStore
- Documented class
- Documented module
* FuncDefStoreException
- Documented constructor and class
* IFuncDefStore
- `addFunctionDef(Function func)` may now throw a `FuncDefStoreException` when you add a function that already exists
* FuncDefStore
- `addFunctionDef(Function func)` now throws a `FuncDefStoreException` when you provide a `Function` that has already been added
* IFuncDefStore
- Moved import to the top
* FuncDefStore
- Cleaned up
- Fixed up calls to `getBuiltInType(...)` which now require some `Container` to pivot on. We now pass in the `Program`
- Fixed up unittests which used `getModule()`, for such uni-modular tests we just use `program.getModules()[0]` now
- When getting the type root everything on the `Program` rather than `tc.getModule()`. We therefore now use the `tc.getProgram()` in its place. This updates the `sizeOf_Literalize(string typeName)` method.
DGen
- `emit()` has been updated to enumerate all `Module[]` of the given `Program` and then calls the respecitve `emit(...)` methods with a (`File`, `Module`) which contains the file which emitting should be written to and also the `Module` being emitted.
- At the end of `emit()` we then try to find the `Module` which contains a function named `main` and then set that as the entrypoint. If such a `main` function cannot be found we then go and do a check whether or not the `dgen:emit_entrypoint_test` configuration option is `true`, if so we then try emit a testing entrypoint and assume that the tst uses only one `Module` (this is something to be cleaned up later; as in all tests should have a `main` method).
- Implemented `findEntrypoint(ref Module mainModule, ref Function mainFunc)` which does as the name implies and finds the containing `Module` which has a `Function` named `"main"` and if so sets both ref arguments and returns `true`, otherwise they are left unset and `false` is returned
- `emitHeaderComment(...)`, `emitStaticAllocations(...)`, `emitFunctionPrototypes(...)`, `emitFunctionDefinitions(...)`, `emitFunctionPrototype(...)`, `emitFunctionDefinition(...)`, `emitCodeQueue(...)`, `emitStdint(...)`, `emitEntrypoint(...)`, `emitTestingEntrypoint(...)` now takes in `File modOut` and `Module mod`
- Note the above have not YET been updated to select correct code queues, static init. queues and `emitEntrypoint(...)` has not yet been implemented
- Updated `emitTestingEntrypoint(...)` to check using the incoming `Module`'s name
- `finalize()` will now compile all sources files, then it will link all generated object files together; optionally cleaning up all but the final genersted excutable at the end
CollidingNameException
- Fixed up name generation (we now anchor on the `Program`)
- Fixed up how we detect if a module's name is in use. We now will check and ensure it doesn't match ANY of the modules contained within the `Program`
DNode
- Implemented `forceName(string)` to set the `name` field forcefully
- The `generate()` method now calls `generalPass(Module, Context)` on each of the `Program`'s `Module`s. We then get an array of `DNode[]` from them. After this we then create a root `DNode` to represent the program and then we make it `needs(DNode)` each `Module` `DNode` created previously.
DNodeGenerator
- When processing `VariableExpression` in `expressionPass(Expression exp, Context context)`, if we get a `Function` being referred to in the expression, then we now set the `Context`'s `Container` still to the `Module` containing the function's definition, _however_ we use a method from the resolver to ensure it is the correct module (because we are now using a multi-module setup).
- We have always set the **root** `Module` when entering `generalPass(Container c, Context context)` and processing a `Function` but, as with the last change mentioned above, we need to find that containing `Module` correctly. Therefore we use a method from the `Resolver` to do that.
- If called with `ScopeType.LOCAL` then the name will be generated in an absolute sense, however the module name will be stripped from the path
- For example `simple_module.a.b` would become `a.b` and then be mapped to `a_b`
- Fixed wrong variable name in `map(Entity item, ScopeType type)`
HashMapper
- Implemented `map(Entity item, ScopeType type)` for `ScopeType.GLOBAL`
- `ScopeType.LOCAL` is yet to be implemented
- Added some future code for `emit()` which will enumerate all `Module`(s) available in the current `Program` and then do an emit step per-each of them and have those go to the correct `File`(s)
- Added a comment for `finalize()` of which indicates where we should link all generated object files for all the modules. After this we should then link this against each other and generate an executable.
- Added seperate stage to _create_ the `main.o` and then only later link with the intent of making an executable.
- This is BETTER because it means we could treat everything in the same way (nevermind a `main` or library)
- Added `-c` to ONLY compile but do NOT attempt to link and make an executable. If we try this it looks for a `main` symbol to satisfy the `_start` for linux-ld
- Updated the build instructions for being able to statically link against the library
- Playing with a way to build library objects without immediately linking
- I am then also seeing how to link it to an application which `_start_` can find its `main` symbol
* Created brsnch
* Created brsnch (removed placeholder)
* Lexer
- Added tab handling for the presence such as spaces would be in.
- Added unit tests for the new tab processing
- Resolved issues where whitepsace was allowed before and or after the
'.' character
- Renamed isSpliter to isSplitter
- Some Code styling
* Check
- Added two new `SymbolType`s for comments
- `SINGLE_LINE_COMMENT` (for `//`) and `MULTI_LINE_COMMENT` (for `/*`)
* Parser
- Added a bogus `parseComment()` which returns nothing, prints out the comment, consumes the `Token` and returns
- `parseStatement()` now supports `parseComment()` whenever a single-line or multi-line comment is detected
* Parser
- Fixed token consumption code in `parseComment()`
* BasicLexer
- Fixed style mishaps
* ArrLexer
- Implemented dummy lexer
* Parser
- Added some comment related functions (for testing)
- Added `pushComment(Token)`, `hasCommentsOnStack() and `getCommentCount()`
- `parseComment()` now pushes the current comment-based `Token` onto the comment-stack
- Added a comment stack
Unit tests
- Added testing for various examples of comment-type `Token`s
* Lexer
- Replaced the characters with Enumerated type
- Working Comment lexing, single and multiline
- Working escape codes for strings
- Working Signage and Size Encoder indicators
- Removed floatMode in favour of float lexing function
- Added doComment for the comment lexing instead of comment mode
- Added doEscapeCode for escape codes in string
Testing
- Added unit tests for comments
- Added unit tests numerical encoders
- Added unit tests numerical encoders
TODO
- ADD unit tests for all valid escape sequences and some invalid
* Lexer
- Removed stringMode in favour of soString
TODO
- Decide on miltiline strings, currently not supported
* Parser
- Test comments which appear at a non-Module but rather statement lavel
* Parser
- Changed to using `BasicLexer` for comment tests now seeing as it is now implemented therein
* Basic
- Added `roll()` and `shourt()` to mark unittests
* Basic
- `shout()` now adds line number to print out
* Lexer rewrite
- flush
- underscores in numbers
- escape codes
- character escapes
- bug fixes
* Basic
- Fixed `shourt(int)`
* Basic
- Remved crashing (on purpose_ unittest
* Resolved bug where isSplitter evaluated to true every time
* Basic
- Removed `goggaWithLineInfo(...)`
* Basic
- Updated `shout()` to remove rolling
- Removed `roll()`
- Added function and module name as well
* Basic
- Documented `shout()`
* Lexer Done and 100% coverage
* LexerSymbols
- Documented
- Formatted
* Lexer (module)
- Added `LS` alias
- Added `isOperator(char c)`, `isSplitter(char c)`, `isNumericalEncoder_Size(char character)`, `isNumericalEncoder_Signage(char character)` and `isValidEscape_String(char character)`
* BasicLexer
- Documented constructor `hasToken()`, `performLex()`, `doIdentOrPath()`, `doChar()`, `doString()`, `doComment()`, `doEscapeCode()`, `doNumber()`, `doEncoder()`, `doFloat()`, `flush()`, `buildAdvance()`, `improvedAdvance()`, `advanceLine()`, `isOperator(char)`, `isSplitter(char)`, `isValidDotPrecede(char character)`, `isNumericalEncoder(char character)`, `isNumericalEncoder_Size(char character)`, `isNumericalEncoder_Signage(char character)` and `isValidEscape_String(char character)`
- Tried reformatting some of `doChar()`, `doString()`, `flush()`, `buildAdvance()`, `improvedAdvance()`, `advanceLine()`, `isOperator(char)`, `isSplitter(char)`
* Basic
- Removed `LS` alias
Lexer
- Made `LS` alias public
* BasicLexer
- Removed methods `isValidEscape_String(char character)`, `isNumericalEncoder_Signage(char character)`, `isNumericalEncoder_Size(char character)`, `isNumericalEncoder(char character)`, `isSplitter(char c)` and ` isOperator(char c)`
Lexer
- Added method `isNumericalEncoder(char character)`
* BasicLexer
- Documented `isValidDotPrecede(char character)`
* Lexer
- Added method `isValidDotPrecede(char character)`
* BasicLexer
- Removed method `isValidDotPrecede(char character)`
* BasicLexer (unittests)
- Documented the unittests
- Fixed formatting
* BasicLexer
- Typo fixes
* BasicLexer (unittests)
- Only compile-in `shourt(...)` when in unittest build mode
* BasicLexer
- Documented `isForward()` and `isBackward()`
- Made `isBackward()` private
---------
Co-authored-by: GMeyer <21568499@sun.ac.za>
Co-authored-by: GMeyer <gustav.meyer1999@gmail.com>