Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java code generation fixes #809

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Src/PCompiler/CompilerCore/Backend/Java/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ internal static IEnumerable<string> 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
Expand Down Expand Up @@ -227,9 +227,9 @@ internal static string AsFFIComment(string line)
internal static readonly string PValueClass = "prt.values.PValue";

/// <summary>
/// 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.
/// </summary>
internal static readonly string EventsClass = "prt.events.Event";
internal static readonly string EventsClass = "prt.events.PEvent";

#endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(")");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 6 additions & 0 deletions Src/PCompiler/CompilerCore/Backend/Java/TypeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,11 @@ internal JMap(JType k, JType v)
/// The type of a collection containing the keys of this Map.
/// </summary>
internal string KeyCollectionType => $"ArrayList<{_k.ReferenceTypeName}>";

/// <summary>
/// The name of the () -> Set method that produces the values in the map.
/// </summary>
internal string ValuesMethodName => "values";

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

internal class JVoid : JType
Expand Down
Loading