diff options
-rw-r--r-- | codegen.hs | 8 | ||||
-rw-r--r-- | puts.nl | 9 |
2 files changed, 14 insertions, 3 deletions
@@ -477,9 +477,7 @@ literalToOperand (LitVar n) t = do return oper' literalToOperand (LitString s) (TypePtr (TypeInt 8)) = do name <- addStringLiteral s - let loadoper = A.ConstantOperand $ A.C.GlobalReference (A.ptr A.i8) (A.Name name) - label <- addInstr $ A.Load False loadoper Nothing 0 [] - return $ A.LocalReference (A.ptr A.i8) (A.Name label) + return $ A.ConstantOperand $ A.C.GlobalReference (A.ptr A.i8) (A.Name name) literalToOperand (LitString _) _ = undefined literalToOperand (LitCall n args) _ = do ((TypeFunc rt ats), lname) <- lookupGlobalFunction n @@ -526,6 +524,10 @@ castOperand orig@(A.LocalReference (A.PointerType t1 _) _) (TypePtr t2) | toLLVMType t2 == t1 = return orig | otherwise = throwError $ "Cannot implicitly cast between pointer to '" ++ show t1 ++ "' and '" ++ pshow t2 ++ "'" +castOperand orig@(A.ConstantOperand (A.C.GlobalReference (A.PointerType t1 _) _)) (TypePtr t2) + | toLLVMType t2 == t1 = return orig + | otherwise = throwError $ "Cannot implicitly cast between pointer to '" ++ show t1 + ++ "' and '" ++ pshow t2 ++ "'" castOperand orig t2 = throwError $ "Cast from '" ++ show orig ++ "' to type '" ++ pshow t2 ++ "' not implemented" castToBool :: A.Operand -> CGMonad A.Operand @@ -0,0 +1,9 @@ +type int = i32; +type char = i8; + +extern func int(ptr(char)) puts; + +int main(){ + puts("kaas!"); + return 0; +}
\ No newline at end of file |