Commit Graph

821 Commits

Author SHA1 Message Date
Tristan B. Velloza Kildaire 74227fe560 BinOpInstr, UnaryOpInstr
- Fixed bug whereby the operator was not being stored on object construction

BinOpInstr, LiteralValue, VariableAssignmentInstr

- Added stub `emit()`
2022-12-12 11:13:38 +02:00
Tristan B. Velloza Kildaire d8e5f108e4 Mapper
- Added new SymbolMapper class with a static method which will take a Container and an entity name, resolve the Entity and then generate the hash of the absolute path to said entity and return this as the `symbol name`

TypeChecker

- Set the static field to refer to this instance of the TypeChecker (in the SymbolMapper class)

VariableDeclaration

- Use the `symbolLookup()` method to transform the name
2022-12-12 10:58:58 +02:00
Tristan B. Velloza Kildaire 6a64ed40c9 CodeEmitter
- Added `finalize()` method, this is to be called whenever the emitting is done and a compiler is to be called on the code

DGen

- Implemented a gcc-based finalization method
- Added `emitEntryPoint()` to emit a main() function which is to be called in libc's `_start` symbol

VariableDeclaration

- Added note we may need a symbol table lookup system actually, rather than just a simple `symbolRename`

Compiler

- Call the `finalize()` method on the DGen code emitter

----

Test cases

- Added `simple_variables_only_decs.t` to test code generation
2022-12-11 21:41:15 +02:00
Tristan B. Velloza Kildaire be95288855 Utils
- Added a method which will replace the `.`s in a symbol with underscores

Instruction

- The symbol names need to be valid in C so let's just make it a rule they will only have _'s (underscores) to replace any characters like `.`s
2022-12-11 21:14:31 +02:00
Tristan B. Velloza Kildaire 585405d9e9 DGen
- Made `emitHeaderComment()` correctly emit the optional `headerPhrase` with the correct structure (using *-prefixed comments)
2022-12-11 21:00:48 +02:00
Tristan B. Velloza Kildaire 272bfee124 VariableDeclaration
- Added docstring
- Cleaned up and refactored out into two separate statements (for variable name generation)
2022-12-11 19:36:31 +02:00
Tristan B. Velloza Kildaire 41e8db9a24 VariableDeclaration
- Prevent updating of the fields `varName`, `length` and `varType` after construction of the object
2022-12-11 19:10:29 +02:00
Tristan B. Velloza Kildaire 57a9e86d5f TypeChecker
- Pass in the type of the variable being declared to the `VariableDeclaration` instruction

VariableDeclaration

- Emitted code now contains the type of the variable being declared
2022-12-11 18:46:05 +02:00
Tristan B. Velloza Kildaire c39bc20d1c VariableDeclaration (WIP)
- Added `emit()` method to fetch name for now and emit a string
2022-12-11 18:40:12 +02:00
Tristan B. Velloza Kildaire 42fac8020a Context
- Added static field for a TypeChecker instance

TypeChecker

- Set the static field of `Context` class to hold a reference to the TypeChecker instance
2022-12-11 18:18:50 +02:00
Tristan B. Velloza Kildaire d19edef8f4 DGen
- Emit code by calling `emit()` on each Instruction object
2022-12-11 18:13:10 +02:00
Tristan B. Velloza Kildaire 1e2ef795d6 Instruction
- Added `emit()` method to base Instruction class
- Fixed typo in name of `StorageDeclaration` class
- WIP: `VariableDeclaration` emit()
2022-12-11 18:12:46 +02:00
Tristan B. Velloza Kildaire 5a22b184b7 DGen
- Don't write a blank line at the top of the header comment (see `emitHeaderComment()`)
2022-12-11 18:09:56 +02:00
Tristan B. Velloza Kildaire 15617e7ced DGen
- Added note to `emitCodeQueue()` that instructions will need recursive `emit()` methods
2022-12-11 18:08:52 +02:00
Tristan B. Velloza Kildaire f4797b79e2 DGenregs
- This file has been removed

DGen

- Removed unused import for `dgenregs.d`
2022-12-11 18:06:10 +02:00
Tristan B. Velloza Kildaire b8c99329aa DGen
- Added trailing newline to the comment emitted by `emitHeaderComment()`
2022-12-11 18:04:53 +02:00
Tristan B. Velloza Kildaire c91d72d0b9 DGen
- Added some NOTEs for potential TODOs
2022-12-11 18:01:54 +02:00
Tristan B. Velloza Kildaire e6b1de47f1 DGen
- Added docstring to `emitHeaderComment()`
2022-12-11 17:58:33 +02:00
Tristan B. Velloza Kildaire fe7390caa0 DGen
- The module name of the source file is now correctly added to the header comment (see `emitHeaderComment()`)
2022-12-11 17:57:16 +02:00
Tristan B. Velloza Kildaire 1f3bdd3279 DGen
- Added support for an additional string comment to be added to the emitted header comment via the `emitHeaderComment()` method
2022-12-11 17:55:18 +02:00
Tristan B. Velloza Kildaire c37b85b781 DGen
- Emit a header comment to the output C file containing information about the generated code (source file and destination file)
2022-12-11 17:52:36 +02:00
Tristan B. Velloza Kildaire b43e8de0ef Compiler
- Make output file `tlangout.c`
2022-12-11 17:43:24 +02:00
Tristan B. Velloza Kildaire 566a916a5a DCodeEmitter
- Removed old code generation code - starting anew
2022-12-11 17:38:58 +02:00
Tristan B. Velloza Kildaire 99224cbb80 Type checker
- Added `getInitQueue()`
- Removed the `beginEmit(initQueue, codeQueue)` method (as this is done for us in compiler.d

CodeEmitter

- Extract init queue as well
2022-12-11 17:37:27 +02:00
Tristan B. Velloza Kildaire 6253281f6f Typechecking
- Cleaned up imports
- Added TODOs and a stub `beginEmit(InitQueue, CodeQueue)` method to be used for the beginning of the code emit process
2022-12-11 17:33:18 +02:00
Tristan B. Velloza Kildaire 466b722bcc Removed junk file 2022-11-26 16:31:46 +02:00
Tristan B. Velloza Kildaire ff20c28458 Added debug statements at each stage of DNode processing in the `doTypeCheck(DNode[])` method along with seperators for the final stage's InitQueue and CodeQueue print out 2022-11-26 16:31:33 +02:00
Tristan B. Velloza Kildaire b58c23bd9c Fixed typo 2022-11-26 16:28:27 +02:00
Tristan B. Velloza Kildaire ff51b2ded0 Cleaned up the `doTypeCheck(DNode[])` method 2022-11-26 16:26:51 +02:00
Tristan B. Velloza Kildaire 13a0a5057f Removed unused commented block of code 2022-11-26 16:25:23 +02:00
Tristan B. Velloza Kildaire af9cd544fe Update .gitignore 2022-11-26 16:20:29 +02:00
Tristan B. Velloza Kildaire 9151a46888 Cleaned up 2022-10-15 23:46:10 +02:00
Tristan B. Velloza Kildaire a122b674e2 Cleaned up ClassStaticNode handling code in the type checker. 2022-10-15 23:43:02 +02:00
Tristan B. Velloza Kildaire cac86d604e Added method documentation 2022-10-15 22:03:50 +02:00
Tristan B. Velloza Kildaire b09a247413 Removed unused SList 2022-10-15 22:01:41 +02:00
Tristan B. Velloza Kildaire 268f4bb48f Added `printInitQueue()` method to print all elements in the initialization queue
Print both the initialixation queue (and then) and the code queue at the end of typechecking the linearized list
2022-10-15 21:57:03 +02:00
Tristan B. Velloza Kildaire ae789c9114 Increased complexity of test case 2022-10-15 21:00:59 +02:00
Tristan B. Velloza Kildaire 0c94ece070 Initialization queue
This is a queue where all things such as:

- Class static initializations
- Module initializations (maybe)
- Struct static initializations

will go.

Added `addInit()` along `SList initQueue` to support such a queue.

- Whenever a ClassStaticNode is come across it is added to this queue (at the back - so as to maintain allocation order, not that allocation would matter - only initialization (which is already working))
2022-10-15 20:36:18 +02:00
Tristan B. Velloza Kildaire 47d1974f93 Just create a ClassStaticInitAllocate instruction but don't do anything with it 2022-10-15 20:25:38 +02:00
Tristan B. Velloza Kildaire 1b7cf42aa5 Disabled ClassStaticAllocate processing code in typechecker for now
Updated test case
2022-10-15 20:24:23 +02:00
Tristan B. Velloza Kildaire c9dcf58911 Updated test case to double check that complex examples would be correctly processed 2022-10-15 17:18:27 +02:00
Tristan B. Velloza Kildaire 31c52c0beb Potential fix for variable declarations and assignments (to them)
- The VarAssDNode processor on typechecker now adds to the back orf the code queue
- We removed all weird swapping code in typechecker
- Dependency wise, a variable declaration is depended-UPON its variable assignment which in turn a module depends ON.
- In the case of no assignments we simpyl make the module depend on the variable declaration dnode directly
- Added new test case to show this all
2022-10-15 17:15:03 +02:00
Tristan B. Velloza Kildaire cbe40e7184 Formatted code 2022-10-15 16:55:10 +02:00
Tristan B. Velloza Kildaire 2d9cf1f333 Added gitignore 2022-10-15 16:53:39 +02:00
Tristan B. Velloza Kildaire f4311b8e67 Added note for something to work on 2022-10-15 16:48:57 +02:00
Tristan B. Velloza Kildaire cd02bc2b66 Updated toString() for ClassStaticNode 2022-10-15 13:28:30 +02:00
Tristan B. Velloza Kildaire 3c65af06a0 Added note 2022-10-14 21:16:33 +02:00
Tristan B. Velloza Kildaire 3536e39f6f Found why we are crashing (dependency generation is ordered right but we need to maybe make different objects or add checks of a different sort) 2022-10-14 20:44:33 +02:00
Tristan B. Velloza Kildaire b30b6e0fe0 Disabled generation of unused Context object 2022-10-14 20:13:10 +02:00
Tristan B. Velloza Kildaire 2f586a10cd Updated test case 2022-10-14 20:12:33 +02:00