forked from Copilot-Language/copilot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
copilot-c99: Add specific
Trigger
representation. Refs Copilot-Lang…
…uage#296. A backend specific representation of triggers allows us to keep track of the internal name for a trigger.
- Loading branch information
Showing
2 changed files
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
-- | C99 backend specific versions of selected `Copilot.Core` datatypes. | ||
module Copilot.Compile.C99.Representation | ||
( | ||
UniqueTrigger (..) | ||
, UniqueTriggerId | ||
, mkUniqueTriggers | ||
) | ||
where | ||
|
||
import Copilot.Core ( Trigger (..) ) | ||
|
||
-- | Internal unique name for a trigger. | ||
type UniqueTriggerId = String | ||
|
||
-- | A `Copilot.Core.Trigger` with an unique name. | ||
data UniqueTrigger = UniqueTrigger UniqueTriggerId Trigger | ||
|
||
-- | Given a list of triggers, make their names unique. | ||
mkUniqueTriggers :: [Trigger] -> [UniqueTrigger] | ||
mkUniqueTriggers ts = zipWith mkUnique ts [0..] | ||
where | ||
mkUnique t@(Trigger name _ _) n = UniqueTrigger (name ++ "_" ++ show n) t |