Skip to content

Commit

Permalink
Added C AST-node for casting Name to Type
Browse files Browse the repository at this point in the history
  • Loading branch information
EliasC committed Feb 4, 2015
1 parent 6660676 commit 3fd16d0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/back/CCode/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ data CCode a where
Function :: CCode Ty -> CCode Name -> [CVarSpec] -> CCode Stat -> CCode Toplevel
AsExpr :: CCode Lval -> CCode Expr
AsLval :: CCode Name -> CCode Lval
AsType :: CCode Name -> CCode Ty
Nam :: String -> CCode Name
Var :: String -> CCode Lval
Typ :: String -> CCode Ty
Expand Down
5 changes: 3 additions & 2 deletions src/back/CCode/PrettyCCode.hs
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ pp' (HashDefine str) = text $ "#define " ++ str
pp' (Statement other) = add_semi $ pp' other
pp' (Switch tst ccodes def) = text "switch" <+> parens (tshow tst) $+$
switch_body ccodes def
pp' (StructDecl name vardecls) = text "struct ___" <> tshow name $+$
pp' (StructDecl name vardecls) = text "struct " <> tshow name $+$
(add_semi . braced_block . vcat) (map pp' fields)
where fields = map (\ (ty, id) -> Embed $ show ty ++ " " ++ show id ++ ";") vardecls
pp' (Struct name) = text "struct ___" <> tshow name
pp' (Struct name) = text "struct " <> tshow name
pp' (Record ccodes) = braces $ commaList ccodes
pp' (Assign lhs rhs) = add_semi $ pp' lhs <+> text "=" <+> pp' rhs
pp' (AssignTL lhs rhs) = add_semi $ pp' lhs <+> text "=" <+> pp' rhs
Expand Down Expand Up @@ -84,6 +84,7 @@ pp' (Function ret_ty name args body) = tshow ret_ty <+> tshow name <>
(braced_block . pp') body
pp' (AsExpr c) = pp' c
pp' (AsLval c) = pp' c
pp' (AsType c) = pp' c
pp' (Nam st) = text st
pp' (Var st) = text st
pp' (Typ st) = text st
Expand Down

0 comments on commit 3fd16d0

Please sign in to comment.