Commit Graph

1017 Commits (arrays)
 

Author SHA1 Message Date
Tristan B. V. Kildaire d2ddf3084f
Update d.yml 2 years ago
Tristan B. V. Kildaire 34f937df10
Disable windows build
For now, disable any non-POSIX operating systems
2 years ago
Tristan B. V. Kildaire 40bc4470dc
Update d.yml 2 years ago
Tristan B. V. Kildaire 334eb60b4d
Update d.yml 2 years ago
Tristan B. V. Kildaire 0fa1e39464 Typechecker/Codegen
- Implemented `isStackArray(Value)` which checks if the given `Value` instruction is a `FetchValueVar`, then extracts the `Variable` being referred to in said instruction and checks if its declared type is that of `StackArray`
- Implemented code generation for `ArrayAssignment`
- Implemented code generation for `ArrayIndex`
2 years ago
Tristan B. V. Kildaire d129d55f62 Parser
- Added a branch to `parseName()` which handles array assignments's semicolon consumption and token cursor movement to the next token
- Updated `parseTypedDeclaration()` to return an object of type `Statement` rather than `TypedEntity`
- Disabled the intentional `assert(false)` when handling array assignments
- Assign the generated `ArrayAssignment` to the `generated` variable
- Updated `parseExtern()` to cast to `TypedEntity` to ensure that the `Statement` returned is of that sub-type (added an assertion to then check this fact)
2 years ago
Tristan B. V. Kildaire 947c63e5ea Dependency
- Added dependency node generation for the `ArrayIndex`
- This will pool the `ArrayIndex` parser-node
- This will then set the context of the parser-node to the current context
- The index expression will be depended upon
- The indexed expression (the entity being indexed) will be depended upon

---

- Added dependency generation for `ArrayAssignment`
- The `ArrayAssignment` parser node will be pooled
- The `ArrayAssignment` will have its context set to the current context
- The assigned expression will be depended upon
- The entity being indexed will be depended upon
- The index expression will be depended upon
2 years ago
Tristan B. V. Kildaire 98b3ab4284 DGen
- Removed TODO comment for `ArrayIndexInstruction` transformation branch
- Added a description for when the `ArrayIndexInstruction` branch is activated for a transformation
- Implemented transformation for `ArrayIndexInstruction`
- Added comment on when `ArrayIndexAssignmentInstruction` activates
- Implemented transformation for `ArrayIndexAssignmentInstruction`
- Added comment for when the `StackArrayIndexInstruction` branch activates
- Implemented transformation for `StackArrayIndexInstruction`
- Added comment for when `StackArrayIndexAssignmentInstruction` branch activates
- Implemented transformation for `StackArrayIndexAssignmentInstruction`
2 years ago
Tristan B. V. Kildaire 31d89ddb4e Test cases
- Added `simple_stack_arrays4.t` which just tests assigning to a stack array of a fixed size BUT referring to said stack array itself as part of the assignment expression
2 years ago
Tristan B. V. Kildaire 7700d243b0 Test cases
- Added `simple_stack_arrays2.t` which tests a stack array of a fixed size and then assigns into it a value
2 years ago
Tristan B. V. Kildaire 8a5c6bbcfa Test cases
- Added `simple_arrays4.t` which makes an `int[]` (which is an `int*`) and then assignes into it at `i` whilst referring to itself at `i` and doing a binary operation
2 years ago
Tristan B. V. Kildaire 38af3486a6 Test cases
- Added `complex_stack_arrays1.t`
- This tests a stack array of a fixed size of `int[]` (basically `int*`) and assigneing into it
2 years ago
Tristan B. V. Kildaire a37a7f8416 Instructions
- Added `ArrayIndexAssignmentInstruction` which is intended to be used for when one wants to assign into a pointer-based array
- It embeds a `Value` instruction which is what is to be assigned and then an `ArrayIndexInstruction` representing the base of the poiinter-based array (base address) coupled with an "index" (offset)

