@tracecode/harness 0.6.6 → 0.7.0-beta8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +48 -0
- package/README.md +134 -15
- package/THIRD_PARTY_NOTICES.md +170 -0
- package/dist/browser.cjs +2361 -1033
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +33 -3
- package/dist/browser.d.ts +33 -3
- package/dist/browser.js +2357 -1033
- package/dist/browser.js.map +1 -1
- package/dist/cli.cjs +160 -23
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +161 -24
- package/dist/cli.js.map +1 -1
- package/dist/core.cjs +748 -867
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +21 -85
- package/dist/core.d.ts +21 -85
- package/dist/core.js +734 -855
- package/dist/core.js.map +1 -1
- package/dist/cpp-worker-client-Bn7kC0_L.d.ts +84 -0
- package/dist/cpp-worker-client-BzdJLuZa.d.cts +84 -0
- package/dist/cpp.cjs +1063 -0
- package/dist/cpp.cjs.map +1 -0
- package/dist/cpp.d.cts +7 -0
- package/dist/cpp.d.ts +7 -0
- package/dist/cpp.js +1035 -0
- package/dist/cpp.js.map +1 -0
- package/dist/csharp-worker-client-DMHIa2YG.d.cts +69 -0
- package/dist/csharp-worker-client-JwqS6LiX.d.ts +69 -0
- package/dist/csharp.cjs +1012 -0
- package/dist/csharp.cjs.map +1 -0
- package/dist/csharp.d.cts +7 -0
- package/dist/csharp.d.ts +7 -0
- package/dist/csharp.js +984 -0
- package/dist/csharp.js.map +1 -0
- package/dist/index.cjs +3142 -1160
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -5
- package/dist/index.d.ts +13 -5
- package/dist/index.js +3117 -1148
- package/dist/index.js.map +1 -1
- package/dist/internal/browser.cjs +1639 -30
- package/dist/internal/browser.cjs.map +1 -1
- package/dist/internal/browser.d.cts +6 -199
- package/dist/internal/browser.d.ts +6 -199
- package/dist/internal/browser.js +1636 -30
- package/dist/internal/browser.js.map +1 -1
- package/dist/java-worker-client-BOwKW-11.d.cts +72 -0
- package/dist/java-worker-client-C97DDnCp.d.ts +72 -0
- package/dist/java.cjs +1225 -0
- package/dist/java.cjs.map +1 -0
- package/dist/java.d.cts +7 -0
- package/dist/java.d.ts +7 -0
- package/dist/java.js +1197 -0
- package/dist/java.js.map +1 -0
- package/dist/javascript-worker-client-CYBGEEvc.d.cts +51 -0
- package/dist/javascript-worker-client-DIX1Mp21.d.ts +51 -0
- package/dist/javascript.cjs +1063 -19
- package/dist/javascript.cjs.map +1 -1
- package/dist/javascript.d.cts +7 -4
- package/dist/javascript.d.ts +7 -4
- package/dist/javascript.js +1061 -19
- package/dist/javascript.js.map +1 -1
- package/dist/pyodide-worker-client-C-2rfHj9.d.ts +111 -0
- package/dist/pyodide-worker-client-Cn0a8Uv3.d.cts +111 -0
- package/dist/python.cjs +1282 -74
- package/dist/python.cjs.map +1 -1
- package/dist/python.d.cts +20 -14
- package/dist/python.d.ts +20 -14
- package/dist/python.js +1279 -74
- package/dist/python.js.map +1 -1
- package/dist/runtime-language-info-BFUSti3-.d.ts +43 -0
- package/dist/runtime-language-info-Bxza1cI2.d.cts +43 -0
- package/dist/runtime-types-2qM0MukN.d.cts +244 -0
- package/dist/runtime-types-2qM0MukN.d.ts +244 -0
- package/package.json +73 -8
- package/workers/cpp/cpp-compiler-frame.html +82 -0
- package/workers/cpp/cpp-compiler-worker.js +131 -0
- package/workers/cpp/cpp-worker.js +5790 -0
- package/workers/cpp/tracecode_runtime.hpp +6169 -0
- package/workers/csharp/csharp-worker.js +301 -0
- package/workers/java/.build/classes/harness/browser/JavaRewriteLibrary.class +0 -0
- package/workers/java/java-source-augmentations.js +907 -0
- package/workers/java/java-worker.js +2161 -177
- package/workers/java/src/harness/browser/JavaRewriteLibrary.java +1659 -32
- package/workers/java/src/javafx/util/Pair.java +42 -0
- package/workers/java/src/tracecode/browser/BrowserCompileAndTraceLibrary.java +714 -0
- package/workers/java/src/tracecode/browser/BrowserCompileAndTraceMain.java +76 -0
- package/workers/java/src/tracecode/browser/RuntimeProbeMain.java +14 -0
- package/workers/java/src/tracecode/user/TraceHooks.java +1414 -0
- package/workers/javascript/javascript-libraries-entry.js +71 -0
- package/workers/javascript/javascript-worker.js +2055 -424
- package/workers/python/generated-python-harness-snippets.js +4 -4
- package/workers/python/pyodide-worker.js +222 -61
- package/workers/python/runtime-core.js +1387 -301
- package/workers/vendor/csharp/.stamp +0 -0
- package/workers/vendor/csharp/TraceCode.CSharpHost.runtimeconfig.json +32 -0
- package/workers/vendor/csharp/_framework/Microsoft.CSharp.wasm +0 -0
- package/workers/vendor/csharp/_framework/Microsoft.CodeAnalysis.CSharp.wasm +0 -0
- package/workers/vendor/csharp/_framework/Microsoft.CodeAnalysis.wasm +0 -0
- package/workers/vendor/csharp/_framework/Microsoft.VisualBasic.Core.wasm +0 -0
- package/workers/vendor/csharp/_framework/Microsoft.VisualBasic.wasm +0 -0
- package/workers/vendor/csharp/_framework/Microsoft.Win32.Primitives.wasm +0 -0
- package/workers/vendor/csharp/_framework/Microsoft.Win32.Registry.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.AppContext.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Buffers.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Collections.Concurrent.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Collections.Immutable.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Collections.NonGeneric.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Collections.Specialized.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Collections.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.ComponentModel.Annotations.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.ComponentModel.DataAnnotations.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.ComponentModel.EventBasedAsync.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.ComponentModel.Primitives.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.ComponentModel.TypeConverter.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.ComponentModel.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Configuration.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Console.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Core.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Data.Common.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Data.DataSetExtensions.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Data.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Diagnostics.Contracts.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Diagnostics.Debug.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Diagnostics.DiagnosticSource.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Diagnostics.FileVersionInfo.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Diagnostics.Process.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Diagnostics.StackTrace.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Diagnostics.TextWriterTraceListener.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Diagnostics.Tools.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Diagnostics.TraceSource.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Diagnostics.Tracing.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Drawing.Primitives.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Drawing.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Dynamic.Runtime.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Formats.Asn1.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Formats.Tar.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Globalization.Calendars.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Globalization.Extensions.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Globalization.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.Compression.Brotli.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.Compression.FileSystem.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.Compression.ZipFile.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.Compression.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.FileSystem.AccessControl.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.FileSystem.DriveInfo.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.FileSystem.Primitives.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.FileSystem.Watcher.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.FileSystem.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.IsolatedStorage.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.MemoryMappedFiles.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.Pipelines.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.Pipes.AccessControl.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.Pipes.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.UnmanagedMemoryStream.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Linq.AsyncEnumerable.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Linq.Expressions.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Linq.Parallel.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Linq.Queryable.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Linq.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Memory.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.Http.Json.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.Http.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.HttpListener.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.Mail.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.NameResolution.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.NetworkInformation.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.Ping.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.Primitives.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.Quic.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.Requests.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.Security.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.ServerSentEvents.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.ServicePoint.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.Sockets.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.WebClient.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.WebHeaderCollection.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.WebProxy.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.WebSockets.Client.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.WebSockets.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Numerics.Vectors.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Numerics.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.ObjectModel.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Private.CoreLib.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Private.DataContractSerialization.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Private.Uri.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Private.Xml.Linq.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Private.Xml.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Reflection.DispatchProxy.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Reflection.Emit.ILGeneration.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Reflection.Emit.Lightweight.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Reflection.Emit.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Reflection.Extensions.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Reflection.Metadata.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Reflection.Primitives.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Reflection.TypeExtensions.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Reflection.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Resources.Reader.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Resources.ResourceManager.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Resources.Writer.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.CompilerServices.Unsafe.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.CompilerServices.VisualC.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.Extensions.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.Handles.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.InteropServices.JavaScript.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.InteropServices.RuntimeInformation.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.InteropServices.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.Intrinsics.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.Loader.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.Numerics.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.Serialization.Formatters.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.Serialization.Json.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.Serialization.Primitives.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.Serialization.Xml.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.Serialization.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Security.AccessControl.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Security.Claims.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Security.Cryptography.Algorithms.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Security.Cryptography.Cng.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Security.Cryptography.Csp.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Security.Cryptography.Encoding.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Security.Cryptography.OpenSsl.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Security.Cryptography.Primitives.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Security.Cryptography.X509Certificates.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Security.Cryptography.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Security.Principal.Windows.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Security.Principal.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Security.SecureString.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Security.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.ServiceModel.Web.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.ServiceProcess.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Text.Encoding.CodePages.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Text.Encoding.Extensions.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Text.Encoding.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Text.Encodings.Web.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Text.Json.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Text.RegularExpressions.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Threading.AccessControl.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Threading.Channels.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Threading.Overlapped.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Threading.Tasks.Dataflow.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Threading.Tasks.Extensions.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Threading.Tasks.Parallel.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Threading.Tasks.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Threading.Thread.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Threading.ThreadPool.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Threading.Timer.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Threading.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Transactions.Local.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Transactions.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.ValueTuple.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Web.HttpUtility.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Web.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Windows.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Xml.Linq.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Xml.ReaderWriter.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Xml.Serialization.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Xml.XDocument.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Xml.XPath.XDocument.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Xml.XPath.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Xml.XmlDocument.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Xml.XmlSerializer.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Xml.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.wasm +0 -0
- package/workers/vendor/csharp/_framework/TraceCode.CSharpHost.wasm +0 -0
- package/workers/vendor/csharp/_framework/WindowsBase.wasm +0 -0
- package/workers/vendor/csharp/_framework/cs/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/cs/Microsoft.CodeAnalysis.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/de/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/de/Microsoft.CodeAnalysis.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/dotnet.boot.js +1958 -0
- package/workers/vendor/csharp/_framework/dotnet.js +4 -0
- package/workers/vendor/csharp/_framework/dotnet.js.map +1 -0
- package/workers/vendor/csharp/_framework/dotnet.native.js +6687 -0
- package/workers/vendor/csharp/_framework/dotnet.native.wasm +0 -0
- package/workers/vendor/csharp/_framework/dotnet.runtime.js +4 -0
- package/workers/vendor/csharp/_framework/dotnet.runtime.js.map +1 -0
- package/workers/vendor/csharp/_framework/es/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/es/Microsoft.CodeAnalysis.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/fr/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/fr/Microsoft.CodeAnalysis.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/it/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/it/Microsoft.CodeAnalysis.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/ja/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/ja/Microsoft.CodeAnalysis.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/ko/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/ko/Microsoft.CodeAnalysis.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/mscorlib.wasm +0 -0
- package/workers/vendor/csharp/_framework/netstandard.wasm +0 -0
- package/workers/vendor/csharp/_framework/pl/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/pl/Microsoft.CodeAnalysis.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/pt-BR/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/pt-BR/Microsoft.CodeAnalysis.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/ru/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/ru/Microsoft.CodeAnalysis.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/0_Microsoft.CodeAnalysis.CSharp.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/100_System.Reflection.Emit.ILGeneration.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/101_System.Reflection.Emit.Lightweight.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/102_System.Reflection.Extensions.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/103_System.Reflection.Metadata.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/104_System.Reflection.Primitives.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/105_System.Reflection.TypeExtensions.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/106_System.Resources.Reader.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/107_System.Resources.ResourceManager.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/108_System.Resources.Writer.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/109_System.Runtime.CompilerServices.Unsafe.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/10_System.Buffers.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/110_System.Runtime.CompilerServices.VisualC.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/111_System.Runtime.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/112_System.Runtime.Extensions.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/113_System.Runtime.Handles.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/114_System.Runtime.InteropServices.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/115_System.Runtime.InteropServices.JavaScript.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/116_System.Runtime.InteropServices.RuntimeInformation.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/117_System.Runtime.Intrinsics.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/118_System.Runtime.Loader.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/119_System.Runtime.Numerics.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/11_System.Collections.Concurrent.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/120_System.Runtime.Serialization.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/121_System.Runtime.Serialization.Formatters.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/122_System.Runtime.Serialization.Json.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/123_System.Runtime.Serialization.Primitives.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/124_System.Runtime.Serialization.Xml.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/125_System.Security.AccessControl.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/126_System.Security.Claims.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/127_System.Security.Cryptography.Algorithms.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/128_System.Security.Cryptography.Cng.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/129_System.Security.Cryptography.Csp.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/12_System.Collections.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/130_System.Security.Cryptography.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/131_System.Security.Cryptography.Encoding.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/132_System.Security.Cryptography.OpenSsl.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/133_System.Security.Cryptography.Primitives.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/134_System.Security.Cryptography.X509Certificates.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/135_System.Security.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/136_System.Security.Principal.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/137_System.Security.Principal.Windows.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/138_System.Security.SecureString.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/139_System.ServiceModel.Web.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/13_System.Collections.Immutable.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/140_System.ServiceProcess.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/141_System.Text.Encoding.CodePages.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/142_System.Text.Encoding.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/143_System.Text.Encoding.Extensions.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/144_System.Text.Encodings.Web.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/145_System.Text.Json.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/146_System.Text.RegularExpressions.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/147_System.Threading.AccessControl.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/148_System.Threading.Channels.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/149_System.Threading.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/14_System.Collections.NonGeneric.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/150_System.Threading.Overlapped.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/151_System.Threading.Tasks.Dataflow.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/152_System.Threading.Tasks.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/153_System.Threading.Tasks.Extensions.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/154_System.Threading.Tasks.Parallel.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/155_System.Threading.Thread.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/156_System.Threading.ThreadPool.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/157_System.Threading.Timer.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/158_System.Transactions.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/159_System.Transactions.Local.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/15_System.Collections.Specialized.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/160_System.ValueTuple.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/161_System.Web.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/162_System.Web.HttpUtility.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/163_System.Windows.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/164_System.Xml.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/165_System.Xml.Linq.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/166_System.Xml.ReaderWriter.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/167_System.Xml.Serialization.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/168_System.Xml.XDocument.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/169_System.Xml.XmlDocument.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/16_System.ComponentModel.Annotations.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/170_System.Xml.XmlSerializer.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/171_System.Xml.XPath.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/172_System.Xml.XPath.XDocument.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/173_TraceCode.CSharpHost.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/174_WindowsBase.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/17_System.ComponentModel.DataAnnotations.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/18_System.ComponentModel.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/19_System.ComponentModel.EventBasedAsync.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/1_Microsoft.CodeAnalysis.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/20_System.ComponentModel.Primitives.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/21_System.ComponentModel.TypeConverter.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/22_System.Configuration.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/23_System.Console.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/24_System.Core.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/25_System.Data.Common.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/26_System.Data.DataSetExtensions.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/27_System.Data.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/28_System.Diagnostics.Contracts.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/29_System.Diagnostics.Debug.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/2_Microsoft.CSharp.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/30_System.Diagnostics.DiagnosticSource.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/31_System.Diagnostics.FileVersionInfo.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/32_System.Diagnostics.Process.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/33_System.Diagnostics.StackTrace.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/34_System.Diagnostics.TextWriterTraceListener.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/35_System.Diagnostics.Tools.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/36_System.Diagnostics.TraceSource.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/37_System.Diagnostics.Tracing.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/38_System.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/39_System.Drawing.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/3_Microsoft.VisualBasic.Core.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/40_System.Drawing.Primitives.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/41_System.Dynamic.Runtime.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/42_System.Formats.Asn1.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/43_System.Formats.Tar.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/44_System.Globalization.Calendars.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/45_System.Globalization.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/46_System.Globalization.Extensions.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/47_System.IO.Compression.Brotli.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/48_System.IO.Compression.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/49_System.IO.Compression.FileSystem.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/4_Microsoft.VisualBasic.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/50_System.IO.Compression.ZipFile.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/51_System.IO.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/52_System.IO.FileSystem.AccessControl.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/53_System.IO.FileSystem.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/54_System.IO.FileSystem.DriveInfo.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/55_System.IO.FileSystem.Primitives.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/56_System.IO.FileSystem.Watcher.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/57_System.IO.IsolatedStorage.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/58_System.IO.MemoryMappedFiles.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/59_System.IO.Pipelines.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/5_Microsoft.Win32.Primitives.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/60_System.IO.Pipes.AccessControl.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/61_System.IO.Pipes.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/62_System.IO.UnmanagedMemoryStream.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/63_System.Linq.AsyncEnumerable.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/64_System.Linq.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/65_System.Linq.Expressions.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/66_System.Linq.Parallel.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/67_System.Linq.Queryable.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/68_System.Memory.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/69_System.Net.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/6_Microsoft.Win32.Registry.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/70_System.Net.Http.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/71_System.Net.Http.Json.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/72_System.Net.HttpListener.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/73_System.Net.Mail.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/74_System.Net.NameResolution.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/75_System.Net.NetworkInformation.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/76_System.Net.Ping.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/77_System.Net.Primitives.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/78_System.Net.Quic.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/79_System.Net.Requests.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/7_mscorlib.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/80_System.Net.Security.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/81_System.Net.ServerSentEvents.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/82_System.Net.ServicePoint.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/83_System.Net.Sockets.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/84_System.Net.WebClient.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/85_System.Net.WebHeaderCollection.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/86_System.Net.WebProxy.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/87_System.Net.WebSockets.Client.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/88_System.Net.WebSockets.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/89_System.Numerics.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/8_netstandard.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/90_System.Numerics.Vectors.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/91_System.ObjectModel.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/92_System.Private.CoreLib.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/93_System.Private.DataContractSerialization.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/94_System.Private.Uri.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/95_System.Private.Xml.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/96_System.Private.Xml.Linq.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/97_System.Reflection.DispatchProxy.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/98_System.Reflection.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/99_System.Reflection.Emit.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/9_System.AppContext.dll +0 -0
- package/workers/vendor/csharp/_framework/tr/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/tr/Microsoft.CodeAnalysis.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/zh-Hans/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/zh-Hans/Microsoft.CodeAnalysis.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/zh-Hant/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/zh-Hant/Microsoft.CodeAnalysis.resources.wasm +0 -0
- package/workers/vendor/csharp/main.mjs +5 -0
- package/workers/vendor/csharp/package.json +1 -0
- package/workers/vendor/java-browser-helper.jar +0 -0
- package/workers/vendor/java-rewriter.jar +0 -0
- package/workers/vendor/javascript-libraries.js +10106 -0
- package/dist/runtime-types-89nchXlY.d.cts +0 -89
- package/dist/runtime-types-CCQ-ZLc9.d.ts +0 -89
- package/dist/types-zyvpJKCi.d.cts +0 -100
- package/dist/types-zyvpJKCi.d.ts +0 -100
- package/workers/java/java-source-augmentations.cjs +0 -242
- package/workers/java/src/spike/user/TraceHooks.java +0 -619
- package/workers/vendor/java-browser-spike-helper.jar +0 -0
- package/workers/vendor/java-practice-rewriter.jar +0 -0
- package/workers/vendor/java-rewrite-bridge.jar +0 -0
|
@@ -0,0 +1,907 @@
|
|
|
1
|
+
(function initTraceCodeJavaSourceAugmentations(root) {
|
|
2
|
+
function escapeRegExp(value) {
|
|
3
|
+
return String(value).replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
function parseNativeTraceLine(line) {
|
|
7
|
+
const match = line.match(/TraceHooks\.[A-Za-z0-9_]+AtLine\((\d+)\b/);
|
|
8
|
+
if (!match) return null;
|
|
9
|
+
const lineNumber = Number.parseInt(match[1], 10);
|
|
10
|
+
return Number.isFinite(lineNumber) && lineNumber > 0 ? lineNumber : null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function javaBraceCounts(line) {
|
|
14
|
+
let open = 0;
|
|
15
|
+
let close = 0;
|
|
16
|
+
let quote = null;
|
|
17
|
+
let escaped = false;
|
|
18
|
+
for (let index = 0; index < line.length; index += 1) {
|
|
19
|
+
const ch = line[index];
|
|
20
|
+
const next = line[index + 1] ?? '';
|
|
21
|
+
if (escaped) {
|
|
22
|
+
escaped = false;
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
if (quote) {
|
|
26
|
+
if (ch === '\\') {
|
|
27
|
+
escaped = true;
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (ch === quote) quote = null;
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
if (ch === '/' && next === '/') break;
|
|
34
|
+
if (ch === '/' && next === '*') {
|
|
35
|
+
const end = line.indexOf('*/', index + 2);
|
|
36
|
+
if (end === -1) break;
|
|
37
|
+
index = end + 1;
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (ch === '"' || ch === "'") {
|
|
41
|
+
quote = ch;
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (ch === '{') open += 1;
|
|
45
|
+
if (ch === '}') close += 1;
|
|
46
|
+
}
|
|
47
|
+
return { open, close, delta: open - close };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function braceDelta(line) {
|
|
51
|
+
return javaBraceCounts(line).delta;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function collectJavaCollectionDeclarations(line) {
|
|
55
|
+
const collections = {
|
|
56
|
+
maps: [],
|
|
57
|
+
sets: [],
|
|
58
|
+
lists: [],
|
|
59
|
+
queues: [],
|
|
60
|
+
adjacencyLists: [],
|
|
61
|
+
arrays: [],
|
|
62
|
+
};
|
|
63
|
+
const declarationPattern =
|
|
64
|
+
/\b((?:java\.util\.)?(?:HashMap|LinkedHashMap|TreeMap|Map|HashSet|LinkedHashSet|TreeSet|Set|ArrayList|LinkedList|List|ArrayDeque|Deque|Queue)(?!\.)\s*(?:<[^;=(){}]+?>)?)\s+([A-Za-z_][A-Za-z0-9_]*)\b/g;
|
|
65
|
+
for (const match of line.matchAll(declarationPattern)) {
|
|
66
|
+
const rawType = match[1] ?? '';
|
|
67
|
+
const typeSource = rawType.replace(/\s+/g, '');
|
|
68
|
+
const outerType = typeSource.replace(/<.*$/, '').replace(/^java\.util\./, '');
|
|
69
|
+
const name = match[2];
|
|
70
|
+
if (!name) continue;
|
|
71
|
+
if (/^(?:HashMap|LinkedHashMap|TreeMap|Map)$/.test(outerType)) {
|
|
72
|
+
collections.maps.push(name);
|
|
73
|
+
} else if (/^(?:HashSet|LinkedHashSet|TreeSet|Set)$/.test(outerType)) {
|
|
74
|
+
collections.sets.push(name);
|
|
75
|
+
} else if (
|
|
76
|
+
/^(?:ArrayList|LinkedList|List)$/.test(outerType) &&
|
|
77
|
+
/<\s*(?:java\.util\.)?(?:List|ArrayList|LinkedList)\s*</.test(rawType)
|
|
78
|
+
) {
|
|
79
|
+
collections.adjacencyLists.push(name);
|
|
80
|
+
} else if (/^(?:ArrayDeque|Deque|Queue)$/.test(outerType)) {
|
|
81
|
+
collections.lists.push(name);
|
|
82
|
+
collections.queues.push(name);
|
|
83
|
+
} else if (/^(?:ArrayList|LinkedList|List)$/.test(outerType)) {
|
|
84
|
+
collections.lists.push(name);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const arrayDeclarationPattern =
|
|
88
|
+
/\b(?:boolean|byte|char|short|int|long|float|double|String|Object|[A-Za-z_][A-Za-z0-9_<>.?]*)\s*(?:\[\s*\]\s*)+\s+([A-Za-z_][A-Za-z0-9_]*)\b/g;
|
|
89
|
+
for (const match of line.matchAll(arrayDeclarationPattern)) {
|
|
90
|
+
const name = match[1];
|
|
91
|
+
if (name) collections.arrays.push(name);
|
|
92
|
+
}
|
|
93
|
+
return collections;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function isLastListIndexExpression(source, receiverName) {
|
|
97
|
+
const normalized = String(source).replace(/\s+/g, '');
|
|
98
|
+
const escaped = escapeRegExp(receiverName);
|
|
99
|
+
return new RegExp(`^${escaped}\\.size\\(\\)-1$`).test(normalized);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function isSimpleIdentifierExpression(source) {
|
|
103
|
+
return /^[A-Za-z_][A-Za-z0-9_]*$/.test(String(source).trim());
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function singleIdentifierIndexSource(source) {
|
|
107
|
+
const identifiers = Array.from(String(source).matchAll(/[A-Za-z_][A-Za-z0-9_]*/g), (match) => match[0]);
|
|
108
|
+
const unique = Array.from(new Set(identifiers.filter((name) => name !== 'TraceHooks')));
|
|
109
|
+
if (unique.length !== 1) return null;
|
|
110
|
+
const stripped = String(source)
|
|
111
|
+
.replace(/[A-Za-z_][A-Za-z0-9_]*/g, '')
|
|
112
|
+
.replace(/[0-9]+/g, '')
|
|
113
|
+
.replace(/[+\-*/%() \t]/g, '');
|
|
114
|
+
return stripped.length === 0 ? unique[0] : null;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function safeIndexSourceExpression(source) {
|
|
118
|
+
const value = String(source).trim().replace(/\s+/g, ' ');
|
|
119
|
+
if (!value) return null;
|
|
120
|
+
if (!/[A-Za-z_][A-Za-z0-9_]*/.test(value)) return null;
|
|
121
|
+
if (/^[A-Za-z_][A-Za-z0-9_]*$/.test(value)) return value;
|
|
122
|
+
if (/^[A-Za-z_][A-Za-z0-9_]*\s*\[[^\]]+\]\s*$/.test(value)) return value.replace(/\s+/g, '');
|
|
123
|
+
if (/^[A-Za-z_][A-Za-z0-9_]*(?:\.[A-Za-z_][A-Za-z0-9_]*\(\))+(?:\s*[+\-*/%]\s*[0-9]+)?$/.test(value)) {
|
|
124
|
+
return value;
|
|
125
|
+
}
|
|
126
|
+
const stripped = value
|
|
127
|
+
.replace(/[A-Za-z_][A-Za-z0-9_]*/g, '')
|
|
128
|
+
.replace(/[0-9]+/g, '')
|
|
129
|
+
.replace(/[+\-*/%() \t]/g, '');
|
|
130
|
+
return stripped.length === 0 ? value : null;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function indexSourceArgument(source) {
|
|
134
|
+
const value = String(source).trim();
|
|
135
|
+
const tracedReadSource = tracedIndexedReadSource(value);
|
|
136
|
+
if (tracedReadSource) return JSON.stringify(tracedReadSource);
|
|
137
|
+
const charAtIndexMatch = value.match(/^[A-Za-z_][A-Za-z0-9_]*\.charAt\(\s*([\s\S]+)\s*\)$/);
|
|
138
|
+
if (charAtIndexMatch?.[1]) {
|
|
139
|
+
const charAtSource = safeIndexSourceExpression(charAtIndexMatch[1]) ?? singleIdentifierIndexSource(charAtIndexMatch[1]);
|
|
140
|
+
if (charAtSource) return JSON.stringify(charAtSource);
|
|
141
|
+
}
|
|
142
|
+
const expressionSource = safeIndexSourceExpression(value) ?? singleIdentifierIndexSource(value);
|
|
143
|
+
if (expressionSource) return JSON.stringify(expressionSource);
|
|
144
|
+
return isSimpleIdentifierExpression(value) ? JSON.stringify(value) : 'null';
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function tracedIndexedReadSource(source) {
|
|
148
|
+
const value = String(source).trim();
|
|
149
|
+
if (!value.startsWith('TraceHooks.read')) return null;
|
|
150
|
+
const open = value.indexOf('(');
|
|
151
|
+
if (open < 0 || !value.endsWith(')')) return null;
|
|
152
|
+
const args = splitTopLevelJavaList(value.slice(open + 1, -1));
|
|
153
|
+
if (args.length < 2) return null;
|
|
154
|
+
const name = String(args[1]).trim().match(/^"([A-Za-z_][A-Za-z0-9_]*)"$/)?.[1];
|
|
155
|
+
if (!name) return null;
|
|
156
|
+
const explicitSource = String(args[args.length - 1] ?? '').trim().match(/^"([^"]+)"$/)?.[1];
|
|
157
|
+
return explicitSource || name;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function indexSourceArgumentSourceFirst(source) {
|
|
161
|
+
const value = String(source).trim();
|
|
162
|
+
const tracedIndexedRead = value.match(/^TraceHooks\.read[A-Za-z0-9_]*AtLine\(\s*\d+\s*,\s*"([A-Za-z_][A-Za-z0-9_]*)"\s*,[\s\S]*,\s*"([^"]+)"\s*\)$/);
|
|
163
|
+
if (tracedIndexedRead?.[1] && tracedIndexedRead?.[2]) {
|
|
164
|
+
return JSON.stringify(`${tracedIndexedRead[1]}[${tracedIndexedRead[2]}]`);
|
|
165
|
+
}
|
|
166
|
+
return indexSourceArgument(value);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function rewriteEnhancedForIterationBind(line, lineNumber, currentMethod) {
|
|
170
|
+
const typePattern = '((?:final\\s+)?(?:boolean|byte|char|short|int|long|float|double|String|Object|[A-Za-z_][A-Za-z0-9_<>.?]*(?:\\s*<[^,;=(){}:]+>)?)\\s*(?:\\[\\s*\\])*)';
|
|
171
|
+
const tracedListReadPattern = new RegExp(
|
|
172
|
+
`\\bfor\\s*\\(\\s*${typePattern}\\s+([A-Za-z_][A-Za-z0-9_]*)\\s*:\\s*(TraceHooks\\.read(?:Object)?ListAtLine\\(\\s*\\d+\\s*,\\s*"([A-Za-z_][A-Za-z0-9_]*)"\\s*,\\s*([A-Za-z_][A-Za-z0-9_]*)\\s*,\\s*([^,]+)\\s*,\\s*([^)]+)\\))\\s*\\)`,
|
|
173
|
+
'g'
|
|
174
|
+
);
|
|
175
|
+
const withTracedListBindings = String(line).replace(
|
|
176
|
+
tracedListReadPattern,
|
|
177
|
+
(match, typeSource, bindingName, source, sourceName, receiverName, indexExpression, indexSource) => {
|
|
178
|
+
if (sourceName !== receiverName) return match;
|
|
179
|
+
if (
|
|
180
|
+
currentMethod.lists.has(sourceName) ||
|
|
181
|
+
currentMethod.adjacencyLists.has(sourceName)
|
|
182
|
+
) {
|
|
183
|
+
return `for (${typeSource} ${bindingName} : TraceHooks.iterationBindAtLine(${lineNumber}, "${sourceName}", ${String(indexExpression).trim()}, ${source}, "${bindingName}", ${String(indexSource).trim()}))`;
|
|
184
|
+
}
|
|
185
|
+
return match;
|
|
186
|
+
}
|
|
187
|
+
);
|
|
188
|
+
return withTracedListBindings.replace(
|
|
189
|
+
/\bfor\s*\(\s*((?:final\s+)?(?:boolean|byte|char|short|int|long|float|double|String|Object|[A-Za-z_][A-Za-z0-9_<>.?]*(?:\s*<[^,;=(){}:]+>)?)\s*(?:\[\s*\])*)\s+([A-Za-z_][A-Za-z0-9_]*)\s*:\s*([^)]+?)\s*\)/g,
|
|
190
|
+
(match, typeSource, bindingName, sourceExpression) => {
|
|
191
|
+
const source = String(sourceExpression).trim();
|
|
192
|
+
if (!bindingName || !source || source.startsWith('__tracecode')) return match;
|
|
193
|
+
const indexedSource = source.match(/^([A-Za-z_][A-Za-z0-9_]*)\.get\(([^()]+)\)$/);
|
|
194
|
+
if (indexedSource) {
|
|
195
|
+
const sourceName = indexedSource[1];
|
|
196
|
+
const indexExpression = String(indexedSource[2]).trim();
|
|
197
|
+
if (
|
|
198
|
+
currentMethod.lists.has(sourceName) ||
|
|
199
|
+
currentMethod.adjacencyLists.has(sourceName)
|
|
200
|
+
) {
|
|
201
|
+
return `for (${typeSource} ${bindingName} : TraceHooks.iterationBindAtLine(${lineNumber}, "${sourceName}", ${indexExpression}, ${source}, "${bindingName}", ${indexSourceArgument(indexExpression)}))`;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
const tracedListRead = source.match(/^TraceHooks\.readListAtLine\(\s*\d+\s*,\s*"([A-Za-z_][A-Za-z0-9_]*)"\s*,\s*\1\s*,\s*([^,]+)\s*,\s*([^)]+)\)$/);
|
|
205
|
+
if (tracedListRead) {
|
|
206
|
+
const sourceName = tracedListRead[1];
|
|
207
|
+
const indexExpression = String(tracedListRead[2]).trim();
|
|
208
|
+
const indexSource = String(tracedListRead[3]).trim();
|
|
209
|
+
if (
|
|
210
|
+
currentMethod.lists.has(sourceName) ||
|
|
211
|
+
currentMethod.adjacencyLists.has(sourceName)
|
|
212
|
+
) {
|
|
213
|
+
return `for (${typeSource} ${bindingName} : TraceHooks.iterationBindAtLine(${lineNumber}, "${sourceName}", ${indexExpression}, ${source}, "${bindingName}", ${indexSource}))`;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
const sourceName = source;
|
|
217
|
+
if (
|
|
218
|
+
!currentMethod.lists.has(sourceName) &&
|
|
219
|
+
!currentMethod.adjacencyLists.has(sourceName) &&
|
|
220
|
+
!currentMethod.sets.has(sourceName) &&
|
|
221
|
+
!currentMethod.maps.has(sourceName) &&
|
|
222
|
+
!currentMethod.arrays.has(sourceName)
|
|
223
|
+
) {
|
|
224
|
+
return match;
|
|
225
|
+
}
|
|
226
|
+
return `for (${typeSource} ${bindingName} : TraceHooks.iterationBindAtLine(${lineNumber}, "${sourceName}", ${sourceName}, "${bindingName}"))`;
|
|
227
|
+
}
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function escapedIndexSourcesTargetSegment(...sources) {
|
|
232
|
+
return `,\\"indexSources\\":[${sources
|
|
233
|
+
.map((source) => {
|
|
234
|
+
const value = String(source).trim();
|
|
235
|
+
return isSimpleIdentifierExpression(value) ? `\\"${value}\\"` : 'null';
|
|
236
|
+
})
|
|
237
|
+
.join(',')}]`;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function splitFirstTopLevelJavaArgument(argsSource) {
|
|
241
|
+
let depth = 0;
|
|
242
|
+
let inString = false;
|
|
243
|
+
let inChar = false;
|
|
244
|
+
let escaped = false;
|
|
245
|
+
for (let index = 0; index < argsSource.length; index += 1) {
|
|
246
|
+
const ch = argsSource[index];
|
|
247
|
+
if (escaped) {
|
|
248
|
+
escaped = false;
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
if (ch === '\\') {
|
|
252
|
+
escaped = true;
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
255
|
+
if (inString) {
|
|
256
|
+
if (ch === '"') inString = false;
|
|
257
|
+
continue;
|
|
258
|
+
}
|
|
259
|
+
if (inChar) {
|
|
260
|
+
if (ch === "'") inChar = false;
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
if (ch === '"') {
|
|
264
|
+
inString = true;
|
|
265
|
+
continue;
|
|
266
|
+
}
|
|
267
|
+
if (ch === "'") {
|
|
268
|
+
inChar = true;
|
|
269
|
+
continue;
|
|
270
|
+
}
|
|
271
|
+
if (ch === '(' || ch === '[' || ch === '{' || ch === '<') depth += 1;
|
|
272
|
+
if (ch === ')' || ch === ']' || ch === '}' || ch === '>') depth -= 1;
|
|
273
|
+
if (ch === ',' && depth === 0) {
|
|
274
|
+
return [argsSource.slice(0, index).trim(), argsSource.slice(index + 1).trim()];
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return null;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
function splitTopLevelJavaList(value) {
|
|
281
|
+
const parts = [];
|
|
282
|
+
let start = 0;
|
|
283
|
+
let parenDepth = 0;
|
|
284
|
+
let bracketDepth = 0;
|
|
285
|
+
let braceDepth = 0;
|
|
286
|
+
let angleDepth = 0;
|
|
287
|
+
let quote = null;
|
|
288
|
+
let escaped = false;
|
|
289
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
290
|
+
const ch = value[index];
|
|
291
|
+
if (escaped) {
|
|
292
|
+
escaped = false;
|
|
293
|
+
continue;
|
|
294
|
+
}
|
|
295
|
+
if (ch === '\\') {
|
|
296
|
+
escaped = true;
|
|
297
|
+
continue;
|
|
298
|
+
}
|
|
299
|
+
if (quote) {
|
|
300
|
+
if (ch === quote) quote = null;
|
|
301
|
+
continue;
|
|
302
|
+
}
|
|
303
|
+
if (ch === '"' || ch === "'") {
|
|
304
|
+
quote = ch;
|
|
305
|
+
continue;
|
|
306
|
+
}
|
|
307
|
+
if (ch === '(') parenDepth += 1;
|
|
308
|
+
if (ch === ')') parenDepth = Math.max(0, parenDepth - 1);
|
|
309
|
+
if (ch === '[') bracketDepth += 1;
|
|
310
|
+
if (ch === ']') bracketDepth = Math.max(0, bracketDepth - 1);
|
|
311
|
+
if (ch === '{') braceDepth += 1;
|
|
312
|
+
if (ch === '}') braceDepth = Math.max(0, braceDepth - 1);
|
|
313
|
+
if (ch === '<') angleDepth += 1;
|
|
314
|
+
if (ch === '>') angleDepth = Math.max(0, angleDepth - 1);
|
|
315
|
+
if (ch === ',' && parenDepth === 0 && bracketDepth === 0 && braceDepth === 0 && angleDepth === 0) {
|
|
316
|
+
parts.push(value.slice(start, index).trim());
|
|
317
|
+
start = index + 1;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
const tail = value.slice(start).trim();
|
|
321
|
+
if (tail.length > 0) parts.push(tail);
|
|
322
|
+
return parts;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
function parseJavaParameterNames(parametersSource) {
|
|
326
|
+
return splitTopLevelJavaList(parametersSource)
|
|
327
|
+
.map((parameter) => parameter.replace(/@\w+(?:\([^)]*\))?/g, '').replace(/\bfinal\b/g, '').trim())
|
|
328
|
+
.map((parameter) => parameter.match(/([A-Za-z_][A-Za-z0-9_]*)\s*(?:\.\.\.)?$/)?.[1] ?? '')
|
|
329
|
+
.filter((name) => name.length > 0);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
function augmentTraceCallArgumentSnapshots(source) {
|
|
333
|
+
const lines = source.split('\n');
|
|
334
|
+
const methodStack = [];
|
|
335
|
+
const methodStartPattern =
|
|
336
|
+
/^(\s*)(?:(?:public|private|protected|static|final|synchronized)\s+)*(?:[A-Za-z_][A-Za-z0-9_<>\[\], ?]*\s+)+([A-Za-z_][A-Za-z0-9_]*)\s*\(([^)]*)\)\s*\{\s*$/;
|
|
337
|
+
|
|
338
|
+
return lines.map((line) => {
|
|
339
|
+
const methodMatch = line.match(methodStartPattern);
|
|
340
|
+
if (methodMatch) {
|
|
341
|
+
methodStack.push({
|
|
342
|
+
name: methodMatch[2],
|
|
343
|
+
params: parseJavaParameterNames(methodMatch[3] ?? ''),
|
|
344
|
+
depth: 1,
|
|
345
|
+
patchedCall: false,
|
|
346
|
+
});
|
|
347
|
+
return line;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
const currentMethod = methodStack[methodStack.length - 1];
|
|
351
|
+
let nextLine = line;
|
|
352
|
+
if (currentMethod && !currentMethod.patchedCall && currentMethod.params.length > 0) {
|
|
353
|
+
const callPattern = new RegExp(
|
|
354
|
+
`^(\\s*)TraceHooks\\.emitCallAtLine\\((\\d+),\\s*"${escapeRegExp(currentMethod.name)}",\\s*([^)]*)\\);\\s*$`
|
|
355
|
+
);
|
|
356
|
+
const callMatch = line.match(callPattern);
|
|
357
|
+
if (callMatch) {
|
|
358
|
+
const serializedArgs = currentMethod.params
|
|
359
|
+
.map((paramName) => ` + " ${paramName}=" + TraceHooks.serializeResult(${paramName})`)
|
|
360
|
+
.join('');
|
|
361
|
+
nextLine = `${callMatch[1]}TraceHooks.emitCallAtLine(${callMatch[2]}, "${currentMethod.name}", ""${serializedArgs});`;
|
|
362
|
+
currentMethod.patchedCall = true;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
if (currentMethod) {
|
|
367
|
+
currentMethod.depth += braceDelta(nextLine);
|
|
368
|
+
while (methodStack.length > 0 && methodStack[methodStack.length - 1].depth <= 0) {
|
|
369
|
+
methodStack.pop();
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
return nextLine;
|
|
374
|
+
}).join('\n');
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
function collectJavaLocalDeclarations(line) {
|
|
378
|
+
const names = [];
|
|
379
|
+
const trimmedLine = String(line).trim();
|
|
380
|
+
if (trimmedLine.startsWith('//') || trimmedLine.startsWith('/*') || trimmedLine.startsWith('*')) return names;
|
|
381
|
+
const declarationPattern =
|
|
382
|
+
/\b(?:final\s+)?((?:boolean|byte|char|short|int|long|float|double|String|Object|[A-Za-z_][A-Za-z0-9_<>.?]*(?:\s*<[^,;=(){}:]+>)?)\s*(?:\[\s*\])*)\s+([A-Za-z_][A-Za-z0-9_]*)\s*(?==)/g;
|
|
383
|
+
const skippedNames = new Set(['class', 'interface', 'enum', 'record', 'return', 'new']);
|
|
384
|
+
for (const match of line.matchAll(declarationPattern)) {
|
|
385
|
+
const name = match[2];
|
|
386
|
+
if (name && !skippedNames.has(name) && !name.startsWith('__tracecode')) names.push(name);
|
|
387
|
+
}
|
|
388
|
+
const enhancedForMatch = line.match(
|
|
389
|
+
/\bfor\s*\(\s*(?:final\s+)?((?:boolean|byte|char|short|int|long|float|double|String|Object|[A-Za-z_][A-Za-z0-9_<>.?]*(?:\s*<[^,;=(){}:]+>)?)\s*(?:\[\s*\])*)\s+([A-Za-z_][A-Za-z0-9_]*)\s*:/
|
|
390
|
+
);
|
|
391
|
+
const enhancedForName = enhancedForMatch?.[2];
|
|
392
|
+
if (enhancedForName && !skippedNames.has(enhancedForName) && !enhancedForName.startsWith('__tracecode')) {
|
|
393
|
+
names.push(enhancedForName);
|
|
394
|
+
}
|
|
395
|
+
return names;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
function visibleJavaLocalNames(scopeStack) {
|
|
399
|
+
const names = [];
|
|
400
|
+
const seen = new Set();
|
|
401
|
+
for (const scope of scopeStack) {
|
|
402
|
+
for (const name of scope.names) {
|
|
403
|
+
if (!seen.has(name)) {
|
|
404
|
+
names.push(name);
|
|
405
|
+
seen.add(name);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
return names;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
function isUnbracedForDeclarationLine(line) {
|
|
413
|
+
return /^\s*for\s*\(/.test(line) && !(line.includes('{'));
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
function isControlHeaderDeclarationLine(line) {
|
|
417
|
+
return /^\s*(?:for|if|while|switch|catch)\s*\(/.test(line);
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
function traceEmitAlreadyIncludesVariable(emitExpression, name) {
|
|
421
|
+
return new RegExp(`\\b${escapeRegExp(name)}=`).test(emitExpression);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
function appendJavaLocalSnapshotsToEmitLine(line, scopeStack) {
|
|
425
|
+
const visibleNames = visibleJavaLocalNames(scopeStack);
|
|
426
|
+
if (visibleNames.length === 0 || !line.includes('TraceHooks.emitLineAtLine(')) return line;
|
|
427
|
+
|
|
428
|
+
return line.replace(/TraceHooks\.emitLineAtLine\((\d+)(?:,\s*([^;]*?))?\);/g, (match, lineNumber, snapshotExpression) => {
|
|
429
|
+
const emitExpression = snapshotExpression ?? '';
|
|
430
|
+
const additions = visibleNames
|
|
431
|
+
.filter((name) => !traceEmitAlreadyIncludesVariable(emitExpression, name))
|
|
432
|
+
.map((name) => ` + " ${name}=" + TraceHooks.serializeResult(${name})`)
|
|
433
|
+
.join('');
|
|
434
|
+
if (!additions) return match;
|
|
435
|
+
const prefix = emitExpression.trim().length > 0 ? emitExpression.trim() : '""';
|
|
436
|
+
return `TraceHooks.emitLineAtLine(${Number.parseInt(lineNumber, 10)}, ${prefix}${additions});`;
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
function guardJavaLineEmit(line) {
|
|
441
|
+
return line.replace(
|
|
442
|
+
/^(\s*)TraceHooks\.emitLineAtLine\((.+)\);\s*$/,
|
|
443
|
+
(_match, indent, argsSource) => `${indent}if (!TraceHooks.traceLimitExceeded()) TraceHooks.emitLineAtLine(${argsSource});`
|
|
444
|
+
);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
function appendJavaScalarDeclarationWrites(line, lineNumber) {
|
|
448
|
+
if (line.includes('TraceHooks.emitScalarWriteAtLine(')) return line;
|
|
449
|
+
if (/TraceHooks\.read[A-Za-z0-9_]*AtLine\(/.test(line)) return line;
|
|
450
|
+
if (/^\s*(?:for|if|while|switch|catch)\s*\(/.test(line)) return line;
|
|
451
|
+
if (!/;\s*$/.test(line)) return line;
|
|
452
|
+
const declarations = collectJavaLocalDeclarations(line);
|
|
453
|
+
if (declarations.length === 0) return line;
|
|
454
|
+
const indent = line.match(/^(\s*)/)?.[1] ?? '';
|
|
455
|
+
const writes = declarations
|
|
456
|
+
.map((name) => `${indent}TraceHooks.emitScalarWriteAtLine(${lineNumber}, "${name}", ${name});`)
|
|
457
|
+
.join('\n');
|
|
458
|
+
return `${line}\n${writes}`;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
function appendJavaPendingScalarDeclarationWrites(line, lineNumber, declarations) {
|
|
462
|
+
if (!Array.isArray(declarations) || declarations.length === 0) return line;
|
|
463
|
+
if (!/;\s*$/.test(line)) return line;
|
|
464
|
+
const indent = line.match(/^(\s*)/)?.[1] ?? '';
|
|
465
|
+
const writes = declarations
|
|
466
|
+
.map((name) => `${indent}TraceHooks.emitScalarWriteAtLine(${lineNumber}, "${name}", ${name});`)
|
|
467
|
+
.join('\n');
|
|
468
|
+
return writes ? `${line}\n${writes}` : line;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
function augmentJavaLocalSnapshots(source) {
|
|
472
|
+
const lines = source.split('\n');
|
|
473
|
+
const output = [];
|
|
474
|
+
const scopeStack = [];
|
|
475
|
+
let currentTraceLine = null;
|
|
476
|
+
let pendingScalarDeclarationWrites = null;
|
|
477
|
+
let methodDepth = 0;
|
|
478
|
+
let generatedExportsClassDepth = null;
|
|
479
|
+
const methodStartPattern =
|
|
480
|
+
/^(\s*)(?:(?:public|private|protected|static|final|synchronized)\s+)*(?:[A-Za-z_][A-Za-z0-9_<>\[\], ?]*\s+)+([A-Za-z_][A-Za-z0-9_]*)\s*\(([^)]*)\)\s*\{\s*$/;
|
|
481
|
+
const generatedExportsClassPattern = /^\s*(?:(?:public|private|protected|static|final)\s+)*class\s+Exports[A-Za-z0-9_]*\s*\{/;
|
|
482
|
+
|
|
483
|
+
for (const line of lines) {
|
|
484
|
+
if (generatedExportsClassDepth !== null) {
|
|
485
|
+
output.push(line);
|
|
486
|
+
generatedExportsClassDepth += braceDelta(line);
|
|
487
|
+
if (generatedExportsClassDepth <= 0) generatedExportsClassDepth = null;
|
|
488
|
+
continue;
|
|
489
|
+
}
|
|
490
|
+
if (generatedExportsClassPattern.test(line)) {
|
|
491
|
+
output.push(line);
|
|
492
|
+
generatedExportsClassDepth = Math.max(0, braceDelta(line));
|
|
493
|
+
if (generatedExportsClassDepth <= 0) generatedExportsClassDepth = null;
|
|
494
|
+
continue;
|
|
495
|
+
}
|
|
496
|
+
if (methodDepth <= 0) {
|
|
497
|
+
const methodMatch = line.match(methodStartPattern);
|
|
498
|
+
if (methodMatch) {
|
|
499
|
+
methodDepth = Math.max(0, braceDelta(line));
|
|
500
|
+
scopeStack.length = 0;
|
|
501
|
+
scopeStack.push({ names: parseJavaParameterNames(methodMatch[3] ?? '') });
|
|
502
|
+
output.push(line);
|
|
503
|
+
if (methodDepth <= 0) {
|
|
504
|
+
scopeStack.length = 0;
|
|
505
|
+
pendingScalarDeclarationWrites = null;
|
|
506
|
+
}
|
|
507
|
+
continue;
|
|
508
|
+
}
|
|
509
|
+
output.push(line);
|
|
510
|
+
continue;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
const leadingClosingCount = line.match(/^\s*}+/)?.[0].replace(/\s/g, '').length ?? 0;
|
|
514
|
+
for (let index = 0; index < leadingClosingCount; index += 1) {
|
|
515
|
+
if (scopeStack.length > 0) scopeStack.pop();
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
output.push(guardJavaLineEmit(appendJavaLocalSnapshotsToEmitLine(line, scopeStack)));
|
|
519
|
+
const emittedTraceLine = parseNativeTraceLine(output[output.length - 1]);
|
|
520
|
+
if (emittedTraceLine !== null) currentTraceLine = emittedTraceLine;
|
|
521
|
+
const declarations = collectJavaLocalDeclarations(line);
|
|
522
|
+
if (declarations.length > 0) {
|
|
523
|
+
const lastIndex = output.length - 1;
|
|
524
|
+
const lineNumber = parseNativeTraceLine(output[lastIndex]) ?? currentTraceLine;
|
|
525
|
+
if (
|
|
526
|
+
lineNumber !== null &&
|
|
527
|
+
!isControlHeaderDeclarationLine(line) &&
|
|
528
|
+
line.includes('=') &&
|
|
529
|
+
!/;\s*$/.test(line)
|
|
530
|
+
) {
|
|
531
|
+
pendingScalarDeclarationWrites = {
|
|
532
|
+
lineNumber,
|
|
533
|
+
declarations: [...declarations],
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
} else if (pendingScalarDeclarationWrites && /;\s*$/.test(line)) {
|
|
537
|
+
const lastIndex = output.length - 1;
|
|
538
|
+
output[lastIndex] = appendJavaPendingScalarDeclarationWrites(
|
|
539
|
+
output[lastIndex],
|
|
540
|
+
pendingScalarDeclarationWrites.lineNumber,
|
|
541
|
+
pendingScalarDeclarationWrites.declarations
|
|
542
|
+
);
|
|
543
|
+
pendingScalarDeclarationWrites = null;
|
|
544
|
+
}
|
|
545
|
+
const declarationsBelongToCurrentScope =
|
|
546
|
+
declarations.length > 0 && !isControlHeaderDeclarationLine(line);
|
|
547
|
+
if (declarationsBelongToCurrentScope) {
|
|
548
|
+
const currentScope = scopeStack[scopeStack.length - 1];
|
|
549
|
+
if (currentScope) currentScope.names.push(...declarations);
|
|
550
|
+
}
|
|
551
|
+
const braceCounts = javaBraceCounts(line);
|
|
552
|
+
const openingCount = braceCounts.open;
|
|
553
|
+
const closingCount = Math.max(0, braceCounts.close - leadingClosingCount);
|
|
554
|
+
for (let index = 0; index < openingCount; index += 1) {
|
|
555
|
+
scopeStack.push({ names: index === 0 && !declarationsBelongToCurrentScope ? declarations : [] });
|
|
556
|
+
}
|
|
557
|
+
if (
|
|
558
|
+
openingCount === 0 &&
|
|
559
|
+
declarations.length > 0 &&
|
|
560
|
+
!declarationsBelongToCurrentScope &&
|
|
561
|
+
!isUnbracedForDeclarationLine(line)
|
|
562
|
+
) {
|
|
563
|
+
const currentScope = scopeStack[scopeStack.length - 1];
|
|
564
|
+
if (currentScope) currentScope.names.push(...declarations);
|
|
565
|
+
}
|
|
566
|
+
for (let index = 0; index < closingCount; index += 1) {
|
|
567
|
+
if (scopeStack.length > 0) scopeStack.pop();
|
|
568
|
+
}
|
|
569
|
+
methodDepth += braceCounts.delta;
|
|
570
|
+
if (methodDepth <= 0) {
|
|
571
|
+
methodDepth = 0;
|
|
572
|
+
scopeStack.length = 0;
|
|
573
|
+
pendingScalarDeclarationWrites = null;
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
return output.join('\n');
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
function replaceJavaReceiverCall(source, receiverName, methodName, replacer) {
|
|
581
|
+
const callPattern = new RegExp(`\\b${escapeRegExp(receiverName)}\\.${methodName}\\(`, 'g');
|
|
582
|
+
let output = '';
|
|
583
|
+
let cursor = 0;
|
|
584
|
+
let match;
|
|
585
|
+
while ((match = callPattern.exec(source)) !== null) {
|
|
586
|
+
const argsStart = match.index + match[0].length;
|
|
587
|
+
let depth = 1;
|
|
588
|
+
let index = argsStart;
|
|
589
|
+
let inString = false;
|
|
590
|
+
let inChar = false;
|
|
591
|
+
let escaped = false;
|
|
592
|
+
while (index < source.length) {
|
|
593
|
+
const ch = source[index];
|
|
594
|
+
if (escaped) {
|
|
595
|
+
escaped = false;
|
|
596
|
+
index += 1;
|
|
597
|
+
continue;
|
|
598
|
+
}
|
|
599
|
+
if (ch === '\\') {
|
|
600
|
+
escaped = true;
|
|
601
|
+
index += 1;
|
|
602
|
+
continue;
|
|
603
|
+
}
|
|
604
|
+
if (inString) {
|
|
605
|
+
if (ch === '"') inString = false;
|
|
606
|
+
index += 1;
|
|
607
|
+
continue;
|
|
608
|
+
}
|
|
609
|
+
if (inChar) {
|
|
610
|
+
if (ch === "'") inChar = false;
|
|
611
|
+
index += 1;
|
|
612
|
+
continue;
|
|
613
|
+
}
|
|
614
|
+
if (ch === '"') {
|
|
615
|
+
inString = true;
|
|
616
|
+
index += 1;
|
|
617
|
+
continue;
|
|
618
|
+
}
|
|
619
|
+
if (ch === "'") {
|
|
620
|
+
inChar = true;
|
|
621
|
+
index += 1;
|
|
622
|
+
continue;
|
|
623
|
+
}
|
|
624
|
+
if (ch === '(') depth += 1;
|
|
625
|
+
if (ch === ')') depth -= 1;
|
|
626
|
+
if (depth === 0) break;
|
|
627
|
+
index += 1;
|
|
628
|
+
}
|
|
629
|
+
if (depth !== 0) continue;
|
|
630
|
+
output += source.slice(cursor, match.index);
|
|
631
|
+
output += replacer(source.slice(argsStart, index).trim());
|
|
632
|
+
cursor = index + 1;
|
|
633
|
+
callPattern.lastIndex = cursor;
|
|
634
|
+
}
|
|
635
|
+
return output + source.slice(cursor);
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
function rewriteJavaArraysFillStatement(line, lineNumber, currentMethod) {
|
|
639
|
+
const match = String(line).match(/^(\s*)(?:java\.util\.)?Arrays\.fill\(([\s\S]*)\);\s*$/);
|
|
640
|
+
if (!match) return line;
|
|
641
|
+
const indent = match[1] ?? '';
|
|
642
|
+
const argsSource = match[2] ?? '';
|
|
643
|
+
const args = splitTopLevelJavaList(argsSource);
|
|
644
|
+
if (args.length !== 2) return line;
|
|
645
|
+
const arrayName = String(args[0]).trim();
|
|
646
|
+
if (!isSimpleIdentifierExpression(arrayName) || !currentMethod.arrays.has(arrayName)) return line;
|
|
647
|
+
return `${indent}TraceHooks.fillArrayAtLine(${lineNumber}, "${arrayName}", ${arrayName}, ${args[1]});`;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
function rewriteJavaArraysSortStatement(line, lineNumber, currentMethod) {
|
|
651
|
+
const match = String(line).match(/^(\s*)(?:java\.util\.)?Arrays\.sort\(([\s\S]*)\);\s*$/);
|
|
652
|
+
if (!match) return line;
|
|
653
|
+
const indent = match[1] ?? '';
|
|
654
|
+
const argsSource = match[2] ?? '';
|
|
655
|
+
const args = splitTopLevelJavaList(argsSource);
|
|
656
|
+
if (args.length < 1 || args.length > 2) return line;
|
|
657
|
+
const arrayName = String(args[0]).trim();
|
|
658
|
+
if (!isSimpleIdentifierExpression(arrayName) || !currentMethod.arrays.has(arrayName)) return line;
|
|
659
|
+
const suffix = args.length === 2 ? `, ${args[1]}` : '';
|
|
660
|
+
return `${indent}TraceHooks.sortArrayAtLine(${lineNumber}, "${arrayName}", ${arrayName}${suffix});`;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
function rewriteJavaArrayLengthReads(line, lineNumber, currentMethod) {
|
|
664
|
+
let nextLine = line;
|
|
665
|
+
for (const name of currentMethod.arrays) {
|
|
666
|
+
const tracedArrayElementLengthPattern = new RegExp(
|
|
667
|
+
`TraceHooks\\.read(?:Object)?ArrayAtLine\\(\\s*${lineNumber}\\s*,\\s*"${escapeRegExp(name)}"\\s*,\\s*${escapeRegExp(name)}\\s*,\\s*([^,]+)\\s*,\\s*([^\\)]+)\\)\\.length\\b(?!\\s*\\()`,
|
|
668
|
+
'g'
|
|
669
|
+
);
|
|
670
|
+
nextLine = nextLine.replace(tracedArrayElementLengthPattern, (match, indexExpression, indexSource) => {
|
|
671
|
+
const readCall = match.slice(0, match.lastIndexOf('.length'));
|
|
672
|
+
return `TraceHooks.readArrayLengthAtLine(${lineNumber}, "${name}", ${readCall}, ${String(indexExpression).trim()}, ${String(indexSource).trim()})`;
|
|
673
|
+
});
|
|
674
|
+
const nestedLengthPattern = new RegExp(`\\b${escapeRegExp(name)}\\s*\\[([^\\]]+)\\]\\.length\\b(?!\\s*\\()`, 'g');
|
|
675
|
+
nextLine = nextLine.replace(nestedLengthPattern, (_match, indexExpression) => {
|
|
676
|
+
const indexSource = String(indexExpression).trim();
|
|
677
|
+
return `TraceHooks.readArrayLengthAtLine(${lineNumber}, "${name}", ${name}[${indexSource}], ${indexSource}, ${indexSourceArgument(indexSource)})`;
|
|
678
|
+
});
|
|
679
|
+
const lengthPattern = new RegExp(`\\b${escapeRegExp(name)}\\.length\\b(?!\\s*\\()`, 'g');
|
|
680
|
+
nextLine = nextLine.replace(lengthPattern, `TraceHooks.readArrayLengthAtLine(${lineNumber}, "${name}", ${name})`);
|
|
681
|
+
}
|
|
682
|
+
return nextLine;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
function buildOriginalLineResolver(sourceText) {
|
|
686
|
+
if (typeof sourceText !== 'string' || sourceText.trim().length === 0) {
|
|
687
|
+
return () => null;
|
|
688
|
+
}
|
|
689
|
+
const linesByText = new Map();
|
|
690
|
+
sourceText.split('\n').forEach((line, index) => {
|
|
691
|
+
const key = line.trim();
|
|
692
|
+
if (!key) return;
|
|
693
|
+
const lines = linesByText.get(key) ?? [];
|
|
694
|
+
lines.push(index + 1);
|
|
695
|
+
linesByText.set(key, lines);
|
|
696
|
+
});
|
|
697
|
+
return (line) => {
|
|
698
|
+
const key = String(line).trim();
|
|
699
|
+
if (!key) return null;
|
|
700
|
+
const lines = linesByText.get(key);
|
|
701
|
+
if (!lines || lines.length === 0) return null;
|
|
702
|
+
return lines.shift() ?? null;
|
|
703
|
+
};
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
function augmentJavaCollectionOperations(source, sourceText) {
|
|
707
|
+
const lines = source.split('\n');
|
|
708
|
+
const methodStack = [];
|
|
709
|
+
let generatedExportsClassDepth = null;
|
|
710
|
+
const resolveOriginalLine = buildOriginalLineResolver(sourceText);
|
|
711
|
+
const methodStartPattern =
|
|
712
|
+
/^(\s*)(?:(?:public|private|protected|static|final|synchronized)\s+)*(?:[A-Za-z_][A-Za-z0-9_<>\[\], ?]*\s+)+([A-Za-z_][A-Za-z0-9_]*)\s*\(([^)]*)\)\s*\{\s*$/;
|
|
713
|
+
const generatedExportsClassPattern = /^\s*(?:(?:public|private|protected|static|final)\s+)*class\s+Exports[A-Za-z0-9_]*\s*\{/;
|
|
714
|
+
|
|
715
|
+
return lines.map((line, lineIndex) => {
|
|
716
|
+
if (generatedExportsClassDepth !== null) {
|
|
717
|
+
generatedExportsClassDepth += braceDelta(line);
|
|
718
|
+
if (generatedExportsClassDepth <= 0) generatedExportsClassDepth = null;
|
|
719
|
+
return line;
|
|
720
|
+
}
|
|
721
|
+
if (generatedExportsClassPattern.test(line)) {
|
|
722
|
+
generatedExportsClassDepth = Math.max(0, braceDelta(line));
|
|
723
|
+
if (generatedExportsClassDepth <= 0) generatedExportsClassDepth = null;
|
|
724
|
+
return line;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
const methodMatch = line.match(methodStartPattern);
|
|
728
|
+
if (methodMatch) {
|
|
729
|
+
methodStack.push({
|
|
730
|
+
depth: 1,
|
|
731
|
+
currentTraceLine: null,
|
|
732
|
+
maps: new Set(),
|
|
733
|
+
sets: new Set(),
|
|
734
|
+
lists: new Set(),
|
|
735
|
+
queues: new Set(),
|
|
736
|
+
adjacencyLists: new Set(),
|
|
737
|
+
arrays: new Set(),
|
|
738
|
+
});
|
|
739
|
+
const params = collectJavaCollectionDeclarations(methodMatch[3] ?? '');
|
|
740
|
+
params.maps.forEach((name) => methodStack[methodStack.length - 1].maps.add(name));
|
|
741
|
+
params.sets.forEach((name) => methodStack[methodStack.length - 1].sets.add(name));
|
|
742
|
+
params.lists.forEach((name) => methodStack[methodStack.length - 1].lists.add(name));
|
|
743
|
+
params.queues.forEach((name) => methodStack[methodStack.length - 1].queues.add(name));
|
|
744
|
+
params.adjacencyLists.forEach((name) => methodStack[methodStack.length - 1].adjacencyLists.add(name));
|
|
745
|
+
params.arrays.forEach((name) => methodStack[methodStack.length - 1].arrays.add(name));
|
|
746
|
+
return line;
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
const currentMethod = methodStack[methodStack.length - 1];
|
|
750
|
+
let nextLine = line;
|
|
751
|
+
if (!currentMethod) return nextLine;
|
|
752
|
+
|
|
753
|
+
const declarations = collectJavaCollectionDeclarations(line);
|
|
754
|
+
declarations.maps.forEach((name) => currentMethod.maps.add(name));
|
|
755
|
+
declarations.sets.forEach((name) => currentMethod.sets.add(name));
|
|
756
|
+
declarations.lists.forEach((name) => currentMethod.lists.add(name));
|
|
757
|
+
declarations.queues.forEach((name) => currentMethod.queues.add(name));
|
|
758
|
+
declarations.adjacencyLists.forEach((name) => currentMethod.adjacencyLists.add(name));
|
|
759
|
+
declarations.arrays.forEach((name) => currentMethod.arrays.add(name));
|
|
760
|
+
|
|
761
|
+
const traceLine = parseNativeTraceLine(line);
|
|
762
|
+
if (traceLine !== null) currentMethod.currentTraceLine = traceLine;
|
|
763
|
+
|
|
764
|
+
const lineNumber = resolveOriginalLine(line) ?? currentMethod.currentTraceLine ?? (lineIndex + 1);
|
|
765
|
+
if (lineNumber !== null) {
|
|
766
|
+
nextLine = rewriteEnhancedForIterationBind(nextLine, lineNumber, currentMethod);
|
|
767
|
+
nextLine = rewriteJavaArraysFillStatement(nextLine, lineNumber, currentMethod);
|
|
768
|
+
nextLine = rewriteJavaArraysSortStatement(nextLine, lineNumber, currentMethod);
|
|
769
|
+
nextLine = rewriteJavaArrayLengthReads(nextLine, lineNumber, currentMethod);
|
|
770
|
+
|
|
771
|
+
for (const name of currentMethod.adjacencyLists) {
|
|
772
|
+
nextLine = replaceJavaReceiverCall(nextLine, name, 'add', (valueSource) =>
|
|
773
|
+
`TraceHooks.addCollectionAtLine(${lineNumber}, "${name}", ${name}, ${valueSource})`
|
|
774
|
+
);
|
|
775
|
+
|
|
776
|
+
const indexedAddPattern = new RegExp(
|
|
777
|
+
`\\b${escapeRegExp(name)}\\.get\\(([^()\\n;]+)\\)\\.add\\(([^;\\n]+)\\);`,
|
|
778
|
+
'g'
|
|
779
|
+
);
|
|
780
|
+
nextLine = nextLine.replace(indexedAddPattern, (_match, indexSource, valueSource) => {
|
|
781
|
+
const indexExpression = String(indexSource).trim();
|
|
782
|
+
const value = String(valueSource).trim();
|
|
783
|
+
return `{ TraceHooks.readObjectListAtLine(${lineNumber}, "${name}", ${name}, ${indexExpression}, ${indexSourceArgument(indexExpression)}).add(${value}); TraceHooks.emitMutatingCallAtLine(${lineNumber}, "${name}", ${indexExpression}, "add", ${indexSourceArgument(indexExpression)}, ${value}); TraceHooks.emitRuntimeSnapshotAtLine(${lineNumber}, "${name}", ${name}); }`;
|
|
784
|
+
});
|
|
785
|
+
|
|
786
|
+
const listGetPattern = new RegExp(`\\b${escapeRegExp(name)}\\.get\\(([^()\\n;]+)\\)`, 'g');
|
|
787
|
+
nextLine = nextLine.replace(listGetPattern, (_match, indexSource) =>
|
|
788
|
+
`TraceHooks.readObjectListAtLine(${lineNumber}, "${name}", ${name}, ${String(indexSource).trim()}, ${indexSourceArgument(indexSource)})`
|
|
789
|
+
);
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
for (const name of currentMethod.maps) {
|
|
793
|
+
const nestedMapMutationPattern = new RegExp(
|
|
794
|
+
`\\b${escapeRegExp(name)}\\.get\\(([^()\\n;]+)\\)\\.(add|push)\\(([^;\\n]+)\\);`,
|
|
795
|
+
'g'
|
|
796
|
+
);
|
|
797
|
+
nextLine = nextLine.replace(nestedMapMutationPattern, (_match, keySource, methodSource, valueSource) => {
|
|
798
|
+
const keyExpression = String(keySource).trim();
|
|
799
|
+
const method = String(methodSource).trim();
|
|
800
|
+
const value = String(valueSource).trim();
|
|
801
|
+
const target = `((java.util.Collection) (${name}).get(${keyExpression}))`;
|
|
802
|
+
return `{ TraceHooks.emit("trace:{\\"kind\\":\\"read\\",\\"line\\":${lineNumber},\\"target\\":{\\"variable\\":\\"${name}\\",\\"path\\":[" + TraceHooks.serializeResult(${keyExpression}) + "]${escapedIndexSourcesTargetSegment(keyExpression)}},\\"value\\":null}"); ${target}.${method}(${value}); TraceHooks.emitMutatingCallAtLine(${lineNumber}, "${name}", ${keyExpression}, "${method}", ${indexSourceArgument(keyExpression)}, ${value}); TraceHooks.emitRuntimeSnapshotAtLine(${lineNumber}, "${name}", ${name}); }`;
|
|
803
|
+
});
|
|
804
|
+
nextLine = replaceJavaReceiverCall(nextLine, name, 'containsKey', (key) =>
|
|
805
|
+
`TraceHooks.containsMapKeyAtLine(${lineNumber}, "${name}", ${name}, ${key}, ${indexSourceArgument(key)})`
|
|
806
|
+
);
|
|
807
|
+
nextLine = replaceJavaReceiverCall(nextLine, name, 'get', (key) =>
|
|
808
|
+
`TraceHooks.readMapAtLine(${lineNumber}, "${name}", ${name}, ${key}, ${indexSourceArgument(key)})`
|
|
809
|
+
);
|
|
810
|
+
nextLine = replaceJavaReceiverCall(nextLine, name, 'getOrDefault', (argsSource) => {
|
|
811
|
+
const parts = splitFirstTopLevelJavaArgument(argsSource);
|
|
812
|
+
if (!parts) return `${name}.getOrDefault(${argsSource})`;
|
|
813
|
+
return `TraceHooks.readMapOrDefaultAtLine(${lineNumber}, "${name}", ${name}, ${parts[0]}, ${parts[1]}, ${indexSourceArgument(parts[0])})`;
|
|
814
|
+
});
|
|
815
|
+
nextLine = replaceJavaReceiverCall(nextLine, name, 'put', (argsSource) => {
|
|
816
|
+
const parts = splitFirstTopLevelJavaArgument(argsSource);
|
|
817
|
+
if (!parts) return `${name}.put(${argsSource})`;
|
|
818
|
+
const keySource = indexSourceArgumentSourceFirst(parts[0]);
|
|
819
|
+
return `TraceHooks.writeMapAtLine(${lineNumber}, "${name}", ${name}, ${parts[0]}, ${parts[1]}, ${keySource})`;
|
|
820
|
+
});
|
|
821
|
+
nextLine = replaceJavaReceiverCall(nextLine, name, 'putIfAbsent', (argsSource) => {
|
|
822
|
+
const parts = splitFirstTopLevelJavaArgument(argsSource);
|
|
823
|
+
if (!parts) return `${name}.putIfAbsent(${argsSource})`;
|
|
824
|
+
const keySource = indexSourceArgumentSourceFirst(parts[0]);
|
|
825
|
+
return `TraceHooks.putMapIfAbsentAtLine(${lineNumber}, "${name}", ${name}, ${parts[0]}, ${parts[1]}, ${keySource})`;
|
|
826
|
+
});
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
for (const name of currentMethod.sets) {
|
|
830
|
+
nextLine = replaceJavaReceiverCall(nextLine, name, 'contains', (key) =>
|
|
831
|
+
`TraceHooks.readSetAtLine(${lineNumber}, "${name}", ${name}, ${key}, ${indexSourceArgument(key)})`
|
|
832
|
+
);
|
|
833
|
+
nextLine = replaceJavaReceiverCall(nextLine, name, 'add', (key) =>
|
|
834
|
+
`TraceHooks.addSetAtLine(${lineNumber}, "${name}", ${name}, ${key})`
|
|
835
|
+
);
|
|
836
|
+
nextLine = replaceJavaReceiverCall(nextLine, name, 'remove', (key) =>
|
|
837
|
+
`TraceHooks.removeSetAtLine(${lineNumber}, "${name}", ${name}, ${key})`
|
|
838
|
+
);
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
for (const name of currentMethod.lists) {
|
|
842
|
+
nextLine = replaceJavaReceiverCall(nextLine, name, 'get', (indexSource) =>
|
|
843
|
+
`TraceHooks.readListAtLine(${lineNumber}, "${name}", ${name}, ${indexSource}, ${indexSourceArgument(indexSource)})`
|
|
844
|
+
);
|
|
845
|
+
nextLine = replaceJavaReceiverCall(nextLine, name, 'add', (valueSource) =>
|
|
846
|
+
`TraceHooks.addCollectionAtLine(${lineNumber}, "${name}", ${name}, ${valueSource})`
|
|
847
|
+
);
|
|
848
|
+
nextLine = replaceJavaReceiverCall(nextLine, name, 'offer', (valueSource) =>
|
|
849
|
+
`TraceHooks.offerQueueAtLine(${lineNumber}, "${name}", ${name}, ${valueSource})`
|
|
850
|
+
);
|
|
851
|
+
nextLine = replaceJavaReceiverCall(nextLine, name, 'remove', (indexSource) => {
|
|
852
|
+
if (currentMethod.queues.has(name) && String(indexSource).trim() === '') {
|
|
853
|
+
return `TraceHooks.pollQueueAtLine(${lineNumber}, "${name}", ${name})`;
|
|
854
|
+
}
|
|
855
|
+
if (isLastListIndexExpression(indexSource, name)) {
|
|
856
|
+
return `TraceHooks.popListAtLine(${lineNumber}, "${name}", ${name})`;
|
|
857
|
+
}
|
|
858
|
+
return `TraceHooks.popListAtLine(${lineNumber}, "${name}", ${name}, ${indexSource})`;
|
|
859
|
+
});
|
|
860
|
+
nextLine = replaceJavaReceiverCall(nextLine, name, 'poll', (indexSource) => {
|
|
861
|
+
if (currentMethod.queues.has(name) && String(indexSource).trim() === '') {
|
|
862
|
+
return `TraceHooks.pollQueueAtLine(${lineNumber}, "${name}", ${name})`;
|
|
863
|
+
}
|
|
864
|
+
return `${name}.poll(${indexSource})`;
|
|
865
|
+
});
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
const staleMutationPattern = /TraceHooks\.emitMutatingCallAtLine\(\d+,\s*"([A-Za-z_][A-Za-z0-9_]*)",\s*"(get|put|putIfAbsent|set|add|offer|remove)"(?:\s*,[^;]+?)?\);\s*/g;
|
|
869
|
+
nextLine = nextLine.replace(staleMutationPattern, (match, name, method) => {
|
|
870
|
+
if (currentMethod.maps.has(name) && (method === 'get' || method === 'put' || method === 'putIfAbsent' || method === 'set')) {
|
|
871
|
+
return '';
|
|
872
|
+
}
|
|
873
|
+
if (currentMethod.sets.has(name) && (method === 'add' || method === 'remove')) {
|
|
874
|
+
return '';
|
|
875
|
+
}
|
|
876
|
+
if (currentMethod.adjacencyLists.has(name) && (method === 'add' )) {
|
|
877
|
+
return '';
|
|
878
|
+
}
|
|
879
|
+
if (currentMethod.lists.has(name) && (method === 'add' || method === 'offer' || method === 'remove')) {
|
|
880
|
+
return '';
|
|
881
|
+
}
|
|
882
|
+
return match;
|
|
883
|
+
});
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
currentMethod.depth += braceDelta(nextLine);
|
|
887
|
+
while (methodStack.length > 0 && methodStack[methodStack.length - 1].depth <= 0) {
|
|
888
|
+
methodStack.pop();
|
|
889
|
+
}
|
|
890
|
+
return nextLine;
|
|
891
|
+
}).join('\n');
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
const api = {
|
|
895
|
+
augmentJavaCollectionOperations,
|
|
896
|
+
augmentJavaLocalSnapshots,
|
|
897
|
+
augmentTraceCallArgumentSnapshots,
|
|
898
|
+
};
|
|
899
|
+
|
|
900
|
+
root.TraceCodeJavaSourceAugmentations = api;
|
|
901
|
+
if (root.self && typeof root.self === 'object') {
|
|
902
|
+
root.self.TraceCodeJavaSourceAugmentations = api;
|
|
903
|
+
}
|
|
904
|
+
if (typeof module === 'object' && module.exports) {
|
|
905
|
+
module.exports = api;
|
|
906
|
+
}
|
|
907
|
+
})(typeof globalThis !== 'undefined' ? globalThis : this);
|