lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> You would do well by starting with what 'flua' actually is. "Flua is ..." and then the bulk of the message.

Hey all, sorry for my lack of clarity. I was creating a new thread off
my last thread where I was discussing the early development, so I
didn't see the need to restate the project description. Most of this
description is actually on the site. Flua is a Lua VM written in
Actionscript, specifically for the Flash/Flex platform, that
interprets bytecode. I'm making it as part of my game engine, gcre8,
which is going to be an online game creation system that allows users
to do simple programming for their own game objects, for which I
decided Lua would be ideal.

Now, to answer specific questions...

>Have you created an ActionScript compiler (script to bytecode) or not ?
>If not, which bytecode do you understand ? I suppose it's Flash. >So
then, is there a compiler freely available for that ?

>Is it still possible to use Lua (script or bytecode) with flua or is it
>restricted to ActionScript. If Lua isn't available, why call the
>project flua ?

This is not a compiler (as of now, at least,) but a bytecode
interpreter which opens .o files created by luac. Eventually It should
be able to support any simple script compiled in lua depending on the
builtins supported either the engine or extended by whoever is using
it (builtins can be defined as functions within AS3)

It isn't a direct Lua to AVM bytecode conversion mainly because that's
outside the scope of this project. It's not made for people to write
Lua code and then execute it as a Flash project, but rather within
Flash, so I can allow users to have a sandboxed environment and share
their games with each other without having too much access to the
flash internals.

> And, well, congratulations for your work.

Thanks! :D

> Just a question ? What id you optimise ? Is that the Lua Virtual
Machine (and so the optimisations could be available for regular Lua
> virtual machines) or some separate part you write for compatibility
with ActionScript ?

Well, I built this bottom-up from the description in the No-Frills
Introduction to the Lua VM, I didn't actually use any Lua VM code
except for some reference for how the builtin functions work (and I've
only implemented a couple of those.) Optimizations were really how to
optimize the main bytecode interpretation loop inside of
Actionscript/Flash, which interprets very slowly if you use standard
AS3 principles. Basically, AS3 and the AVM are dynamically typed but
many types can be specified as static to speed things up. with the
absence of C unions I had to statically type as much as possible, but
I still had to leave a few items dynamic. Also, there are many
instances where the AVM "upgrades" integers to its Number class when
doing interfaces, which also slows things down significantly. Also,
anywhere there was an object reference I tried to reference it first
into a local variable to save on the lookup time. The most extreme was
to, instead of abstracting the 32-bit operation as an object (with
opcodes, a, b, c, bx, sbx registers,) moving it straight into an
unsigned int and having the ops as needed do the bit operations (which
are very fast comparatively in AS3) in the main loop. That's the
hardest to work with as far as interpreting the code, but it has
offered significant speed increases.


>And, why modify the Lua VM to understand actionscript bytecode ? Why
>not create a translator between ActionScript bytecode and Lua
bytecode ? (that could be done transparently in the same binary)

Well, the scope of the project is really the other way around, getting
the AVM to understand Lua bytecode... I think I stated above why I
wrote a bytecode interpreter rather than a translator, although due to
what I've learned in this project I may decide in the future to write
a bytecode interpreter just to challenge myself and offer it to the
community. I'd most likely do something like that in C and not
directly in AVM just for my own sanity!!

> Do you think you could convince some projects to use flua instead of
> their own virtual machine ? I'm thinking of gnash, gecko and webkit.

The project is really for more domain-specific needs and I'm not
really trying to compete with anyone, just trying to make my own
humble offering of code I need for my purposes that hopefully someone
else can use, and with the input from others I can make it better.

As KHMan said, I'm not really read or trying to take on the big guns,
I'm just a CS student with the eventual goal of making something fun
for people to play around with and build up my coding skills.

> From the first paragraph on the website, I gather that it's the other way
> around. Flua would be written in ActionScript, and take Lua bytecode as
> input and interpret it. Or maybe I misread the above ?

> I had the impression it is the opposite way, a Lua vm based on ActionScript, see the ready() function in the example code on home page.

Yup, that's correct. :) Again, I apologize for my lack of clarity, I
tend to write in one big stream-of-consciousness in the early morning
hours! :(

Thanks all for your responses!!

Jason Neufeld (Phil. 3:12)