Skip to content
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

Add generated variables in bulk before calling readEquations #566

Closed
chrispcampbell opened this issue Nov 24, 2024 · 0 comments · Fixed by #567
Closed

Add generated variables in bulk before calling readEquations #566

chrispcampbell opened this issue Nov 24, 2024 · 0 comments · Fixed by #567
Assignees

Comments

@chrispcampbell
Copy link
Contributor

While working on the fixes for #179, I found an issue with the current implementation of the readEquation phase that is an obstacle to those fixes.

In cases like generateDelay3VarsForSeparatedVar where we generate variables at compile time in order to implement complex functions (e.g., DELAY3[I]), we call context.defineVariable() for each generated variable in isolation; each call to defineVariable() will do addVariable followed by readEquation.

The problem with this approach is that when there are multiple equations being defined (that refer to each other), we aren't able to access information from the variables that aren't yet added.

It would be better if we generate the text of all equations first, then change defineVariable(eqn: string) to be defineVariables(eqns: string[]). Then we can call addVariable on all those equations in a first pass, and then when it calls readEquation those variables will be defined and can be accessed.

This is basically a refactoring that has no impact on current behavior (all existing tests will pass), but it will make it easier to implement other in-progress fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant