Initial draft of interpreter. Lua compiled "chunks" can be unmarshalled. Approximately half of bytecodes implemented in some form or another.

This commit is contained in:
James Roseborough
2007-06-08 05:11:37 +00:00
commit 70dfc20f57
31 changed files with 1368 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
/**
*
*/
package lua;
import lua.value.LFunction;
import lua.value.LString;
import lua.value.LTable;
final class Builtin extends LFunction {
static void addBuiltins(LTable table) {
table.luaSetTable( new LString( "print" ), new Builtin(0) );
}
private static final int PRINT = 0;
private int id;
Builtin( int id ) {
this.id = id;
}
// perform a lua call
public void luaStackCall(StackState state, int base, int nresults) {
switch ( id ) {
case PRINT:
System.out.println( String.valueOf( state.stack[base+1] ) );
return;
default:
luaUnsupportedOperation();
}
}
}