Implemented the code for ClearMobile in the C and C++ backends
This commit is contained in:
parent
dfee567ffc
commit
83f654a273
|
@ -197,6 +197,7 @@ cgenOps = GenOps {
|
|||
genBytesIn = cgenBytesIn,
|
||||
genCase = cgenCase,
|
||||
genCheckedConversion = cgenCheckedConversion,
|
||||
genClearMobile = cgenClearMobile,
|
||||
genConversion = cgenConversion,
|
||||
genConversionSymbol = cgenConversionSymbol,
|
||||
genDecl = cgenDecl,
|
||||
|
@ -1855,4 +1856,16 @@ cgenAllocMobile ops m (A.Mobile t) Nothing = tell ["malloc("] >> call genBytesIn
|
|||
-- into a subsequent assignment
|
||||
cgenAllocMobile ops _ _ _ = call genMissing ops "Mobile allocation with initialising-expression"
|
||||
|
||||
cgenClearMobile :: GenOps -> Meta -> A.Variable -> CGen ()
|
||||
cgenClearMobile ops _ v
|
||||
= do tell ["if("]
|
||||
genVar
|
||||
tell ["!=NULL){free("]
|
||||
genVar
|
||||
tell [");"]
|
||||
genVar
|
||||
tell ["=NULL;}"]
|
||||
where
|
||||
genVar = call genVariable ops v
|
||||
|
||||
--}}}
|
||||
|
|
|
@ -103,6 +103,7 @@ cppgenOps = cgenOps {
|
|||
genArraySizesLiteral = cppgenArraySizesLiteral,
|
||||
genArrayStoreName = cppgenArrayStoreName,
|
||||
genArraySubscript = cppgenArraySubscript,
|
||||
genClearMobile = cppgenClearMobile,
|
||||
genDeclType = cppgenDeclType,
|
||||
genDeclaration = cppgenDeclaration,
|
||||
genDirectedVariable = cppgenDirectedVariable,
|
||||
|
@ -1115,3 +1116,15 @@ cppgenAllocMobile ops m (A.Mobile t) me
|
|||
case me of
|
||||
Just e -> tell ["("] >> call genExpression ops e >> tell [")"]
|
||||
Nothing -> return ()
|
||||
|
||||
cppgenClearMobile :: GenOps -> Meta -> A.Variable -> CGen ()
|
||||
cppgenClearMobile ops _ v
|
||||
= do tell ["if("]
|
||||
genVar
|
||||
tell ["!=NULL){delete "]
|
||||
genVar
|
||||
tell [";"]
|
||||
genVar
|
||||
tell ["=NULL;}"]
|
||||
where
|
||||
genVar = call genVariable ops v
|
||||
|
|
Loading…
Reference in New Issue
Block a user