aboutsummaryrefslogtreecommitdiff
path: root/gcc
AgeCommit message (Collapse)AuthorFilesLines
2021-01-18Add struct_field_expression supportPhilip Herron7-2/+100
This adds in struct field expressions and should be generic enough for tuples later on.
2021-01-17Fix the naming of VAR_DECLS within gimple nodes.Philip Herron1-5/+14
This was using LetStmt->Pattern.as_string which included mut in the string dump. This makes the gimple nodes harder to debug as the name is (mut a) insteaad of a for example.
2021-01-17Handle forward references in backend compilationPhilip Herron5-5/+36
We must ensure the backend can support compilation of things declared lexically after they are referenced. This scans the toplevel except functions which are handled as we reference them. To make that generic enough for all toplevel items will be a move to query based compilation which still needs planning.
2021-01-17Support GroupedExpr'sPhilip Herron5-0/+39
This makes the expression handling support exprs within parens. Such as: x = (2*a) + 3;
2021-01-17grouped expr wipPhilip Herron1-0/+5
2021-01-17This adds supports for tuplesPhilip Herron13-22/+184
More testing is required but this adds tuples apart from TupleStructs which are parsed as CallExpr. This will be the primitives required to finish that work.
2021-01-16Enforce type checking on implicit returnsPhilip Herron18-116/+375
This change enforces strict type checkon on all ExprWithBlock. This includes unreachable tail expressions. Specific test cases have been added for context to ensure the failure cases are hit accordingly. This change also improves the diagnostic errors for mismatched types where the reference HirId was lost leading to default locations.
2021-01-16This brings in resolution and type checking of the unit-type.Philip Herron21-22/+198
It is possible to assign and declare variables of unit-type which translate down to zero sized void_type_node. More work is needed to handle array and ADT types using unit-type when emiting gimple. The name+type resolution should be generic enough.
2021-01-11Mark DECL_PUBLIC for main fn or functions with visibility.Philip Herron1-2/+16
This change will need more thought later when it comes to traits and generics etc. Fixes #136
2021-01-10Add in a check for unused decls within ribs.Philip Herron15-40/+159
This lead to cleanup of the name resolver as the usage of mappings means that in a given rib if there are no references to a decl NodeId that means it was not used. To get on par with the offical rust compiler it should be allowed to have a reference where the name was assigned but not used but this might be a seperate pass.
2021-01-09Functions with parameters much receive their own scoping RibPhilip Herron2-16/+14
This means that paramters are scoped and shadowed correctly. Currently the resolver is treating all paramters are shadowing each other if they have the same name which is incorrect.
2021-01-09Fix crash when compiling BlockExpr'sPhilip Herron2-0/+15
This ensures the compiler respects scoping and shadowing rules of blocks added within an enclosing scope.
2021-01-09There was a bug with LetStmts where we name resolved the identifierPhilip Herron2-3/+7
pattern first before the init expression. This lead to a situation where shadowing rules were broken. Example: let x = 1; let x = x + 1; In this example the code was referencing the 2nd LetStmt as the resolved name for the Identifier reference.
2021-01-09Make TyTyVisitor a pure abstract classPhilip Herron10-70/+185
This will help enforce consistency of visitors to fix issues with TyTy unification rules.
2021-01-08Respect the f32 and f64 suffix on literalsPhilip Herron5-16/+36
Rust is permissive for integers being marked as floats so the check in the lexer can be removed here.
2021-01-08Implicit Returns support.Philip Herron21-105/+387
For implict returns we must consider cases with a block having multiple returns: HIR::BlockExpr Stmts { ... return x } HIR::BlockExpr final_expression { x + 1 } Although the code above is bad this is valid rust code and the rust compiler correctly identifies the final_expression as unreachable. This dead code eliminiation is done as part of AST to HIR lowering. Type resolution examines all blocks to identifiy if they terminate a function with a return/final expression it must correspond accordngly. If the block is the final block the resulting termination of the block must match the return type of the function, else the block must conform to unit type.
2021-01-08Add test to cover handling hex, binary and octal number literals.Philip Herron2-3/+12
This also ensure the type suffix is respected against the number.
2021-01-06Add in support to compile static variables. Still requires name manglingPhilip Herron11-2/+102
for the ASM name similar to functions.
2021-01-06Fix bad naming of f64 named type in GIMPLE.Philip Herron1-1/+1
2021-01-06Add in F32 and F64 types builtin types.Philip Herron10-0/+155
We need to ensure all suffix of literals are handled in a subsequent PR.
2021-01-06Examine the Suffix hint on integers to apply apropriate TyTy type.Philip Herron17-83/+197
This change propagates the PrimitiveCoreType to AST and HIR so the suffix can be examined.
2021-01-06This brings structs back in post HIR changes. It supports structsPhilip Herron29-88/+933
where no base struct is referenced and the constructor is in order.
2020-12-25Implement constant expressionsPhilip Herron11-1/+109
2020-12-23Remove impl_block test. This is part of the next milestone and we wantPhilip Herron1-14/+0
to turn on CI build failure if any test fails and this will block that change until the next milestone if not removed.
2020-12-23Implement compilation of ArrayElemsCopied to GIMPLEPhilip Herron7-15/+96
let mut array = [123; 5]
2020-12-23This brings arrays back into the new framework. It resolves ArrayTypePhilip Herron18-30/+442
ArrayExpr, ArrayExprElems and ArrayIndexExpr. Still need to do ArrayElemsCopied. I expect there to be some changes to cleanup the rust-tyty-resolver this code is to resolve all ribs within a scope but its getting a bit hairy in there now.
2020-12-23Bring conditionals back since the HIR change.Philip Herron19-41/+733
2020-12-23Add missing license textNym Seddon28-1/+499
Add GPL license text to files without the header
2020-12-23Shadowing rules are done as part of name resolution.Philip Herron3-2/+19
When a new name is defined the name resolver freezes the previous declartion such that all new references point to the latest decl. This patch fixes a crash when we shadow and get a type mismatch and the combination of types fails. See the failure test case for the crash.
2020-12-23Fix minor typo in visibility as_stringNym Seddon1-1/+1
2020-12-19When compiling a block it might reference a GIMPLE node that is notPhilip Herron3-14/+16
resolved yet. Such as: fn main() -> i32 { call() } fn call() -> i32 { return 1; } The compilation pass acts on the first function main and detects the other node call is not compiled yet we can go resolve it. This is a toplevel item since it has a local_def_id and therefore it has a NULL enclosing scope for the block. Fixes #72
2020-12-19Add type unification as part of typecheck.Philip Herron11-10/+216
Rust must examine each usage of a name and unify their types. For example: let mut x; x = 1 This means the declaration is determined to be an inference variable then the assignment can be resolved to an Integer TyTy which can be combined as part of the rules to now make the let x decl be an i32.
2020-12-17This is a new HIR -> GIMPLE pass it reuses the mappings from hir,Philip Herron32-99/+1738
name resolution and type resolution to simplify the generation of gimple.
2020-12-17Remove old analysis framework and strip the AST->GIMPLE pass this needsPhilip Herron14-6389/+103
to use the new name and type resolution pass contexts.
2020-12-17TypeResolution pass now with a TyTy modulePhilip Herron36-243/+2039
Resolution must implement the Gathering specified in the rust-dev guide. We need to be able to handle cases such as: let mut x; x = 1; or let mut x = vec!{} x.push(1) Now the TyTy module has a combine abstract method to allow the combination of types to condense down from their integral parts.
2020-12-17This sets up a name resolution framework trying to follow rust-dev guidePhilip Herron23-145/+1329
We can use the NodeId from the AST to generate apropriate mappings for all names and types. Ribs are the scopes for names being instansiated, and reference to defintion tables allows all names to be resolved to NodeId's. Later on NodeIds will map over to HIR ids allowing for type resolution.
2020-12-17Add AST->HIR lowering passPhilip Herron11-5/+1052
This is the initial pass to move the AST to HIR. It is very extensible and easy to maintain now.
2020-12-17Add in HIR TreePhilip Herron14-0/+19882
This is an IR based off the AST its almost a copy but with NodeMappings on the parent Tree Types. This should ideally have all macro tree's removed during the lowering process.
2020-12-17Add generated NodeId's to the ASTPhilip Herron5-290/+481
NodeIds are going to be used for Hir->Ast lookups later on.
2020-12-17Cleanup Makefile for RustPhilip Herron1-8/+25
This adds some extra Flags to ignore unused warnings and no overloaded-virtuals. This helps with compilation error diagnosis.
2020-12-17Introduce HIR MappingPhilip Herron5-2/+582
This is the start of a bigger refactor of the compiler to follow the rustc internals. This introduces a mapping system for. - HirId which maps to any Hir Node within the current crate - LocalDefId any toplevel Hir Node HIR::Item within current crate - NodeId maps any AST node akin to HirId such that they can map back - DefId Cratea and localDefId combination
2020-12-17tweak to rust-system.h includesPhilip Herron1-1/+2
2020-12-14Prevented several warnings about unused parametersSimplyTheOther3-33/+33
2020-12-14Improved use tree parsingSimplyTheOther1-182/+245
2020-12-13Added location storage for struct expr fieldsSimplyTheOther2-28/+44
Fixed typo in an enum expr field class
2020-12-13Modified binding power used when parsing expression inside index exprSimplyTheOther1-4/+6
2020-12-13Fixed SimplePath's operator == not being constSimplyTheOther1-1/+1
2020-12-13Attempt to fix array parsing errorsSimplyTheOther4-5/+34
2020-12-10Enhanced dumping of expansionSimplyTheOther1-9/+8
2020-12-10Fixed BlockExpr not being allowed to be emptySimplyTheOther1-8/+8