Thanks Jeremy, Chris and Ronaldo! This is exactly the answer I was
looking for :-)
On Jun 20, 10:43 pm, Jeremy Voorhis <
jvoor...@gmail.com> wrote:
> On Monday, June 20, 2011 at 12:41 AM, asterite wrote:
> > Hi!
>
> Hi Ary,> Do you think it's possible to write a new programming language in Ruby using your LLVM bindings? I just want to experiment a little with an idea I have, so I'd prefer doing it in Ruby rather than in C++. If later I find the language really usueful I might re-make it C++.
>
> It is absolutely possible. Chris Wailes has written a quality tutorial using ruby-llvm and his own scanner / parser / AST library.
http://chris.wailes.name/?page_id=97
>
> Ronaldo Ferraz has also implemented his own mostly-functional language called Spell, using ruby-llvm and garbage collection support.
https://github.com/rferraz/spell
>
> > But... is it possible using your bindings? Because I see you can dump a Module, but how do I make an "ll" file out of it, optimize it and compile it to native code? (maybe using the llvm command line tools?) And how to define and use external functions?
>
> Unfortunately, the LLVM C bindings upon which ruby-llvm is based only support dumping ll format to stdout. There are a couple of good alternatives to working with .ll files, however. You can use the ruby-llvm JIT compiler api to compile, optimize and execute code on the fly. You can also generate bitcode files which are the binary encoding of LLVM IR. You can generate a .ll file from a .bc by using the llvm-dis utility.> Sorry, I'm really new to LLVM so I just want to know your opinion...
>
> > Thanks!
> > Ary
>
> Thanks for asking, LLVM and its bindings present a new api to learn, but learning LLVM IR itself is like learning a new language. It can be a little daunting at first, the language reference manual is very helpful.
http://llvm.org/docs/LangRef.html