Age | Commit message (Collapse) | Author | Files | Lines |
|
This adds in struct field expressions and should be generic enough for
tuples later on.
|
|
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.
|
|
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.
|
|
This makes the expression handling support exprs within parens. Such as:
x = (2*a) + 3;
|
|
|
|
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.
|
|
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.
|
|
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.
|
|
This change will need more thought later when it comes to traits and
generics etc.
Fixes #136
|
|
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.
|
|
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.
|
|
This ensures the compiler respects scoping and shadowing rules of
blocks added within an enclosing scope.
|
|
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.
|
|
This will help enforce consistency of visitors to fix issues with
TyTy unification rules.
|
|
Rust is permissive for integers being marked as floats so the check in the
lexer can be removed here.
|
|
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.
|
|
This also ensure the type suffix is respected against the number.
|
|
for the ASM name similar to functions.
|
|
|
|
We need to ensure all suffix of literals are handled in a subsequent PR.
|
|
This change propagates the PrimitiveCoreType to AST and HIR so
the suffix can be examined.
|
|
where no base struct is referenced and the constructor is in order.
|
|
|
|
to turn on CI build failure if any test fails and this will block that
change until the next milestone if not removed.
|
|
let mut array = [123; 5]
|
|
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.
|
|
|
|
Add GPL license text to files without the header
|
|
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.
|
|
|
|
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
|
|
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.
|
|
name resolution and type resolution to simplify the generation of
gimple.
|
|
to use the new name and type resolution pass contexts.
|
|
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.
|
|
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.
|
|
This is the initial pass to move the AST to HIR. It is very extensible and
easy to maintain now.
|
|
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.
|
|
NodeIds are going to be used for Hir->Ast lookups later on.
|
|
This adds some extra Flags to ignore unused warnings and no
overloaded-virtuals. This helps with compilation error diagnosis.
|
|
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
|
|
|
|
|
|
|
|
Fixed typo in an enum expr field class
|
|
|
|
|
|
|
|
|
|
|