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

Casting of pointers in JS backend #5667

Open
dom96 opened this issue Apr 5, 2017 · 0 comments
Open

Casting of pointers in JS backend #5667

dom96 opened this issue Apr 5, 2017 · 0 comments

Comments

@dom96
Copy link
Contributor

dom96 commented Apr 5, 2017

I have made an attempt to get the marshal module working in the JS backend and it's not so easy. After fixing the lack of copyMem in streams.nim I was faced with a bunch of internal errors.

To fix the copyMem I added the following to streams.nim:

when defined(js):
  proc copyMem(dest, source: pointer, size: Natural) =
    for i in 0 .. <size:
      {.emit: """
        `dest`[`i`] = `source`[`i`];
      """.}

Then I started seeing internal errors in genDeref, on the following line in the typeinfo module:

...
result = cast[ptr bool](x.value)[]
...

Some relevant discussion on IRC is available here.

As far as @Araq told me, cast[T](x) is mapped to x in the JS backend and x[] is mapped to x[0], it therefore stands to reason that cast[T](x)[] should be mapped to x[0].

Not sure how to implement this unfortunately. There is also a problem when assigning a pointer to another pointer (an internal error in genAsgn). These errors can be mitigated to some extent by hacking around with emit but I don't think this solution is correct.

@stale stale bot added the stale Staled PR/issues; remove the label after fixing them label Aug 4, 2020
@nim-lang nim-lang deleted a comment from stale bot Oct 13, 2021
@ringabout ringabout added Feature and removed stale Staled PR/issues; remove the label after fixing them labels Oct 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants