Skip to content

Commit 49055ad

Browse files
ChristineZh0uChristine Zhou
andauthored
Java code generation fixes (#809)
Co-authored-by: Christine Zhou <zhouchrs@amazon.com>
1 parent 545dec4 commit 49055ad

4 files changed

Lines changed: 11 additions & 4 deletions

File tree

Src/PCompiler/CompilerCore/Backend/Java/Constants.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ internal static IEnumerable<string> ImportStatements()
5252

5353
#region Event source generation
5454

55-
public static readonly string EventNamespaceName = "Events";
55+
public static readonly string EventNamespaceName = "PEvents";
5656
public static readonly string EventDefnFileName = $"{EventNamespaceName}.java";
5757

5858
#endregion
@@ -227,9 +227,9 @@ internal static string AsFFIComment(string line)
227227
internal static readonly string PValueClass = "prt.values.PValue";
228228

229229
/// <summary>
230-
/// The fully-qualified class name of the Java P runtime's Event class.
230+
/// The fully-qualified class name of the Java P runtime's PEvent class.
231231
/// </summary>
232-
internal static readonly string EventsClass = "prt.events.Event";
232+
internal static readonly string EventsClass = "prt.events.PEvent";
233233

234234
#endregion
235235

Src/PCompiler/CompilerCore/Backend/Java/JavaSourceGenerator.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ internal void WriteClone(TypeManager.JType t, Action writeTermToBeCloned)
105105
case TypeManager.JType.JSet _:
106106
case TypeManager.JType.JForeign _:
107107
case TypeManager.JType.JNamedTuple _:
108+
case TypeManager.JType.JEvent _:
108109
Write($"{Constants.PrtDeepCloneMethodName}(");
109110
writeTermToBeCloned();
110111
Write(")");

Src/PCompiler/CompilerCore/Backend/Java/MachineGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ private void WriteExpr(IPExpr expr)
830830
// construct a new List from that collection.
831831
Write($"new {mt.ValueCollectionType}(");
832832
WriteExpr(ve.Expr);
833-
Write($".{mt.KeysMethodName}()");
833+
Write($".{mt.ValuesMethodName}()");
834834
Write(")");
835835
break;
836836
}

Src/PCompiler/CompilerCore/Backend/Java/TypeManager.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,11 @@ internal JMap(JType k, JType v)
234234
/// The type of a collection containing the keys of this Map.
235235
/// </summary>
236236
internal string KeyCollectionType => $"ArrayList<{_k.ReferenceTypeName}>";
237+
238+
/// <summary>
239+
/// The name of the () -> Set method that produces the values in the map.
240+
/// </summary>
241+
internal string ValuesMethodName => "values";
237242

238243
/// <summary>
239244
/// The type of a collection containing the keys of this Map.
@@ -307,6 +312,7 @@ internal JEvent()
307312
_unboxedType = $"{Constants.EventsClass}<?>";
308313
}
309314
internal override bool IsPrimitive => false;
315+
internal override string DefaultValue => "null";
310316
}
311317

312318
internal class JVoid : JType

0 commit comments

Comments
 (0)