-
Notifications
You must be signed in to change notification settings - Fork 39
Conversation
I see that some tests are failing due to the new |
so, now the changes to the analyser are missing? |
@leolara maybe I misunderstood but I thought that the conclusion was to extract the usages in a separate pass and put them in a separate data structure. In this case it could all be done in the language server. |
@alxkzmn That is not the conclusion: #254 (comment) The conclusion is to remove the lines that check if the state symbol is there and create it if it is not. The state symbol will be there. |
@leolara to make sure I'm on the right track:
|
Yes, single pass, you don't need a separate data structure. What you had before is ok, just needs to assume that the states are already in the symbol table, because they should be. As I explained, we are already doing kind of two passes, one to collect the state symbols and then to analyse each state after. So when you are analysing a transition you already should have the state in the symbol table |
@leolara the PR is ready for review. |
src/compiler/semantic/analyser.rs
Outdated
@@ -62,7 +62,9 @@ impl Analyser { | |||
block, | |||
} => { | |||
let sym = SymTableEntry { | |||
id: id.name(), |
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.
@alxkzmn perhaps we could have a constructor new
that always sets usages to vec![]
src/compiler/semantic/analyser.rs
Outdated
.into_iter() | ||
.for_each(|expr| self.analyse_expression(expr)), | ||
Statement::SignalAssignment(_, ids, exprs) => { | ||
self.extract_id_usages(&ids); |
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.
@alxkzmn wouldn't it be better to extract the usages after the semantic analysis? I mean swaping the calls to extract_id_usages and analyse_expression ?
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, at least it seems more intuitively to make more sense to analyse first and then extract the usages
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.
The IDs weren't initially used (_), so shouldn't be any difference (only affects the order in which they are recorded). But I'll rename and move the method after the analysis, just in case.
src/parser/ast/mod.rs
Outdated
|
||
/// Returns the proximity score of the given offset to the debug symbol. | ||
/// The proximity score is the sum of the distance from the start and end of the symbol. | ||
/// If the offset is not within the symbol, -1 is returned. |
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.
The comment is no longer valid
I put all my ideas here together to avoid more cycles:
|
/// ### Returns | ||
/// The `SymTableEntry` that is closest to the offset. | ||
pub fn find_symbol_by_offset(&self, filename: String, offset: usize) -> Option<SymTableEntry> { | ||
let mut closest_symbol: Option<SymTableEntry> = None; |
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.
@alxkzmn I think it would be much more efficient and clear to store the closest_symbol_proximity in a variable instead of calling proximity score every time.
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 initially wanted to do that but then refactored into calling the method for readability because it seemed like overoptimizing.
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 think it also make it more readbale, also perhaps you could have an and in the two conditions, although I think that feature with if let
is experimental.
But I also thought for a moment that proximity_score had a couple of loops inside so I thought it was more important.
It was aprove already, you can merge |
The following changes were necessary to integrate with the language server:
SymTableEntry
(and some WIP additional functionality in the Analyzer to record the usages during the analysis).SymTable