{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FunctionalDependencies #-}
module Drasil.Shared.InterfaceCommon (
Label, Library, Body, Block, VSBinder, Variable, SVariable, Value, SValue,
NamedArgs, MixedCall, MixedCtorCall, PosCall, PosCtorCall, InOutCall,
InOutFunc, DocInOutFunc,
UnRepr(..), BodySym(..), bodyStatements, oneLiner, BlockSym(..), TypeSym(..),
TypeElim(..), getTypeString, VariableSym(..), ScopeSym(..), convScope,
VariableElim(..), listOf, listVar, ValueSym(..), Argument(..), Literal(..),
litZero, MathConstant(..), VariableValue(..), CommandLineArgs(..),
NumericExpression(..), BooleanExpression(..), Comparison(..),
ValueExpression(..), funcApp, funcAppNamedArgs, extFuncApp, libFuncApp, exists,
IndexTranslator(..), Reference(..), Array(..), List(..), ListStatement(..),
Set(..), NativeVector(..), InternalList(..), listSlice, listIndexExists, at,
EmptyStatement(..), MultiStatement(..), ValueStatement(..),
AssignStatement(..), (&=), DeclStatement(..), PrintConsole(..),
ReadConsole(..), FileHandling(..), PrintFile(..), ReadFile(..),
StringStatement(..), FunctionSym, FuncAppStatement(..), CommentStatement(..),
ControlStatement(..), ifNoElse, switchAsIf, VisibilitySym(..),
ParameterSym(..), MethodSym(..), BinderSym(..), BinderElim(..), convType
) where
import Data.Bifunctor (first)
import Text.PrettyPrint.HughesPJ (Doc)
import Drasil.Shared.AST (ScopeData(..), ScopeTag(..), TypeData(..), BinderD,
ParamData, VarData, ValData)
import Drasil.Shared.CodeType (CodeType(..))
import Drasil.Shared.State (MS, VS)
type Label = String
type Library = String
class UnRepr repr contents where
unRepr :: repr contents -> contents
type Body = Doc
class BodySym r bod block | r -> bod block where
body :: [MS (r block)] -> MS (r bod)
:: Label -> MS (r bod) -> MS (r bod)
bodyStatements
:: (BlockSym r block stmt, BodySym r bod block) => [MS (r stmt)] -> MS (r bod)
bodyStatements :: forall {k} (r :: k -> *) (block :: k) (stmt :: k) (bod :: k).
(BlockSym r block stmt, BodySym r bod block) =>
[MS (r stmt)] -> MS (r bod)
bodyStatements [MS (r stmt)]
sts = [MS (r block)] -> MS (r bod)
forall {k} (r :: k -> *) (bod :: k) (block :: k).
BodySym r bod block =>
[MS (r block)] -> MS (r bod)
body [[MS (r stmt)] -> MS (r block)
forall {k} (r :: k -> *) (block :: k) (stmt :: k).
BlockSym r block stmt =>
[MS (r stmt)] -> MS (r block)
block [MS (r stmt)]
sts]
oneLiner
:: (BlockSym r block stmt, BodySym r bod block) => MS (r stmt) -> MS (r bod)
oneLiner :: forall {k} (r :: k -> *) (block :: k) (stmt :: k) (bod :: k).
(BlockSym r block stmt, BodySym r bod block) =>
MS (r stmt) -> MS (r bod)
oneLiner MS (r stmt)
tp = [MS (r stmt)] -> MS (r bod)
forall {k} (r :: k -> *) (block :: k) (stmt :: k) (bod :: k).
(BlockSym r block stmt, BodySym r bod block) =>
[MS (r stmt)] -> MS (r bod)
bodyStatements [MS (r stmt)
tp]
type Block = Doc
class BlockSym r block stmt | r -> block stmt where
block :: [MS (r stmt)] -> MS (r block)
class TypeSym r where
bool :: VS (r TypeData)
int :: VS (r TypeData)
float :: VS (r TypeData)
double :: VS (r TypeData)
char :: VS (r TypeData)
string :: VS (r TypeData)
infile :: VS (r TypeData)
outfile :: VS (r TypeData)
referenceType :: VS (r TypeData) -> VS (r TypeData)
listType :: VS (r TypeData) -> VS (r TypeData)
setType :: VS (r TypeData) -> VS (r TypeData)
arrayType :: VS (r TypeData) -> VS (r TypeData)
innerType :: VS (r TypeData) -> VS (r TypeData)
funcType :: [VS (r TypeData)] -> VS (r TypeData) -> VS (r TypeData)
void :: VS (r TypeData)
getTypeString :: (UnRepr r TypeData) => r TypeData -> String
getTypeString :: forall (r :: * -> *). UnRepr r TypeData => r TypeData -> String
getTypeString = TypeData -> String
typeString (TypeData -> String)
-> (r TypeData -> TypeData) -> r TypeData -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. r TypeData -> TypeData
forall (repr :: * -> *) contents.
UnRepr repr contents =>
repr contents -> contents
unRepr
class ScopeSym r where
global :: r ScopeData
mainFn :: r ScopeData
local :: r ScopeData
type Variable = VarData
type SVariable a = VS (a Variable)
class (TypeSym r) => VariableSym r where
var :: Label -> VS (r TypeData) -> SVariable r
constant :: Label -> VS (r TypeData) -> SVariable r
extVar :: Library -> Label -> VS (r TypeData) -> SVariable r
class (VariableSym r) => VariableElim r where
variableName :: r Variable -> String
variableType :: r Variable -> r TypeData
listVar :: (VariableSym r) => Label -> VS (r TypeData) -> SVariable r
listVar :: forall (r :: * -> *).
VariableSym r =>
String -> VS (r TypeData) -> SVariable r
listVar String
n VS (r TypeData)
t = String -> VS (r TypeData) -> SVariable r
forall (r :: * -> *).
VariableSym r =>
String -> VS (r TypeData) -> SVariable r
var String
n (VS (r TypeData) -> VS (r TypeData)
forall (r :: * -> *).
TypeSym r =>
VS (r TypeData) -> VS (r TypeData)
listType VS (r TypeData)
t)
listOf :: (VariableSym r) => Label -> VS (r TypeData) -> SVariable r
listOf :: forall (r :: * -> *).
VariableSym r =>
String -> VS (r TypeData) -> SVariable r
listOf = String -> VS (r TypeData) -> SVariable r
forall (r :: * -> *).
VariableSym r =>
String -> VS (r TypeData) -> SVariable r
listVar
type Value = ValData
type SValue a = VS (a Value)
class (TypeSym r) => ValueSym r where
valueType :: r Value -> r TypeData
class (TypeSym r) => TypeElim r where
getCodeType :: r TypeData -> CodeType
class (ValueSym r) => Argument r where
pointerArg :: SValue r -> SValue r
class (ValueSym r) => Literal r where
litTrue :: SValue r
litFalse :: SValue r
litChar :: Char -> SValue r
litDouble :: Double -> SValue r
litFloat :: Float -> SValue r
litInt :: Integer -> SValue r
litString :: String -> SValue r
litArray :: VS (r TypeData) -> [SValue r] -> SValue r
litList :: VS (r TypeData) -> [SValue r] -> SValue r
litSet :: VS (r TypeData) -> [SValue r] -> SValue r
litZero :: (Literal r, TypeElim r) => VS (r TypeData) -> SValue r
litZero :: forall (r :: * -> *).
(Literal r, TypeElim r) =>
VS (r TypeData) -> SValue r
litZero VS (r TypeData)
t = do
t' <- VS (r TypeData)
t
case getCodeType t' of
CodeType
Integer -> Integer -> StateT ValueState Identity (r Value)
forall (r :: * -> *). Literal r => Integer -> SValue r
litInt Integer
0
CodeType
Float -> Float -> StateT ValueState Identity (r Value)
forall (r :: * -> *). Literal r => Float -> SValue r
litFloat Float
0
CodeType
Double -> Double -> StateT ValueState Identity (r Value)
forall (r :: * -> *). Literal r => Double -> SValue r
litDouble Double
0
CodeType
_ -> String -> StateT ValueState Identity (r Value)
forall a. HasCallStack => String -> a
error String
"litZero expects a numeric type"
class (ValueSym r) => MathConstant r where
pi :: SValue r
class (VariableSym r, ValueSym r) => VariableValue r where
valueOf :: SVariable r -> SValue r
class (ValueSym r) => CommandLineArgs r where
arg :: Integer -> SValue r
argsList :: SValue r
argExists :: Integer -> SValue r
class (ValueSym r) => NumericExpression r where
(#~) :: SValue r -> SValue r
infixl 8 #~
(#/^) :: SValue r -> SValue r
infixl 7 #/^
(#|) :: SValue r -> SValue r
infixl 7 #|
(#+) :: SValue r -> SValue r -> SValue r
infixl 5 #+
(#-) :: SValue r -> SValue r -> SValue r
infixl 5 #-
(#*) :: SValue r -> SValue r -> SValue r
infixl 6 #*
(#/) :: SValue r -> SValue r -> SValue r
infixl 6 #/
(#%) :: SValue r -> SValue r -> SValue r
infixl 6 #%
(#^) :: SValue r -> SValue r -> SValue r
infixl 7 #^
log :: SValue r -> SValue r
ln :: SValue r -> SValue r
exp :: SValue r -> SValue r
sin :: SValue r -> SValue r
cos :: SValue r -> SValue r
tan :: SValue r -> SValue r
csc :: SValue r -> SValue r
sec :: SValue r -> SValue r
cot :: SValue r -> SValue r
arcsin :: SValue r -> SValue r
arccos :: SValue r -> SValue r
arctan :: SValue r -> SValue r
floor :: SValue r -> SValue r
ceil :: SValue r -> SValue r
class (ValueSym r) => BooleanExpression r where
(?!) :: SValue r -> SValue r
infixr 6 ?!
(?&&) :: SValue r -> SValue r -> SValue r
infixl 2 ?&&
(?||) :: SValue r -> SValue r -> SValue r
infixl 1 ?||
class (ValueSym r) => Comparison r where
(?<) :: SValue r -> SValue r -> SValue r
infixl 4 ?<
(?<=) :: SValue r -> SValue r -> SValue r
infixl 4 ?<=
(?>) :: SValue r -> SValue r -> SValue r
infixl 4 ?>
(?>=) :: SValue r -> SValue r -> SValue r
infixl 4 ?>=
(?==) :: SValue r -> SValue r -> SValue r
infixl 3 ?==
(?!=) :: SValue r -> SValue r -> SValue r
infixl 3 ?!=
type NamedArgs r = [(SVariable r, SValue r)]
type MixedCall r = Label -> VS (r TypeData) -> [SValue r] -> NamedArgs r -> SValue r
type MixedCtorCall r = VS (r TypeData) -> [SValue r] -> NamedArgs r -> SValue r
type PosCall r = Label -> VS (r TypeData) -> [SValue r] -> SValue r
type PosCtorCall r = VS (r TypeData) -> [SValue r] -> SValue r
type VSBinder a = VS (a BinderD)
class (TypeSym r) => BinderSym r where
binder :: Label -> VS (r TypeData) -> VSBinder r
class (BinderSym r) => BinderElim r where
binderName :: r BinderD -> String
binderType :: r BinderD -> r TypeData
class (VariableSym r, ValueSym r) => ValueExpression r where
inlineIf :: SValue r -> SValue r -> SValue r -> SValue r
funcAppMixedArgs :: MixedCall r
extFuncAppMixedArgs :: Library -> MixedCall r
libFuncAppMixedArgs :: Library -> MixedCall r
lambda :: [VSBinder r] -> SValue r -> SValue r
notNull :: SValue r -> SValue r
funcApp :: (ValueExpression r) => PosCall r
funcApp :: forall (r :: * -> *). ValueExpression r => PosCall r
funcApp String
n VS (r TypeData)
t [SValue r]
vs = MixedCall r
forall (r :: * -> *). ValueExpression r => MixedCall r
funcAppMixedArgs String
n VS (r TypeData)
t [SValue r]
vs []
funcAppNamedArgs :: (ValueExpression r) => Label -> VS (r TypeData) ->
NamedArgs r -> SValue r
funcAppNamedArgs :: forall (r :: * -> *).
ValueExpression r =>
String -> VS (r TypeData) -> NamedArgs r -> SValue r
funcAppNamedArgs String
n VS (r TypeData)
t = MixedCall r
forall (r :: * -> *). ValueExpression r => MixedCall r
funcAppMixedArgs String
n VS (r TypeData)
t []
extFuncApp :: (ValueExpression r) => Library -> PosCall r
extFuncApp :: forall (r :: * -> *). ValueExpression r => String -> PosCall r
extFuncApp String
l String
n VS (r TypeData)
t [SValue r]
vs = String -> MixedCall r
forall (r :: * -> *). ValueExpression r => String -> MixedCall r
extFuncAppMixedArgs String
l String
n VS (r TypeData)
t [SValue r]
vs []
libFuncApp :: (ValueExpression r) => Library -> PosCall r
libFuncApp :: forall (r :: * -> *). ValueExpression r => String -> PosCall r
libFuncApp String
l String
n VS (r TypeData)
t [SValue r]
vs = String -> MixedCall r
forall (r :: * -> *). ValueExpression r => String -> MixedCall r
libFuncAppMixedArgs String
l String
n VS (r TypeData)
t [SValue r]
vs []
exists :: (ValueExpression r) => SValue r -> SValue r
exists :: forall (r :: * -> *). ValueExpression r => SValue r -> SValue r
exists = SValue r -> SValue r
forall (r :: * -> *). ValueExpression r => SValue r -> SValue r
notNull
class (ValueSym r) => r where
intToIndex :: SValue r -> SValue r
indexToInt :: SValue r -> SValue r
class (TypeSym r, ValueSym r) => Reference r where
makeRef :: SValue r -> SValue r
maybeDeref :: SValue r -> SValue r
class (IndexTranslator r) => Array r where
arrayElem :: SValue r -> SValue r -> SVariable r
arrayLength :: SValue r -> SValue r
arrayCopy :: SValue r -> SValue r
class (IndexTranslator r) => List r where
listSize :: SValue r -> SValue r
listAccess :: SValue r -> SValue r -> SValue r
indexOf :: SValue r -> SValue r -> SValue r
class ListStatement r stmt | r -> stmt where
listAdd :: SValue r -> SValue r -> SValue r -> MS (r stmt)
listAppend :: SValue r -> SValue r -> MS (r stmt)
listSet :: SValue r -> SValue r -> SValue r -> MS (r stmt)
class (ValueSym r) => Set r where
contains :: SValue r -> SValue r -> SValue r
setAdd :: SValue r -> SValue r -> SValue r
setRemove :: SValue r -> SValue r -> SValue r
setUnion :: SValue r -> SValue r -> SValue r
class (IndexTranslator r, Literal r) => NativeVector r where
vecType :: VS (r TypeData) -> VS (r TypeData)
vecType = VS (r TypeData) -> VS (r TypeData)
forall (r :: * -> *).
TypeSym r =>
VS (r TypeData) -> VS (r TypeData)
listType
litVec :: VS (r TypeData) -> [SValue r] -> SValue r
litVec = VS (r TypeData) -> [SValue r] -> SValue r
forall (r :: * -> *).
Literal r =>
VS (r TypeData) -> [SValue r] -> SValue r
litList
vecScale :: SValue r -> SValue r -> SValue r
vecAdd :: SValue r -> SValue r -> SValue r
vecIndex :: SValue r -> SValue r -> SValue r
vecDot :: SValue r -> SValue r -> SValue r
vecMag :: SValue r -> SValue r
vecUnit :: SValue r -> SValue r
class (ValueSym r) => InternalList r block | r -> block where
listSlice' :: Maybe (SValue r) -> Maybe (SValue r) -> Maybe (SValue r)
-> SVariable r -> SValue r -> MS (r block)
listSlice :: (InternalList r block) => SVariable r -> SValue r ->
Maybe (SValue r) -> Maybe (SValue r) -> Maybe (SValue r) -> MS (r block)
listSlice :: forall (r :: * -> *) block.
InternalList r block =>
SVariable r
-> SValue r
-> Maybe (SValue r)
-> Maybe (SValue r)
-> Maybe (SValue r)
-> MS (r block)
listSlice SVariable r
vnew SValue r
vold Maybe (SValue r)
b Maybe (SValue r)
e Maybe (SValue r)
tp = Maybe (SValue r)
-> Maybe (SValue r)
-> Maybe (SValue r)
-> SVariable r
-> SValue r
-> MS (r block)
forall (r :: * -> *) block.
InternalList r block =>
Maybe (SValue r)
-> Maybe (SValue r)
-> Maybe (SValue r)
-> SVariable r
-> SValue r
-> MS (r block)
listSlice' Maybe (SValue r)
b Maybe (SValue r)
e Maybe (SValue r)
tp SVariable r
vnew SValue r
vold
listIndexExists :: (List r, Comparison r) => SValue r -> SValue r -> SValue r
listIndexExists :: forall (r :: * -> *).
(List r, Comparison r) =>
SValue r -> SValue r -> SValue r
listIndexExists SValue r
lst SValue r
index = SValue r -> SValue r
forall (r :: * -> *). List r => SValue r -> SValue r
listSize SValue r
lst SValue r -> SValue r -> SValue r
forall (r :: * -> *).
Comparison r =>
SValue r -> SValue r -> SValue r
?> SValue r
index
at :: (List r) => SValue r -> SValue r -> SValue r
at :: forall (r :: * -> *). List r => SValue r -> SValue r -> SValue r
at = SValue r -> SValue r -> SValue r
forall (r :: * -> *). List r => SValue r -> SValue r -> SValue r
listAccess
class EmptyStatement r stmt | r -> stmt where
emptyStmt :: MS (r stmt)
class MultiStatement r stmt | r -> stmt where
multi :: [MS (r stmt)] -> MS (r stmt)
class ValueStatement r stmt | r -> stmt where
valStmt :: SValue r -> MS (r stmt)
class (VariableSym r) => AssignStatement r stmt | r -> stmt where
(&-=) :: SVariable r -> SValue r -> MS (r stmt)
infixl 1 &-=
(&+=) :: SVariable r -> SValue r -> MS (r stmt)
infixl 1 &+=
(&++) :: SVariable r -> MS (r stmt)
infixl 8 &++
(&--) :: SVariable r -> MS (r stmt)
infixl 8 &--
assign :: SVariable r -> SValue r -> MS (r stmt)
(&=) :: (AssignStatement r stmt) => SVariable r -> SValue r -> MS (r stmt)
infixr 1 &=
&= :: forall (r :: * -> *) stmt.
AssignStatement r stmt =>
SVariable r -> SValue r -> MS (r stmt)
(&=) = SVariable r -> SValue r -> MS (r stmt)
forall (r :: * -> *) stmt.
AssignStatement r stmt =>
SVariable r -> SValue r -> MS (r stmt)
assign
class (VariableSym r, ScopeSym r) => DeclStatement r stmt bod | r -> stmt bod where
varDec :: SVariable r -> r ScopeData -> MS (r stmt)
varDecDef :: SVariable r -> r ScopeData -> SValue r -> MS (r stmt)
listDec :: Integer -> SVariable r -> r ScopeData -> MS (r stmt)
listDecDef :: SVariable r -> r ScopeData -> [SValue r] -> MS (r stmt)
setDec :: SVariable r -> r ScopeData -> MS (r stmt)
setDecDef :: SVariable r -> r ScopeData -> SValue r -> MS (r stmt)
arrayDec :: Integer -> SValue r -> SVariable r -> r ScopeData -> MS (r stmt)
arrayDecDef :: SVariable r -> r ScopeData -> [SValue r] -> MS (r stmt)
constDecDef :: SVariable r -> r ScopeData -> SValue r -> MS (r stmt)
funcDecDef :: SVariable r -> r ScopeData -> [SVariable r] -> MS (r bod)
-> MS (r stmt)
class (VariableSym r) => PrintConsole r stmt | r -> stmt where
print :: SValue r -> MS (r stmt)
printLn :: SValue r -> MS (r stmt)
printStr :: String -> MS (r stmt)
printStrLn :: String -> MS (r stmt)
class (VariableSym r) => ReadConsole r stmt | r -> stmt where
getInput :: SVariable r -> MS (r stmt)
discardInput :: MS (r stmt)
class (VariableSym r) => FileHandling r stmt | r -> stmt where
openFileR :: SVariable r -> SValue r -> MS (r stmt)
openFileW :: SVariable r -> SValue r -> MS (r stmt)
openFileA :: SVariable r -> SValue r -> MS (r stmt)
closeFile :: SValue r -> MS (r stmt)
class (VariableSym r) => PrintFile r stmt | r -> stmt where
printFile :: SValue r -> SValue r -> MS (r stmt)
printFileLn :: SValue r -> SValue r -> MS (r stmt)
printFileStr :: SValue r -> String -> MS (r stmt)
printFileStrLn :: SValue r -> String -> MS (r stmt)
class (VariableSym r) => ReadFile r stmt | r -> stmt where
getFileInput :: SValue r -> SVariable r -> MS (r stmt)
discardFileInput :: SValue r -> MS (r stmt)
getFileInputLine :: SValue r -> SVariable r -> MS (r stmt)
discardFileLine :: SValue r -> MS (r stmt)
getFileInputAll :: SValue r -> SVariable r -> MS (r stmt)
class (VariableSym r) => StringStatement r stmt | r -> stmt where
stringSplit :: Char -> SVariable r -> SValue r -> MS (r stmt)
stringListVals :: [SVariable r] -> SValue r -> MS (r stmt)
stringListLists :: [SVariable r] -> SValue r -> MS (r stmt)
class (ValueSym r) => FunctionSym r where
type InOutCall r stmt = Label -> [SValue r] -> [SVariable r] -> [SVariable r] ->
MS (r stmt)
class (VariableSym r) => FuncAppStatement r stmt | r -> stmt where
inOutCall :: InOutCall r stmt
extInOutCall :: Library -> InOutCall r stmt
class r stmt | r -> stmt where
:: String -> MS (r stmt)
class (VariableSym r) => ControlStatement r stmt bod | r -> stmt bod where
break :: MS (r stmt)
continue :: MS (r stmt)
returnStmt :: SValue r -> MS (r stmt)
throw :: Label -> MS (r stmt)
ifCond :: [(SValue r, MS (r bod))] -> MS (r bod) -> MS (r stmt)
switch :: SValue r -> [(SValue r, MS (r bod))] -> MS (r bod) -> MS (r stmt)
ifExists :: SValue r -> MS (r bod) -> MS (r bod) -> MS (r stmt)
for :: MS (r stmt) -> SValue r -> MS (r stmt) -> MS (r bod) ->
MS (r stmt)
forRange :: SVariable r -> SValue r -> SValue r -> SValue r -> MS (r bod) ->
MS (r stmt)
forEach :: SVariable r -> SValue r -> MS (r bod) -> MS (r stmt)
while :: SValue r -> MS (r bod) -> MS (r stmt)
tryCatch :: MS (r bod) -> MS (r bod) -> MS (r stmt)
assert :: SValue r -> SValue r -> MS (r stmt)
ifNoElse
:: (BodySym r bod block, ControlStatement r stmt bod)
=> [(SValue r, MS (r bod))] -> MS (r stmt)
ifNoElse :: forall (r :: * -> *) bod block stmt.
(BodySym r bod block, ControlStatement r stmt bod) =>
[(SValue r, MS (r bod))] -> MS (r stmt)
ifNoElse [(SValue r, MS (r bod))]
bs = [(SValue r, MS (r bod))] -> MS (r bod) -> MS (r stmt)
forall (r :: * -> *) stmt bod.
ControlStatement r stmt bod =>
[(SValue r, MS (r bod))] -> MS (r bod) -> MS (r stmt)
ifCond [(SValue r, MS (r bod))]
bs (MS (r bod) -> MS (r stmt)) -> MS (r bod) -> MS (r stmt)
forall a b. (a -> b) -> a -> b
$ [MS (r block)] -> MS (r bod)
forall {k} (r :: k -> *) (bod :: k) (block :: k).
BodySym r bod block =>
[MS (r block)] -> MS (r bod)
body []
switchAsIf
:: (ControlStatement r stmt bod, Comparison r)
=> SValue r -> [(SValue r, MS (r bod))] -> MS (r bod) -> MS (r stmt)
switchAsIf :: forall (r :: * -> *) stmt bod.
(ControlStatement r stmt bod, Comparison r) =>
SValue r -> [(SValue r, MS (r bod))] -> MS (r bod) -> MS (r stmt)
switchAsIf SValue r
v = [(SValue r, MS (r bod))] -> MS (r bod) -> MS (r stmt)
forall (r :: * -> *) stmt bod.
ControlStatement r stmt bod =>
[(SValue r, MS (r bod))] -> MS (r bod) -> MS (r stmt)
ifCond ([(SValue r, MS (r bod))] -> MS (r bod) -> MS (r stmt))
-> ([(SValue r, MS (r bod))] -> [(SValue r, MS (r bod))])
-> [(SValue r, MS (r bod))]
-> MS (r bod)
-> MS (r stmt)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((SValue r, MS (r bod)) -> (SValue r, MS (r bod)))
-> [(SValue r, MS (r bod))] -> [(SValue r, MS (r bod))]
forall a b. (a -> b) -> [a] -> [b]
map ((SValue r -> SValue r)
-> (SValue r, MS (r bod)) -> (SValue r, MS (r bod))
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first (SValue r
v SValue r -> SValue r -> SValue r
forall (r :: * -> *).
Comparison r =>
SValue r -> SValue r -> SValue r
?==))
class VisibilitySym r vis | r -> vis where
private :: r vis
public :: r vis
class (VariableSym r) => ParameterSym r where
param :: SVariable r -> MS (r ParamData)
pointerParam :: SVariable r -> MS (r ParamData)
type InOutFunc r mthd bod = [SVariable r] -> [SVariable r] -> [SVariable r] ->
MS (r bod) -> MS (r mthd)
type DocInOutFunc r mthd bod = String -> [(String, SVariable r)] ->
[(String, SVariable r)] -> [(String, SVariable r)] -> MS (r bod) -> MS (r mthd)
class (ParameterSym r, VisibilitySym r vis) => MethodSym r vis mthd bod | r -> mthd bod
where
docMain :: MS (r bod) -> MS (r mthd)
function :: Label -> r vis -> VS (r TypeData) -> [MS (r ParamData)] ->
MS (r bod) -> MS (r mthd)
mainFunction :: MS (r bod) -> MS (r mthd)
docFunc :: String -> [String] -> Maybe String -> MS (r mthd) -> MS (r mthd)
inOutFunc :: Label -> r vis -> InOutFunc r mthd bod
docInOutFunc :: Label -> r vis -> DocInOutFunc r mthd bod
convType :: (TypeSym r) => CodeType -> VS (r TypeData)
convType :: forall (r :: * -> *). TypeSym r => CodeType -> VS (r TypeData)
convType CodeType
Boolean = VS (r TypeData)
forall (r :: * -> *). TypeSym r => VS (r TypeData)
bool
convType CodeType
Integer = VS (r TypeData)
forall (r :: * -> *). TypeSym r => VS (r TypeData)
int
convType CodeType
Float = VS (r TypeData)
forall (r :: * -> *). TypeSym r => VS (r TypeData)
float
convType CodeType
Double = VS (r TypeData)
forall (r :: * -> *). TypeSym r => VS (r TypeData)
double
convType CodeType
Char = VS (r TypeData)
forall (r :: * -> *). TypeSym r => VS (r TypeData)
char
convType CodeType
String = VS (r TypeData)
forall (r :: * -> *). TypeSym r => VS (r TypeData)
string
convType (Reference CodeType
t) = VS (r TypeData) -> VS (r TypeData)
forall (r :: * -> *).
TypeSym r =>
VS (r TypeData) -> VS (r TypeData)
referenceType (CodeType -> VS (r TypeData)
forall (r :: * -> *). TypeSym r => CodeType -> VS (r TypeData)
convType CodeType
t)
convType (List CodeType
t) = VS (r TypeData) -> VS (r TypeData)
forall (r :: * -> *).
TypeSym r =>
VS (r TypeData) -> VS (r TypeData)
listType (CodeType -> VS (r TypeData)
forall (r :: * -> *). TypeSym r => CodeType -> VS (r TypeData)
convType CodeType
t)
convType (Set CodeType
t) = VS (r TypeData) -> VS (r TypeData)
forall (r :: * -> *).
TypeSym r =>
VS (r TypeData) -> VS (r TypeData)
setType (CodeType -> VS (r TypeData)
forall (r :: * -> *). TypeSym r => CodeType -> VS (r TypeData)
convType CodeType
t)
convType (Array CodeType
t) = VS (r TypeData) -> VS (r TypeData)
forall (r :: * -> *).
TypeSym r =>
VS (r TypeData) -> VS (r TypeData)
arrayType (CodeType -> VS (r TypeData)
forall (r :: * -> *). TypeSym r => CodeType -> VS (r TypeData)
convType CodeType
t)
convType (Func [CodeType]
ps CodeType
r) = [VS (r TypeData)] -> VS (r TypeData) -> VS (r TypeData)
forall (r :: * -> *).
TypeSym r =>
[VS (r TypeData)] -> VS (r TypeData) -> VS (r TypeData)
funcType ((CodeType -> VS (r TypeData)) -> [CodeType] -> [VS (r TypeData)]
forall a b. (a -> b) -> [a] -> [b]
map CodeType -> VS (r TypeData)
forall (r :: * -> *). TypeSym r => CodeType -> VS (r TypeData)
convType [CodeType]
ps) (CodeType -> VS (r TypeData)
forall (r :: * -> *). TypeSym r => CodeType -> VS (r TypeData)
convType CodeType
r)
convType CodeType
Void = VS (r TypeData)
forall (r :: * -> *). TypeSym r => VS (r TypeData)
void
convType CodeType
InFile = VS (r TypeData)
forall (r :: * -> *). TypeSym r => VS (r TypeData)
infile
convType CodeType
OutFile = VS (r TypeData)
forall (r :: * -> *). TypeSym r => VS (r TypeData)
outfile
convType (Object String
_) = String -> VS (r TypeData)
forall a. HasCallStack => String -> a
error String
"Objects not supported"
convScope :: (ScopeSym r) => ScopeData -> r ScopeData
convScope :: forall (r :: * -> *). ScopeSym r => ScopeData -> r ScopeData
convScope (SD {scopeTag :: ScopeData -> ScopeTag
scopeTag = ScopeTag
Global}) = r ScopeData
forall (r :: * -> *). ScopeSym r => r ScopeData
global
convScope (SD {scopeTag :: ScopeData -> ScopeTag
scopeTag = ScopeTag
Local}) = r ScopeData
forall (r :: * -> *). ScopeSym r => r ScopeData
local