aboutsummaryrefslogtreecommitdiff
path: root/gcc
AgeCommit message (Collapse)AuthorFilesLines
2021-03-01Adds the same support from generic structs in #235 onto tuple structsPhilip Herron6-52/+89
Type binding still not supported here but the same generic support is added to tuples. Fixes #236
2021-03-01Support Generic arguments to StructsPhilip Herron32-291/+1169
This removes StructFieldType from the TyTy base as it is not a type that can be unified against. It adds in a substition mapper implementation which will likely change over time when this this support is extended over to Functions and TupleStructs. Note generic argument binding is not supported as part of this yet. Fixes #235
2021-03-01Update default configs in ExpansionCfgNala Ginrut1-4/+7
2021-02-22Reformat all files in gcc/rust/typecheckAkshat Agarwal7-14/+19
Signed-off-by: Akshat Agarwal <humancalico@disroot.org>
2021-02-19Fixed unsigned and signed comparisionYizhe1-3/+3
2021-02-19Removed `base` field from `BaseRules`Yizhe1-23/+69
Now the base(pointer to Ty) is only stored in derived rules. It is accessible in `BaseRules` with `get_base` method, which is implemented in derived rules.
2021-02-19Renamed `BaseRules::equals` back to `BaseRules::is_equal`Yizhe2-17/+17
Initially I thought `equals` is a better name because it fits the java usage. However there will be another `can_eq` method that adjust types, and in that case `is_equal` is a more consistent name.
2021-02-19Added `equals` method to `BaseType`Yizhe2-5/+154
The resulting code looks quite similar to `unify`, except that it doesn't save refs, so it should be more efficient. However the introduced complexity is a bit worrying. This commit also adjusted some const qualifiers of `BaseType` methods where necessary.
2021-02-19Added some doc for BaseRules and BaseTypeYizhe2-2/+37
2021-02-19Renamed `combine` to `unify`Yizhe10-97/+97
2021-02-19Renamed `TyBase` to `BaseType`Yizhe24-317/+317
2021-02-19Format all files in gcc/rust/ using clang-formatAkshat Agarwal15-119/+122
Signed-off-by: Akshat Agarwal <humancalico@disroot.org> This commit formats all files in gcc/rust using clang-format.
2021-02-18Add debug interface to GCC debug_tree on GENERIC graphsPhilip Herron2-0/+17
This adds in a debugging interface for the backend IR to help diagnose issues with the tree.
2021-02-18remove ast/clone-test.hAkshat Agarwal1-108/+0
Signed-off-by: Akshat Agarwal <humancalico@disroot.org> Fixes: #99
2021-02-13Add ReferenceType with BorrowExpr and DereferenceExprPhilip Herron25-18/+370
This also adds in the mising InferenceType _ which was mostly implemented before as part of Data Structures 1. We create GENERIC REFERENCE_TYPES for these this is the building block to finish work on mutability rules and pointers. Fixes: #196 Addresses: #169 #170
2021-02-13Add char typePhilip Herron13-0/+155
This might need changes in the Lexer to allow for wchar_t to be preserved. Addresses #85
2021-02-13Fix parsing of Char literalsPhilip Herron1-0/+4
2021-02-13Add in ContinueExpr supportPhilip Herron11-85/+335
We made an implicit loop begin label that can be referenced in a goto to restart the loop. Fixes #188
2021-02-13Add in while loop supportPhilip Herron10-7/+183
We create a LoopExpr comprising of: LOOP_EXPR { EXIT_EXPR (while loop predicate) { <LOOP_BODY> } } Fixes #109
2021-02-13Fix bug parsing while loop expressionsPhilip Herron2-14/+32
If a while loop is part of an expression it needs to know it does not need to skip token.
2021-02-11Merge branch 'master' of https://github.com/redbrain/gccrsSimplyTheOther46-461/+1216
2021-02-10Add support to break from loops with a valuePhilip Herron5-4/+119
This adds support to make the break value assignable such that the loop now becomes akin to a BlockExpr Fixes #108 #106
2021-02-10Add check for break outside of a loop.Philip Herron8-55/+85
This will be needed to stop the compiler proceding to continue and break expressions without a loop context.
2021-02-10Support LoopLabels and break to label.Philip Herron7-7/+97
This allows for the Rust refernece example for loop labels to be compiled. Fixes #107
2021-02-10Return expressions can be empty which us unit-typePhilip Herron4-7/+33
The parser has the same bug as in #225 for break expressions. This tidies up the type resolver and GENERIC translation to handle the case where there is no return expression as well. Fixes #226
2021-02-10Support Break without label and expressionPhilip Herron17-64/+262
This reuses GENERICS LOOP_EXPR and EXIT_EXPR to implement the infinite loop. Addresses: #106 #108
2021-02-10Introduce new label namesapce for name resolutionPhilip Herron4-1/+55
Labels are in their own namesapce so they do not affect types and normal values within a program. Addresses #107
2021-02-10Give ParseRestriction option to allow for null parse_expr.Philip Herron2-4/+9
The null_denotion function expects to find the beginning of an expression but breaks can be empty and the parser will fail with unexpected ';'. Fixes #225
2021-02-10Support Simple LoopExprPhilip Herron7-0/+65
This is the building block for the rest of loops where we have a basic infinite loop. Break/Continue reliest on the resolution of labels and breaks can also make a loop into a BlockExpr Fixes #106
2021-02-10Fix parse of LoopExpr as part of a normal expressionPhilip Herron2-9/+27
For example this fixes the form of: let x = loop { ... }; Fixes #219
2021-02-10Enable -frust-dump-all option for debuggingPhilip Herron5-106/+230
We output each debug IR to file which makes it easier to debug larger test cases. Beaware not all dumps are complete such as name resolution is not implemented yet, HIR is badly formatted and type resolution dump is not finished.
2021-02-10Fix parsing |= as a compound assignment expression.Philip Herron2-2/+3
Fixes #173
2021-02-09Fix bad type resolution for CallExpr when fn is not simply PathInExpressionPhilip Herron3-82/+69
When we have a function that is for example a FieldAccessExpression the compiler must resolve and compile that field into a reference which can be called. This is not simple direct call to a function in that senario. Fixes #217
2021-02-09Fixes parsing if expressions as part of an expression.Philip Herron3-10/+50
This allows for rust style ternery expressions. Fixes #214
2021-02-09Conditional blocks with else can resolve into a non unit type expression.Philip Herron4-15/+80
When we compile if blocks the else gives us a final branch that can resolve. Single IfExpr cannot resolve as there is no final branch. This also fixes a small regression in compiling elif blocks where the gimple body was empty. Fixes #213
2021-02-09Unified Tokens partially in preparation for macro expansionSimplyTheOther5-179/+63
2021-02-07With the merge of BlockExprsPhilip Herron7-142/+81
Further testing found regressions with implicit returns and type resolution. This unifies the type resolution in block expressions to be more strict and ensure everything bar the final statement should be UnitType.
2021-02-07General cleanup of AST and macro expansion-related thingsSimplyTheOther7-923/+396
2021-02-07Merge branch 'master' of https://github.com/redbrain/gccrsSimplyTheOther55-867/+2075
2021-02-06Fix overloaded virtual and unused parameters warningsPhilip Herron6-442/+386
2021-02-06Add in support to compile Methods and MethodCallExprPhilip Herron28-223/+1170
There is more work to be done here with adjustments to the self argument such as borrows and mutability checking. Method resolution is basic, for now there is code to scan for all possible matches but traits are not supported at the moment so this resolves quite simply for now. Fixes #191 #112
2021-02-06Support Self used within impl blocksPhilip Herron6-6/+68
This is simply a type reference so we can use the name resolver to resolve Self as a type reference back to the Type used for the impl block. Fixes #204
2021-02-06Fix unreachable crash when a struct contains another algebraic data typePhilip Herron2-2/+18
When we have a nested struct this must resolve to the existing compiled struct and not create a new record type.
2021-02-06Move scan for unused names to be after type resolutionPhilip Herron6-59/+43
Methods are resolved as part of type resolution so scanning ribs early on will results in false warnings about unused methods.
2021-02-06This adds support for basic BlockExpressionsPhilip Herron11-117/+236
We keep temporary's for each block in order for the result to be referenced. For example: let x = { test() + 1 }; This can be resolved into: { let x:i32; _tmp1:i32; { _tmp2:i32 = test(); _tmp1 = _tmp2 + 1; } x = _tmp1; } Fixes #189
2021-02-06Enforce Duplicate definition rulesPhilip Herron10-23/+159
Rust does not allow functions/methods/constants/static definitions to shadow otherwise you end up with unuseable items.
2021-02-06Rewrote MetaNameValueStr to store raw string rather than quoted stringSimplyTheOther2-41/+17
2021-02-06Added more debug for cfg expansionSimplyTheOther1-0/+6
2021-02-06Added even more debug for cfg predicate checkingSimplyTheOther3-1/+8
2021-02-06Added more debug for cfg predicate checkingSimplyTheOther1-0/+7