/** Runs a chunk of Lua code from an input stream. */ protected void runChunk(InputStream in) throws IOException { try { long start = System.nanoTime(); luaState.setTop(0); luaState.load(in, "console"); luaState.call(0, LuaState.MULTRET); long stop = System.nanoTime(); for (int i = 1; i <= luaState.getTop(); i++) { if (i > 1) { System.out.print(", "); } switch (luaState.type(i)) { case BOOLEAN: System.out.print(Boolean.valueOf(luaState.toBoolean(i))); break; case NUMBER: case STRING: System.out.print(luaState.toString(i)); break; default: System.out.print(luaState.typeName(i)); } } System.out.print("\t#msec="); System.out.print(String.format("%.3f", (stop - start) / 1000000.0)); System.out.println(); } catch (LuaRuntimeException e) { e.printLuaStackTrace(); e.printStackTrace(); } catch (LuaException e) { System.err.println(e.getMessage()); } }