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

I added all the operators that malfunction supports. #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

xekoukou
Copy link
Contributor

@xekoukou xekoukou commented Oct 5, 2016

I added all the operators that malfunction supports.

Unfortunately, trying to use xor operator results in segmentation fault.

module Main

import Data.Bits

main : IO ()
main = do printLn (xor (MkBits {n=64} 7) (MkBits {n=64} 45))
          pure ()

Gdb reports this:

Program received signal SIGSEGV, Segmentation fault.
0x0000000000404c5e in camlIdris_malfunction_output__Data$2eBits$2ebitAt_4084 () at pervasives.ml:32
32      pervasives.ml: No such file or directory.

@stedolan
Copy link
Owner

The problem is the two FIXMEs in CodegenMalfunction.hs, which implement the sign-extension and truncation primitives as no-ops. Since bigints that happen to be small are represented the same way as plain ints, this sorta-kinda-works for int to bigint conversions, but is totally wrong for int to int64 conversions (in the OCaml runtime system, int64s are always boxed).

Your commit looks good, but I'll hold off merging it until I expose integer conversions in Malfunction, which are needed to do this correctly.

@xekoukou
Copy link
Contributor Author

As soon as I have the time, I will try to update this to the new syntax.

@xekoukou
Copy link
Contributor Author

There are remaining problems in this pull request.

  1. Fixed length integers are treated as unsigned in Idris.
  2. The shift operators in Idris does not take 'int' in the second argument like shift_left of Ocaml.

There might be other problems as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants