diff --git a/ExtendedJavaScriptSubset.sln b/ExtendedJavaScriptSubset.sln
index d134919..523c309 100644
--- a/ExtendedJavaScriptSubset.sln
+++ b/ExtendedJavaScriptSubset.sln
@@ -62,6 +62,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{04AB
samples\this.js = samples\this.js
samples\typeresolving.js = samples\typeresolving.js
samples\vec2d.js = samples\vec2d.js
+ samples\cycled.js = samples\cycled.js
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Src", "Src", "{FB8F6EE1-1942-46D6-954E-9A1647BBDF10}"
diff --git a/samples/cycled.js b/samples/cycled.js
new file mode 100644
index 0000000..18ca8e8
--- /dev/null
+++ b/samples/cycled.js
@@ -0,0 +1,8 @@
+type CycledType = {
+ x: CycledType;
+}
+let obj: CycledType = {
+ x: null;
+}
+obj.x = obj
+print(obj as string)
\ No newline at end of file
diff --git a/src/Domain/HydraScript.Domain.BackEnd/HydraScript.Domain.BackEnd.csproj b/src/Domain/HydraScript.Domain.BackEnd/HydraScript.Domain.BackEnd.csproj
index 7faaaf6..00c662b 100644
--- a/src/Domain/HydraScript.Domain.BackEnd/HydraScript.Domain.BackEnd.csproj
+++ b/src/Domain/HydraScript.Domain.BackEnd/HydraScript.Domain.BackEnd.csproj
@@ -7,4 +7,8 @@
true
+
+ false
+
+
diff --git a/src/Domain/HydraScript.Domain.BackEnd/Impl/Instructions/WithAssignment/AsString.cs b/src/Domain/HydraScript.Domain.BackEnd/Impl/Instructions/WithAssignment/AsString.cs
index 83e7429..85bf6d0 100644
--- a/src/Domain/HydraScript.Domain.BackEnd/Impl/Instructions/WithAssignment/AsString.cs
+++ b/src/Domain/HydraScript.Domain.BackEnd/Impl/Instructions/WithAssignment/AsString.cs
@@ -3,25 +3,34 @@
namespace HydraScript.Domain.BackEnd.Impl.Instructions.WithAssignment;
-public class AsString(IValue value) : Simple(value)
+public partial class AsString(IValue value) : Simple(value)
{
+ private static readonly AsStringSerializationContext AsStringJsonContext = new(new JsonSerializerOptions
+ {
+ WriteIndented = true,
+ ReferenceHandler = ReferenceHandler.IgnoreCycles,
+ PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
+ NumberHandling = JsonNumberHandling.AllowNamedFloatingPointLiterals
+ });
+
public override IAddress Execute(IExecuteParams executeParams)
{
var frame = executeParams.Frames.Peek();
frame[Left!] = JsonSerializer.Serialize(
- Right.right!.Get(frame),
- new JsonSerializerOptions
- {
- WriteIndented = true,
- PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
- ReferenceHandler = ReferenceHandler.IgnoreCycles,
- NumberHandling = JsonNumberHandling.AllowNamedFloatingPointLiterals
- }
- );
+ value: Right.right!.Get(frame)!,
+ AsStringJsonContext.Object);
return Address.Next;
}
protected override string ToStringInternal() =>
$"{Left} = {Right.right} as string";
+
+ [JsonSourceGenerationOptions(GenerationMode = JsonSourceGenerationMode.Serialization)]
+ [JsonSerializable(typeof(List