class LuaScriptEngine implements IScriptEngine {

    @Override
    public Object execScript(String scriptName, Object... args) throws CallException {
        Log.v(SCRIPTS_TAG, "execScript: " + scriptName);

        LuaFunction func = this.luaFunctions.get(scriptName);

        if (func == null) {
            throw new IllegalStateException("lua script '" + scriptName + "' doesn't exists in cache, you have to compile it first!");
        }

        Log.d(SCRIPTS_TAG, "execute lua script '" + scriptName + "'");

        try {
            Object[] objs = DirectCallExecutor.newExecutor().call(state, func);

            if (objs.length > 0) {
                return objs[0];
            } else {
                //it's a void method
                return null;
            }
        } catch (CallException e) {
            Log.w(SCRIPTS_TAG, "CallException: ", e);
            throw e;
            //throw new ScriptExecutionException("CallException: " + e.getLocalizedMessage());
        } catch (CallPausedException e) {
            Log.w(SCRIPTS_TAG, "CallPausedException: ", e);
        } catch (InterruptedException e) {
            Log.w(SCRIPTS_TAG, "InterruptedException: ", e);
        }

        return null;
    }

    public  LuaScriptEngine();

}