Commit Graph

192641 Commits

Author SHA1 Message Date
Philip Herron 3b3079eba5 Cleanup error handling on array index expression type resolution 2022-02-24 15:55:35 +00:00
Philip Herron 7d6579c2fa Fix ICE as infered is nullptr at this point 2022-02-24 15:43:00 +00:00
Philip Herron 2975f11436 Add index and index_mut lang item mappings 2022-02-24 14:54:34 +00:00
Philip Herron 0033df1a52 Refactor ArrayIndexExpr typechecking into cc impl file 2022-02-24 14:30:15 +00:00
Philip Herron 833c439a50 Add boilerplate for the new SliceType 2022-02-24 12:47:57 +00:00
Philip Herron a6dd242845 Refactor ArrayIndexExpr code into implementation cc file 2022-02-24 11:59:19 +00:00
Philip Herron 7d4845bc95 Add code generation for range expressions 2022-02-24 11:49:51 +00:00
Philip Herron fa21267280 Fix TyTy::ADTType is_equals to always check the variants for equality 2022-02-24 11:20:19 +00:00
Philip Herron a64983f86c Add typechecking for range expressions
This looks up the relevant lang items and constructs their algebraic data
types with the specified range types for the substitution argument.
2022-02-24 11:19:23 +00:00
Philip Herron 1c3af63eae Add missing range mapping lang item 2022-02-24 11:19:23 +00:00
Philip Herron ac17ed5f5e Add HIR lowering for range expressions 2022-02-24 11:19:23 +00:00
Arthur Cohen 8cc50f2d23 builtin_macros: Add test for file!() 2022-02-23 15:53:15 +01:00
Arthur Cohen 62ab4d6bf1 builtin_macros: Add make_string helper 2022-02-23 15:53:15 +01:00
Arthur Cohen 986b8c3c60 builtins: Add file!() macro 2022-02-23 15:44:21 +01:00
bors[bot] bf92a10122
Merge #969
969: Add builtin macros framework r=CohenArthur a=CohenArthur

This PR adds bases to define new builtin macro functions.

Since we operate at the `insert_macro_def` level, this requires builtin macros to be defined, as is the case in the rust standard library:

```rust
    macro_rules! assert {
        ($cond:expr $(,)?) => {{ /* compiler built-in */ }};
        ($cond:expr, $($arg:tt)+) => {{ /* compiler built-in */ }};
    }
```

Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
2022-02-23 13:37:07 +00:00
Arthur Cohen 48b3fe622e macros: Add optional builtin transcribers to MacroRulesDefinition 2022-02-23 14:36:11 +01:00
Arthur Cohen 0b46175fb8 macro: Add source containing builtin definitions
Co-authored-by: philberty <philip.herron@embecosm.com>
2022-02-23 14:36:11 +01:00
bors[bot] 10de9cf4f3
Merge #956
956: Substitute repetitions r=CohenArthur a=CohenArthur

Needs #955 

This PR splits up the `substitute_tokens` function into multiple smaller functions. Still a draft until I can get repetitions working.

Closes #960 
Closes #961 

Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
2022-02-23 09:17:08 +00:00
Arthur Cohen 92a62562c8 substitute_repetition: Correctly insert sub-fragments 2022-02-23 10:13:06 +01:00
Arthur Cohen 1f546e5e3a match_repetition: Set the correct amount of matches for each fragment
Co-authored-by: philberty <philip.herron@embecosm.com>
2022-02-23 10:13:06 +01:00
bors[bot] e0f261f1ae
Merge #953
953: Refactor lang item mappings r=philberty a=philberty

This refactors how we find our lang items so that during HIR lowering
we have a generic outer attributes handler on Items. The old code only
done lang item mappings during the type check pass and assumed all
lang items are Traits which is not the case. To implement slices range
syntax actually map to structs within libcore/ops/range.rs which have
lang items on structs. This means we can have lang items on any Item.

Co-authored-by: Philip Herron <philip.herron@embecosm.com>
2022-02-22 16:25:07 +00:00
Philip Herron 865aa0aeb5 Add new Builtin attributes mappings
This class keeps track of all known builtin attributes and specifies which
pass they are handled at. This replaces the checks we added for outer
attributes during hir lowering making it a more maintainable data
structure.
2022-02-22 16:19:30 +00:00
Philip Herron 9bdc5462f2 Add mappings for range lang items 2022-02-22 15:17:36 +00:00
Philip Herron bede822298 Refactor mapping any lang items to be done during HIR lowering
This extracts a common way of handling outer attributes on Items to improve
error handling and make lang item mappings more generic.
2022-02-22 15:17:36 +00:00
Philip Herron 87aeea2583 Refactor lang item mappings enum into its own header 2022-02-22 15:17:36 +00:00
Arthur Cohen 6db51e3936 subs_repetition: Add simple test cases 2022-02-22 12:06:27 +01:00
Arthur Cohen ded1aca902 substitute_repetition: Substitute repetitions properly 2022-02-22 12:06:27 +01:00
Arthur Cohen 143aad62e1 substitute_repetition: Add parsing of repetition pattern 2022-02-22 12:05:58 +01:00
Arthur Cohen ae1f91a698 transcribe: Move substitute_metavar in its own function 2022-02-22 11:57:19 +01:00
bors[bot] 265c223766
Merge #964 #965
964: Forbid unresolved test cases r=CohenArthur a=CohenArthur