- Added a `toString()` override for `StackArrayIndexAssignmentInstruction`
2 years ago
Tristan B. V. Kildaire c4f449dd78 INstructions
- Added `getArrayName()`, `getIndexInstr()` and `getAssignedValue()` to `StackArrayIndexAssignmentInstruction`
2 years ago
Tristan B. V. Kildaire b4f8e80906 DGen
- Added a stub emitter for `ArrayIndexInstruction` (pointer-based array indexing)
- Added a stub emitter for `StackArrayINdexInstruction` (stack-array based array indexing)
2 years ago
Tristan B. V. Kildaire b8612ebbc8 Instructions
- Added implementation for `StackArrayIndexAssignmentInstruction` which represents the assignment of some `Value` instruction to a stack-based array (indicated by the `arrayName` string field) at the index indicated by the provided `Value` instruction
2 years ago
Tristan B. V. Kildaire 270ca64106 Instructions
- Added a new instruction type, `StackArrayINdexInstruction`, which is used to know when we are indexing into a stack-based array rather than a pointer-based array (just to be able to disambiguate between the two)
- Added a work-in-progress type `StackArrayIndexAssignmentInstruction` which will be used for assigning to stack arrays at a given index
2 years ago
Tristan B. V. Kildaire b6a39f3a27 DGen
- Handle `ArrayIndexInstruction` which is for whenever you index into a point-based array (an expression like `myArray[i]` is now being supported in emit (first steps))
2 years ago
Tristan B. V. Kildaire de2e6edfd5
Update README.md 2 years ago
Tristan B. V. Kildaire 3d2ea5a395
Create d.yml 2 years ago
Tristan B. V. Kildaire e78e5daa6b Instruction
- Added new instruction for indexing into arrays, a new `Value`-type instruction called `ArrayIndexInstruction`
2 years ago
Tristan B. V. Kildaire 765815a747 Parser
- Added right-hand side expression parsing for array assignments

Test cases

- Updated test case to test both array expressions on the left-hand side of an assignment and as a free-standing expression on the right hand side

Data

- Implemeneted `ArrayAssignment` which is to be used for assigning into arrays
2 years ago
Tristan B. V. Kildaire 38b938a7b2 Parser
- Removed now-completed TODO relating to array accesses in `parseExpression()`
2 years ago
Tristan B. V. Kildaire 1ffa059be0 Parser
- Added support for array accesses/indexing in `parseExpression()`
- Added a token-rerun mechanism that lets us replay the needed tokens which needed to be looked ahead in order to determine an array access was about to occur
2 years ago
Tristan B. V. Kildaire c2f2843bda Expressions
- Added new parse node (a sub-type of `Expression`) for representing array indexing; `ArrayIndex`

Data

- Fixed compilation error caused by missing semi-colon
2 years ago
Tristan B. V. Kildaire 79086c2ace Merge branch 'vardec_varass_dependency' into arrays 2 years ago
Tristan B. V. Kildaire 3b4142f16b Parser
- Implemented `ulong getCursor()` which returns the parser's token pointer
2 years ago
Tristan B. V. Kildaire ef74f58699 Merge branch 'vardec_varass_dependency' into arrays 2 years ago
Tristan B. V. Kildaire 37225c8484 Parser
- Added a TODO about a possible refactor to make things split out more
- Implemented `setCursor(ulong)` so that we can update the position of the token pointer
2 years ago
Tristan B. V. Kildaire 29f824ad13 Data
- Added new work-in-progress parser node type `ArrayAssignment`

Parser

- Added TODO about the type of returned parse node needing to be updated down the line

Notes

- Updated `wip.txt` with more thoughts
2 years ago
Tristan B. V. Kildaire 0b9371b688 Parser
- Moved logic for array assignments into the branch for it (deferred it)
2 years ago
Tristan B. V. Kildaire 983b480312 Parser
- Handle the case whereby `SymbolType.ASSIGN` or `SymbolType.IDENT_TYPE` is not found by throwing an error
2 years ago
Tristan B. V. Kildaire 47f779e852 Parser
- We can now detect when infact we are doing an array-indexed assignment and when not, we then flip` arrayIndexing` to `true` if that is the case and ensure that `=` SymbolType.ASSIGN is not triggering the varaible-declaration-with-assignment but rather eters a different branch based on this boolean
- Set the identifier being assigned to (in the array indexing case) to the `type` with the `[]...` stripped

Notes

- Added a TODO file `wip.txt` with notes about what is to be done for adding full array support
2 years ago
Tristan B. V. Kildaire 39723a09d7 Parser
- Working on adding array index assignment support

Test cases

- Added test case to test array assignments with
2 years ago
Tristan B. V. Kildaire 37bd0941db Tets cases
- Added new test case for testing (later) multi-dimensional stack-arrays
2 years ago
Tristan B. V. Kildaire 91a953a1df Builtins
- Added `bool isStackArray(string)` in order to check if a given type string is designated as a stack-array type or not
- `Type getBuiltInType(TypeChecker, string)` now can generate the `StackArray` type including the component type and the size of the stack allocation

Parser

- Added support to`parseTypedDeclaration` to be able to parse stack-based array types
- Added terminator `]` to `parseExpression()`

DGen

- Added stack-based array type transformation support to `string typeTransform(Type)`
- Added transformation support for stack-based arrays for the `VariableDeclaration` instruction

StackArray

- Renamed `Array` type to `StackArray`
` The `StackArray` type now has an `arraySize` field and is included in the constructor's paremeters
- Added a `getAllocatedSize()` method to retrieve the `arraySize` field

Dependency

- Temporarily enabled the `StackArray` type in dependency processing for `VariableDeclarations` such that we can continue through the pipeline

Test cases

- Updated `simple_arrays.t` to test stack-based array types
2 years ago
Tristan B. V. Kildaire 68bc89308a Dependency
- When processing the `Array` type which is now to be seen  as a stack-based array (fixed size), error out in processing it during variable declarations
2 years ago
Tristan B. V. Kildaire 6b8952bb58 Array
- Added `getComponentType()` method which will return the array's element type
2 years ago
Tristan B. V. Kildaire e5520dc192 Builtins
- Removed comment as now fixed
2 years ago
Tristan B. V. Kildaire cbd6796e48 Builtins
- Updated TODO
2 years ago
Tristan B. V. Kildaire 32993900b5 Builtins
- Removed seperate handling of `<componentType>[]` and incorporated it into the pointer check, now we have fixed sub-issue 3 of issue #81

Test cases

- Updated test case `simple_arrays2.t` to showcase the aforementioned fix
2 years ago
Tristan B. V. Kildaire a4c3389abf Test cases
- Updated test case `simple_arrays2.t` to show case bug sub-issue 3 in issue #81
2 years ago
Tristan B. V. Kildaire 417a6e0598 Builtins
- Added information about the current bug faced in issue #81 (third sub-issue)
2 years ago
Tristan B. V. Kildaire 2ea4a37912 Builtins
- `getBuiltInType(TypeChecker, string)` will now return a `Pointer` object for arrays of which the type was `<componentType>[]` (non-stack bound) as effectively they are pointers with a different syntax -doing it here means that it is transparent and typechecking, code gen and emit will just see a pointer type which makes life a lot easier
2 years ago
Tristan B. V. Kildaire 52f0b58a63 Dependency
- When a variable declaration has a kind-of type we are unaware of then  print out an error message before asserting `false`
2 years ago
Tristan B. V. Kildaire d4d2947d04 Tets cases
- We will now be using `simple_arrays2.t` as our testing bench for array support
2 years ago
Tristan B. V. Kildaire e6efce2b97 Merge branch 'vardec_varass_dependency' into arrays 2 years ago
Tristan B. V. Kildaire 03a998bae8 Typechecker
- Removed `assert(false)` in code which handles a mismatched parameter type versus argument type, replaced with a throws `TypeMismatchException`
2 years ago
Tristan B. V. Kildaire ab66860e7b Typechecker
- See TODO
2 years ago
Tristan B. V. Kildaire dcdaa87c54 Typehecker
- Any attempt to dereference an entity of which is not a pointer type will now throw a `TypeCheckerException` instead of a failing assertion with a print-out
2 years ago