{- -----------------------------------------------------------------------------
Copyright 2019-2021,2023 Kevin P. Barry

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
----------------------------------------------------------------------------- -}

-- Author: Kevin P. Barry [ta0kira@gmail.com]

{-# LANGUAGE Safe #-}

module CompilerCxx.CategoryContext (
  getContextForInit,
  getMainContext,
  getProcedureContext,
) where

import Prelude hiding (pi)
import qualified Data.Map as Map
import qualified Data.Set as Set

import Base.CompilerError
import Base.GeneralType
import Base.Positional
import Compilation.CompilerState
import Compilation.ProcedureContext
import Compilation.ScopeContext
import CompilerCxx.Code (isStoredUnboxed)
import Types.DefinedCategory
import Types.Procedure
import Types.TypeCategory
import Types.TypeInstance


getContextForInit :: (Show c, CollectErrorsM m) =>
  Bool -> CategoryMap c -> ExprMap c -> AnyCategory c -> DefinedCategory c ->
  SymbolScope -> m (ProcedureContext c)
getContextForInit :: forall c (m :: * -> *).
(Show c, CollectErrorsM m) =>
Bool
-> CategoryMap c
-> ExprMap c
-> AnyCategory c
-> DefinedCategory c
-> SymbolScope
-> m (ProcedureContext c)
getContextForInit Bool
to CategoryMap c
tm ExprMap c
em AnyCategory c
t DefinedCategory c
d SymbolScope
s = do
  let ps :: Positional (ValueParam c)
ps = forall a. [a] -> Positional a
Positional forall a b. (a -> b) -> a -> b
$ forall c. AnyCategory c -> [ValueParam c]
getCategoryParams AnyCategory c
t
  -- NOTE: This is always ValueScope for initializer checks.
  let ms :: [DefinedMember c]
ms = forall a. (a -> Bool) -> [a] -> [a]
filter ((forall a. Eq a => a -> a -> Bool
== SymbolScope
ValueScope) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall c. DefinedMember c -> SymbolScope
dmScope) forall a b. (a -> b) -> a -> b
$ forall c. DefinedCategory c -> [DefinedMember c]
dcMembers DefinedCategory c
d
  let pa :: [ParamFilter c]
pa = if SymbolScope
s forall a. Eq a => a -> a -> Bool
== SymbolScope
CategoryScope
              then []
              else forall c. AnyCategory c -> [ParamFilter c]
getCategoryFilters AnyCategory c
t
  let sa :: Map ParamName SymbolScope
sa = forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList forall a b. (a -> b) -> a -> b
$ forall a b. [a] -> [b] -> [(a, b)]
zip (forall a b. (a -> b) -> [a] -> [b]
map forall c. ValueParam c -> ParamName
vpParam forall a b. (a -> b) -> a -> b
$ forall c. AnyCategory c -> [ValueParam c]
getCategoryParams AnyCategory c
t) (forall a. a -> [a]
repeat SymbolScope
TypeScope)
  let r :: CategoryResolver c
r = forall c. CategoryMap c -> CategoryResolver c
CategoryResolver CategoryMap c
tm
  Map FunctionName (ScopedFunction c)
fa <- forall c (m :: * -> *) r.
(Show c, CollectErrorsM m, TypeResolver r) =>
r
-> AnyCategory c
-> [ScopedFunction c]
-> m (Map FunctionName (ScopedFunction c))
setInternalFunctions CategoryResolver c
r AnyCategory c
t (forall c. DefinedCategory c -> [ScopedFunction c]
dcFunctions DefinedCategory c
d)
  ParamFilters
fm <- forall (m :: * -> *) c.
CollectErrorsM m =>
[ValueParam c] -> [ParamFilter c] -> m ParamFilters
getFilterMap (forall a. Positional a -> [a]
pValues Positional (ValueParam c)
ps) [ParamFilter c]
pa
  let typeInstance :: TypeInstance
typeInstance = CategoryName -> InstanceParams -> TypeInstance
TypeInstance (forall c. AnyCategory c -> CategoryName
getCategoryName AnyCategory c
t) forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall a. (Eq a, Ord a) => a -> GeneralType a
singleType forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> ParamName -> TypeInstanceOrParam
JustParamName Bool
False forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall c. ValueParam c -> ParamName
vpParam) Positional (ValueParam c)
ps
  let builtin :: Map VariableName (VariableValue c)
