Fixed types on functions in the code generator.

This commit is contained in:
Samuel Hammersberg 2023-02-16 14:16:08 +01:00
parent 6d9c42a03e
commit ab34666484
2 changed files with 18 additions and 5 deletions

View file

@ -264,8 +264,14 @@ compile (Program prg) = do
type2LlvmType :: Type -> LLVMType
type2LlvmType = \case
TInt -> I64
TFun t xs -> Function (type2LlvmType t) [type2LlvmType xs]
TFun t xs -> do
let (t', xs') = function2LLVMType xs [type2LlvmType t]
Function t' xs'
t -> CustomType $ Ident ("\"" ++ show t ++ "\"")
where
function2LLVMType :: Type -> [LLVMType] -> (LLVMType, [LLVMType])
function2LLVMType (TFun t xs) s = function2LLVMType xs (type2LlvmType t : s)
function2LLVMType x s = (type2LlvmType x, s)
getType :: Exp -> LLVMType
getType (EInt _) = I64