Re: Using luajit runtime for non-lua languages

  • From: Tim Caswell <tim@xxxxxxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Sat, 2 Feb 2013 21:02:27 -0600

I'd rather not compile to lua because then I need a lua compiler in
addition to a jack compiler.  I guess the problem with generating my own
luajit bytecode is I miss out on all the optimizations luajit does as it
generates the bytecode from lua.  I wonder if there is a way to give luajit
IR code and have it optimize it and generate the final bytecode.  I would
still be skipping all the lua lexer/parser/code-gen steps and the lua
standard library.

If luajit isn't meant to be used this way, does anyone have experience or
opinions on LLVM or Parrot?  I'm also considering using those.  I really
like llvm because of it's many targets.  But I don't quite understand how
much runtime is required to compile llvm based languages.  I don't want my
users to have to install llvm to be able to compile Jack code.

I do plan on porting my lexer/ parser/ code-gen code to Jack itself so it
can be self-hosting.  I just need a runtime bytecode format to use that I
can bundle with the binary.


On Sat, Feb 2, 2013 at 5:46 PM, Pierre-Yves Gérardy <pygy79@xxxxxxxxx>wrote:

> On Sun, Feb 3, 2013 at 12:06 AM, Pierre-Yves Gérardy <pygy79@xxxxxxxxx>
> wrote:
> >
> > and the enforcement of the "density" of the list type.
>
>
> Scratch that. Since the list and hash types are different, you could
> use __newindex() to check efficiently whether the index is legal or
> not. The same goes for tuples.
>
> Adding some more, if you were to take the compile to Lua route, you
> could easily make a standalone binary by embedding the parser/compiler
> as a boot script in a C header.
>
> for the generic loop, you could use the generic for loop, and wrap the
> "in" clause in a dispatcher.
>
>     function forDispatch (first, ...)
>         -- custom iterators?
>         if type(first) == "function" then return first, ... end
>         -- lists, tuples? and hashes
>         if type(first) == "table" then
>             local m = getmetatable(first)
>             if m == listMT then return ipairs(first)
>             else if ...
>                 -- I guess you catch my drift...
>             end
>         error("Invalid type")
>     end
>
> -- Pierre-Yves
>
>

Other related posts: