-
Notifications
You must be signed in to change notification settings - Fork 668
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Restructure Definitions and Assigns in preparation for writing to arr… #28526
Conversation
0295f6e
to
69b0e45
Compare
Oh also the commit message is backward - I didn't remove |
} | ||
|
||
fn visit_assign(&mut self, _input: &'a AssignStatement) -> String { | ||
panic!("DefinitionStatement's should not exist in SSA form.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
panic!("DefinitionStatement's should not exist in SSA form.") | |
panic!("AssignStatement's should not exist in SSA form.") |
@@ -35,8 +35,8 @@ impl Assigner { | |||
|
|||
/// Constructs the assignment statement `place = expr;`. | |||
/// This function should be the only place where `AssignStatement`s are constructed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// This function should be the only place where `AssignStatement`s are constructed. | |
/// This function should be the only place where `DefinitionStatement`s are constructed. |
@@ -57,12 +57,13 @@ impl AssignerInner { | |||
|
|||
/// Constructs the assignment statement `place = expr;`. | |||
/// This function should be the only place where `AssignStatement`s are constructed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// This function should be the only place where `AssignStatement`s are constructed. | |
/// This function should be the only place where `DefinitionStatement`s are constructed. |
fn reconstruct_definition(&mut self, _: DefinitionStatement) -> (Statement, Self::AdditionalOutput) { | ||
unreachable!("`DefinitionStatement`s should not exist in the AST at this phase of compilation.") | ||
fn reconstruct_definition(&mut self, mut input: DefinitionStatement) -> (Statement, Self::AdditionalOutput) { | ||
// Check the lhs of the assignment to see any of variables are used. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Check the lhs of the assignment to see any of variables are used. | |
// Check the lhs of the definition to see any of variables are used. |
@@ -1,14 +1,8 @@ | |||
namespace = "Compile" | |||
expectation = "Fail" | |||
outputs = [""" | |||
Error [ETYC0372000]: invalid assignment target | |||
--> compiler-test:5:9 | |||
Error [EPAR0370005]: expected ; -- found '=' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way this error can be made more informative?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, these changes look good to me since the compiled programs do not change. Left a couple of nits. Before merging, it would be good to verify that the documentation is consistent with the new AST.
Which documentation? You're referring to comments in the code? |
80a6ff2
to
1cb7dc3
Compare
…ays, etc. Specifically: - AssociatedConstant and AssociatedFunction are moved out of AccessExpression to become variants of Expression. - A new type DefinitionPlace is the place in a DefinitionStatement. - ConstantDeclaration is gone - Definition can handle its case. - SSA pass now produces Definitions instead of Assigns. - The Place in an AssignStatement is now an Identifier. (In the future it will become a new type, capable of handling writes to arrays, structs, and tuples.)
1cb7dc3
to
4834474
Compare
Restructure Definitions and Assigns in preparation for writing to arrays, etc.
Specifically:
AssociatedConstant and AssociatedFunction are moved out of AccessExpression to become variants of Expression.
A new type DefinitionPlace is the place in a DefinitionStatement.
ConstantDeclaration is gone - Definition can handle its case.
SSA pass now produces Definitions instead of Assigns.
The Place in an AssignStatement is now an Identifier. (In the future it will become a new type, capable of handling writes to arrays, structs, and tuples.)