Added the generation of IsDefined checks, and stopped them being applied to derefenced arrays
This commit is contained in:
parent
fae0d6d6a2
commit
228523e7e7
|
@ -904,6 +904,10 @@ cgenExpression (A.BytesInType m t) = call genBytesIn m t (Left False)
|
|||
--cgenExpression (A.ExprConstr {})
|
||||
cgenExpression (A.AllocMobile m t me) = call genAllocMobile m t me
|
||||
cgenExpression (A.CloneMobile m e) = call genCloneMobile m e
|
||||
cgenExpression (A.IsDefined m (A.ExprVariable _ (A.DerefVariable _ v)))
|
||||
= tell ["("] >> call genVariable v A.Original >> tell ["!=NULL)"]
|
||||
cgenExpression (A.IsDefined m e)
|
||||
= tell ["("] >> call genExpression e >> tell ["!=NULL)"]
|
||||
cgenExpression (A.SubscriptedExpr m sub (A.ExprVariable _ v))
|
||||
= call genVariable (A.SubscriptedVariable m sub v) A.Original
|
||||
cgenExpression (A.SubscriptedExpr m (A.SubscriptFromFor _ _ start _) e@(A.AllSizesVariable {}))
|
||||
|
|
|
@ -399,6 +399,8 @@ pullUp pullUpArraysInsideRecords = pass "Pull up definitions"
|
|||
-- | Pull array expressions that aren't already non-subscripted variables.
|
||||
-- Also pull lists that are literals or constructed
|
||||
doExpression :: A.Expression -> PassM A.Expression
|
||||
-- For is-defined, we don't want to pull up:
|
||||
doExpression e@(A.IsDefined {}) = return e
|
||||
doExpression e
|
||||
-- This part handles recursing into the expression first:
|
||||
= do e' <- doExpression' e
|
||||
|
|
Loading…
Reference in New Issue
Block a user