From 5d23d37255bd2e350b98a45dbaefb587dc8a90f7 Mon Sep 17 00:00:00 2001 From: James Roseborough Date: Sun, 25 Apr 2010 06:28:31 +0000 Subject: [PATCH] Move DEBUG_ENABLED flag --- src/core/org/luaj/vm2/lib/DebugLib.java | 5 ++--- src/jse/org/luaj/vm2/lib/JsePlatform.java | 7 ++++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/core/org/luaj/vm2/lib/DebugLib.java b/src/core/org/luaj/vm2/lib/DebugLib.java index 7b515345..ae1bd5ac 100644 --- a/src/core/org/luaj/vm2/lib/DebugLib.java +++ b/src/core/org/luaj/vm2/lib/DebugLib.java @@ -103,14 +103,13 @@ public class DebugLib extends OneArgFunction { private static final LuaString ACTIVELINES = valueOf("activelines"); public DebugLib() { + DEBUG_ENABLED = true; } public LuaValue call(LuaValue arg) { LuaTable t = new LuaTable(); bindv(t, NAMES); env.set("debug", t); - if ( ! DEBUG_ENABLED ) - DEBUG_ENABLED = true; return t; } @@ -281,7 +280,7 @@ public class DebugLib extends OneArgFunction { public String toString() { return DebugLib.traceback(thread, 0); } -} + } private static DebugState getDebugState( LuaThread thread ) { if ( thread.debugState == null ) diff --git a/src/jse/org/luaj/vm2/lib/JsePlatform.java b/src/jse/org/luaj/vm2/lib/JsePlatform.java index fba07241..bb71a539 100644 --- a/src/jse/org/luaj/vm2/lib/JsePlatform.java +++ b/src/jse/org/luaj/vm2/lib/JsePlatform.java @@ -43,7 +43,6 @@ public class JsePlatform { _G.load(new TableLib()); _G.load(new StringLib()); _G.load(new CoroutineLib()); - _G.load(new DebugLib()); _G.load(new JseMathLib()); _G.load(new JseIoLib()); _G.load(new JseOsLib()); @@ -51,4 +50,10 @@ public class JsePlatform { LuaThread.setGlobals(_G); return _G; } + + public static LuaTable debugGlobals() { + LuaTable _G = standardGlobals(); + _G.load(new DebugLib()); + return _G; + } }