-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
- Loading branch information
There are no files selected for viewing
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 GitHub Actions / Build-And-Test-MacOS
Check warning on line 5 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PFrozenMutationException.cs GitHub Actions / Build-And-Test-Ubuntu
Check warning on line 5 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PFrozenMutationException.cs GitHub Actions / Build-And-Test-MacOS
Check warning on line 5 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PFrozenMutationException.cs GitHub Actions / Build-And-Test-Windows
Check warning on line 5 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PFrozenMutationException.cs GitHub Actions / Build-And-Test-Ubuntu
|
||
{ | ||
public PFrozenMutationException() | ||
Check warning on line 7 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PFrozenMutationException.cs GitHub Actions / Build-And-Test-MacOS
Check warning on line 7 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PFrozenMutationException.cs GitHub Actions / Build-And-Test-Ubuntu
Check warning on line 7 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PFrozenMutationException.cs GitHub Actions / Build-And-Test-MacOS
Check warning on line 7 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PFrozenMutationException.cs GitHub Actions / Build-And-Test-Windows
Check warning on line 7 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PFrozenMutationException.cs GitHub Actions / Build-And-Test-Ubuntu
|
||
{ | ||
} | ||
|
||
public PFrozenMutationException(string message) : base(message) | ||
Check warning on line 11 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PFrozenMutationException.cs GitHub Actions / Build-And-Test-MacOS
Check warning on line 11 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PFrozenMutationException.cs GitHub Actions / Build-And-Test-Ubuntu
Check warning on line 11 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PFrozenMutationException.cs GitHub Actions / Build-And-Test-MacOS
Check warning on line 11 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PFrozenMutationException.cs GitHub Actions / Build-And-Test-Windows
Check warning on line 11 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PFrozenMutationException.cs GitHub Actions / Build-And-Test-Ubuntu
|
||
{ | ||
} | ||
} | ||
} |
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 GitHub Actions / Build-And-Test-MacOS
Check warning on line 5 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PIllegalCoercionException.cs GitHub Actions / Build-And-Test-Ubuntu
Check warning on line 5 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PIllegalCoercionException.cs GitHub Actions / Build-And-Test-MacOS
Check warning on line 5 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PIllegalCoercionException.cs GitHub Actions / Build-And-Test-Windows
Check warning on line 5 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PIllegalCoercionException.cs GitHub Actions / Build-And-Test-Ubuntu
|
||
{ | ||
public PIllegalCoercionException() | ||
Check warning on line 7 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PIllegalCoercionException.cs GitHub Actions / Build-And-Test-MacOS
Check warning on line 7 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PIllegalCoercionException.cs GitHub Actions / Build-And-Test-Ubuntu
Check warning on line 7 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PIllegalCoercionException.cs GitHub Actions / Build-And-Test-MacOS
Check warning on line 7 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PIllegalCoercionException.cs GitHub Actions / Build-And-Test-Windows
Check warning on line 7 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PIllegalCoercionException.cs GitHub Actions / Build-And-Test-Ubuntu
|
||
{ | ||
} | ||
|
||
public PIllegalCoercionException(string message) : base(message) | ||
Check warning on line 11 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PIllegalCoercionException.cs GitHub Actions / Build-And-Test-MacOS
Check warning on line 11 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PIllegalCoercionException.cs GitHub Actions / Build-And-Test-Ubuntu
Check warning on line 11 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PIllegalCoercionException.cs GitHub Actions / Build-And-Test-MacOS
Check warning on line 11 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PIllegalCoercionException.cs GitHub Actions / Build-And-Test-Windows
Check warning on line 11 in Src/PChecker/CheckerCore/PRuntime/Exceptions/PIllegalCoercionException.cs GitHub Actions / Build-And-Test-Ubuntu
|
||
{ | ||
} | ||
|
||
public PIllegalCoercionException(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 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) | ||
{ | ||
|
||
} | ||
} | ||
} |
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 | ||
{ | ||
} | ||
} | ||
} |
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) | ||
{ | ||
} | ||
} | ||
} |
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; | ||
} | ||
} | ||
} |