builtin = forall a k. (a -> Bool) -> Map k a -> Map k a
Map.filter ((forall a. Eq a => a -> a -> Bool
== SymbolScope
LocalScope) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall c. VariableValue c -> SymbolScope
vvScope) forall a b. (a -> b) -> a -> b
$ forall c. TypeInstance -> Map VariableName (VariableValue c)
builtinVariables TypeInstance
typeInstance
  let readOnly :: Map VariableName [a]
readOnly = forall k a. Ord k => (a -> a -> a) -> [(k, a)] -> Map k a
Map.fromListWith forall a. [a] -> [a] -> [a]
(++) forall a b. (a -> b) -> a -> b
$ forall a b. (a -> b) -> [a] -> [b]
map (\DefinedMember c
m -> (forall c. DefinedMember c -> VariableName
dmName DefinedMember c
m,[])) forall a b. (a -> b) -> a -> b
$ forall c. DefinedCategory c -> [DefinedMember c]
dcMembers DefinedCategory c
d
  Map VariableName (VariableValue c)
members <- forall c (m :: * -> *).
(Show c, CollectErrorsM m) =>
Map VariableName [c]
-> Map VariableName [c]
-> [DefinedMember c]
-> m (Map VariableName (VariableValue c))
mapMembers forall {a}. Map VariableName [a]
readOnly forall k a. Map k a
Map.empty forall a b. (a -> b) -> a -> b
$ forall a. (a -> Bool) -> [a] -> [a]
filter ((forall a. Ord a => a -> a -> Bool
<= SymbolScope
s) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall c. DefinedMember c -> SymbolScope
dmScope) (forall c. DefinedCategory c -> [DefinedMember c]
dcMembers DefinedCategory c
d)
  forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ ProcedureContext {
      _pcScope :: SymbolScope
_pcScope = SymbolScope
s,
      _pcType :: CategoryName
_pcType = forall c. AnyCategory c -> CategoryName
getCategoryName AnyCategory c
t,
      _pcExtParams :: Positional (ValueParam c)
_pcExtParams = Positional (ValueParam c)
ps,
      _pcMembers :: [DefinedMember c]
_pcMembers = [DefinedMember c]
ms,
      _pcCategories :: CategoryMap c
_pcCategories = CategoryMap c
tm,
      _pcAllFilters :: ParamFilters
_pcAllFilters = ParamFilters
fm,
      _pcExtFilters :: [ParamFilter c]
_pcExtFilters = [ParamFilter c]
pa,
      _pcParamScopes :: Map ParamName SymbolScope
_pcParamScopes = Map ParamName SymbolScope
sa,
      _pcFunctions :: Map FunctionName (ScopedFunction c)
_pcFunctions = Map FunctionName (ScopedFunction c)
fa,
      _pcVariables :: Map VariableName (VariableValue c)
_pcVariables = forall k a. Ord k => Map k a -> Map k a -> Map k a
Map.union forall {c}. Map VariableName (VariableValue c)
builtin Map VariableName (VariableValue c)
members,
      _pcReturns :: ReturnValidation c
_pcReturns = forall c. Positional (PassedValue c) -> ReturnValidation c
ValidatePositions (forall a. [a] -> Positional a
Positional []),
      _pcDeferred :: DeferVariable c
_pcDeferred = forall c. DeferVariable c
emptyDeferred,
      _pcJumpType :: JumpType
_pcJumpType = JumpType
NextStatement,
      _pcIsNamed :: Bool
_pcIsNamed = Bool
False,
      _pcPrimNamed :: [ReturnVariable]
_pcPrimNamed = [],
      _pcRequiredTypes :: Set CategoryName
_pcRequiredTypes = forall a. Set a
Set.empty,
      _pcOutput :: [String]
_pcOutput = [],
      _pcDisallowInit :: Bool
_pcDisallowInit = Bool
True,
      _pcLoopSetup :: LoopSetup [String]
_pcLoopSetup = forall s. LoopSetup s
NotInLoop,
      _pcCleanupBlocks :: [Maybe (CleanupBlock c [String])]
_pcCleanupBlocks = [],
      _pcInCleanup :: Bool
_pcInCleanup = Bool
False,
      _pcUsedVars :: [UsedVariable c]
_pcUsedVars = [],
      _pcExprMap :: ExprMap c
_pcExprMap = ExprMap c
em,
      _pcReservedMacros :: [(MacroName, [c])]
_pcReservedMacros = [],
      _pcNoTrace :: Bool
_pcNoTrace = Bool
False,
      _pcTestsOnly :: Bool
_pcTestsOnly = Bool
to,
      _pcTraces :: [String]
_pcTraces = [],
      _pcParentCall :: Maybe
  (Positional ParamName,
   Positional (Maybe (CallArgLabel c), InputValue c))
_pcParentCall = forall a. Maybe a
Nothing
    }

