Skip to content

Commit

Permalink
Merge branch 'master' into dev/aman
Browse files Browse the repository at this point in the history
  • Loading branch information
aman-goel committed Nov 7, 2023
2 parents 5a8db65 + 1e11ea7 commit 37bd807
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions Src/PCompiler/CompilerCore/Backend/Java/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ Please separate each generated class into its own .java file (detailed throughou

public static readonly string FFIPackage = "PForeign";
public static readonly string FFIGlobalScopeCname = "PObserveGlobal";
public static readonly string FFILocalScopeSuffix = "Foreign";


// Something that is clearly not valid Java.
Expand Down
6 changes: 3 additions & 3 deletions Src/PCompiler/CompilerCore/Backend/Java/FFIStubGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ private void WriteFFITypesHeader(string classname)
private void WriteFFIHeader(string monitorName)
{
WriteLine(Constants.AsFFIComment(
$"Please place and complete the following class in {Constants.FFIPackage}/{monitorName}.java :"));
$"Please place and complete the following class in {Constants.FFIPackage}/{monitorName}{Constants.FFILocalScopeSuffix}.java :"));
}

private void WriteForeignTypeStub(ForeignType t)
Expand Down Expand Up @@ -275,7 +275,7 @@ private void WriteForeignFunctions(Machine m)
// Class definition: By convention, this "para-class" has the same name as
// the P machine it is defined within, to mimic the C#-style partial class mixin
// functionalty that we are not afforded in Java, unfortunately.
WriteLine($"public class {mname} {{");
WriteLine($"public class {mname}{Constants.FFILocalScopeSuffix} {{");
foreach (var f in ffs)
{
WriteForeignFunctionStub(f, m);
Expand Down Expand Up @@ -324,7 +324,7 @@ void WriteForeignFunctionStub(Function f, Machine m = null)
}

WriteLine(") {");
WriteLine(" /* throws RaiseEventException, TransitionException */ {");
WriteLine(" /* throws RaiseEventException, TransitionException */");

if (ret is TypeManager.JType.JVoid _)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ private void WriteFunctionCallExpr(Function f, IEnumerable<IPExpr> args)
var ffiBridge = Names.FFIBridgeForMachine(
isStatic
? Constants.FFIGlobalScopeCname
: _currentMachine.Name);
: $"{_currentMachine.Name}{Constants.FFILocalScopeSuffix}");
Write($"{ffiBridge}.{fname}(");

// All foreign functions have an implicit first argument to the current machine
Expand Down

0 comments on commit 37bd807

Please sign in to comment.