-
Notifications
You must be signed in to change notification settings - Fork 17
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
Variables IR and Codegen #100
Conversation
4180902
to
5d980da
Compare
335e360
to
b6fddf7
Compare
0424320
to
c26a0bd
Compare
c26a0bd
to
b37f500
Compare
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.
Looks good, thanks @tohrnii! I like the improvement to the boundary constraint handling to make them more generic. I left a few comments inline
IdentifierType::TransitionVariable(transition_variable) => { | ||
if let TransitionVariableType::Scalar(expr) = transition_variable.value() { | ||
if let Some((trace_segment, node_index)) = | ||
variable_roots.get(&VariableValue::Scalar(ident.to_string())) | ||
{ | ||
Ok((*trace_segment, *node_index)) | ||
} else { | ||
let (trace_segment, node_index) = | ||
self.insert_expr(symbol_table, expr.clone(), variable_roots)?; | ||
variable_roots.insert( | ||
VariableValue::Scalar(ident.to_string()), | ||
(trace_segment, node_index), | ||
); | ||
Ok((trace_segment, node_index)) | ||
} | ||
} else { | ||
Err(SemanticError::InvalidUsage(format!( | ||
"Identifier {} was declared as a {} which is not a supported type.", | ||
ident, elem_type | ||
))) | ||
} | ||
} |
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.
There's quite a bit of similarity/near-redundancy between this, insert_vector_access
, and `insert_matrix_access, so I think there's probably a better way. Can you take a look at refactoring a bit or ping me if you want to discuss?
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.
I agree with you that there is some redundancy but I can't think of a way to reduce it much here.
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.
Ok, let's leave it for now and revisit in the future once the tests are in place.
b37f500
to
d2591d6
Compare
8201cb5
to
02175ee
Compare
Thank you @grjte and @Al-Kindi-0 for the review. Made suggested changes. |
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.
Thanks @tohrnii! I have a few final comments, but they're all very small nits - should only take 5 min to update.
IdentifierType::TransitionVariable(transition_variable) => { | ||
if let TransitionVariableType::Scalar(expr) = transition_variable.value() { | ||
if let Some((trace_segment, node_index)) = | ||
variable_roots.get(&VariableValue::Scalar(ident.to_string())) | ||
{ | ||
Ok((*trace_segment, *node_index)) | ||
} else { | ||
let (trace_segment, node_index) = | ||
self.insert_expr(symbol_table, expr.clone(), variable_roots)?; | ||
variable_roots.insert( | ||
VariableValue::Scalar(ident.to_string()), | ||
(trace_segment, node_index), | ||
); | ||
Ok((trace_segment, node_index)) | ||
} | ||
} else { | ||
Err(SemanticError::InvalidUsage(format!( | ||
"Identifier {} was declared as a {} which is not a supported type.", | ||
ident, elem_type | ||
))) | ||
} | ||
} |
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.
Ok, let's leave it for now and revisit in the future once the tests are in place.
13bf212
to
9ad732b
Compare
Thanks @grjte. Fixed. |
9ad732b
to
51ccbe3
Compare
- Remove variables for boundary constraints - Remove variables graph - Remove variables vector
51ccbe3
to
f087117
Compare
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.
Looks good, thanks @tohrnii!
Partly addressing #61.