getProcedureContext :: (Show c, CollectErrorsM m) =>
  Bool -> ScopeContext c -> ScopedFunction c -> ExecutableProcedure c -> m (ProcedureContext c)
getProcedureContext :: forall c (m :: * -> *).
(Show c, CollectErrorsM m) =>
Bool
-> ScopeContext c
-> ScopedFunction c
-> ExecutableProcedure c
-> m (ProcedureContext c)
getProcedureContext Bool
to (ScopeContext CategoryMap c
tm CategoryName
t Positional (ValueParam c)
ps [DefinedMember c]
ms [ParamFilter c]
pa Map FunctionName (ScopedFunction c)
fa Map VariableName (VariableValue c)
va ExprMap c
em)
                    ff :: ScopedFunction c
ff@(ScopedFunction [c]
_ FunctionName
_ CategoryName
_ SymbolScope
s FunctionVisibility c
_ Positional (PassedValue c, Maybe (CallArgLabel c))
as1 Positional (PassedValue c)
rs1 Positional (ValueParam c)
ps1 [ParamFilter c]
fs [ScopedFunction c]
_)
                    (ExecutableProcedure [c]
_ [PragmaProcedure c]
_ [c]
_ FunctionName
_ ArgValues c
as2 ReturnValues c
rs2 Procedure c
_) = do
  ReturnValidation c
rs' <- if forall c. ReturnValues c -> Bool
isUnnamedReturns ReturnValues c
rs2
            then forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall c. Positional (PassedValue c) -> ReturnValidation c
ValidatePositions Positional (PassedValue c)
rs1
            else forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall c.
Positional VariableName
-> Positional (PassedValue c)
-> DeferVariable c
-> ReturnValidation c
ValidateNames (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall c. OutputValue c -> VariableName
ovName forall a b. (a -> b) -> a -> b
$ forall c. ReturnValues c -> Positional (OutputValue c)
nrNames ReturnValues c
rs2) Positional (PassedValue c)
rs1 forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry forall c.
VariableName -> PassedValue c -> DeferVariable c -> DeferVariable c
addDeferred) forall c. DeferVariable c
emptyDeferred) forall a b. (a -> b) -> a -> b
$ forall a b (m :: * -> *) c.
(Show a, Show b, CollectErrorsM m) =>
(a -> b -> m c) -> Positional a -> Positional b -> m [c]
processPairs forall {m :: * -> *} {c}.
Monad m =>
PassedValue c -> OutputValue c -> m (VariableName, PassedValue c)
pairOutput Positional (PassedValue c)
rs1 (forall c. ReturnValues c -> Positional (OutputValue c)
nrNames ReturnValues c
rs2)
  Map VariableName (VariableValue c)
va' <- forall c (m :: * -> *).
(Show c, CollectErrorsM m) =>
Map VariableName (VariableValue c)
-> Positional (PassedValue c, Maybe (CallArgLabel c))
-> ArgValues c
-> m (Map VariableName (VariableValue c))
updateArgVariables Map VariableName (VariableValue c)
va Positional (PassedValue c, Maybe (CallArgLabel c))
as1 ArgValues c
as2
  Map VariableName (VariableValue c)
va'' <- forall c (m :: * -> *).
(Show c, CollectErrorsM m) =>
Map VariableName (VariableValue c)
-> Positional (PassedValue c)
-> ReturnValues c
-> m (Map VariableName (VariableValue c))
updateReturnVariables Map VariableName (VariableValue c)
va' Positional (PassedValue c)
rs1 ReturnValues c
rs2
  let pa' :: [ParamFilter c]
pa' = if SymbolScope
s forall a. Eq a => a -> a -> Bool
== SymbolScope
CategoryScope
               then [ParamFilter c]
fs
               else [ParamFilter c]
pa forall a. [a] -> [a] -> [a]
++ [ParamFilter c]
fs
  let localScopes :: Map ParamName SymbolScope
localScopes = forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList forall a b. (a -> b) -> a -> b
$ forall a b. [a] -> [b] -> [(a, b)]
zip (forall a b. (a -> b) -> [a] -> [b]
map forall c. ValueParam c -> ParamName
vpParam forall a b. (a -> b) -> a -> b
$ forall a. Positional a -> [a]
pValues Positional (ValueParam c)
ps1) (forall a. a -> [a]
repeat SymbolScope
LocalScope)
  let typeScopes :: Map ParamName SymbolScope
typeScopes = forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList forall a b. (a -> b) -> a -> b
$ forall a b. [a] -> [b] -> [(a, b)]
zip (forall a b. (a -> b) -> [a] -> [b]
map forall c. ValueParam c -> ParamName
vpParam forall a b. (a -> b) -> a -> b
$ forall a. Positional a -> [a]
pValues Positional (ValueParam c)
ps) (forall a. a -> [a]
repeat SymbolScope
TypeScope)
  let sa :: Map ParamName SymbolScope
sa = case SymbolScope
s of
                SymbolScope
CategoryScope -> Map ParamName SymbolScope
localScopes
                SymbolScope
TypeScope     -> forall k a. Ord k => Map k a -> Map k a -> Map k a
Map.union Map ParamName SymbolScope
typeScopes Map ParamName SymbolScope
localScopes
                SymbolScope
ValueScope    -> forall k a. Ord k => Map k a -> Map k a -> Map k a
Map.union Map ParamName SymbolScope
typeScopes Map ParamName SymbolScope
localScopes
                SymbolScope
_ -> forall a. HasCallStack => a
undefined
  ParamFilters
localFilters <- forall (m :: * -> *) c.
CollectErrorsM m =>
ScopedFunction c -> m ParamFilters
getFunctionFilterMap ScopedFunction c
ff
  ParamFilters
typeFilters <- forall (m :: * -> *) c.
CollectErrorsM m =>
[ValueParam c] -> [ParamFilter c] -> m ParamFilters
getFilterMap (forall a. Positional a -> [a]
pValues Positional (ValueParam c)
ps) [ParamFilter c]
pa
  let allFilters :: ParamFilters
allFilters = case SymbolScope
s of
                   SymbolScope
CategoryScope -> ParamFilters
localFilters
                   SymbolScope
TypeScope     -> forall k a. Ord k => Map k a -> Map k a -> Map k a
Map.union ParamFilters
localFilters ParamFilters
typeFilters
                   SymbolScope
ValueScope    -> forall k a. Ord k => Map k a -> Map k a -> Map k a
Map.union ParamFilters
localFilters ParamFilters
typeFilters
                   SymbolScope
_ -> forall a. HasCallStack => a
undefined
  let ns0 :: [ReturnVariable]
ns0 = if forall c. ReturnValues c -> Bool
isUnnamedReturns ReturnValues c
rs2
               then []
               else forall a b c d. (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d]
zipWith3 Int -> VariableName -> ValueType -> ReturnVariable
ReturnVariable [Int
0..] (forall a b. (a -> b) -> [a] -> [b]
map forall c. OutputValue c -> VariableName
ovName forall a b. (a -> b) -> a -> b
$ forall a. Positional a -> [a]
pValues forall a b. (a -> b) -> a -> b
$ forall c. ReturnValues c -> Positional (OutputValue c)
nrNames ReturnValues c
rs2) (forall a b. (a -> b) -> [a] -> [b]
map forall c. PassedValue c -> ValueType
pvType forall a b. (a -> b) -> a -> b
$ forall a. Positional a -> [a]
pValues Positional (PassedValue c)
rs1)
  let ns :: [ReturnVariable]
ns = forall a. (a -> Bool) -> [a] -> [a]
filter (ValueType -> Bool
isStoredUnboxed forall b c a. (b -> c) -> (a -> b) -> a -> c
. ReturnVariable -> ValueType
rvType) [ReturnVariable]
ns0
  forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ ProcedureContext {
      _pcScope :: SymbolScope
_pcScope = SymbolScope
s,
      _pcType :: CategoryName
_pcType = CategoryName
t,
      _pcExtParams :: Positional (ValueParam c)
_pcExtParams = Positional (ValueParam c)
ps,
      _pcMembers :: [DefinedMember c]
_pcMembers = [DefinedMember c]
ms,
      _pcCategories :: CategoryMap c
_pcCategories = CategoryMap c
tm,
      _pcAllFilters :: ParamFilters
_pcAllFilters = ParamFilters
allFilters,
      _pcExtFilters :: [ParamFilter c]
_pcExtFilters = [ParamFilter c]
pa',
      _pcParamScopes :: Map ParamName SymbolScope
_pcParamScopes = Map ParamName SymbolScope
sa,
      _pcFunctions :: Map FunctionName (ScopedFunction c)
_pcFunctions = Map FunctionName (ScopedFunction c)
fa,
      _pcVariables :: Map VariableName (VariableValue c)
_pcVariables = Map VariableName (VariableValue c)
va'',
      _pcReturns :: ReturnValidation c
_pcReturns = ReturnValidation c
rs',
      _pcDeferred :: DeferVariable c
_pcDeferred = forall c. DeferVariable c
emptyDeferred,
      _pcJumpType :: JumpType
_pcJumpType = JumpType
NextStatement,
      _pcIsNamed :: Bool
_pcIsNamed = Bool -> Bool
not (forall c. ReturnValues c -> Bool
isUnnamedReturns ReturnValues c
rs2),
      _pcPrimNamed :: [ReturnVariable]
_pcPrimNamed = [ReturnVariable]
ns,
      _pcRequiredTypes :: Set CategoryName
_pcRequiredTypes = forall a. Set a
Set.empty,
      _pcOutput :: [String]
_pcOutput = [],
      _pcDisallowInit :: Bool
_pcDisallowInit = Bool
False,
      _pcLoopSetup :: LoopSetup [String]
_pcLoopSetup = forall s. LoopSetup s
NotInLoop,
      _pcCleanupBlocks :: [Maybe (CleanupBlock c [String])]
_pcCleanupBlocks = [],
      _pcInCleanup :: Bool
_pcInCleanup = Bool
False,
      _pcUsedVars :: [UsedVariable c]
_pcUsedVars = [],
      _pcExprMap :: ExprMap c
_pcExprMap = ExprMap c
em,
      _pcReservedMacros :: [(MacroName, [c])]
_pcReservedMacros = [],
      _pcNoTrace :: Bool
_pcNoTrace = Bool
False,
      _pcTestsOnly :: Bool
_pcTestsOnly = Bool
to,
      _pcTraces :: [String]
_pcTraces = [],
      _pcParentCall :: Maybe
  (Positional ParamName,
   Positional (Maybe (CallArgLabel c), InputValue c))
_pcParentCall = Maybe
  (Positional ParamName,
   Positional (Maybe (CallArgLabel c), InputValue c))
parentCall
    }
  where
    pairOutput :: PassedValue c -> OutputValue c -> m (VariableName, PassedValue c)
pairOutput (PassedValue [c]
c1 ValueType
t2) (OutputValue [c]
c2 VariableName
n2) = forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ (VariableName
n2,forall c. [c] -> ValueType -> PassedValue c
PassedValue ([c]
c2forall a. [a] -> [a] -> [a]
++[c]
c1) ValueType
t2)
    args :: Positional (Maybe (CallArgLabel c), InputValue c)
