aboutsummaryrefslogtreecommitdiff
path: root/gcc
AgeCommit message (Collapse)AuthorFilesLines
2021-03-09Cleanup HIR::Function to make fields privatePhilip Herron11-37/+111
This is a refactoring/cleanup effort to stop using raw fields of HIR::Items. It also removes an old set of locals since before the TyTy module and move to HIR from the AST::Function.
2021-03-09Separate function definitions from function pointers.Philip Herron17-46/+359
Function definitions can have substations (generics) where as function pointers cannot. These are distinct elements and their separation is important to support wildcards (inference variables) on BareFunctionTypes. To fix this the patch leverages the wrapper TyCtx which denotes a type that must be infered. Fixes #269
2021-03-09Cleanup Formatting for is_equal on TupleTypesPhilip Herron1-17/+10
2021-03-09Introduce TyCtx wrapper over TyTy Types with elements than can change.Philip Herron6-77/+88
ArrayTypes for example can have an inference variable for an element type which requires the Type system to lookup what type it is when requested. TyCtx acts as this wrapper that takes an HirId reference that cleans up the code for ArrayTypes, ReferenceTypes and TupleTypes where elements can be inference variables.
2021-03-09Missing const on methodPhilip Herron2-2/+2
Getting mappings can be const in order to get mappings info on Types.
2021-03-09Fix bug when using general inference variablesPhilip Herron2-2/+11
When we have a General inference G? variable as part of an array that is unified with integeral inference variables I? the context left the General inference variable but really this changed to tbe I? and can default to i32. Fixes #258
2021-03-05Remove useless file.Marc Poulhiès1-71/+0
fix #98
2021-03-03Add in TyTy support for an initial String LiteralPhilip Herron13-5/+145
This gives the apropriate reference type over const char *. Fixes #85
2021-03-02Add missing copright headerPhilip Herron1-3/+21
2021-03-01Fix bad type resolution on deadcode1.rs and implicit_return_err1.rsPhilip Herron2-4/+4
There was a subtle tweak to checking wether this is the actual final statement of the block to verify the types.
2021-03-01Ensure compilation fails when Struct is constructed with CallExprPhilip Herron3-10/+22
CallExpr is only used for TupleStructs, so this needs to refelect rustc behaviour.
2021-03-01Fix bug when assembling function names with :: in the symbolPhilip Herron1-3/+3
When the assembler comes along Foo::new as a symbol name it will fail we need name mangling to fix this properly.
2021-03-01If the compiler crashes we fail the testYizhe1-1/+2
2021-03-01Fix formattingYizhe5-50/+54
2021-03-01Modify the parser to use the new enumsYizhe1-82/+82
2021-03-01Modify AST and HIR code to use the new enumsYizhe5-75/+85
2021-03-01Cleanup AST-to-HIR loweringYizhe1-108/+28
With AST and HIR using the same operator enum, we no longer need to perform conversions. Except for CompoundAssignmentExpr, which gets compiled away and therefore still needs conversion.
2021-03-01Remove the last trace of the Operator enum #2Yizhe2-14/+0
Missed a few lines in the last attempt. Whoops.
2021-03-01Fix typoYizhe5-16/+16
2021-03-01Remove the last trace of the Operator enumYizhe1-87/+19
Now that everyone uses the 4 enums in the global namespace, the process of lowering HIR to Bexpression can be simplified by removing the intermediate translation.
2021-03-01Rewrite backend to accept the new enumYizhe2-142/+227
Gcc_backend::unary_expression and Gcc_backend::binary_expression has been split into 4 smaller functions corresponding to the 4 enums. It turns out that keeping the 4 enums distinct helps simplify the logic a lot. A lot of if-else branches were eliminated just by inlining the type infomation. There were also some minor cleanup. `operator_to_tree_code` function has been modified to omit the `tree` parameter and offload floating-point check to the caller.
2021-03-01Extract enums into the global namespaceYizhe3-159/+75
`operator.h` has been rewritten from scratch. 5 enums are extracted from the AST namespace, while only 4 of them are used in the HIR namespace. There're still code that uses the old Operator enum. We also need to change code that uses the AST enum to point to the new global enum.
2021-03-01Fix to parse inner attribute correctlyNala Ginrut1-75/+87
2021-03-01Add some more error handling to genericsPhilip Herron9-7/+63
Check for wrong number of arguments and fix crash with invalid Type specified as generic argument.
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