module Language.Drasil.Code.ExternalLibraryCall (ExternalLibraryCall,
StepGroupFill(..), StepFill(..), FunctionIntFill(..), ArgumentFill(..),
ParameterFill(..), ClassInfoFill(..), MethodInfoFill(..), externalLibCall,
choiceStepsFill, choiceStepFill, mandatoryStepFill, mandatoryStepsFill,
callStepFill, libCallFill, userDefinedArgFill, basicArgFill, functionArgFill,
customObjArgFill, recordArgFill, unnamedParamFill, unnamedParamPBVFill,
userDefinedParamFill, customClassFill, implementationFill,
constructorInfoFill, methodInfoFill, appendCurrSolFill, populateSolListFill,
assignArrayIndexFill, assignSolFromObjFill, initSolListFromArrayFill,
initSolListWithValFill, solveAndPopulateWhileFill, returnExprListFill,
fixedStatementFill, fixedStatementFill', initSolWithValFill
) where
import Language.Drasil.Chunk.Code (CodeVarChunk)
import Language.Drasil.Chunk.Parameter (ParameterChunk, pcAuto, pcVal)
import Language.Drasil.Chunk.NamedArgument (NamedArgument)
import Language.Drasil (CodeExpr)
import Language.Drasil.Mod (Initializer, StateVariable)
import Data.List.NonEmpty (NonEmpty(..), fromList)
type ExternalLibraryCall = [StepGroupFill]
data StepGroupFill = SGF Int [StepFill]
data StepFill = CallF FunctionIntFill
| LoopF (NonEmpty FunctionIntFill) [CodeExpr] (NonEmpty StepFill)
| StatementF [CodeVarChunk] [CodeExpr]
newtype FunctionIntFill = FIF [ArgumentFill]
data ArgumentFill = UserDefinedArgF (Maybe NamedArgument) CodeExpr
| BasicF CodeExpr
| FnF [ParameterFill] StepFill
| ClassF [StateVariable] ClassInfoFill
| RecordF [CodeExpr]
data ParameterFill = NameableParamF ParameterChunk | UserDefined ParameterChunk
data ClassInfoFill = RegularF [MethodInfoFill] | ImplementsF [MethodInfoFill]
data MethodInfoFill = CIF [ParameterFill] [Initializer] [StepFill]
| MIF [ParameterFill] (NonEmpty StepFill)
externalLibCall :: [StepGroupFill] -> ExternalLibraryCall
externalLibCall :: [StepGroupFill] -> [StepGroupFill]
externalLibCall = [StepGroupFill] -> [StepGroupFill]
forall a. a -> a
id
choiceStepsFill :: Int -> [StepFill] -> StepGroupFill
choiceStepsFill :: Int -> [StepFill] -> StepGroupFill
choiceStepsFill = Int -> [StepFill] -> StepGroupFill
SGF
choiceStepFill :: Int -> StepFill -> StepGroupFill
choiceStepFill :: Int -> StepFill -> StepGroupFill
choiceStepFill Int
i StepFill
s = Int -> [StepFill] -> StepGroupFill
SGF Int
i [StepFill
s]
mandatoryStepFill :: StepFill -> StepGroupFill
mandatoryStepFill :: StepFill -> StepGroupFill
mandatoryStepFill StepFill
s = Int -> [StepFill] -> StepGroupFill
SGF Int
0 [StepFill
s]
mandatoryStepsFill :: [StepFill] -> StepGroupFill
mandatoryStepsFill :: [StepFill] -> StepGroupFill
mandatoryStepsFill = Int -> [StepFill] -> StepGroupFill
SGF Int
0
callStepFill :: FunctionIntFill -> StepFill
callStepFill :: FunctionIntFill -> StepFill
callStepFill = FunctionIntFill -> StepFill
CallF
loopStepFill :: [FunctionIntFill] -> [CodeExpr] -> [StepFill] -> StepFill
loopStepFill :: [FunctionIntFill] -> [CodeExpr] -> [StepFill] -> StepFill
loopStepFill [] [CodeExpr]
_ [StepFill]
_ = [Char] -> StepFill
forall a. HasCallStack => [Char] -> a
error [Char]
"loopStepFill should be called with a non-empty list of FunctionInterfaceFill"
loopStepFill [FunctionIntFill]
_ [CodeExpr]
_ [] = [Char] -> StepFill
forall a. HasCallStack => [Char] -> a
error [Char]
"loopStepFill should be called with a non-empty list of StepFill"
loopStepFill [FunctionIntFill]
fifs [CodeExpr]
cdchs [StepFill]
sfs = NonEmpty FunctionIntFill
-> [CodeExpr] -> NonEmpty StepFill -> StepFill
LoopF ([FunctionIntFill] -> NonEmpty FunctionIntFill
forall a. HasCallStack => [a] -> NonEmpty a
fromList [FunctionIntFill]
fifs) [CodeExpr]
cdchs ([StepFill] -> NonEmpty StepFill
forall a. HasCallStack => [a] -> NonEmpty a
fromList [StepFill]
sfs)
libCallFill :: [ArgumentFill] -> FunctionIntFill
libCallFill :: [ArgumentFill] -> FunctionIntFill
libCallFill = [ArgumentFill] -> FunctionIntFill
FIF
userDefinedArgFill :: CodeExpr -> ArgumentFill
userDefinedArgFill :: CodeExpr -> ArgumentFill
userDefinedArgFill = Maybe NamedArgument -> CodeExpr -> ArgumentFill
UserDefinedArgF Maybe NamedArgument
forall a. Maybe a
Nothing
basicArgFill :: CodeExpr -> ArgumentFill
basicArgFill :: CodeExpr -> ArgumentFill
basicArgFill = CodeExpr -> ArgumentFill
BasicF
functionArgFill :: [ParameterFill] -> StepFill -> ArgumentFill
functionArgFill :: [ParameterFill] -> StepFill -> ArgumentFill
functionArgFill = [ParameterFill] -> StepFill -> ArgumentFill
FnF
customObjArgFill :: [StateVariable] -> ClassInfoFill -> ArgumentFill
customObjArgFill :: [StateVariable] -> ClassInfoFill -> ArgumentFill
customObjArgFill = [StateVariable] -> ClassInfoFill -> ArgumentFill
ClassF
recordArgFill :: [CodeExpr] -> ArgumentFill
recordArgFill :: [CodeExpr] -> ArgumentFill
recordArgFill = [CodeExpr] -> ArgumentFill
RecordF
unnamedParamFill :: CodeVarChunk -> ParameterFill
unnamedParamFill :: CodeVarChunk -> ParameterFill
unnamedParamFill = ParameterChunk -> ParameterFill
NameableParamF (ParameterChunk -> ParameterFill)
-> (CodeVarChunk -> ParameterChunk)
-> CodeVarChunk
-> ParameterFill
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CodeVarChunk -> ParameterChunk
forall c. CodeIdea c => c -> ParameterChunk
pcAuto
unnamedParamPBVFill :: CodeVarChunk -> ParameterFill
unnamedParamPBVFill :: CodeVarChunk -> ParameterFill
unnamedParamPBVFill = ParameterChunk -> ParameterFill
NameableParamF (ParameterChunk -> ParameterFill)
-> (CodeVarChunk -> ParameterChunk)
-> CodeVarChunk
-> ParameterFill
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CodeVarChunk -> ParameterChunk
forall c. CodeIdea c => c -> ParameterChunk
pcVal
userDefinedParamFill :: CodeVarChunk -> ParameterFill
userDefinedParamFill :: CodeVarChunk -> ParameterFill
userDefinedParamFill = ParameterChunk -> ParameterFill
UserDefined (ParameterChunk -> ParameterFill)
-> (CodeVarChunk -> ParameterChunk)
-> CodeVarChunk
-> ParameterFill
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CodeVarChunk -> ParameterChunk
forall c. CodeIdea c => c -> ParameterChunk
pcAuto
customClassFill :: [MethodInfoFill] -> ClassInfoFill
customClassFill :: [MethodInfoFill] -> ClassInfoFill
customClassFill = [MethodInfoFill] -> ClassInfoFill
RegularF
implementationFill :: [MethodInfoFill] -> ClassInfoFill
implementationFill :: [MethodInfoFill] -> ClassInfoFill
implementationFill = [MethodInfoFill] -> ClassInfoFill
ImplementsF
constructorInfoFill :: [ParameterFill] -> [Initializer] -> [StepFill] ->
MethodInfoFill
constructorInfoFill :: [ParameterFill] -> [Initializer] -> [StepFill] -> MethodInfoFill
constructorInfoFill = [ParameterFill] -> [Initializer] -> [StepFill] -> MethodInfoFill
CIF
methodInfoFill :: [ParameterFill] -> [StepFill] -> MethodInfoFill
methodInfoFill :: [ParameterFill] -> [StepFill] -> MethodInfoFill
methodInfoFill [ParameterFill]
_ [] = [Char] -> MethodInfoFill
forall a. HasCallStack => [Char] -> a
error [Char]
"methodInfoFill should be called with non-empty list of StepFill"
methodInfoFill [ParameterFill]
pfs [StepFill]
sfs = [ParameterFill] -> NonEmpty StepFill -> MethodInfoFill
MIF [ParameterFill]
pfs ([StepFill] -> NonEmpty StepFill
forall a. HasCallStack => [a] -> NonEmpty a
fromList [StepFill]
sfs)
appendCurrSolFill :: CodeVarChunk -> StepFill
appendCurrSolFill :: CodeVarChunk -> StepFill
appendCurrSolFill CodeVarChunk
s = [CodeVarChunk] -> [CodeExpr] -> StepFill
statementStepFill [CodeVarChunk
s] []
populateSolListFill :: CodeVarChunk -> [StepFill]
populateSolListFill :: CodeVarChunk -> [StepFill]
populateSolListFill CodeVarChunk
s = Int -> StepFill -> [StepFill]
forall a. Int -> a -> [a]
replicate Int
2 ([CodeVarChunk] -> [CodeExpr] -> StepFill
statementStepFill [CodeVarChunk
s] [])
assignArrayIndexFill :: CodeVarChunk-> [CodeExpr] -> StepFill
assignArrayIndexFill :: CodeVarChunk -> [CodeExpr] -> StepFill
assignArrayIndexFill CodeVarChunk
a = [CodeVarChunk] -> [CodeExpr] -> StepFill
statementStepFill [CodeVarChunk
a]
assignSolFromObjFill :: CodeVarChunk -> StepFill
assignSolFromObjFill :: CodeVarChunk -> StepFill
assignSolFromObjFill CodeVarChunk
s = [CodeVarChunk] -> [CodeExpr] -> StepFill
statementStepFill [CodeVarChunk
s] []
initSolListFromArrayFill :: CodeVarChunk -> StepFill
initSolListFromArrayFill :: CodeVarChunk -> StepFill
initSolListFromArrayFill CodeVarChunk
s = [CodeVarChunk] -> [CodeExpr] -> StepFill
statementStepFill [CodeVarChunk
s] []
initSolListWithValFill :: CodeVarChunk -> CodeExpr -> StepFill
initSolListWithValFill :: CodeVarChunk -> CodeExpr -> StepFill
initSolListWithValFill CodeVarChunk
s CodeExpr
v = [CodeVarChunk] -> [CodeExpr] -> StepFill
statementStepFill [CodeVarChunk
s] [CodeExpr
v]
solveAndPopulateWhileFill :: FunctionIntFill -> CodeExpr -> FunctionIntFill ->
CodeVarChunk -> StepFill
solveAndPopulateWhileFill :: FunctionIntFill
-> CodeExpr -> FunctionIntFill -> CodeVarChunk -> StepFill
solveAndPopulateWhileFill FunctionIntFill
lcf CodeExpr
ub FunctionIntFill
slvf CodeVarChunk
s = [FunctionIntFill] -> [CodeExpr] -> [StepFill] -> StepFill
loopStepFill [FunctionIntFill
lcf] [CodeExpr
ub]
[FunctionIntFill -> StepFill
callStepFill FunctionIntFill
slvf, CodeVarChunk -> StepFill
appendCurrSolFill CodeVarChunk
s]
returnExprListFill :: [CodeExpr] -> StepFill
returnExprListFill :: [CodeExpr] -> StepFill
returnExprListFill = [CodeVarChunk] -> [CodeExpr] -> StepFill
statementStepFill []
statementStepFill :: [CodeVarChunk] -> [CodeExpr] -> StepFill
statementStepFill :: [CodeVarChunk] -> [CodeExpr] -> StepFill
statementStepFill = [CodeVarChunk] -> [CodeExpr] -> StepFill
StatementF
fixedStatementFill :: StepFill
fixedStatementFill :: StepFill
fixedStatementFill = [CodeVarChunk] -> [CodeExpr] -> StepFill
StatementF [] []
fixedStatementFill' :: CodeExpr -> StepFill
fixedStatementFill' :: CodeExpr -> StepFill
fixedStatementFill' CodeExpr
a = [CodeVarChunk] -> [CodeExpr] -> StepFill
StatementF [] [CodeExpr
a]
initSolWithValFill :: CodeVarChunk -> CodeExpr -> StepFill
initSolWithValFill :: CodeVarChunk -> CodeExpr -> StepFill
initSolWithValFill CodeVarChunk
s CodeExpr
v = [CodeVarChunk] -> [CodeExpr] -> StepFill
statementStepFill [CodeVarChunk
s] [CodeExpr
v]