-
Notifications
You must be signed in to change notification settings - Fork 64
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
Reactor classes in the same file with the same name, up to case differences, are prohibited #1741
Conversation
This is not really a fix because we still have the problem that we consider reactor classes to have distinct names using a **case-sensitive** comparison, but we want to generate files corresponding to the reactor classes that will be compared **case-insensitively** on macOS. However, it does make our generated code "less wrong."
The file name of the fed-gen file should be specified in one place (DRY).
The problem here is that we use the uniqueID of the federate both before and after we transform it into separate programs. After we transform it, the name of the instance depends on the name of the main reactor, which might be different (indeed, it must be different in order for us to eliminate the possibility of name collisions with other parts of the program). So this is a bit of a hack, but I'm not sure what else to do.
It is bad that in order to make this change it is necessary to edit code in several places. But it isn't clear how to fix this because different parts of the code operate on the program at different stages in the compilation process, either before or after it has been split into many programs.
This is hacky. The problem is that the generated code does not have a federated reactor, but we do an AST transformation so that we can pretend that it is (I do not want to know why). So we end up running the code generator on a federated program, even though it is supposed to result on code for a single federate. So if the federate had its name prefixed once in the main run of the code generator, its name will be prefixed again in the nested run of the code generator.
I think this is ready for review. |
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 looks good to me! Would be nice to have a test, but that's not critical.
OK. I will choose to merge this now without testing the validation rule. |
Fixes #1702.
The core issue in #1702 is that we consider reactor classes to have distinct names using a case-sensitive comparison, but we want to generate files corresponding to the reactor classes that will be compared case-insensitively on macOS.
We can't just mangle these file names because users might refer to them in their code.
Therefore, we should avoid creating reactor classes whose names are the same, up to case differences.