Skip to content

Commit

Permalink
Debug local pure arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
anton-k committed Jan 28, 2023
1 parent 45b1754 commit a99de74
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ ppRatedVar :: R.Var -> Doc
ppRatedVar v = ppRate (R.varType v) <> int (R.varId v)

ppRate :: Rate -> Doc
ppRate x = case x of
ppRate x = case removeArrRate x of
Sr -> char 'S'
_ -> phi x
where phi = textStrict . Text.toLower . Text.pack . show
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ inferIter opts (Stmt lhs rhs) =

onInitPureArr outRate processingRate initVals = do
typedInits <- mapM (mapM (getVar initRate)) initVals
save outRate (InitPureArr outRate processingRate typedInits)
save (toArrRate outRate) (InitPureArr outRate processingRate typedInits)
where
initRate = fromIfRate processingRate

Expand All @@ -487,7 +487,6 @@ inferIter opts (Stmt lhs rhs) =
where
initRate = fromIfRate processingRate


-------------------------------------------------------------
-- generic funs

Expand Down
21 changes: 21 additions & 0 deletions csound-expression-dynamic/src/Csound/Dynamic/Types/Exp.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
module Csound.Dynamic.Types.Exp(
E, RatedExp(..), isEmptyExp,
ratedExp, noRate, withRate, setRate,
toArrRate, removeArrRate,
Exp, toPrimOr, toPrimOrTfm, PrimOr(..), MainExp(..), Name,
InstrId(..), intInstrId, ratioInstrId, stringInstrId,
VarType(..), Var(..), Info(..), OpcFixity(..), Rate(..),
Expand Down Expand Up @@ -314,8 +315,28 @@ data Rate -- rate:
| Fr -- spectrum (for pvs opcodes)
| Wr -- special spectrum
| Tvar -- I don't understand what it is (fix me) used with Fr
| ArArr -- array rates
| KrArr
| IrArr
| SrArr
deriving (Show, Eq, Ord, Enum, Bounded, Generic)

toArrRate :: Rate -> Rate
toArrRate = \case
Ar -> ArArr
Kr -> KrArr
Ir -> IrArr
Sr -> SrArr
other -> other

removeArrRate :: Rate -> Rate
removeArrRate = \case
ArArr -> Ar
KrArr -> Kr
IrArr -> Ir
SrArr -> Sr
other -> other

-- Opcode type signature. Opcodes can produce single output (SingleRate) or multiple outputs (MultiRate).
-- In Csound opcodes are often have several signatures. That is one opcode name can produce signals of the
-- different rate (it depends on the type of the outputs). Here we assume (to make things easier) that
Expand Down

0 comments on commit a99de74

Please sign in to comment.