From 8156a1733f1e26e1bdda3f13366eff108ac8da46 Mon Sep 17 00:00:00 2001 From: TopchetoEU <36534413+TopchetoEU@users.noreply.github.com> Date: Wed, 10 Jan 2024 17:01:24 +0200 Subject: [PATCH] refactor: move debugging logic out of core --- .../topchetoeu/jscript/{utils/mapping => common}/VLQ.java | 2 +- src/me/topchetoeu/jscript/core/engine/debug/Debugger.java | 5 ----- src/me/topchetoeu/jscript/utils/JScriptRepl.java | 8 ++------ .../{core/engine => utils}/debug/DebugHandler.java | 2 +- .../jscript/{core/engine => utils}/debug/DebugServer.java | 4 ++-- src/me/topchetoeu/jscript/utils/debug/Debugger.java | 7 +++++++ .../{core/engine => utils}/debug/DebuggerProvider.java | 2 +- .../jscript/{core/engine => utils}/debug/HttpRequest.java | 2 +- .../{core/engine => utils}/debug/SimpleDebugger.java | 3 ++- .../jscript/{core/engine => utils}/debug/V8Error.java | 2 +- .../jscript/{core/engine => utils}/debug/V8Event.java | 2 +- .../jscript/{core/engine => utils}/debug/V8Message.java | 2 +- .../jscript/{core/engine => utils}/debug/V8Result.java | 2 +- .../jscript/{core/engine => utils}/debug/WebSocket.java | 4 ++-- .../{core/engine => utils}/debug/WebSocketMessage.java | 2 +- src/me/topchetoeu/jscript/utils/mapping/SourceMap.java | 1 + 16 files changed, 25 insertions(+), 25 deletions(-) rename src/me/topchetoeu/jscript/{utils/mapping => common}/VLQ.java (98%) delete mode 100644 src/me/topchetoeu/jscript/core/engine/debug/Debugger.java rename src/me/topchetoeu/jscript/{core/engine => utils}/debug/DebugHandler.java (95%) rename src/me/topchetoeu/jscript/{core/engine => utils}/debug/DebugServer.java (98%) create mode 100644 src/me/topchetoeu/jscript/utils/debug/Debugger.java rename src/me/topchetoeu/jscript/{core/engine => utils}/debug/DebuggerProvider.java (67%) rename src/me/topchetoeu/jscript/{core/engine => utils}/debug/HttpRequest.java (98%) rename src/me/topchetoeu/jscript/{core/engine => utils}/debug/SimpleDebugger.java (99%) rename src/me/topchetoeu/jscript/{core/engine => utils}/debug/V8Error.java (89%) rename src/me/topchetoeu/jscript/{core/engine => utils}/debug/V8Event.java (90%) rename src/me/topchetoeu/jscript/{core/engine => utils}/debug/V8Message.java (96%) rename src/me/topchetoeu/jscript/{core/engine => utils}/debug/V8Result.java (90%) rename src/me/topchetoeu/jscript/{core/engine => utils}/debug/WebSocket.java (97%) rename src/me/topchetoeu/jscript/{core/engine => utils}/debug/WebSocketMessage.java (93%) diff --git a/src/me/topchetoeu/jscript/utils/mapping/VLQ.java b/src/me/topchetoeu/jscript/common/VLQ.java similarity index 98% rename from src/me/topchetoeu/jscript/utils/mapping/VLQ.java rename to src/me/topchetoeu/jscript/common/VLQ.java index 5f49aea..249d8fd 100644 --- a/src/me/topchetoeu/jscript/utils/mapping/VLQ.java +++ b/src/me/topchetoeu/jscript/common/VLQ.java @@ -1,4 +1,4 @@ -package me.topchetoeu.jscript.utils.mapping; +package me.topchetoeu.jscript.common; import java.util.ArrayList; import java.util.List; diff --git a/src/me/topchetoeu/jscript/core/engine/debug/Debugger.java b/src/me/topchetoeu/jscript/core/engine/debug/Debugger.java deleted file mode 100644 index c920d0a..0000000 --- a/src/me/topchetoeu/jscript/core/engine/debug/Debugger.java +++ /dev/null @@ -1,5 +0,0 @@ -package me.topchetoeu.jscript.core.engine.debug; - -public interface Debugger extends DebugHandler, DebugController { - void close(); -} diff --git a/src/me/topchetoeu/jscript/utils/JScriptRepl.java b/src/me/topchetoeu/jscript/utils/JScriptRepl.java index 9fafb57..ae31fd8 100644 --- a/src/me/topchetoeu/jscript/utils/JScriptRepl.java +++ b/src/me/topchetoeu/jscript/utils/JScriptRepl.java @@ -8,21 +8,17 @@ import java.nio.file.Path; import me.topchetoeu.jscript.common.Filename; import me.topchetoeu.jscript.common.Metadata; import me.topchetoeu.jscript.common.Reading; -import me.topchetoeu.jscript.core.engine.Context; import me.topchetoeu.jscript.core.engine.Engine; import me.topchetoeu.jscript.core.engine.Environment; import me.topchetoeu.jscript.core.engine.debug.DebugContext; -import me.topchetoeu.jscript.core.engine.debug.DebugServer; -import me.topchetoeu.jscript.core.engine.debug.SimpleDebugger; -import me.topchetoeu.jscript.core.engine.values.ArrayValue; import me.topchetoeu.jscript.core.engine.values.NativeFunction; -import me.topchetoeu.jscript.core.engine.values.ObjectValue; import me.topchetoeu.jscript.core.engine.values.Values; import me.topchetoeu.jscript.core.exceptions.EngineException; import me.topchetoeu.jscript.core.exceptions.InterruptException; import me.topchetoeu.jscript.core.exceptions.SyntaxException; -import me.topchetoeu.jscript.lib.EnvironmentLib; import me.topchetoeu.jscript.lib.Internals; +import me.topchetoeu.jscript.utils.debug.DebugServer; +import me.topchetoeu.jscript.utils.debug.SimpleDebugger; import me.topchetoeu.jscript.utils.filesystem.Filesystem; import me.topchetoeu.jscript.utils.filesystem.MemoryFilesystem; import me.topchetoeu.jscript.utils.filesystem.Mode; diff --git a/src/me/topchetoeu/jscript/core/engine/debug/DebugHandler.java b/src/me/topchetoeu/jscript/utils/debug/DebugHandler.java similarity index 95% rename from src/me/topchetoeu/jscript/core/engine/debug/DebugHandler.java rename to src/me/topchetoeu/jscript/utils/debug/DebugHandler.java index 5d90310..9615f62 100644 --- a/src/me/topchetoeu/jscript/core/engine/debug/DebugHandler.java +++ b/src/me/topchetoeu/jscript/utils/debug/DebugHandler.java @@ -1,4 +1,4 @@ -package me.topchetoeu.jscript.core.engine.debug; +package me.topchetoeu.jscript.utils.debug; import java.io.IOException; diff --git a/src/me/topchetoeu/jscript/core/engine/debug/DebugServer.java b/src/me/topchetoeu/jscript/utils/debug/DebugServer.java similarity index 98% rename from src/me/topchetoeu/jscript/core/engine/debug/DebugServer.java rename to src/me/topchetoeu/jscript/utils/debug/DebugServer.java index 53e091e..8cbb631 100644 --- a/src/me/topchetoeu/jscript/core/engine/debug/DebugServer.java +++ b/src/me/topchetoeu/jscript/utils/debug/DebugServer.java @@ -1,4 +1,4 @@ -package me.topchetoeu.jscript.core.engine.debug; +package me.topchetoeu.jscript.utils.debug; import java.io.IOException; import java.io.UncheckedIOException; @@ -15,7 +15,7 @@ import me.topchetoeu.jscript.common.events.Notifier; import me.topchetoeu.jscript.common.json.JSON; import me.topchetoeu.jscript.common.json.JSONList; import me.topchetoeu.jscript.common.json.JSONMap; -import me.topchetoeu.jscript.core.engine.debug.WebSocketMessage.Type; +import me.topchetoeu.jscript.utils.debug.WebSocketMessage.Type; import me.topchetoeu.jscript.core.exceptions.SyntaxException; public class DebugServer { diff --git a/src/me/topchetoeu/jscript/utils/debug/Debugger.java b/src/me/topchetoeu/jscript/utils/debug/Debugger.java new file mode 100644 index 0000000..53c35ff --- /dev/null +++ b/src/me/topchetoeu/jscript/utils/debug/Debugger.java @@ -0,0 +1,7 @@ +package me.topchetoeu.jscript.utils.debug; + +import me.topchetoeu.jscript.core.engine.debug.DebugController; + +public interface Debugger extends DebugHandler, DebugController { + void close(); +} diff --git a/src/me/topchetoeu/jscript/core/engine/debug/DebuggerProvider.java b/src/me/topchetoeu/jscript/utils/debug/DebuggerProvider.java similarity index 67% rename from src/me/topchetoeu/jscript/core/engine/debug/DebuggerProvider.java rename to src/me/topchetoeu/jscript/utils/debug/DebuggerProvider.java index d92d174..fba409d 100644 --- a/src/me/topchetoeu/jscript/core/engine/debug/DebuggerProvider.java +++ b/src/me/topchetoeu/jscript/utils/debug/DebuggerProvider.java @@ -1,4 +1,4 @@ -package me.topchetoeu.jscript.core.engine.debug; +package me.topchetoeu.jscript.utils.debug; public interface DebuggerProvider { Debugger getDebugger(WebSocket socket, HttpRequest req); diff --git a/src/me/topchetoeu/jscript/core/engine/debug/HttpRequest.java b/src/me/topchetoeu/jscript/utils/debug/HttpRequest.java similarity index 98% rename from src/me/topchetoeu/jscript/core/engine/debug/HttpRequest.java rename to src/me/topchetoeu/jscript/utils/debug/HttpRequest.java index be924dc..4fcc42f 100644 --- a/src/me/topchetoeu/jscript/core/engine/debug/HttpRequest.java +++ b/src/me/topchetoeu/jscript/utils/debug/HttpRequest.java @@ -1,4 +1,4 @@ -package me.topchetoeu.jscript.core.engine.debug; +package me.topchetoeu.jscript.utils.debug; import java.io.BufferedReader; import java.io.IOException; diff --git a/src/me/topchetoeu/jscript/core/engine/debug/SimpleDebugger.java b/src/me/topchetoeu/jscript/utils/debug/SimpleDebugger.java similarity index 99% rename from src/me/topchetoeu/jscript/core/engine/debug/SimpleDebugger.java rename to src/me/topchetoeu/jscript/utils/debug/SimpleDebugger.java index 0bc3730..c286c9b 100644 --- a/src/me/topchetoeu/jscript/core/engine/debug/SimpleDebugger.java +++ b/src/me/topchetoeu/jscript/utils/debug/SimpleDebugger.java @@ -1,4 +1,4 @@ -package me.topchetoeu.jscript.core.engine.debug; +package me.topchetoeu.jscript.utils.debug; import java.io.IOException; import java.util.ArrayList; @@ -22,6 +22,7 @@ import me.topchetoeu.jscript.core.compilation.Instruction.Type; import me.topchetoeu.jscript.core.engine.Context; import me.topchetoeu.jscript.core.engine.Engine; import me.topchetoeu.jscript.core.engine.Environment; +import me.topchetoeu.jscript.core.engine.debug.DebugContext; import me.topchetoeu.jscript.core.engine.frame.CodeFrame; import me.topchetoeu.jscript.core.engine.scope.GlobalScope; import me.topchetoeu.jscript.core.engine.values.ArrayValue; diff --git a/src/me/topchetoeu/jscript/core/engine/debug/V8Error.java b/src/me/topchetoeu/jscript/utils/debug/V8Error.java similarity index 89% rename from src/me/topchetoeu/jscript/core/engine/debug/V8Error.java rename to src/me/topchetoeu/jscript/utils/debug/V8Error.java index 410f72d..352dc70 100644 --- a/src/me/topchetoeu/jscript/core/engine/debug/V8Error.java +++ b/src/me/topchetoeu/jscript/utils/debug/V8Error.java @@ -1,4 +1,4 @@ -package me.topchetoeu.jscript.core.engine.debug; +package me.topchetoeu.jscript.utils.debug; import me.topchetoeu.jscript.common.json.JSON; import me.topchetoeu.jscript.common.json.JSONMap; diff --git a/src/me/topchetoeu/jscript/core/engine/debug/V8Event.java b/src/me/topchetoeu/jscript/utils/debug/V8Event.java similarity index 90% rename from src/me/topchetoeu/jscript/core/engine/debug/V8Event.java rename to src/me/topchetoeu/jscript/utils/debug/V8Event.java index dc44466..4ce0a36 100644 --- a/src/me/topchetoeu/jscript/core/engine/debug/V8Event.java +++ b/src/me/topchetoeu/jscript/utils/debug/V8Event.java @@ -1,4 +1,4 @@ -package me.topchetoeu.jscript.core.engine.debug; +package me.topchetoeu.jscript.utils.debug; import me.topchetoeu.jscript.common.json.JSON; import me.topchetoeu.jscript.common.json.JSONMap; diff --git a/src/me/topchetoeu/jscript/core/engine/debug/V8Message.java b/src/me/topchetoeu/jscript/utils/debug/V8Message.java similarity index 96% rename from src/me/topchetoeu/jscript/core/engine/debug/V8Message.java rename to src/me/topchetoeu/jscript/utils/debug/V8Message.java index 3eb6c56..6d31e0d 100644 --- a/src/me/topchetoeu/jscript/core/engine/debug/V8Message.java +++ b/src/me/topchetoeu/jscript/utils/debug/V8Message.java @@ -1,4 +1,4 @@ -package me.topchetoeu.jscript.core.engine.debug; +package me.topchetoeu.jscript.utils.debug; import java.util.Map; diff --git a/src/me/topchetoeu/jscript/core/engine/debug/V8Result.java b/src/me/topchetoeu/jscript/utils/debug/V8Result.java similarity index 90% rename from src/me/topchetoeu/jscript/core/engine/debug/V8Result.java rename to src/me/topchetoeu/jscript/utils/debug/V8Result.java index ab1cab7..d28d33a 100644 --- a/src/me/topchetoeu/jscript/core/engine/debug/V8Result.java +++ b/src/me/topchetoeu/jscript/utils/debug/V8Result.java @@ -1,4 +1,4 @@ -package me.topchetoeu.jscript.core.engine.debug; +package me.topchetoeu.jscript.utils.debug; import me.topchetoeu.jscript.common.json.JSON; import me.topchetoeu.jscript.common.json.JSONMap; diff --git a/src/me/topchetoeu/jscript/core/engine/debug/WebSocket.java b/src/me/topchetoeu/jscript/utils/debug/WebSocket.java similarity index 97% rename from src/me/topchetoeu/jscript/core/engine/debug/WebSocket.java rename to src/me/topchetoeu/jscript/utils/debug/WebSocket.java index 52eb37a..d79932a 100644 --- a/src/me/topchetoeu/jscript/core/engine/debug/WebSocket.java +++ b/src/me/topchetoeu/jscript/utils/debug/WebSocket.java @@ -1,4 +1,4 @@ -package me.topchetoeu.jscript.core.engine.debug; +package me.topchetoeu.jscript.utils.debug; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -6,7 +6,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.net.Socket; -import me.topchetoeu.jscript.core.engine.debug.WebSocketMessage.Type; +import me.topchetoeu.jscript.utils.debug.WebSocketMessage.Type; public class WebSocket implements AutoCloseable { public long maxLength = 1 << 20; diff --git a/src/me/topchetoeu/jscript/core/engine/debug/WebSocketMessage.java b/src/me/topchetoeu/jscript/utils/debug/WebSocketMessage.java similarity index 93% rename from src/me/topchetoeu/jscript/core/engine/debug/WebSocketMessage.java rename to src/me/topchetoeu/jscript/utils/debug/WebSocketMessage.java index 10242b2..10d3959 100644 --- a/src/me/topchetoeu/jscript/core/engine/debug/WebSocketMessage.java +++ b/src/me/topchetoeu/jscript/utils/debug/WebSocketMessage.java @@ -1,4 +1,4 @@ -package me.topchetoeu.jscript.core.engine.debug; +package me.topchetoeu.jscript.utils.debug; public class WebSocketMessage { public static enum Type { diff --git a/src/me/topchetoeu/jscript/utils/mapping/SourceMap.java b/src/me/topchetoeu/jscript/utils/mapping/SourceMap.java index 12bea81..6f9a53d 100644 --- a/src/me/topchetoeu/jscript/utils/mapping/SourceMap.java +++ b/src/me/topchetoeu/jscript/utils/mapping/SourceMap.java @@ -6,6 +6,7 @@ import java.util.TreeMap; import java.util.stream.Collectors; import me.topchetoeu.jscript.common.Location; +import me.topchetoeu.jscript.common.VLQ; import me.topchetoeu.jscript.common.json.JSON; public class SourceMap {