@tracecode/harness 0.6.6 → 0.7.0-beta7
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 +6147 -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 +880 -0
- package/workers/java/java-worker.js +2149 -178
- package/workers/java/src/harness/browser/JavaRewriteLibrary.java +1645 -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 +1406 -0
- package/workers/javascript/javascript-libraries-entry.js +71 -0
- package/workers/javascript/javascript-worker.js +2054 -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,1406 @@
|
|
|
1
|
+
package tracecode.user;
|
|
2
|
+
|
|
3
|
+
import java.util.ArrayList;
|
|
4
|
+
import java.util.List;
|
|
5
|
+
|
|
6
|
+
public final class TraceHooks {
|
|
7
|
+
private static final int DEFAULT_MAX_EVENTS = 50000;
|
|
8
|
+
private static final int MAX_SERIALIZE_DEPTH = 48;
|
|
9
|
+
private static final int MAX_SERIALIZED_ITEMS = 64;
|
|
10
|
+
private static final int MAX_OBJECT_FIELDS = 32;
|
|
11
|
+
private static final List<String> EVENTS = new ArrayList<>();
|
|
12
|
+
private static final ThreadLocal<java.util.List<TraceFrame>> CALL_STACK = ThreadLocal.withInitial(java.util.ArrayList::new);
|
|
13
|
+
private static final ThreadLocal<String> LAST_INDEX_SOURCE = new ThreadLocal<>();
|
|
14
|
+
private static int maxEvents = DEFAULT_MAX_EVENTS;
|
|
15
|
+
private static boolean traceLimitExceeded = false;
|
|
16
|
+
private static int droppedEventCount = 0;
|
|
17
|
+
|
|
18
|
+
private TraceHooks() {}
|
|
19
|
+
|
|
20
|
+
public static void emit(String event) {
|
|
21
|
+
if (traceLimitExceeded) {
|
|
22
|
+
droppedEventCount += 1;
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (event == null || !event.startsWith("trace:")) {
|
|
26
|
+
throw new IllegalArgumentException("TraceHooks.emit only accepts native trace: runtime events");
|
|
27
|
+
}
|
|
28
|
+
if (EVENTS.size() >= maxEvents) {
|
|
29
|
+
traceLimitExceeded = true;
|
|
30
|
+
droppedEventCount += 1;
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
EVENTS.add(sanitizeJsonNonFiniteNumbers(withCallStack(event)));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public static void reset() {
|
|
37
|
+
reset(DEFAULT_MAX_EVENTS);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public static void reset(int nextMaxEvents) {
|
|
41
|
+
EVENTS.clear();
|
|
42
|
+
CALL_STACK.get().clear();
|
|
43
|
+
LAST_INDEX_SOURCE.remove();
|
|
44
|
+
maxEvents = Math.max(1, nextMaxEvents);
|
|
45
|
+
traceLimitExceeded = false;
|
|
46
|
+
droppedEventCount = 0;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
public static List<String> drainEvents() {
|
|
50
|
+
List<String> copy = new ArrayList<>(EVENTS);
|
|
51
|
+
EVENTS.clear();
|
|
52
|
+
return copy;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public static boolean traceLimitExceeded() {
|
|
56
|
+
return traceLimitExceeded;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public static int droppedEventCount() {
|
|
60
|
+
return droppedEventCount;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public static String serializeResult(Object value) {
|
|
64
|
+
return serializeResult(value, new java.util.IdentityHashMap<Object, String>(), 0, true);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
public static String serializeOutputResult(Object value) {
|
|
68
|
+
return serializeResult(value, new java.util.IdentityHashMap<Object, String>(), 0, false);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public static void emitLineAtLine(int line) {
|
|
72
|
+
emit("trace:{\"kind\":\"line\",\"line\":" + line + "}");
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public static void emitLineAtLine(int line, String snapshotFragment) {
|
|
76
|
+
emitLineAtLine(line);
|
|
77
|
+
emitSnapshotsFromFragment(line, snapshotFragment);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
public static void emitCallAtLine(int line, String functionName, String argsJson) {
|
|
81
|
+
StringBuilder out = new StringBuilder("trace:{\"kind\":\"call\",\"line\":");
|
|
82
|
+
out.append(line).append(",\"function\":").append(jsonString(functionName == null ? "" : functionName));
|
|
83
|
+
String argsPayload = argsJsonPayload(argsJson);
|
|
84
|
+
if (argsPayload != null) out.append(",\"args\":").append(argsPayload);
|
|
85
|
+
CALL_STACK.get().add(new TraceFrame(functionName == null ? "" : functionName, line, argsPayload));
|
|
86
|
+
out.append("}");
|
|
87
|
+
emit(out.toString());
|
|
88
|
+
emitSnapshotsFromFragment(line, argsJson);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
public static void emitReturnAtLine(int line, String functionName) {
|
|
92
|
+
emitReturnAtLine(line, functionName, null);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
public static void emitReturnAtLine(int line, String functionName, Object value) {
|
|
96
|
+
StringBuilder out = new StringBuilder("trace:{\"kind\":\"return\",\"line\":");
|
|
97
|
+
out.append(line).append(",\"function\":").append(jsonString(functionName == null ? "" : functionName));
|
|
98
|
+
if (value != null) out.append(",\"value\":").append(serializeResult(value));
|
|
99
|
+
out.append("}");
|
|
100
|
+
emit(out.toString());
|
|
101
|
+
popCallFrame(functionName);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
public static void emitSerializedReturnAtLine(int line, String functionName, String serializedValue) {
|
|
105
|
+
StringBuilder out = new StringBuilder("trace:{\"kind\":\"return\",\"line\":");
|
|
106
|
+
out.append(line).append(",\"function\":").append(jsonString(functionName == null ? "" : functionName));
|
|
107
|
+
if (serializedValue != null) out.append(",\"value\":").append(serializedValue);
|
|
108
|
+
out.append("}");
|
|
109
|
+
emit(out.toString());
|
|
110
|
+
popCallFrame(functionName);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
public static void emitRuntimeSnapshotAtLine(int line, String name, Object value) {
|
|
114
|
+
emitSnapshot(line, name, serializeResult(value));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
public static void emitFieldWriteAtLine(int line, String name, String field, Object value) {
|
|
118
|
+
emitTraceWrite(line, name, "[" + jsonString(field) + "]", value);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
public static void emitArrayWriteAtLine(int line, String name, int index, Object value) {
|
|
122
|
+
emitTraceWrite(line, name, "[" + serializeResult(index) + "]", value);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
public static void emitArrayWriteAtLine(int line, String name, int index, Object value, String indexSource) {
|
|
126
|
+
emitTraceWrite(line, name, "[" + serializeResult(index) + "]", value, indexSourcesJson(indexSource));
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
public static void emitArrayWriteAtLine(int line, String name, int row, int col, Object value) {
|
|
130
|
+
emitTraceWrite(line, name, "[" + serializeResult(row) + "," + serializeResult(col) + "]", value);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
public static void emitArrayWriteAtLine(int line, String name, int row, int col, Object value, String rowSource, String colSource) {
|
|
134
|
+
emitTraceWrite(line, name, "[" + serializeResult(row) + "," + serializeResult(col) + "]", value, indexSourcesJson(rowSource, colSource));
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
public static void fillArrayAtLine(int line, String name, int[] values, int value) {
|
|
138
|
+
java.util.Arrays.fill(values, value);
|
|
139
|
+
emitTraceMutate(line, name, null, "fill", null, "[" + serializeResult(value) + "]");
|
|
140
|
+
emitRuntimeSnapshotAtLine(line, name, values);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
public static void fillArrayAtLine(int line, String name, long[] values, long value) {
|
|
144
|
+
java.util.Arrays.fill(values, value);
|
|
145
|
+
emitTraceMutate(line, name, null, "fill", null, "[" + serializeResult(value) + "]");
|
|
146
|
+
emitRuntimeSnapshotAtLine(line, name, values);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
public static void fillArrayAtLine(int line, String name, boolean[] values, boolean value) {
|
|
150
|
+
java.util.Arrays.fill(values, value);
|
|
151
|
+
emitTraceMutate(line, name, null, "fill", null, "[" + serializeResult(value) + "]");
|
|
152
|
+
emitRuntimeSnapshotAtLine(line, name, values);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
public static void fillArrayAtLine(int line, String name, char[] values, char value) {
|
|
156
|
+
java.util.Arrays.fill(values, value);
|
|
157
|
+
emitTraceMutate(line, name, null, "fill", null, "[" + serializeResult(value) + "]");
|
|
158
|
+
emitRuntimeSnapshotAtLine(line, name, values);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
public static void fillArrayAtLine(int line, String name, byte[] values, byte value) {
|
|
162
|
+
java.util.Arrays.fill(values, value);
|
|
163
|
+
emitTraceMutate(line, name, null, "fill", null, "[" + serializeResult(value) + "]");
|
|
164
|
+
emitRuntimeSnapshotAtLine(line, name, values);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
public static void fillArrayAtLine(int line, String name, short[] values, short value) {
|
|
168
|
+
java.util.Arrays.fill(values, value);
|
|
169
|
+
emitTraceMutate(line, name, null, "fill", null, "[" + serializeResult(value) + "]");
|
|
170
|
+
emitRuntimeSnapshotAtLine(line, name, values);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
public static void fillArrayAtLine(int line, String name, float[] values, float value) {
|
|
174
|
+
java.util.Arrays.fill(values, value);
|
|
175
|
+
emitTraceMutate(line, name, null, "fill", null, "[" + serializeResult(value) + "]");
|
|
176
|
+
emitRuntimeSnapshotAtLine(line, name, values);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
public static void fillArrayAtLine(int line, String name, double[] values, double value) {
|
|
180
|
+
java.util.Arrays.fill(values, value);
|
|
181
|
+
emitTraceMutate(line, name, null, "fill", null, "[" + serializeResult(value) + "]");
|
|
182
|
+
emitRuntimeSnapshotAtLine(line, name, values);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
public static <T> void fillArrayAtLine(int line, String name, T[] values, T value) {
|
|
186
|
+
java.util.Arrays.fill(values, value);
|
|
187
|
+
emitTraceMutate(line, name, null, "fill", null, "[" + serializeResult(value) + "]");
|
|
188
|
+
emitRuntimeSnapshotAtLine(line, name, values);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
public static void sortArrayAtLine(int line, String name, int[] values) {
|
|
192
|
+
java.util.Arrays.sort(values);
|
|
193
|
+
emitTraceMutate(line, name, null, "sort", null, "[]");
|
|
194
|
+
emitRuntimeSnapshotAtLine(line, name, values);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
public static void sortArrayAtLine(int line, String name, long[] values) {
|
|
198
|
+
java.util.Arrays.sort(values);
|
|
199
|
+
emitTraceMutate(line, name, null, "sort", null, "[]");
|
|
200
|
+
emitRuntimeSnapshotAtLine(line, name, values);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
public static void sortArrayAtLine(int line, String name, double[] values) {
|
|
204
|
+
java.util.Arrays.sort(values);
|
|
205
|
+
emitTraceMutate(line, name, null, "sort", null, "[]");
|
|
206
|
+
emitRuntimeSnapshotAtLine(line, name, values);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
public static void sortArrayAtLine(int line, String name, char[] values) {
|
|
210
|
+
java.util.Arrays.sort(values);
|
|
211
|
+
emitTraceMutate(line, name, null, "sort", null, "[]");
|
|
212
|
+
emitRuntimeSnapshotAtLine(line, name, values);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
public static <T> void sortArrayAtLine(int line, String name, T[] values) {
|
|
216
|
+
java.util.Arrays.sort(values);
|
|
217
|
+
emitTraceMutate(line, name, null, "sort", null, "[]");
|
|
218
|
+
emitRuntimeSnapshotAtLine(line, name, values);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
public static <T> void sortArrayAtLine(int line, String name, T[] values, java.util.Comparator<? super T> comparator) {
|
|
222
|
+
java.util.Arrays.sort(values, comparator);
|
|
223
|
+
emitTraceMutate(line, name, null, "sort", null, "[]");
|
|
224
|
+
emitRuntimeSnapshotAtLine(line, name, values);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
public static <T> T readObjectFieldAtLine(int line, String name, String field, T value) {
|
|
228
|
+
emitTraceRead(line, name, "[" + jsonString(field) + "]", value);
|
|
229
|
+
return value;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
public static void emitExceptionAtLine(int line, Object value) {
|
|
233
|
+
emit("trace:{\"kind\":\"exception\",\"line\":" + line + ",\"value\":" + serializeResult(value) + "}");
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
public static void emitStdoutAtLine(int line, Object value) {
|
|
237
|
+
emit("trace:{\"kind\":\"stdout\",\"line\":" + line + ",\"value\":" + serializeResult(value) + "}");
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
public static boolean traceCondition(int line, boolean value) {
|
|
241
|
+
emitLineAtLine(line);
|
|
242
|
+
return value;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
private static String serializeResult(Object value, java.util.IdentityHashMap<Object, String> seen, int depth, boolean capValues) {
|
|
246
|
+
if (depth > MAX_SERIALIZE_DEPTH) return "\"<max depth>\"";
|
|
247
|
+
if (value == null) return "null";
|
|
248
|
+
if (value != null && value.getClass().isArray()) {
|
|
249
|
+
if (seen.containsKey(value)) return "{\"__ref__\":" + jsonString(seen.get(value)) + "}";
|
|
250
|
+
seen.put(value, "ref-" + seen.size());
|
|
251
|
+
int length = java.lang.reflect.Array.getLength(value);
|
|
252
|
+
int emitted = capValues ? Math.min(length, MAX_SERIALIZED_ITEMS) : length;
|
|
253
|
+
StringBuilder out = new StringBuilder("[");
|
|
254
|
+
for (int index = 0; index < emitted; index++) {
|
|
255
|
+
if (index > 0) out.append(",");
|
|
256
|
+
out.append(serializeResult(java.lang.reflect.Array.get(value, index), seen, depth + 1, capValues));
|
|
257
|
+
}
|
|
258
|
+
if (capValues) appendArrayTruncationMarker(out, emitted, length);
|
|
259
|
+
out.append("]");
|
|
260
|
+
return out.toString();
|
|
261
|
+
}
|
|
262
|
+
if (value instanceof Double) {
|
|
263
|
+
double number = ((Double) value).doubleValue();
|
|
264
|
+
if (Double.isNaN(number)) return "\"NaN\"";
|
|
265
|
+
if (Double.isInfinite(number)) return number > 0 ? "\"Infinity\"" : "\"-Infinity\"";
|
|
266
|
+
}
|
|
267
|
+
if (value instanceof Float) {
|
|
268
|
+
float number = ((Float) value).floatValue();
|
|
269
|
+
if (Float.isNaN(number)) return "\"NaN\"";
|
|
270
|
+
if (Float.isInfinite(number)) return number > 0 ? "\"Infinity\"" : "\"-Infinity\"";
|
|
271
|
+
}
|
|
272
|
+
if (value instanceof java.util.Collection<?>) {
|
|
273
|
+
if (seen.containsKey(value)) return "{\"__ref__\":" + jsonString(seen.get(value)) + "}";
|
|
274
|
+
seen.put(value, "ref-" + seen.size());
|
|
275
|
+
java.util.Collection<?> collection = (java.util.Collection<?>) value;
|
|
276
|
+
StringBuilder out = new StringBuilder("[");
|
|
277
|
+
int index = 0;
|
|
278
|
+
for (Object item : collection) {
|
|
279
|
+
if (capValues && index >= MAX_SERIALIZED_ITEMS) break;
|
|
280
|
+
if (index > 0) out.append(",");
|
|
281
|
+
out.append(serializeResult(item, seen, depth + 1, capValues));
|
|
282
|
+
index++;
|
|
283
|
+
}
|
|
284
|
+
if (capValues) appendArrayTruncationMarker(out, index, collection.size());
|
|
285
|
+
out.append("]");
|
|
286
|
+
return out.toString();
|
|
287
|
+
}
|
|
288
|
+
if (value instanceof java.util.Map<?, ?>) {
|
|
289
|
+
if (seen.containsKey(value)) return "{\"__ref__\":" + jsonString(seen.get(value)) + "}";
|
|
290
|
+
seen.put(value, "ref-" + seen.size());
|
|
291
|
+
java.util.Map<?, ?> map = (java.util.Map<?, ?>) value;
|
|
292
|
+
StringBuilder out = new StringBuilder("{");
|
|
293
|
+
int index = 0;
|
|
294
|
+
for (java.util.Map.Entry<?, ?> entry : map.entrySet()) {
|
|
295
|
+
if (capValues && index >= MAX_SERIALIZED_ITEMS) break;
|
|
296
|
+
if (index > 0) out.append(",");
|
|
297
|
+
out.append(jsonString(String.valueOf(entry.getKey()))).append(":").append(serializeResult(entry.getValue(), seen, depth + 1, capValues));
|
|
298
|
+
index++;
|
|
299
|
+
}
|
|
300
|
+
if (capValues && index < map.size()) {
|
|
301
|
+
if (index > 0) out.append(",");
|
|
302
|
+
appendObjectTruncationFields(out, map.size() - index);
|
|
303
|
+
}
|
|
304
|
+
out.append("}");
|
|
305
|
+
return out.toString();
|
|
306
|
+
}
|
|
307
|
+
if (isUserObject(value)) {
|
|
308
|
+
return serializeUserObject(value, seen, depth, capValues);
|
|
309
|
+
}
|
|
310
|
+
if (value instanceof Number || value instanceof Boolean) {
|
|
311
|
+
return String.valueOf(value);
|
|
312
|
+
}
|
|
313
|
+
if (value instanceof Character || value instanceof CharSequence || value instanceof Enum<?>) {
|
|
314
|
+
return jsonString(String.valueOf(value));
|
|
315
|
+
}
|
|
316
|
+
return jsonString(String.valueOf(value));
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
private static void appendArrayTruncationMarker(StringBuilder out, int emitted, int total) {
|
|
320
|
+
if (emitted >= total) return;
|
|
321
|
+
if (emitted > 0) out.append(",");
|
|
322
|
+
out.append("{\"__truncated__\":true,\"remaining\":").append(total - emitted).append("}");
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
private static void appendObjectTruncationFields(StringBuilder out, int remaining) {
|
|
326
|
+
out.append("\"__truncated__\":true,\"remaining\":").append(Math.max(0, remaining));
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
private static boolean isUserObject(Object value) {
|
|
330
|
+
if (value == null) return false;
|
|
331
|
+
if (value instanceof java.util.Collection<?>) return false;
|
|
332
|
+
if (value instanceof java.util.Map<?, ?>) return false;
|
|
333
|
+
if (value instanceof Number || value instanceof Boolean || value instanceof CharSequence || value instanceof Character) return false;
|
|
334
|
+
Package packageInfo = value.getClass().getPackage();
|
|
335
|
+
String packageName = packageInfo == null ? "" : packageInfo.getName();
|
|
336
|
+
return packageName.startsWith("harness.user.") || packageName.startsWith("tracecode.user.");
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
private static String serializeUserObject(Object value, java.util.IdentityHashMap<Object, String> seen, int depth, boolean capValues) {
|
|
340
|
+
if (seen.containsKey(value)) return "{\"__ref__\":" + jsonString(seen.get(value)) + "}";
|
|
341
|
+
String nodeId = "ref-" + seen.size();
|
|
342
|
+
seen.put(value, nodeId);
|
|
343
|
+
StringBuilder out = new StringBuilder("{");
|
|
344
|
+
out.append("\"__type__\":").append(jsonString(value.getClass().getSimpleName()));
|
|
345
|
+
out.append(",\"__class__\":").append(jsonString(value.getClass().getSimpleName()));
|
|
346
|
+
out.append(",\"__id__\":").append(jsonString(nodeId));
|
|
347
|
+
java.lang.reflect.Field[] fields = value.getClass().getDeclaredFields();
|
|
348
|
+
java.util.Arrays.sort(fields, java.util.Comparator.comparing(java.lang.reflect.Field::getName));
|
|
349
|
+
int emitted = 0;
|
|
350
|
+
int eligible = 0;
|
|
351
|
+
for (java.lang.reflect.Field field : fields) {
|
|
352
|
+
if (java.lang.reflect.Modifier.isStatic(field.getModifiers())) continue;
|
|
353
|
+
eligible++;
|
|
354
|
+
if (capValues && emitted >= MAX_OBJECT_FIELDS) continue;
|
|
355
|
+
try {
|
|
356
|
+
field.setAccessible(true);
|
|
357
|
+
out.append(",").append(jsonString(field.getName())).append(":").append(serializeResult(field.get(value), seen, depth + 1, capValues));
|
|
358
|
+
emitted++;
|
|
359
|
+
} catch (Exception ignored) {
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
if (capValues && eligible > emitted) {
|
|
363
|
+
out.append(",");
|
|
364
|
+
appendObjectTruncationFields(out, eligible - emitted);
|
|
365
|
+
}
|
|
366
|
+
out.append("}");
|
|
367
|
+
return out.toString();
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
private static String sanitizeJsonNonFiniteNumbers(String event) {
|
|
371
|
+
return event
|
|
372
|
+
.replaceAll("(?<![A-Za-z0-9_\\\"])-Infinity(?![A-Za-z0-9_\\\"])", "\"-Infinity\"")
|
|
373
|
+
.replaceAll("(?<![A-Za-z0-9_\\\"])Infinity(?![A-Za-z0-9_\\\"])", "\"Infinity\"")
|
|
374
|
+
.replaceAll("(?<![A-Za-z0-9_\\\"])NaN(?![A-Za-z0-9_\\\"])", "\"NaN\"");
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
private static String withCallStack(String event) {
|
|
378
|
+
java.util.List<TraceFrame> stack = CALL_STACK.get();
|
|
379
|
+
if (stack.isEmpty() || !event.endsWith("}")) return event;
|
|
380
|
+
return event.substring(0, event.length() - 1) + ",\"callStack\":" + serializeCallStack(stack) + "}";
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
private static String serializeCallStack(java.util.List<TraceFrame> stack) {
|
|
384
|
+
StringBuilder out = new StringBuilder("[");
|
|
385
|
+
for (int index = 0; index < stack.size(); index++) {
|
|
386
|
+
if (index > 0) out.append(",");
|
|
387
|
+
TraceFrame frame = stack.get(index);
|
|
388
|
+
out.append("{\"function\":").append(jsonString(frame.functionName)).append(",\"line\":").append(frame.line);
|
|
389
|
+
if (frame.argsJson != null) out.append(",\"args\":").append(frame.argsJson);
|
|
390
|
+
out.append("}");
|
|
391
|
+
}
|
|
392
|
+
out.append("]");
|
|
393
|
+
return out.toString();
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
private static void popCallFrame(String functionName) {
|
|
397
|
+
java.util.List<TraceFrame> stack = CALL_STACK.get();
|
|
398
|
+
if (stack.isEmpty()) return;
|
|
399
|
+
String normalized = functionName == null ? "" : functionName;
|
|
400
|
+
int last = stack.size() - 1;
|
|
401
|
+
if (stack.get(last).functionName.equals(normalized)) {
|
|
402
|
+
stack.remove(last);
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
for (int index = last; index >= 0; index--) {
|
|
406
|
+
if (stack.get(index).functionName.equals(normalized)) {
|
|
407
|
+
stack.subList(index, stack.size()).clear();
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
private static String argsJsonPayload(String snapshotFragment) {
|
|
414
|
+
if (snapshotFragment == null) return null;
|
|
415
|
+
String fragment = snapshotFragment.trim();
|
|
416
|
+
if (fragment.isEmpty()) return null;
|
|
417
|
+
if (fragment.startsWith("{")) return fragment;
|
|
418
|
+
java.util.List<SnapshotEntry> entries = parseSnapshotEntries(fragment);
|
|
419
|
+
if (entries.isEmpty()) return null;
|
|
420
|
+
StringBuilder out = new StringBuilder("{");
|
|
421
|
+
for (int index = 0; index < entries.size(); index++) {
|
|
422
|
+
SnapshotEntry entry = entries.get(index);
|
|
423
|
+
if (index > 0) out.append(",");
|
|
424
|
+
out.append(jsonString(entry.name)).append(":").append(entry.value);
|
|
425
|
+
}
|
|
426
|
+
out.append("}");
|
|
427
|
+
return out.toString();
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
private static void emitSnapshotsFromFragment(int line, String snapshotFragment) {
|
|
431
|
+
for (SnapshotEntry entry : parseSnapshotEntries(snapshotFragment)) {
|
|
432
|
+
emitSnapshot(line, entry.name, entry.value);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
private static java.util.List<SnapshotEntry> parseSnapshotEntries(String snapshotFragment) {
|
|
437
|
+
java.util.List<SnapshotEntry> entries = new java.util.ArrayList<>();
|
|
438
|
+
if (snapshotFragment == null) return entries;
|
|
439
|
+
String fragment = snapshotFragment.trim();
|
|
440
|
+
if (fragment.isEmpty() || fragment.startsWith("{")) return entries;
|
|
441
|
+
|
|
442
|
+
int cursor = 0;
|
|
443
|
+
while (cursor < fragment.length()) {
|
|
444
|
+
while (cursor < fragment.length() && Character.isWhitespace(fragment.charAt(cursor))) cursor++;
|
|
445
|
+
int nameStart = cursor;
|
|
446
|
+
while (cursor < fragment.length()) {
|
|
447
|
+
char ch = fragment.charAt(cursor);
|
|
448
|
+
if (ch == '=') break;
|
|
449
|
+
if (Character.isWhitespace(ch)) break;
|
|
450
|
+
cursor++;
|
|
451
|
+
}
|
|
452
|
+
if (cursor >= fragment.length() || fragment.charAt(cursor) != '=') {
|
|
453
|
+
cursor++;
|
|
454
|
+
continue;
|
|
455
|
+
}
|
|
456
|
+
String name = fragment.substring(nameStart, cursor).trim().replace('.', '_');
|
|
457
|
+
cursor++;
|
|
458
|
+
int valueStart = cursor;
|
|
459
|
+
int valueEnd = findSerializedValueEnd(fragment, valueStart);
|
|
460
|
+
if (valueEnd <= valueStart) break;
|
|
461
|
+
String value = fragment.substring(valueStart, valueEnd).trim();
|
|
462
|
+
if (!name.isEmpty() && !value.isEmpty()) entries.add(new SnapshotEntry(name, value));
|
|
463
|
+
cursor = valueEnd;
|
|
464
|
+
}
|
|
465
|
+
return entries;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
private static int findSerializedValueEnd(String source, int start) {
|
|
469
|
+
int cursor = start;
|
|
470
|
+
while (cursor < source.length() && Character.isWhitespace(source.charAt(cursor))) cursor++;
|
|
471
|
+
if (cursor >= source.length()) return cursor;
|
|
472
|
+
|
|
473
|
+
char first = source.charAt(cursor);
|
|
474
|
+
if (first == '"' || first == '\'') return findQuotedValueEnd(source, cursor, first);
|
|
475
|
+
if (first == '[' || first == '{') return findBalancedValueEnd(source, cursor);
|
|
476
|
+
|
|
477
|
+
while (cursor < source.length()) {
|
|
478
|
+
char ch = source.charAt(cursor);
|
|
479
|
+
if (Character.isWhitespace(ch) && looksLikeNextSnapshotName(source, cursor + 1)) break;
|
|
480
|
+
cursor++;
|
|
481
|
+
}
|
|
482
|
+
return cursor;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
private static int findQuotedValueEnd(String source, int start, char quote) {
|
|
486
|
+
boolean escaped = false;
|
|
487
|
+
for (int index = start + 1; index < source.length(); index++) {
|
|
488
|
+
char ch = source.charAt(index);
|
|
489
|
+
if (escaped) {
|
|
490
|
+
escaped = false;
|
|
491
|
+
continue;
|
|
492
|
+
}
|
|
493
|
+
if (ch == '\\') {
|
|
494
|
+
escaped = true;
|
|
495
|
+
continue;
|
|
496
|
+
}
|
|
497
|
+
if (ch == quote) return index + 1;
|
|
498
|
+
}
|
|
499
|
+
return source.length();
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
private static int findBalancedValueEnd(String source, int start) {
|
|
503
|
+
int depth = 0;
|
|
504
|
+
boolean inString = false;
|
|
505
|
+
boolean escaped = false;
|
|
506
|
+
for (int index = start; index < source.length(); index++) {
|
|
507
|
+
char ch = source.charAt(index);
|
|
508
|
+
if (escaped) {
|
|
509
|
+
escaped = false;
|
|
510
|
+
continue;
|
|
511
|
+
}
|
|
512
|
+
if (inString) {
|
|
513
|
+
if (ch == '\\') {
|
|
514
|
+
escaped = true;
|
|
515
|
+
} else if (ch == '"') {
|
|
516
|
+
inString = false;
|
|
517
|
+
}
|
|
518
|
+
continue;
|
|
519
|
+
}
|
|
520
|
+
if (ch == '"') {
|
|
521
|
+
inString = true;
|
|
522
|
+
continue;
|
|
523
|
+
}
|
|
524
|
+
if (ch == '[' || ch == '{') depth++;
|
|
525
|
+
if (ch == ']' || ch == '}') {
|
|
526
|
+
depth--;
|
|
527
|
+
if (depth <= 0) return index + 1;
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
return source.length();
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
private static boolean looksLikeNextSnapshotName(String source, int start) {
|
|
534
|
+
int cursor = start;
|
|
535
|
+
while (cursor < source.length() && Character.isWhitespace(source.charAt(cursor))) cursor++;
|
|
536
|
+
if (cursor >= source.length()) return false;
|
|
537
|
+
char first = source.charAt(cursor);
|
|
538
|
+
if (!(Character.isLetter(first) || first == '_')) return false;
|
|
539
|
+
cursor++;
|
|
540
|
+
while (cursor < source.length()) {
|
|
541
|
+
char ch = source.charAt(cursor);
|
|
542
|
+
if (ch == '=') return true;
|
|
543
|
+
if (!(Character.isLetterOrDigit(ch) || ch == '_' || ch == '.')) return false;
|
|
544
|
+
cursor++;
|
|
545
|
+
}
|
|
546
|
+
return false;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
private static void emitSnapshot(int line, String name, String serializedValue) {
|
|
550
|
+
emit("trace:{\"kind\":\"snapshot\",\"line\":" + line + ",\"target\":{\"variable\":" + jsonString(name) + "},\"value\":" + serializedValue + "}");
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
public static void emitMutatingCallAtLine(int line, String name, String method) {
|
|
554
|
+
emitTraceMutate(line, name, null, method);
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
public static void emitMutatingCallAtLine(int line, String name, String method, Object... args) {
|
|
558
|
+
emitTraceMutate(line, name, null, method, null, serializeArgs(args));
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
public static void emitNoArgMutatingCallAtLine(int line, String name, String method) {
|
|
562
|
+
emitTraceMutate(line, name, null, method, null, "[]");
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
public static <T> T readQueuePeekAtLine(int line, String name, java.util.Queue<T> queue) {
|
|
566
|
+
T value = queue.peek();
|
|
567
|
+
emitTraceRead(line, name, "[0]", value);
|
|
568
|
+
return value;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
public static <T> T removeQueueAtLine(int line, String name, java.util.Queue<T> queue) {
|
|
572
|
+
T value = queue.peek();
|
|
573
|
+
emitTraceRead(line, name, "[0]", value);
|
|
574
|
+
value = queue.remove();
|
|
575
|
+
emitTraceMutate(line, name, null, "remove", null, "[]");
|
|
576
|
+
emitSnapshot(line, name, serializeResult(queue));
|
|
577
|
+
return value;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
public static void emitMutatingCallAtLine(int line, String name, int index, String method) {
|
|
581
|
+
emitTraceMutate(line, name, "[" + serializeResult(index) + "]", method);
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
public static void emitMutatingCallAtLine(int line, String name, int index, String method, String indexSource) {
|
|
585
|
+
emitTraceMutate(line, name, "[" + serializeResult(index) + "]", method, indexSourcesJson(indexSource));
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
public static void emitMutatingCallAtLine(int line, String name, Object key, String method, String indexSource) {
|
|
589
|
+
emitTraceMutate(line, name, "[" + serializeResult(key) + "]", method, indexSourcesJson(indexSource));
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
public static void emitMutatingCallAtLine(int line, String name, Object key, String method, String indexSource, Object value) {
|
|
593
|
+
emitTraceMutate(line, name, "[" + serializeResult(key) + "]", method, indexSourcesJson(indexSource), "[" + serializeResult(value) + "]");
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
public static void emitKeyedMutatingCallAtLine(int line, String name, String method, Object key) {
|
|
597
|
+
emitTraceMutate(line, name, "[" + serializeResult(key) + "]", method);
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
public static void emitKeyedMutatingCallAtLine(int line, String name, String method, Object key, Object value) {
|
|
601
|
+
emitTraceMutate(line, name, "[" + serializeResult(key) + "]", method, null, "[" + serializeResult(value) + "]");
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
public static <T> Iterable<T> iterationBindAtLine(int line, String name, Iterable<T> values, String bindingVariable) {
|
|
605
|
+
return new Iterable<T>() {
|
|
606
|
+
@Override
|
|
607
|
+
public java.util.Iterator<T> iterator() {
|
|
608
|
+
final java.util.Iterator<T> iterator = values.iterator();
|
|
609
|
+
return new java.util.Iterator<T>() {
|
|
610
|
+
private int index = 0;
|
|
611
|
+
|
|
612
|
+
@Override
|
|
613
|
+
public boolean hasNext() {
|
|
614
|
+
return iterator.hasNext();
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
@Override
|
|
618
|
+
public T next() {
|
|
619
|
+
T value = iterator.next();
|
|
620
|
+
emitTraceReadWithIterationBinding(line, name, "[" + serializeResult(index) + "]", value, bindingVariable);
|
|
621
|
+
index++;
|
|
622
|
+
return value;
|
|
623
|
+
}
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
public static <T> Iterable<T> iterationBindAtLine(int line, String name, Object parentKey, Iterable<T> values, String bindingVariable, String parentKeySource) {
|
|
630
|
+
return new Iterable<T>() {
|
|
631
|
+
@Override
|
|
632
|
+
public java.util.Iterator<T> iterator() {
|
|
633
|
+
final java.util.Iterator<T> iterator = values.iterator();
|
|
634
|
+
return new java.util.Iterator<T>() {
|
|
635
|
+
private int index = 0;
|
|
636
|
+
|
|
637
|
+
@Override
|
|
638
|
+
public boolean hasNext() {
|
|
639
|
+
return iterator.hasNext();
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
@Override
|
|
643
|
+
public T next() {
|
|
644
|
+
T value = iterator.next();
|
|
645
|
+
emitTraceReadWithIterationBinding(
|
|
646
|
+
line,
|
|
647
|
+
name,
|
|
648
|
+
"[" + serializeResult(parentKey) + "," + serializeResult(index) + "]",
|
|
649
|
+
value,
|
|
650
|
+
bindingVariable,
|
|
651
|
+
indexSourcesJson(parentKeySource, null));
|
|
652
|
+
index++;
|
|
653
|
+
return value;
|
|
654
|
+
}
|
|
655
|
+
};
|
|
656
|
+
}
|
|
657
|
+
};
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
public static <T> Iterable<T> iterationBindAtLine(int line, String name, T[] values, String bindingVariable) {
|
|
661
|
+
return iterationBindAtLine(line, name, java.util.Arrays.asList(values), bindingVariable);
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
public static Iterable<Integer> iterationBindAtLine(int line, String name, int[] values, String bindingVariable) {
|
|
665
|
+
java.util.List<Integer> boxed = new java.util.ArrayList<>(values.length);
|
|
666
|
+
for (int value : values) boxed.add(value);
|
|
667
|
+
return iterationBindAtLine(line, name, boxed, bindingVariable);
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
public static Iterable<Long> iterationBindAtLine(int line, String name, long[] values, String bindingVariable) {
|
|
671
|
+
java.util.List<Long> boxed = new java.util.ArrayList<>(values.length);
|
|
672
|
+
for (long value : values) boxed.add(value);
|
|
673
|
+
return iterationBindAtLine(line, name, boxed, bindingVariable);
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
public static Iterable<Double> iterationBindAtLine(int line, String name, double[] values, String bindingVariable) {
|
|
677
|
+
java.util.List<Double> boxed = new java.util.ArrayList<>(values.length);
|
|
678
|
+
for (double value : values) boxed.add(value);
|
|
679
|
+
return iterationBindAtLine(line, name, boxed, bindingVariable);
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
public static Iterable<Character> iterationBindAtLine(int line, String name, char[] values, String bindingVariable) {
|
|
683
|
+
java.util.List<Character> boxed = new java.util.ArrayList<>(values.length);
|
|
684
|
+
for (char value : values) boxed.add(value);
|
|
685
|
+
return iterationBindAtLine(line, name, boxed, bindingVariable);
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
public static Iterable<Boolean> iterationBindAtLine(int line, String name, boolean[] values, String bindingVariable) {
|
|
689
|
+
java.util.List<Boolean> boxed = new java.util.ArrayList<>(values.length);
|
|
690
|
+
for (boolean value : values) boxed.add(value);
|
|
691
|
+
return iterationBindAtLine(line, name, boxed, bindingVariable);
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
public static int readArrayLengthAtLine(int line, String name, Object value) {
|
|
695
|
+
int length = value == null ? 0 : java.lang.reflect.Array.getLength(value);
|
|
696
|
+
emitTraceRead(line, name, "[" + jsonString("length") + "]", length);
|
|
697
|
+
emitRuntimeSnapshotAtLine(line, name, value);
|
|
698
|
+
return length;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
public static int readArrayLengthAtLine(int line, String name, Object value, int index, String indexSource) {
|
|
702
|
+
int length = value == null ? 0 : java.lang.reflect.Array.getLength(value);
|
|
703
|
+
emitTraceRead(
|
|
704
|
+
line,
|
|
705
|
+
name,
|
|
706
|
+
"[" + serializeResult(index) + "," + jsonString("length") + "]",
|
|
707
|
+
length,
|
|
708
|
+
indexSourcesJson(indexSource, null)
|
|
709
|
+
);
|
|
710
|
+
return length;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
public static int readIndexedStringLengthAtLine(int line, String name, CharSequence[] values, int index, String indexSource) {
|
|
714
|
+
int length = values[index] == null ? 0 : values[index].length();
|
|
715
|
+
emitTraceRead(
|
|
716
|
+
line,
|
|
717
|
+
name,
|
|
718
|
+
"[" + serializeResult(index) + "," + jsonString("length") + "]",
|
|
719
|
+
length,
|
|
720
|
+
indexSourcesJson(indexSource, null)
|
|
721
|
+
);
|
|
722
|
+
return length;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
public static <K, V> V readMapAtLine(int line, String name, java.util.Map<K, V> values, K key) {
|
|
726
|
+
V value = values.get(key);
|
|
727
|
+
emitTraceRead(line, name, "[" + serializeResult(key) + "]", value);
|
|
728
|
+
return value;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
public static <K, V> V readMapAtLine(int line, String name, java.util.Map<K, V> values, K key, String keySource) {
|
|
732
|
+
V value = values.get(key);
|
|
733
|
+
emitTraceRead(line, name, "[" + serializeResult(key) + "]", value, indexSourcesJson(keySource));
|
|
734
|
+
return value;
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
public static <K, V> V readFieldMapAtLine(int line, String ownerName, String field, java.util.Map<K, V> values, K key) {
|
|
738
|
+
V value = values.get(key);
|
|
739
|
+
emitTraceRead(line, ownerName, "[" + jsonString(field) + "," + serializeResult(key) + "]", value);
|
|
740
|
+
return value;
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
public static <K, V> V readFieldMapAtLine(int line, String ownerName, String field, java.util.Map<K, V> values, K key, String keySource) {
|
|
744
|
+
V value = values.get(key);
|
|
745
|
+
emitTraceRead(line, ownerName, "[" + jsonString(field) + "," + serializeResult(key) + "]", value, indexSourcesJson(null, keySource));
|
|
746
|
+
return value;
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
public static <K, V> V readMapOrDefaultAtLine(int line, String name, java.util.Map<K, V> values, K key, V defaultValue) {
|
|
750
|
+
V value = values.getOrDefault(key, defaultValue);
|
|
751
|
+
emitTraceRead(line, name, "[" + serializeResult(key) + "]", value);
|
|
752
|
+
return value;
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
public static <K, V> V readMapOrDefaultAtLine(int line, String name, java.util.Map<K, V> values, K key, V defaultValue, String keySource) {
|
|
756
|
+
V value = values.getOrDefault(key, defaultValue);
|
|
757
|
+
emitTraceRead(line, name, "[" + serializeResult(key) + "]", value, indexSourcesJson(keySource));
|
|
758
|
+
return value;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
public static <K, V> V readFieldMapOrDefaultAtLine(int line, String ownerName, String field, java.util.Map<K, V> values, K key, V defaultValue) {
|
|
762
|
+
V value = values.getOrDefault(key, defaultValue);
|
|
763
|
+
emitTraceRead(line, ownerName, "[" + jsonString(field) + "," + serializeResult(key) + "]", value);
|
|
764
|
+
return value;
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
public static <K, V> V readFieldMapOrDefaultAtLine(int line, String ownerName, String field, java.util.Map<K, V> values, K key, V defaultValue, String keySource) {
|
|
768
|
+
V value = values.getOrDefault(key, defaultValue);
|
|
769
|
+
emitTraceRead(line, ownerName, "[" + jsonString(field) + "," + serializeResult(key) + "]", value, indexSourcesJson(null, keySource));
|
|
770
|
+
return value;
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
public static boolean containsMapKeyAtLine(int line, String name, java.util.Map<?, ?> values, Object key) {
|
|
774
|
+
boolean value = values.containsKey(key);
|
|
775
|
+
emitTraceRead(line, name, "[" + serializeResult(key) + "]", value);
|
|
776
|
+
return value;
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
public static boolean containsMapKeyAtLine(int line, String name, java.util.Map<?, ?> values, Object key, String keySource) {
|
|
780
|
+
boolean value = values.containsKey(key);
|
|
781
|
+
emitTraceRead(line, name, "[" + serializeResult(key) + "]", value, indexSourcesJson(keySource));
|
|
782
|
+
return value;
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
public static boolean containsFieldMapKeyAtLine(int line, String ownerName, String field, java.util.Map<?, ?> values, Object key) {
|
|
786
|
+
boolean value = values.containsKey(key);
|
|
787
|
+
emitTraceRead(line, ownerName, "[" + jsonString(field) + "," + serializeResult(key) + "]", value);
|
|
788
|
+
return value;
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
public static boolean containsFieldMapKeyAtLine(int line, String ownerName, String field, java.util.Map<?, ?> values, Object key, String keySource) {
|
|
792
|
+
boolean value = values.containsKey(key);
|
|
793
|
+
emitTraceRead(line, ownerName, "[" + jsonString(field) + "," + serializeResult(key) + "]", value, indexSourcesJson(null, keySource));
|
|
794
|
+
return value;
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
public static boolean readSetAtLine(int line, String name, java.util.Set<?> values, Object key) {
|
|
798
|
+
boolean value = values.contains(key);
|
|
799
|
+
emitTraceRead(line, name, "[" + serializeResult(key) + "]", value);
|
|
800
|
+
return value;
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
public static boolean readSetAtLine(int line, String name, java.util.Set<?> values, Object key, String keySource) {
|
|
804
|
+
boolean value = values.contains(key);
|
|
805
|
+
emitTraceRead(line, name, "[" + serializeResult(key) + "]", value, indexSourcesJson(keySource));
|
|
806
|
+
return value;
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
public static <K, V> V putMapAtLine(int line, String name, java.util.Map<K, V> values, K key, V value) {
|
|
810
|
+
V previous = values.put(key, value);
|
|
811
|
+
emitTraceWrite(line, name, "[" + serializeResult(key) + "]", values.get(key));
|
|
812
|
+
emitTraceMutate(line, name, "[" + serializeResult(key) + "]", "put", null, "[" + serializeResult(key) + "," + serializeResult(value) + "]");
|
|
813
|
+
emitRuntimeSnapshotAtLine(line, name, values);
|
|
814
|
+
return previous;
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
public static <K, V> V putMapAtLine(int line, String name, java.util.Map<K, V> values, K key, V value, String keySource) {
|
|
818
|
+
V previous = values.put(key, value);
|
|
819
|
+
if (keySource == null) keySource = consumeLastIndexSource();
|
|
820
|
+
String indexSources = indexSourcesJson(keySource);
|
|
821
|
+
emitTraceWrite(line, name, "[" + serializeResult(key) + "]", values.get(key), indexSources);
|
|
822
|
+
emitTraceMutate(line, name, "[" + serializeResult(key) + "]", "put", indexSources, "[" + serializeResult(key) + "," + serializeResult(value) + "]");
|
|
823
|
+
emitRuntimeSnapshotAtLine(line, name, values);
|
|
824
|
+
return previous;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
public static <K, V> V writeMapAtLine(int line, String name, java.util.Map<K, V> values, K key, V value) {
|
|
828
|
+
return putMapAtLine(line, name, values, key, value);
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
public static <K, V> V writeMapAtLine(int line, String name, java.util.Map<K, V> values, K key, V value, String keySource) {
|
|
832
|
+
return putMapAtLine(line, name, values, key, value, keySource);
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
public static <K, V> V putMapIfAbsentAtLine(int line, String name, java.util.Map<K, V> values, K key, V value) {
|
|
836
|
+
V previous = values.putIfAbsent(key, value);
|
|
837
|
+
if (previous == null) {
|
|
838
|
+
emitTraceWrite(line, name, "[" + serializeResult(key) + "]", values.get(key));
|
|
839
|
+
} else {
|
|
840
|
+
emitTraceRead(line, name, "[" + serializeResult(key) + "]", previous);
|
|
841
|
+
}
|
|
842
|
+
emitTraceMutate(line, name, "[" + serializeResult(key) + "]", "putIfAbsent", null, "[" + serializeResult(key) + "," + serializeResult(value) + "]");
|
|
843
|
+
emitRuntimeSnapshotAtLine(line, name, values);
|
|
844
|
+
return previous;
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
public static <K, V> V putMapIfAbsentAtLine(int line, String name, java.util.Map<K, V> values, K key, V value, String keySource) {
|
|
848
|
+
V previous = values.putIfAbsent(key, value);
|
|
849
|
+
if (keySource == null) keySource = consumeLastIndexSource();
|
|
850
|
+
String indexSources = indexSourcesJson(keySource);
|
|
851
|
+
if (previous == null) {
|
|
852
|
+
emitTraceWrite(line, name, "[" + serializeResult(key) + "]", values.get(key), indexSources);
|
|
853
|
+
} else {
|
|
854
|
+
emitTraceRead(line, name, "[" + serializeResult(key) + "]", previous, indexSources);
|
|
855
|
+
}
|
|
856
|
+
emitTraceMutate(line, name, "[" + serializeResult(key) + "]", "putIfAbsent", indexSources, "[" + serializeResult(key) + "," + serializeResult(value) + "]");
|
|
857
|
+
emitRuntimeSnapshotAtLine(line, name, values);
|
|
858
|
+
return previous;
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
public static <K, V> V putFieldMapAtLine(int line, String ownerName, String field, java.util.Map<K, V> values, K key, V value) {
|
|
862
|
+
V previous = values.put(key, value);
|
|
863
|
+
emitTraceWrite(line, ownerName, "[" + jsonString(field) + "," + serializeResult(key) + "]", values.get(key));
|
|
864
|
+
return previous;
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
public static <K, V> V putFieldMapAtLine(int line, String ownerName, String field, java.util.Map<K, V> values, K key, V value, String keySource) {
|
|
868
|
+
V previous = values.put(key, value);
|
|
869
|
+
emitTraceWrite(line, ownerName, "[" + jsonString(field) + "," + serializeResult(key) + "]", values.get(key), indexSourcesJson(null, keySource));
|
|
870
|
+
return previous;
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
public static <K, V> V putFieldMapIfAbsentAtLine(int line, String ownerName, String field, java.util.Map<K, V> values, K key, V value) {
|
|
874
|
+
V previous = values.putIfAbsent(key, value);
|
|
875
|
+
if (previous == null) {
|
|
876
|
+
emitTraceWrite(line, ownerName, "[" + jsonString(field) + "," + serializeResult(key) + "]", values.get(key));
|
|
877
|
+
} else {
|
|
878
|
+
emitTraceRead(line, ownerName, "[" + jsonString(field) + "," + serializeResult(key) + "]", previous);
|
|
879
|
+
}
|
|
880
|
+
return previous;
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
public static <K, V> V putFieldMapIfAbsentAtLine(int line, String ownerName, String field, java.util.Map<K, V> values, K key, V value, String keySource) {
|
|
884
|
+
V previous = values.putIfAbsent(key, value);
|
|
885
|
+
String indexSources = indexSourcesJson(null, keySource);
|
|
886
|
+
if (previous == null) {
|
|
887
|
+
emitTraceWrite(line, ownerName, "[" + jsonString(field) + "," + serializeResult(key) + "]", values.get(key), indexSources);
|
|
888
|
+
} else {
|
|
889
|
+
emitTraceRead(line, ownerName, "[" + jsonString(field) + "," + serializeResult(key) + "]", previous, indexSources);
|
|
890
|
+
}
|
|
891
|
+
return previous;
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
public static <T> boolean addSetAtLine(int line, String name, java.util.Set<T> values, T key) {
|
|
895
|
+
boolean changed = values.add(key);
|
|
896
|
+
emitTraceMutate(line, name, null, "add", null, "[" + serializeResult(key) + "]");
|
|
897
|
+
emitRuntimeSnapshotAtLine(line, name, values);
|
|
898
|
+
return changed;
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
public static <T> boolean addCollectionAtLine(int line, String name, java.util.Collection<T> values, T value) {
|
|
902
|
+
boolean changed = values.add(value);
|
|
903
|
+
emitTraceMutate(line, name, null, "add", null, "[" + serializeResult(value) + "]");
|
|
904
|
+
emitRuntimeSnapshotAtLine(line, name, values);
|
|
905
|
+
return changed;
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
public static <T> boolean offerQueueAtLine(int line, String name, java.util.Queue<T> values, T value) {
|
|
909
|
+
boolean changed = values.offer(value);
|
|
910
|
+
emitTraceMutate(line, name, null, "offer", null, "[" + serializeResult(value) + "]");
|
|
911
|
+
emitRuntimeSnapshotAtLine(line, name, values);
|
|
912
|
+
return changed;
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
public static <T> T pollQueueAtLine(int line, String name, java.util.Queue<T> values) {
|
|
916
|
+
T value = values.peek();
|
|
917
|
+
emitTraceRead(line, name, "[0]", value);
|
|
918
|
+
value = values.poll();
|
|
919
|
+
emitTraceMutate(line, name, null, "poll", null, "[]");
|
|
920
|
+
emitRuntimeSnapshotAtLine(line, name, values);
|
|
921
|
+
return value;
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
public static boolean removeSetAtLine(int line, String name, java.util.Set<?> values, Object key) {
|
|
925
|
+
boolean changed = values.remove(key);
|
|
926
|
+
emitTraceMutate(line, name, null, "remove");
|
|
927
|
+
emitRuntimeSnapshotAtLine(line, name, values);
|
|
928
|
+
return changed;
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
public static <T> T popListAtLine(int line, String name, java.util.List<T> values, int index) {
|
|
932
|
+
T value = values.remove(index);
|
|
933
|
+
emitTraceMutate(line, name, null, "remove", null, "[" + serializeResult(index) + "]");
|
|
934
|
+
emitRuntimeSnapshotAtLine(line, name, values);
|
|
935
|
+
return value;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
public static <T> T popListAtLine(int line, String name, java.util.List<T> values) {
|
|
939
|
+
return popListAtLine(line, name, values, values.size() - 1);
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
public static <T> T readListAtLine(int line, String name, java.util.List<T> values, int index) {
|
|
943
|
+
T value = values.get(index);
|
|
944
|
+
emitTraceRead(line, name, "[" + serializeResult(index) + "]", value);
|
|
945
|
+
return value;
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
public static <T> T readListAtLine(int line, String name, java.util.List<T> values, int index, String indexSource) {
|
|
949
|
+
T value = values.get(index);
|
|
950
|
+
emitTraceRead(line, name, "[" + serializeResult(index) + "]", value, indexSourcesJson(indexSource));
|
|
951
|
+
return value;
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
public static <T> T readObjectListAtLine(int line, String name, java.util.List<T> values, int index, String indexSource) {
|
|
955
|
+
return readListAtLine(line, name, values, index, indexSource);
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
public static <T> T writeListAtLine(int line, String name, java.util.List<T> values, int index, T value) {
|
|
959
|
+
T previous = values.set(index, value);
|
|
960
|
+
emitTraceWrite(line, name, "[" + serializeResult(index) + "]", values.get(index));
|
|
961
|
+
emitRuntimeSnapshotAtLine(line, name, values);
|
|
962
|
+
return previous;
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
public static <T> T writeListAtLine(int line, String name, java.util.List<T> values, int index, T value, String indexSource) {
|
|
966
|
+
T previous = values.set(index, value);
|
|
967
|
+
emitTraceWrite(line, name, "[" + serializeResult(index) + "]", values.get(index), indexSourcesJson(indexSource));
|
|
968
|
+
emitRuntimeSnapshotAtLine(line, name, values);
|
|
969
|
+
return previous;
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
public static int readIntArrayAtLine(int line, String name, int[] values, int index, String indexSource) {
|
|
973
|
+
int value = values[index];
|
|
974
|
+
emitTraceRead(line, name, "[" + serializeResult(index) + "]", value, indexSourcesJson(indexSource));
|
|
975
|
+
return value;
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
public static long readLongArrayAtLine(int line, String name, long[] values, int index, String indexSource) {
|
|
979
|
+
long value = values[index];
|
|
980
|
+
emitTraceRead(line, name, "[" + serializeResult(index) + "]", value, indexSourcesJson(indexSource));
|
|
981
|
+
return value;
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
public static boolean readBooleanArrayAtLine(int line, String name, boolean[] values, int index, String indexSource) {
|
|
985
|
+
boolean value = values[index];
|
|
986
|
+
emitTraceRead(line, name, "[" + serializeResult(index) + "]", value, indexSourcesJson(indexSource));
|
|
987
|
+
return value;
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
public static double readDoubleArrayAtLine(int line, String name, double[] values, int index, String indexSource) {
|
|
991
|
+
double value = values[index];
|
|
992
|
+
emitTraceRead(line, name, "[" + serializeResult(index) + "]", value, indexSourcesJson(indexSource));
|
|
993
|
+
return value;
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
public static float readFloatArrayAtLine(int line, String name, float[] values, int index, String indexSource) {
|
|
997
|
+
float value = values[index];
|
|
998
|
+
emitTraceRead(line, name, "[" + serializeResult(index) + "]", value, indexSourcesJson(indexSource));
|
|
999
|
+
return value;
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
public static char readCharArrayAtLine(int line, String name, char[] values, int index, String indexSource) {
|
|
1003
|
+
char value = values[index];
|
|
1004
|
+
emitTraceRead(line, name, "[" + serializeResult(index) + "]", String.valueOf(value), indexSourcesJson(indexSource));
|
|
1005
|
+
return value;
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
public static byte readByteArrayAtLine(int line, String name, byte[] values, int index, String indexSource) {
|
|
1009
|
+
byte value = values[index];
|
|
1010
|
+
emitTraceRead(line, name, "[" + serializeResult(index) + "]", value, indexSourcesJson(indexSource));
|
|
1011
|
+
return value;
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
public static short readShortArrayAtLine(int line, String name, short[] values, int index, String indexSource) {
|
|
1015
|
+
short value = values[index];
|
|
1016
|
+
emitTraceRead(line, name, "[" + serializeResult(index) + "]", value, indexSourcesJson(indexSource));
|
|
1017
|
+
return value;
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
public static <T> T readObjectArrayAtLine(int line, String name, T[] values, int index, String indexSource) {
|
|
1021
|
+
T value = values[index];
|
|
1022
|
+
emitTraceRead(line, name, "[" + serializeResult(index) + "]", value, indexSourcesJson(indexSource));
|
|
1023
|
+
return value;
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
public static int readIntArrayListAtLine(int line, String name, java.util.List<int[]> values, int index, int elementIndex) {
|
|
1027
|
+
int value = values.get(index)[elementIndex];
|
|
1028
|
+
emitNestedListArrayRead(line, name, index, elementIndex, value);
|
|
1029
|
+
return value;
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
public static int readIntArrayListAtLine(int line, String name, java.util.List<int[]> values, int index, int elementIndex, String indexSource, String elementIndexSource) {
|
|
1033
|
+
int value = values.get(index)[elementIndex];
|
|
1034
|
+
emitNestedListArrayRead(line, name, index, elementIndex, value, indexSourcesJson(indexSource, elementIndexSource));
|
|
1035
|
+
return value;
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
public static long readLongArrayListAtLine(int line, String name, java.util.List<long[]> values, int index, int elementIndex) {
|
|
1039
|
+
long value = values.get(index)[elementIndex];
|
|
1040
|
+
emitNestedListArrayRead(line, name, index, elementIndex, value);
|
|
1041
|
+
return value;
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
public static long readLongArrayListAtLine(int line, String name, java.util.List<long[]> values, int index, int elementIndex, String indexSource, String elementIndexSource) {
|
|
1045
|
+
long value = values.get(index)[elementIndex];
|
|
1046
|
+
emitNestedListArrayRead(line, name, index, elementIndex, value, indexSourcesJson(indexSource, elementIndexSource));
|
|
1047
|
+
return value;
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
public static char readCharArrayListAtLine(int line, String name, java.util.List<char[]> values, int index, int elementIndex) {
|
|
1051
|
+
char value = values.get(index)[elementIndex];
|
|
1052
|
+
emitNestedListArrayRead(line, name, index, elementIndex, value);
|
|
1053
|
+
return value;
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
public static char readCharArrayListAtLine(int line, String name, java.util.List<char[]> values, int index, int elementIndex, String indexSource, String elementIndexSource) {
|
|
1057
|
+
char value = values.get(index)[elementIndex];
|
|
1058
|
+
emitNestedListArrayRead(line, name, index, elementIndex, String.valueOf(value), indexSourcesJson(indexSource, elementIndexSource));
|
|
1059
|
+
return value;
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
public static boolean readBooleanArrayListAtLine(int line, String name, java.util.List<boolean[]> values, int index, int elementIndex) {
|
|
1063
|
+
boolean value = values.get(index)[elementIndex];
|
|
1064
|
+
emitNestedListArrayRead(line, name, index, elementIndex, value);
|
|
1065
|
+
return value;
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
public static boolean readBooleanArrayListAtLine(int line, String name, java.util.List<boolean[]> values, int index, int elementIndex, String indexSource, String elementIndexSource) {
|
|
1069
|
+
boolean value = values.get(index)[elementIndex];
|
|
1070
|
+
emitNestedListArrayRead(line, name, index, elementIndex, value, indexSourcesJson(indexSource, elementIndexSource));
|
|
1071
|
+
return value;
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
public static double readDoubleArrayListAtLine(int line, String name, java.util.List<double[]> values, int index, int elementIndex) {
|
|
1075
|
+
double value = values.get(index)[elementIndex];
|
|
1076
|
+
emitNestedListArrayRead(line, name, index, elementIndex, value);
|
|
1077
|
+
return value;
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
public static double readDoubleArrayListAtLine(int line, String name, java.util.List<double[]> values, int index, int elementIndex, String indexSource, String elementIndexSource) {
|
|
1081
|
+
double value = values.get(index)[elementIndex];
|
|
1082
|
+
emitNestedListArrayRead(line, name, index, elementIndex, value, indexSourcesJson(indexSource, elementIndexSource));
|
|
1083
|
+
return value;
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
public static float readFloatArrayListAtLine(int line, String name, java.util.List<float[]> values, int index, int elementIndex) {
|
|
1087
|
+
float value = values.get(index)[elementIndex];
|
|
1088
|
+
emitNestedListArrayRead(line, name, index, elementIndex, value);
|
|
1089
|
+
return value;
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
public static float readFloatArrayListAtLine(int line, String name, java.util.List<float[]> values, int index, int elementIndex, String indexSource, String elementIndexSource) {
|
|
1093
|
+
float value = values.get(index)[elementIndex];
|
|
1094
|
+
emitNestedListArrayRead(line, name, index, elementIndex, value, indexSourcesJson(indexSource, elementIndexSource));
|
|
1095
|
+
return value;
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
public static byte readByteArrayListAtLine(int line, String name, java.util.List<byte[]> values, int index, int elementIndex) {
|
|
1099
|
+
byte value = values.get(index)[elementIndex];
|
|
1100
|
+
emitNestedListArrayRead(line, name, index, elementIndex, value);
|
|
1101
|
+
return value;
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
public static byte readByteArrayListAtLine(int line, String name, java.util.List<byte[]> values, int index, int elementIndex, String indexSource, String elementIndexSource) {
|
|
1105
|
+
byte value = values.get(index)[elementIndex];
|
|
1106
|
+
emitNestedListArrayRead(line, name, index, elementIndex, value, indexSourcesJson(indexSource, elementIndexSource));
|
|
1107
|
+
return value;
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
public static short readShortArrayListAtLine(int line, String name, java.util.List<short[]> values, int index, int elementIndex) {
|
|
1111
|
+
short value = values.get(index)[elementIndex];
|
|
1112
|
+
emitNestedListArrayRead(line, name, index, elementIndex, value);
|
|
1113
|
+
return value;
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
public static short readShortArrayListAtLine(int line, String name, java.util.List<short[]> values, int index, int elementIndex, String indexSource, String elementIndexSource) {
|
|
1117
|
+
short value = values.get(index)[elementIndex];
|
|
1118
|
+
emitNestedListArrayRead(line, name, index, elementIndex, value, indexSourcesJson(indexSource, elementIndexSource));
|
|
1119
|
+
return value;
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
public static <T> T readObjectArrayListAtLine(int line, String name, java.util.List<T[]> values, int index, int elementIndex) {
|
|
1123
|
+
T value = values.get(index)[elementIndex];
|
|
1124
|
+
emitNestedListArrayRead(line, name, index, elementIndex, value);
|
|
1125
|
+
return value;
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
public static <T> T readObjectArrayListAtLine(int line, String name, java.util.List<T[]> values, int index, int elementIndex, String indexSource, String elementIndexSource) {
|
|
1129
|
+
T value = values.get(index)[elementIndex];
|
|
1130
|
+
emitNestedListArrayRead(line, name, index, elementIndex, value, indexSourcesJson(indexSource, elementIndexSource));
|
|
1131
|
+
return value;
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
public static char readStringCharAtLine(int line, String name, CharSequence value, int index) {
|
|
1135
|
+
char result = value.charAt(index);
|
|
1136
|
+
emit("trace:{\"kind\":\"read\",\"line\":" + line + ",\"target\":{\"variable\":\"" + name + "\",\"path\":[" + serializeResult(index) + "]},\"value\":" + serializeResult(String.valueOf(result)) + "}");
|
|
1137
|
+
return result;
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
public static char readStringCharAtLine(int line, String name, CharSequence value, int index, String indexSource) {
|
|
1141
|
+
char result = value.charAt(index);
|
|
1142
|
+
if (indexSource != null) LAST_INDEX_SOURCE.set(indexSource);
|
|
1143
|
+
emitTraceRead(line, name, "[" + serializeResult(index) + "]", String.valueOf(result), indexSourcesJson(indexSource));
|
|
1144
|
+
return result;
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
public static char readStringMatrixCharAtLine(int line, String name, CharSequence[] values, int row, int col) {
|
|
1148
|
+
char result = values[row].charAt(col);
|
|
1149
|
+
emitTraceRead(line, name, "[" + serializeResult(row) + "," + serializeResult(col) + "]", String.valueOf(result));
|
|
1150
|
+
return result;
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
public static char readStringMatrixCharAtLine(int line, String name, CharSequence[] values, int row, int col, String rowSource, String colSource) {
|
|
1154
|
+
char result = values[row].charAt(col);
|
|
1155
|
+
emitTraceRead(line, name, "[" + serializeResult(row) + "," + serializeResult(col) + "]", String.valueOf(result), indexSourcesJson(rowSource, colSource));
|
|
1156
|
+
return result;
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
private static String consumeLastIndexSource() {
|
|
1160
|
+
String source = LAST_INDEX_SOURCE.get();
|
|
1161
|
+
LAST_INDEX_SOURCE.remove();
|
|
1162
|
+
return source;
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
public static String jsonString(String value) {
|
|
1166
|
+
if (value == null) return "null";
|
|
1167
|
+
StringBuilder builder = new StringBuilder();
|
|
1168
|
+
builder.append('"');
|
|
1169
|
+
for (int index = 0; index < value.length(); index++) {
|
|
1170
|
+
char ch = value.charAt(index);
|
|
1171
|
+
switch (ch) {
|
|
1172
|
+
case '"':
|
|
1173
|
+
builder.append("\\\"");
|
|
1174
|
+
break;
|
|
1175
|
+
case '\\':
|
|
1176
|
+
builder.append("\\\\");
|
|
1177
|
+
break;
|
|
1178
|
+
case '\n':
|
|
1179
|
+
builder.append("\\n");
|
|
1180
|
+
break;
|
|
1181
|
+
case '\r':
|
|
1182
|
+
builder.append("\\r");
|
|
1183
|
+
break;
|
|
1184
|
+
case '\t':
|
|
1185
|
+
builder.append("\\t");
|
|
1186
|
+
break;
|
|
1187
|
+
default:
|
|
1188
|
+
if (ch < 0x20) {
|
|
1189
|
+
builder.append(String.format("\\u%04x", (int) ch));
|
|
1190
|
+
} else {
|
|
1191
|
+
builder.append(ch);
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
builder.append('"');
|
|
1196
|
+
return builder.toString();
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
public static int readIntMatrixAtLine(int line, String name, int[][] values, int row, int col, String rowSource, String colSource) {
|
|
1200
|
+
int value = values[row][col];
|
|
1201
|
+
emitMatrixRead(line, name, row, col, value, indexSourcesJson(rowSource, colSource));
|
|
1202
|
+
return value;
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
public static boolean readBooleanMatrixAtLine(int line, String name, boolean[][] values, int row, int col, String rowSource, String colSource) {
|
|
1206
|
+
boolean value = values[row][col];
|
|
1207
|
+
emitMatrixRead(line, name, row, col, value, indexSourcesJson(rowSource, colSource));
|
|
1208
|
+
return value;
|
|
1209
|
+
}
|
|
1210
|
+
|
|
1211
|
+
public static char readCharMatrixAtLine(int line, String name, char[][] values, int row, int col, String rowSource, String colSource) {
|
|
1212
|
+
char value = values[row][col];
|
|
1213
|
+
emitMatrixRead(line, name, row, col, String.valueOf(value), indexSourcesJson(rowSource, colSource));
|
|
1214
|
+
return value;
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
public static long readLongMatrixAtLine(int line, String name, long[][] values, int row, int col) {
|
|
1218
|
+
long value = values[row][col];
|
|
1219
|
+
emitMatrixRead(line, name, row, col, value);
|
|
1220
|
+
return value;
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
public static long readLongMatrixAtLine(int line, String name, long[][] values, int row, int col, String rowSource, String colSource) {
|
|
1224
|
+
long value = values[row][col];
|
|
1225
|
+
emitMatrixRead(line, name, row, col, value, indexSourcesJson(rowSource, colSource));
|
|
1226
|
+
return value;
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
public static double readDoubleMatrixAtLine(int line, String name, double[][] values, int row, int col) {
|
|
1230
|
+
double value = values[row][col];
|
|
1231
|
+
emitMatrixRead(line, name, row, col, value);
|
|
1232
|
+
return value;
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
public static double readDoubleMatrixAtLine(int line, String name, double[][] values, int row, int col, String rowSource, String colSource) {
|
|
1236
|
+
double value = values[row][col];
|
|
1237
|
+
emitMatrixRead(line, name, row, col, value, indexSourcesJson(rowSource, colSource));
|
|
1238
|
+
return value;
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
public static float readFloatMatrixAtLine(int line, String name, float[][] values, int row, int col) {
|
|
1242
|
+
float value = values[row][col];
|
|
1243
|
+
emitMatrixRead(line, name, row, col, value);
|
|
1244
|
+
return value;
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
public static float readFloatMatrixAtLine(int line, String name, float[][] values, int row, int col, String rowSource, String colSource) {
|
|
1248
|
+
float value = values[row][col];
|
|
1249
|
+
emitMatrixRead(line, name, row, col, value, indexSourcesJson(rowSource, colSource));
|
|
1250
|
+
return value;
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
public static byte readByteMatrixAtLine(int line, String name, byte[][] values, int row, int col) {
|
|
1254
|
+
byte value = values[row][col];
|
|
1255
|
+
emitMatrixRead(line, name, row, col, value);
|
|
1256
|
+
return value;
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
public static byte readByteMatrixAtLine(int line, String name, byte[][] values, int row, int col, String rowSource, String colSource) {
|
|
1260
|
+
byte value = values[row][col];
|
|
1261
|
+
emitMatrixRead(line, name, row, col, value, indexSourcesJson(rowSource, colSource));
|
|
1262
|
+
return value;
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
public static short readShortMatrixAtLine(int line, String name, short[][] values, int row, int col) {
|
|
1266
|
+
short value = values[row][col];
|
|
1267
|
+
emitMatrixRead(line, name, row, col, value);
|
|
1268
|
+
return value;
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
public static short readShortMatrixAtLine(int line, String name, short[][] values, int row, int col, String rowSource, String colSource) {
|
|
1272
|
+
short value = values[row][col];
|
|
1273
|
+
emitMatrixRead(line, name, row, col, value, indexSourcesJson(rowSource, colSource));
|
|
1274
|
+
return value;
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
public static <T> T readObjectMatrixAtLine(int line, String name, T[][] values, int row, int col, String rowSource, String colSource) {
|
|
1278
|
+
T value = values[row][col];
|
|
1279
|
+
emitMatrixRead(line, name, row, col, value, indexSourcesJson(rowSource, colSource));
|
|
1280
|
+
return value;
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
private static void emitMatrixRead(int line, String name, int row, int col, Object value) {
|
|
1284
|
+
emit("trace:{\"kind\":\"read\",\"line\":" + line + ",\"target\":{\"variable\":\"" + name + "\",\"path\":[" + serializeResult(row) + "," + serializeResult(col) + "]},\"value\":" + serializeResult(value) + "}");
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
private static void emitMatrixRead(int line, String name, int row, int col, Object value, String indexSourcesJson) {
|
|
1288
|
+
emitTraceRead(line, name, "[" + serializeResult(row) + "," + serializeResult(col) + "]", value, indexSourcesJson);
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
private static void emitNestedListArrayRead(int line, String name, int index, int elementIndex, Object value) {
|
|
1292
|
+
emit("trace:{\"kind\":\"read\",\"line\":" + line + ",\"target\":{\"variable\":\"" + name + "\",\"path\":[" + serializeResult(index) + "," + serializeResult(elementIndex) + "]},\"value\":" + serializeResult(value) + "}");
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1295
|
+
private static void emitNestedListArrayRead(int line, String name, int index, int elementIndex, Object value, String indexSourcesJson) {
|
|
1296
|
+
emitTraceRead(line, name, "[" + serializeResult(index) + "," + serializeResult(elementIndex) + "]", value, indexSourcesJson);
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1299
|
+
private static void emitTraceRead(int line, String name, String pathJson, Object value) {
|
|
1300
|
+
emitTraceRead(line, name, pathJson, value, null);
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
private static void emitTraceRead(int line, String name, String pathJson, Object value, String indexSourcesJson) {
|
|
1304
|
+
StringBuilder out = new StringBuilder("trace:{\"kind\":\"read\",\"line\":");
|
|
1305
|
+
out.append(line).append(",\"target\":{\"variable\":").append(jsonString(name)).append(",\"path\":").append(pathJson);
|
|
1306
|
+
if (indexSourcesJson != null) out.append(",\"indexSources\":").append(indexSourcesJson);
|
|
1307
|
+
out.append("},\"value\":").append(serializeResult(value)).append("}");
|
|
1308
|
+
emit(out.toString());
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
private static void emitTraceReadWithIterationBinding(int line, String name, String pathJson, Object value, String bindingVariable) {
|
|
1312
|
+
emitTraceReadWithIterationBinding(line, name, pathJson, value, bindingVariable, null);
|
|
1313
|
+
}
|
|
1314
|
+
|
|
1315
|
+
private static void emitTraceReadWithIterationBinding(int line, String name, String pathJson, Object value, String bindingVariable, String indexSourcesJson) {
|
|
1316
|
+
StringBuilder out = new StringBuilder("trace:{\"kind\":\"read\",\"line\":");
|
|
1317
|
+
out.append(line).append(",\"target\":{\"variable\":").append(jsonString(name)).append(",\"path\":").append(pathJson);
|
|
1318
|
+
if (indexSourcesJson != null) out.append(",\"indexSources\":").append(indexSourcesJson);
|
|
1319
|
+
out.append("}");
|
|
1320
|
+
out.append(",\"value\":").append(serializeResult(value));
|
|
1321
|
+
out.append(",\"binding\":{\"kind\":\"iteration\",\"variable\":").append(jsonString(bindingVariable)).append("}}");
|
|
1322
|
+
emit(out.toString());
|
|
1323
|
+
}
|
|
1324
|
+
|
|
1325
|
+
private static void emitTraceWrite(int line, String name, String pathJson, Object value) {
|
|
1326
|
+
emitTraceWrite(line, name, pathJson, value, null);
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
public static void emitScalarWriteAtLine(int line, String name, Object value) {
|
|
1330
|
+
emit("trace:{\"kind\":\"write\",\"line\":" + line + ",\"target\":{\"variable\":" + jsonString(name) + "},\"value\":" + serializeResult(value) + "}");
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1333
|
+
private static void emitTraceWrite(int line, String name, String pathJson, Object value, String indexSourcesJson) {
|
|
1334
|
+
StringBuilder out = new StringBuilder("trace:{\"kind\":\"write\",\"line\":");
|
|
1335
|
+
out.append(line).append(",\"target\":{\"variable\":").append(jsonString(name)).append(",\"path\":").append(pathJson);
|
|
1336
|
+
if (indexSourcesJson != null) out.append(",\"indexSources\":").append(indexSourcesJson);
|
|
1337
|
+
out.append("},\"value\":").append(serializeResult(value)).append("}");
|
|
1338
|
+
emit(out.toString());
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
private static void emitTraceMutate(int line, String name, String pathJson, String method) {
|
|
1342
|
+
emitTraceMutate(line, name, pathJson, method, null);
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
private static void emitTraceMutate(int line, String name, String pathJson, String method, String indexSourcesJson) {
|
|
1346
|
+
emitTraceMutate(line, name, pathJson, method, indexSourcesJson, null);
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
private static void emitTraceMutate(int line, String name, String pathJson, String method, String indexSourcesJson, String argsJson) {
|
|
1350
|
+
StringBuilder out = new StringBuilder("trace:{\"kind\":\"mutate\",\"line\":");
|
|
1351
|
+
out.append(line).append(",\"target\":{\"variable\":").append(jsonString(name));
|
|
1352
|
+
if (pathJson != null) out.append(",\"path\":").append(pathJson);
|
|
1353
|
+
if (indexSourcesJson != null) out.append(",\"indexSources\":").append(indexSourcesJson);
|
|
1354
|
+
out.append("}");
|
|
1355
|
+
if (method != null && !method.isEmpty()) out.append(",\"method\":").append(jsonString(method));
|
|
1356
|
+
if (argsJson != null) out.append(",\"args\":").append(argsJson);
|
|
1357
|
+
out.append("}");
|
|
1358
|
+
emit(out.toString());
|
|
1359
|
+
}
|
|
1360
|
+
|
|
1361
|
+
private static String serializeArgs(Object... args) {
|
|
1362
|
+
StringBuilder out = new StringBuilder("[");
|
|
1363
|
+
if (args != null) {
|
|
1364
|
+
for (int index = 0; index < args.length; index++) {
|
|
1365
|
+
if (index > 0) out.append(",");
|
|
1366
|
+
out.append(serializeResult(args[index]));
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
out.append("]");
|
|
1370
|
+
return out.toString();
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1373
|
+
private static String indexSourcesJson(String... sources) {
|
|
1374
|
+
if (sources == null || sources.length == 0) return null;
|
|
1375
|
+
StringBuilder out = new StringBuilder("[");
|
|
1376
|
+
for (int index = 0; index < sources.length; index++) {
|
|
1377
|
+
if (index > 0) out.append(",");
|
|
1378
|
+
String source = sources[index];
|
|
1379
|
+
out.append(source == null || source.isEmpty() ? "null" : jsonString(source));
|
|
1380
|
+
}
|
|
1381
|
+
out.append("]");
|
|
1382
|
+
return out.toString();
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1385
|
+
private static final class SnapshotEntry {
|
|
1386
|
+
final String name;
|
|
1387
|
+
final String value;
|
|
1388
|
+
|
|
1389
|
+
SnapshotEntry(String name, String value) {
|
|
1390
|
+
this.name = name;
|
|
1391
|
+
this.value = value;
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
private static final class TraceFrame {
|
|
1396
|
+
final String functionName;
|
|
1397
|
+
final int line;
|
|
1398
|
+
final String argsJson;
|
|
1399
|
+
|
|
1400
|
+
TraceFrame(String functionName, int line, String argsJson) {
|
|
1401
|
+
this.functionName = functionName == null ? "" : functionName;
|
|
1402
|
+
this.line = line;
|
|
1403
|
+
this.argsJson = argsJson;
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
}
|