-
Notifications
You must be signed in to change notification settings - Fork 85
Conversation
@@ -0,0 +1,46 @@ | |||
package org.yakindu.sct.generator.c |
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.
Missing Copyright header
import org.yakindu.sct.model.sexec.ExecutionState | ||
import org.yakindu.sct.model.sexec.naming.INamingService | ||
|
||
class StateConfVectorIndexCalculator { |
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.
Missing author tag
protected Map<ExecutionState, Integer> indexMap | ||
protected Map<ExecutionState, String> defineMap | ||
|
||
def Integer getIndex(ExecutionState it) { |
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 would remove the Map. Its just a call to stateVector.offset, there is no need to cache the result for this. Then the IndexCalculator can be used stateless and as a singleton.
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!
- The class does not calculate anything as the calculation of the index is already calculated.
- it is effectively just a shortcut access extension that allows to write
it.index
instead ofit.stateVector.offset
. it.stateVector.offset
is more precise about what is really meant.
So - please remove this class
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 whole class? @andreasmuelder only proposed to remove the map, which I agree with. The class does make sense because the name of the define is used in two locations, FlowCode and StatemachineHeader. Not having this class or at least the function in some other class would introduce copied code.
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.
from comments:
- remove StateConfVectorIndexCalculator
- add copyright header
protected Map<ExecutionState, Integer> indexMap | ||
protected Map<ExecutionState, String> defineMap | ||
|
||
def Integer getIndex(ExecutionState it) { |
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!
- The class does not calculate anything as the calculation of the index is already calculated.
- it is effectively just a shortcut access extension that allows to write
it.index
instead ofit.stateVector.offset
. it.stateVector.offset
is more precise about what is really meant.
So - please remove this class
Resolves #1336 by calculating and applying defines for all states that can be used in the code instead of "magic" indices of the StateConfVector.