Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow floating-point constants when cross-compiling #91

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/CrossCodegen.hs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ outValidityCheck viaAsm s@(Special pos key value) uniq =
"}\n"

-- we want this to fail if the value is syntactically invalid or isn't a constant
validConstTest value' = outCLine pos ++ " {\n static int test_array[(" ++ value' ++ ") > 0 ? 2 : 1];\n (void)test_array;\n }\n"
validConstTest value' = outCLine pos ++ " {\n int test_array[(" ++ value' ++ ") > 0 ? 2 : 1];\n (void)test_array;\n }\n"
validConstTestViaAsm name value' = outCLine pos ++ "\nextern long long _hsc2hs_test_" ++ name ++";\n"
++ "long long _hsc2hs_test_" ++ name ++ " = (" ++ value' ++ ");\n"

Expand Down Expand Up @@ -380,8 +380,6 @@ computeConst zOrig@(ZCursor (Special pos _ _) _ _) value =
int <- case cViaAsm config of
True -> runCompileAsmIntegerTest z
False -> do nonNegative <- compareConst z (GreaterOrEqual (Signed 0))
integral <- checkValueIsIntegral z nonNegative
when (not integral) $ testFail pos $ value ++ " is not an integer"
(lower,upper) <- bracketBounds z nonNegative
binarySearch z nonNegative lower upper
testLog' $ "result: " ++ show int
Expand Down Expand Up @@ -573,7 +571,7 @@ runCompileBooleanTest (ZCursor s above below) booleanTest = do
outHeaderCProg' s ++
-- the test
"int _hsc2hs_test() {\n" ++
" static int test_array[1 - 2 * !(" ++ booleanTest ++ ")];\n" ++
" int test_array[1 - 2 * !(" ++ booleanTest ++ ")];\n" ++
" return test_array[0];\n" ++
"}\n" ++
(concatMap outHeaderCProg' below)
Expand Down