{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE PostfixOperators #-}
module GOOL.Drasil.LanguageRenderer.JavaRenderer (
JavaCode(..), jName, jVersion
) where
import Utils.Drasil (indent)
import GOOL.Drasil.CodeType (CodeType(..))
import GOOL.Drasil.ClassInterface (Label, MSBody, VSType, SVariable, SValue,
VSFunction, MSStatement, MSParameter, SMethod, CSStateVar, SClass, OOProg,
ProgramSym(..), FileSym(..), PermanenceSym(..), BodySym(..), oneLiner,
BlockSym(..), TypeSym(..), TypeElim(..), VariableSym(..), VariableElim(..),
ValueSym(..), Argument(..), Literal(..), litZero, MathConstant(..),
VariableValue(..), CommandLineArgs(..), NumericExpression(..),
BooleanExpression(..), Comparison(..), ValueExpression(..), funcApp,
selfFuncApp, extFuncApp, newObj, InternalValueExp(..), FunctionSym(..), ($.),
GetSet(..), List(..), InternalList(..), ThunkSym(..), VectorType(..),
VectorDecl(..), VectorThunk(..), VectorExpression(..), ThunkAssign(..),
StatementSym(..), AssignStatement(..), (&=), DeclStatement(..),
IOStatement(..), StringStatement(..), FuncAppStatement(..),
CommentStatement(..), ControlStatement(..), StatePattern(..),
ObserverPattern(..), StrategyPattern(..), ScopeSym(..), ParameterSym(..),
MethodSym(..), StateVarSym(..), ClassSym(..), ModuleSym(..))
import GOOL.Drasil.RendererClasses (RenderSym, RenderFile(..), ImportSym(..),
ImportElim, PermElim(binding), RenderBody(..), BodyElim, RenderBlock(..),
BlockElim, RenderType(..), InternalTypeElim, UnaryOpSym(..), BinaryOpSym(..),
OpElim(uOpPrec, bOpPrec), RenderVariable(..), InternalVarElim(variableBind),
RenderValue(..), ValueElim(valuePrec), InternalGetSet(..),
InternalListFunc(..), RenderFunction(..), FunctionElim(functionType),
InternalAssignStmt(..), InternalIOStmt(..), InternalControlStmt(..),
RenderStatement(..), StatementElim(statementTerm), RenderScope(..),
ScopeElim, MethodTypeSym(..), RenderParam(..),
ParamElim(parameterName, parameterType), RenderMethod(..), MethodElim,
StateVarElim, RenderClass(..), ClassElim, RenderMod(..), ModuleElim,
BlockCommentSym(..), BlockCommentElim)
import qualified GOOL.Drasil.RendererClasses as RC (import', perm, body, block,
type', uOp, bOp, variable, value, function, statement, scope, parameter,
method, stateVar, class', module', blockComment')
import GOOL.Drasil.LanguageRenderer (dot, new, elseIfLabel, forLabel, tryLabel,
catchLabel, throwLabel, throwsLabel, importLabel, blockCmtStart, blockCmtEnd,
docCmtStart, bodyStart, bodyEnd, endStatement, commentStart, exceptionObj',
new', args, printLabel, exceptionObj, mainFunc, new, nullLabel, listSep,
access, containing, mathFunc, functionDox, variableList, parameterList,
appendToBody, surroundBody, intValue)
import qualified GOOL.Drasil.LanguageRenderer as R (sqrt, abs, log10,
log, exp, sin, cos, tan, asin, acos, atan, floor, ceil, pow, package, class',
multiStmt, body, printFile, param, listDec, classVar, cast, castObj, static,
dynamic, break, continue, private, public, blockCmt, docCmt, addComments,
commentedMod, commentedItem)
import GOOL.Drasil.LanguageRenderer.Constructors (mkStmt, mkStateVal, mkVal,
VSOp, unOpPrec, powerPrec, unExpr, unExpr', unExprNumDbl, typeUnExpr, binExpr,
binExprNumDbl', typeBinExpr)
import qualified GOOL.Drasil.LanguageRenderer.LanguagePolymorphic as G (
multiBody, block, multiBlock, listInnerType, obj, csc, sec, cot, negateOp,
equalOp, notEqualOp, greaterOp, greaterEqualOp, lessOp, lessEqualOp, plusOp,
minusOp, multOp, divideOp, moduloOp, var, staticVar, objVar, arrayElem,
litChar, litDouble, litInt, litString, valueOf, arg, argsList, objAccess,
objMethodCall, funcAppMixedArgs, selfFuncAppMixedArgs, newObjMixedArgs,
lambda, func, get, set, listAdd, listAppend, listAccess, listSet, getFunc,
setFunc, listAppendFunc, stmt, loopStmt, emptyStmt, assign, subAssign,
increment, objDecNew, print, closeFile, returnStmt, valStmt, comment, throw,
ifCond, tryCatch, construct, param, method, getMethod, setMethod, function,
buildClass, implementingClass, commentedClass, modFromData, fileDoc,
fileFromData, defaultOptSpace)
import GOOL.Drasil.LanguageRenderer.LanguagePolymorphic (docFuncRepr)
import qualified GOOL.Drasil.LanguageRenderer.CommonPseudoOO as CP (int,
constructor, doxFunc, doxClass, doxMod, extVar, classVar, objVarSelf,
extFuncAppMixedArgs, indexOf, listAddFunc, discardFileLine, intClass,
funcType, arrayType, pi, printSt, arrayDec, arrayDecDef, openFileA, forEach,
docMain, mainFunction, buildModule', bindingError, listDecDef,
destructorError, stateVarDef, constVar, litArray, call', listSizeFunc,
listAccessFunc', notNull, doubleRender, double, openFileR, openFileW,
stateVar, floatRender, float, string')
import qualified GOOL.Drasil.LanguageRenderer.CLike as C (float, double, char,
listType, void, notOp, andOp, orOp, self, litTrue, litFalse, litFloat,
inlineIf, libFuncAppMixedArgs, libNewObjMixedArgs, listSize, increment1,
decrement1, varDec, varDecDef, listDec, extObjDecNew, switch, for, while,
intFunc, multiAssignError, multiReturnError, multiTypeError)
import qualified GOOL.Drasil.LanguageRenderer.Macros as M (ifExists,
runStrategy, listSlice, stringListVals, stringListLists, forRange,
notifyObservers, checkState)
import GOOL.Drasil.AST (Terminator(..), ScopeTag(..), qualName, FileType(..),
FileData(..), fileD, FuncData(..), fd, ModData(..), md, updateMod,
MethodData(..), mthd, updateMthd, OpData(..), ParamData(..), pd,
ProgData(..), progD, TypeData(..), td, ValData(..), vd, VarData(..), vard,
CommonThunk, pureValue, vectorize, vectorize2, sumComponents, commonVecIndex,
commonThunkElim, commonThunkDim)
import GOOL.Drasil.CodeAnalysis (Exception(..), ExceptionType(..), exception,
stdExc, HasException(..))
import GOOL.Drasil.Helpers (emptyIfNull, toCode, toState, onCodeValue,
onStateValue, on2CodeValues, on2StateValues, on3CodeValues, on3StateValues,
onCodeList, onStateList, on2StateWrapped)
import GOOL.Drasil.State (VS, lensGStoFS, lensMStoFS, lensMStoVS, lensVStoFS,
lensVStoMS, modifyReturn, modifyReturnList, revFiles, addProgNameToPaths,
addLangImport, addLangImportVS, addExceptionImports, getModuleName,
setFileType, getClassName, setCurrMain, setOutputsDeclared,
isOutputsDeclared, getExceptions, getMethodExcMap, addExceptions, useVarName,
genLoopIndex)
import Prelude hiding (break,print,sin,cos,tan,floor,(<>))
import Control.Applicative (liftA2)
import Control.Lens.Zoom (zoom)
import Control.Monad (join)
import Control.Monad.State (modify)
import Data.Composition ((.:))
import qualified Data.Map as Map (lookup)
import Data.List (nub, intercalate, sort)
import Text.PrettyPrint.HughesPJ (Doc, text, (<>), (<+>), ($$), parens, empty,
equals, vcat, lbrace, rbrace, braces, colon, quotes)
jExt :: String
jExt :: String
jExt = String
"java"
newtype JavaCode a = JC {forall a. JavaCode a -> a
unJC :: a}
instance Functor JavaCode where
fmap :: forall a b. (a -> b) -> JavaCode a -> JavaCode b
fmap a -> b
f (JC a
x) = forall a. a -> JavaCode a
JC (a -> b
f a
x)
instance Applicative JavaCode where
pure :: forall a. a -> JavaCode a
pure = forall a. a -> JavaCode a
JC
(JC a -> b
f) <*> :: forall a b. JavaCode (a -> b) -> JavaCode a -> JavaCode b
<*> (JC a
x) = forall a. a -> JavaCode a
JC (a -> b
f a
x)
instance Monad JavaCode where
JC a
x >>= :: forall a b. JavaCode a -> (a -> JavaCode b) -> JavaCode b
>>= a -> JavaCode b
f = a -> JavaCode b
f a
x
instance OOProg JavaCode where
instance ProgramSym JavaCode where
type Program JavaCode = ProgData
prog :: String -> String -> [SFile JavaCode] -> GSProgram JavaCode
prog String
n String
st [SFile JavaCode]
fs = forall s b a. [State s b] -> (s -> s) -> ([b] -> a) -> State s a
modifyReturnList (forall a b. (a -> b) -> [a] -> [b]
map (forall (m :: * -> *) (n :: * -> *) s t c.
Zoom m n s t =>
LensLike' (Zoomed m c) t s -> m c -> n c
zoom Lens' GOOLState FileState
lensGStoFS) [SFile JavaCode]
fs) (GOOLState -> GOOLState
revFiles forall b c a. (b -> c) -> (a -> b) -> a -> c
.
String -> GOOLState -> GOOLState
addProgNameToPaths String
n) (forall (m :: * -> *) a b. Monad m => ([a] -> b) -> [m a] -> m b
onCodeList (String -> String -> [FileData] -> ProgData
progD String
n String
st forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
map (String -> Doc -> FileData -> FileData
R.package String
n
Doc
endStatement)))
instance RenderSym JavaCode
instance FileSym JavaCode where
type File JavaCode = FileData
fileDoc :: FSModule JavaCode -> SFile JavaCode
fileDoc FSModule JavaCode
m = do
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (FileType -> FileState -> FileState
setFileType FileType
Combined)
forall (r :: * -> *).
RenderSym r =>
String
-> (r (Module r) -> r (Block r))
-> r (Block r)
-> FSModule r
-> SFile r
G.fileDoc String
jExt forall (r :: * -> *). RenderFile r => r (Module r) -> r (Block r)
top forall (r :: * -> *). RenderFile r => r (Block r)
bottom FSModule JavaCode
m
docMod :: String -> [String] -> String -> SFile JavaCode -> SFile JavaCode
docMod = forall (r :: * -> *).
RenderSym r =>
String -> String -> [String] -> String -> SFile r -> SFile r
CP.doxMod String
jExt
instance RenderFile JavaCode where
top :: JavaCode (Module JavaCode) -> JavaCode (Block JavaCode)
top JavaCode (Module JavaCode)
_ = forall (r :: * -> *) a. Monad r => a -> r a
toCode Doc
empty
bottom :: JavaCode (Block JavaCode)
bottom = forall (r :: * -> *) a. Monad r => a -> r a
toCode Doc
empty
commentedMod :: SFile JavaCode
-> FS (JavaCode (BlockComment JavaCode)) -> SFile JavaCode
commentedMod = forall a b c s.
(a -> b -> c) -> State s a -> State s b -> State s c
on2StateValues (forall (r :: * -> *) a b c.
Applicative r =>
(a -> b -> c) -> r a -> r b -> r c
on2CodeValues FileData -> Doc -> FileData
R.commentedMod)
fileFromData :: String -> FSModule JavaCode -> SFile JavaCode
fileFromData = forall (r :: * -> *).
RenderSym r =>
(String -> r (Module r) -> r (File r))
-> String -> FSModule r -> SFile r
G.fileFromData (forall (r :: * -> *) a b. Functor r => (a -> b) -> r a -> r b
onCodeValue forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ModData -> FileData
fileD)
instance ImportSym JavaCode where
type Import JavaCode = Doc
langImport :: String -> JavaCode (Import JavaCode)
langImport = forall (r :: * -> *) a. Monad r => a -> r a
toCode forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Doc
jImport
modImport :: String -> JavaCode (Import JavaCode)
modImport = forall (r :: * -> *). ImportSym r => String -> r (Import r)
langImport
instance ImportElim JavaCode where
import' :: JavaCode (Import JavaCode) -> Doc
import' = forall a. JavaCode a -> a
unJC
instance PermanenceSym JavaCode where
type Permanence JavaCode = Doc
static :: JavaCode (Permanence JavaCode)
static = forall (r :: * -> *) a. Monad r => a -> r a
toCode Doc
R.static
dynamic :: JavaCode (Permanence JavaCode)
dynamic = forall (r :: * -> *) a. Monad r => a -> r a
toCode Doc
R.dynamic
instance PermElim JavaCode where
perm :: JavaCode (Permanence JavaCode) -> Doc
perm = forall a. JavaCode a -> a
unJC
binding :: JavaCode (Permanence JavaCode) -> Binding
binding = forall a. HasCallStack => String -> a
error forall a b. (a -> b) -> a -> b
$ String -> String
CP.bindingError String
jName
instance BodySym JavaCode where
type Body JavaCode = Doc
body :: [MSBlock JavaCode] -> MSBody JavaCode
body = forall a b s. ([a] -> b) -> [State s a] -> State s b
onStateList (forall (m :: * -> *) a b. Monad m => ([a] -> b) -> [m a] -> m b
onCodeList [Doc] -> Doc
R.body)
addComments :: String -> MSBody JavaCode -> MSBody JavaCode
addComments String
s = forall a b s. (a -> b) -> State s a -> State s b
onStateValue (forall (r :: * -> *) a b. Functor r => (a -> b) -> r a -> r b
onCodeValue (String -> Doc -> Doc -> Doc
R.addComments String
s Doc
commentStart))
instance RenderBody JavaCode where
multiBody :: [MSBody JavaCode] -> MSBody JavaCode
multiBody = forall (r :: * -> *).
(RenderSym r, Monad r) =>
[MSBody r] -> MS (r Doc)
G.multiBody
instance BodyElim JavaCode where
body :: JavaCode (Body JavaCode) -> Doc
body = forall a. JavaCode a -> a
unJC
instance BlockSym JavaCode where
type Block JavaCode = Doc
block :: [MSStatement JavaCode] -> MSBlock JavaCode
block = forall (r :: * -> *).
(RenderSym r, Monad r) =>
[MSStatement r] -> MS (r Doc)
G.block
instance RenderBlock JavaCode where
multiBlock :: [MSBlock JavaCode] -> MSBlock JavaCode
multiBlock = forall (r :: * -> *).
(RenderSym r, Monad r) =>
[MSBlock r] -> MS (r Doc)
G.multiBlock
instance BlockElim JavaCode where
block :: JavaCode (Block JavaCode) -> Doc
block = forall a. JavaCode a -> a
unJC
instance TypeSym JavaCode where
type Type JavaCode = TypeData
bool :: VSType JavaCode
bool = forall (r :: * -> *). RenderSym r => VSType r
jBoolType
int :: VSType JavaCode
int = forall (r :: * -> *). RenderSym r => VSType r
CP.int
float :: VSType JavaCode
float = forall (r :: * -> *). RenderSym r => VSType r
C.float
double :: VSType JavaCode
double = forall (r :: * -> *). RenderSym r => VSType r
C.double
char :: VSType JavaCode
char = forall (r :: * -> *). RenderSym r => VSType r
C.char
string :: VSType JavaCode
string = forall (r :: * -> *). RenderSym r => VSType r
CP.string'
infile :: VSType JavaCode
infile = forall (r :: * -> *). RenderSym r => VSType r
jInfileType
outfile :: VSType JavaCode
outfile = forall (r :: * -> *). RenderSym r => VSType r
jOutfileType
listType :: VSType JavaCode -> VSType JavaCode
listType = forall (r :: * -> *). RenderSym r => VSType r -> VSType r
jListType
arrayType :: VSType JavaCode -> VSType JavaCode
arrayType = forall (r :: * -> *). RenderSym r => VSType r -> VSType r
CP.arrayType
listInnerType :: VSType JavaCode -> VSType JavaCode
listInnerType = forall (r :: * -> *). RenderSym r => VSType r -> VSType r
G.listInnerType
obj :: String -> VSType JavaCode
obj = forall (r :: * -> *). RenderSym r => String -> VSType r
G.obj
funcType :: [VSType JavaCode] -> VSType JavaCode -> VSType JavaCode
funcType = forall (r :: * -> *).
RenderSym r =>
[VSType r] -> VSType r -> VSType r
CP.funcType
void :: VSType JavaCode
void = forall (r :: * -> *). RenderSym r => VSType r
C.void
instance TypeElim JavaCode where
getType :: JavaCode (Type JavaCode) -> CodeType
getType = TypeData -> CodeType
cType forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. JavaCode a -> a
unJC
getTypeString :: JavaCode (Type JavaCode) -> String
getTypeString = TypeData -> String
typeString forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. JavaCode a -> a
unJC
instance RenderType JavaCode where
multiType :: [VSType JavaCode] -> VSType JavaCode
multiType [VSType JavaCode]
_ = forall a. HasCallStack => String -> a
error forall a b. (a -> b) -> a -> b
$ String -> String
C.multiTypeError String
jName
typeFromData :: CodeType -> String -> Doc -> VSType JavaCode
typeFromData CodeType
t String
s Doc
d = forall a s. a -> State s a
toState forall a b. (a -> b) -> a -> b
$ forall (r :: * -> *) a. Monad r => a -> r a
toCode forall a b. (a -> b) -> a -> b
$ CodeType -> String -> Doc -> TypeData
td CodeType
t String
s Doc
d
instance InternalTypeElim JavaCode where
type' :: JavaCode (Type JavaCode) -> Doc
type' = TypeData -> Doc
typeDoc forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. JavaCode a -> a
unJC
instance UnaryOpSym JavaCode where
type UnaryOp JavaCode = OpData
notOp :: VSUnOp JavaCode
notOp = forall (r :: * -> *). Monad r => VSOp r
C.notOp
negateOp :: VSUnOp JavaCode
negateOp = forall (r :: * -> *). Monad r => VSOp r
G.negateOp
sqrtOp :: VSUnOp JavaCode
sqrtOp = forall (r :: * -> *). Monad r => String -> VSOp r
jUnaryMath String
R.sqrt
absOp :: VSUnOp JavaCode
absOp = forall (r :: * -> *). Monad r => String -> VSOp r
jUnaryMath String
R.abs
logOp :: VSUnOp JavaCode
logOp = forall (r :: * -> *). Monad r => String -> VSOp r
jUnaryMath String
R.log10
lnOp :: VSUnOp JavaCode
lnOp = forall (r :: * -> *). Monad r => String -> VSOp r
jUnaryMath String
R.log
expOp :: VSUnOp JavaCode
expOp = forall (r :: * -> *). Monad r => String -> VSOp r
jUnaryMath String
R.exp
sinOp :: VSUnOp JavaCode
sinOp = forall (r :: * -> *). Monad r => String -> VSOp r
jUnaryMath String
R.sin
cosOp :: VSUnOp JavaCode
cosOp = forall (r :: * -> *). Monad r => String -> VSOp r
jUnaryMath String
R.cos
tanOp :: VSUnOp JavaCode
tanOp = forall (r :: * -> *). Monad r => String -> VSOp r
jUnaryMath String
R.tan
asinOp :: VSUnOp JavaCode
asinOp = forall (r :: * -> *). Monad r => String -> VSOp r
jUnaryMath String
R.asin
acosOp :: VSUnOp JavaCode
acosOp = forall (r :: * -> *). Monad r => String -> VSOp r
jUnaryMath String
R.acos
atanOp :: VSUnOp JavaCode
atanOp = forall (r :: * -> *). Monad r => String -> VSOp r
jUnaryMath String
R.atan
floorOp :: VSUnOp JavaCode
floorOp = forall (r :: * -> *). Monad r => String -> VSOp r
jUnaryMath String
R.floor
ceilOp :: VSUnOp JavaCode
ceilOp = forall (r :: * -> *). Monad r => String -> VSOp r
jUnaryMath String
R.ceil
instance BinaryOpSym JavaCode where
type BinaryOp JavaCode = OpData
equalOp :: VSBinOp JavaCode
equalOp = forall (r :: * -> *). Monad r => VSOp r
G.equalOp
notEqualOp :: VSBinOp JavaCode
notEqualOp = forall (r :: * -> *). Monad r => VSOp r
G.notEqualOp
greaterOp :: VSBinOp JavaCode
greaterOp = forall (r :: * -> *). Monad r => VSOp r
G.greaterOp
greaterEqualOp :: VSBinOp JavaCode
greaterEqualOp = forall (r :: * -> *). Monad r => VSOp r
G.greaterEqualOp
lessOp :: VSBinOp JavaCode
lessOp = forall (r :: * -> *). Monad r => VSOp r
G.lessOp
lessEqualOp :: VSBinOp JavaCode
lessEqualOp = forall (r :: * -> *). Monad r => VSOp r
G.lessEqualOp
plusOp :: VSBinOp JavaCode
plusOp = forall (r :: * -> *). Monad r => VSOp r
G.plusOp
minusOp :: VSBinOp JavaCode
minusOp = forall (r :: * -> *). Monad r => VSOp r
G.minusOp
multOp :: VSBinOp JavaCode
multOp = forall (r :: * -> *). Monad r => VSOp r
G.multOp
divideOp :: VSBinOp JavaCode
divideOp = forall (r :: * -> *). Monad r => VSOp r
G.divideOp
powerOp :: VSBinOp JavaCode
powerOp = forall (r :: * -> *). Monad r => String -> VSOp r
powerPrec forall a b. (a -> b) -> a -> b
$ String -> String
mathFunc String
R.pow
moduloOp :: VSBinOp JavaCode
moduloOp = forall (r :: * -> *). Monad r => VSOp r
G.moduloOp
andOp :: VSBinOp JavaCode
andOp = forall (r :: * -> *). Monad r => VSOp r
C.andOp
orOp :: VSBinOp JavaCode
orOp = forall (r :: * -> *). Monad r => VSOp r
C.orOp
instance OpElim JavaCode where
uOp :: JavaCode (UnaryOp JavaCode) -> Doc
uOp = OpData -> Doc
opDoc forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. JavaCode a -> a
unJC
bOp :: JavaCode (BinaryOp JavaCode) -> Doc
bOp = OpData -> Doc
opDoc forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. JavaCode a -> a
unJC
uOpPrec :: JavaCode (UnaryOp JavaCode) -> Int
uOpPrec = OpData -> Int
opPrec forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. JavaCode a -> a
unJC
bOpPrec :: JavaCode (BinaryOp JavaCode) -> Int
bOpPrec = OpData -> Int
opPrec forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. JavaCode a -> a
unJC
instance VariableSym JavaCode where
type Variable JavaCode = VarData
var :: String -> VSType JavaCode -> SVariable JavaCode
var = forall (r :: * -> *).
RenderSym r =>
String -> VSType r -> SVariable r
G.var
staticVar :: String -> VSType JavaCode -> SVariable JavaCode
staticVar = forall (r :: * -> *).
RenderSym r =>
String -> VSType r -> SVariable r
G.staticVar
constant :: String -> VSType JavaCode -> SVariable JavaCode
constant = forall (r :: * -> *).
VariableSym r =>
String -> VSType r -> SVariable r
var
extVar :: String -> String -> VSType JavaCode -> SVariable JavaCode
extVar = forall (r :: * -> *).
RenderSym r =>
String -> String -> VSType r -> SVariable r
CP.extVar
self :: SVariable JavaCode
self = forall (r :: * -> *). RenderSym r => SVariable r
C.self
classVar :: VSType JavaCode -> SVariable JavaCode -> SVariable JavaCode
classVar = forall (r :: * -> *).
RenderSym r =>
(Doc -> Doc -> Doc) -> VSType r -> SVariable r -> SVariable r
CP.classVar Doc -> Doc -> Doc
R.classVar
extClassVar :: VSType JavaCode -> SVariable JavaCode -> SVariable JavaCode
extClassVar = forall (r :: * -> *).
VariableSym r =>
VSType r -> SVariable r -> SVariable r
classVar
objVar :: SVariable JavaCode -> SVariable JavaCode -> SVariable JavaCode
objVar = forall (r :: * -> *).
RenderSym r =>
SVariable r -> SVariable r -> SVariable r
G.objVar
objVarSelf :: SVariable JavaCode -> SVariable JavaCode
objVarSelf = forall (r :: * -> *). RenderSym r => SVariable r -> SVariable r
CP.objVarSelf
arrayElem :: Integer -> SVariable JavaCode -> SVariable JavaCode
arrayElem Integer
i = forall (r :: * -> *).
RenderSym r =>
SValue r -> SVariable r -> SVariable r
G.arrayElem (forall (r :: * -> *). Literal r => Integer -> SValue r
litInt Integer
i)
instance VariableElim JavaCode where
variableName :: JavaCode (Variable JavaCode) -> String
variableName = VarData -> String
varName forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. JavaCode a -> a
unJC
variableType :: JavaCode (Variable JavaCode) -> JavaCode (Type JavaCode)
variableType = forall (r :: * -> *) a b. Functor r => (a -> b) -> r a -> r b
onCodeValue VarData -> TypeData
varType
instance InternalVarElim JavaCode where
variableBind :: JavaCode (Variable JavaCode) -> Binding
variableBind = VarData -> Binding
varBind forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. JavaCode a -> a
unJC
variable :: JavaCode (Variable JavaCode) -> Doc
variable = VarData -> Doc
varDoc forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. JavaCode a -> a
unJC
instance RenderVariable JavaCode where
varFromData :: Binding -> String -> VSType JavaCode -> Doc -> SVariable JavaCode
varFromData Binding
b String
n VSType JavaCode
t' Doc
d = do
JavaCode TypeData
t <- VSType JavaCode
t'
forall a s. a -> State s a
toState forall a b. (a -> b) -> a -> b
$ forall (r :: * -> *) a b c.
Applicative r =>
(a -> b -> c) -> r a -> r b -> r c
on2CodeValues (Binding -> String -> TypeData -> Doc -> VarData
vard Binding
b String
n) JavaCode TypeData
t (forall (r :: * -> *) a. Monad r => a -> r a
toCode Doc
d)
instance ValueSym JavaCode where
type Value JavaCode = ValData
valueType :: JavaCode (Value JavaCode) -> JavaCode (Type JavaCode)
valueType = forall (r :: * -> *) a b. Functor r => (a -> b) -> r a -> r b
onCodeValue ValData -> TypeData
valType
instance Argument JavaCode where
pointerArg :: SValue JavaCode -> SValue JavaCode
pointerArg = forall a. a -> a
id
instance Literal JavaCode where
litTrue :: SValue JavaCode
litTrue = forall (r :: * -> *). RenderSym r => SValue r
C.litTrue
litFalse :: SValue JavaCode
litFalse = forall (r :: * -> *). RenderSym r => SValue r
C.litFalse
litChar :: Char -> SValue JavaCode
litChar = forall (r :: * -> *).
RenderSym r =>
(Doc -> Doc) -> Char -> SValue r
G.litChar Doc -> Doc
quotes
litDouble :: Double -> SValue JavaCode
litDouble = forall (r :: * -> *). RenderSym r => Double -> SValue r
G.litDouble
litFloat :: Float -> SValue JavaCode
litFloat = forall (r :: * -> *). RenderSym r => Float -> SValue r
C.litFloat
litInt :: Integer -> SValue JavaCode
litInt = forall (r :: * -> *). RenderSym r => Integer -> SValue r
G.litInt
litString :: String -> SValue JavaCode
litString = forall (r :: * -> *). RenderSym r => String -> SValue r
G.litString
litArray :: VSType JavaCode -> [SValue JavaCode] -> SValue JavaCode
litArray = forall (r :: * -> *).
RenderSym r =>
(Doc -> Doc) -> VSType r -> [SValue r] -> SValue r
CP.litArray Doc -> Doc
braces
litList :: VSType JavaCode -> [SValue JavaCode] -> SValue JavaCode
litList VSType JavaCode
t [SValue JavaCode]
es = do
forall (m :: * -> *) (n :: * -> *) s t c.
Zoom m n s t =>
LensLike' (Zoomed m c) t s -> m c -> n c
zoom Lens' ValueState MethodState
lensVStoMS forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (if forall (t :: * -> *) a. Foldable t => t a -> Bool
null [SValue JavaCode]
es then forall a. a -> a
id else String -> MethodState -> MethodState
addLangImport forall a b. (a -> b) -> a -> b
$ String -> String
utilImport
String
jArrays)
forall (r :: * -> *). ValueExpression r => PosCtorCall r
newObj (forall (r :: * -> *). TypeSym r => VSType r -> VSType r
listType VSType JavaCode
t) [VSType JavaCode -> [SValue JavaCode] -> SValue JavaCode
jAsListFunc VSType JavaCode
t [SValue JavaCode]
es | Bool -> Bool
not (forall (t :: * -> *) a. Foldable t => t a -> Bool
null [SValue JavaCode]
es)]
instance MathConstant JavaCode where
pi :: SValue JavaCode
pi = forall (r :: * -> *). RenderSym r => SValue r
CP.pi
instance VariableValue JavaCode where
valueOf :: SVariable JavaCode -> SValue JavaCode
valueOf = forall (r :: * -> *). RenderSym r => SVariable r -> SValue r
G.valueOf
instance CommandLineArgs JavaCode where
arg :: Integer -> SValue JavaCode
arg Integer
n = forall (r :: * -> *).
RenderSym r =>
SValue r -> SValue r -> SValue r
G.arg (forall (r :: * -> *). Literal r => Integer -> SValue r
litInt Integer
n) forall (r :: * -> *). CommandLineArgs r => SValue r
argsList
argsList :: SValue JavaCode
argsList = forall (r :: * -> *). RenderSym r => String -> SValue r
G.argsList String
args
argExists :: Integer -> SValue JavaCode
argExists Integer
i = forall (r :: * -> *). List r => SValue r -> SValue r
listSize forall (r :: * -> *). CommandLineArgs r => SValue r
argsList forall (r :: * -> *).
Comparison r =>
SValue r -> SValue r -> SValue r
?> forall (r :: * -> *). Literal r => Integer -> SValue r
litInt (forall a b. (Integral a, Num b) => a -> b
fromIntegral Integer
i)
instance NumericExpression JavaCode where
#~ :: SValue JavaCode -> SValue JavaCode
(#~) = forall (r :: * -> *).
RenderSym r =>
VSUnOp r -> SValue r -> SValue r
unExpr' forall (r :: * -> *). UnaryOpSym r => VSUnOp r
negateOp
#/^ :: SValue JavaCode -> SValue JavaCode
(#/^) = forall (r :: * -> *).
RenderSym r =>
VSUnOp r -> SValue r -> SValue r
unExprNumDbl forall (r :: * -> *). UnaryOpSym r => VSUnOp r
sqrtOp
#| :: SValue JavaCode -> SValue JavaCode
(#|) = forall (r :: * -> *).
RenderSym r =>
VSUnOp r -> SValue r -> SValue r
unExpr forall (r :: * -> *). UnaryOpSym r => VSUnOp r
absOp
#+ :: SValue JavaCode -> SValue JavaCode -> SValue JavaCode
(#+) = forall (r :: * -> *).
RenderSym r =>
VSBinOp r -> SValue r -> SValue r -> SValue r
binExpr forall (r :: * -> *). BinaryOpSym r => VSBinOp r
plusOp
#- :: SValue JavaCode -> SValue JavaCode -> SValue JavaCode
(#-) = forall (r :: * -> *).
RenderSym r =>
VSBinOp r -> SValue r -> SValue r -> SValue r
binExpr forall (r :: * -> *). BinaryOpSym r => VSBinOp r
minusOp
#* :: SValue JavaCode -> SValue JavaCode -> SValue JavaCode
(#*) = forall (r :: * -> *).
RenderSym r =>
VSBinOp r -> SValue r -> SValue r -> SValue r
binExpr forall (r :: * -> *). BinaryOpSym r => VSBinOp r
multOp
#/ :: SValue JavaCode -> SValue JavaCode -> SValue JavaCode
(#/) = forall (r :: * -> *).
RenderSym r =>
VSBinOp r -> SValue r -> SValue r -> SValue r
binExpr forall (r :: * -> *). BinaryOpSym r => VSBinOp r
divideOp
#% :: SValue JavaCode -> SValue JavaCode -> SValue JavaCode
(#%) = forall (r :: * -> *).
RenderSym r =>
VSBinOp r -> SValue r -> SValue r -> SValue r
binExpr forall (r :: * -> *). BinaryOpSym r => VSBinOp r
moduloOp
#^ :: SValue JavaCode -> SValue JavaCode -> SValue JavaCode
(#^) = forall (r :: * -> *).
RenderSym r =>
VSBinOp r -> SValue r -> SValue r -> SValue r
binExprNumDbl' forall (r :: * -> *). BinaryOpSym r => VSBinOp r
powerOp
log :: SValue JavaCode -> SValue JavaCode
log = forall (r :: * -> *).
RenderSym r =>
VSUnOp r -> SValue r -> SValue r
unExprNumDbl forall (r :: * -> *). UnaryOpSym r => VSUnOp r
logOp
ln :: SValue JavaCode -> SValue JavaCode
ln = forall (r :: * -> *).
RenderSym r =>
VSUnOp r -> SValue r -> SValue r
unExprNumDbl forall (r :: * -> *). UnaryOpSym r => VSUnOp r
lnOp
exp :: SValue JavaCode -> SValue JavaCode
exp = forall (r :: * -> *).
RenderSym r =>
VSUnOp r -> SValue r -> SValue r
unExprNumDbl forall (r :: * -> *). UnaryOpSym r => VSUnOp r
expOp
sin :: SValue JavaCode -> SValue JavaCode
sin = forall (r :: * -> *).
RenderSym r =>
VSUnOp r -> SValue r -> SValue r
unExprNumDbl forall (r :: * -> *). UnaryOpSym r => VSUnOp r
sinOp
cos :: SValue JavaCode -> SValue JavaCode
cos = forall (r :: * -> *).
RenderSym r =>
VSUnOp r -> SValue r -> SValue r
unExprNumDbl forall (r :: * -> *). UnaryOpSym r => VSUnOp r
cosOp
tan :: SValue JavaCode -> SValue JavaCode
tan = forall (r :: * -> *).
RenderSym r =>
VSUnOp r -> SValue r -> SValue r
unExprNumDbl forall (r :: * -> *). UnaryOpSym r => VSUnOp r
tanOp
csc :: SValue JavaCode -> SValue JavaCode
csc = forall (r :: * -> *). RenderSym r => SValue r -> SValue r
G.csc
sec :: SValue JavaCode -> SValue JavaCode
sec = forall (r :: * -> *). RenderSym r => SValue r -> SValue r
G.sec
cot :: SValue JavaCode -> SValue JavaCode
cot = forall (r :: * -> *). RenderSym r => SValue r -> SValue r
G.cot
arcsin :: SValue JavaCode -> SValue JavaCode
arcsin = forall (r :: * -> *).
RenderSym r =>
VSUnOp r -> SValue r -> SValue r
unExprNumDbl forall (r :: * -> *). UnaryOpSym r => VSUnOp r
asinOp
arccos :: SValue JavaCode -> SValue JavaCode
arccos = forall (r :: * -> *).
RenderSym r =>
VSUnOp r -> SValue r -> SValue r
unExprNumDbl forall (r :: * -> *). UnaryOpSym r => VSUnOp r
acosOp
arctan :: SValue JavaCode -> SValue JavaCode
arctan = forall (r :: * -> *).
RenderSym r =>
VSUnOp r -> SValue r -> SValue r
unExprNumDbl forall (r :: * -> *). UnaryOpSym r => VSUnOp r
atanOp
floor :: SValue JavaCode -> SValue JavaCode
floor = forall (r :: * -> *).
RenderSym r =>
VSUnOp r -> SValue r -> SValue r
unExpr forall (r :: * -> *). UnaryOpSym r => VSUnOp r
floorOp
ceil :: SValue JavaCode -> SValue JavaCode
ceil = forall (r :: * -> *).
RenderSym r =>
VSUnOp r -> SValue r -> SValue r
unExpr forall (r :: * -> *). UnaryOpSym r => VSUnOp r
ceilOp
instance BooleanExpression JavaCode where
?! :: SValue JavaCode -> SValue JavaCode
(?!) = forall (r :: * -> *).
RenderSym r =>
VSUnOp r -> VSType r -> SValue r -> SValue r
typeUnExpr forall (r :: * -> *). UnaryOpSym r => VSUnOp r
notOp forall (r :: * -> *). TypeSym r => VSType r
bool
?&& :: SValue JavaCode -> SValue JavaCode -> SValue JavaCode
(?&&) = forall (r :: * -> *).
RenderSym r =>
VSBinOp r -> VSType r -> SValue r -> SValue r -> SValue r
typeBinExpr forall (r :: * -> *). BinaryOpSym r => VSBinOp r
andOp forall (r :: * -> *). TypeSym r => VSType r
bool
?|| :: SValue JavaCode -> SValue JavaCode -> SValue JavaCode
(?||) = forall (r :: * -> *).
RenderSym r =>
VSBinOp r -> VSType r -> SValue r -> SValue r -> SValue r
typeBinExpr forall (r :: * -> *). BinaryOpSym r => VSBinOp r
orOp forall (r :: * -> *). TypeSym r => VSType r
bool
instance Comparison JavaCode where
?< :: SValue JavaCode -> SValue JavaCode -> SValue JavaCode
(?<) = forall (r :: * -> *).
RenderSym r =>
VSBinOp r -> VSType r -> SValue r -> SValue r -> SValue r
typeBinExpr forall (r :: * -> *). BinaryOpSym r => VSBinOp r
lessOp forall (r :: * -> *). TypeSym r => VSType r
bool
?<= :: SValue JavaCode -> SValue JavaCode -> SValue JavaCode
(?<=) = forall (r :: * -> *).
RenderSym r =>
VSBinOp r -> VSType r -> SValue r -> SValue r -> SValue r
typeBinExpr forall (r :: * -> *). BinaryOpSym r => VSBinOp r
lessEqualOp forall (r :: * -> *). TypeSym r => VSType r
bool
?> :: SValue JavaCode -> SValue JavaCode -> SValue JavaCode
(?>) = forall (r :: * -> *).
RenderSym r =>
VSBinOp r -> VSType r -> SValue r -> SValue r -> SValue r
typeBinExpr forall (r :: * -> *). BinaryOpSym r => VSBinOp r
greaterOp forall (r :: * -> *). TypeSym r => VSType r
bool
?>= :: SValue JavaCode -> SValue JavaCode -> SValue JavaCode
(?>=) = forall (r :: * -> *).
RenderSym r =>
VSBinOp r -> VSType r -> SValue r -> SValue r -> SValue r
typeBinExpr forall (r :: * -> *). BinaryOpSym r => VSBinOp r
greaterEqualOp forall (r :: * -> *). TypeSym r => VSType r
bool
?== :: SValue JavaCode -> SValue JavaCode -> SValue JavaCode
(?==) = SValue JavaCode -> SValue JavaCode -> SValue JavaCode
jEquality
?!= :: SValue JavaCode -> SValue JavaCode -> SValue JavaCode
(?!=) = forall (r :: * -> *).
RenderSym r =>
VSBinOp r -> VSType r -> SValue r -> SValue r -> SValue r
typeBinExpr forall (r :: * -> *). BinaryOpSym r => VSBinOp r
notEqualOp forall (r :: * -> *). TypeSym r => VSType r
bool
instance ValueExpression JavaCode where
inlineIf :: SValue JavaCode
-> SValue JavaCode -> SValue JavaCode -> SValue JavaCode
inlineIf = forall (r :: * -> *).
RenderSym r =>
SValue r -> SValue r -> SValue r -> SValue r
C.inlineIf
funcAppMixedArgs :: MixedCall JavaCode
funcAppMixedArgs String
n VSType JavaCode
t [SValue JavaCode]
vs NamedArgs JavaCode
ns = do
String -> StateT ValueState Identity ()
addCallExcsCurrMod String
n
forall (r :: * -> *). RenderSym r => MixedCall r
G.funcAppMixedArgs String
n VSType JavaCode
t [SValue JavaCode]
vs NamedArgs JavaCode
ns
selfFuncAppMixedArgs :: MixedCall JavaCode
selfFuncAppMixedArgs String
n VSType JavaCode
t [SValue JavaCode]
ps NamedArgs JavaCode
ns = do
String -> StateT ValueState Identity ()
addCallExcsCurrMod String
n
forall (r :: * -> *).
RenderSym r =>
Doc -> SVariable r -> MixedCall r
G.selfFuncAppMixedArgs Doc
dot forall (r :: * -> *). VariableSym r => SVariable r
self String
n VSType JavaCode
t [SValue JavaCode]
ps NamedArgs JavaCode
ns
extFuncAppMixedArgs :: String -> MixedCall JavaCode
extFuncAppMixedArgs String
l String
n VSType JavaCode
t [SValue JavaCode]
vs NamedArgs JavaCode
ns = do
Map QualifiedName [ExceptionType]
mem <- VS (Map QualifiedName [ExceptionType])
getMethodExcMap
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (forall b a. b -> (a -> b) -> Maybe a -> b
maybe forall a. a -> a
id [ExceptionType] -> ValueState -> ValueState
addExceptions (forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup (String -> String -> QualifiedName
qualName String
l String
n) Map QualifiedName [ExceptionType]
mem))
forall (r :: * -> *). RenderSym r => String -> MixedCall r
CP.extFuncAppMixedArgs String
l String
n VSType JavaCode
t [SValue JavaCode]
vs NamedArgs JavaCode
ns
libFuncAppMixedArgs :: String -> MixedCall JavaCode
libFuncAppMixedArgs = forall (r :: * -> *). RenderSym r => String -> MixedCall r
C.libFuncAppMixedArgs
newObjMixedArgs :: MixedCtorCall JavaCode
newObjMixedArgs VSType JavaCode
ot [SValue JavaCode]
vs NamedArgs JavaCode
ns = forall (r :: * -> *).
RenderSym r =>
VSType r -> (VSType r -> SValue r) -> SValue r
addConstructorCallExcsCurrMod VSType JavaCode
ot (\VSType JavaCode
t ->
forall (r :: * -> *). RenderSym r => MixedCall r
G.newObjMixedArgs (String
new forall a. [a] -> [a] -> [a]
++ String
" ") VSType JavaCode
t [SValue JavaCode]
vs NamedArgs JavaCode
ns)
extNewObjMixedArgs :: MixedCall JavaCode
extNewObjMixedArgs String
l VSType JavaCode
ot [SValue JavaCode]
vs NamedArgs JavaCode
ns = do
JavaCode TypeData
t <- VSType JavaCode
ot
Map QualifiedName [ExceptionType]
mem <- VS (Map QualifiedName [ExceptionType])
getMethodExcMap
let tp :: String
tp = forall (r :: * -> *). TypeElim r => r (Type r) -> String
getTypeString JavaCode TypeData
t
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (forall b a. b -> (a -> b) -> Maybe a -> b
maybe forall a. a -> a
id [ExceptionType] -> ValueState -> ValueState
addExceptions (forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup (String -> String -> QualifiedName
qualName String
l String
tp) Map QualifiedName [ExceptionType]
mem))
forall (r :: * -> *). ValueExpression r => MixedCtorCall r
newObjMixedArgs (forall a s. a -> State s a
toState JavaCode TypeData
t) [SValue JavaCode]
vs NamedArgs JavaCode
ns
libNewObjMixedArgs :: MixedCall JavaCode
libNewObjMixedArgs = forall (r :: * -> *). RenderSym r => MixedCall r
C.libNewObjMixedArgs
lambda :: [SVariable JavaCode] -> SValue JavaCode -> SValue JavaCode
lambda = forall (r :: * -> *).
RenderSym r =>
([r (Variable r)] -> r (Value r) -> Doc)
-> [SVariable r] -> SValue r -> SValue r
G.lambda forall (r :: * -> *).
RenderSym r =>
[r (Variable r)] -> r (Value r) -> Doc
jLambda
notNull :: SValue JavaCode -> SValue JavaCode
notNull = forall (r :: * -> *). RenderSym r => String -> SValue r -> SValue r
CP.notNull String
nullLabel
instance RenderValue JavaCode where
inputFunc :: SValue JavaCode
inputFunc = forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (String -> ValueState -> ValueState
addLangImportVS forall a b. (a -> b) -> a -> b
$ String -> String
utilImport String
jScanner) forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (r :: * -> *). RenderSym r => VSType r -> Doc -> SValue r
mkStateVal
(forall (r :: * -> *). TypeSym r => String -> VSType r
obj String
jScanner) (Doc -> Doc
parens forall a b. (a -> b) -> a -> b
$ Doc
new' Doc -> Doc -> Doc
<+> Doc
jScanner' Doc -> Doc -> Doc
<> Doc -> Doc
parens (String -> Doc
jSystem String
jStdIn))
printFunc :: SValue JavaCode
printFunc = forall (r :: * -> *). RenderSym r => VSType r -> Doc -> SValue r
mkStateVal forall (r :: * -> *). TypeSym r => VSType r
void (String -> Doc
jSystem (String
jStdOut String -> String -> String
`access` String
printLabel))
printLnFunc :: SValue JavaCode
printLnFunc = forall (r :: * -> *). RenderSym r => VSType r -> Doc -> SValue r
mkStateVal forall (r :: * -> *). TypeSym r => VSType r
void (String -> Doc
jSystem (String
jStdOut String -> String -> String
`access` String
jPrintLn))
printFileFunc :: SValue JavaCode -> SValue JavaCode
printFileFunc = forall (m :: * -> *) a b c.
Monad m =>
(a -> b -> m c) -> m a -> m b -> m c
on2StateWrapped (\JavaCode TypeData
v -> forall (r :: * -> *). RenderSym r => r (Type r) -> Doc -> SValue r
mkVal JavaCode TypeData
v forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Doc -> Doc
R.printFile String
printLabel forall b c a. (b -> c) -> (a -> b) -> a -> c
.
forall (r :: * -> *). ValueElim r => r (Value r) -> Doc
RC.value) forall (r :: * -> *). TypeSym r => VSType r
void
printFileLnFunc :: SValue JavaCode -> SValue JavaCode
printFileLnFunc = forall (m :: * -> *) a b c.
Monad m =>
(a -> b -> m c) -> m a -> m b -> m c
on2StateWrapped (\JavaCode TypeData
v -> forall (r :: * -> *). RenderSym r => r (Type r) -> Doc -> SValue r
mkVal JavaCode TypeData
v forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Doc -> Doc
R.printFile String
jPrintLn forall b c a. (b -> c) -> (a -> b) -> a -> c
.
forall (r :: * -> *). ValueElim r => r (Value r) -> Doc
RC.value) forall (r :: * -> *). TypeSym r => VSType r
void
cast :: VSType JavaCode -> SValue JavaCode -> SValue JavaCode
cast = VSType JavaCode -> SValue JavaCode -> SValue JavaCode
jCast
call :: Maybe String -> Maybe Doc -> MixedCall JavaCode
call = forall (r :: * -> *).
RenderSym r =>
String -> Maybe String -> Maybe Doc -> MixedCall r
CP.call' String
jName
valFromData :: Maybe Int -> VSType JavaCode -> Doc -> SValue JavaCode
valFromData Maybe Int
p VSType JavaCode
t' Doc
d = do
JavaCode TypeData
t <- VSType JavaCode
t'
forall a s. a -> State s a
toState forall a b. (a -> b) -> a -> b
$ forall (r :: * -> *) a b c.
Applicative r =>
(a -> b -> c) -> r a -> r b -> r c
on2CodeValues (Maybe Int -> TypeData -> Doc -> ValData
vd Maybe Int
p) JavaCode TypeData
t (forall (r :: * -> *) a. Monad r => a -> r a
toCode Doc
d)
instance ValueElim JavaCode where
valuePrec :: JavaCode (Value JavaCode) -> Maybe Int
valuePrec = ValData -> Maybe Int
valPrec forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. JavaCode a -> a
unJC
value :: JavaCode (Value JavaCode) -> Doc
value = ValData -> Doc
val forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. JavaCode a -> a
unJC
instance InternalValueExp JavaCode where
objMethodCallMixedArgs' :: String
-> VSType JavaCode
-> SValue JavaCode
-> [SValue JavaCode]
-> NamedArgs JavaCode
-> SValue JavaCode
objMethodCallMixedArgs' String
f VSType JavaCode
t SValue JavaCode
o [SValue JavaCode]
ps NamedArgs JavaCode
ns = do
JavaCode ValData
ob <- SValue JavaCode
o
Map QualifiedName [ExceptionType]
mem <- VS (Map QualifiedName [ExceptionType])
getMethodExcMap
let tp :: String
tp = forall (r :: * -> *). TypeElim r => r (Type r) -> String
getTypeString (forall (r :: * -> *). ValueSym r => r (Value r) -> r (Type r)
valueType JavaCode ValData
ob)
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (forall b a. b -> (a -> b) -> Maybe a -> b
maybe forall a. a -> a
id [ExceptionType] -> ValueState -> ValueState
addExceptions (forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup (String -> String -> QualifiedName
qualName String
tp String
f) Map QualifiedName [ExceptionType]
mem))
forall (r :: * -> *).
RenderSym r =>
String
-> VSType r -> SValue r -> [SValue r] -> NamedArgs r -> SValue r
G.objMethodCall String
f VSType JavaCode
t SValue JavaCode
o [SValue JavaCode]
ps NamedArgs JavaCode
ns
instance FunctionSym JavaCode where
type Function JavaCode = FuncData
func :: String
-> VSType JavaCode -> [SValue JavaCode] -> VSFunction JavaCode
func = forall (r :: * -> *).
RenderSym r =>
String -> VSType r -> [SValue r] -> VSFunction r
G.func
objAccess :: SValue JavaCode -> VSFunction JavaCode -> SValue JavaCode
objAccess = forall (r :: * -> *).
RenderSym r =>
SValue r -> VSFunction r -> SValue r
G.objAccess
instance GetSet JavaCode where
get :: SValue JavaCode -> SVariable JavaCode -> SValue JavaCode
get = forall (r :: * -> *).
RenderSym r =>
SValue r -> SVariable r -> SValue r
G.get
set :: SValue JavaCode
-> SVariable JavaCode -> SValue JavaCode -> SValue JavaCode
set = forall (r :: * -> *).
RenderSym r =>
SValue r -> SVariable r -> SValue r -> SValue r
G.set
instance List JavaCode where
listSize :: SValue JavaCode -> SValue JavaCode
listSize = forall (r :: * -> *). RenderSym r => SValue r -> SValue r
C.listSize
listAdd :: SValue JavaCode
-> SValue JavaCode -> SValue JavaCode -> SValue JavaCode
listAdd = forall (r :: * -> *).
RenderSym r =>
SValue r -> SValue r -> SValue r -> SValue r
G.listAdd
listAppend :: SValue JavaCode -> SValue JavaCode -> SValue JavaCode
listAppend = forall (r :: * -> *).
RenderSym r =>
SValue r -> SValue r -> SValue r
G.listAppend
listAccess :: SValue JavaCode -> SValue JavaCode -> SValue JavaCode
listAccess = forall (r :: * -> *).
RenderSym r =>
SValue r -> SValue r -> SValue r
G.listAccess
listSet :: SValue JavaCode
-> SValue JavaCode -> SValue JavaCode -> SValue JavaCode
listSet = forall (r :: * -> *).
RenderSym r =>
SValue r -> SValue r -> SValue r -> SValue r
G.listSet
indexOf :: SValue JavaCode -> SValue JavaCode -> SValue JavaCode
indexOf = forall (r :: * -> *).
RenderSym r =>
String -> SValue r -> SValue r -> SValue r
CP.indexOf String
jIndex
instance InternalList JavaCode where
listSlice' :: Maybe (SValue JavaCode)
-> Maybe (SValue JavaCode)
-> Maybe (SValue JavaCode)
-> SVariable JavaCode
-> SValue JavaCode
-> MSBlock JavaCode
listSlice' = forall (r :: * -> *).
RenderSym r =>
Maybe (SValue r)
-> Maybe (SValue r)
-> Maybe (SValue r)
-> SVariable r
-> SValue r
-> MSBlock r
M.listSlice
instance InternalGetSet JavaCode where
getFunc :: SVariable JavaCode -> VSFunction JavaCode
getFunc = forall (r :: * -> *). RenderSym r => SVariable r -> VSFunction r
G.getFunc
setFunc :: VSType JavaCode
-> SVariable JavaCode -> SValue JavaCode -> VSFunction JavaCode
setFunc = forall (r :: * -> *).
RenderSym r =>
VSType r -> SVariable r -> SValue r -> VSFunction r
G.setFunc
instance InternalListFunc JavaCode where
listSizeFunc :: VSFunction JavaCode
listSizeFunc = forall (r :: * -> *). RenderSym r => VSFunction r
CP.listSizeFunc
listAddFunc :: SValue JavaCode
-> SValue JavaCode -> SValue JavaCode -> VSFunction JavaCode
listAddFunc SValue JavaCode
_ = forall (r :: * -> *).
RenderSym r =>
String -> SValue r -> SValue r -> VSFunction r
CP.listAddFunc String
jListAdd
listAppendFunc :: SValue JavaCode -> VSFunction JavaCode
listAppendFunc = forall (r :: * -> *).
RenderSym r =>
String -> SValue r -> VSFunction r
G.listAppendFunc String
jListAdd
listAccessFunc :: VSType JavaCode -> SValue JavaCode -> VSFunction JavaCode
listAccessFunc = forall (r :: * -> *).
RenderSym r =>
String -> VSType r -> SValue r -> VSFunction r
CP.listAccessFunc' String
jListAccess
listSetFunc :: SValue JavaCode
-> SValue JavaCode -> SValue JavaCode -> VSFunction JavaCode
listSetFunc = SValue JavaCode
-> SValue JavaCode -> SValue JavaCode -> VSFunction JavaCode
jListSetFunc
instance ThunkSym JavaCode where
type Thunk JavaCode = CommonThunk VS
instance ThunkAssign JavaCode where
thunkAssign :: SVariable JavaCode -> VSThunk JavaCode -> MSStatement JavaCode
thunkAssign SVariable JavaCode
v VSThunk JavaCode
t = do
String
iName <- MS String
genLoopIndex
let
i :: SVariable JavaCode
i = forall (r :: * -> *).
VariableSym r =>
String -> VSType r -> SVariable r
var String
iName forall (r :: * -> *). TypeSym r => VSType r
int
dim :: StateT ValueState Identity (JavaCode ValData)
dim = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ VSThunk JavaCode
t forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall (s :: * -> *).
(s ValData -> s ValData) -> CommonThunk s -> s ValData
commonThunkDim (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. JavaCode a -> a
unJC forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (r :: * -> *). List r => SValue r -> SValue r
listSize forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall (f :: * -> *) a. Applicative f => a -> f a
pure) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. JavaCode a -> a
unJC
loopInit :: MSStatement JavaCode
loopInit = forall (m :: * -> *) (n :: * -> *) s t c.
Zoom m n s t =>
LensLike' (Zoomed m c) t s -> m c -> n c
zoom Lens' MethodState ValueState
lensMStoVS (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. JavaCode a -> a
unJC VSThunk JavaCode
t) forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall (s :: * -> *) a.
(CommonThunk s -> a) -> (CommonThunk s -> a) -> CommonThunk s -> a
commonThunkElim
(forall a b. a -> b -> a
const forall (r :: * -> *). RenderStatement r => MSStatement r
emptyStmt) (forall a b. a -> b -> a
const forall a b. (a -> b) -> a -> b
$ forall (r :: * -> *).
AssignStatement r =>
SVariable r -> SValue r -> MSStatement r
assign SVariable JavaCode
v forall a b. (a -> b) -> a -> b
$ forall (r :: * -> *).
(TypeElim r, Literal r) =>
VSType r -> SValue r
litZero forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall (r :: * -> *).
VariableElim r =>
r (Variable r) -> r (Type r)
variableType SVariable JavaCode
v)
loopBody :: MSStatement JavaCode
loopBody = forall (m :: * -> *) (n :: * -> *) s t c.
Zoom m n s t =>
LensLike' (Zoomed m c) t s -> m c -> n c
zoom Lens' MethodState ValueState
lensMStoVS (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. JavaCode a -> a
unJC VSThunk JavaCode
t) forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall (s :: * -> *) a.
(CommonThunk s -> a) -> (CommonThunk s -> a) -> CommonThunk s -> a
commonThunkElim
(forall (r :: * -> *). StatementSym r => SValue r -> MSStatement r
valStmt forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (r :: * -> *).
List r =>
SValue r -> SValue r -> SValue r -> SValue r
listSet (forall (r :: * -> *). VariableValue r => SVariable r -> SValue r
valueOf SVariable JavaCode
v) (forall (r :: * -> *). VariableValue r => SVariable r -> SValue r
valueOf SVariable JavaCode
i) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (r :: * -> *).
VectorExpression r =>
SValue r -> VSThunk r -> SValue r
vecIndex (forall (r :: * -> *). VariableValue r => SVariable r -> SValue r
valueOf SVariable JavaCode
i) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a. Applicative f => a -> f a
pure forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a. Applicative f => a -> f a
pure)
((SVariable JavaCode
v &+=) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (r :: * -> *).
VectorExpression r =>
SValue r -> VSThunk r -> SValue r
vecIndex (forall (r :: * -> *). VariableValue r => SVariable r -> SValue r
valueOf SVariable JavaCode
i) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a. Applicative f => a -> f a
pure forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a. Applicative f => a -> f a
pure)
forall (r :: * -> *).
StatementSym r =>
[MSStatement r] -> MSStatement r
multi [MSStatement JavaCode
loopInit,
forall (r :: * -> *).
ControlStatement r =>
SVariable r
-> SValue r -> SValue r -> SValue r -> MSBody r -> MSStatement r
forRange SVariable JavaCode
i (forall (r :: * -> *). Literal r => Integer -> SValue r
litInt Integer
0) StateT ValueState Identity (JavaCode ValData)
dim (forall (r :: * -> *). Literal r => Integer -> SValue r
litInt Integer
1) forall a b. (a -> b) -> a -> b
$ forall (r :: * -> *). BodySym r => [MSBlock r] -> MSBody r
body [forall (r :: * -> *). BlockSym r => [MSStatement r] -> MSBlock r
block [MSStatement JavaCode
loopBody]]]
instance VectorType JavaCode where
vecType :: VSType JavaCode -> VSType JavaCode
vecType = forall (r :: * -> *). TypeSym r => VSType r -> VSType r
listType
instance VectorDecl JavaCode where
vecDec :: Integer -> SVariable JavaCode -> MSStatement JavaCode
vecDec = forall (r :: * -> *).
DeclStatement r =>
Integer -> SVariable r -> MSStatement r
listDec
vecDecDef :: SVariable JavaCode -> [SValue JavaCode] -> MSStatement JavaCode
vecDecDef = forall (r :: * -> *).
DeclStatement r =>
SVariable r -> [SValue r] -> MSStatement r
listDecDef
instance VectorThunk JavaCode where
vecThunk :: SVariable JavaCode -> VSThunk JavaCode
vecThunk = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a. Applicative f => a -> f a
pure forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (s :: * -> *). s ValData -> CommonThunk s
pureValue forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. JavaCode a -> a
unJC forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (r :: * -> *). VariableValue r => SVariable r -> SValue r
valueOf
instance VectorExpression JavaCode where
vecScale :: SValue JavaCode -> VSThunk JavaCode -> VSThunk JavaCode
vecScale SValue JavaCode
k = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. (a -> b) -> a -> b
$ forall (s :: * -> *).
(s ValData -> s ValData) -> CommonThunk s -> CommonThunk s
vectorize (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. JavaCode a -> a
unJC forall b c a. (b -> c) -> (a -> b) -> a -> c
. (SValue JavaCode
k #*) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall (f :: * -> *) a. Applicative f => a -> f a
pure)
vecAdd :: VSThunk JavaCode -> VSThunk JavaCode -> VSThunk JavaCode
vecAdd = forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 forall a b. (a -> b) -> a -> b
$ forall (s :: * -> *).
(s ValData -> s ValData -> s ValData)
-> CommonThunk s -> CommonThunk s -> CommonThunk s
vectorize2 (\StateT ValueState Identity ValData
v1 StateT ValueState Identity ValData
v2 -> forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. JavaCode a -> a
unJC forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall (f :: * -> *) a. Applicative f => a -> f a
pure StateT ValueState Identity ValData
v1 forall (r :: * -> *).
NumericExpression r =>
SValue r -> SValue r -> SValue r
#+ forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall (f :: * -> *) a. Applicative f => a -> f a
pure StateT ValueState Identity ValData
v2)
vecIndex :: SValue JavaCode -> VSThunk JavaCode -> SValue JavaCode
vecIndex SValue JavaCode
i = (forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall (f :: * -> *) a. Applicative f => a -> f a
pure forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (s :: * -> *).
(s ValData -> s ValData) -> CommonThunk s -> s ValData
commonVecIndex (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. JavaCode a -> a
unJC forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b c. (a -> b -> c) -> b -> a -> c
flip forall (r :: * -> *). List r => SValue r -> SValue r -> SValue r
listAccess SValue JavaCode
i forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall (f :: * -> *) a. Applicative f => a -> f a
pure) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. JavaCode a -> a
unJC)
vecDot :: VSThunk JavaCode -> VSThunk JavaCode -> VSThunk JavaCode
vecDot = forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall (s :: * -> *). CommonThunk s -> CommonThunk s
sumComponents forall (r :: * -> *) a b. Functor r => (a -> b) -> r a -> r b
<$> forall (s :: * -> *).
(s ValData -> s ValData -> s ValData)
-> CommonThunk s -> CommonThunk s -> CommonThunk s
vectorize2 (\StateT ValueState Identity ValData
v1 StateT ValueState Identity ValData
v2 -> forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. JavaCode a -> a
unJC forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall (f :: * -> *) a. Applicative f => a -> f a
pure StateT ValueState Identity ValData
v1 forall (r :: * -> *).
NumericExpression r =>
SValue r -> SValue r -> SValue r
#* forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall (f :: * -> *) a. Applicative f => a -> f a
pure StateT ValueState Identity ValData
v2)
instance RenderFunction JavaCode where
funcFromData :: Doc -> VSType JavaCode -> VSFunction JavaCode
funcFromData Doc
d = forall a b s. (a -> b) -> State s a -> State s b
onStateValue (forall (r :: * -> *) a b. Functor r => (a -> b) -> r a -> r b
onCodeValue (TypeData -> Doc -> FuncData
`fd` Doc
d))
instance FunctionElim JavaCode where
functionType :: JavaCode (Function JavaCode) -> JavaCode (Type JavaCode)
functionType = forall (r :: * -> *) a b. Functor r => (a -> b) -> r a -> r b
onCodeValue FuncData -> TypeData
fType
function :: JavaCode (Function JavaCode) -> Doc
function = FuncData -> Doc
funcDoc forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. JavaCode a -> a
unJC
instance InternalAssignStmt JavaCode where
multiAssign :: [SVariable JavaCode] -> [SValue JavaCode] -> MSStatement JavaCode
multiAssign [SVariable JavaCode]
_ [SValue JavaCode]
_ = forall a. HasCallStack => String -> a
error forall a b. (a -> b) -> a -> b
$ String -> String
C.multiAssignError String
jName
instance InternalIOStmt JavaCode where
printSt :: Bool
-> Maybe (SValue JavaCode)
-> SValue JavaCode
-> SValue JavaCode
-> MSStatement JavaCode
printSt Bool
_ Maybe (SValue JavaCode)
_ = forall (r :: * -> *).
RenderSym r =>
SValue r -> SValue r -> MSStatement r
CP.printSt
instance InternalControlStmt JavaCode where
multiReturn :: [SValue JavaCode] -> MSStatement JavaCode
multiReturn [SValue JavaCode]
_ = forall a. HasCallStack => String -> a
error forall a b. (a -> b) -> a -> b
$ String -> String
C.multiReturnError String
jName
instance RenderStatement JavaCode where
stmt :: MSStatement JavaCode -> MSStatement JavaCode
stmt = forall (r :: * -> *). RenderSym r => MSStatement r -> MSStatement r
G.stmt
loopStmt :: MSStatement JavaCode -> MSStatement JavaCode
loopStmt = forall (r :: * -> *). RenderSym r => MSStatement r -> MSStatement r
G.loopStmt
emptyStmt :: MSStatement JavaCode
emptyStmt = forall (r :: * -> *). RenderSym r => MSStatement r
G.emptyStmt
stmtFromData :: Doc -> Terminator -> MSStatement JavaCode
stmtFromData Doc
d Terminator
t = forall a s. a -> State s a
toState forall a b. (a -> b) -> a -> b
$ forall (r :: * -> *) a. Monad r => a -> r a
toCode (Doc
d, Terminator
t)
instance StatementElim JavaCode where
statement :: JavaCode (Statement JavaCode) -> Doc
statement = forall a b. (a, b) -> a
fst forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. JavaCode a -> a
unJC
statementTerm :: JavaCode (Statement JavaCode) -> Terminator
statementTerm = forall a b. (a, b) -> b
snd forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. JavaCode a -> a
unJC
instance StatementSym JavaCode where
type Statement JavaCode = (Doc, Terminator)
valStmt :: SValue JavaCode -> MSStatement JavaCode
valStmt = forall (r :: * -> *).
RenderSym r =>
Terminator -> SValue r -> MSStatement r
G.valStmt Terminator
Semi
multi :: [MSStatement JavaCode] -> MSStatement JavaCode
multi = forall a b s. ([a] -> b) -> [State s a] -> State s b
onStateList (forall (m :: * -> *) a b. Monad m => ([a] -> b) -> [m a] -> m b
onCodeList [(Doc, Terminator)] -> (Doc, Terminator)
R.multiStmt)
instance AssignStatement JavaCode where
assign :: SVariable JavaCode -> SValue JavaCode -> MSStatement JavaCode
assign = forall (r :: * -> *).
RenderSym r =>
Terminator -> SVariable r -> SValue r -> MSStatement r
G.assign Terminator
Semi
&-= :: SVariable JavaCode -> SValue JavaCode -> MSStatement JavaCode
(&-=) = forall (r :: * -> *).
RenderSym r =>
Terminator -> SVariable r -> SValue r -> MSStatement r
G.subAssign Terminator
Semi
&+= :: SVariable JavaCode -> SValue JavaCode -> MSStatement JavaCode
(&+=) = forall (r :: * -> *).
RenderSym r =>
SVariable r -> SValue r -> MSStatement r
G.increment
&++ :: SVariable JavaCode -> MSStatement JavaCode
(&++) = forall (r :: * -> *). RenderSym r => SVariable r -> MSStatement r
C.increment1
&-- :: SVariable JavaCode -> MSStatement JavaCode
(&--) = forall (r :: * -> *). RenderSym r => SVariable r -> MSStatement r
C.decrement1
instance DeclStatement JavaCode where
varDec :: SVariable JavaCode -> MSStatement JavaCode
varDec = forall (r :: * -> *).
RenderSym r =>
r (Permanence r)
-> r (Permanence r) -> Doc -> SVariable r -> MSStatement r
C.varDec forall (r :: * -> *). PermanenceSym r => r (Permanence r)
static forall (r :: * -> *). PermanenceSym r => r (Permanence r)
dynamic Doc
empty
varDecDef :: SVariable JavaCode -> SValue JavaCode -> MSStatement JavaCode
varDecDef = forall (r :: * -> *).
RenderSym r =>
Terminator -> SVariable r -> SValue r -> MSStatement r
C.varDecDef Terminator
Semi
listDec :: Integer -> SVariable JavaCode -> MSStatement JavaCode
listDec Integer
n SVariable JavaCode
v = forall (m :: * -> *) (n :: * -> *) s t c.
Zoom m n s t =>
LensLike' (Zoomed m c) t s -> m c -> n c
zoom Lens' MethodState ValueState
lensMStoVS SVariable JavaCode
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (\JavaCode VarData
v' -> forall (r :: * -> *).
RenderSym r =>
(r (Value r) -> Doc) -> SValue r -> SVariable r -> MSStatement r
C.listDec (forall (r :: * -> *).
RenderSym r =>
r (Variable r) -> r (Value r) -> Doc
R.listDec JavaCode VarData
v')
(forall (r :: * -> *). Literal r => Integer -> SValue r
litInt Integer
n) SVariable JavaCode
v)
listDecDef :: SVariable JavaCode -> [SValue JavaCode] -> MSStatement JavaCode
listDecDef = forall (r :: * -> *).
RenderSym r =>
SVariable r -> [SValue r] -> MSStatement r
CP.listDecDef
arrayDec :: Integer -> SVariable JavaCode -> MSStatement JavaCode
arrayDec Integer
n = forall (r :: * -> *).
RenderSym r =>
SValue r -> SVariable r -> MSStatement r
CP.arrayDec (forall (r :: * -> *). Literal r => Integer -> SValue r
litInt Integer
n)
arrayDecDef :: SVariable JavaCode -> [SValue JavaCode] -> MSStatement JavaCode
arrayDecDef = forall (r :: * -> *).
RenderSym r =>
SVariable r -> [SValue r] -> MSStatement r
CP.arrayDecDef
objDecDef :: SVariable JavaCode -> SValue JavaCode -> MSStatement JavaCode
objDecDef = forall (r :: * -> *).
DeclStatement r =>
SVariable r -> SValue r -> MSStatement r
varDecDef
objDecNew :: SVariable JavaCode -> [SValue JavaCode] -> MSStatement JavaCode
objDecNew = forall (r :: * -> *).
RenderSym r =>
SVariable r -> [SValue r] -> MSStatement r
G.objDecNew
extObjDecNew :: String
-> SVariable JavaCode -> [SValue JavaCode] -> MSStatement JavaCode
extObjDecNew = forall (r :: * -> *).
RenderSym r =>
String -> SVariable r -> [SValue r] -> MSStatement r
C.extObjDecNew
constDecDef :: SVariable JavaCode -> SValue JavaCode -> MSStatement JavaCode
constDecDef = forall (r :: * -> *).
RenderSym r =>
SVariable r -> SValue r -> MSStatement r
jConstDecDef
funcDecDef :: SVariable JavaCode
-> [SVariable JavaCode] -> MSBody JavaCode -> MSStatement JavaCode
funcDecDef = forall (r :: * -> *).
RenderSym r =>
SVariable r -> [SVariable r] -> MSBody r -> MSStatement r
jFuncDecDef
instance IOStatement JavaCode where
print :: SValue JavaCode -> MSStatement JavaCode
print = forall (r :: * -> *).
RenderSym r =>
Bool -> Maybe (SValue r) -> SValue r -> SValue r -> MSStatement r
jOut Bool
False forall a. Maybe a
Nothing forall (r :: * -> *). RenderValue r => SValue r
printFunc
printLn :: SValue JavaCode -> MSStatement JavaCode
printLn = forall (r :: * -> *).
RenderSym r =>
Bool -> Maybe (SValue r) -> SValue r -> SValue r -> MSStatement r
jOut Bool
True forall a. Maybe a
Nothing forall (r :: * -> *). RenderValue r => SValue r
printLnFunc
printStr :: String -> MSStatement JavaCode
printStr = forall (r :: * -> *).
RenderSym r =>
Bool -> Maybe (SValue r) -> SValue r -> SValue r -> MSStatement r
jOut Bool
False forall a. Maybe a
Nothing forall (r :: * -> *). RenderValue r => SValue r
printFunc forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (r :: * -> *). Literal r => String -> SValue r
litString
printStrLn :: String -> MSStatement JavaCode
printStrLn = forall (r :: * -> *).
RenderSym r =>
Bool -> Maybe (SValue r) -> SValue r -> SValue r -> MSStatement r
jOut Bool
True forall a. Maybe a
Nothing forall (r :: * -> *). RenderValue r => SValue r
printLnFunc forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (r :: * -> *). Literal r => String -> SValue r
litString
printFile :: SValue JavaCode -> SValue JavaCode -> MSStatement JavaCode
printFile SValue JavaCode
f = forall (r :: * -> *).
RenderSym r =>
Bool -> Maybe (SValue r) -> SValue r -> SValue r -> MSStatement r
jOut Bool
False (forall a. a -> Maybe a
Just SValue JavaCode
f) (forall (r :: * -> *). RenderValue r => SValue r -> SValue r
printFileFunc SValue JavaCode
f)
printFileLn :: SValue JavaCode -> SValue JavaCode -> MSStatement JavaCode
printFileLn SValue JavaCode
f = forall (r :: * -> *).
RenderSym r =>
Bool -> Maybe (SValue r) -> SValue r -> SValue r -> MSStatement r
jOut Bool
True (forall a. a -> Maybe a
Just SValue JavaCode
f) (forall (r :: * -> *). RenderValue r => SValue r -> SValue r
printFileLnFunc SValue JavaCode
f)
printFileStr :: SValue JavaCode -> String -> MSStatement JavaCode
printFileStr SValue JavaCode
f = forall (r :: * -> *).
RenderSym r =>
Bool -> Maybe (SValue r) -> SValue r -> SValue r -> MSStatement r
jOut Bool
False (forall a. a -> Maybe a
Just SValue JavaCode
f) (forall (r :: * -> *). RenderValue r => SValue r -> SValue r
printFileFunc SValue JavaCode
f) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (r :: * -> *). Literal r => String -> SValue r
litString
printFileStrLn :: SValue JavaCode -> String -> MSStatement JavaCode
printFileStrLn SValue JavaCode
f = forall (r :: * -> *).
RenderSym r =>
Bool -> Maybe (SValue r) -> SValue r -> SValue r -> MSStatement r
jOut Bool
True (forall a. a -> Maybe a
Just SValue JavaCode
f) (forall (r :: * -> *). RenderValue r => SValue r -> SValue r
printFileLnFunc SValue JavaCode
f) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (r :: * -> *). Literal r => String -> SValue r
litString
getInput :: SVariable JavaCode -> MSStatement JavaCode
getInput SVariable JavaCode
v = SVariable JavaCode
v forall (r :: * -> *).
AssignStatement r =>
SVariable r -> SValue r -> MSStatement r
&= SVariable JavaCode -> SValue JavaCode -> SValue JavaCode
jInput SVariable JavaCode
v forall (r :: * -> *). RenderValue r => SValue r
inputFunc
discardInput :: MSStatement JavaCode
discardInput = SValue JavaCode -> MSStatement JavaCode
jDiscardInput forall (r :: * -> *). RenderValue r => SValue r
inputFunc
getFileInput :: SValue JavaCode -> SVariable JavaCode -> MSStatement JavaCode
getFileInput SValue JavaCode
f SVariable JavaCode
v = SVariable JavaCode
v forall (r :: * -> *).
AssignStatement r =>
SVariable r -> SValue r -> MSStatement r
&= SVariable JavaCode -> SValue JavaCode -> SValue JavaCode
jInput SVariable JavaCode
v SValue JavaCode
f
discardFileInput :: SValue JavaCode -> MSStatement JavaCode
discardFileInput = SValue JavaCode -> MSStatement JavaCode
jDiscardInput
openFileR :: SVariable JavaCode -> SValue JavaCode -> MSStatement JavaCode
openFileR = forall (r :: * -> *).
RenderSym r =>
(SValue r -> VSType r -> SValue r)
-> SVariable r -> SValue r -> MSStatement r
CP.openFileR forall (r :: * -> *).
RenderSym r =>
SValue r -> VSType r -> SValue r
jOpenFileR
openFileW :: SVariable JavaCode -> SValue JavaCode -> MSStatement JavaCode
openFileW = forall (r :: * -> *).
RenderSym r =>
(SValue r -> VSType r -> SValue r -> SValue r)
-> SVariable r -> SValue r -> MSStatement r
CP.openFileW forall (r :: * -> *).
RenderSym r =>
SValue r -> VSType r -> SValue r -> SValue r
jOpenFileWorA
openFileA :: SVariable JavaCode -> SValue JavaCode -> MSStatement JavaCode
openFileA = forall (r :: * -> *).
RenderSym r =>
(SValue r -> VSType r -> SValue r -> SValue r)
-> SVariable r -> SValue r -> MSStatement r
CP.openFileA forall (r :: * -> *).
RenderSym r =>
SValue r -> VSType r -> SValue r -> SValue r
jOpenFileWorA
closeFile :: SValue JavaCode -> MSStatement JavaCode
closeFile = forall (r :: * -> *).
RenderSym r =>
String -> SValue r -> MSStatement r
G.closeFile String
jClose
getFileInputLine :: SValue JavaCode -> SVariable JavaCode -> MSStatement JavaCode
getFileInputLine SValue JavaCode
f SVariable JavaCode
v = SVariable JavaCode
v forall (r :: * -> *).
AssignStatement r =>
SVariable r -> SValue r -> MSStatement r
&= SValue JavaCode
f forall (r :: * -> *).
FunctionSym r =>
SValue r -> VSFunction r -> SValue r
$. VSFunction JavaCode
jNextLineFunc
discardFileLine :: SValue JavaCode -> MSStatement JavaCode
discardFileLine = forall (r :: * -> *).
RenderSym r =>
String -> SValue r -> MSStatement r
CP.discardFileLine String
jNextLine
getFileInputAll :: SValue JavaCode -> SVariable JavaCode -> MSStatement JavaCode
getFileInputAll SValue JavaCode
f SVariable JavaCode
v = forall (r :: * -> *).
ControlStatement r =>
SValue r -> MSBody r -> MSStatement r
while (SValue JavaCode
f forall (r :: * -> *).
FunctionSym r =>
SValue r -> VSFunction r -> SValue r
$. VSFunction JavaCode
jHasNextLineFunc)
(forall (r :: * -> *). BodySym r => MSStatement r -> MSBody r
oneLiner forall a b. (a -> b) -> a -> b
$ forall (r :: * -> *). StatementSym r => SValue r -> MSStatement r
valStmt forall a b. (a -> b) -> a -> b
$ forall (r :: * -> *). List r => SValue r -> SValue r -> SValue r
listAppend (forall (r :: * -> *). VariableValue r => SVariable r -> SValue r
valueOf SVariable JavaCode
v) (SValue JavaCode
f forall (r :: * -> *).
FunctionSym r =>
SValue r -> VSFunction r -> SValue r
$. VSFunction JavaCode
jNextLineFunc))
instance StringStatement JavaCode where
stringSplit :: Char
-> SVariable JavaCode -> SValue JavaCode -> MSStatement JavaCode
stringSplit Char
d SVariable JavaCode
vnew SValue JavaCode
s = do
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (String -> MethodState -> MethodState
addLangImport forall a b. (a -> b) -> a -> b
$ String -> String
utilImport String
jArrays)
Doc
ss <- forall (m :: * -> *) (n :: * -> *) s t c.
Zoom m n s t =>
LensLike' (Zoomed m c) t s -> m c -> n c
zoom Lens' MethodState ValueState
lensMStoVS forall a b. (a -> b) -> a -> b
$
forall (r :: * -> *).
RenderSym r =>
SVariable r -> SValue r -> VS Doc
jStringSplit SVariable JavaCode
vnew (VSType JavaCode -> [SValue JavaCode] -> SValue JavaCode
jAsListFunc forall (r :: * -> *). TypeSym r => VSType r
string [SValue JavaCode
s forall (r :: * -> *).
FunctionSym r =>
SValue r -> VSFunction r -> SValue r
$. forall (r :: * -> *). RenderSym r => Char -> VSFunction r
jSplitFunc Char
d])
forall (r :: * -> *). RenderSym r => Doc -> MSStatement r
mkStmt Doc
ss
stringListVals :: [SVariable JavaCode] -> SValue JavaCode -> MSStatement JavaCode
stringListVals = forall (r :: * -> *).
RenderSym r =>
[SVariable r] -> SValue r -> MSStatement r
M.stringListVals
stringListLists :: [SVariable JavaCode] -> SValue JavaCode -> MSStatement JavaCode
stringListLists = forall (r :: * -> *).
RenderSym r =>
[SVariable r] -> SValue r -> MSStatement r
M.stringListLists
instance FuncAppStatement JavaCode where
inOutCall :: InOutCall JavaCode
inOutCall = (String -> VSType JavaCode -> [SValue JavaCode] -> SValue JavaCode)
-> InOutCall JavaCode
jInOutCall forall (r :: * -> *). ValueExpression r => PosCall r
funcApp
selfInOutCall :: InOutCall JavaCode
selfInOutCall = (String -> VSType JavaCode -> [SValue JavaCode] -> SValue JavaCode)
-> InOutCall JavaCode
jInOutCall forall (r :: * -> *). ValueExpression r => PosCall r
selfFuncApp
extInOutCall :: String -> InOutCall JavaCode
extInOutCall String
m = (String -> VSType JavaCode -> [SValue JavaCode] -> SValue JavaCode)
-> InOutCall JavaCode
jInOutCall (forall (r :: * -> *). ValueExpression r => String -> PosCall r
extFuncApp String
m)
instance CommentStatement JavaCode where
comment :: String -> MSStatement JavaCode
comment = forall (r :: * -> *). RenderSym r => Doc -> String -> MSStatement r
G.comment Doc
commentStart
instance ControlStatement JavaCode where
break :: MSStatement JavaCode
break = forall (r :: * -> *). RenderSym r => Doc -> MSStatement r
mkStmt Doc
R.break
continue :: MSStatement JavaCode
continue = forall (r :: * -> *). RenderSym r => Doc -> MSStatement r
mkStmt Doc
R.continue
returnStmt :: SValue JavaCode -> MSStatement JavaCode
returnStmt = forall (r :: * -> *).
RenderSym r =>
Terminator -> SValue r -> MSStatement r
G.returnStmt Terminator
Semi
throw :: String -> MSStatement JavaCode
throw = forall (r :: * -> *).
RenderSym r =>
(r (Value r) -> Doc) -> Terminator -> String -> MSStatement r
G.throw forall (r :: * -> *). RenderSym r => r (Value r) -> Doc
jThrowDoc Terminator
Semi
ifCond :: [(SValue JavaCode, MSBody JavaCode)]
-> MSBody JavaCode -> MSStatement JavaCode
ifCond = forall (r :: * -> *).
RenderSym r =>
(Doc -> Doc)
-> Doc
-> OptionalSpace
-> Doc
-> Doc
-> [(SValue r, MSBody r)]
-> MSBody r
-> MSStatement r
G.ifCond Doc -> Doc
parens Doc
bodyStart OptionalSpace
G.defaultOptSpace Doc
elseIfLabel Doc
bodyEnd
switch :: SValue JavaCode
-> [(SValue JavaCode, MSBody JavaCode)]
-> MSBody JavaCode
-> MSStatement JavaCode
switch = forall (r :: * -> *).
RenderSym r =>
(Doc -> Doc)
-> MSStatement r
-> SValue r
-> [(SValue r, MSBody r)]
-> MSBody r
-> MSStatement r
C.switch Doc -> Doc
parens forall (r :: * -> *). ControlStatement r => MSStatement r
break
ifExists :: SValue JavaCode
-> MSBody JavaCode -> MSBody JavaCode -> MSStatement JavaCode
ifExists = forall (r :: * -> *).
RenderSym r =>
SValue r -> MSBody r -> MSBody r -> MSStatement r
M.ifExists
for :: MSStatement JavaCode
-> SValue JavaCode
-> MSStatement JavaCode
-> MSBody JavaCode
-> MSStatement JavaCode
for = forall (r :: * -> *).
RenderSym r =>
Doc
-> Doc
-> MSStatement r
-> SValue r
-> MSStatement r
-> MSBody r
-> MSStatement r
C.for Doc
bodyStart Doc
bodyEnd
forRange :: SVariable JavaCode
-> SValue JavaCode
-> SValue JavaCode
-> SValue JavaCode
-> MSBody JavaCode
-> MSStatement JavaCode
forRange = forall (r :: * -> *).
RenderSym r =>
SVariable r
-> SValue r -> SValue r -> SValue r -> MSBody r -> MSStatement r
M.forRange
forEach :: SVariable JavaCode
-> SValue JavaCode -> MSBody JavaCode -> MSStatement JavaCode
forEach = forall (r :: * -> *).
RenderSym r =>
Doc
-> Doc
-> Doc
-> Doc
-> SVariable r
-> SValue r
-> MSBody r
-> MSStatement r
CP.forEach Doc
bodyStart Doc
bodyEnd Doc
forLabel Doc
colon
while :: SValue JavaCode -> MSBody JavaCode -> MSStatement JavaCode
while = forall (r :: * -> *).
RenderSym r =>
(Doc -> Doc) -> Doc -> Doc -> SValue r -> MSBody r -> MSStatement r
C.while Doc -> Doc
parens Doc
bodyStart Doc
bodyEnd
tryCatch :: MSBody JavaCode -> MSBody JavaCode -> MSStatement JavaCode
tryCatch = forall (r :: * -> *).
RenderSym r =>
(r (Body r) -> r (Body r) -> Doc)
-> MSBody r -> MSBody r -> MSStatement r
G.tryCatch forall (r :: * -> *).
RenderSym r =>
r (Body r) -> r (Body r) -> Doc
jTryCatch
instance StatePattern JavaCode where
checkState :: String
-> [(SValue JavaCode, MSBody JavaCode)]
-> MSBody JavaCode
-> MSStatement JavaCode
checkState = forall (r :: * -> *).
RenderSym r =>
String -> [(SValue r, MSBody r)] -> MSBody r -> MSStatement r
M.checkState
instance ObserverPattern JavaCode where
notifyObservers :: VSFunction JavaCode -> VSType JavaCode -> MSStatement JavaCode
notifyObservers = forall (r :: * -> *).
RenderSym r =>
VSFunction r -> VSType r -> MSStatement r
M.notifyObservers
instance StrategyPattern JavaCode where
runStrategy :: String
-> [(String, MSBody JavaCode)]
-> Maybe (SValue JavaCode)
-> Maybe (SVariable JavaCode)
-> MSBlock JavaCode
runStrategy = forall (r :: * -> *).
(RenderSym r, Monad r) =>
String
-> [(String, MSBody r)]
-> Maybe (SValue r)
-> Maybe (SVariable r)
-> MS (r Doc)
M.runStrategy
instance ScopeSym JavaCode where
type Scope JavaCode = Doc
private :: JavaCode (Scope JavaCode)
private = forall (r :: * -> *) a. Monad r => a -> r a
toCode Doc
R.private
public :: JavaCode (Scope JavaCode)
public = forall (r :: * -> *) a. Monad r => a -> r a
toCode Doc
R.public
instance RenderScope JavaCode where
scopeFromData :: ScopeTag -> Doc -> JavaCode (Scope JavaCode)
scopeFromData ScopeTag
_ = forall (r :: * -> *) a. Monad r => a -> r a
toCode
instance ScopeElim JavaCode where
scope :: JavaCode (Scope JavaCode) -> Doc
scope = forall a. JavaCode a -> a
unJC
instance MethodTypeSym JavaCode where
type MethodType JavaCode = TypeData
mType :: VSType JavaCode -> MSMthdType JavaCode
mType = forall (m :: * -> *) (n :: * -> *) s t c.
Zoom m n s t =>
LensLike' (Zoomed m c) t s -> m c -> n c
zoom Lens' MethodState ValueState
lensMStoVS
construct :: String -> MSMthdType JavaCode
construct = forall (r :: * -> *). RenderSym r => String -> MS (r (Type r))
G.construct
instance ParameterSym JavaCode where
type Parameter JavaCode = ParamData
param :: SVariable JavaCode -> MSParameter JavaCode
param = forall (r :: * -> *).
RenderSym r =>
(r (Variable r) -> Doc) -> SVariable r -> MSParameter r
G.param forall (r :: * -> *). RenderSym r => r (Variable r) -> Doc
R.param
pointerParam :: SVariable JavaCode -> MSParameter JavaCode
pointerParam = forall (r :: * -> *).
ParameterSym r =>
SVariable r -> MSParameter r
param
instance RenderParam JavaCode where
paramFromData :: SVariable JavaCode -> Doc -> MSParameter JavaCode
paramFromData SVariable JavaCode
v' Doc
d = do
JavaCode VarData
v <- forall (m :: * -> *) (n :: * -> *) s t c.
Zoom m n s t =>
LensLike' (Zoomed m c) t s -> m c -> n c
zoom Lens' MethodState ValueState
lensMStoVS SVariable JavaCode
v'
forall a s. a -> State s a
toState forall a b. (a -> b) -> a -> b
$ forall (r :: * -> *) a b c.
Applicative r =>
(a -> b -> c) -> r a -> r b -> r c
on2CodeValues VarData -> Doc -> ParamData
pd JavaCode VarData
v (forall (r :: * -> *) a. Monad r => a -> r a
toCode Doc
d)
instance ParamElim JavaCode where
parameterName :: JavaCode (Parameter JavaCode) -> String
parameterName = forall (r :: * -> *). VariableElim r => r (Variable r) -> String
variableName forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (r :: * -> *) a b. Functor r => (a -> b) -> r a -> r b
onCodeValue ParamData -> VarData
paramVar
parameterType :: JavaCode (Parameter JavaCode) -> JavaCode (Type JavaCode)
parameterType = forall (r :: * -> *).
VariableElim r =>
r (Variable r) -> r (Type r)
variableType forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (r :: * -> *) a b. Functor r => (a -> b) -> r a -> r b
onCodeValue ParamData -> VarData
paramVar
parameter :: JavaCode (Parameter JavaCode) -> Doc
parameter = ParamData -> Doc
paramDoc forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. JavaCode a -> a
unJC
instance MethodSym JavaCode where
type Method JavaCode = MethodData
method :: String
-> JavaCode (Scope JavaCode)
-> JavaCode (Permanence JavaCode)
-> VSType JavaCode
-> [MSParameter JavaCode]
-> MSBody JavaCode
-> SMethod JavaCode
method = forall (r :: * -> *).
RenderSym r =>
String
-> r (Scope r)
-> r (Permanence r)
-> VSType r
-> [MSParameter r]
-> MSBody r
-> SMethod r
G.method
getMethod :: SVariable JavaCode -> SMethod JavaCode
getMethod = forall (r :: * -> *). RenderSym r => SVariable r -> SMethod r
G.getMethod
setMethod :: SVariable JavaCode -> SMethod JavaCode
setMethod = forall (r :: * -> *). RenderSym r => SVariable r -> SMethod r
G.setMethod
constructor :: [MSParameter JavaCode]
-> NamedArgs JavaCode -> MSBody JavaCode -> SMethod JavaCode
constructor [MSParameter JavaCode]
ps NamedArgs JavaCode
is MSBody JavaCode
b = MS String
getClassName forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (\String
n -> forall (r :: * -> *).
RenderSym r =>
String
-> [MSParameter r] -> Initializers r -> MSBody r -> SMethod r
CP.constructor String
n [MSParameter JavaCode]
ps NamedArgs JavaCode
is MSBody JavaCode
b)
docMain :: MSBody JavaCode -> SMethod JavaCode
docMain = forall (r :: * -> *). RenderSym r => MSBody r -> SMethod r
CP.docMain
function :: String
-> JavaCode (Scope JavaCode)
-> VSType JavaCode
-> [MSParameter JavaCode]
-> MSBody JavaCode
-> SMethod JavaCode
function = forall (r :: * -> *).
RenderSym r =>
String
-> r (Scope r)
-> VSType r
-> [MSParameter r]
-> MSBody r
-> SMethod r
G.function
mainFunction :: MSBody JavaCode -> SMethod JavaCode
mainFunction = forall (r :: * -> *).
RenderSym r =>
VSType r -> String -> MSBody r -> SMethod r
CP.mainFunction forall (r :: * -> *). TypeSym r => VSType r
string String
mainFunc
docFunc :: String
-> [String] -> Maybe String -> SMethod JavaCode -> SMethod JavaCode
docFunc = forall (r :: * -> *).
RenderSym r =>
String -> [String] -> Maybe String -> SMethod r -> SMethod r
CP.doxFunc
inOutMethod :: String
-> JavaCode (Scope JavaCode)
-> JavaCode (Permanence JavaCode)
-> InOutFunc JavaCode
inOutMethod String
n JavaCode (Scope JavaCode)
s JavaCode (Permanence JavaCode)
p = (VSType JavaCode
-> [MSParameter JavaCode] -> MSBody JavaCode -> SMethod JavaCode)
-> InOutFunc JavaCode
jInOut (forall (r :: * -> *).
MethodSym r =>
String
-> r (Scope r)
-> r (Permanence r)
-> VSType r
-> [MSParameter r]
-> MSBody r
-> SMethod r
method String
n JavaCode (Scope JavaCode)
s JavaCode (Permanence JavaCode)
p)
docInOutMethod :: String
-> JavaCode (Scope JavaCode)
-> JavaCode (Permanence JavaCode)
-> DocInOutFunc JavaCode
docInOutMethod String
n JavaCode (Scope JavaCode)
s JavaCode (Permanence JavaCode)
p = forall (r :: * -> *).
RenderSym r =>
([SVariable r]
-> [SVariable r] -> [SVariable r] -> MSBody r -> SMethod r)
-> String
-> [(String, SVariable r)]
-> [(String, SVariable r)]
-> [(String, SVariable r)]
-> MSBody r
-> SMethod r
jDocInOut (forall (r :: * -> *).
MethodSym r =>
String -> r (Scope r) -> r (Permanence r) -> InOutFunc r
inOutMethod String
n JavaCode (Scope JavaCode)
s JavaCode (Permanence JavaCode)
p)
inOutFunc :: String -> JavaCode (Scope JavaCode) -> InOutFunc JavaCode
inOutFunc String
n JavaCode (Scope JavaCode)
s = (VSType JavaCode
-> [MSParameter JavaCode] -> MSBody JavaCode -> SMethod JavaCode)
-> InOutFunc JavaCode
jInOut (forall (r :: * -> *).
MethodSym r =>
String
-> r (Scope r)
-> VSType r
-> [MSParameter r]
-> MSBody r
-> SMethod r
function String
n JavaCode (Scope JavaCode)
s)
docInOutFunc :: String -> JavaCode (Scope JavaCode) -> DocInOutFunc JavaCode
docInOutFunc String
n JavaCode (Scope JavaCode)
s = forall (r :: * -> *).
RenderSym r =>
([SVariable r]
-> [SVariable r] -> [SVariable r] -> MSBody r -> SMethod r)
-> String
-> [(String, SVariable r)]
-> [(String, SVariable r)]
-> [(String, SVariable r)]
-> MSBody r
-> SMethod r
jDocInOut (forall (r :: * -> *).
MethodSym r =>
String -> r (Scope r) -> InOutFunc r
inOutFunc String
n JavaCode (Scope JavaCode)
s)
instance RenderMethod JavaCode where
intMethod :: Bool
-> String
-> JavaCode (Scope JavaCode)
-> JavaCode (Permanence JavaCode)
-> MSMthdType JavaCode
-> [MSParameter JavaCode]
-> MSBody JavaCode
-> SMethod JavaCode
intMethod Bool
m String
n JavaCode (Scope JavaCode)
s JavaCode (Permanence JavaCode)
p MSMthdType JavaCode
t [MSParameter JavaCode]
ps MSBody JavaCode
b = do
JavaCode TypeData
tp <- MSMthdType JavaCode
t
[JavaCode ParamData]
pms <- forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [MSParameter JavaCode]
ps
JavaCode Doc
bd <- MSBody JavaCode
b
Map QualifiedName [ExceptionType]
mem <- forall (m :: * -> *) (n :: * -> *) s t c.
Zoom m n s t =>
LensLike' (Zoomed m c) t s -> m c -> n c
zoom Lens' MethodState ValueState
lensMStoVS VS (Map QualifiedName [ExceptionType])
getMethodExcMap
[ExceptionType]
es <- MS [ExceptionType]
getExceptions
String
mn <- forall (m :: * -> *) (n :: * -> *) s t c.
Zoom m n s t =>
LensLike' (Zoomed m c) t s -> m c -> n c
zoom Lens' MethodState FileState
lensMStoFS FS String
getModuleName
let excs :: [Exception]
excs = forall a b. (a -> b) -> [a] -> [b]
map (forall a. JavaCode a -> a
unJC forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (r :: * -> *).
HasException r =>
ExceptionType -> r Exception
toConcreteExc) forall a b. (a -> b) -> a -> b
$ forall b a. b -> (a -> b) -> Maybe a -> b
maybe [ExceptionType]
es (forall a. Eq a => [a] -> [a]
nub forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall a. [a] -> [a] -> [a]
++ [ExceptionType]
es))
(forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup (String -> String -> QualifiedName
qualName String
mn String
n) Map QualifiedName [ExceptionType]
mem)
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify ((if Bool
m then MethodState -> MethodState
setCurrMain else forall a. a -> a
id) forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Exception] -> MethodState -> MethodState
addExceptionImports [Exception]
excs)
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall (r :: * -> *) a. Monad r => a -> r a
toCode forall a b. (a -> b) -> a -> b
$ Doc -> MethodData
mthd forall a b. (a -> b) -> a -> b
$ forall (r :: * -> *).
RenderSym r =>
String
-> [String]
-> r (Scope r)
-> r (Permanence r)
-> r (Type r)
-> [r (Parameter r)]
-> r (Body r)
-> Doc
jMethod String
n (forall a b. (a -> b) -> [a] -> [b]
map Exception -> String
exc [Exception]
excs) JavaCode (Scope JavaCode)
s JavaCode (Permanence JavaCode)
p JavaCode TypeData
tp [JavaCode ParamData]
pms JavaCode Doc
bd
intFunc :: Bool
-> String
-> JavaCode (Scope JavaCode)
-> JavaCode (Permanence JavaCode)
-> MSMthdType JavaCode
-> [MSParameter JavaCode]
-> MSBody JavaCode
-> SMethod JavaCode
intFunc = forall (r :: * -> *).
RenderSym r =>
Bool
-> String
-> r (Scope r)
-> r (Permanence r)
-> MSMthdType r
-> [MSParameter r]
-> MSBody r
-> SMethod r
C.intFunc
commentedFunc :: MS (JavaCode (BlockComment JavaCode))
-> SMethod JavaCode -> SMethod JavaCode
commentedFunc MS (JavaCode (BlockComment JavaCode))
cmt SMethod JavaCode
m = forall a b c s.
(a -> b -> c) -> State s a -> State s b -> State s c
on2StateValues (forall (r :: * -> *) a b c.
Applicative r =>
(a -> b -> c) -> r a -> r b -> r c
on2CodeValues MethodData -> (Doc -> Doc) -> MethodData
updateMthd) SMethod JavaCode
m
(forall a b s. (a -> b) -> State s a -> State s b
onStateValue (forall (r :: * -> *) a b. Functor r => (a -> b) -> r a -> r b
onCodeValue Doc -> Doc -> Doc
R.commentedItem) MS (JavaCode (BlockComment JavaCode))
cmt)
destructor :: [CSStateVar JavaCode] -> SMethod JavaCode
destructor [CSStateVar JavaCode]
_ = forall a. HasCallStack => String -> a
error forall a b. (a -> b) -> a -> b
$ String -> String
CP.destructorError String
jName
mthdFromData :: ScopeTag -> Doc -> SMethod JavaCode
mthdFromData ScopeTag
_ Doc
d = forall a s. a -> State s a
toState forall a b. (a -> b) -> a -> b
$ forall (r :: * -> *) a. Monad r => a -> r a
toCode forall a b. (a -> b) -> a -> b
$ Doc -> MethodData
mthd Doc
d
instance MethodElim JavaCode where
method :: JavaCode (Method JavaCode) -> Doc
method = MethodData -> Doc
mthdDoc forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. JavaCode a -> a
unJC
instance StateVarSym JavaCode where
type StateVar JavaCode = Doc
stateVar :: JavaCode (Scope JavaCode)
-> JavaCode (Permanence JavaCode)
-> SVariable JavaCode
-> CSStateVar JavaCode
stateVar = forall (r :: * -> *).
(RenderSym r, Monad r) =>
r (Scope r) -> r (Permanence r) -> SVariable r -> CS (r Doc)
CP.stateVar
stateVarDef :: JavaCode (Scope JavaCode)
-> JavaCode (Permanence JavaCode)
-> SVariable JavaCode
-> SValue JavaCode
-> CSStateVar JavaCode
stateVarDef = forall (r :: * -> *).
(RenderSym r, Monad r) =>
r (Scope r)
-> r (Permanence r) -> SVariable r -> SValue r -> CS (r Doc)
CP.stateVarDef
constVar :: JavaCode (Scope JavaCode)
-> SVariable JavaCode -> SValue JavaCode -> CSStateVar JavaCode
constVar = forall (r :: * -> *).
(RenderSym r, Monad r) =>
Doc -> r (Scope r) -> SVariable r -> SValue r -> CS (r Doc)
CP.constVar (forall (r :: * -> *). PermElim r => r (Permanence r) -> Doc
RC.perm (forall (r :: * -> *). PermanenceSym r => r (Permanence r)
static :: JavaCode (Permanence JavaCode)))
instance StateVarElim JavaCode where
stateVar :: JavaCode (StateVar JavaCode) -> Doc
stateVar = forall a. JavaCode a -> a
unJC
instance ClassSym JavaCode where
type Class JavaCode = Doc
buildClass :: Maybe String
-> [CSStateVar JavaCode] -> [SMethod JavaCode] -> SClass JavaCode
buildClass = forall (r :: * -> *).
RenderSym r =>
Maybe String -> [CSStateVar r] -> [SMethod r] -> SClass r
G.buildClass
extraClass :: String
-> Maybe String
-> [CSStateVar JavaCode]
-> [SMethod JavaCode]
-> SClass JavaCode
extraClass = forall (r :: * -> *).
RenderSym r =>
String -> Maybe String -> [CSStateVar r] -> [SMethod r] -> SClass r
jExtraClass
implementingClass :: String
-> [String]
-> [CSStateVar JavaCode]
-> [SMethod JavaCode]
-> SClass JavaCode
implementingClass = forall (r :: * -> *).
RenderSym r =>
String -> [String] -> [CSStateVar r] -> [SMethod r] -> SClass r
G.implementingClass
docClass :: String -> SClass JavaCode -> SClass JavaCode
docClass = forall (r :: * -> *). RenderSym r => String -> SClass r -> SClass r
CP.doxClass
instance RenderClass JavaCode where
intClass :: String
-> JavaCode (Scope JavaCode)
-> JavaCode Doc
-> [CSStateVar JavaCode]
-> [SMethod JavaCode]
-> SClass JavaCode
intClass = forall (r :: * -> *).
(RenderSym r, Monad r) =>
(String -> Doc -> Doc -> Doc -> Doc -> Doc)
-> String
-> r (Scope r)
-> r Doc
-> [CSStateVar r]
-> [SMethod r]
-> CS (r Doc)
CP.intClass String -> Doc -> Doc -> Doc -> Doc -> Doc
R.class'
inherit :: Maybe String -> JavaCode Doc
inherit Maybe String
n = forall (r :: * -> *) a. Monad r => a -> r a
toCode forall a b. (a -> b) -> a -> b
$ forall b a. b -> (a -> b) -> Maybe a -> b
maybe Doc
empty ((Doc
jExtends <+>) forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Doc
text) Maybe String
n
implements :: [String] -> JavaCode Doc
implements [String]
is = forall (r :: * -> *) a. Monad r => a -> r a
toCode forall a b. (a -> b) -> a -> b
$ Doc
jImplements Doc -> Doc -> Doc
<+> String -> Doc
text (forall a. [a] -> [[a]] -> [a]
intercalate String
listSep [String]
is)
commentedClass :: CS (JavaCode (BlockComment JavaCode))
-> SClass JavaCode -> SClass JavaCode
commentedClass = forall (r :: * -> *).
(RenderSym r, Monad r) =>
CS (r (BlockComment r)) -> SClass r -> CS (r Doc)
G.commentedClass
instance ClassElim JavaCode where
class' :: JavaCode (Class JavaCode) -> Doc
class' = forall a. JavaCode a -> a
unJC
instance ModuleSym JavaCode where
type Module JavaCode = ModData
buildModule :: String
-> [String]
-> [SMethod JavaCode]
-> [SClass JavaCode]
-> FSModule JavaCode
buildModule String
n = forall (r :: * -> *).
RenderSym r =>
String
-> (String -> r (Import r))
-> [String]
-> [SMethod r]
-> [SClass r]
-> FSModule r
CP.buildModule' String
n forall (r :: * -> *). ImportSym r => String -> r (Import r)
langImport
instance RenderMod JavaCode where
modFromData :: String -> FS Doc -> FSModule JavaCode
modFromData String
n = forall (r :: * -> *).
String -> (Doc -> r (Module r)) -> FS Doc -> FSModule r
G.modFromData String
n (forall (r :: * -> *) a. Monad r => a -> r a
toCode forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Doc -> ModData
md String
n)
updateModuleDoc :: (Doc -> Doc)
-> JavaCode (Module JavaCode) -> JavaCode (Module JavaCode)
updateModuleDoc Doc -> Doc
f = forall (r :: * -> *) a b. Functor r => (a -> b) -> r a -> r b
onCodeValue ((Doc -> Doc) -> ModData -> ModData
updateMod Doc -> Doc
f)
instance ModuleElim JavaCode where
module' :: JavaCode (Module JavaCode) -> Doc
module' = ModData -> Doc
modDoc forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. JavaCode a -> a
unJC
instance BlockCommentSym JavaCode where
type JavaCode = Doc
blockComment :: [String] -> JavaCode (BlockComment JavaCode)
blockComment [String]
lns = forall (r :: * -> *) a. Monad r => a -> r a
toCode forall a b. (a -> b) -> a -> b
$ [String] -> Doc -> Doc -> Doc
R.blockCmt [String]
lns Doc
blockCmtStart Doc
blockCmtEnd
docComment :: forall a.
State a [String] -> State a (JavaCode (BlockComment JavaCode))
docComment = forall a b s. (a -> b) -> State s a -> State s b
onStateValue (\[String]
lns -> forall (r :: * -> *) a. Monad r => a -> r a
toCode forall a b. (a -> b) -> a -> b
$ [String] -> Doc -> Doc -> Doc
R.docCmt [String]
lns Doc
docCmtStart
Doc
blockCmtEnd)
instance BlockCommentElim JavaCode where
blockComment' :: JavaCode (BlockComment JavaCode) -> Doc
blockComment' = forall a. JavaCode a -> a
unJC
instance HasException JavaCode where
toConcreteExc :: ExceptionType -> JavaCode Exception
toConcreteExc ExceptionType
Standard = forall (r :: * -> *) a. Monad r => a -> r a
toCode forall a b. (a -> b) -> a -> b
$ String -> Exception
stdExc String
exceptionObj
toConcreteExc ExceptionType
FileNotFound = forall (r :: * -> *) a. Monad r => a -> r a
toCode forall a b. (a -> b) -> a -> b
$ String -> String -> Exception
exception (String -> String
javaImport String
io) String
jFNFExc
toConcreteExc ExceptionType
IO = forall (r :: * -> *) a. Monad r => a -> r a
toCode forall a b. (a -> b) -> a -> b
$ String -> String -> Exception
exception (String -> String
javaImport String
io) String
jIOExc
jName, jVersion :: String
jName :: String
jName = String
"Java"
jVersion :: String
jVersion = String
"14"
jImport :: Label -> Doc
jImport :: String -> Doc
jImport String
n = Doc
importLabel Doc -> Doc -> Doc
<+> String -> Doc
text String
n Doc -> Doc -> Doc
<> Doc
endStatement
jBoolType :: (RenderSym r) => VSType r
jBoolType :: forall (r :: * -> *). RenderSym r => VSType r
jBoolType = forall (r :: * -> *).
RenderType r =>
CodeType -> String -> Doc -> VSType r
typeFromData CodeType
Boolean String
jBool (String -> Doc
text String
jBool)
jInfileType :: (RenderSym r) => VSType r
jInfileType :: forall (r :: * -> *). RenderSym r => VSType r
jInfileType = do
r (Type r)
tpf <- forall (r :: * -> *).
RenderType r =>
CodeType -> String -> Doc -> VSType r
typeFromData CodeType
InFile String
jScanner Doc
jScanner'
forall s a. (s -> s) -> a -> State s a
modifyReturn (String -> ValueState -> ValueState
addLangImportVS forall a b. (a -> b) -> a -> b
$ String -> String
utilImport String
jScanner) r (Type r)
tpf
jOutfileType :: (RenderSym r) => VSType r
jOutfileType :: forall (r :: * -> *). RenderSym r => VSType r
jOutfileType = do
r (Type r)
tpf <- forall (r :: * -> *).
RenderType r =>
CodeType -> String -> Doc -> VSType r
typeFromData CodeType
OutFile String
jPrintWriter (String -> Doc
text String
jPrintWriter)
forall s a. (s -> s) -> a -> State s a
modifyReturn (String -> ValueState -> ValueState
addLangImportVS forall a b. (a -> b) -> a -> b
$ String -> String
ioImport String
jPrintWriter) r (Type r)
tpf
jExtends, jImplements, jFinal, jScanner', jLambdaSep :: Doc
jExtends :: Doc
jExtends = String -> Doc
text String
"extends"
jImplements :: Doc
jImplements = String -> Doc
text String
"implements"
jFinal :: Doc
jFinal = String -> Doc
text String
"final"
jScanner' :: Doc
jScanner' = String -> Doc
text String
jScanner
jLambdaSep :: Doc
jLambdaSep = String -> Doc
text String
"->"
arrayList, jBool, jBool', jInteger, jObject, jScanner,
jPrintWriter, jFile, jFileWriter, jIOExc, jFNFExc, jArrays, jAsList, jStdIn,
jStdOut, jPrintLn, jEquals, jParseInt, jParseDbl, jParseFloat, jIndex,
jListAdd, jListAccess, jListSet, jClose, jNext, jNextLine, jNextBool,
jHasNextLine, jCharAt, jSplit, io, util :: String
arrayList :: String
arrayList = String
"ArrayList"
jBool :: String
jBool = String
"boolean"
jBool' :: String
jBool' = String
"Boolean"
jInteger :: String
jInteger = String
"Integer"
jObject :: String
jObject = String
"Object"
jScanner :: String
jScanner = String
"Scanner"
jPrintWriter :: String
jPrintWriter = String
"PrintWriter"
jFile :: String
jFile = String
"File"
jFileWriter :: String
jFileWriter = String
"FileWriter"
jIOExc :: String
jIOExc = String
"IOException"
jFNFExc :: String
jFNFExc = String
"FileNotFoundException"
jArrays :: String
jArrays = String
"Arrays"
jAsList :: String
jAsList = String
jArrays String -> String -> String
`access` String
"asList"
jStdIn :: String
jStdIn = String
"in"
jStdOut :: String
jStdOut = String
"out"
jPrintLn :: String
jPrintLn = String
"println"
jEquals :: String
jEquals = String
"equals"
jParseInt :: String
jParseInt = String
jInteger String -> String -> String
`access` String
"parseInt"
jParseDbl :: String
jParseDbl = String
CP.doubleRender String -> String -> String
`access` String
"parseDouble"
jParseFloat :: String
jParseFloat = String
CP.floatRender String -> String -> String
`access` String
"parseFloat"
jIndex :: String
jIndex = String
"indexOf"
jListAdd :: String
jListAdd = String
"add"
jListAccess :: String
jListAccess = String
"get"
jListSet :: String
jListSet = String
"set"
jClose :: String
jClose = String
"close"
jNext :: String
jNext = String
"next"
jNextLine :: String
jNextLine = String
"nextLine"
jNextBool :: String
jNextBool = String
"nextBoolean"
jHasNextLine :: String
jHasNextLine = String
"hasNextLine"
jCharAt :: String
jCharAt = String
"charAt"
jSplit :: String
jSplit = String
"split"
io :: String
io = String
"io"
util :: String
util = String
"util"
javaImport, ioImport, utilImport :: String -> String
javaImport :: String -> String
javaImport = String -> String -> String
access String
"java"
ioImport :: String -> String
ioImport = String -> String
javaImport forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> String -> String
access String
io
utilImport :: String -> String
utilImport = String -> String
javaImport forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> String -> String
access String
util
jSystem :: String -> Doc
jSystem :: String -> Doc
jSystem = String -> Doc
text forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> String -> String
access String
"System"
jUnaryMath :: (Monad r) => String -> VSOp r
jUnaryMath :: forall (r :: * -> *). Monad r => String -> VSOp r
jUnaryMath = forall (r :: * -> *). Monad r => String -> VSOp r
unOpPrec forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> String
mathFunc
jListType :: (RenderSym r) => VSType r -> VSType r
jListType :: forall (r :: * -> *). RenderSym r => VSType r -> VSType r
jListType VSType r
t = do
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (String -> ValueState -> ValueState
addLangImportVS forall a b. (a -> b) -> a -> b
$ String -> String
utilImport String
arrayList)
VSType r
t forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (CodeType -> VSType r
jListType' forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (r :: * -> *). TypeElim r => r (Type r) -> CodeType
getType)
where jListType' :: CodeType -> VSType r
jListType' CodeType
Integer = forall (r :: * -> *).
RenderType r =>
CodeType -> String -> Doc -> VSType r
typeFromData (CodeType -> CodeType
List CodeType
Integer)
String
lstInt (String -> Doc
text String
lstInt)
jListType' CodeType
Float = forall (r :: * -> *). RenderSym r => String -> VSType r -> VSType r
C.listType String
arrayList forall (r :: * -> *). RenderSym r => VSType r
CP.float
jListType' CodeType
Double = forall (r :: * -> *). RenderSym r => String -> VSType r -> VSType r
C.listType String
arrayList forall (r :: * -> *). RenderSym r => VSType r
CP.double
jListType' CodeType
Boolean = forall (r :: * -> *).
RenderType r =>
CodeType -> String -> Doc -> VSType r
typeFromData (CodeType -> CodeType
List CodeType
Boolean) String
lstBool (String -> Doc
text String
lstBool)
jListType' CodeType
_ = forall (r :: * -> *). RenderSym r => String -> VSType r -> VSType r
C.listType String
arrayList VSType r
t
lstInt :: String
lstInt = String
arrayList String -> String -> String
`containing` String
jInteger
lstBool :: String
lstBool = String
arrayList String -> String -> String
`containing` String
jBool'
jArrayType :: VSType JavaCode
jArrayType :: VSType JavaCode
jArrayType = forall (r :: * -> *). TypeSym r => VSType r -> VSType r
arrayType (forall (r :: * -> *). TypeSym r => String -> VSType r
obj String
jObject)
jFileType :: (RenderSym r) => VSType r
jFileType :: forall (r :: * -> *). RenderSym r => VSType r
jFileType = do
r (Type r)
tpf <- forall (r :: * -> *). TypeSym r => String -> VSType r
obj String
jFile
forall s a. (s -> s) -> a -> State s a
modifyReturn (String -> ValueState -> ValueState
addLangImportVS forall a b. (a -> b) -> a -> b
$ String -> String
ioImport String
jFile) r (Type r)
tpf
jFileWriterType :: (RenderSym r) => VSType r
jFileWriterType :: forall (r :: * -> *). RenderSym r => VSType r
jFileWriterType = do
r (Type r)
tpf <- forall (r :: * -> *). TypeSym r => String -> VSType r
obj String
jFileWriter
forall s a. (s -> s) -> a -> State s a
modifyReturn (String -> ValueState -> ValueState
addLangImportVS forall a b. (a -> b) -> a -> b
$ String -> String
ioImport String
jFileWriter) r (Type r)
tpf
jAsListFunc :: VSType JavaCode -> [SValue JavaCode] -> SValue JavaCode
jAsListFunc :: VSType JavaCode -> [SValue JavaCode] -> SValue JavaCode
jAsListFunc VSType JavaCode
t = forall (r :: * -> *). ValueExpression r => PosCall r
funcApp String
jAsList (forall (r :: * -> *). TypeSym r => VSType r -> VSType r
listType VSType JavaCode
t)
jEqualsFunc :: SValue JavaCode -> VSFunction JavaCode
jEqualsFunc :: SValue JavaCode -> VSFunction JavaCode
jEqualsFunc SValue JavaCode
v = forall (r :: * -> *).
FunctionSym r =>
String -> VSType r -> [SValue r] -> VSFunction r
func String
jEquals forall (r :: * -> *). TypeSym r => VSType r
bool [SValue JavaCode
v]
jParseIntFunc :: SValue JavaCode -> SValue JavaCode
jParseIntFunc :: SValue JavaCode -> SValue JavaCode
jParseIntFunc SValue JavaCode
v = forall (r :: * -> *). ValueExpression r => PosCall r
funcApp String
jParseInt forall (r :: * -> *). TypeSym r => VSType r
int [SValue JavaCode
v]
jParseDblFunc :: SValue JavaCode -> SValue JavaCode
jParseDblFunc :: SValue JavaCode -> SValue JavaCode
jParseDblFunc SValue JavaCode
v = forall (r :: * -> *). ValueExpression r => PosCall r
funcApp String
jParseDbl forall (r :: * -> *). TypeSym r => VSType r
double [SValue JavaCode
v]
jParseFloatFunc :: SValue JavaCode -> SValue JavaCode
jParseFloatFunc :: SValue JavaCode -> SValue JavaCode
jParseFloatFunc SValue JavaCode
v = forall (r :: * -> *). ValueExpression r => PosCall r
funcApp String
jParseFloat forall (r :: * -> *). TypeSym r => VSType r
float [SValue JavaCode
v]
jListSetFunc :: SValue JavaCode -> SValue JavaCode -> SValue JavaCode ->
VSFunction JavaCode
jListSetFunc :: SValue JavaCode
-> SValue JavaCode -> SValue JavaCode -> VSFunction JavaCode
jListSetFunc SValue JavaCode
v SValue JavaCode
i SValue JavaCode
toVal = forall (r :: * -> *).
FunctionSym r =>
String -> VSType r -> [SValue r] -> VSFunction r
func String
jListSet (forall a b s. (a -> b) -> State s a -> State s b
onStateValue forall (r :: * -> *). ValueSym r => r (Value r) -> r (Type r)
valueType SValue JavaCode
v) [forall (r :: * -> *). RenderSym r => SValue r -> SValue r
intValue SValue JavaCode
i, SValue JavaCode
toVal]
jNextFunc :: VSFunction JavaCode
jNextFunc :: VSFunction JavaCode
jNextFunc = forall (r :: * -> *).
FunctionSym r =>
String -> VSType r -> [SValue r] -> VSFunction r
func String
jNext forall (r :: * -> *). TypeSym r => VSType r
string []
jNextLineFunc :: VSFunction JavaCode
jNextLineFunc :: VSFunction JavaCode
jNextLineFunc = forall (r :: * -> *).
FunctionSym r =>
String -> VSType r -> [SValue r] -> VSFunction r
func String
jNextLine forall (r :: * -> *). TypeSym r => VSType r
string []
jNextBoolFunc :: VSFunction JavaCode
jNextBoolFunc :: VSFunction JavaCode
jNextBoolFunc = forall (r :: * -> *).
FunctionSym r =>
String -> VSType r -> [SValue r] -> VSFunction r
func String
jNextBool forall (r :: * -> *). TypeSym r => VSType r
bool []
jHasNextLineFunc :: VSFunction JavaCode
jHasNextLineFunc :: VSFunction JavaCode
jHasNextLineFunc = forall (r :: * -> *).
FunctionSym r =>
String -> VSType r -> [SValue r] -> VSFunction r
func String
jHasNextLine forall (r :: * -> *). TypeSym r => VSType r
bool []
jCharAtFunc :: VSFunction JavaCode
jCharAtFunc :: VSFunction JavaCode
jCharAtFunc = forall (r :: * -> *).
FunctionSym r =>
String -> VSType r -> [SValue r] -> VSFunction r
func String
jCharAt forall (r :: * -> *). TypeSym r => VSType r
char [forall (r :: * -> *). Literal r => Integer -> SValue r
litInt Integer
0]
jSplitFunc :: (RenderSym r) => Char -> VSFunction r
jSplitFunc :: forall (r :: * -> *). RenderSym r => Char -> VSFunction r
jSplitFunc Char
d = forall (r :: * -> *).
FunctionSym r =>
String -> VSType r -> [SValue r] -> VSFunction r
func String
jSplit (forall (r :: * -> *). TypeSym r => VSType r -> VSType r
listType forall (r :: * -> *). TypeSym r => VSType r
string) [forall (r :: * -> *). Literal r => String -> SValue r
litString [Char
d]]
jEquality :: SValue JavaCode -> SValue JavaCode -> SValue JavaCode
jEquality :: SValue JavaCode -> SValue JavaCode -> SValue JavaCode
jEquality SValue JavaCode
v1 SValue JavaCode
v2 = SValue JavaCode
v2 forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= CodeType -> SValue JavaCode
jEquality' forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (r :: * -> *). TypeElim r => r (Type r) -> CodeType
getType forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (r :: * -> *). ValueSym r => r (Value r) -> r (Type r)
valueType
where jEquality' :: CodeType -> SValue JavaCode
jEquality' CodeType
String = forall (r :: * -> *).
FunctionSym r =>
SValue r -> VSFunction r -> SValue r
objAccess SValue JavaCode
v1 (SValue JavaCode -> VSFunction JavaCode
jEqualsFunc SValue JavaCode
v2)
jEquality' CodeType
_ = forall (r :: * -> *).
RenderSym r =>
VSBinOp r -> VSType r -> SValue r -> SValue r -> SValue r
typeBinExpr forall (r :: * -> *). BinaryOpSym r => VSBinOp r
equalOp forall (r :: * -> *). TypeSym r => VSType r
bool SValue JavaCode
v1 SValue JavaCode
v2
jLambda :: (RenderSym r) => [r (Variable r)] -> r (Value r) -> Doc
jLambda :: forall (r :: * -> *).
RenderSym r =>
[r (Variable r)] -> r (Value r) -> Doc
jLambda [r (Variable r)]
ps r (Value r)
ex = Doc -> Doc
parens (forall (r :: * -> *). RenderSym r => [r (Variable r)] -> Doc
variableList [r (Variable r)]
ps) Doc -> Doc -> Doc
<+> Doc
jLambdaSep Doc -> Doc -> Doc
<+> forall (r :: * -> *). ValueElim r => r (Value r) -> Doc
RC.value r (Value r)
ex
jCast :: VSType JavaCode -> SValue JavaCode -> SValue JavaCode
jCast :: VSType JavaCode -> SValue JavaCode -> SValue JavaCode
jCast = forall (m :: * -> *) a. Monad m => m (m a) -> m a
join forall c d a b. (c -> d) -> (a -> b -> c) -> a -> b -> d
.: forall a b c s.
(a -> b -> c) -> State s a -> State s b -> State s c
on2StateValues (\JavaCode TypeData
t JavaCode ValData
v -> CodeType
-> CodeType
-> JavaCode TypeData
-> JavaCode ValData
-> StateT ValueState Identity (JavaCode ValData)
jCast' (forall (r :: * -> *). TypeElim r => r (Type r) -> CodeType
getType JavaCode TypeData
t) (forall (r :: * -> *). TypeElim r => r (Type r) -> CodeType
getType forall a b. (a -> b) -> a -> b
$ forall (r :: * -> *). ValueSym r => r (Value r) -> r (Type r)
valueType
JavaCode ValData
v) JavaCode TypeData
t JavaCode ValData
v)
where jCast' :: CodeType
-> CodeType
-> JavaCode TypeData
-> JavaCode ValData
-> SValue JavaCode
jCast' CodeType
Double CodeType
String JavaCode TypeData
_ JavaCode ValData
v = SValue JavaCode -> SValue JavaCode
jParseDblFunc (forall a s. a -> State s a
toState JavaCode ValData
v)
jCast' CodeType
Float CodeType
String JavaCode TypeData
_ JavaCode ValData
v = SValue JavaCode -> SValue JavaCode
jParseFloatFunc (forall a s. a -> State s a
toState JavaCode ValData
v)
jCast' CodeType
_ CodeType
_ JavaCode TypeData
t JavaCode ValData
v = forall (r :: * -> *). RenderSym r => VSType r -> Doc -> SValue r
mkStateVal (forall a s. a -> State s a
toState JavaCode TypeData
t) (Doc -> Doc -> Doc
R.castObj (Doc -> Doc
R.cast (forall (r :: * -> *). InternalTypeElim r => r (Type r) -> Doc
RC.type' JavaCode TypeData
t))
(forall (r :: * -> *). ValueElim r => r (Value r) -> Doc
RC.value JavaCode ValData
v))
jConstDecDef :: (RenderSym r) => SVariable r -> SValue r -> MSStatement r
jConstDecDef :: forall (r :: * -> *).
RenderSym r =>
SVariable r -> SValue r -> MSStatement r
jConstDecDef SVariable r
v' SValue r
def' = do
r (Variable r)
v <- forall (m :: * -> *) (n :: * -> *) s t c.
Zoom m n s t =>
LensLike' (Zoomed m c) t s -> m c -> n c
zoom Lens' MethodState ValueState
lensMStoVS SVariable r
v'
r (Value r)
def <- forall (m :: * -> *) (n :: * -> *) s t c.
Zoom m n s t =>
LensLike' (Zoomed m c) t s -> m c -> n c
zoom Lens' MethodState ValueState
lensMStoVS SValue r
def'
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify forall a b. (a -> b) -> a -> b
$ String -> MethodState -> MethodState
useVarName forall a b. (a -> b) -> a -> b
$ forall (r :: * -> *). VariableElim r => r (Variable r) -> String
variableName r (Variable r)
v
forall (r :: * -> *). RenderSym r => Doc -> MSStatement r
mkStmt forall a b. (a -> b) -> a -> b
$ Doc
jFinal Doc -> Doc -> Doc
<+> forall (r :: * -> *). InternalTypeElim r => r (Type r) -> Doc
RC.type' (forall (r :: * -> *).
VariableElim r =>
r (Variable r) -> r (Type r)
variableType r (Variable r)
v) Doc -> Doc -> Doc
<+>
forall (r :: * -> *). InternalVarElim r => r (Variable r) -> Doc
RC.variable r (Variable r)
v Doc -> Doc -> Doc
<+> Doc
equals Doc -> Doc -> Doc
<+> forall (r :: * -> *). ValueElim r => r (Value r) -> Doc
RC.value r (Value r)
def
jFuncDecDef :: (RenderSym r) => SVariable r -> [SVariable r] -> MSBody r ->
MSStatement r
jFuncDecDef :: forall (r :: * -> *).
RenderSym r =>
SVariable r -> [SVariable r] -> MSBody r -> MSStatement r
jFuncDecDef SVariable r
v [SVariable r]
ps MSBody r
bod = do
r (Variable r)
vr <- forall (m :: * -> *) (n :: * -> *) s t c.
Zoom m n s t =>
LensLike' (Zoomed m c) t s -> m c -> n c
zoom Lens' MethodState ValueState
lensMStoVS SVariable r
v
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify forall a b. (a -> b) -> a -> b
$ String -> MethodState -> MethodState
useVarName forall a b. (a -> b) -> a -> b
$ forall (r :: * -> *). VariableElim r => r (Variable r) -> String
variableName r (Variable r)
vr
[r (Variable r)]
pms <- forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (forall (m :: * -> *) (n :: * -> *) s t c.
Zoom m n s t =>
LensLike' (Zoomed m c) t s -> m c -> n c
zoom Lens' MethodState ValueState
lensMStoVS) [SVariable r]
ps
r (Body r)
b <- MSBody r
bod
forall (r :: * -> *). RenderSym r => Doc -> MSStatement r
mkStmt forall a b. (a -> b) -> a -> b
$ forall (r :: * -> *). InternalTypeElim r => r (Type r) -> Doc
RC.type' (forall (r :: * -> *).
VariableElim r =>
r (Variable r) -> r (Type r)
variableType r (Variable r)
vr) Doc -> Doc -> Doc
<+> forall (r :: * -> *). InternalVarElim r => r (Variable r) -> Doc
RC.variable r (Variable r)
vr Doc -> Doc -> Doc
<+> Doc
equals Doc -> Doc -> Doc
<+>
Doc -> Doc
parens (forall (r :: * -> *). RenderSym r => [r (Variable r)] -> Doc
variableList [r (Variable r)]
pms) Doc -> Doc -> Doc
<+> Doc
jLambdaSep Doc -> Doc -> Doc
<+> Doc
bodyStart Doc -> Doc -> Doc
$$ Doc -> Doc
indent (forall (r :: * -> *). BodyElim r => r (Body r) -> Doc
RC.body r (Body r)
b)
Doc -> Doc -> Doc
$$ Doc
bodyEnd
jThrowDoc :: (RenderSym r) => r (Value r) -> Doc
jThrowDoc :: forall (r :: * -> *). RenderSym r => r (Value r) -> Doc
jThrowDoc r (Value r)
errMsg = Doc
throwLabel Doc -> Doc -> Doc
<+> Doc
new' Doc -> Doc -> Doc
<+> Doc
exceptionObj' Doc -> Doc -> Doc
<>
Doc -> Doc
parens (forall (r :: * -> *). ValueElim r => r (Value r) -> Doc
RC.value r (Value r)
errMsg)
jTryCatch :: (RenderSym r) => r (Body r) -> r (Body r) -> Doc
jTryCatch :: forall (r :: * -> *).
RenderSym r =>
r (Body r) -> r (Body r) -> Doc
jTryCatch r (Body r)
tb r (Body r)
cb = [Doc] -> Doc
vcat [
Doc
tryLabel Doc -> Doc -> Doc
<+> Doc
lbrace,
Doc -> Doc
indent forall a b. (a -> b) -> a -> b
$ forall (r :: * -> *). BodyElim r => r (Body r) -> Doc
RC.body r (Body r)
tb,
Doc
rbrace Doc -> Doc -> Doc
<+> Doc
catchLabel Doc -> Doc -> Doc
<+> Doc -> Doc
parens (Doc
exceptionObj' Doc -> Doc -> Doc
<+> String -> Doc
text String
"exc") Doc -> Doc -> Doc
<+>
Doc
lbrace,
Doc -> Doc
indent forall a b. (a -> b) -> a -> b
$ forall (r :: * -> *). BodyElim r => r (Body r) -> Doc
RC.body r (Body r)
cb,
Doc
rbrace]
jOut :: (RenderSym r) => Bool -> Maybe (SValue r) -> SValue r -> SValue r ->
MSStatement r
jOut :: forall (r :: * -> *).
RenderSym r =>
Bool -> Maybe (SValue r) -> SValue r -> SValue r -> MSStatement r
jOut Bool
newLn Maybe (SValue r)
f SValue r
printFn SValue r
v = forall (m :: * -> *) (n :: * -> *) s t c.
Zoom m n s t =>
LensLike' (Zoomed m c) t s -> m c -> n c
zoom Lens' MethodState ValueState
lensMStoVS SValue r
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= CodeType -> StateT MethodState Identity (r (Statement r))
jOut' forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (r :: * -> *). TypeElim r => r (Type r) -> CodeType
getType forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (r :: * -> *). ValueSym r => r (Value r) -> r (Type r)
valueType
where jOut' :: CodeType -> StateT MethodState Identity (r (Statement r))
jOut' (List (Object String
_)) = forall (r :: * -> *).
RenderSym r =>
Bool -> Maybe (SValue r) -> SValue r -> SValue r -> MSStatement r
G.print Bool
newLn Maybe (SValue r)
f SValue r
printFn SValue r
v
jOut' (List CodeType
_) = forall (r :: * -> *).
InternalIOStmt r =>
Bool -> Maybe (SValue r) -> SValue r -> SValue r -> MSStatement r
printSt Bool
newLn Maybe (SValue r)
f SValue r
printFn SValue r
v
jOut' CodeType
_ = forall (r :: * -> *).
RenderSym r =>
Bool -> Maybe (SValue r) -> SValue r -> SValue r -> MSStatement r
G.print Bool
newLn Maybe (SValue r)
f SValue r
printFn SValue r
v
jDiscardInput :: SValue JavaCode -> MSStatement JavaCode
jDiscardInput :: SValue JavaCode -> MSStatement JavaCode
jDiscardInput SValue JavaCode
inFn = forall (r :: * -> *). StatementSym r => SValue r -> MSStatement r
valStmt forall a b. (a -> b) -> a -> b
$ SValue JavaCode
inFn forall (r :: * -> *).
FunctionSym r =>
SValue r -> VSFunction r -> SValue r
$. VSFunction JavaCode
jNextFunc
jInput :: SVariable JavaCode -> SValue JavaCode -> SValue JavaCode
jInput :: SVariable JavaCode -> SValue JavaCode -> SValue JavaCode
jInput SVariable JavaCode
vr SValue JavaCode
inFn = do
JavaCode VarData
v <- SVariable JavaCode
vr
let jInput' :: CodeType -> SValue JavaCode
jInput' CodeType
Integer = SValue JavaCode -> SValue JavaCode
jParseIntFunc forall a b. (a -> b) -> a -> b
$ SValue JavaCode
inFn forall (r :: * -> *).
FunctionSym r =>
SValue r -> VSFunction r -> SValue r
$. VSFunction JavaCode
jNextLineFunc
jInput' CodeType
Float = SValue JavaCode -> SValue JavaCode
jParseFloatFunc forall a b. (a -> b) -> a -> b
$ SValue JavaCode
inFn forall (r :: * -> *).
FunctionSym r =>
SValue r -> VSFunction r -> SValue r
$. VSFunction JavaCode
jNextLineFunc
jInput' CodeType
Double = SValue JavaCode -> SValue JavaCode
jParseDblFunc forall a b. (a -> b) -> a -> b
$ SValue JavaCode
inFn forall (r :: * -> *).
FunctionSym r =>
SValue r -> VSFunction r -> SValue r
$. VSFunction JavaCode
jNextLineFunc
jInput' CodeType
Boolean = SValue JavaCode
inFn forall (r :: * -> *).
FunctionSym r =>
SValue r -> VSFunction r -> SValue r
$. VSFunction JavaCode
jNextBoolFunc
jInput' CodeType
String = SValue JavaCode
inFn forall (r :: * -> *).
FunctionSym r =>
SValue r -> VSFunction r -> SValue r
$. VSFunction JavaCode
jNextLineFunc
jInput' CodeType
Char = (SValue JavaCode
inFn forall (r :: * -> *).
FunctionSym r =>
SValue r -> VSFunction r -> SValue r
$. VSFunction JavaCode
jNextFunc) forall (r :: * -> *).
FunctionSym r =>
SValue r -> VSFunction r -> SValue r
$. VSFunction JavaCode
jCharAtFunc
jInput' CodeType
_ = forall a. HasCallStack => String -> a
error String
"Attempt to read value of unreadable type"
CodeType -> SValue JavaCode
jInput' (forall (r :: * -> *). TypeElim r => r (Type r) -> CodeType
getType forall a b. (a -> b) -> a -> b
$ forall (r :: * -> *).
VariableElim r =>
r (Variable r) -> r (Type r)
variableType JavaCode VarData
v)
jOpenFileR :: (RenderSym r) => SValue r -> VSType r -> SValue r
jOpenFileR :: forall (r :: * -> *).
RenderSym r =>
SValue r -> VSType r -> SValue r
jOpenFileR SValue r
n VSType r
t = forall (r :: * -> *). ValueExpression r => PosCtorCall r
newObj VSType r
t [forall (r :: * -> *). ValueExpression r => PosCtorCall r
newObj forall (r :: * -> *). RenderSym r => VSType r
jFileType [SValue r
n]]
jOpenFileWorA :: (RenderSym r) => SValue r -> VSType r -> SValue r -> SValue r
jOpenFileWorA :: forall (r :: * -> *).
RenderSym r =>
SValue r -> VSType r -> SValue r -> SValue r
jOpenFileWorA SValue r
n VSType r
t SValue r
wa = forall (r :: * -> *). ValueExpression r => PosCtorCall r
newObj VSType r
t [forall (r :: * -> *). ValueExpression r => PosCtorCall r
newObj forall (r :: * -> *). RenderSym r => VSType r
jFileWriterType [forall (r :: * -> *). ValueExpression r => PosCtorCall r
newObj forall (r :: * -> *). RenderSym r => VSType r
jFileType [SValue r
n],
SValue r
wa]]
jStringSplit :: (RenderSym r) => SVariable r -> SValue r -> VS Doc
jStringSplit :: forall (r :: * -> *).
RenderSym r =>
SVariable r -> SValue r -> VS Doc
jStringSplit = forall a b c s.
(a -> b -> c) -> State s a -> State s b -> State s c
on2StateValues (\r (Variable r)
vnew r (Value r)
s -> forall (r :: * -> *). InternalVarElim r => r (Variable r) -> Doc
RC.variable r (Variable r)
vnew Doc -> Doc -> Doc
<+> Doc
equals Doc -> Doc -> Doc
<+>
Doc
new' Doc -> Doc -> Doc
<+> forall (r :: * -> *). InternalTypeElim r => r (Type r) -> Doc
RC.type' (forall (r :: * -> *).
VariableElim r =>
r (Variable r) -> r (Type r)
variableType r (Variable r)
vnew) Doc -> Doc -> Doc
<> Doc -> Doc
parens (forall (r :: * -> *). ValueElim r => r (Value r) -> Doc
RC.value r (Value r)
s))
jMethod :: (RenderSym r) => Label -> [String] -> r (Scope r) -> r (Permanence r)
-> r (Type r) -> [r (Parameter r)] -> r (Body r) -> Doc
jMethod :: forall (r :: * -> *).
RenderSym r =>
String
-> [String]
-> r (Scope r)
-> r (Permanence r)
-> r (Type r)
-> [r (Parameter r)]
-> r (Body r)
-> Doc
jMethod String
n [String]
es r (Scope r)
s r (Permanence r)
p r (Type r)
t [r (Parameter r)]
ps r (Body r)
b = [Doc] -> Doc
vcat [
forall (r :: * -> *). ScopeElim r => r (Scope r) -> Doc
RC.scope r (Scope r)
s Doc -> Doc -> Doc
<+> forall (r :: * -> *). PermElim r => r (Permanence r) -> Doc
RC.perm r (Permanence r)
p Doc -> Doc -> Doc
<+> forall (r :: * -> *). InternalTypeElim r => r (Type r) -> Doc
RC.type' r (Type r)
t Doc -> Doc -> Doc
<+> String -> Doc
text String
n Doc -> Doc -> Doc
<>
Doc -> Doc
parens (forall (r :: * -> *). RenderSym r => [r (Parameter r)] -> Doc
parameterList [r (Parameter r)]
ps) Doc -> Doc -> Doc
<+> forall a. [a] -> Doc -> Doc
emptyIfNull [String]
es (Doc
throwsLabel Doc -> Doc -> Doc
<+>
String -> Doc
text (forall a. [a] -> [[a]] -> [a]
intercalate String
listSep (forall a. Ord a => [a] -> [a]
sort [String]
es))) Doc -> Doc -> Doc
<+> Doc
lbrace,
Doc -> Doc
indent forall a b. (a -> b) -> a -> b
$ forall (r :: * -> *). BodyElim r => r (Body r) -> Doc
RC.body r (Body r)
b,
Doc
rbrace]
outputs :: SVariable JavaCode
outputs :: SVariable JavaCode
outputs = forall (r :: * -> *).
VariableSym r =>
String -> VSType r -> SVariable r
var String
"outputs" VSType JavaCode
jArrayType
jAssignFromArray :: Integer -> [SVariable JavaCode] -> [MSStatement JavaCode]
jAssignFromArray :: Integer -> [SVariable JavaCode] -> [MSStatement JavaCode]
jAssignFromArray Integer
_ [] = []
jAssignFromArray Integer
c (SVariable JavaCode
v:[SVariable JavaCode]
vs) = (SVariable JavaCode
v forall (r :: * -> *).
AssignStatement r =>
SVariable r -> SValue r -> MSStatement r
&= forall (r :: * -> *).
RenderValue r =>
VSType r -> SValue r -> SValue r
cast (forall a b s. (a -> b) -> State s a -> State s b
onStateValue forall (r :: * -> *).
VariableElim r =>
r (Variable r) -> r (Type r)
variableType SVariable JavaCode
v)
(forall (r :: * -> *). VariableValue r => SVariable r -> SValue r
valueOf forall a b. (a -> b) -> a -> b
$ forall (r :: * -> *).
VariableSym r =>
Integer -> SVariable r -> SVariable r
arrayElem Integer
c SVariable JavaCode
outputs)) forall a. a -> [a] -> [a]
: Integer -> [SVariable JavaCode] -> [MSStatement JavaCode]
jAssignFromArray (Integer
cforall a. Num a => a -> a -> a
+Integer
1) [SVariable JavaCode]
vs
jInOutCall :: (Label -> VSType JavaCode -> [SValue JavaCode] ->
SValue JavaCode) -> Label -> [SValue JavaCode] -> [SVariable JavaCode] ->
[SVariable JavaCode] -> MSStatement JavaCode
jInOutCall :: (String -> VSType JavaCode -> [SValue JavaCode] -> SValue JavaCode)
-> InOutCall JavaCode
jInOutCall String -> VSType JavaCode -> [SValue JavaCode] -> SValue JavaCode
f String
n [SValue JavaCode]
ins [] [] = forall (r :: * -> *). StatementSym r => SValue r -> MSStatement r
valStmt forall a b. (a -> b) -> a -> b
$ String -> VSType JavaCode -> [SValue JavaCode] -> SValue JavaCode
f String
n forall (r :: * -> *). TypeSym r => VSType r
void [SValue JavaCode]
ins
jInOutCall String -> VSType JavaCode -> [SValue JavaCode] -> SValue JavaCode
f String
n [SValue JavaCode]
ins [SVariable JavaCode
out] [] = forall (r :: * -> *).
AssignStatement r =>
SVariable r -> SValue r -> MSStatement r
assign SVariable JavaCode
out forall a b. (a -> b) -> a -> b
$ String -> VSType JavaCode -> [SValue JavaCode] -> SValue JavaCode
f String
n (forall a b s. (a -> b) -> State s a -> State s b
onStateValue forall (r :: * -> *).
VariableElim r =>
r (Variable r) -> r (Type r)
variableType SVariable JavaCode
out)
[SValue JavaCode]
ins
jInOutCall String -> VSType JavaCode -> [SValue JavaCode] -> SValue JavaCode
f String
n [SValue JavaCode]
ins [] [SVariable JavaCode
out] = forall (r :: * -> *).
AssignStatement r =>
SVariable r -> SValue r -> MSStatement r
assign SVariable JavaCode
out forall a b. (a -> b) -> a -> b
$ String -> VSType JavaCode -> [SValue JavaCode] -> SValue JavaCode
f String
n (forall a b s. (a -> b) -> State s a -> State s b
onStateValue forall (r :: * -> *).
VariableElim r =>
r (Variable r) -> r (Type r)
variableType SVariable JavaCode
out)
(forall (r :: * -> *). VariableValue r => SVariable r -> SValue r
valueOf SVariable JavaCode
out forall a. a -> [a] -> [a]
: [SValue JavaCode]
ins)
jInOutCall String -> VSType JavaCode -> [SValue JavaCode] -> SValue JavaCode
f String
n [SValue JavaCode]
ins [SVariable JavaCode]
outs [SVariable JavaCode]
both = [State ValueState (JavaCode VarData)] -> MSStatement JavaCode
fCall [State ValueState (JavaCode VarData)]
rets
where rets :: [State ValueState (JavaCode VarData)]
rets = [SVariable JavaCode]
both forall a. [a] -> [a] -> [a]
++ [SVariable JavaCode]
outs
fCall :: [State ValueState (JavaCode VarData)] -> MSStatement JavaCode
fCall [State ValueState (JavaCode VarData)
x] = forall (r :: * -> *).
AssignStatement r =>
SVariable r -> SValue r -> MSStatement r
assign State ValueState (JavaCode VarData)
x forall a b. (a -> b) -> a -> b
$ String -> VSType JavaCode -> [SValue JavaCode] -> SValue JavaCode
f String
n (forall a b s. (a -> b) -> State s a -> State s b
onStateValue forall (r :: * -> *).
VariableElim r =>
r (Variable r) -> r (Type r)
variableType State ValueState (JavaCode VarData)
x)
(forall a b. (a -> b) -> [a] -> [b]
map forall (r :: * -> *). VariableValue r => SVariable r -> SValue r
valueOf [SVariable JavaCode]
both forall a. [a] -> [a] -> [a]
++ [SValue JavaCode]
ins)
fCall [State ValueState (JavaCode VarData)]
xs = MS Bool
isOutputsDeclared forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (\Bool
odec -> forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify MethodState -> MethodState
setOutputsDeclared forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
forall (r :: * -> *).
StatementSym r =>
[MSStatement r] -> MSStatement r
multi ((if Bool
odec then forall (r :: * -> *).
AssignStatement r =>
SVariable r -> SValue r -> MSStatement r
assign else forall (r :: * -> *).
DeclStatement r =>
SVariable r -> SValue r -> MSStatement r
varDecDef) SVariable JavaCode
outputs
(String -> VSType JavaCode -> [SValue JavaCode] -> SValue JavaCode
f String
n VSType JavaCode
jArrayType (forall a b. (a -> b) -> [a] -> [b]
map forall (r :: * -> *). VariableValue r => SVariable r -> SValue r
valueOf [SVariable JavaCode]
both forall a. [a] -> [a] -> [a]
++ [SValue JavaCode]
ins)) forall a. a -> [a] -> [a]
: Integer -> [SVariable JavaCode] -> [MSStatement JavaCode]
jAssignFromArray Integer
0 [State ValueState (JavaCode VarData)]
xs))
jInOut :: (VSType JavaCode -> [MSParameter JavaCode] -> MSBody JavaCode ->
SMethod JavaCode) ->
[SVariable JavaCode] -> [SVariable JavaCode] -> [SVariable JavaCode] ->
MSBody JavaCode -> SMethod JavaCode
jInOut :: (VSType JavaCode
-> [MSParameter JavaCode] -> MSBody JavaCode -> SMethod JavaCode)
-> InOutFunc JavaCode
jInOut VSType JavaCode
-> [MSParameter JavaCode] -> MSBody JavaCode -> SMethod JavaCode
f [SVariable JavaCode]
ins [] [] MSBody JavaCode
b = VSType JavaCode
-> [MSParameter JavaCode] -> MSBody JavaCode -> SMethod JavaCode
f forall (r :: * -> *). TypeSym r => VSType r
void (forall a b. (a -> b) -> [a] -> [b]
map forall (r :: * -> *).
ParameterSym r =>
SVariable r -> MSParameter r
param [SVariable JavaCode]
ins) MSBody JavaCode
b
jInOut VSType JavaCode
-> [MSParameter JavaCode] -> MSBody JavaCode -> SMethod JavaCode
f [SVariable JavaCode]
ins [SVariable JavaCode
v] [] MSBody JavaCode
b = VSType JavaCode
-> [MSParameter JavaCode] -> MSBody JavaCode -> SMethod JavaCode
f (forall a b s. (a -> b) -> State s a -> State s b
onStateValue forall (r :: * -> *).
VariableElim r =>
r (Variable r) -> r (Type r)
variableType SVariable JavaCode
v) (forall a b. (a -> b) -> [a] -> [b]
map forall (r :: * -> *).
ParameterSym r =>
SVariable r -> MSParameter r
param [SVariable JavaCode]
ins)
(forall a b c d s.
(a -> b -> c -> d)
-> State s a -> State s b -> State s c -> State s d
on3StateValues (forall (r :: * -> *) a b c d.
Applicative r =>
(a -> b -> c -> d) -> r a -> r b -> r c -> r d
on3CodeValues (Doc, Terminator) -> Doc -> (Doc, Terminator) -> Doc
surroundBody) (forall (r :: * -> *).
DeclStatement r =>
SVariable r -> MSStatement r
varDec SVariable JavaCode
v) MSBody JavaCode
b (forall (r :: * -> *).
ControlStatement r =>
SValue r -> MSStatement r
returnStmt forall a b. (a -> b) -> a -> b
$
forall (r :: * -> *). VariableValue r => SVariable r -> SValue r
valueOf SVariable JavaCode
v))
jInOut VSType JavaCode
-> [MSParameter JavaCode] -> MSBody JavaCode -> SMethod JavaCode
f [SVariable JavaCode]
ins [] [SVariable JavaCode
v] MSBody JavaCode
b = VSType JavaCode
-> [MSParameter JavaCode] -> MSBody JavaCode -> SMethod JavaCode
f (forall a b s. (a -> b) -> State s a -> State s b
onStateValue forall (r :: * -> *).
VariableElim r =>
r (Variable r) -> r (Type r)
variableType SVariable JavaCode
v)
(forall a b. (a -> b) -> [a] -> [b]
map forall (r :: * -> *).
ParameterSym r =>
SVariable r -> MSParameter r
param forall a b. (a -> b) -> a -> b
$ SVariable JavaCode
v forall a. a -> [a] -> [a]
: [SVariable JavaCode]
ins) (forall a b c s.
(a -> b -> c) -> State s a -> State s b -> State s c
on2StateValues (forall (r :: * -> *) a b c.
Applicative r =>
(a -> b -> c) -> r a -> r b -> r c
on2CodeValues Doc -> (Doc, Terminator) -> Doc
appendToBody) MSBody JavaCode
b
(forall (r :: * -> *).
ControlStatement r =>
SValue r -> MSStatement r
returnStmt forall a b. (a -> b) -> a -> b
$ forall (r :: * -> *). VariableValue r => SVariable r -> SValue r
valueOf SVariable JavaCode
v))
jInOut VSType JavaCode
-> [MSParameter JavaCode] -> MSBody JavaCode -> SMethod JavaCode
f [SVariable JavaCode]
ins [SVariable JavaCode]
outs [SVariable JavaCode]
both MSBody JavaCode
b = VSType JavaCode
-> [MSParameter JavaCode] -> MSBody JavaCode -> SMethod JavaCode
f ([State ValueState (JavaCode VarData)]
-> State ValueState (JavaCode TypeData)
returnTp [State ValueState (JavaCode VarData)]
rets)
(forall a b. (a -> b) -> [a] -> [b]
map forall (r :: * -> *).
ParameterSym r =>
SVariable r -> MSParameter r
param forall a b. (a -> b) -> a -> b
$ [SVariable JavaCode]
both forall a. [a] -> [a] -> [a]
++ [SVariable JavaCode]
ins) (forall a b c d s.
(a -> b -> c -> d)
-> State s a -> State s b -> State s c -> State s d
on3StateValues (forall (r :: * -> *) a b c d.
Applicative r =>
(a -> b -> c -> d) -> r a -> r b -> r c -> r d
on3CodeValues (Doc, Terminator) -> Doc -> (Doc, Terminator) -> Doc
surroundBody) MSStatement JavaCode
decls
MSBody JavaCode
b ([State ValueState (JavaCode VarData)] -> MSStatement JavaCode
returnSt [State ValueState (JavaCode VarData)]
rets))
where returnTp :: [SVariable JavaCode] -> VSType JavaCode
returnTp [SVariable JavaCode
x] = forall a b s. (a -> b) -> State s a -> State s b
onStateValue forall (r :: * -> *).
VariableElim r =>
r (Variable r) -> r (Type r)
variableType SVariable JavaCode
x
returnTp [SVariable JavaCode]
_ = VSType JavaCode
jArrayType
returnSt :: [State ValueState (JavaCode VarData)] -> MSStatement JavaCode
returnSt [State ValueState (JavaCode VarData)
x] = forall (r :: * -> *).
ControlStatement r =>
SValue r -> MSStatement r
returnStmt forall a b. (a -> b) -> a -> b
$ forall (r :: * -> *). VariableValue r => SVariable r -> SValue r
valueOf State ValueState (JavaCode VarData)
x
returnSt [State ValueState (JavaCode VarData)]
_ = forall (r :: * -> *).
StatementSym r =>
[MSStatement r] -> MSStatement r
multi (forall (r :: * -> *).
DeclStatement r =>
Integer -> SVariable r -> MSStatement r
arrayDec (forall a. Integral a => a -> Integer
toInteger forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) a. Foldable t => t a -> Int
length [State ValueState (JavaCode VarData)]
rets) SVariable JavaCode
outputs
forall a. a -> [a] -> [a]
: Integer -> [SValue JavaCode] -> [MSStatement JavaCode]
assignArray Integer
0 (forall a b. (a -> b) -> [a] -> [b]
map forall (r :: * -> *). VariableValue r => SVariable r -> SValue r
valueOf [State ValueState (JavaCode VarData)]
rets)
forall a. [a] -> [a] -> [a]
++ [forall (r :: * -> *).
ControlStatement r =>
SValue r -> MSStatement r
returnStmt (forall (r :: * -> *). VariableValue r => SVariable r -> SValue r
valueOf SVariable JavaCode
outputs)])
assignArray :: Integer -> [SValue JavaCode] -> [MSStatement JavaCode]
assignArray :: Integer -> [SValue JavaCode] -> [MSStatement JavaCode]
assignArray Integer
_ [] = []
assignArray Integer
c (SValue JavaCode
v:[SValue JavaCode]
vs) = (forall (r :: * -> *).
VariableSym r =>
Integer -> SVariable r -> SVariable r
arrayElem Integer
c SVariable JavaCode
outputs forall (r :: * -> *).
AssignStatement r =>
SVariable r -> SValue r -> MSStatement r
&= SValue JavaCode
v) forall a. a -> [a] -> [a]
: Integer -> [SValue JavaCode] -> [MSStatement JavaCode]
assignArray (Integer
cforall a. Num a => a -> a -> a
+Integer
1) [SValue JavaCode]
vs
decls :: MSStatement JavaCode
decls = forall (r :: * -> *).
StatementSym r =>
[MSStatement r] -> MSStatement r
multi forall a b. (a -> b) -> a -> b
$ forall a b. (a -> b) -> [a] -> [b]
map forall (r :: * -> *).
DeclStatement r =>
SVariable r -> MSStatement r
varDec [SVariable JavaCode]
outs
rets :: [State ValueState (JavaCode VarData)]
rets = [SVariable JavaCode]
both forall a. [a] -> [a] -> [a]
++ [SVariable JavaCode]
outs
jDocInOut :: (RenderSym r) => ([SVariable r] -> [SVariable r] -> [SVariable r] ->
MSBody r -> SMethod r) ->
String -> [(String, SVariable r)] -> [(String, SVariable r)] ->
[(String, SVariable r)] -> MSBody r -> SMethod r
jDocInOut :: forall (r :: * -> *).
RenderSym r =>
([SVariable r]
-> [SVariable r] -> [SVariable r] -> MSBody r -> SMethod r)
-> String
-> [(String, SVariable r)]
-> [(String, SVariable r)]
-> [(String, SVariable r)]
-> MSBody r
-> SMethod r
jDocInOut [SVariable r]
-> [SVariable r] -> [SVariable r] -> MSBody r -> SMethod r
f String
desc [(String, SVariable r)]
is [] [] MSBody r
b = forall (r :: * -> *).
RenderSym r =>
FuncDocRenderer
-> String -> [String] -> [String] -> SMethod r -> SMethod r
docFuncRepr FuncDocRenderer
functionDox String
desc (forall a b. (a -> b) -> [a] -> [b]
map forall a b. (a, b) -> a
fst [(String, SVariable r)]
is) []
([SVariable r]
-> [SVariable r] -> [SVariable r] -> MSBody r -> SMethod r
f (forall a b. (a -> b) -> [a] -> [b]
map forall a b. (a, b) -> b
snd [(String, SVariable r)]
is) [] [] MSBody r
b)
jDocInOut [SVariable r]
-> [SVariable r] -> [SVariable r] -> MSBody r -> SMethod r
f String
desc [(String, SVariable r)]
is [(String, SVariable r)
o] [] MSBody r
b = forall (r :: * -> *).
RenderSym r =>
FuncDocRenderer
-> String -> [String] -> [String] -> SMethod r -> SMethod r
docFuncRepr FuncDocRenderer
functionDox String
desc (forall a b. (a -> b) -> [a] -> [b]
map forall a b. (a, b) -> a
fst [(String, SVariable r)]
is)
[forall a b. (a, b) -> a
fst (String, SVariable r)
o] ([SVariable r]
-> [SVariable r] -> [SVariable r] -> MSBody r -> SMethod r
f (forall a b. (a -> b) -> [a] -> [b]
map forall a b. (a, b) -> b
snd [(String, SVariable r)]
is) [forall a b. (a, b) -> b
snd (String, SVariable r)
o] [] MSBody r
b)
jDocInOut [SVariable r]
-> [SVariable r] -> [SVariable r] -> MSBody r -> SMethod r
f String
desc [(String, SVariable r)]
is [] [(String, SVariable r)
both] MSBody r
b = forall (r :: * -> *).
RenderSym r =>
FuncDocRenderer
-> String -> [String] -> [String] -> SMethod r -> SMethod r
docFuncRepr FuncDocRenderer
functionDox String
desc (forall a b. (a -> b) -> [a] -> [b]
map forall a b. (a, b) -> a
fst ((String, SVariable r)
both forall a. a -> [a] -> [a]
:
[(String, SVariable r)]
is)) [forall a b. (a, b) -> a
fst (String, SVariable r)
both] ([SVariable r]
-> [SVariable r] -> [SVariable r] -> MSBody r -> SMethod r
f (forall a b. (a -> b) -> [a] -> [b]
map forall a b. (a, b) -> b
snd [(String, SVariable r)]
is) [] [forall a b. (a, b) -> b
snd (String, SVariable r)
both] MSBody r
b)
jDocInOut [SVariable r]
-> [SVariable r] -> [SVariable r] -> MSBody r -> SMethod r
f String
desc [(String, SVariable r)]
is [(String, SVariable r)]
os [(String, SVariable r)]
bs MSBody r
b = forall (r :: * -> *).
RenderSym r =>
FuncDocRenderer
-> String -> [String] -> [String] -> SMethod r -> SMethod r
docFuncRepr FuncDocRenderer
functionDox String
desc (forall a b. (a -> b) -> [a] -> [b]
map forall a b. (a, b) -> a
fst forall a b. (a -> b) -> a -> b
$ [(String, SVariable r)]
bs forall a. [a] -> [a] -> [a]
++ [(String, SVariable r)]
is)
[String]
rets ([SVariable r]
-> [SVariable r] -> [SVariable r] -> MSBody r -> SMethod r
f (forall a b. (a -> b) -> [a] -> [b]
map forall a b. (a, b) -> b
snd [(String, SVariable r)]
is) (forall a b. (a -> b) -> [a] -> [b]
map forall a b. (a, b) -> b
snd [(String, SVariable r)]
os) (forall a b. (a -> b) -> [a] -> [b]
map forall a b. (a, b) -> b
snd [(String, SVariable r)]
bs) MSBody r
b)
where rets :: [String]
rets = String
"array containing the following values:" forall a. a -> [a] -> [a]
: forall a b. (a -> b) -> [a] -> [b]
map forall a b. (a, b) -> a
fst [(String, SVariable r)]
bs forall a. [a] -> [a] -> [a]
++
forall a b. (a -> b) -> [a] -> [b]
map forall a b. (a, b) -> a
fst [(String, SVariable r)]
os
jExtraClass :: (RenderSym r) => Label -> Maybe Label -> [CSStateVar r] ->
[SMethod r] -> SClass r
String
n = forall (r :: * -> *).
RenderClass r =>
String
-> r (Scope r)
-> r Doc
-> [CSStateVar r]
-> [SMethod r]
-> SClass r
intClass String
n (forall (r :: * -> *).
RenderScope r =>
ScopeTag -> Doc -> r (Scope r)
scopeFromData ScopeTag
Priv Doc
empty) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (r :: * -> *). RenderClass r => Maybe String -> r Doc
inherit
addCallExcsCurrMod :: String -> VS ()
addCallExcsCurrMod :: String -> StateT ValueState Identity ()
addCallExcsCurrMod String
n = do
String
cm <- forall (m :: * -> *) (n :: * -> *) s t c.
Zoom m n s t =>
LensLike' (Zoomed m c) t s -> m c -> n c
zoom Lens' ValueState FileState
lensVStoFS FS String
getModuleName
Map QualifiedName [ExceptionType]
mem <- VS (Map QualifiedName [ExceptionType])
getMethodExcMap
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (forall b a. b -> (a -> b) -> Maybe a -> b
maybe forall a. a -> a
id [ExceptionType] -> ValueState -> ValueState
addExceptions (forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup (String -> String -> QualifiedName
qualName String
cm String
n) Map QualifiedName [ExceptionType]
mem))
addConstructorCallExcsCurrMod :: (RenderSym r) => VSType r ->
(VSType r -> SValue r) -> SValue r
addConstructorCallExcsCurrMod :: forall (r :: * -> *).
RenderSym r =>
VSType r -> (VSType r -> SValue r) -> SValue r
addConstructorCallExcsCurrMod VSType r
ot VSType r -> SValue r
f = do
r (Type r)
t <- VSType r
ot
String
cm <- forall (m :: * -> *) (n :: * -> *) s t c.
Zoom m n s t =>
LensLike' (Zoomed m c) t s -> m c -> n c
zoom Lens' ValueState FileState
lensVStoFS FS String
getModuleName
Map QualifiedName [ExceptionType]
mem <- VS (Map QualifiedName [ExceptionType])
getMethodExcMap
let tp :: String
tp = forall (r :: * -> *). TypeElim r => r (Type r) -> String
getTypeString r (Type r)
t
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (forall b a. b -> (a -> b) -> Maybe a -> b
maybe forall a. a -> a
id [ExceptionType] -> ValueState -> ValueState
addExceptions (forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup (String -> String -> QualifiedName
qualName String
cm String
tp) Map QualifiedName [ExceptionType]
mem))
VSType r -> SValue r
f (forall (f :: * -> *) a. Applicative f => a -> f a
pure r (Type r)
t)