args = forall a. [a] -> Positional a
Positional forall a b. (a -> b) -> a -> b
$ forall a b. [a] -> [b] -> [(a, b)]
zip (forall a b. (a -> b) -> [a] -> [b]
map forall a b. (a, b) -> b
snd forall a b. (a -> b) -> a -> b
$ forall a. Positional a -> [a]
pValues Positional (PassedValue c, Maybe (CallArgLabel c))
as1) (forall a. Positional a -> [a]
pValues forall a b. (a -> b) -> a -> b
$ forall c. ArgValues c -> Positional (InputValue c)
avNames ArgValues c
as2)
    parentCall :: Maybe
  (Positional ParamName,
   Positional (Maybe (CallArgLabel c), InputValue c))
parentCall = forall a. a -> Maybe a
Just (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall c. ValueParam c -> ParamName
vpParam Positional (ValueParam c)
ps1,Positional (Maybe (CallArgLabel c), InputValue c)
args)

getMainContext :: CollectErrorsM m => Bool -> CategoryMap c -> ExprMap c -> m (ProcedureContext c)
getMainContext :: forall (m :: * -> *) c.
CollectErrorsM m =>
Bool -> CategoryMap c -> ExprMap c -> m (ProcedureContext c)
getMainContext Bool
to CategoryMap c
tm ExprMap c
em = forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ ProcedureContext {
    _pcScope :: SymbolScope
_pcScope = SymbolScope
LocalScope,
    _pcType :: CategoryName
_pcType = CategoryName
CategoryNone,
    _pcExtParams :: Positional (ValueParam c)
_pcExtParams = forall a. [a] -> Positional a
Positional [],
    _pcMembers :: [DefinedMember c]
_pcMembers = [],
    _pcCategories :: CategoryMap c
_pcCategories = CategoryMap c
tm,
    _pcAllFilters :: ParamFilters
_pcAllFilters = forall k a. Map k a
Map.empty,
    _pcExtFilters :: [ParamFilter c]
_pcExtFilters = [],
    _pcParamScopes :: Map ParamName SymbolScope
_pcParamScopes = forall k a. Map k a
Map.empty,
    _pcFunctions :: Map FunctionName (ScopedFunction c)
_pcFunctions = forall k a. Map k a
Map.empty,
    _pcVariables :: Map VariableName (VariableValue c)
_pcVariables = forall k a. Map k a
Map.empty,
    _pcReturns :: ReturnValidation c
_pcReturns = forall c. Positional (PassedValue c) -> ReturnValidation c
ValidatePositions (forall a. [a] -> Positional a
Positional []),
    _pcDeferred :: DeferVariable c
_pcDeferred = forall c. DeferVariable c
emptyDeferred,
    _pcJumpType :: JumpType
_pcJumpType = JumpType
NextStatement,
    _pcIsNamed :: Bool
_pcIsNamed = Bool
False,
    _pcPrimNamed :: [ReturnVariable]
_pcPrimNamed = [],
    _pcRequiredTypes :: Set CategoryName
_pcRequiredTypes = forall a. Set a
Set.empty,
    _pcOutput :: [String]
_pcOutput = [],
    _pcDisallowInit :: Bool
_pcDisallowInit = Bool
False,
    _pcLoopSetup :: LoopSetup [String]
_pcLoopSetup = forall s. LoopSetup s
NotInLoop,
    _pcCleanupBlocks :: [Maybe (CleanupBlock c [String])]
_pcCleanupBlocks = [],
    _pcInCleanup :: Bool
_pcInCleanup = Bool
False,
    _pcUsedVars :: [UsedVariable c]
_pcUsedVars = [],
    _pcExprMap :: ExprMap c
_pcExprMap = ExprMap c
em,
    _pcReservedMacros :: [(MacroName, [c])]
_pcReservedMacros = [],
    _pcNoTrace :: Bool
_pcNoTrace = Bool
False,
    _pcTestsOnly :: Bool
_pcTestsOnly = Bool
to,
    _pcTraces :: [String]
_pcTraces = [],
    _pcParentCall :: Maybe
  (Positional ParamName,
   Positional (Maybe (CallArgLabel c), InputValue c))
_pcParentCall = forall a. Maybe a
Nothing
  }