Skip to content

Commit

Permalink
Moved the CSharpRuntime for P into the CheckerCore
Browse files Browse the repository at this point in the history
  • Loading branch information
ankushdesai committed May 21, 2024
1 parent fe1e4f7 commit 78d9088
Show file tree
Hide file tree
Showing 38 changed files with 3,346 additions and 76 deletions.
9 changes: 0 additions & 9 deletions P.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30011.22
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Runtime", "Runtime", "{D641DC13-F2F0-4365-963A-DCFC80BABCAA}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{31FBBC4D-8756-4D60-B8D5-ED9E0FC8D4C1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTests", "Tst\UnitTests\UnitTests.csproj", "{71691381-D3C9-478C-BA37-A94032A536DF}"
Expand All @@ -15,8 +13,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PCommandLine", "Src\PCompil
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CompilerCore", "Src\PCompiler\CompilerCore\CompilerCore.csproj", "{41F39ADD-B75F-473F-AC41-D1A9CDA9A9CD}"
EndProject
Project("{9344BDBB-3E7F-41FC-A0DD-8665D75EE146}") = "CSharpRuntime", "Src\PRuntimes\PCSharpRuntime\CSharpRuntime.csproj", "{27E011B3-3995-454A-B200-57800CC941DA}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PChecker", "PChecker", "{F7D2A6F5-841A-4E22-9ECD-2E1CF736F7EA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CheckerCore", "Src\PChecker\CheckerCore\CheckerCore.csproj", "{37778F65-BDBF-4AEA-BA34-01026A223083}"
Expand All @@ -41,10 +37,6 @@ Global
{41F39ADD-B75F-473F-AC41-D1A9CDA9A9CD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{41F39ADD-B75F-473F-AC41-D1A9CDA9A9CD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{41F39ADD-B75F-473F-AC41-D1A9CDA9A9CD}.Release|Any CPU.Build.0 = Release|Any CPU
{27E011B3-3995-454A-B200-57800CC941DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{27E011B3-3995-454A-B200-57800CC941DA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{27E011B3-3995-454A-B200-57800CC941DA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{27E011B3-3995-454A-B200-57800CC941DA}.Release|Any CPU.Build.0 = Release|Any CPU
{37778F65-BDBF-4AEA-BA34-01026A223083}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{37778F65-BDBF-4AEA-BA34-01026A223083}.Debug|Any CPU.Build.0 = Debug|Any CPU
{37778F65-BDBF-4AEA-BA34-01026A223083}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -56,7 +48,6 @@ Global
GlobalSection(NestedProjects) = preSolution
{71691381-D3C9-478C-BA37-A94032A536DF} = {31FBBC4D-8756-4D60-B8D5-ED9E0FC8D4C1}
{41F39ADD-B75F-473F-AC41-D1A9CDA9A9CD} = {1B21372A-3030-4532-8B30-2A1A3E74527A}
{27E011B3-3995-454A-B200-57800CC941DA} = {D641DC13-F2F0-4365-963A-DCFC80BABCAA}
{37778F65-BDBF-4AEA-BA34-01026A223083} = {F7D2A6F5-841A-4E22-9ECD-2E1CF736F7EA}
{C1A8AF94-F550-4EC7-889A-9D0CCA259502} = {8BAB6184-8545-4E17-8199-86110AC5228F}
EndGlobalSection
Expand Down
54 changes: 0 additions & 54 deletions README.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;

namespace PChecker.PRuntime.Exceptions
{
public class PFrozenMutationException : Exception

Check warning on line 5 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PFrozenMutationException.cs

View workflow job for this annotation

GitHub Actions / Build-And-Test-MacOS

Missing XML comment for publicly visible type or member 'PFrozenMutationException'

Check warning on line 5 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PFrozenMutationException.cs

View workflow job for this annotation

GitHub Actions / Build-And-Test-Ubuntu

Missing XML comment for publicly visible type or member 'PFrozenMutationException'

Check warning on line 5 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PFrozenMutationException.cs

View workflow job for this annotation

GitHub Actions / Build-And-Test-MacOS

Missing XML comment for publicly visible type or member 'PFrozenMutationException'

Check warning on line 5 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PFrozenMutationException.cs

View workflow job for this annotation

GitHub Actions / Build-And-Test-Windows

Missing XML comment for publicly visible type or member 'PFrozenMutationException'

Check warning on line 5 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PFrozenMutationException.cs

View workflow job for this annotation

GitHub Actions / Build-And-Test-Ubuntu

Missing XML comment for publicly visible type or member 'PFrozenMutationException'

Check warning on line 5 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PFrozenMutationException.cs

View workflow job for this annotation

GitHub Actions / Build-And-Test-Windows

Missing XML comment for publicly visible type or member 'PFrozenMutationException'
{
public PFrozenMutationException()

Check warning on line 7 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PFrozenMutationException.cs

View workflow job for this annotation

GitHub Actions / Build-And-Test-MacOS

Missing XML comment for publicly visible type or member 'PFrozenMutationException.PFrozenMutationException()'

Check warning on line 7 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PFrozenMutationException.cs

View workflow job for this annotation

GitHub Actions / Build-And-Test-Ubuntu

Missing XML comment for publicly visible type or member 'PFrozenMutationException.PFrozenMutationException()'

Check warning on line 7 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PFrozenMutationException.cs

View workflow job for this annotation

GitHub Actions / Build-And-Test-MacOS

Missing XML comment for publicly visible type or member 'PFrozenMutationException.PFrozenMutationException()'

Check warning on line 7 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PFrozenMutationException.cs

View workflow job for this annotation

GitHub Actions / Build-And-Test-Windows

Missing XML comment for publicly visible type or member 'PFrozenMutationException.PFrozenMutationException()'

Check warning on line 7 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PFrozenMutationException.cs

View workflow job for this annotation

GitHub Actions / Build-And-Test-Ubuntu

Missing XML comment for publicly visible type or member 'PFrozenMutationException.PFrozenMutationException()'

Check warning on line 7 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PFrozenMutationException.cs

View workflow job for this annotation

GitHub Actions / Build-And-Test-Windows

Missing XML comment for publicly visible type or member 'PFrozenMutationException.PFrozenMutationException()'
{
}

public PFrozenMutationException(string message) : base(message)

Check warning on line 11 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PFrozenMutationException.cs

View workflow job for this annotation

GitHub Actions / Build-And-Test-MacOS

Missing XML comment for publicly visible type or member 'PFrozenMutationException.PFrozenMutationException(string)'

Check warning on line 11 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PFrozenMutationException.cs

View workflow job for this annotation

GitHub Actions / Build-And-Test-Ubuntu

Missing XML comment for publicly visible type or member 'PFrozenMutationException.PFrozenMutationException(string)'

Check warning on line 11 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PFrozenMutationException.cs

View workflow job for this annotation

GitHub Actions / Build-And-Test-MacOS

Missing XML comment for publicly visible type or member 'PFrozenMutationException.PFrozenMutationException(string)'

Check warning on line 11 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PFrozenMutationException.cs

View workflow job for this annotation

GitHub Actions / Build-And-Test-Windows

Missing XML comment for publicly visible type or member 'PFrozenMutationException.PFrozenMutationException(string)'

Check warning on line 11 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PFrozenMutationException.cs

View workflow job for this annotation

GitHub Actions / Build-And-Test-Ubuntu

Missing XML comment for publicly visible type or member 'PFrozenMutationException.PFrozenMutationException(string)'

Check warning on line 11 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PFrozenMutationException.cs

View workflow job for this annotation

GitHub Actions / Build-And-Test-Windows

Missing XML comment for publicly visible type or member 'PFrozenMutationException.PFrozenMutationException(string)'
{
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;

namespace PChecker.PRuntime.Exceptions
{
public class PIllegalCoercionException : Exception

Check warning on line 5 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PIllegalCoercionException.cs

View workflow job for this annotation

GitHub Actions / Build-And-Test-MacOS

Missing XML comment for publicly visible type or member 'PIllegalCoercionException'

Check warning on line 5 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PIllegalCoercionException.cs

View workflow job for this annotation

GitHub Actions / Build-And-Test-Ubuntu

Missing XML comment for publicly visible type or member 'PIllegalCoercionException'

Check warning on line 5 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PIllegalCoercionException.cs

View workflow job for this annotation

GitHub Actions / Build-And-Test-MacOS

Missing XML comment for publicly visible type or member 'PIllegalCoercionException'

Check warning on line 5 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PIllegalCoercionException.cs

View workflow job for this annotation

GitHub Actions / Build-And-Test-Windows

Missing XML comment for publicly visible type or member 'PIllegalCoercionException'

Check warning on line 5 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PIllegalCoercionException.cs

View workflow job for this annotation

GitHub Actions / Build-And-Test-Ubuntu

Missing XML comment for publicly visible type or member 'PIllegalCoercionException'

Check warning on line 5 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PIllegalCoercionException.cs

View workflow job for this annotation

GitHub Actions / Build-And-Test-Windows

Missing XML comment for publicly visible type or member 'PIllegalCoercionException'
{
public PIllegalCoercionException()

Check warning on line 7 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PIllegalCoercionException.cs

View workflow job for this annotation

GitHub Actions / Build-And-Test-MacOS

Missing XML comment for publicly visible type or member 'PIllegalCoercionException.PIllegalCoercionException()'

Check warning on line 7 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PIllegalCoercionException.cs

View workflow job for this annotation

GitHub Actions / Build-And-Test-Ubuntu

Missing XML comment for publicly visible type or member 'PIllegalCoercionException.PIllegalCoercionException()'

Check warning on line 7 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PIllegalCoercionException.cs

View workflow job for this annotation

GitHub Actions / Build-And-Test-MacOS

Missing XML comment for publicly visible type or member 'PIllegalCoercionException.PIllegalCoercionException()'

Check warning on line 7 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PIllegalCoercionException.cs

View workflow job for this annotation

GitHub Actions / Build-And-Test-Windows

Missing XML comment for publicly visible type or member 'PIllegalCoercionException.PIllegalCoercionException()'

Check warning on line 7 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PIllegalCoercionException.cs

View workflow job for this annotation

GitHub Actions / Build-And-Test-Ubuntu

Missing XML comment for publicly visible type or member 'PIllegalCoercionException.PIllegalCoercionException()'

Check warning on line 7 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PIllegalCoercionException.cs

View workflow job for this annotation

GitHub Actions / Build-And-Test-Windows

Missing XML comment for publicly visible type or member 'PIllegalCoercionException.PIllegalCoercionException()'
{
}

public PIllegalCoercionException(string message) : base(message)

Check warning on line 11 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PIllegalCoercionException.cs

View workflow job for this annotation

GitHub Actions / Build-And-Test-MacOS

Missing XML comment for publicly visible type or member 'PIllegalCoercionException.PIllegalCoercionException(string)'

Check warning on line 11 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PIllegalCoercionException.cs

View workflow job for this annotation

GitHub Actions / Build-And-Test-Ubuntu

Missing XML comment for publicly visible type or member 'PIllegalCoercionException.PIllegalCoercionException(string)'

Check warning on line 11 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PIllegalCoercionException.cs

View workflow job for this annotation

GitHub Actions / Build-And-Test-MacOS

Missing XML comment for publicly visible type or member 'PIllegalCoercionException.PIllegalCoercionException(string)'

Check warning on line 11 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PIllegalCoercionException.cs

View workflow job for this annotation

GitHub Actions / Build-And-Test-Windows

Missing XML comment for publicly visible type or member 'PIllegalCoercionException.PIllegalCoercionException(string)'

Check warning on line 11 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PIllegalCoercionException.cs

View workflow job for this annotation

GitHub Actions / Build-And-Test-Ubuntu

Missing XML comment for publicly visible type or member 'PIllegalCoercionException.PIllegalCoercionException(string)'

Check warning on line 11 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PIllegalCoercionException.cs

View workflow job for this annotation

GitHub Actions / Build-And-Test-Windows

Missing XML comment for publicly visible type or member 'PIllegalCoercionException.PIllegalCoercionException(string)'
{
}

public PIllegalCoercionException(string message, Exception innerException) : base(message, innerException)
{
}
}
}
19 changes: 19 additions & 0 deletions Src/PChecker/CheckerCore/PRuntime/Exceptions/PInternalException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;

namespace PChecker.PRuntime.Exceptions
{
public class PInternalException : Exception
{
public PInternalException()
{
}

public PInternalException(string message) : base(message)
{
}

public PInternalException(string message, Exception innerException) : base(message, innerException)
{
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;

namespace PChecker.PRuntime.Exceptions
{
public enum NonStandardReturn
{
Raise,
Goto,
Pop
}

public class PNonStandardReturnException : Exception
{
public PNonStandardReturnException()
{
}

public PNonStandardReturnException(string message) : base(message)
{
}

public PNonStandardReturnException(string message, Exception innerException) : base(message, innerException)
{
}

public NonStandardReturn ReturnKind { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;

namespace PChecker.PRuntime.Exceptions
{
public class PUnreachableCodeException : Exception
{
public PUnreachableCodeException()
{
}

public PUnreachableCodeException(string message) : base(message)
{
}

public PUnreachableCodeException(string message, Exception innerException) : base(message, innerException)
{
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;

namespace PChecker.PRuntime.Exceptions
{
public class PrtInhabitsTypeException : Exception
{
public PrtInhabitsTypeException()
{
}

public PrtInhabitsTypeException(string message) : base(message)
{
}

public PrtInhabitsTypeException(string message, Exception innerException) : base(message, innerException)
{
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;

namespace PChecker.PRuntime.Exceptions
{
public class UnknownNamedTupleFieldAccess : Exception
{
public static UnknownNamedTupleFieldAccess FromFields(string expectedField, IEnumerable<string> actualFields)
{
var msg =
"Field " + expectedField + " absent from NamedTuple with fields " + String.Join(",", actualFields);
return new UnknownNamedTupleFieldAccess(msg);
}

private UnknownNamedTupleFieldAccess(string msg): base(msg)
{

}
}
}
33 changes: 33 additions & 0 deletions Src/PChecker/CheckerCore/PRuntime/GodMachine.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using PChecker.Actors;
using PChecker.Actors.Events;

namespace PChecker.PRuntime
{
public class _GodMachine : StateMachine
{
private void InitOnEntry(Event e)
{
var mainMachine = (e as Config).MainMachine;
CreateActor(mainMachine, mainMachine.Name,
new PMachine.InitializeParametersEvent(
new PMachine.InitializeParameters("I_" + mainMachine.Name, null)));
}

public class Config : Event
{
public Type MainMachine;

public Config(Type main)
{
MainMachine = main;
}
}

[Start]
[OnEntry(nameof(InitOnEntry))]
private class Init : State
{
}
}
}
57 changes: 57 additions & 0 deletions Src/PChecker/CheckerCore/PRuntime/PEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using System;
using PChecker.Actors.Events;
using PChecker.PRuntime.Values;

namespace PChecker.PRuntime
{
public class PEvent : Event, IPrtValue
{
public PEvent() : base()
{
}

public PEvent(IPrtValue payload) : base()
{
Payload = payload;
}

public IPrtValue Payload { get; }

public bool Equals(IPrtValue other)
{
return other != null && GetType().FullName.Equals(other.GetType().FullName);
}

public virtual IPrtValue Clone()
{
throw new NotImplementedException();
}

public object ToDict()
{
return this.GetType().Name;
}

public override bool Equals(object obj)
{
return obj is PEvent other && Equals(other);
}

public override int GetHashCode()
{
return GetType().FullName.GetHashCode();
}

public override string ToString()
{
return GetType().Name;
}
}

public class PHalt : PEvent
{
public PHalt(IPrtValue payload) : base(payload)
{
}
}
}
37 changes: 37 additions & 0 deletions Src/PChecker/CheckerCore/PRuntime/PInterfaces.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System.Collections.Generic;
using System.Linq;
using PChecker.PRuntime.Exceptions;
using PChecker.PRuntime.Values;

namespace PChecker.PRuntime
{
public class PInterfaces
{
private static readonly Dictionary<string, List<string>> Interfaces = new Dictionary<string, List<string>>();

public static void AddInterface(string interfaceName, params string[] permissions)
{
Interfaces.Add(interfaceName, permissions.ToList());
}

public static void Clear()
{
Interfaces.Clear();
}

public static List<string> GetPermissions(string interfaceName)
{
return Interfaces[interfaceName].ToList();
}

public static bool IsCoercionAllowed(PMachineValue val, string interfaceName)
{
if (GetPermissions(interfaceName).Any(ev => !val.Permissions.Contains(ev)))
{
throw new PIllegalCoercionException($"value cannot be coerced to interface {interfaceName}");
}

return true;
}
}
}
Loading

0 comments on commit 78d9088

Please sign in to comment.