Commit 35ac09aa by Zachary Snow

struct conversion handles complex expression nesting

parent dadcd6ae
...@@ -373,10 +373,38 @@ convertAsgn structs types (lhs, expr) = ...@@ -373,10 +373,38 @@ convertAsgn structs types (lhs, expr) =
retType = case Map.lookup f types of retType = case Map.lookup f types of
Nothing -> Implicit Unspecified [] Nothing -> Implicit Unspecified []
Just t -> t Just t -> t
-- TODO: There are other expression cases that we probably need to convertSubExpr (Call (Just x) f args) =
-- recurse into. That said, it's not clear to me how much we really (Implicit Unspecified [], Call (Just x) f args)
-- expect to see things like concatenated packed structs, for example. convertSubExpr (String s) = (Implicit Unspecified [], String s)
convertSubExpr other = (Implicit Unspecified [], other) convertSubExpr (Number n) = (Implicit Unspecified [], Number n)
convertSubExpr (PSIdent x y) = (Implicit Unspecified [], PSIdent x y)
convertSubExpr (Repeat e es) =
(Implicit Unspecified [], Repeat e' es')
where
(_, e') = convertSubExpr e
es' = map (snd . convertSubExpr) es
convertSubExpr (UniOp op e) =
(Implicit Unspecified [], UniOp op e')
where (_, e') = convertSubExpr e
convertSubExpr (Mux a b c) =
(t, Mux a' b' c')
where
(_, a') = convertSubExpr a
(t, b') = convertSubExpr b
(_, c') = convertSubExpr c
convertSubExpr (Cast (Left t) sub) =
(t, Cast (Left t) (snd $ convertSubExpr sub))
convertSubExpr (Cast (Right e) sub) =
(Implicit Unspecified [], Cast (Right e) (snd $ convertSubExpr sub))
convertSubExpr (Bits (Left t)) = (Implicit Unspecified [], Bits (Left t))
convertSubExpr (Bits (Right e)) =
(Implicit Unspecified [], Bits (Right e'))
where e' = snd $ convertSubExpr e
convertSubExpr (Pattern items) =
(Implicit Unspecified [], Pattern items')
where
items' = map mapItem items
mapItem (mx, e) = (mx, snd $ convertSubExpr e)
-- lookup the range of a field in its unstructured type -- lookup the range of a field in its unstructured type
lookupUnstructRange :: TypeFunc -> Identifier -> Range lookupUnstructRange :: TypeFunc -> Identifier -> Range
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment