R      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQ%Utility functions used throughout Ion(c) 2015 Chris HodappNone,Return the symbol name of an Ivory procedure?Return the Ivory unsigned int type (in its AST) that the given R8 would require (i.e. any value from 0 to 255 returns a S4; values beyond that but less than 65535 require a T6; and so on.) The given integer must be non-negative.TChecks the given string for being a valid C identifier. If it is, then it returns U, and otherwise VA and the string index of the character which renders it invalid.Base Ion types(c) 2015 Chris HodappNone(+35KL/Path, C name, and index at which it is invalidPath, phase, period Path, phase Path, period 7Minimum phase (i.e. at this phase, or any later point) Exactly this phase 4Phase is relative to the first tick within a period )Phase is relative to the last phase used!The type of Ivory action that an IonNodeT can support. Note that this purposely forbids breaking, returning, and allocating.WA scheduled action. Phase and period here are absolute, and there are no child nodes.A unique ID for this action)Name (without any disambiguation applied)=A list of names giving the trail that produced this schedule,The (absolute & exact) phase of this actionThe period of this action"The Ivory effects for this action%Ivory effects which all must return W for anything in  to executeUnique ID (used as base name)Next unused number2Ivory definitions that the specifications produceThe  inherited context7A flat list of schedule items generated along the way. This wraps 6 with the ability to create unique C identifier names.!  !"#  !! !#  "    !"#*Types and functions for flattened schedule(c) 2015 Chris HodappNone$)Produce a flat list of scheduled actions.%2Prune any schedule item that has no Ivory actions.&MAssign unique IDs to the list of schedule items, starting from the given ID.$%&$%&$%&$%&-Ivory code generation from Ion specifications(c) 2015 Chris HodappNone(>KLN'Concrete exports from an ,)Helper function to generate code from an  and run the Ivory compiler on it (or else output an exception message). While I don't yet know any reason why it needs to, this also returns whatever value the  returns.-Produce exports from the given  specs..Produce an Ivory effect from a .'()*+, Options for X%Name for schedule function and moduleSpec-Name for schedule functionIon specification.'()*+,-.'()*+,-.'()*+,-.-Operators used in creating Ion specifications(c) 2015 Chris HodappNone(>KL/?Transform a sub-node according to a function which transforms + items, and then collect the state from it.2Specify a name of a sub-node, returning the parent. This node name is used in the paths to the node and in some C identifiers in the generated C code; its purpose is mainly diagnostic and to help the C code be more comprehensible.4Specify a relative, minimum delay for a sub-node - i.e. a minimum offset past the phase that is inherited. For instance, in the example,  5 20 $ do 5 40 $ foo 4 2 $ bar 4 2 $ baz foo and bar: both run at a (minimum) phase of 22, because the entire do# block inherits that minimum phase.5Specify a minimum phase for a sub-node - that is, the earliest tick within a period that the sub-node should be scheduled at. Phase must be non-negative, and lower than the period.6Specify a period for a sub-node - that is, the interval, in ticks, at which the sub-node is scheduled to repeat. Period must be positive; a period of 1 indicates that the sub-node executes at every single clock tick.7Specify a sub-period for a sub-node - that is, the factor by which to multiply the inherited period. A factor of 2, for instance, would execute the sub-node half as often as its parent.8Ignore a sub-node completely. This is intended to mask off some part of a spec while still leaving it present for compilation. Note that this disables only the scheduled effects of a node, and so it has no effect on things like @.9LMake a sub-node's execution conditional; if the given Ivory effect returns true (as evaluated at the inherited phase and period), then this sub-node is active, and otherwise is not. Multiple conditions may accumulate, in which case they combine with a logical and; (i.e. all of them must be true for the node to be active).:Attach an Ivory effect to an K. This effect will execute at the inherited phase and period of the node.;Return a unique name.< Allocate a Y for this , returning a reference to it. If the initial value fails to specify the type of this, then an external signature may be needed (or instead =9). If access to this variable is needed outside of the ( monad, retrieve the reference from an  with the ionRef function. The  ModuleDef* for this will be generated automatically.=Same as <, but with an initial Z to disambiguate the area type.>This is < , but using N to create a unique name. (The purpose for this is to help with composing an ' or instantiating one multiple times.)?This is = , but using  to create a unique name.@This is like Ivory proc , but using & to give the procedure a unique name.A@ with an initial Proxy# to disambiguate the procedure typeBAll the  adapt_X_Y1 functions adapt an Ivory procedure which takes XE arguments and returns nothing, into an Ivory procedure which takes Y arguments. If X > Y. then zero is passed for the argument(s); if Y < Xp then the additional arguments are ignored. The generated procedure is automatically included as part of the Y spec. The main point of this is to simplify the chaining together of Ivory procedures.K'Create a timer resource. The returned v still must be called at regular intervals (e.g. by including it in a larger Ion spec that is already active). See L and M" to actually activate this timer.L9Begin counting a timer down by the given number of ticks.MStop a timer from running./012NameSub-node34Relative phaseSub-node5PhaseSub-node6PeriodSub-node75Factor by which to multiply period (must be positive)Sub-node89:;<Name of variableInitial value (or U)=Proxy (to disambiguate type)Name of variableInitial value (or U)>?@ABCDEFGHIJKProxy to resolve timer typeTimer expiration procedureL Timer from KCountdown timeM/0123456789:;<=>?@ABCDEFGHIJKLM/0123456789:;<=>?@ABCDEFGHIJKLM/0123456789:;<=>?@ABCDEFGHIJKLM8Ion types for continuations & continuation-passing style(c) 2015 Chris HodappNone(35KLNThis wraps a pattern of functions calling each other in continuation-passing style. The intent is that the returned entry function (which takes arguments aM) causes the supplied continuation function to be called (passing arguments b).This is a common pattern for asynchronous calls, for instance, in which the callback or interrupt calls the continuation function.DMultiple calls of this sort can be composed with '(=<<)' (and with  RecursiveDo and mdo:) to chain them in the order in which they would proceed.For instance, in (start <- call1 =<< call2 =<< call3 final, start contains the entry function to call16, whose continuation is set to the entry function of call2>, whose continuation in turn is set to the entry function of call3, whose continuation is final}. Note that chaining these with '(>>=)' is possible too, but the order is somewhat reversed from what is logical - hence, mdo often being sensible here.OLift a Haskell function up into an N.P AccumulateC an argument into a continuation function. Specifically: Given an N? taking some argument in its entry function, generate another N with the same type of entry function, but whose continuation function contains another argument (which will receive the same value of that argument).?Note that every use of this requires a static variable of type a. Also, this implementation does not protect against the continuation function being called without the entry function; if this occurs, the continuation will contain old values of a5 from earlier invocations, or possibly a zero value.TODO: Right now this handles only converting single-argument to double-argument. I intend to modify this to work similarly to [ and callAux in Ivory.NContinuation functionEntry functionOPQNOPQNOPQNOPQTop-level Ion module(c) 2015 Chris HodappNone%'()*+-12456789:;<=>?@ABCDEFGHIJKLMNP%N'()*+-2546798;@A<=>?:KLM1BCDEFGHIJP\      !"#$%&'()*+,--./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\Z[]^_`^_aZbcdefZghZijZklmIRDdgTBnlgo9LDRr7icmh3Ivory.Language.Ion.UtilIvory.Language.Ion.BaseIvory.Language.Ion.ScheduleIvory.Language.Ion.CodeIvory.Language.Ion.OperatorsIvory.Language.Ion.CPSIvory.Language.IonprocName fitWordType checkCName IonException InvalidCNamePhaseExceedsPeriodPhaseIsNegativePeriodMustBePositive PhaseTypeMinExact PhaseContextAbsoluteRelative IvoryActionScheduleschedId schedName schedPath schedPhase schedPeriod schedAction schedCondIonDefionIdionNumionDefsionCtxtionSchedIon defaultIonDefdefaultSchedule$fExceptionIonException $fShowIvoryflattenprune uniqueIds IonExportsionEntry ionModuleionValue ionCompileionDefgetIvory addActiongetSchedgetPhaseionphaseSetdelayphaseperiod subPerioddisablecondivoryEffnewNamearea'areaP'newAreanewAreaPnewProcnewProcP adapt_0_1 adapt_1_0 adapt_0_2 adapt_2_0 adapt_0_3 adapt_3_0 adapt_0_4 adapt_4_0 adapt_0_5timer startTimer stopTimerIonContliftaccumjoin integer-gmpGHC.Integer.TypeIntegerGeSwRwKvpPW4Tvetg6BXBRIvory.Language.Syntax.TypeWord8Word16baseGHC.BaseNothingJustIvory.Language.IBooltrueHskL5rL2lVuKBgx1fwmKKuIvory.Compile.C.CmdlineFrontend runCompilerIvory.Language.MemAreaMemAreaIvory.Language.ProxyProxyIvory.Language.Proccall