Removed some of the old C generation functions, and added a new one (genFunctionCall) to get the C++ backend compiling again
This commit is contained in:
parent
5c353f10b7
commit
5a7f68a44f
|
@ -104,8 +104,7 @@ cgenOps = GenOps {
|
|||
genExpression = cgenExpression,
|
||||
genFlatArraySize = cgenFlatArraySize,
|
||||
genForwardDeclaration = cgenForwardDeclaration,
|
||||
genFuncDyadic = cgenFuncDyadic,
|
||||
genFuncMonadic = cgenFuncMonadic,
|
||||
genFunctionCall = cgenFunctionCall,
|
||||
genGetTime = cgenGetTime,
|
||||
genIf = cgenIf,
|
||||
genInput = cgenInput,
|
||||
|
@ -134,8 +133,6 @@ cgenOps = GenOps {
|
|||
genReschedule = cgenReschedule,
|
||||
genRetypeSizes = cgenRetypeSizes,
|
||||
genSeq = cgenSeq,
|
||||
genSimpleDyadic = cgenSimpleDyadic,
|
||||
genSimpleMonadic = cgenSimpleMonadic,
|
||||
genSpec = cgenSpec,
|
||||
genSpecMode = cgenSpecMode,
|
||||
genStop = cgenStop,
|
||||
|
@ -947,14 +944,7 @@ cgenExpression (A.Literal _ t lr) = call genLiteral lr t
|
|||
cgenExpression (A.True m) = tell ["true"]
|
||||
cgenExpression (A.False m) = tell ["false"]
|
||||
-- Any function calls remaining must be to the built-in operator functions:
|
||||
cgenExpression (A.FunctionCall m n es)
|
||||
= do A.Function _ _ _ fs _ <- specTypeOfName n
|
||||
genName n
|
||||
tell ["(wptr,"]
|
||||
call genActuals fs (map A.ActualExpression es)
|
||||
tell [","]
|
||||
genMeta m
|
||||
tell [")"]
|
||||
cgenExpression (A.FunctionCall m n es) = call genFunctionCall m n es
|
||||
cgenExpression (A.IntrinsicFunctionCall m s es) = call genIntrinsicFunction m s es
|
||||
--cgenExpression (A.BytesInExpr m e)
|
||||
cgenExpression (A.BytesInExpr m (A.ExprVariable _ v))
|
||||
|
@ -971,6 +961,17 @@ cgenExpression (A.IsDefined m e)
|
|||
= tell ["("] >> call genExpression e >> tell ["!=NULL)"]
|
||||
cgenExpression t = call genMissing $ "genExpression " ++ show t
|
||||
|
||||
cgenFunctionCall :: Meta -> A.Name -> [A.Expression] -> CGen ()
|
||||
cgenFunctionCall m n es
|
||||
= do A.Function _ _ _ fs _ <- specTypeOfName n
|
||||
genName n
|
||||
tell ["(wptr,"]
|
||||
call genActuals fs (map A.ActualExpression es)
|
||||
tell [","]
|
||||
genMeta m
|
||||
tell [")"]
|
||||
|
||||
|
||||
cgenTypeSymbol :: String -> A.Type -> CGen ()
|
||||
cgenTypeSymbol s t
|
||||
= do f <- fget getScalarType
|
||||
|
@ -991,41 +992,6 @@ cgenIntrinsicFunction m s es
|
|||
--}}}
|
||||
|
||||
--{{{ operators
|
||||
cgenSimpleMonadic :: String -> A.Expression -> CGen ()
|
||||
cgenSimpleMonadic s e
|
||||
= do tell ["(", s]
|
||||
call genExpression e
|
||||
tell [")"]
|
||||
|
||||
cgenFuncMonadic :: Meta -> String -> A.Expression -> CGen ()
|
||||
cgenFuncMonadic m s e
|
||||
= do t <- astTypeOf e
|
||||
call genTypeSymbol s t
|
||||
tell [" ("]
|
||||
call genExpression e
|
||||
tell [", "]
|
||||
genMeta m
|
||||
tell [")"]
|
||||
|
||||
cgenSimpleDyadic :: String -> A.Expression -> A.Expression -> CGen ()
|
||||
cgenSimpleDyadic s e f
|
||||
= do tell ["("]
|
||||
call genExpression e
|
||||
tell [" ", s, " "]
|
||||
call genExpression f
|
||||
tell [")"]
|
||||
|
||||
cgenFuncDyadic :: Meta -> String -> A.Expression -> A.Expression -> CGen ()
|
||||
cgenFuncDyadic m s e f
|
||||
= do t <- astTypeOf e
|
||||
call genTypeSymbol s t
|
||||
tell [" ("]
|
||||
call genExpression e
|
||||
tell [", "]
|
||||
call genExpression f
|
||||
tell [", "]
|
||||
genMeta m
|
||||
tell [")"]
|
||||
--}}}
|
||||
|
||||
cgenListConcat :: A.Expression -> A.Expression -> CGen ()
|
||||
|
@ -1723,13 +1689,8 @@ cgenAssign m [v] (A.ExpressionList _ [e])
|
|||
cgenAssign m [v] (A.FunctionCallList _ n es)
|
||||
= do call genVariable v A.Original
|
||||
tell ["="]
|
||||
genName n
|
||||
tell ["(wptr,"]
|
||||
A.Function _ _ _ fs _ <- specTypeOfName n
|
||||
call genActuals fs (map A.ActualExpression es)
|
||||
tell [","]
|
||||
genMeta m
|
||||
tell [");"]
|
||||
call genFunctionCall m n es
|
||||
tell [";"]
|
||||
cgenAssign m (v:vs) (A.IntrinsicFunctionCallList _ n es)
|
||||
= do call genVariable v A.Original
|
||||
let (funcName, giveMeta) = case lookup n simpleFloatIntrinsics of
|
||||
|
|
|
@ -142,8 +142,8 @@ data GenOps = GenOps {
|
|||
genExpression :: A.Expression -> CGen (),
|
||||
genFlatArraySize :: [A.Dimension] -> CGen (),
|
||||
genForwardDeclaration :: A.Specification -> CGen(),
|
||||
genFuncDyadic :: Meta -> String -> A.Expression -> A.Expression -> CGen (),
|
||||
genFuncMonadic :: Meta -> String -> A.Expression -> CGen (),
|
||||
-- | Only used for built-in operators at the moment:
|
||||
genFunctionCall :: Meta -> A.Name -> [A.Expression] -> CGen (),
|
||||
-- | Gets the current time into the given variable
|
||||
genGetTime :: A.Variable -> CGen (),
|
||||
-- | Generates an IF statement (which can have replicators, specifications and such things inside it).
|
||||
|
@ -180,8 +180,6 @@ data GenOps = GenOps {
|
|||
genReschedule :: CGen(),
|
||||
genRetypeSizes :: Meta -> A.Type -> A.Name -> A.Type -> A.Variable -> CGen (),
|
||||
genSeq :: A.Structured A.Process -> CGen (),
|
||||
genSimpleDyadic :: String -> A.Expression -> A.Expression -> CGen (),
|
||||
genSimpleMonadic :: String -> A.Expression -> CGen (),
|
||||
genSpec :: forall b. Level -> A.Specification -> CGen b -> CGen b,
|
||||
genSpecMode :: A.SpecMode -> CGen (),
|
||||
-- | Generates a STOP process that uses the given Meta tag and message as its printed message.
|
||||
|
|
|
@ -65,6 +65,7 @@ cppgenOps = cgenOps {
|
|||
getCType = cppgetCType,
|
||||
genDirectedVariable = cppgenDirectedVariable,
|
||||
genForwardDeclaration = cppgenForwardDeclaration,
|
||||
genFunctionCall = cppgenFunctionCall,
|
||||
genGetTime = cppgenGetTime,
|
||||
genIf = cppgenIf,
|
||||
genInputItem = cppgenInputItem,
|
||||
|
@ -521,6 +522,7 @@ cppgenFormal nameFunc (A.Formal am t n) = call genDecl NotTopLevel am t (nameFun
|
|||
cppgenForwardDeclaration :: A.Specification -> CGen()
|
||||
cppgenForwardDeclaration (A.Specification _ n (A.Proc _ (sm, _) fs _))
|
||||
= do --Generate the "process" as a C++ function:
|
||||
genStatic TopLevel n
|
||||
call genSpecMode sm
|
||||
tell ["void "]
|
||||
name
|
||||
|
@ -868,3 +870,14 @@ cppgenDirectedVariable m t v dir
|
|||
|
||||
cppgenReschedule :: CGen ()
|
||||
cppgenReschedule = tell ["csp::CPPCSP_Yield();"]
|
||||
|
||||
-- Changed because we don't need to pass the workspace in:
|
||||
cppgenFunctionCall :: Meta -> A.Name -> [A.Expression] -> CGen ()
|
||||
cppgenFunctionCall m n es
|
||||
= do A.Function _ _ _ fs _ <- specTypeOfName n
|
||||
genName n
|
||||
tell ["("]
|
||||
call genActuals fs (map A.ActualExpression es)
|
||||
tell [","]
|
||||
genMeta m
|
||||
tell [")"]
|
||||
|
|
Loading…
Reference in New Issue
Block a user