MichaReiser / llvm-node

LLVM 9.0+ Node Bindings
MIT License
183 stars 29 forks source link

Lack of support for IntToPtr #115

Closed jiachen247 closed 3 years ago

jiachen247 commented 3 years ago

This currently no way to convent a int back to a pointer! https://llvm.org/docs/LangRef.html#inttoptr-to-instruction

ApsarasX commented 3 years ago

What a coincidence! I'm doing something similar to you.

I'm also working on a project to turn TypeScript into LLVM IR. It would be better if I could cooperate with you.

Besides, I developed a library called llvm-bindings to replace llvm-node, because it seems that llvm-node is no longer maintained.

If you like, you can try to use llvm-bindings.

If some APIs you needing have not been exposed, you can remind me in the discussion area of its repository that I should be able to add them in 1-2 days.

jiachen247 commented 3 years ago

Hi @ApsarasX , wow thats great to hear will check out your bindings if I ever have to work with llvm and node again!

I found a hack around this! you can have a create a corresponding struct that has a pointer instead of a int field and bitcasting the whole stuct from one to the other should not throw an error (just to do inttoptr lol)

Hope this helps anyone whole might be stuck!

MichaReiser commented 3 years ago

I'm maintaining the library in my free time but am not adding new functionality because I'm no longer working on a project using it. Thanks for suggesting an alternative @ApsarasX and great to see that it's built on top of N-API.

@jiachen247 I'm happy to merge a PR that adds support for the required instruction.

ApsarasX commented 3 years ago

@MichaReiser Thank you very much for your affirmation. llvm-bindings is mostly inspired by llvm-node. I will indicate your contribution in README.md

ApsarasX commented 3 years ago

@jiachen247

I have release v0.1.2 of llvm-bindings.

In the v0.1.1, I have added many create methods of cast instruction in IRBuilder, including CreatePtrToInt and CreateIntToPtr.

I hope that these help to you.

ApsarasX commented 3 years ago

I'm maintaining the library in my free time but am not adding new functionality because I'm no longer working on a project using it. Thanks for suggesting an alternative @ApsarasX and great to see that it's built on top of N-API.

@jiachen247 I'm happy to merge a PR that adds support for the required instruction.

@MichaReiser Excuse me, can you help me guide how to implement inheritance? I find an issue in node-addon-api, but I can find any valid method to implement inheritance.

MichaReiser commented 3 years ago

@ApsarasX I'm sorry but I don't know. Inheritance wasn't supported the last time I tried (see #19 and your linked issue) and I haven't tried to migrate since then (it would be nice because it allows to delete much of the boilerplate code).