2023-02-26 17:49:20 +00:00
|
|
|
# This workflow uses actions that are not certified by GitHub.
|
|
|
|
# They are provided by a third-party and are governed by
|
|
|
|
# separate terms of service, privacy policy, and support
|
|
|
|
# documentation.
|
|
|
|
name: D
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches: [ "vardec_varass_dependency" ]
|
|
|
|
pull_request:
|
|
|
|
branches: [ "vardec_varass_dependency" ]
|
|
|
|
workflow_dispatch:
|
|
|
|
|
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
|
|
|
|
jobs:
|
2023-03-26 10:52:55 +00:00
|
|
|
build:
|
2023-03-26 10:39:30 +00:00
|
|
|
name: Build
|
2023-03-25 20:59:22 +00:00
|
|
|
strategy:
|
|
|
|
matrix:
|
2023-03-26 10:52:55 +00:00
|
|
|
os: [ubuntu-latest]
|
2023-08-14 20:21:46 +00:00
|
|
|
dc: [dmd-latest]
|
2023-03-25 20:59:22 +00:00
|
|
|
exclude:
|
2023-08-14 20:21:46 +00:00
|
|
|
- { os: macOS-latest, dc: dmd-latest }
|
2023-02-26 17:49:20 +00:00
|
|
|
|
2023-03-25 20:59:22 +00:00
|
|
|
runs-on: ${{ matrix.os }}
|
2023-02-26 17:49:20 +00:00
|
|
|
steps:
|
2023-03-25 20:59:22 +00:00
|
|
|
- uses: actions/checkout@v2
|
2023-03-26 10:47:56 +00:00
|
|
|
|
2023-03-26 10:43:17 +00:00
|
|
|
|
2023-03-25 20:59:22 +00:00
|
|
|
- name: Install D compiler
|
|
|
|
uses: dlang-community/setup-dlang@v1
|
|
|
|
with:
|
|
|
|
compiler: ${{ matrix.dc }}
|
2023-02-26 17:49:20 +00:00
|
|
|
|
2023-03-26 10:46:05 +00:00
|
|
|
- name: Build
|
|
|
|
run: dub build
|
|
|
|
|
2023-03-26 10:58:47 +00:00
|
|
|
|
2023-03-26 10:57:38 +00:00
|
|
|
|
2023-03-26 10:47:56 +00:00
|
|
|
- uses: actions/upload-artifact@v3
|
|
|
|
with:
|
|
|
|
name: tbin
|
|
|
|
path: tlang
|
2023-03-26 11:21:30 +00:00
|
|
|
|
|
|
|
unittests:
|
|
|
|
needs: build
|
|
|
|
name: Unit tests
|
2023-03-26 11:23:16 +00:00
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
os: [ubuntu-latest]
|
|
|
|
dc: [dmd-2.101.0]
|
|
|
|
exclude:
|
|
|
|
- { os: macOS-latest, dc: dmd-2.085.0 }
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-03-26 11:21:30 +00:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
2023-03-26 11:23:16 +00:00
|
|
|
- name: Install D compiler
|
|
|
|
uses: dlang-community/setup-dlang@v1
|
2023-03-26 11:21:30 +00:00
|
|
|
with:
|
2023-03-26 11:23:16 +00:00
|
|
|
compiler: ${{ matrix.dc }}
|
2023-08-21 12:12:32 +00:00
|
|
|
|
2023-08-21 12:10:50 +00:00
|
|
|
- name: Install Doveralls (code coverage tool)
|
|
|
|
run: dub fetch doveralls
|
2023-03-26 11:21:30 +00:00
|
|
|
|
|
|
|
- name: DUB unit tests with coverage
|
|
|
|
run: dub test --coverage
|
2023-08-21 12:12:32 +00:00
|
|
|
|
|
|
|
- name: Coverage upload
|
|
|
|
run: dub run doveralls
|
2023-03-26 11:21:30 +00:00
|
|
|
|
|
|
|
- uses: actions/upload-artifact@v3
|
|
|
|
with:
|
|
|
|
name: coverage files
|
|
|
|
path: \*.lst
|
|
|
|
|
2023-03-26 11:45:30 +00:00
|
|
|
syntaxcheck:
|
|
|
|
needs: [build, unittests]
|
|
|
|
name: Syntax checking (fine typecheck home)
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
- name: Download tlang compiler
|
|
|
|
uses: actions/download-artifact@v3
|
|
|
|
with:
|
|
|
|
name: tbin
|
|
|
|
|
|
|
|
- name: Chmod compiler
|
|
|
|
run: chmod +x tlang
|
|
|
|
# TODO: Maybe check below and make them typeheck again
|
|
|
|
- name: Simple float constant
|
|
|
|
run: ./tlang syntaxcheck source/tlang/testing/typecheck/simple_float_constant.t
|
|
|
|
- name: Simple float constant bad
|
2023-04-12 09:38:26 +00:00
|
|
|
run: |
|
|
|
|
set +e
|
|
|
|
./tlang syntaxcheck source/tlang/testing/typecheck/simple_float_constant_bad.t
|
|
|
|
if [ $? = 255 ]
|
|
|
|
then
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi
|
2023-03-26 11:45:30 +00:00
|
|
|
- name: Simple string
|
|
|
|
run: ./tlang syntaxcheck source/tlang/testing/typecheck/simple_string.t
|
2023-04-21 13:29:53 +00:00
|
|
|
|
|
|
|
- name: Simple return (good)
|
|
|
|
run: |
|
|
|
|
./tlang syntaxcheck source/tlang/testing/return/simple_return_good.t
|
|
|
|
- name: Simple return (bad return position)
|
|
|
|
run: |
|
|
|
|
set +e
|
|
|
|
./tlang syntaxcheck source/tlang/testing/return/simple_return_bad.t
|
|
|
|
if [ $? = 255 ]
|
|
|
|
then
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi
|
2023-03-26 11:45:30 +00:00
|
|
|
|
2023-07-11 19:43:21 +00:00
|
|
|
|
|
|
|
- name: Simple return (expressionless)
|
|
|
|
run: ./tlang syntaxcheck source/tlang/testing/return/simple_return_expressionless.t
|
|
|
|
|
2023-03-26 11:15:43 +00:00
|
|
|
typecheck:
|
2023-03-26 11:22:11 +00:00
|
|
|
needs: [build, unittests]
|
2023-03-26 11:15:43 +00:00
|
|
|
name: Typechecking tests
|
2023-03-26 10:52:55 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2023-03-26 11:02:30 +00:00
|
|
|
- uses: actions/checkout@v2
|
2023-03-26 11:37:10 +00:00
|
|
|
- name: Download tlang compiler
|
2023-03-26 10:52:55 +00:00
|
|
|
uses: actions/download-artifact@v3
|
|
|
|
with:
|
|
|
|
name: tbin
|
2023-03-26 10:47:56 +00:00
|
|
|
|
2023-03-26 10:58:47 +00:00
|
|
|
- name: Chmod compiler
|
|
|
|
run: chmod +x tlang
|
|
|
|
|
2023-07-11 19:43:21 +00:00
|
|
|
|
|
|
|
- name: Simple return (expressionless)
|
|
|
|
run: ./tlang typecheck source/tlang/testing/return/simple_return_expressionless.t
|
|
|
|
|
|
|
|
- name: Simple return (with expression)
|
|
|
|
run: ./tlang typecheck source/tlang/testing/return/simple_return_type.t
|
|
|
|
|
|
|
|
|
2023-03-26 10:58:47 +00:00
|
|
|
|
2023-03-26 11:01:07 +00:00
|
|
|
- name: Simple function call
|
|
|
|
run: ./tlang typecheck source/tlang/testing/typecheck/simple_function_call.t
|
2023-04-12 07:31:10 +00:00
|
|
|
- name: Simple function call 1 (type mismatch)
|
2023-04-12 07:42:44 +00:00
|
|
|
run: |
|
|
|
|
set +e
|
|
|
|
./tlang typecheck source/tlang/testing/typecheck/simple_function_call_1.t
|
|
|
|
if [ $? = 255 ]
|
|
|
|
then
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi
|
2023-03-26 11:41:22 +00:00
|
|
|
|
Array support (#1)
* Parser
- Added ability for `parseName()` to recognize array types
- Added array type handling to `parseTypedDeclaration()`
- Removed unneeded `derefCount` and comment in `parseTypedDeclaration()`
Check
- Added new symbol types `OBRACKET` and `CBRACKET`
* Tets cases
- We will now be using `simple_arrays2.t` as our testing bench for array support
* Dependency
- When a variable declaration has a kind-of type we are unaware of then print out an error message before asserting `false`
* 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
* Builtins
- Added information about the current bug faced in issue #81 (third sub-issue)
* Test cases
- Updated test case `simple_arrays2.t` to show case bug sub-issue 3 in issue #81
* 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
* Builtins
- Updated TODO
* Builtins
- Removed comment as now fixed
* Array
- Added `getComponentType()` method which will return the array's element type
* 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
* 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
* Tets cases
- Added new test case for testing (later) multi-dimensional stack-arrays
* Parser
- Working on adding array index assignment support
Test cases
- Added test case to test array assignments with
* 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
* Parser
- Handle the case whereby `SymbolType.ASSIGN` or `SymbolType.IDENT_TYPE` is not found by throwing an error
* Parser
- Moved logic for array assignments into the branch for it (deferred it)
* 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
* Expressions
- Added new parse node (a sub-type of `Expression`) for representing array indexing; `ArrayIndex`
Data
- Fixed compilation error caused by missing semi-colon
* 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
* Parser
- Removed now-completed TODO relating to array accesses in `parseExpression()`
* 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
* Instruction
- Added new instruction for indexing into arrays, a new `Value`-type instruction called `ArrayIndexInstruction`
* 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))
* 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
* 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
* DGen
- Added a stub emitter for `ArrayIndexInstruction` (pointer-based array indexing)
- Added a stub emitter for `StackArrayINdexInstruction` (stack-array based array indexing)
* INstructions
- Added `getArrayName()`, `getIndexInstr()` and `getAssignedValue()` to `StackArrayIndexAssignmentInstruction`
* 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`
* Test cases
- Added `complex_stack_arrays1.t`
- This tests a stack array of a fixed size of `int[]` (basically `int*`) and assigneing into it
* 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
* Test cases
- Added `simple_stack_arrays2.t` which tests a stack array of a fixed size and then assigns into it a value
* 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
* 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`
* 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
* 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)
* 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`
* Test cases
- WIP: Added `simple_stack_array_coerce.t` as we want to add coercion for this now
* Typecheck
- Added rudimentary check for checking if an argument is a stack array, and if the parameter (to a function call) is a pointer and if so then returns whether they have matching component types in a new function named `canCoerceStackArray(Type, Type)`
* Typecheck
- Fixed `canCoerceStackArray(Type, Type)` to actually coerce the first type first into a pointer type (coercing the stack array's component type to `<compType>*`) and THEN apply the `isSameType(Type, Type)` check
* Typecheck
- Hoisted up `canCoerceStackArray(Type, Type)` to the class-level of `TypeChecker`
- Removed debug prints from `canCoerceStackArray(Type, Type)`
- Added a TODO where the check should be done in the `FunctionCall` branch of the `DNode` processor
* TypeChecker
- Added a seperate check for function call `DNode` processing which now checks if we can coerce the stack-array-based argument to the pointer-based type parameter
Notes
- Emit now fails as we haven't implement an emit for this case, so we need to do that.
- Also, should we change the type of what is being passed in - perhaps that actually makes sense here - we haven't fully coerced it actually
* TypeChecker
- Updated `canCoerceStackArray(Type, Type)` to now take in `canCoerceStackArray(Type, Type, ref Type)` to set the newly created coerced type
- Fixed bug whereby if the coercion succeeded we didn't actually add to the list of evaluation-instructions in the `FuncCallInstr` object, hence there would be a `null` Instruction object appearing in the code emit phase.
- Added some NOTEs which we can clean up this code using
* TypeChecker
- Cleaned up commented-out code
* Added CI/CD test for 'simple_stack_array_coerce.t'
* Added CI/CD test for 'complex_stack_arrays1.t'
* Added CI/CD semantic tests (WIP) for 'simple_stack_array_coerce.t' and 'complex_stack_arrays1.t'
* Added CI/CD semantic tests (WIP) for 'simple_arrays2.t' and 'simple_arrays4.t'
* Added CI/CD semantic tests (WIP) for 'simple_arrays2.t' and 'simple_arrays4.t'
* Added CI/CD semantic tests (WIP) for 'simple_arrays2.t' and 'simple_arrays4.t'
* Fixed filepath for test 'simple_arrays.t'
* Fixed typechecking tests for arrays
* DGen
- Added instrumentation for `simple_stack_array_coerce.t`
Test cases
- Updated `simple_stack_array_coerce.t` to update the array passed in a manner such that we can sum the two elements later, return it and assert to ensure it is set correctly
* Parser
- Had to ensure the old identifier code was removed too, was too early; therefore this now-dead code was removed
* Test cases
- Added this test (even though it is a bad test, the syntax ie wrong)
* Test cases
- Update `simple_stack_arrsys4.t` to return an `int` such that we can verify it works.
- Also added more tests to it.
DGen
- Added semantic test code generation for `simple_stack_arrays4.t`
CI
- Re-organised tests for semantics in emit for arrays into those "Which have semantic tests" and "those which don't (yet)"
- Added semantic/emit test for `simple_stack_arrays4.t`
* Test cases
- Updated `simple_arrays2.t` to test casting of complex array types
* Test cases
- Updated `complex_stack_arrays1.t`
* Test cases
- Added new test for testing pointer syntax; `simple_stack_array_coerce_ptr_syntax.t`
- FIXME: It is broken as we don't have the latest pointer code - that must still be finished
* Test cases
- Added test case `simple_stack_array_ceorce_wrong.t` where coercion must fail
* Test cases
- Added `simple_pointer_array_syntax.t` which should test the `int[] == int*` stuff
* DGen
- Made semantic test for `simple_pointer_array_syntax.t`
Test cases
- Added a test for `simple_pointer_array_syntax.t.t`
* Branding
- Added logo here
* Test cases
- Addes semantic code emit instrucmentation for `simple_stack_array_coerce_ptr_syntax.t`
* Pipelines
- Added test case for `source/tlang/testing/simple_stack_array_coerce_wrong.t` for typechecking phase
* Test cases
- Added test case `complex_stack_array_coerce.t`
* Test cases
- Added extensive positive test case `complex_stack_array_coerce_permutation_good.t` which has a lot of different ways to write `int**` (think `int*[]` etc)
- Added negative test cases `complex_stack_array_coerce_bad1.t`, `complex_stack_array_coerce_bad2.t` and `complex_stack_array_coerce_bad3.t`
2023-04-20 09:21:50 +00:00
|
|
|
# Array support
|
|
|
|
- name: Simple array
|
|
|
|
run: ./tlang typecheck source/tlang/testing/simple_arrays.t
|
|
|
|
- name: Simple array 2
|
|
|
|
run: ./tlang typecheck source/tlang/testing/simple_arrays2.t
|
|
|
|
- name: Simple array 4
|
|
|
|
run: ./tlang typecheck source/tlang/testing/simple_arrays4.t
|
|
|
|
|
|
|
|
- name: Stack-based array coercion
|
|
|
|
run: ./tlang typecheck source/tlang/testing/simple_stack_array_coerce.t
|
|
|
|
- name: Complex stack-based arrays
|
|
|
|
run: ./tlang typecheck source/tlang/testing/complex_stack_arrays1.t
|
|
|
|
- name: Stack-based array coercion (type mismatch)
|
|
|
|
run: |
|
|
|
|
set +e
|
|
|
|
./tlang compile source/tlang/testing/simple_stack_array_coerce_wrong.t
|
|
|
|
if [ $? = 255 ]
|
|
|
|
then
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
- name: Stack-based array coercion (good permutations))
|
|
|
|
run: |
|
|
|
|
./tlang typecheck source/tlang/testing/complex_stack_array_coerce_permutation_good.t
|
|
|
|
- name: Stack-based array coercion (type mismatch - bad permutation 1)
|
|
|
|
run: |
|
|
|
|
set +e
|
|
|
|
./tlang compile source/tlang/testing/complex_stack_array_coerce_bad1.t
|
|
|
|
if [ $? = 255 ]
|
|
|
|
then
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
- name: Stack-based array coercion (type mismatch - bad permutation 2)
|
|
|
|
run: |
|
|
|
|
set +e
|
|
|
|
./tlang compile source/tlang/testing/complex_stack_array_coerce_bad2.t
|
|
|
|
if [ $? = 255 ]
|
|
|
|
then
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
- name: Stack-based array coercion (type mismatch - bad permutation 3)
|
|
|
|
run: |
|
|
|
|
set +e
|
|
|
|
./tlang compile source/tlang/testing/complex_stack_array_coerce_bad3.t
|
|
|
|
if [ $? = 255 ]
|
|
|
|
then
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi
|
2023-03-26 11:12:12 +00:00
|
|
|
|
2023-03-26 11:09:49 +00:00
|
|
|
- name: Collide container module1
|
2023-04-12 07:49:08 +00:00
|
|
|
run: |
|
|
|
|
set +e
|
|
|
|
./tlang typecheck source/tlang/testing/collide_container_module1.t
|
|
|
|
if [ $? = 255 ]
|
|
|
|
then
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi
|
2023-03-26 11:09:49 +00:00
|
|
|
- name: Collide container module2
|
2023-04-12 07:49:08 +00:00
|
|
|
run: |
|
|
|
|
set +e
|
|
|
|
./tlang typecheck source/tlang/testing/collide_container_module2.t
|
|
|
|
if [ $? = 255 ]
|
|
|
|
then
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi
|
2023-03-26 11:12:12 +00:00
|
|
|
- name: Collide container non-module
|
2023-04-12 07:49:08 +00:00
|
|
|
run: |
|
|
|
|
set +e
|
|
|
|
./tlang typecheck source/tlang/testing/collide_container_non_module.t
|
|
|
|
if [ $? = 255 ]
|
|
|
|
then
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi
|
2023-03-26 11:12:12 +00:00
|
|
|
- name: Collide container
|
2023-04-12 07:49:08 +00:00
|
|
|
run: |
|
|
|
|
set +e
|
|
|
|
./tlang typecheck source/tlang/testing/collide_container.t
|
|
|
|
if [ $? = 255 ]
|
|
|
|
then
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi
|
2023-03-26 11:12:12 +00:00
|
|
|
- name: Collide member
|
2023-04-12 07:49:08 +00:00
|
|
|
run: |
|
|
|
|
set +e
|
|
|
|
./tlang typecheck source/tlang/testing/collide_member.t
|
|
|
|
if [ $? = 255 ]
|
|
|
|
then
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi
|
2023-03-26 11:15:43 +00:00
|
|
|
- name: Precedence collision test
|
2023-04-12 07:49:08 +00:00
|
|
|
run: |
|
|
|
|
set +e
|
|
|
|
./tlang typecheck source/tlang/testing/precedence_collision_test.t
|
|
|
|
if [ $? = 255 ]
|
|
|
|
then
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi
|
2023-03-26 11:09:49 +00:00
|
|
|
|
2023-03-26 11:15:43 +00:00
|
|
|
- name: Else if without if
|
2023-04-12 07:51:40 +00:00
|
|
|
run: |
|
|
|
|
set +e
|
|
|
|
./tlang typecheck source/tlang/testing/else_if_without_if.pl
|
|
|
|
if [ $? = 255 ]
|
|
|
|
then
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-03-26 11:15:43 +00:00
|
|
|
- name: Simple module positive
|
|
|
|
run: ./tlang typecheck source/tlang/testing/simple1_module_positive.t
|
2023-04-12 07:55:12 +00:00
|
|
|
# TODO: Re-enable OOP when we start focusing on it again
|
|
|
|
#- name: Simple OOP
|
|
|
|
# run: ./tlang typecheck source/tlang/testing/simple1_oop.t
|
2023-03-26 11:15:43 +00:00
|
|
|
- name: Simple name recognition
|
|
|
|
run: ./tlang typecheck source/tlang/testing/simple2_name_recognition.t
|
2023-04-12 07:57:13 +00:00
|
|
|
# TODO: Re-enable OOP when we start focusing on it again
|
|
|
|
#- name: test3
|
|
|
|
# run: ./tlang typecheck source/tlang/testing/test3.t
|
2023-03-26 11:12:12 +00:00
|
|
|
|
2023-03-26 11:32:22 +00:00
|
|
|
- name: Simple literals
|
|
|
|
run: ./tlang typecheck source/tlang/testing/simple_literals.t
|
2023-04-12 09:33:34 +00:00
|
|
|
- name: Simple literals 2 (uncoercible)
|
|
|
|
run: |
|
2023-04-12 09:36:31 +00:00
|
|
|
set +e
|
2023-04-12 09:33:34 +00:00
|
|
|
./tlang typecheck source/tlang/testing/simple_literals2.t
|
|
|
|
if [ $? = 255 ]
|
|
|
|
then
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi
|
2023-03-26 11:32:22 +00:00
|
|
|
- name: Simple literals 3
|
|
|
|
run: ./tlang typecheck source/tlang/testing/simple_literals3.t
|
2023-04-12 09:42:21 +00:00
|
|
|
- name: Simple literals 4 (range violation)
|
|
|
|
run:
|
|
|
|
set +e
|
|
|
|
./tlang typecheck source/tlang/testing/simple_literals4.t
|
|
|
|
if [ $? = 255 ]
|
|
|
|
then
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi
|
2023-03-26 11:32:22 +00:00
|
|
|
- name: Simple literals 5
|
|
|
|
run: ./tlang typecheck source/tlang/testing/simple_literals5.t
|
|
|
|
- name: Simple literals 6
|
|
|
|
run: ./tlang typecheck source/tlang/testing/simple_literals6.t
|
🧠️ Feature: Universal coercion and type enforcer (#9)
* TypeChecker
- Added `bool isSameType2(Value v1, Value v2, bool attemptCoercion = false)` for future implementation of universal coercion as per #115
* TypeChecker
- Renamed `isSameType2` to `typeEnforce`
- Updated `typeEnforce`'s default parameter documentation from `false` to `attemptCoercion` (as it should have been in the beginning)
* TypeCheckerException
- Save the `TypecheckError` coming in as `errType` and make it available via `getError()`
TypemMismatchException
- Save the original (expected) and attempted types and make them available via `getExpectedType()` and `getATtemptedType()` respectively
* TypeChecker
- Updated `typeEnforce` from taking in `Value v1, Value v2, bool` to `Type t1, Value v2, bool`.
- `typeEnforce()` will now extract the `Type` of `Value v2` and call `isSameType(t1, t2)`, if that fails and coercion is allowed then it is attempted, however if that fails then it causes an exception to be thrown. In the case coercion is not allowed, then a `TypeMismatchException` is thrown
Unit tests
- Tested the new `typeEnforce(Type t1, Value v2, bool)` and it seems to work, both a case of failing matching (coercion disallowed) and working coercion (coercion allowed)
* TypeChecker
- Documented existing unittest for `typeEnforce(Type, Value, bool)`
- Added new unit test for `typeEnforce(Type, Value, bool)` which tests when the types ARE the same
* TypeChecker
- Cleaned up `typeEnforce(Type, Value, bool)`
* TypeChecker
- Added a work-in-progress unit test to test how I would use `typeEnforce(Type t1, Value v2, bool coercion = false)` in practice
- Added TODOs in `attemptCoercion(Type, Type)` where I must add support
* TypeChecker
- Finished the unit test testing out the usage for `typeEnforce(Type, Value, bool coerce = false)`
- Added TODOs to `attemptCoercion(Type, Value)` for the changes required to it
* TypeChecker
- Removed incorrect TODOs from `attemptCoerce(Type, Value)` and updated the message when the coercion fails
Unit tests
- Updated first unit test for `typeEnforce()` to test failing coercion on a non-`LiteralValue` instruction
- Added a unit test where `typeEnforce()` WILL pass as it coerces a `LiteralValue` instruction
* Exceptions (`typechecker`)
- Added new exception type `CoercionException` to be thrown whenever a coercion cannot take place.
* TypeChecker
- Ensure that `attemptCoercion(Type, Value)` only throws instances of `CoercionException`
* Unit tests
- Fixed failing-coercion check by catching the correct exception when it fails `CoercionException` instead of `TypeMismatchException`)
* TypeChecker
- Added documentation for `isSameType(Type t1, Type t2)`
* TypeChecker
- Updated documentation for `isCoercibleRange(Type, Value)`
- Updated `attemptCoercion(Type, Value)` with new documentation and renamed parameters
* Unit tests (typechecker)
- Added comments
* TypeChecker
- Removed now-completed TODO in `typeEnforce(Type t1, Value v2, bool allowCoercion = false)`
* TypeChecker
- Removed unused `typeStatus` variable in `typeEnforce(Type, Value, bool)`
* TypeChecker
- Variable declarations (with assignments) now use the `typeEnforce()` method with coercion allowed in order to do the type checking and coercion changes
- Added a comment explaining a certain branch of `attemptCoercion(Type, Value)`
* TypeChecker
- If the to-type and provided-type are both numerical then use a size-based test
Test cases
- Added two test cases which test `typeEnforce()` on incoming `Value`-based instructions as part of variable declarations
* Test cases
- Fixed negative test case - it MUST have an error and that should be seen as a pass
* TypeChecker (unit tests)
- Disabled invalid unit test (marked for re-writing)
- I should re-write the below. It is now incorrect as I DO ALLOW coercion of non literal-based instructions now - so it fails because it is using an older specification of TLang
* TypeChecker
- Migrated the type checking of standalone variable assignments to using `typeEnforce()`
Test cases
- Added positive and negative test cases
* - Updated `.gitignore`
* Feature/type enforcer cast instr emit (#13)
* TypeChecker
- `typeEnforce()` now will not change the type of `Value`-based instruction `v2` but rather return, on successful coercion set a `ref`-based argument to a new instance of a `CastedValueInstruction`, if coercion fails or was disabled and types mismatched then an exeption is thrown as normal.
- If the types are an exact same match, a-la `isSameType(Type, Type)`, then this `ref` value is set to `v2` (makes programming easy) else we would have no way to know
- `attemptCoerce()` now, to go with the above changes to `typeEnforce()`, returns a `CatsedValueInstruction` to the to-type on successful coercion, else an exception is thrown as usual
- Updated two cases of `typeEnforce()` usage to the new method signature, also now add a sanity check assertion that the types now DO match as they should
* TypeChecker
- We need not set it again, look the value we use when we CALL `typeEnforce()` is that of the `fromInstruction` and if no changes occur we still have it, it is fine - if it changes via the call to `typeEnforce()` via the `ref` based argument thne same old
- No need for us to set it here in the event of no changes, we are writing back the exact same Instruction/object-reference
* TypeChecker (unit tests)
- Upgraded to the new `typeEnforcer()` method signature
* TypeChecker
- Improved documentation for `typeEnforce()`
* TypeChecker
- Added TODO regarding pointer coercion with integers in `Pointer + Integer` case (for pointer airthmetic)
* TypeChecker
- Added a new branch which currently throws an exception as it is unimplememted
- This branch (above) is in `attemptCoercion()` and is to handle the coercion of `Integer` to `Pointer` for pointer arithmetic
- When doing the typechecking/codegen for `BinaryOp`, disable the pointer coercion call to `attemptPointerAriehmeticCoercion()`, instead now make calls in those cases they apply, to `typeEnforce()`
- The above stuff is still broken, not yet implemented.
* TypeChecker
- Cannot use cast as that can return false positives for an all pointer case as all `Pointer`s are `Integer`s
- Added `isPointerType(Type)` to check the above
- Added then also `isIntegralTypeButNotPointer(Type)` which checks for an `Integer` type but excluding if it is a `Pointer`
- Updated the checks in the `BinaryOperator` branch of `typeCheckThing(DNode)` to do this
* TypeChecker
- Need to do the `Pointer` checks first in `attemptCoercion(Type, Value)`
* TypeChecker
- `attemptCoercion(Type, Value)` now returns a `CastedValueInstruction` to cast the `Integer` type to the `Pointer` type
* TypeCHecker
- Catch mis use of type enforcement by using `isIntegralTypeButNotPointer(Type)` and isPointerType`(Type)` for the previous commit
* TypeChecker
- Refresh the types after the potential calls to `typeEnforce(..., ..., ..., ...)`
* Pipeline
- Use `set -e` for `simple_pointer.t` test in emit stage
* Pipelines (emit stage)
- Previous compilation may have succeeded, meaning ./tlang.out never gets updated and exits fine with 0, but we only use the last commands exit status to check for a pass for a test.
- By setting this if COMPILATION fails then we exit with its code and the test status is set via that
* Pipelines
- Removed the `set -e` code as the correct `Exception` now causes a non-zero exit code from the changes made in `varass_vardec_dependency`
* DGen
- Added notice for issue #140
* TypeChecker
- Made `isIntegralTypeButNotPointer(Type)` public
- Made `isPointerType(Type)` public
* Instructions
- `CastedValueInstruction` now is unrelaxed by default but can be set (tis aids in how it can be emitted later for issue #140)
* DGen
- Added some checks for certain conditions whereby pointer coercion requires relaxing the casted operands (coerced operands)
* DGen
- Relax `CastedValueInstruction`(s) when appropriate in `BinaryOpInstr` handling code
- Removed panics
* DGen
- Added relaxation support to the code emitting code for `CastedValueInstruction`
* DGen
- make debug messages for when relaxation occurs for `CastedValueInstruction` emitting more clear
* TypeChecker
- Implemented `biggerOfTheTwo(Integer, Integer)` which determines the biggest of the two `Integer`-based types and returns that one.
* TypeChecker
- Fixed incorrect variable name in `biggerOfTheTwo(Integer, Integer)`
* TypeChecker
- Throw an error in the case where a `BinaryOperatorExpression` occurs with non-`Integer`-based instructions (at least for now)
* TypeChecker
- If both types are `Integral` (but not `Pointer`) then smaller coerces to bigger, if they however are equal then signed coerces to unsigned
* TypeChecker
- Removed now irrelevant comment
* TypeChecker
- Don't throw exception here, rather let the `isSameType(Type, Type)` check handle that
- We still keep the warning we print about missing cases implementation-wise
* TypeChecker
- Fixed explanation
* TypeChecker
- Marked related issue
* TypeChecker
- Implemented ` isStackArrayType(Type typeIn)`
- WIP: Added a check for handling `StackArray -> Pointer` coercion to `attemptCoercion(Type, Value)`
* TypeChecker
- `attemptCoercion(Type, Value)` will now ensure firstly that the `StackArray`'s component type matches that of the `Pointer`'s referred type, if not throw an exception, if so, then return a `CastedValueInstruction`
* TypeChecker
- Print out a debug message when attempting to coerce a `StackArray` to a `Pointer`
- Fixed the error message thrown when a `StackArray` could not be coerced to a `Pointer` due to the component type != ptr's referred type
- `FunctionCall` handling now has the `canCoerceStackArray()` code disabled and uses the `typeEnforce()` method
* TypeChecker
- Type checking code for `FunctionCall`
* TypeCheck
- Completed TODO comment
* TypeChecker
- Added a TODO
* TypeChecker
- Added FIXME where the `typeEnforce()` call need to be made for the `ReturnStmt`'s return expression's type to match or be checked-against the containing `Function`'s
* TypeChecker
- `ReturnStmt` now uses `typeEnforce()`
* Test cases
- Added two new checks for checking the return type of a function and matching a `ReturnStmt`'s expression's type to it
* TypeChecker
- Removed assertion check, rather let the exception thrown handle the error
- Only after we know the finally-parenting `Container` is a `Function` (should we reference `funcContainer`
* Test cases
- Removed explicit cast from `simple_function_recursion_factorial.t`
* TypeChecker
- If we have a `LiteralValue` and a non-`LiteralValue` then coerce the `LiteralValue` towards the non`-LiteralValue` via `typeEnforce()`
- This should allow the correct range checking of literal values within the range of the to-type and not require annoying explicit casts
* Test cases
- Removed now-unneeded explicit casts on literal values in `simple_function_recursion_factorial.t`
* TypeChecker
- Added comment describing the process used
- Removed now-completed TODO
* TypeChecker
- Removed some dead code
- Removed now-completed FIXME/TODO
* TypeChecker
- Removed old type checking code for variable declarations with assignments
- Removed old type checking code for standalone variable assignments
2023-08-10 17:42:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# All the universal coercion tests are below
|
|
|
|
#
|
|
|
|
# Over time those above will be ported over to it and will
|
|
|
|
# infact make part of the test suite of typeEnforce()
|
|
|
|
- name: Simple Coerce Literal Good (to variable declaration)
|
|
|
|
run: ./tlang typecheck source/tlang/testing/universal_coerce/simple_coerce_literal_good.t
|
|
|
|
- name: Simple Coerce Literal Bad [Size loss] (to variable declaration)
|
|
|
|
run:
|
|
|
|
set +e
|
|
|
|
./tlang typecheck source/tlang/testing/universal_coerce/simple_coerce_literal_bad.t
|
|
|
|
if [ $? = 255 ]
|
|
|
|
then
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
- name: Simple Coerce Literal Good (standalone variable assignment)
|
|
|
|
run: ./tlang typecheck source/tlang/testing/universal_coerce/simple_coerce_literal_good_stdalo.t
|
|
|
|
- name: Simple Coerce Literal Bad [Size loss] (standalone variable assignment)
|
|
|
|
run:
|
|
|
|
set +e
|
|
|
|
./tlang typecheck source/tlang/testing/universal_coerce/simple_coerce_literal_bad_stdalon.t
|
|
|
|
if [ $? = 255 ]
|
|
|
|
then
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
- name: Function return expression coercion (good)
|
|
|
|
run: ./tlang typecheck source/tlang/testing/simple_function_return_type_check_good.t
|
|
|
|
- name: Function return expression coercion (bad)
|
|
|
|
run:
|
|
|
|
set +e
|
|
|
|
./tlang typecheck source/tlang/testing/simple_function_return_type_check_bad.t
|
|
|
|
if [ $? = 255 ]
|
|
|
|
then
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi
|
2023-03-26 11:32:22 +00:00
|
|
|
|
2023-03-26 11:18:50 +00:00
|
|
|
emit:
|
2023-03-26 11:23:54 +00:00
|
|
|
needs: [build, unittests]
|
2023-03-26 11:18:50 +00:00
|
|
|
name: Emit tests
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
2023-03-26 11:37:10 +00:00
|
|
|
- name: Download tlang compiler
|
2023-03-26 11:18:50 +00:00
|
|
|
uses: actions/download-artifact@v3
|
|
|
|
with:
|
|
|
|
name: tbin
|
|
|
|
|
|
|
|
- name: Chmod compiler
|
🧠️ Feature: Universal coercion and type enforcer (#9)
* TypeChecker
- Added `bool isSameType2(Value v1, Value v2, bool attemptCoercion = false)` for future implementation of universal coercion as per #115
* TypeChecker
- Renamed `isSameType2` to `typeEnforce`
- Updated `typeEnforce`'s default parameter documentation from `false` to `attemptCoercion` (as it should have been in the beginning)
* TypeCheckerException
- Save the `TypecheckError` coming in as `errType` and make it available via `getError()`
TypemMismatchException
- Save the original (expected) and attempted types and make them available via `getExpectedType()` and `getATtemptedType()` respectively
* TypeChecker
- Updated `typeEnforce` from taking in `Value v1, Value v2, bool` to `Type t1, Value v2, bool`.
- `typeEnforce()` will now extract the `Type` of `Value v2` and call `isSameType(t1, t2)`, if that fails and coercion is allowed then it is attempted, however if that fails then it causes an exception to be thrown. In the case coercion is not allowed, then a `TypeMismatchException` is thrown
Unit tests
- Tested the new `typeEnforce(Type t1, Value v2, bool)` and it seems to work, both a case of failing matching (coercion disallowed) and working coercion (coercion allowed)
* TypeChecker
- Documented existing unittest for `typeEnforce(Type, Value, bool)`
- Added new unit test for `typeEnforce(Type, Value, bool)` which tests when the types ARE the same
* TypeChecker
- Cleaned up `typeEnforce(Type, Value, bool)`
* TypeChecker
- Added a work-in-progress unit test to test how I would use `typeEnforce(Type t1, Value v2, bool coercion = false)` in practice
- Added TODOs in `attemptCoercion(Type, Type)` where I must add support
* TypeChecker
- Finished the unit test testing out the usage for `typeEnforce(Type, Value, bool coerce = false)`
- Added TODOs to `attemptCoercion(Type, Value)` for the changes required to it
* TypeChecker
- Removed incorrect TODOs from `attemptCoerce(Type, Value)` and updated the message when the coercion fails
Unit tests
- Updated first unit test for `typeEnforce()` to test failing coercion on a non-`LiteralValue` instruction
- Added a unit test where `typeEnforce()` WILL pass as it coerces a `LiteralValue` instruction
* Exceptions (`typechecker`)
- Added new exception type `CoercionException` to be thrown whenever a coercion cannot take place.
* TypeChecker
- Ensure that `attemptCoercion(Type, Value)` only throws instances of `CoercionException`
* Unit tests
- Fixed failing-coercion check by catching the correct exception when it fails `CoercionException` instead of `TypeMismatchException`)
* TypeChecker
- Added documentation for `isSameType(Type t1, Type t2)`
* TypeChecker
- Updated documentation for `isCoercibleRange(Type, Value)`
- Updated `attemptCoercion(Type, Value)` with new documentation and renamed parameters
* Unit tests (typechecker)
- Added comments
* TypeChecker
- Removed now-completed TODO in `typeEnforce(Type t1, Value v2, bool allowCoercion = false)`
* TypeChecker
- Removed unused `typeStatus` variable in `typeEnforce(Type, Value, bool)`
* TypeChecker
- Variable declarations (with assignments) now use the `typeEnforce()` method with coercion allowed in order to do the type checking and coercion changes
- Added a comment explaining a certain branch of `attemptCoercion(Type, Value)`
* TypeChecker
- If the to-type and provided-type are both numerical then use a size-based test
Test cases
- Added two test cases which test `typeEnforce()` on incoming `Value`-based instructions as part of variable declarations
* Test cases
- Fixed negative test case - it MUST have an error and that should be seen as a pass
* TypeChecker (unit tests)
- Disabled invalid unit test (marked for re-writing)
- I should re-write the below. It is now incorrect as I DO ALLOW coercion of non literal-based instructions now - so it fails because it is using an older specification of TLang
* TypeChecker
- Migrated the type checking of standalone variable assignments to using `typeEnforce()`
Test cases
- Added positive and negative test cases
* - Updated `.gitignore`
* Feature/type enforcer cast instr emit (#13)
* TypeChecker
- `typeEnforce()` now will not change the type of `Value`-based instruction `v2` but rather return, on successful coercion set a `ref`-based argument to a new instance of a `CastedValueInstruction`, if coercion fails or was disabled and types mismatched then an exeption is thrown as normal.
- If the types are an exact same match, a-la `isSameType(Type, Type)`, then this `ref` value is set to `v2` (makes programming easy) else we would have no way to know
- `attemptCoerce()` now, to go with the above changes to `typeEnforce()`, returns a `CatsedValueInstruction` to the to-type on successful coercion, else an exception is thrown as usual
- Updated two cases of `typeEnforce()` usage to the new method signature, also now add a sanity check assertion that the types now DO match as they should
* TypeChecker
- We need not set it again, look the value we use when we CALL `typeEnforce()` is that of the `fromInstruction` and if no changes occur we still have it, it is fine - if it changes via the call to `typeEnforce()` via the `ref` based argument thne same old
- No need for us to set it here in the event of no changes, we are writing back the exact same Instruction/object-reference
* TypeChecker (unit tests)
- Upgraded to the new `typeEnforcer()` method signature
* TypeChecker
- Improved documentation for `typeEnforce()`
* TypeChecker
- Added TODO regarding pointer coercion with integers in `Pointer + Integer` case (for pointer airthmetic)
* TypeChecker
- Added a new branch which currently throws an exception as it is unimplememted
- This branch (above) is in `attemptCoercion()` and is to handle the coercion of `Integer` to `Pointer` for pointer arithmetic
- When doing the typechecking/codegen for `BinaryOp`, disable the pointer coercion call to `attemptPointerAriehmeticCoercion()`, instead now make calls in those cases they apply, to `typeEnforce()`
- The above stuff is still broken, not yet implemented.
* TypeChecker
- Cannot use cast as that can return false positives for an all pointer case as all `Pointer`s are `Integer`s
- Added `isPointerType(Type)` to check the above
- Added then also `isIntegralTypeButNotPointer(Type)` which checks for an `Integer` type but excluding if it is a `Pointer`
- Updated the checks in the `BinaryOperator` branch of `typeCheckThing(DNode)` to do this
* TypeChecker
- Need to do the `Pointer` checks first in `attemptCoercion(Type, Value)`
* TypeChecker
- `attemptCoercion(Type, Value)` now returns a `CastedValueInstruction` to cast the `Integer` type to the `Pointer` type
* TypeCHecker
- Catch mis use of type enforcement by using `isIntegralTypeButNotPointer(Type)` and isPointerType`(Type)` for the previous commit
* TypeChecker
- Refresh the types after the potential calls to `typeEnforce(..., ..., ..., ...)`
* Pipeline
- Use `set -e` for `simple_pointer.t` test in emit stage
* Pipelines (emit stage)
- Previous compilation may have succeeded, meaning ./tlang.out never gets updated and exits fine with 0, but we only use the last commands exit status to check for a pass for a test.
- By setting this if COMPILATION fails then we exit with its code and the test status is set via that
* Pipelines
- Removed the `set -e` code as the correct `Exception` now causes a non-zero exit code from the changes made in `varass_vardec_dependency`
* DGen
- Added notice for issue #140
* TypeChecker
- Made `isIntegralTypeButNotPointer(Type)` public
- Made `isPointerType(Type)` public
* Instructions
- `CastedValueInstruction` now is unrelaxed by default but can be set (tis aids in how it can be emitted later for issue #140)
* DGen
- Added some checks for certain conditions whereby pointer coercion requires relaxing the casted operands (coerced operands)
* DGen
- Relax `CastedValueInstruction`(s) when appropriate in `BinaryOpInstr` handling code
- Removed panics
* DGen
- Added relaxation support to the code emitting code for `CastedValueInstruction`
* DGen
- make debug messages for when relaxation occurs for `CastedValueInstruction` emitting more clear
* TypeChecker
- Implemented `biggerOfTheTwo(Integer, Integer)` which determines the biggest of the two `Integer`-based types and returns that one.
* TypeChecker
- Fixed incorrect variable name in `biggerOfTheTwo(Integer, Integer)`
* TypeChecker
- Throw an error in the case where a `BinaryOperatorExpression` occurs with non-`Integer`-based instructions (at least for now)
* TypeChecker
- If both types are `Integral` (but not `Pointer`) then smaller coerces to bigger, if they however are equal then signed coerces to unsigned
* TypeChecker
- Removed now irrelevant comment
* TypeChecker
- Don't throw exception here, rather let the `isSameType(Type, Type)` check handle that
- We still keep the warning we print about missing cases implementation-wise
* TypeChecker
- Fixed explanation
* TypeChecker
- Marked related issue
* TypeChecker
- Implemented ` isStackArrayType(Type typeIn)`
- WIP: Added a check for handling `StackArray -> Pointer` coercion to `attemptCoercion(Type, Value)`
* TypeChecker
- `attemptCoercion(Type, Value)` will now ensure firstly that the `StackArray`'s component type matches that of the `Pointer`'s referred type, if not throw an exception, if so, then return a `CastedValueInstruction`
* TypeChecker
- Print out a debug message when attempting to coerce a `StackArray` to a `Pointer`
- Fixed the error message thrown when a `StackArray` could not be coerced to a `Pointer` due to the component type != ptr's referred type
- `FunctionCall` handling now has the `canCoerceStackArray()` code disabled and uses the `typeEnforce()` method
* TypeChecker
- Type checking code for `FunctionCall`
* TypeCheck
- Completed TODO comment
* TypeChecker
- Added a TODO
* TypeChecker
- Added FIXME where the `typeEnforce()` call need to be made for the `ReturnStmt`'s return expression's type to match or be checked-against the containing `Function`'s
* TypeChecker
- `ReturnStmt` now uses `typeEnforce()`
* Test cases
- Added two new checks for checking the return type of a function and matching a `ReturnStmt`'s expression's type to it
* TypeChecker
- Removed assertion check, rather let the exception thrown handle the error
- Only after we know the finally-parenting `Container` is a `Function` (should we reference `funcContainer`
* Test cases
- Removed explicit cast from `simple_function_recursion_factorial.t`
* TypeChecker
- If we have a `LiteralValue` and a non-`LiteralValue` then coerce the `LiteralValue` towards the non`-LiteralValue` via `typeEnforce()`
- This should allow the correct range checking of literal values within the range of the to-type and not require annoying explicit casts
* Test cases
- Removed now-unneeded explicit casts on literal values in `simple_function_recursion_factorial.t`
* TypeChecker
- Added comment describing the process used
- Removed now-completed TODO
* TypeChecker
- Removed some dead code
- Removed now-completed FIXME/TODO
* TypeChecker
- Removed old type checking code for variable declarations with assignments
- Removed old type checking code for standalone variable assignments
2023-08-10 17:42:11 +00:00
|
|
|
run: chmod +x tlang
|
|
|
|
|
|
|
|
|
2023-03-26 11:18:50 +00:00
|
|
|
- name: Simple functions
|
|
|
|
run: |
|
|
|
|
./tlang compile source/tlang/testing/simple_functions.t
|
|
|
|
./tlang.out
|
2023-04-28 09:03:46 +00:00
|
|
|
- name: Simple functions (statement-level)
|
|
|
|
run: |
|
|
|
|
./tlang compile source/tlang/testing/simple_direct_func_call.t
|
|
|
|
./tlang.out
|
|
|
|
- name: Simple functions (recursive)
|
|
|
|
run: |
|
|
|
|
./tlang compile source/tlang/testing/simple_function_recursion_factorial.t
|
|
|
|
./tlang.out
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-04-12 06:59:19 +00:00
|
|
|
# TODO: Re-enable when we support the `discard` keyword again
|
|
|
|
#- name: Simple variables
|
|
|
|
# run: |
|
|
|
|
# ./tlang compile source/tlang/testing/simple_variables.t
|
|
|
|
# ./tlang.out
|
2023-03-26 11:18:50 +00:00
|
|
|
- name: Simple conditions
|
|
|
|
run: |
|
2023-04-12 07:04:11 +00:00
|
|
|
./tlang compile source/tlang/testing/simple_conditionals.t
|
2023-03-26 11:18:50 +00:00
|
|
|
./tlang.out
|
|
|
|
- name: Nested conditionals
|
|
|
|
run: |
|
|
|
|
./tlang compile source/tlang/testing/nested_conditionals.t
|
|
|
|
./tlang.out
|
|
|
|
- name: Simple function decls
|
|
|
|
run: |
|
|
|
|
./tlang compile source/tlang/testing/simple_function_decls.t
|
|
|
|
./tlang.out
|
|
|
|
- name: Simple function (only) decls
|
|
|
|
run: |
|
|
|
|
./tlang compile source/tlang/testing/simple_variables_only_decs.t
|
|
|
|
./tlang.out
|
|
|
|
- name: Simple variables decls assignment
|
|
|
|
run: |
|
|
|
|
./tlang compile source/tlang/testing/simple_variables_decls_ass.t
|
|
|
|
./tlang.out
|
|
|
|
- name: Simple while
|
|
|
|
run: |
|
|
|
|
./tlang compile source/tlang/testing/simple_while.t
|
|
|
|
./tlang.out
|
2023-03-26 11:29:36 +00:00
|
|
|
#- name: Simple do-while
|
|
|
|
# run: |
|
|
|
|
# ./tlang compile source/tlang/testing/simple_do_while.t
|
|
|
|
# ./tlang.out
|
2023-03-26 11:27:24 +00:00
|
|
|
- name: Simple for-loops
|
|
|
|
run: |
|
|
|
|
./tlang compile source/tlang/testing/simple_for_loops.t
|
|
|
|
./tlang.out
|
2023-03-26 11:28:56 +00:00
|
|
|
- name: Simple cast
|
|
|
|
run: |
|
|
|
|
./tlang compile source/tlang/testing/simple_cast.t
|
|
|
|
./tlang.out
|
|
|
|
- name: Simple pointer
|
|
|
|
run: |
|
|
|
|
./tlang compile source/tlang/testing/simple_pointer.t
|
|
|
|
./tlang.out
|
2023-04-17 14:50:11 +00:00
|
|
|
- name: Simple pointer cast (little endian)
|
|
|
|
run: |
|
|
|
|
././tlang compile source/tlang/testing/simple_pointer_cast_le.t
|
|
|
|
./tlang.out
|
2023-03-26 11:31:01 +00:00
|
|
|
- name: Simple extern
|
|
|
|
run: |
|
|
|
|
chmod +x extern_test.sh
|
|
|
|
./extern_test.sh
|
Array support (#1)
* Parser
- Added ability for `parseName()` to recognize array types
- Added array type handling to `parseTypedDeclaration()`
- Removed unneeded `derefCount` and comment in `parseTypedDeclaration()`
Check
- Added new symbol types `OBRACKET` and `CBRACKET`
* Tets cases
- We will now be using `simple_arrays2.t` as our testing bench for array support
* Dependency
- When a variable declaration has a kind-of type we are unaware of then print out an error message before asserting `false`
* 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
* Builtins
- Added information about the current bug faced in issue #81 (third sub-issue)
* Test cases
- Updated test case `simple_arrays2.t` to show case bug sub-issue 3 in issue #81
* 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
* Builtins
- Updated TODO
* Builtins
- Removed comment as now fixed
* Array
- Added `getComponentType()` method which will return the array's element type
* 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
* 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
* Tets cases
- Added new test case for testing (later) multi-dimensional stack-arrays
* Parser
- Working on adding array index assignment support
Test cases
- Added test case to test array assignments with
* 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
* Parser
- Handle the case whereby `SymbolType.ASSIGN` or `SymbolType.IDENT_TYPE` is not found by throwing an error
* Parser
- Moved logic for array assignments into the branch for it (deferred it)
* 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
* Expressions
- Added new parse node (a sub-type of `Expression`) for representing array indexing; `ArrayIndex`
Data
- Fixed compilation error caused by missing semi-colon
* 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
* Parser
- Removed now-completed TODO relating to array accesses in `parseExpression()`
* 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
* Instruction
- Added new instruction for indexing into arrays, a new `Value`-type instruction called `ArrayIndexInstruction`
* 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))
* 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
* 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
* DGen
- Added a stub emitter for `ArrayIndexInstruction` (pointer-based array indexing)
- Added a stub emitter for `StackArrayINdexInstruction` (stack-array based array indexing)
* INstructions
- Added `getArrayName()`, `getIndexInstr()` and `getAssignedValue()` to `StackArrayIndexAssignmentInstruction`
* 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`
* Test cases
- Added `complex_stack_arrays1.t`
- This tests a stack array of a fixed size of `int[]` (basically `int*`) and assigneing into it
* 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
* Test cases
- Added `simple_stack_arrays2.t` which tests a stack array of a fixed size and then assigns into it a value
* 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
* 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`
* 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
* 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)
* 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`
* Test cases
- WIP: Added `simple_stack_array_coerce.t` as we want to add coercion for this now
* Typecheck
- Added rudimentary check for checking if an argument is a stack array, and if the parameter (to a function call) is a pointer and if so then returns whether they have matching component types in a new function named `canCoerceStackArray(Type, Type)`
* Typecheck
- Fixed `canCoerceStackArray(Type, Type)` to actually coerce the first type first into a pointer type (coercing the stack array's component type to `<compType>*`) and THEN apply the `isSameType(Type, Type)` check
* Typecheck
- Hoisted up `canCoerceStackArray(Type, Type)` to the class-level of `TypeChecker`
- Removed debug prints from `canCoerceStackArray(Type, Type)`
- Added a TODO where the check should be done in the `FunctionCall` branch of the `DNode` processor
* TypeChecker
- Added a seperate check for function call `DNode` processing which now checks if we can coerce the stack-array-based argument to the pointer-based type parameter
Notes
- Emit now fails as we haven't implement an emit for this case, so we need to do that.
- Also, should we change the type of what is being passed in - perhaps that actually makes sense here - we haven't fully coerced it actually
* TypeChecker
- Updated `canCoerceStackArray(Type, Type)` to now take in `canCoerceStackArray(Type, Type, ref Type)` to set the newly created coerced type
- Fixed bug whereby if the coercion succeeded we didn't actually add to the list of evaluation-instructions in the `FuncCallInstr` object, hence there would be a `null` Instruction object appearing in the code emit phase.
- Added some NOTEs which we can clean up this code using
* TypeChecker
- Cleaned up commented-out code
* Added CI/CD test for 'simple_stack_array_coerce.t'
* Added CI/CD test for 'complex_stack_arrays1.t'
* Added CI/CD semantic tests (WIP) for 'simple_stack_array_coerce.t' and 'complex_stack_arrays1.t'
* Added CI/CD semantic tests (WIP) for 'simple_arrays2.t' and 'simple_arrays4.t'
* Added CI/CD semantic tests (WIP) for 'simple_arrays2.t' and 'simple_arrays4.t'
* Added CI/CD semantic tests (WIP) for 'simple_arrays2.t' and 'simple_arrays4.t'
* Fixed filepath for test 'simple_arrays.t'
* Fixed typechecking tests for arrays
* DGen
- Added instrumentation for `simple_stack_array_coerce.t`
Test cases
- Updated `simple_stack_array_coerce.t` to update the array passed in a manner such that we can sum the two elements later, return it and assert to ensure it is set correctly
* Parser
- Had to ensure the old identifier code was removed too, was too early; therefore this now-dead code was removed
* Test cases
- Added this test (even though it is a bad test, the syntax ie wrong)
* Test cases
- Update `simple_stack_arrsys4.t` to return an `int` such that we can verify it works.
- Also added more tests to it.
DGen
- Added semantic test code generation for `simple_stack_arrays4.t`
CI
- Re-organised tests for semantics in emit for arrays into those "Which have semantic tests" and "those which don't (yet)"
- Added semantic/emit test for `simple_stack_arrays4.t`
* Test cases
- Updated `simple_arrays2.t` to test casting of complex array types
* Test cases
- Updated `complex_stack_arrays1.t`
* Test cases
- Added new test for testing pointer syntax; `simple_stack_array_coerce_ptr_syntax.t`
- FIXME: It is broken as we don't have the latest pointer code - that must still be finished
* Test cases
- Added test case `simple_stack_array_ceorce_wrong.t` where coercion must fail
* Test cases
- Added `simple_pointer_array_syntax.t` which should test the `int[] == int*` stuff
* DGen
- Made semantic test for `simple_pointer_array_syntax.t`
Test cases
- Added a test for `simple_pointer_array_syntax.t.t`
* Branding
- Added logo here
* Test cases
- Addes semantic code emit instrucmentation for `simple_stack_array_coerce_ptr_syntax.t`
* Pipelines
- Added test case for `source/tlang/testing/simple_stack_array_coerce_wrong.t` for typechecking phase
* Test cases
- Added test case `complex_stack_array_coerce.t`
* Test cases
- Added extensive positive test case `complex_stack_array_coerce_permutation_good.t` which has a lot of different ways to write `int**` (think `int*[]` etc)
- Added negative test cases `complex_stack_array_coerce_bad1.t`, `complex_stack_array_coerce_bad2.t` and `complex_stack_array_coerce_bad3.t`
2023-04-20 09:21:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Array support
|
|
|
|
- name: Stack-based arrays simple
|
|
|
|
run: |
|
|
|
|
./tlang compile source/tlang/testing/simple_stack_arrays4.t
|
|
|
|
./tlang.out
|
|
|
|
- name: Stack-based array coercion (array syntax)
|
|
|
|
run: |
|
|
|
|
./tlang compile source/tlang/testing/simple_stack_array_coerce.t
|
|
|
|
./tlang.out
|
|
|
|
- name: Stack-based array coercion (pointer syntax)
|
|
|
|
run: |
|
|
|
|
./tlang compile source/tlang/testing/simple_stack_array_coerce_ptr_syntax.t
|
|
|
|
./tlang.out
|
|
|
|
- name: Stack-based array with normal array coercion (complex)
|
|
|
|
run: |
|
|
|
|
./tlang compile source/tlang/testing/complex_stack_array_coerce.t
|
|
|
|
./tlang.out
|
|
|
|
|
|
|
|
|
|
|
|
# TODO: Actually add semantic tests for these
|
|
|
|
- name: Complex stack-based arrays
|
|
|
|
run: |
|
|
|
|
./tlang compile source/tlang/testing/complex_stack_arrays1.t
|
|
|
|
./tlang.out
|
|
|
|
- name: Simple array
|
|
|
|
run: |
|
|
|
|
./tlang compile source/tlang/testing/simple_arrays.t
|
|
|
|
./tlang.out
|
|
|
|
- name: Simple array 2
|
|
|
|
run: |
|
|
|
|
./tlang compile source/tlang/testing/simple_arrays2.t
|
|
|
|
./tlang.out
|
|
|
|
- name: Simple array 4
|
|
|
|
run: |
|
|
|
|
./tlang compile source/tlang/testing/simple_arrays4.t
|
|
|
|
./tlang.out
|
|
|
|
|
|
|
|
|
2023-04-17 14:50:11 +00:00
|
|
|
- name: Simple pointer (malloc and free)
|
|
|
|
run: |
|
|
|
|
chmod +x malloc_test.sh
|
|
|
|
./malloc_test.sh
|
Array support (#1)
* Parser
- Added ability for `parseName()` to recognize array types
- Added array type handling to `parseTypedDeclaration()`
- Removed unneeded `derefCount` and comment in `parseTypedDeclaration()`
Check
- Added new symbol types `OBRACKET` and `CBRACKET`
* Tets cases
- We will now be using `simple_arrays2.t` as our testing bench for array support
* Dependency
- When a variable declaration has a kind-of type we are unaware of then print out an error message before asserting `false`
* 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
* Builtins
- Added information about the current bug faced in issue #81 (third sub-issue)
* Test cases
- Updated test case `simple_arrays2.t` to show case bug sub-issue 3 in issue #81
* 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
* Builtins
- Updated TODO
* Builtins
- Removed comment as now fixed
* Array
- Added `getComponentType()` method which will return the array's element type
* 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
* 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
* Tets cases
- Added new test case for testing (later) multi-dimensional stack-arrays
* Parser
- Working on adding array index assignment support
Test cases
- Added test case to test array assignments with
* 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
* Parser
- Handle the case whereby `SymbolType.ASSIGN` or `SymbolType.IDENT_TYPE` is not found by throwing an error
* Parser
- Moved logic for array assignments into the branch for it (deferred it)
* 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
* Expressions
- Added new parse node (a sub-type of `Expression`) for representing array indexing; `ArrayIndex`
Data
- Fixed compilation error caused by missing semi-colon
* 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
* Parser
- Removed now-completed TODO relating to array accesses in `parseExpression()`
* 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
* Instruction
- Added new instruction for indexing into arrays, a new `Value`-type instruction called `ArrayIndexInstruction`
* 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))
* 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
* 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
* DGen
- Added a stub emitter for `ArrayIndexInstruction` (pointer-based array indexing)
- Added a stub emitter for `StackArrayINdexInstruction` (stack-array based array indexing)
* INstructions
- Added `getArrayName()`, `getIndexInstr()` and `getAssignedValue()` to `StackArrayIndexAssignmentInstruction`
* 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`
* Test cases
- Added `complex_stack_arrays1.t`
- This tests a stack array of a fixed size of `int[]` (basically `int*`) and assigneing into it
* 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
* Test cases
- Added `simple_stack_arrays2.t` which tests a stack array of a fixed size and then assigns into it a value
* 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
* 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`
* 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
* 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)
* 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`
* Test cases
- WIP: Added `simple_stack_array_coerce.t` as we want to add coercion for this now
* Typecheck
- Added rudimentary check for checking if an argument is a stack array, and if the parameter (to a function call) is a pointer and if so then returns whether they have matching component types in a new function named `canCoerceStackArray(Type, Type)`
* Typecheck
- Fixed `canCoerceStackArray(Type, Type)` to actually coerce the first type first into a pointer type (coercing the stack array's component type to `<compType>*`) and THEN apply the `isSameType(Type, Type)` check
* Typecheck
- Hoisted up `canCoerceStackArray(Type, Type)` to the class-level of `TypeChecker`
- Removed debug prints from `canCoerceStackArray(Type, Type)`
- Added a TODO where the check should be done in the `FunctionCall` branch of the `DNode` processor
* TypeChecker
- Added a seperate check for function call `DNode` processing which now checks if we can coerce the stack-array-based argument to the pointer-based type parameter
Notes
- Emit now fails as we haven't implement an emit for this case, so we need to do that.
- Also, should we change the type of what is being passed in - perhaps that actually makes sense here - we haven't fully coerced it actually
* TypeChecker
- Updated `canCoerceStackArray(Type, Type)` to now take in `canCoerceStackArray(Type, Type, ref Type)` to set the newly created coerced type
- Fixed bug whereby if the coercion succeeded we didn't actually add to the list of evaluation-instructions in the `FuncCallInstr` object, hence there would be a `null` Instruction object appearing in the code emit phase.
- Added some NOTEs which we can clean up this code using
* TypeChecker
- Cleaned up commented-out code
* Added CI/CD test for 'simple_stack_array_coerce.t'
* Added CI/CD test for 'complex_stack_arrays1.t'
* Added CI/CD semantic tests (WIP) for 'simple_stack_array_coerce.t' and 'complex_stack_arrays1.t'
* Added CI/CD semantic tests (WIP) for 'simple_arrays2.t' and 'simple_arrays4.t'
* Added CI/CD semantic tests (WIP) for 'simple_arrays2.t' and 'simple_arrays4.t'
* Added CI/CD semantic tests (WIP) for 'simple_arrays2.t' and 'simple_arrays4.t'
* Fixed filepath for test 'simple_arrays.t'
* Fixed typechecking tests for arrays
* DGen
- Added instrumentation for `simple_stack_array_coerce.t`
Test cases
- Updated `simple_stack_array_coerce.t` to update the array passed in a manner such that we can sum the two elements later, return it and assert to ensure it is set correctly
* Parser
- Had to ensure the old identifier code was removed too, was too early; therefore this now-dead code was removed
* Test cases
- Added this test (even though it is a bad test, the syntax ie wrong)
* Test cases
- Update `simple_stack_arrsys4.t` to return an `int` such that we can verify it works.
- Also added more tests to it.
DGen
- Added semantic test code generation for `simple_stack_arrays4.t`
CI
- Re-organised tests for semantics in emit for arrays into those "Which have semantic tests" and "those which don't (yet)"
- Added semantic/emit test for `simple_stack_arrays4.t`
* Test cases
- Updated `simple_arrays2.t` to test casting of complex array types
* Test cases
- Updated `complex_stack_arrays1.t`
* Test cases
- Added new test for testing pointer syntax; `simple_stack_array_coerce_ptr_syntax.t`
- FIXME: It is broken as we don't have the latest pointer code - that must still be finished
* Test cases
- Added test case `simple_stack_array_ceorce_wrong.t` where coercion must fail
* Test cases
- Added `simple_pointer_array_syntax.t` which should test the `int[] == int*` stuff
* DGen
- Made semantic test for `simple_pointer_array_syntax.t`
Test cases
- Added a test for `simple_pointer_array_syntax.t.t`
* Branding
- Added logo here
* Test cases
- Addes semantic code emit instrucmentation for `simple_stack_array_coerce_ptr_syntax.t`
* Pipelines
- Added test case for `source/tlang/testing/simple_stack_array_coerce_wrong.t` for typechecking phase
* Test cases
- Added test case `complex_stack_array_coerce.t`
* Test cases
- Added extensive positive test case `complex_stack_array_coerce_permutation_good.t` which has a lot of different ways to write `int**` (think `int*[]` etc)
- Added negative test cases `complex_stack_array_coerce_bad1.t`, `complex_stack_array_coerce_bad2.t` and `complex_stack_array_coerce_bad3.t`
2023-04-20 09:21:50 +00:00
|
|
|
- name: Simple pointer (array syntax)
|
|
|
|
run: |
|
|
|
|
./tlang compile source/tlang/testing/simple_pointer_array_syntax.t
|
|
|
|
./tlang.out
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-03-26 11:51:35 +00:00
|
|
|
##################################
|
|
|
|
####### Deployment section #######
|
|
|
|
##################################
|
|
|
|
|
2023-03-26 12:11:43 +00:00
|
|
|
# deploy:
|
|
|
|
# needs: [build, unittests, typecheck, syntaxcheck, emit]
|
|
|
|
# name: Deply alpha build
|
|
|
|
# runs-on: ubuntu-latest
|
|
|
|
# steps:
|
|
|
|
# - uses: actions/checkout@v2
|
|
|
|
# - name: Download tlang compiler
|
|
|
|
# uses: actions/download-artifact@v3
|
|
|
|
# with:
|
|
|
|
# name: tbin
|
|
|
|
|
|
|
|
# - uses: "marvinpinto/action-automatic-releases@latest"
|
|
|
|
# with:
|
|
|
|
# repo_token: "${{ secrets.YES_TOKEN_DEPLOY }}"
|
|
|
|
# automatic_release_tag: "latest"
|
|
|
|
# prerelease: true
|
|
|
|
# title: "Development Build"
|
|
|
|
# files: |
|
|
|
|
# tbin
|
2023-03-26 11:51:35 +00:00
|
|
|
|
|
|
|
|
2023-03-26 11:28:56 +00:00
|
|
|
|
2023-03-26 11:27:24 +00:00
|
|
|
|