ssm-lang / Scoria

This is an embedding of the Sparse Synchronous Model, in Haskell!
BSD 3-Clause "New" or "Revised" License
4 stars 0 forks source link

Use unsigned integers #78

Closed j-hui closed 3 years ago

j-hui commented 3 years ago

Fix for #32 by using C's unsigned integers to represent SSM signed types.

Also includes some reorganization of SSM.Backend.C to isolate more of the type-related eccentricities within SSM.Backend.C.Types.

j-hui commented 3 years ago

@Rewbert fixed according to your suggestions, and ready for review!

Now, there is one issue in #32 that remains to be addressed. This patch fixes the undefined behavior of signed integer over/underflow in C, but does not do anything to address the undefined behavior in Haskell. It so happens that on our current dev environment, Haskell's Int type does more or less what we expect it to, but there's not much of a guarantee that will continue to be the case.

To fix that, should I fix the interpreter to perform arithmetic using Integer and manually perform over/underflow checks + wrapraound? That may incur a noticeable penalty for testing, so I can understand the argument for punting on this and fixing it when it only once we find issues in tests (since this doesn't technically affect the correctness of our generated code).

Rewbert commented 3 years ago

I'd say skip for now, but leave the issue open :)