Closes #923 

965: macro-invoc-lexer: Split implementation in its own file r=CohenArthur a=CohenArthur

Closes #949 

Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
2022-02-22 10:05:34 +00:00
bors[bot] 133beb6d0f
Merge #955
955: matched_fragment: Track and set fragment match amount r=CohenArthur a=CohenArthur



Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
2022-02-22 09:39:25 +00:00
Arthur Cohen 91aca2c19e matched_fragment: Track and set fragment match amount
Co-authored-by: philberty <philip.herron@embecosm.com>
2022-02-22 10:38:39 +01:00
Arthur Cohen 4e19c2f792 macro-invoc-lexer: Split implementation in its own file 2022-02-21 17:27:56 +01:00
Arthur Cohen 9b36f95366 testsuite: Add -fdump-tree-gimple to inline1.rs 2022-02-21 17:01:10 +01:00
Arthur Cohen 737873ca87 ci: Do not allow unresolved test cases 2022-02-21 16:39:06 +01:00
bors[bot] 796465596f
Merge #950
950: Match macro repetitions r=CohenArthur a=CohenArthur

This PR adds support for matching macro invocations and counting the amount of times they've been matched

Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
2022-02-20 14:34:37 +00:00
bors[bot] 4e096b1f14
Merge #951
951: Add name resolution to slices r=philberty a=philberty

This is the first part to support slices where we complete the name
resolution of the SliceType with its element as well as the range
expressions used in construction.

This patch also includes separation of the implementation from the
headers to try and incrementally improve build speed.

Addresses #849 

Co-authored-by: Philip Herron <philip.herron@embecosm.com>
2022-02-20 14:03:54 +00:00
Arthur Cohen d0d4dcfdb4 macro: Add repetition execution test cases 2022-02-18 16:46:10 +01:00
Arthur Cohen af789a7079 macros: Add test cases for repetitions 2022-02-18 16:46:10 +01:00
Arthur Cohen ad7e4bb6f8 macro-repetitions: Match repetitions properly 2022-02-18 16:46:10 +01:00
bors[bot] 31387e7609
Merge #944
944: parser: Add `clear_errors()` method r=CohenArthur a=CohenArthur

Clears all errors from the error table so we can reuse the parser in later situations. I'm unsure whether or not the method should also emit all of the errors if present? In that case, we might want to rename it or add another wrapper that emits then clears

Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
2022-02-18 14:43:08 +00:00
Philip Herron 3dd4ce76a6 Add name resolution to range expressions 2022-02-18 13:26:24 +00:00
Philip Herron 755d0e5adf Refactor AST::ResolveExpr into its own cc file 2022-02-18 13:07:13 +00:00
Philip Herron de08987dc7 Add name resolution to AST::SliceType 2022-02-18 12:55:14 +00:00
Philip Herron 78cdc6ca31 Refactor type name resolution into their own .cc file 2022-02-18 12:46:44 +00:00
bors[bot] 425905b49a
Merge #942
942:  Removed Lambda Function within AST::PathPattern r=philberty a=mvvsmk

Addresses issue #717 
1) Changed the rust-path.h and removed the iterate_path_segments
   fuction.
2) Removed the lambda fuction form rust-ast-lower.cc and replaced it
   with a for loop.

Do let me know if I missed anything or could improve on something.

Signed-off-by : M V V S Manoj Kumar <mvvsmanojkumar@gmail.com>



Co-authored-by: M V V S Manoj Kumar <mvvsmanojkumar@gmail.com>
2022-02-18 11:50:32 +00:00
Arthur Cohen 472c0a3057 macro-repetition: Rename enum variants to better reflect repetition kind 2022-02-18 11:18:03 +01:00
Arthur Cohen 5f35a8c637 parser: Add `clear_errors()` method 2022-02-18 09:19:04 +01:00
bors[bot] fbe22e8768
Merge #940
940: Add more location info to AST structures r=CohenArthur a=CohenArthur

Two classes still remain locus-less: `TupleStructItems` and `TuplePatternItems` as I do not believe they are constructed at the moment.

Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
2022-02-18 08:14:30 +00:00
Arthur Cohen 0e15b89839 struct pattern: Add location on struct name 2022-02-18 09:10:55 +01:00