@Override public CompiledScript compile(Reader script) throws ScriptException { try { InputStream is = new Utf8Encoder(script); try { final Globals g = context.globals; final LuaFunction f = g.load(script, "script").checkfunction(); return new LuajCompiledScript(f, g); } catch (LuaError lee) { throw new ScriptException(lee.getMessage()); } finally { is.close(); } } catch (Exception e) { throw new ScriptException("eval threw " + e.toString()); } }
Object eval(Globals g, Bindings b) throws ScriptException { g.setmetatable(new BindingsMetatable(b)); LuaFunction f = function; if (f.isclosure()) f = new LuaClosure(f.checkclosure().p, g); else { try { f = f.getClass().newInstance(); } catch (Exception e) { throw new ScriptException(e); } f.initupvalue1(g); } return toJava(f.invoke(LuaValue.NONE)); }