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

copilot-c99: Allow multiple triggers with the same name #572

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

fdedden
Copy link
Member

@fdedden fdedden commented Dec 20, 2024

Extends the C99 backend to allow multiple references to the same trigger:

spec = do
  trigger "f" guard0 [arg $ constI8 10]
  trigger "f" guard1 [arg $ constI8 12]

Note that the guards may overlap, which will mean the trigger is called twice in that iteration.

As C99 does not allow multiple function definitions sharing the same name, we can only allow a single type per trigger function. The following is explicitly disallowed by the backend:

spec = do
  trigger "f" guard0 [arg $ constI8 10]
  trigger "f" guard1 [arg $ constI8 12, arg $ constI8 15]

Upon compilation, the user gets an error message:

Copilot error: attempt at compiling specification with conflicting trigger definitions.
Multiple triggers have the same name, but different argument types.

Feel free to make any modification necessary to my commits.

…uage#296.

A backend specific representation of triggers allows us to keep track of
the internal name for a trigger.
…age#296.

Updates the generation of the `step` function to use unique names for
the trigger related code.
…lot-Language#296.

Generate the trigger guard and argument functions using the unique
names.
…opilot-Language#296.

The .h file should not list the same trigger multiple times, this commit
removes the duplicates.
…anguage#296.

Multiple triggers sharing the same name should have the exact same
argument types as well, as C99 does not allow multiple function definitions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant