@@ -483,7 +483,7 @@ computeType z@(ZCursor (Special pos _ value) _ _) = do
483
483
testLogAtPos pos (" computing type of " ++ value) $ do
484
484
integral <- testLog (" checking if type " ++ value ++ " is an integer" ) $ do
485
485
success <- runCompileBooleanTest z $ " (" ++ value ++ " )(int)(" ++ value ++ " )1.4 == (" ++ value ++ " )1.4"
486
- testLog' $ " result: " ++ (if success then " integer" else " floating" )
486
+ testLog' $ " result: " ++ (if success then " integer" else " pointer or floating" )
487
487
return success
488
488
typeRet <- if integral
489
489
then do
@@ -494,18 +494,25 @@ computeType z@(ZCursor (Special pos _ value) _ _) = do
494
494
size <- computeConst z (" sizeof(" ++ value ++ " )" )
495
495
return $ (if signed then " Int" else " Word" ) ++ (show (size * 8 ))
496
496
else do
497
- let checkSize test = testLog (" checking if " ++ test) $ do
498
- success <- runCompileBooleanTest z test
499
- testLog' $ " result: " ++ show success
500
- return success
501
- ldouble <- checkSize (" sizeof(" ++ value ++ " ) > sizeof(double)" )
502
- if ldouble
503
- then return " LDouble"
504
- else do
505
- double <- checkSize (" sizeof(" ++ value ++ " ) == sizeof(double)" )
506
- if double
507
- then return " Double"
508
- else return " Float"
497
+ pointer <- testLog (" checking if type " ++ value ++ " is a pointer" ) $ do
498
+ success <- runCompileIsPointerTest z value
499
+ testLog' $ " result: " ++ (if success then " pointer" else " floating" )
500
+ return success
501
+ if pointer
502
+ then return " CUIntPtr"
503
+ else do
504
+ let checkSize test = testLog (" checking if " ++ test) $ do
505
+ success <- runCompileBooleanTest z test
506
+ testLog' $ " result: " ++ show success
507
+ return success
508
+ ldouble <- checkSize (" sizeof(" ++ value ++ " ) > sizeof(double)" )
509
+ if ldouble
510
+ then return " LDouble"
511
+ else do
512
+ double <- checkSize (" sizeof(" ++ value ++ " ) == sizeof(double)" )
513
+ if double
514
+ then return " Double"
515
+ else return " Float"
509
516
testLog' $ " result: " ++ typeRet
510
517
return typeRet
511
518
computeType _ = error " computeType argument isn't a Special"
@@ -572,6 +579,22 @@ runCompileBooleanTest (ZCursor s above below) booleanTest = do
572
579
(concatMap outHeaderCProg' below)
573
580
runCompileTest test
574
581
582
+ runCompileIsPointerTest :: ZCursor Token -> String -> TestMonad Bool
583
+ runCompileIsPointerTest (ZCursor s above below) ty = do
584
+ config <- testGetConfig
585
+ flags <- testGetFlags
586
+ let test = -- all the surrounding code
587
+ outTemplateHeaderCProg (cTemplate config) ++
588
+ (concatMap outFlagHeaderCProg flags) ++
589
+ (concatMap outHeaderCProg' above) ++
590
+ outHeaderCProg' s ++
591
+ -- the test
592
+ " void _hsc2hs_test(" ++ ty ++ " val) {\n " ++
593
+ " memset(val, 0, 0);\n " ++
594
+ " }\n " ++
595
+ (concatMap outHeaderCProg' below)
596
+ runCompileTest test
597
+
575
598
runCompileAsmIntegerTest :: ZCursor Token -> TestMonad Integer
576
599
runCompileAsmIntegerTest (ZCursor s@ (Special _ _ value) above below) = do
577
600
config <- testGetConfig
0 commit comments