Give LFunctions a vm property

Localize instructions and reg from frame

Split LVM.run() into LVM.call()/LVM.run()

Implement OP_TEST and OP_JMP

Implement OP_LOADBOOL

Initialise all stack slots to nil when calling a chunk

Allow LValues with a value of 'false' to be create (it was converted to 'null')

Implement OP_SELF

Fix for error handling to handle string exceptions

OP_FORPREP, OP_FORLOOP: Support for numerical for loops

Instantiate a new LValue in OP_LOADK, otherwise "constants" aren't so constant...

Fix off-by-one in calculating the value of sBx

Print sBx field in bytecode dump (for debugging)

Couple of fixes for last commit

Remove rawExceptions flag, always print exception's stack trace if it has one

Support for OP_NEWTABLE, OP_GETTABLE, OP_SETTABLE

New LValueFromValue() to convert from any Javascript value (almost) to a LValue

Implement OP_SETUPVALUE \o/

Add new debug option - rawExceptions - to prevent catching exceptions thrown by the VM, use for debugging the VM.

It's required to insert the new function into the stack before processing its upvalue instructions, in case it refers to itself.

Remove some, hmm, "debugging" code :)

Remove some accidentally-committed debug output

Switch from JSON.stringify for debug output to sys.inspect which doesn't bail out on circular references

Support for upvalues in functions \o/ implemented OP_GETUPVAL, and a stub for OP_SETUPVAL.

OP_RETURN: Support for return values from Lua functions \o/

Support for B==0 in OP_CALL (signifies params are to top of the stack)

Fix OP_RETURN to update this.frame

Implement OP_CALL for Lua functions (no return values yet)

Implement basic OP_CLOSURE (no support for upvalues yet)

Add chunk property to LFunction to show which chunk it came from

Support for reading all fields in the chunk (including function prototypes, required for OP_CLOSURE)

Initial stab at reading Number constants from bytecode

Throw error on unhandled opcodes

Use new notation for accessing instruction fields

Add a bytecode interpreter \o/

Add debugMode switch

Add errors for when trying to index non-tables

Implement OP_SETGLOBAL

Print error on error

Return nil for non-existent table keys

Throw an error if trying to call a non-function

Implement OP_MOVE, OP_LOADNIL and OP_RETURN. Also change the way OP_CALL is implemented, and update the test code with a more complicated (kind of) sample.

Style fix

Initial commit

(0) +56 +100 tip

mercurial