{-# LANGUAGE GADTs #-}
module Language.Drasil.Mod (Class(..), StateVariable(..), Func(..),
FuncData(..), FuncDef(..), FuncStmt(..), Initializer, Mod(..), Name,
Version, Description, Import, ($:=), pubStateVar, privStateVar, classDef,
classImplements, ctorDef, ffor, fforRange, fDecDef, fname, fstdecl, funcData, funcDef,
funcDefParams, packmod, packmodRequires
) where
import Language.Drasil (Space, MayHaveUnit, Quantity, CodeExpr, LiteralC(..))
import Database.Drasil (ChunkDB)
import Drasil.GOOL (VisibilityTag(..))
import Language.Drasil.Chunk.Code (CodeVarChunk, CodeFuncChunk, codevars,
codevars', quantvar)
import Language.Drasil.Chunk.Parameter (ParameterChunk, pcAuto)
import Language.Drasil.Code.DataDesc (DataDesc)
import Utils.Drasil (toPlainName)
import Data.List ((\\), nub)
type Name = String
type Description = String
type Import = String
type Version = String
data Mod = Mod Name Description [Import] [Class] [Func]
packmod :: Name -> Description -> [Class] -> [Func] -> Mod
packmod :: Name -> Name -> [Class] -> [Func] -> Mod
packmod Name
n Name
d = Name -> Name -> [Name] -> [Class] -> [Func] -> Mod
packmodRequires Name
n Name
d []
packmodRequires :: Name -> Description -> [Import] -> [Class] -> [Func] -> Mod
packmodRequires :: Name -> Name -> [Name] -> [Class] -> [Func] -> Mod
packmodRequires Name
n = Name -> Name -> [Name] -> [Class] -> [Func] -> Mod
Mod (Name -> Name
toPlainName Name
n)
data Class = ClassDef {
Class -> Name
className :: Name,
Class -> Maybe Name
implements :: Maybe Name,
Class -> Name
classDesc :: Description,
Class -> [StateVariable]
stateVars :: [StateVariable],
Class -> [Func]
constructors :: [Func],
Class -> [Func]
methods :: [Func]}
data StateVariable = SV {
StateVariable -> VisibilityTag
svVisibility :: VisibilityTag,
StateVariable -> CodeVarChunk
stVar :: CodeVarChunk}
pubStateVar :: CodeVarChunk -> StateVariable
pubStateVar :: CodeVarChunk -> StateVariable
pubStateVar = VisibilityTag -> CodeVarChunk -> StateVariable
SV VisibilityTag
Pub
privStateVar :: CodeVarChunk -> StateVariable
privStateVar :: CodeVarChunk -> StateVariable
privStateVar = VisibilityTag -> CodeVarChunk -> StateVariable
SV VisibilityTag
Priv
classDef :: Name -> Description -> [StateVariable] -> [Func] -> [Func] -> Class
classDef :: Name -> Name -> [StateVariable] -> [Func] -> [Func] -> Class
classDef Name
n = Name
-> Maybe Name
-> Name
-> [StateVariable]
-> [Func]
-> [Func]
-> Class
ClassDef Name
n Maybe Name
forall a. Maybe a
Nothing
classImplements :: Name -> Name -> Description -> [StateVariable] -> [Func] ->
[Func] -> Class
classImplements :: Name
-> Name -> Name -> [StateVariable] -> [Func] -> [Func] -> Class
classImplements Name
n Name
i = Name
-> Maybe Name
-> Name
-> [StateVariable]
-> [Func]
-> [Func]
-> Class
ClassDef Name
n (Name -> Maybe Name
forall a. a -> Maybe a
Just Name
i)
data Func = FDef FuncDef
| FData FuncData
funcData :: Name -> Description -> DataDesc -> Func
funcData :: Name -> Name -> DataDesc -> Func
funcData Name
n Name
desc DataDesc
d = FuncData -> Func
FData (FuncData -> Func) -> FuncData -> Func
forall a b. (a -> b) -> a -> b
$ Name -> Name -> DataDesc -> FuncData
FuncData (Name -> Name
toPlainName Name
n) Name
desc DataDesc
d
funcDef :: (Quantity c, MayHaveUnit c) => Name -> Description -> [c] ->
Space -> Maybe Description -> [FuncStmt] -> Func
funcDef :: forall c.
(Quantity c, MayHaveUnit c) =>
Name -> Name -> [c] -> Space -> Maybe Name -> [FuncStmt] -> Func
funcDef Name
s Name
desc [c]
i Space
t Maybe Name
returnDesc [FuncStmt]
fs = FuncDef -> Func
FDef (FuncDef -> Func) -> FuncDef -> Func
forall a b. (a -> b) -> a -> b
$ Name
-> Name
-> [ParameterChunk]
-> Space
-> Maybe Name
-> [FuncStmt]
-> FuncDef
FuncDef (Name -> Name
toPlainName Name
s) Name
desc
((c -> ParameterChunk) -> [c] -> [ParameterChunk]
forall a b. (a -> b) -> [a] -> [b]
map (CodeVarChunk -> ParameterChunk
forall c. CodeIdea c => c -> ParameterChunk
pcAuto (CodeVarChunk -> ParameterChunk)
-> (c -> CodeVarChunk) -> c -> ParameterChunk
forall b c a. (b -> c) -> (a -> b) -> a -> c
. c -> CodeVarChunk
forall c. (Quantity c, MayHaveUnit c) => c -> CodeVarChunk
quantvar) [c]
i) Space
t Maybe Name
returnDesc [FuncStmt]
fs
funcDefParams :: Name -> Description -> [ParameterChunk] -> Space ->
Maybe Description -> [FuncStmt] -> Func
funcDefParams :: Name
-> Name
-> [ParameterChunk]
-> Space
-> Maybe Name
-> [FuncStmt]
-> Func
funcDefParams Name
s Name
desc [ParameterChunk]
ps Space
t Maybe Name
returnDesc [FuncStmt]
fs = FuncDef -> Func
FDef (FuncDef -> Func) -> FuncDef -> Func
forall a b. (a -> b) -> a -> b
$ Name
-> Name
-> [ParameterChunk]
-> Space
-> Maybe Name
-> [FuncStmt]
-> FuncDef
FuncDef (Name -> Name
toPlainName Name
s) Name
desc
[ParameterChunk]
ps Space
t Maybe Name
returnDesc [FuncStmt]
fs
ctorDef :: Name -> Description -> [ParameterChunk] -> [Initializer] ->
[FuncStmt] -> Func
ctorDef :: Name
-> Name -> [ParameterChunk] -> [Initializer] -> [FuncStmt] -> Func
ctorDef Name
n Name
desc [ParameterChunk]
ps [Initializer]
is [FuncStmt]
fs = FuncDef -> Func
FDef (FuncDef -> Func) -> FuncDef -> Func
forall a b. (a -> b) -> a -> b
$ Name
-> Name
-> [ParameterChunk]
-> [Initializer]
-> [FuncStmt]
-> FuncDef
CtorDef Name
n Name
desc [ParameterChunk]
ps [Initializer]
is [FuncStmt]
fs
data FuncData where
FuncData :: Name -> Description -> DataDesc -> FuncData
data FuncDef where
FuncDef :: Name -> Description -> [ParameterChunk] -> Space ->
Maybe Description -> [FuncStmt] -> FuncDef
CtorDef :: Name -> Description -> [ParameterChunk] -> [Initializer] ->
[FuncStmt] -> FuncDef
type Initializer = (CodeVarChunk, CodeExpr)
data FuncStmt where
FAsg :: CodeVarChunk -> CodeExpr -> FuncStmt
FAsgIndex :: CodeVarChunk -> Integer -> CodeExpr -> FuncStmt
FFor :: CodeVarChunk -> CodeExpr -> CodeExpr -> CodeExpr
-> [FuncStmt] -> FuncStmt
FForEach :: CodeVarChunk -> CodeExpr -> [FuncStmt] -> FuncStmt
FWhile :: CodeExpr -> [FuncStmt] -> FuncStmt
FCond :: CodeExpr -> [FuncStmt] -> [FuncStmt] -> FuncStmt
FRet :: CodeExpr -> FuncStmt
FThrow :: String -> FuncStmt
FTry :: [FuncStmt] -> [FuncStmt] -> FuncStmt
FContinue :: FuncStmt
FDecDef :: CodeVarChunk -> CodeExpr -> FuncStmt
FFuncDef :: CodeFuncChunk -> [ParameterChunk] -> [FuncStmt] -> FuncStmt
FVal :: CodeExpr -> FuncStmt
FMulti :: [FuncStmt] -> FuncStmt
FAppend :: CodeExpr -> CodeExpr -> FuncStmt
($:=) :: (Quantity c, MayHaveUnit c) => c -> CodeExpr -> FuncStmt
c
v $:= :: forall c. (Quantity c, MayHaveUnit c) => c -> CodeExpr -> FuncStmt
$:= CodeExpr
e = CodeVarChunk -> CodeExpr -> FuncStmt
FAsg (c -> CodeVarChunk
forall c. (Quantity c, MayHaveUnit c) => c -> CodeVarChunk
quantvar c
v) CodeExpr
e
ffor :: (Quantity c, MayHaveUnit c) => c -> CodeExpr -> [FuncStmt] -> FuncStmt
ffor :: forall c.
(Quantity c, MayHaveUnit c) =>
c -> CodeExpr -> [FuncStmt] -> FuncStmt
ffor c
v CodeExpr
end = c -> CodeExpr -> CodeExpr -> CodeExpr -> [FuncStmt] -> FuncStmt
forall c.
(Quantity c, MayHaveUnit c) =>
c -> CodeExpr -> CodeExpr -> CodeExpr -> [FuncStmt] -> FuncStmt
fforRange c
v (Integer -> CodeExpr
forall r. LiteralC r => Integer -> r
int Integer
0) CodeExpr
end (Integer -> CodeExpr
forall r. LiteralC r => Integer -> r
int Integer
1)
fforRange :: (Quantity c, MayHaveUnit c) => c -> CodeExpr -> CodeExpr
-> CodeExpr -> [FuncStmt] -> FuncStmt
fforRange :: forall c.
(Quantity c, MayHaveUnit c) =>
c -> CodeExpr -> CodeExpr -> CodeExpr -> [FuncStmt] -> FuncStmt
fforRange c
v = CodeVarChunk
-> CodeExpr -> CodeExpr -> CodeExpr -> [FuncStmt] -> FuncStmt
FFor (c -> CodeVarChunk
forall c. (Quantity c, MayHaveUnit c) => c -> CodeVarChunk
quantvar c
v)
fDecDef :: (Quantity c, MayHaveUnit c) => c -> CodeExpr -> FuncStmt
fDecDef :: forall c. (Quantity c, MayHaveUnit c) => c -> CodeExpr -> FuncStmt
fDecDef c
v = CodeVarChunk -> CodeExpr -> FuncStmt
FDecDef (c -> CodeVarChunk
forall c. (Quantity c, MayHaveUnit c) => c -> CodeVarChunk
quantvar c
v)
fstdecl :: ChunkDB -> [FuncStmt] -> [CodeVarChunk]
fstdecl :: ChunkDB -> [FuncStmt] -> [CodeVarChunk]
fstdecl ChunkDB
ctx [FuncStmt]
fsts = [CodeVarChunk] -> [CodeVarChunk]
forall a. Eq a => [a] -> [a]
nub ((FuncStmt -> [CodeVarChunk]) -> [FuncStmt] -> [CodeVarChunk]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (ChunkDB -> FuncStmt -> [CodeVarChunk]
fstvars ChunkDB
ctx) [FuncStmt]
fsts) [CodeVarChunk] -> [CodeVarChunk] -> [CodeVarChunk]
forall a. Eq a => [a] -> [a] -> [a]
\\ [CodeVarChunk] -> [CodeVarChunk]
forall a. Eq a => [a] -> [a]
nub ((FuncStmt -> [CodeVarChunk]) -> [FuncStmt] -> [CodeVarChunk]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (ChunkDB -> FuncStmt -> [CodeVarChunk]
declared ChunkDB
ctx) [FuncStmt]
fsts)
where
fstvars :: ChunkDB -> FuncStmt -> [CodeVarChunk]
fstvars :: ChunkDB -> FuncStmt -> [CodeVarChunk]
fstvars ChunkDB
sm (FDecDef CodeVarChunk
cch CodeExpr
e) = CodeVarChunk
cchCodeVarChunk -> [CodeVarChunk] -> [CodeVarChunk]
forall a. a -> [a] -> [a]
:CodeExpr -> ChunkDB -> [CodeVarChunk]
codevars' CodeExpr
e ChunkDB
sm
fstvars ChunkDB
sm (FFuncDef CodeFuncChunk
cch [ParameterChunk]
ps [FuncStmt]
sts) = CodeFuncChunk -> CodeVarChunk
forall c. (Quantity c, MayHaveUnit c) => c -> CodeVarChunk
quantvar CodeFuncChunk
cch CodeVarChunk -> [CodeVarChunk] -> [CodeVarChunk]
forall a. a -> [a] -> [a]
: (ParameterChunk -> CodeVarChunk)
-> [ParameterChunk] -> [CodeVarChunk]
forall a b. (a -> b) -> [a] -> [b]
map ParameterChunk -> CodeVarChunk
forall c. (Quantity c, MayHaveUnit c) => c -> CodeVarChunk
quantvar [ParameterChunk]
ps
[CodeVarChunk] -> [CodeVarChunk] -> [CodeVarChunk]
forall a. [a] -> [a] -> [a]
++ (FuncStmt -> [CodeVarChunk]) -> [FuncStmt] -> [CodeVarChunk]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (ChunkDB -> FuncStmt -> [CodeVarChunk]
fstvars ChunkDB
sm) [FuncStmt]
sts
fstvars ChunkDB
sm (FAsg CodeVarChunk
cch CodeExpr
e) = CodeVarChunk
cchCodeVarChunk -> [CodeVarChunk] -> [CodeVarChunk]
forall a. a -> [a] -> [a]
:CodeExpr -> ChunkDB -> [CodeVarChunk]
codevars' CodeExpr
e ChunkDB
sm
fstvars ChunkDB
sm (FAsgIndex CodeVarChunk
cch Integer
_ CodeExpr
e) = CodeVarChunk
cchCodeVarChunk -> [CodeVarChunk] -> [CodeVarChunk]
forall a. a -> [a] -> [a]
:CodeExpr -> ChunkDB -> [CodeVarChunk]
codevars' CodeExpr
e ChunkDB
sm
fstvars ChunkDB
sm (FFor CodeVarChunk
cch CodeExpr
s CodeExpr
e CodeExpr
st [FuncStmt]
fs) = [CodeVarChunk] -> [CodeVarChunk]
forall a. Eq a => [a] -> [a]
nub ([CodeVarChunk] -> [CodeVarChunk])
-> [CodeVarChunk] -> [CodeVarChunk]
forall a b. (a -> b) -> a -> b
$ CodeVarChunk
cch CodeVarChunk -> [CodeVarChunk] -> [CodeVarChunk]
forall a. a -> [a] -> [a]
: CodeExpr -> ChunkDB -> [CodeVarChunk]
codevars' CodeExpr
e ChunkDB
sm [CodeVarChunk] -> [CodeVarChunk] -> [CodeVarChunk]
forall a. [a] -> [a] -> [a]
++ CodeExpr -> ChunkDB -> [CodeVarChunk]
codevars' CodeExpr
s ChunkDB
sm
[CodeVarChunk] -> [CodeVarChunk] -> [CodeVarChunk]
forall a. [a] -> [a] -> [a]
++ CodeExpr -> ChunkDB -> [CodeVarChunk]
codevars' CodeExpr
st ChunkDB
sm [CodeVarChunk] -> [CodeVarChunk] -> [CodeVarChunk]
forall a. [a] -> [a] -> [a]
++ (FuncStmt -> [CodeVarChunk]) -> [FuncStmt] -> [CodeVarChunk]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (ChunkDB -> FuncStmt -> [CodeVarChunk]
fstvars ChunkDB
sm) [FuncStmt]
fs
fstvars ChunkDB
sm (FForEach CodeVarChunk
cch CodeExpr
e [FuncStmt]
fs) = [CodeVarChunk] -> [CodeVarChunk]
forall a. Eq a => [a] -> [a]
nub (CodeVarChunk
cch CodeVarChunk -> [CodeVarChunk] -> [CodeVarChunk]
forall a. a -> [a] -> [a]
: CodeExpr -> ChunkDB -> [CodeVarChunk]
codevars' CodeExpr
e ChunkDB
sm [CodeVarChunk] -> [CodeVarChunk] -> [CodeVarChunk]
forall a. [a] -> [a] -> [a]
++ (FuncStmt -> [CodeVarChunk]) -> [FuncStmt] -> [CodeVarChunk]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (ChunkDB -> FuncStmt -> [CodeVarChunk]
fstvars ChunkDB
sm) [FuncStmt]
fs)
fstvars ChunkDB
sm (FWhile CodeExpr
e [FuncStmt]
fs) = CodeExpr -> ChunkDB -> [CodeVarChunk]
codevars' CodeExpr
e ChunkDB
sm [CodeVarChunk] -> [CodeVarChunk] -> [CodeVarChunk]
forall a. [a] -> [a] -> [a]
++ (FuncStmt -> [CodeVarChunk]) -> [FuncStmt] -> [CodeVarChunk]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (ChunkDB -> FuncStmt -> [CodeVarChunk]
fstvars ChunkDB
sm) [FuncStmt]
fs
fstvars ChunkDB
sm (FCond CodeExpr
e [FuncStmt]
tfs [FuncStmt]
efs) = CodeExpr -> ChunkDB -> [CodeVarChunk]
codevars' CodeExpr
e ChunkDB
sm [CodeVarChunk] -> [CodeVarChunk] -> [CodeVarChunk]
forall a. [a] -> [a] -> [a]
++ (FuncStmt -> [CodeVarChunk]) -> [FuncStmt] -> [CodeVarChunk]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (ChunkDB -> FuncStmt -> [CodeVarChunk]
fstvars ChunkDB
sm) [FuncStmt]
tfs [CodeVarChunk] -> [CodeVarChunk] -> [CodeVarChunk]
forall a. [a] -> [a] -> [a]
++ (FuncStmt -> [CodeVarChunk]) -> [FuncStmt] -> [CodeVarChunk]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (ChunkDB -> FuncStmt -> [CodeVarChunk]
fstvars ChunkDB
sm) [FuncStmt]
efs
fstvars ChunkDB
sm (FRet CodeExpr
e) = CodeExpr -> ChunkDB -> [CodeVarChunk]
codevars' CodeExpr
e ChunkDB
sm
fstvars ChunkDB
sm (FTry [FuncStmt]
tfs [FuncStmt]
cfs) = (FuncStmt -> [CodeVarChunk]) -> [FuncStmt] -> [CodeVarChunk]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (ChunkDB -> FuncStmt -> [CodeVarChunk]
fstvars ChunkDB
sm) [FuncStmt]
tfs [CodeVarChunk] -> [CodeVarChunk] -> [CodeVarChunk]
forall a. [a] -> [a] -> [a]
++ (FuncStmt -> [CodeVarChunk]) -> [FuncStmt] -> [CodeVarChunk]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (ChunkDB -> FuncStmt -> [CodeVarChunk]
fstvars ChunkDB
sm ) [FuncStmt]
cfs
fstvars ChunkDB
_ (FThrow Name
_) = []
fstvars ChunkDB
_ FuncStmt
FContinue = []
fstvars ChunkDB
sm (FVal CodeExpr
v) = CodeExpr -> ChunkDB -> [CodeVarChunk]
codevars' CodeExpr
v ChunkDB
sm
fstvars ChunkDB
sm (FMulti [FuncStmt]
ss) = (FuncStmt -> [CodeVarChunk]) -> [FuncStmt] -> [CodeVarChunk]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (ChunkDB -> FuncStmt -> [CodeVarChunk]
fstvars ChunkDB
sm) [FuncStmt]
ss
fstvars ChunkDB
sm (FAppend CodeExpr
a CodeExpr
b) = [CodeVarChunk] -> [CodeVarChunk]
forall a. Eq a => [a] -> [a]
nub (CodeExpr -> ChunkDB -> [CodeVarChunk]
codevars CodeExpr
a ChunkDB
sm [CodeVarChunk] -> [CodeVarChunk] -> [CodeVarChunk]
forall a. [a] -> [a] -> [a]
++ CodeExpr -> ChunkDB -> [CodeVarChunk]
codevars CodeExpr
b ChunkDB
sm)
declared :: ChunkDB -> FuncStmt -> [CodeVarChunk]
declared :: ChunkDB -> FuncStmt -> [CodeVarChunk]
declared ChunkDB
_ (FDecDef CodeVarChunk
cch CodeExpr
_) = [CodeVarChunk
cch]
declared ChunkDB
sm (FFuncDef CodeFuncChunk
cch [ParameterChunk]
ps [FuncStmt]
sts) = CodeFuncChunk -> CodeVarChunk
forall c. (Quantity c, MayHaveUnit c) => c -> CodeVarChunk
quantvar CodeFuncChunk
cch CodeVarChunk -> [CodeVarChunk] -> [CodeVarChunk]
forall a. a -> [a] -> [a]
: (ParameterChunk -> CodeVarChunk)
-> [ParameterChunk] -> [CodeVarChunk]
forall a b. (a -> b) -> [a] -> [b]
map ParameterChunk -> CodeVarChunk
forall c. (Quantity c, MayHaveUnit c) => c -> CodeVarChunk
quantvar [ParameterChunk]
ps
[CodeVarChunk] -> [CodeVarChunk] -> [CodeVarChunk]
forall a. [a] -> [a] -> [a]
++ (FuncStmt -> [CodeVarChunk]) -> [FuncStmt] -> [CodeVarChunk]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (ChunkDB -> FuncStmt -> [CodeVarChunk]
declared ChunkDB
sm) [FuncStmt]
sts
declared ChunkDB
_ (FAsg CodeVarChunk
_ CodeExpr
_) = []
declared ChunkDB
_ FAsgIndex {} = []
declared ChunkDB
sm (FFor CodeVarChunk
cch CodeExpr
_ CodeExpr
_ CodeExpr
_ [FuncStmt]
fs) = CodeVarChunk
cch CodeVarChunk -> [CodeVarChunk] -> [CodeVarChunk]
forall a. a -> [a] -> [a]
: (FuncStmt -> [CodeVarChunk]) -> [FuncStmt] -> [CodeVarChunk]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (ChunkDB -> FuncStmt -> [CodeVarChunk]
declared ChunkDB
sm) [FuncStmt]
fs
declared ChunkDB
sm (FForEach CodeVarChunk
cch CodeExpr
_ [FuncStmt]
fs) = CodeVarChunk
cch CodeVarChunk -> [CodeVarChunk] -> [CodeVarChunk]
forall a. a -> [a] -> [a]
: (FuncStmt -> [CodeVarChunk]) -> [FuncStmt] -> [CodeVarChunk]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (ChunkDB -> FuncStmt -> [CodeVarChunk]
declared ChunkDB
sm) [FuncStmt]
fs
declared ChunkDB
sm (FWhile CodeExpr
_ [FuncStmt]
fs) = (FuncStmt -> [CodeVarChunk]) -> [FuncStmt] -> [CodeVarChunk]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (ChunkDB -> FuncStmt -> [CodeVarChunk]
declared ChunkDB
sm) [FuncStmt]
fs
declared ChunkDB
sm (FCond CodeExpr
_ [FuncStmt]
tfs [FuncStmt]
efs) = (FuncStmt -> [CodeVarChunk]) -> [FuncStmt] -> [CodeVarChunk]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (ChunkDB -> FuncStmt -> [CodeVarChunk]
declared ChunkDB
sm) [FuncStmt]
tfs [CodeVarChunk] -> [CodeVarChunk] -> [CodeVarChunk]
forall a. [a] -> [a] -> [a]
++ (FuncStmt -> [CodeVarChunk]) -> [FuncStmt] -> [CodeVarChunk]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (ChunkDB -> FuncStmt -> [CodeVarChunk]
declared ChunkDB
sm) [FuncStmt]
efs
declared ChunkDB
_ (FRet CodeExpr
_) = []
declared ChunkDB
sm (FTry [FuncStmt]
tfs [FuncStmt]
cfs) = (FuncStmt -> [CodeVarChunk]) -> [FuncStmt] -> [CodeVarChunk]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (ChunkDB -> FuncStmt -> [CodeVarChunk]
declared ChunkDB
sm) [FuncStmt]
tfs [CodeVarChunk] -> [CodeVarChunk] -> [CodeVarChunk]
forall a. [a] -> [a] -> [a]
++ (FuncStmt -> [CodeVarChunk]) -> [FuncStmt] -> [CodeVarChunk]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (ChunkDB -> FuncStmt -> [CodeVarChunk]
declared ChunkDB
sm) [FuncStmt]
cfs
declared ChunkDB
_ (FThrow Name
_) = []
declared ChunkDB
_ FuncStmt
FContinue = []
declared ChunkDB
_ (FVal CodeExpr
_) = []
declared ChunkDB
sm (FMulti [FuncStmt]
ss) = (FuncStmt -> [CodeVarChunk]) -> [FuncStmt] -> [CodeVarChunk]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (ChunkDB -> FuncStmt -> [CodeVarChunk]
declared ChunkDB
sm) [FuncStmt]
ss
declared ChunkDB
_ (FAppend CodeExpr
_ CodeExpr
_) = []
fname :: Func -> Name
fname :: Func -> Name
fname (FDef (FuncDef Name
n Name
_ [ParameterChunk]
_ Space
_ Maybe Name
_ [FuncStmt]
_)) = Name
n
fname (FDef (CtorDef Name
n Name
_ [ParameterChunk]
_ [Initializer]
_ [FuncStmt]
_)) = Name
n
fname (FData (FuncData Name
n Name
_ DataDesc
_)) = Name
n