[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Parsing to byte code
- From: "Matt Holmes" <kerion@...>
- Date: Mon, 10 Sep 2001 13:47:57 -0400
Well, after checking out lua_loadfile/buffer in 4.1, I think perhaps my
question was misinterpreted.
What I want to do is this:
A script file path gets passed to my method. Said method opens the file,
does some pre-parsing that my engine does (special meta-data tags), then
strips those tags and prepares the actual Lua code for the interpreter. Once
it has the Lua code in this buffer, I want to be able to tell Lua "Okay,
parse this and turn it in to byte code, but don't execute it. Oh, and I need
the byte code back from you please". This would allow me to cache the
bytecode in memory, rather then keeping the source text hanging around. I
need to do this because on a fully populated MUD with hundreds of players
and thousands of objects floating around, having Lua reparse every script
file everytime an object is loaded is utterly wasteful. I already cache
script files in textual form, but I would much rather cache them as byte
code to save the interpretation step.
Matt
----- Original Message -----
From: "Luiz Henrique de Figueiredo" <lhf@tecgraf.puc-rio.br>
To: "Multiple recipients of list" <lua-l@tecgraf.puc-rio.br>
Sent: Monday, September 10, 2001 11:53 AM
Subject: Re: Parsing to byte code
>
> With Lua 4.1, use lua_loadfile instead of lua_dofile.
> With Lua 4.0, write your scripts as "return function () XXX end", where
XXX
> is your original script, run dofile on this and get return value.
>
> If you want to save pre-compiled scripts, use dump in 4.1 (see
src/luac/dumplib).
> --lhf
>