diff --git a/Src/PCompiler/CompilerCore/Backend/Java/Constants.cs b/Src/PCompiler/CompilerCore/Backend/Java/Constants.cs index d3ab2b30e..98658c2d5 100644 --- a/Src/PCompiler/CompilerCore/Backend/Java/Constants.cs +++ b/Src/PCompiler/CompilerCore/Backend/Java/Constants.cs @@ -52,7 +52,7 @@ internal static IEnumerable ImportStatements() #region Event source generation - public static readonly string EventNamespaceName = "Events"; + public static readonly string EventNamespaceName = "PEvents"; public static readonly string EventDefnFileName = $"{EventNamespaceName}.java"; #endregion @@ -227,9 +227,9 @@ internal static string AsFFIComment(string line) internal static readonly string PValueClass = "prt.values.PValue"; /// - /// The fully-qualified class name of the Java P runtime's Event class. + /// The fully-qualified class name of the Java P runtime's PEvent class. /// - internal static readonly string EventsClass = "prt.events.Event"; + internal static readonly string EventsClass = "prt.events.PEvent"; #endregion diff --git a/Src/PCompiler/CompilerCore/Backend/Java/JavaSourceGenerator.cs b/Src/PCompiler/CompilerCore/Backend/Java/JavaSourceGenerator.cs index e20d520fd..582d1427e 100644 --- a/Src/PCompiler/CompilerCore/Backend/Java/JavaSourceGenerator.cs +++ b/Src/PCompiler/CompilerCore/Backend/Java/JavaSourceGenerator.cs @@ -105,6 +105,7 @@ internal void WriteClone(TypeManager.JType t, Action writeTermToBeCloned) case TypeManager.JType.JSet _: case TypeManager.JType.JForeign _: case TypeManager.JType.JNamedTuple _: + case TypeManager.JType.JEvent _: Write($"{Constants.PrtDeepCloneMethodName}("); writeTermToBeCloned(); Write(")"); diff --git a/Src/PCompiler/CompilerCore/Backend/Java/MachineGenerator.cs b/Src/PCompiler/CompilerCore/Backend/Java/MachineGenerator.cs index a9cbadb52..5c369e820 100644 --- a/Src/PCompiler/CompilerCore/Backend/Java/MachineGenerator.cs +++ b/Src/PCompiler/CompilerCore/Backend/Java/MachineGenerator.cs @@ -830,7 +830,7 @@ private void WriteExpr(IPExpr expr) // construct a new List from that collection. Write($"new {mt.ValueCollectionType}("); WriteExpr(ve.Expr); - Write($".{mt.KeysMethodName}()"); + Write($".{mt.ValuesMethodName}()"); Write(")"); break; } diff --git a/Src/PCompiler/CompilerCore/Backend/Java/TypeManager.cs b/Src/PCompiler/CompilerCore/Backend/Java/TypeManager.cs index 1afbace9d..3e91f481b 100644 --- a/Src/PCompiler/CompilerCore/Backend/Java/TypeManager.cs +++ b/Src/PCompiler/CompilerCore/Backend/Java/TypeManager.cs @@ -234,6 +234,11 @@ internal JMap(JType k, JType v) /// The type of a collection containing the keys of this Map. /// internal string KeyCollectionType => $"ArrayList<{_k.ReferenceTypeName}>"; + + /// + /// The name of the () -> Set method that produces the values in the map. + /// + internal string ValuesMethodName => "values"; /// /// The type of a collection containing the keys of this Map. @@ -307,6 +312,7 @@ internal JEvent() _unboxedType = $"{Constants.EventsClass}"; } internal override bool IsPrimitive => false; + internal override string DefaultValue => "null"; } internal class JVoid : JType