954: HIR Visitor refactoring r=philberty a=dkm
This change split the single HIR visitor in smaller abstract ones:
- Stmt
- VisItem
- Pattern
- ExternalItem
- Impl
- Type
- Expression
Instead of providing a Base class with empty visit() methods, they are kept
abstract to avoid the case where a missing visit() is silently ignored:
implementors must explicitely override all visit.
There is also a FullVisitor that covers all HIR nodes and also provides a Base
class with empty behavior.
fixes#825
Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
Co-authored-by: Marc Poulhiès <dkm@kataplop.net>
This change split the single HIR visitor in smaller abstract ones:
- Stmt
- VisItem
- Pattern
- ExternalItem
- Impl
- Type
- Expression
Instead of providing a Base class with empty visit() methods, they are kept
abstract to avoid the case where a missing visit() is silently ignored:
implementors must explicitely override all visit.
There is also a FullVisitor that covers all HIR nodes and also provides a Base
class with empty behavior.
fixes#825
Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
974: Add support for ranges and index lang items along with the TyTy::SliceType r=philberty a=philberty
This PR contains more code to begin supporting Slices which requires support
for more intrinsic, range and index lang items. More work is needed to support
slices such as the const_ptr lang item and the offset intrinsic but this is a big
PR already and adds support for more lang items along the way.
Fixes#975
Addresses #849
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
This reuses our code to resolve operator overloads to call into the index
lang item for the array-index-expression this serves as a basis for
supporting slices.
Fixes#975
This means we can reuse the same code for operations that are not
HIR::OperatorExpr's such as ArrayIndexExpr which can resolve to
core::ops::index lang items.
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>
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#960Closes#961
Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
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>
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.
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>
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>
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>
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>