Commit Graph

886 Commits (master)

Author SHA1 Message Date
Tristan B. V. Kildaire ec7d8cf424 Instruction
- Added a new instruction, `ForLoop`, which contains a pre-run Instruction and a `Branch` instruction, coupled with some flags

DGen

- Added a TODO for WhileLoops (we need to implement do-while loops)
- Implemented C code emitting in `emit()` for `ForLoop` instruction

Check

- Added missing back-mapping for `SymbolType.SMALLER_THAN`

Data

- Added new parser node type `ForLoop`

Parser

- Fixed typo in `parseWhile()`
- Implemented `parseDoWhile()` for do-while loops
- Implemented `parseFor()` for for-loops
- Implemented `parseStatement()` for singular statement parsing
- `parseStatement()` can now have the terminating symbol specified, defaults to `SymbolType.SEMICOLON`
- `parseName()` and `parseAssignment()` now also accept a terminating symbol parameter as per `parseStatement()`'s behavior
- `parseBody()` now makes multiple calls to `parseStatement()` for singular Statement parsing (dead code below still to be removed)
- Removed commented-out unittests
- Unittests that read from files now have the file source code embedded
- Added unit test for while loops, for-loops (unfinished) and some other smaller language constructs (roughly 70% coverage)

TypeChecker (CodeGen)

- Do-while loops will fail if used (for now)
- Added for-loop code generation

Dependency

- Implemented `generalStatement()` for statement processing
- `generalPass()` now makes calls to `generalStatement()`

Tests

- Added `simple_for_loops.t` to test for-loops
- Added `simple_do_while.t` to test do-while loops
1 year ago
Tristan B. V. Kildaire 22c4e8d5a1 Instruction
- Added new instruction `WhileLoopInstruction`

DGen

- Added support for emitting while-loops (so far just plain while loops) (`WhileLoopInstruction` in `emit()`)
- Added baked-in entry point testing code for while loops in `emitEntryPoint()`

Parsing

- Added missing plumbing for while loop parser nodes in `parseWhile()`

Data

- Fixed some typos
- Removed dead/unused "deps" code from `Entity`
- Added some documentation comments
- Added `WhileLoop` type for parser nodes

TypeChecker

- Removed TODO in comment for already-implemented/completed if-statements
- Added while-loop code generation support (only while-loops, no do-whiles)

Dependency

- Added while-loop dependency generation support (so far only while-loops, no do-whiles)

Tests

- Added new test case `simple_while.t` for testing while loops
1 year ago
Tristan B. V. Kildaire d35d651b0d Fixed test case simple1_oop.t 2 years ago
Tristan B. V. Kildaire 4f899c69e2 Lexer
- Fixed missing flushing for issue #65 (see "Flushing fix ")
- Added unit test for flushing fix

VariableDeclaration (Instruction)

- Added support for the embedding of a VariableAssignmentInstr inside (added a getter too) (a part of issue #66)
- Conditional support for if statements: Added two new instructions (IfStatementInstruction and BranchInstruction). See issue #64

DGen

- Added depth increment/decrement on enter/leave scope of `transform()`
- Correct tabbing for nested if-statements using new method `genTabs(ulong)` (which uses the above mechanism). Makes code emitted for if statements (issue #64) look nicer.
- Updated VariableDeclarations (with assignments) handling in `transform()` in the manner similar to BinOpInstr (see issue #66)
- Added a TODO for formatting BinOpInstr's `transform()` a little more aesthetically nicer
- Added code emitting support for if statements (the `IfStatementInstruction` instruction) (see issue #64)
- Updated `emitEntryPoint()` to only emit testing C code for the correct input test file

Parser

- `parseIf()` now returns an instance of IfStatement which couples multiple `Branch` objects consisting of `Statement[]` and `Expression`
- Ensured that each `Statement` of the generated `Statement[]` from `parseBody()` for a given `Branch` is parented to said Branch using `parentToContainer()`
- Ensured each generated `Branch` in `Branch[]` is parented to the generated `IfStatement` using `parentToContainer()`
- `parseBody()` now adds to its `Statement[]` build-up array the generated `IfStatement` from the call to `parseIf()`

Check

- Added support for back-mapping `SymbolType.EQUALS` to `getCharacter(SymbolType)`

Data

- Added `Branch` parser node which is a Container for body statements (`Statement[]`)
- Added `IfStatement` parser node which is a Container of `Statement[]` which are actually `Branch[]`

TypeChecker

- Moved import for `reverse` to top of module
- Implemented `tailPopInstr()` method which will pop from the back of the `codeQueue` "scratchpad"
- Fixes handling of `StaticVariableDeclaration` and `VariableAssignmentNode` (fixes issue #66)
- Added handling for IfStatement entities (if statement support #64)

Resolution

- Added a debug statement to `resolveUp(Container, string)` to print out the container to lookup from and the name being looked up

Dependency

- Added a default `toString()` to the DNode class which prints `[DNode: <entity toString()]`
- Added a TODO and debug print related to issues #9
- Disabled InitScope.STATIC check for now as it caused issues with if statement parsing (probably due to VIRTUAL being default and therefore skipping if statment processing) - issue #69
- Cleaned up handling of Entity type `Variable` (variable declarations) - removed repeated code
- Undid the VarAss->(depends on)->VarDec, reverted back to VarDec->(depends on)->VarAss, fixed by #66 (and closes it and #11)
- Added support for `IfStatement` (if statements) in `generalPass(Container, Context)`

Test cases

- Added new test case testing nested if statements (`nested_conditions.t`)
- Added another test case for if statements, `simple_conditions.t`
2 years ago
Tristan B. V. Kildaire beb068a33c Check
- Added `SymbolType.EQUALS`
- Added check for equality operator
2 years ago
Tristan B. V. Kildaire ed9aa3637c Lexer
- Update column position
2 years ago
Tristan B. V. Kildaire dc607cdcd0 Lexer
- Added support for equality operator `==` (fixes issue #65
2 years ago
Tristan B. V. Kildaire d1b3319a74 Instruction
- Added new instruction type `ReturnInstruction`

Data

- Adjusted return statement parser node weighting to 2 (makes it on the same level as normal body statements)

Dependency

- Added dependency generation for return statements
- Removed old commented-out code in the function-definition generation section of `generalPass()`

TypeChecker/Codegen

- Added code generation for return statements

DGen

- Added code emitting for return statements (`ReturnInstruction`)

Test cases

- Updated test case `simple_functions.t` to test return statements
2 years ago
Tristan B. V. Kildaire 2140747a36 Test cases
- Updated test case `simple_functions.t` to use `k` global via best effort resolution and top-down resolution to test both methods
2 years ago
Tristan B. V. Kildaire 9405c03e10 DGen
- Cleaned up emit() method
- New test case hashes inserted for entryPoint test code

Test cases

- Updated `simple_function_decls.t` to be exactly that, ONLY declarations with basic bodies
- Migrated advanced function usage testing code to a new unit test: `simple_functions.t`
2 years ago
Tristan B. V. Kildaire f8a6fb0962 Merging of function_parameter_fix into vardec_varass codebase
DGen

- Updated function parameter symbol lookup to use new `symbolLookup9Entity)` mechanism

Test cases

- Updated test case `simple_function_decls.t` to use arguments referencing for tests
2 years ago
Tristan B. V. Kildaire ddea68a73d Dependency
- Bug fix (#57) - Undid hack (of #46) for Context setting of VariableStdAloneAssignments
- Bug fix (#54) in VariableExpression whereby global lookups failed because they used `resolveWithin()` and not `resolveBest()`

Resolution

- Implemented `generateNameBest(Entity)` which can generate the full absolute path of the given Entity
- Added debug statements to `isDescendant(Container, Entity)`
- Added a TODO for when isDescendant fails, the asserts should be removed and placed there

Mapper

- The `symbolLookup()` method now takes in only the Entity and provides a hash (by making use of `generateNameBest()`)

DGen

- Switched to using the new `symbolLookup(Entity)` in `transform()` wherever it was being used

Test cases

- Updated test case `simple_function_decls.t` to use a global variable reference in a VariableExpression to test the fix for #54
2 years ago
Tristan B. V. Kildaire 2a12c310a6 Instruction
- Make the name of the function const and public for FuncCallInstr

CodeEmitter

- Added methods `getCursor()`, `getSelectedQueueLength()` and `getQueueLength()`
- Removed old queue-specific methods

DGen

- Added emitting for FuncCallInstr instruction (function call support)
- Now emit globals first BEFORE function definitions
- Added debug prints per instruction to know what instruction is currently being transform()'d
- After emitting sections add newlines between each to make for neater C code
- `emitEntryPoint()` now adds a test for `simple_function_decls.t` (This should be removed soon)
- Removed incorrect TODO in `finalize()`

Dependency

- Make the `nodePool` static, to ensure pooling carries over across multiple `DNodeGenerator` instances
- Fixed handling of function calls in `expressionPass()` - do NOT add a so-called `FunctionDefNode` (remember functions are defined by `addFuncDef()`)
- Set the Context of standalone variable assignments to the Context of the Variable entity representing the variable being assigned to

TypeChecker

- Assign the Context object stored in the `FunctionCall` statement to the `FuncCallInstr`

Test cases

- Updated test case `simple_function_decls.t`
2 years ago
Tristan B. V. Kildaire 8a481fb0ac App
- Added newline to release info print
- Fixed module docstring

Commands

- Added new command-line options: `syntaxcheck`, `typecheck`
- Added todo to `help` command
- Re-ordered commands for order of appearance in help text

Compiler

- Added docstring to `beginCompilation(string[])` function

Mapper

- Added debug print of the Container being used for the symbol lookup

CodeEmitter

- Re-worked CodeEmitter class to use a single so-called "selected queue"
- Added methods to move back and forth between said "selected queue", get the length, etc.
- Remove old queue-specific methods

DGen

- Use the new CodeEmitter "selected-queue" functionality
- Emit function definitions now supported

Exceptions

- Added this keyword

Check

- Added support for SymbolTYpe.OCURLY and SymbolType.CCURLY to `getCharacter(SymbolType)`

Data

- Added a `hasParams()` method to the Function entity type

TypeChecker

- Added support for emitting function definitions (required DNode.poes = [] (cleaning), codeQueue cleaning etc.)
- Added `getInitQueue()` method to make a copy of the current "scratchpad" `codeQueue`
- Build up a copy of the global queue now (make a copy similiar to what we did for `getInitQueue()` but inline)
- Added a debug print

Dependency

- Added a FIXME note for issue #46
- Added a TODO relating to `static DNode[] poes`

Test cases

- Added test case `simple_function_decls.t` to test function definition code emit
- Updated test case `simple_variables.t` to note that the T code generates invalid C code

README

- Build instructions now generate coverage files (`.lst`s)
- Updated link to documentation
2 years ago
Tristan B. V. Kildaire f17d38b74e Parser
- Added support for return statements
- Fixed up SyntaxError to display informative messages
- `expect(SymbolType, Token)` will now use the new SyntaxError constructor

Data

- Added `ReturnStmt` type for return statement support
2 years ago
Tristan B. V. Kildaire ffa2174172 Test cases
- Added note about compile-time constant violations that this code would generate C-wise to `simple_variables.t`
2 years ago
Tristan B. V. Kildaire 990f0ed1cc DGen
- Implemented code emit for variable expressions (fetching their values)

----

Test cases

- Updated test case `simple_variables.t` to be able to test the newly implemented `FetchValueInstr` code emit
2 years ago
Tristan B. V. Kildaire 3afdd5b05d TypeChecker
- Copy Context across from the `VariableExpression` to the `FetchValueVar` instruction
2 years ago
Tristan B. V. Kildaire 1e6d52c1fe DGen
- Actually implement last commit
2 years ago
Tristan B. V. Kildaire bd725dd2e5 DGen
- If an emit transform is missing then show the type is is missing for with the "Base emit"
2 years ago
Tristan B. V. Kildaire 8abfda42a4 DGen
- Removed some completed TODOs
- Refactored code
2 years ago
Tristan B. V. Kildaire 8978a74a21 Check
- Updated SymbolType mappings

----

Test cases

- Updated test case to test the above (`simple_variables.t`)
2 years ago
Tristan B. V. Kildaire 5364380e7c DGen
- Removed redundant imports

Dependency

- Set the context for the `VariableAssignmentStdAlone` entity
- Removed words that show I have the mental maturity of a 12 year old

----

 Test cases

 - Updated `simple_variables_decls_ass.t`
 - Updated `simples_variables.t`
2 years ago
Tristan B. V. Kildaire 908356c27b VariableAssignmentStdAlone
- Removed duplicate instance of `VariableAssignmentInstr`
- Set the context of the created `VariableAssignmentInstr` to be that of the `VariableAssignmentStdAlone`  entity
2 years ago
Tristan B. V. Kildaire 01bdb145e2 CoreEmitter
- All operations regarding moving through (iterating over) instructions are now to be done via the instructions provided by CodeEmitter, moveback, moveforward etc.

DGen

- Re-worked the system to use new CodeEmitter semantics
- Variable assignments in declarations are oneshot now which makes it more compact, semantically better and also valid C

---

Tests

- Updated the `simple_variables.t` test case to have many binary operations chained
2 years ago
Tristan B. V. Kildaire e64a9ef5d1 DGen
- Added `Variable` type import

CoreEmitter

- Added some testing code which (MAY) be used
2 years ago
Tristan B. V. Kildaire ca92e6f7bf Mapper
- Prefix generated names with `t`
2 years ago
Tristan B. V. Kildaire ee8d73e23b Instruction
- Removed import of (now) non-existent function
2 years ago
Tristan B. V. Kildaire 90a302826b DGen
- Added varAssStack (instance of Stack)
2 years ago
Tristan B. V. Kildaire 997b378cc9 Utils
- Removed `symbolRename(string)` method
2 years ago
Tristan B. V. Kildaire 23b3e67f02 Utils
- Added template-based Stack implementation
2 years ago
Tristan B. V. Kildaire c870208118 DGen
- Use clang for now
2 years ago
Tristan B. V. Kildaire b0d9d2aabe Instruction
- Removed all `emit()` methods (this is now done in the language-specific emitter - DGen)

CoreEmitter

- Added docstrings
- Added required `transform(Instruction)` method which must transform each provided Instruction into a string (a.k.a. do the actual emit()-ting)

DGen

- Migrated C-emit code into the overrided `transform(Instruction)` method
2 years ago
Tristan B. V. Kildaire b2a3b40795 Instruction
- Added note about how we should change our approach to emitting code - it should not be done within the Instructions but rather in DGen somehow
2 years ago
Tristan B. V. Kildaire dfc90451bb Instruction
- Added `getContext()` to Instruction
2 years ago
Tristan B. V. Kildaire b51f38951a VariableAssignmentInstr
- Now emits correct assignment C code
2 years ago
Tristan B. V. Kildaire 50728d02d3 Dependency
- VariableAssignment entity now has its Context object set to the current Context (of the Variable being declared) (so this is a declare assignment case only (so far)) (fixes #36)

TypeChecker

- Extract the Context object from the VariableAssignment entity and then set it as the Context for the VariableAssigmnetInstr instruction (fixes #36)

VariableAssigmnentInstr

- The `emit()` method will now emit the assignment code

Check

- Added `getCharacter(SymbolType)` which maps a SymbolType to a maths operator (WIP)
2 years ago
Tristan B. V. Kildaire 18dbe5508f LiteralValue
- Implemented the correct emit for this instruction (just emits the string version of the ulong `data`

BinOpInstr

- Emit is almost correct, just missing a mapping from SymbolType to the maths operator required
2 years ago
Tristan B. V. Kildaire 74227fe560 BinOpInstr, UnaryOpInstr
- Fixed bug whereby the operator was not being stored on object construction

BinOpInstr, LiteralValue, VariableAssignmentInstr

- Added stub `emit()`
2 years ago
Tristan B. V. 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
2 years ago
Tristan B. V. 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
2 years ago
Tristan B. V. 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
2 years ago
Tristan B. V. Kildaire 585405d9e9 DGen
- Made `emitHeaderComment()` correctly emit the optional `headerPhrase` with the correct structure (using *-prefixed comments)
2 years ago
Tristan B. V. Kildaire 272bfee124 VariableDeclaration
- Added docstring
- Cleaned up and refactored out into two separate statements (for variable name generation)
2 years ago
Tristan B. V. Kildaire 41e8db9a24 VariableDeclaration
- Prevent updating of the fields `varName`, `length` and `varType` after construction of the object
2 years ago
Tristan B. V. 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
2 years ago
Tristan B. V. Kildaire c39bc20d1c VariableDeclaration (WIP)
- Added `emit()` method to fetch name for now and emit a string
2 years ago
Tristan B. V. 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
2 years ago
Tristan B. V. Kildaire d19edef8f4 DGen
- Emit code by calling `emit()` on each Instruction object
2 years ago
Tristan B. V. Kildaire 1e2ef795d6 Instruction
- Added `emit()` method to base Instruction class
- Fixed typo in name of `StorageDeclaration` class
- WIP: `VariableDeclaration` emit()
2 years ago
Tristan B. V. Kildaire 5a22b184b7 DGen
- Don't write a blank line at the top of the header comment (see `emitHeaderComment()`)
2 years ago
Tristan B. V. Kildaire 15617e7ced DGen
- Added note to `emitCodeQueue()` that instructions will need recursive `emit()` methods
2 years ago
Tristan B. V. Kildaire f4797b79e2 DGenregs
- This file has been removed

DGen

- Removed unused import for `dgenregs.d`
2 years ago
Tristan B. V. Kildaire b8c99329aa DGen
- Added trailing newline to the comment emitted by `emitHeaderComment()`
2 years ago
Tristan B. V. Kildaire c91d72d0b9 DGen
- Added some NOTEs for potential TODOs
2 years ago
Tristan B. V. Kildaire e6b1de47f1 DGen
- Added docstring to `emitHeaderComment()`
2 years ago
Tristan B. V. Kildaire fe7390caa0 DGen
- The module name of the source file is now correctly added to the header comment (see `emitHeaderComment()`)
2 years ago
Tristan B. V. Kildaire 1f3bdd3279 DGen
- Added support for an additional string comment to be added to the emitted header comment via the `emitHeaderComment()` method
2 years ago
Tristan B. V. Kildaire c37b85b781 DGen
- Emit a header comment to the output C file containing information about the generated code (source file and destination file)
2 years ago
Tristan B. V. Kildaire b43e8de0ef Compiler
- Make output file `tlangout.c`
2 years ago
Tristan B. V. Kildaire 566a916a5a DCodeEmitter
- Removed old code generation code - starting anew
2 years ago
Tristan B. V. 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
2 years ago
Tristan B. V. 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
2 years ago
Tristan B. V. 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 2 years ago
Tristan B. V. Kildaire b58c23bd9c Fixed typo 2 years ago
Tristan B. V. Kildaire ff51b2ded0 Cleaned up the `doTypeCheck(DNode[])` method 2 years ago
Tristan B. V. Kildaire 13a0a5057f Removed unused commented block of code 2 years ago
Tristan B. V. Kildaire 9151a46888 Cleaned up 2 years ago
Tristan B. V. Kildaire a122b674e2 Cleaned up ClassStaticNode handling code in the type checker. 2 years ago
Tristan B. V. Kildaire cac86d604e Added method documentation 2 years ago
Tristan B. V. Kildaire b09a247413 Removed unused SList 2 years ago
Tristan B. V. 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
2 years ago
Tristan B. V. Kildaire ae789c9114 Increased complexity of test case 2 years ago
Tristan B. V. 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))
2 years ago
Tristan B. V. Kildaire 47d1974f93 Just create a ClassStaticInitAllocate instruction but don't do anything with it 2 years ago
Tristan B. V. Kildaire 1b7cf42aa5 Disabled ClassStaticAllocate processing code in typechecker for now
Updated test case
2 years ago
Tristan B. V. Kildaire c9dcf58911 Updated test case to double check that complex examples would be correctly processed 2 years ago
Tristan B. V. 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
2 years ago
Tristan B. V. Kildaire cbe40e7184 Formatted code 2 years ago
Tristan B. V. Kildaire f4311b8e67 Added note for something to work on 2 years ago
Tristan B. V. Kildaire cd02bc2b66 Updated toString() for ClassStaticNode 2 years ago
Tristan B. V. Kildaire 3c65af06a0 Added note 2 years ago
Tristan B. V. 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) 2 years ago
Tristan B. V. Kildaire b30b6e0fe0 Disabled generation of unused Context object 2 years ago
Tristan B. V. Kildaire 2f586a10cd Updated test case 2 years ago
Tristan B. V. Kildaire 86905da623 Added TODO 2 years ago
Tristan B. V. Kildaire 2031a4645c Context should just be the same one passed in as we are not changing really. 2 years ago
Tristan B. V. Kildaire c85aba1f56 WIP 2 years ago
Tristan B. V. Kildaire e46950778b Fixes:
- The test case was broken -_-
- Full-path traversal now implemented somewhat, along with checks on the container if they require static initialization (such as for Classes)
2 years ago
Tristan B. V. Kildaire 0c104440ae Freeze for now 2 years ago
Tristan B. V. Kildaire 05d00ff58b WIP: Seems wrong the order we get back, might need to take some time to think about how to get about implementing this 2 years ago
Tristan B. V. Kildaire 15d2bf6b68 Dependency generation
Full path evaluation update

If the local segment is a Class-type-of Container then run
a class static allocation on it and make the current dnode
dependent on that ClassStaticAllocation dnode returned from
classStaticAllocate().
2 years ago
Tristan B. V. Kildaire 2d58d5f0d7 WIP: Full path dependency evaluation 2 years ago
Tristan B. V. Kildaire 8a82751a18 Added Gitea issue number #8 for ClassStaticAllocate node 2 years ago
Tristan B. V. Kildaire 4b36623861 Added Gitea issue note 2 years ago
Tristan B. V. Kildaire 96d8f0face WIP: Found a fix for context lookup failure 2 years ago
Tristan B. V. Kildaire e2e356da73 Added FIXME note 2 years ago
Tristan B. V. Kildaire 81f168e154 Removed unused commented-out code 2 years ago
Tristan B. V. Kildaire 69572ff02c Removed unused method (older method before generalPass()) 2 years ago
Tristan B. V. Kildaire a8630b5939 We need to do funciton definition dependency generation ALOGN with normal dependency generation
- Disabled seperate generate() calls to FuncDefs in core.d for typechecking
- Added `saveFunctionDefinitionNode()` and `retrieveFunctionDefinitionNode()` to core.d for dependency
- Added a generalPass() call (and fixed it to skip on things != STATIC for InitScope - temporary fix)
- Added test case to test with
2 years ago
Tristan B. V. Kildaire 60a6f078a3 - Made Function a kind-of Container
- Ensure we set the parentOf all Statement's inside a Function (definition) whilst parsing - to prevent a runtime assertion (I believe, well all fixed now)
2 years ago
Tristan B. V. Kildaire 77708b65be WIP: Linerization (typechecking and code generation) for defined functions 2 years ago
Tristan B. V. Kildaire e810f762bc Added while loop test case 2 years ago
Tristan B. V. Kildaire 5444bd55e8 Added support for comparators to parser 2 years ago
Tristan B. V. Kildaire 200149efdf Cleaned up core.d unittest 2 years ago
Tristan B. V. Kildaire c1efb0c819 Added unit test to test floating point empty string test in lexer 2 years ago
Tristan B. V. Kildaire 3fccf2fa5a Removed debug print 2 years ago
Tristan B. V. Kildaire 806814f01c Fixed bug whereby `isNumericalStr()` returned true for empty strings.
This fixes problems whereby if the current build up was empty and a field accessor was being attempted then lexing would fail.
2 years ago
Tristan B. V. Kildaire 3d54c4deee Removed assertions which are guaranteed to pass now (since the last fix of 449e878796) 2 years ago
Tristan B. V. Kildaire 449e878796 Fixed bug when processing the body of a class and a DNode was hit which was not one of the allowed types:
1. VariableDeclaration

Previously we added back the `varDecInstr` which is post-cast and if the cast failed (hence hitting this !varDecInstr branch) we didn't add back `instr` but rather added back `varDecInstr` which is 0 instead of being non-zero.

This later is incorrect.
2 years ago
Tristan B. V. Kildaire aae5dbabe8 Fixed compilation issue with jcli
Upgraded jcli
2 years ago
Tristan B. V. Kildaire a8f93e5817 Cleaned up comments for number literal code gen and type checking handling 2 years ago
Tristan B. V. Kildaire 7e49cf1d0a Added float support
- Added float constant support to the lexer
- Added float support to the typechecker to build the correct Instruction type

Unit tests

- Added unit test for a bad example of a malformed encoded floating point to test out the lexer
2 years ago
Tristan B. V. Kildaire 2dbe14b490 WIP: Floating pooint literal/constant support 2 years ago
Tristan B. V. Kildaire f49b0ce2b9 Added floating point constants to test 2 years ago
Tristan B. V. Kildaire c561060470 Added float and double types to builtin types
Added floating point test case
2 years ago
Tristan B. V. Kildaire e8ddb62152 Removed Double type
Refactored Float type
2 years ago
Tristan B. V. Kildaire f64c067184 Updated simple_string.t test 2 years ago
Tristan B. V. Kildaire 4488678d3e Code cleanup 2 years ago
Tristan B. V. Kildaire 18411c48c4 Removed TODO 2 years ago
Tristan B. V. Kildaire c8347fefba Updated simple_string.t to include string constants (literals) that test interning to the same pool ID 2 years ago
Tristan B. V. Kildaire d19512668a Pass StringLiteral instruction extracted string literal from StringExpression synmbol
Removed TODO
2 years ago
Tristan B. V. Kildaire e2157f428c Implemented `getStringLiteral()` for StringExpression symbol type 2 years ago
Tristan B. V. Kildaire 7e9e303a1c Implemented StringLiteral Value-kind-of instruction with string interning 2 years ago
Tristan B. V. Kildaire f9a8590604 Array type handling added to builtin-types handling 2 years ago
Tristan B. V. Kildaire e0feaac953 Added new test case 2 years ago
Tristan B. V. Kildaire 6cfca2cea2 Added `addInstr()` for StringExpression handling (String literals)
Bug fixed whenever a "" is encountered
2 years ago
Tristan B. V. Kildaire 415538f54a Added StringLiteral instruction 2 years ago
Tristan B. V. Kildaire ca2fa84057 Added support for Pointer type resolution via `getType()`. Now `char**` -> Pointer("char*"), which before construction of such a Pointer is recursively resolved, so nested Pointer(Pointer(...)) 2 years ago
Tristan B. V. Kildaire 88a48e1b3d FuncDecNode for the Dependecny Tree Generator added 2 years ago
Tristan B. V. Kildaire 35d71a0c25 WIP: FunctionHandle (reference to a funciton's name (NOT a FuncCall)) support (context may not be entirely right) 2 years ago
Tristan B. V. Kildaire f571115c23 Added some possible todos, might not need to do any of them but I also might 2 years ago
Tristan B. V. Kildaire 1322c0f790 BinaryOperatorExpression now has a proper toString() 2 years ago
Tristan B. V. Kildaire 1f8f248219 Added support for the ampersand operator 2 years ago
Tristan B. V. Kildaire 15a848756b Added support for binary/boolean operators in the unary and binary operator cases 2 years ago
Tristan B. V. Kildaire e9a60380b6 Pointer type now only requires you provide it the data type of the data being pointed to.
The name of the type will be automatically constructed as `dataType*` (if `dataType` was the type of the data being pointed to)
2 years ago
Tristan B. V. Kildaire 6412241185 Added a test case to test pointer handles 2 years ago
Tristan B. V. Kildaire 15826a2cab Updated test case to include a variable access 2 years ago
Tristan B. V. Kildaire cc2cdf2c30 Throw a parsing error when attempting to use anything but a +, * or - as a unary operator 2 years ago
Tristan B. V. Kildaire 250d4997e9 Added unit test for simple_function_call 2 years ago
Tristan B. V. Kildaire 2ed6a4834d Cleaned up 2 years ago
Tristan B. V. Kildaire c02a574ffa Updated test case to test new unary operator expression support 2 years ago
Tristan B. V. Kildaire aff0da5116 Added codegen/typecheck support for unary operator expressions 2 years ago
Tristan B. V. Kildaire 1b51d9923e Added support to the dependency tree generator for unary operator expressions 2 years ago
Tristan B. V. Kildaire ef9018db89 Added UnaryOperatorExpression (finished it) 2 years ago
Tristan B. V. Kildaire 1e202fe788 Added Unary Oprator Instruction 2 years ago
Tristan B. V. Kildaire 414d9de902 Updated test case 2 years ago
Tristan B. V. Kildaire cd54753359 cleaned up 2 years ago
Tristan B. V. Kildaire 190f64c0e8 cleaned up 2 years ago
Tristan B. V. Kildaire b5c4ca44ee Updated test case 2 years ago
Tristan B. V. Kildaire d79b9eee5c Debugging things 2 years ago
Tristan B. V. Kildaire 1841ca48d9 Recursively descnend upon function argument expressions 2 years ago
Tristan B. V. Kildaire c28a297064 Added toString() to FunctionCall that includes uniqueness number AND funciton's name 2 years ago
Tristan B. V. Kildaire 1b002382d5 BinaryOperatorExpressions are meant to evaluate to a value, they MUST be ValueInstructions 2 years ago
Tristan B. V. Kildaire ba63f85df9 Binary operator expressions now work 2 years ago
Tristan B. V. Kildaire 6222aabc8b Pop types off for Binary Operator typechecking 2 years ago
Tristan B. V. Kildaire de31585bcc Cleaned up 2 years ago
Tristan B. V. Kildaire 475983dd95 Cleaned up 2 years ago
Tristan B. V. Kildaire da9bc742e5 Constrain FuncCallInstr evaluation (for arguyments) to only being value-deriving instructions 2 years ago
Tristan B. V. Kildaire 492074119d Added sub-instructions to FuncCallInstr being built 2 years ago
Tristan B. V. Kildaire 3cac1b496d Fixed addInfo for FuncCallInstr instruction 2 years ago
Tristan B. V. Kildaire 18eba51144 Remove uneeded reversal code 2 years ago
Tristan B. V. Kildaire 4677cacdf1 I think it works now as the types are in the same order as instructions
So I guess that works
2 years ago
Tristan B. V. Kildaire 76f0d6e1a9 Changed `addType(Type)` to add types to the front of the type queue
Added `addTypeB(Type)` to add Types to the end of the type queue
2 years ago
Tristan B. V. Kildaire 4b53823d9c Added `isTypesEmpty()` 2 years ago
Tristan B. V. Kildaire abe72f45a7 WIP 2 years ago
Tristan B. V. Kildaire a84e0dfe20 Some stuff, working on getting function calls working 2 years ago
Tristan B. V. Kildaire 71efb7ae8f Fixed dependency generation for function call paremeters (expressions) 2 years ago
Tristan B. V. Kildaire aa5e82fe09 Added stub funccallinstr add to sotp segmentation fault on funciton calls being processed 2 years ago
Tristan B. V. Kildaire 5641c7f164 Added the ability to perform ONLY tokenization (lexing) 2 years ago
Tristan B. V. Kildaire b5488d5c92 Stuff 2 years ago
Tristan B. V. Kildaire 49de425e45 Static initialization for classes, including class memory allocation and then static variable (member) initialization has now been implemented for the code generator 3 years ago
Tristan B. V. Kildaire 3a32ecfea5 Or do it like that 3 years ago
Tristan B. V. Kildaire a45d2bc30b Variable's name is full path so resolve from the module 3 years ago
Tristan B. V. Kildaire 263bf5edb7 Bug fixed
Should not be parent of, but rather should be the class itself
3 years ago
Tristan B. V. Kildaire 3da50e9eab Got some sort of class allocator node created, now to re-order it by using Context to be able to know when the StaticVariableDeclaration is within class.
This then generates code to allocate space for the class, once done we can be assured the declarations (placed after it now) will be assigning to properly allocated space (paged and maped for example)
3 years ago
Tristan B. V. Kildaire cae3cfe88c Updated 3 years ago
Tristan B. V. Kildaire c58bf07bb1 WIP: Trying to get literal encoding working (but it is currently broken) 3 years ago
Tristan B. V. Kildaire 6ed33a8051 Done with work for today, good refactoring, now to work on class static initoialization.
Instance initialization and unique-ness, and same for Functions with their "FunctionData" will come later
3 years ago
Tristan B. V. Kildaire cb6fb5f86f Removed unused commented blocks of code 3 years ago
Tristan B. V. Kildaire 020847cb76 Added nested class static initialization to test case 3 years ago
Tristan B. V. Kildaire d74f8cb046 Updated test case 3 years ago
Tristan B. V. Kildaire 47edb41e17 Seems like generalised generalPass() is working 3 years ago
Tristan B. V. Kildaire 3eddf73b7b Added some stuff
FunctionData adding, some generation stuff, but reworking to make a general pass function
3 years ago
Tristan B. V. Kildaire 60f490d8e8 Refactored dependency tree generation code (and all related modules) to its own directory 3 years ago
Tristan B. V. Kildaire fffcc953ab Refactored Context class 3 years ago
Tristan B. V. Kildaire 7dd8f2df75 Updated test case 3 years ago
Tristan B. V. Kildaire f0b0f83c45 Added note to be used later 3 years ago
Tristan B. V. Kildaire c9997c60d0 Made public 3 years ago
Tristan B. V. Kildaire beaad7e7f1 Added the thing 3 years ago
Tristan B. V. Kildaire 6499abb616 Fixed up all other `getStatements()` for other Container types 3 years ago
Tristan B. V. Kildaire b39fea5e10 Fixed `getStatements()` for Module container type to be stable. Not having it so caused bad affects and re-ordering that should have NOT happened 3 years ago
Tristan B. Kildaire 7fe3ea342c Added note on name resolution for correct stack offset mapping 3 years ago
Tristan B. Kildaire de261ec511 Copy Context information from the ParserNode across to the Instruction node (only so far for Module Variable Declaration DNodes' embedded PNode 3 years ago
Tristan B. Kildaire 3b36113a5b Added Context 3 years ago
Tristan B. Kildaire 8a8ddcee3a Added notes on ceogeneration 3 years ago
Tristan B. Kildaire b88943d2ed Fixed `pushVariable()` to ACTUALLY add to the stackOffsetMap 3 years ago
Tristan B. Kildaire bef0bced14 Addes some stub functions for writing of variables to the stack (code to generate it) 3 years ago
Tristan B. Kildaire 6c1dac5f2a On variable declaration maintain a mapping of offsets of variables on the stack 3 years ago
Tristan B. V. Kildaire fb927eeb17 Yesh 3 years ago