diff --git a/Src/PChecker/CheckerCore/PRuntime/PEvent.cs b/Src/PChecker/CheckerCore/PRuntime/PEvent.cs
deleted file mode 100644
index 23a16cc4d3..0000000000
--- a/Src/PChecker/CheckerCore/PRuntime/PEvent.cs
+++ /dev/null
@@ -1,57 +0,0 @@
-using System;
-using PChecker.StateMachines.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)
- {
- }
- }
-}
\ No newline at end of file
diff --git a/Src/PChecker/CheckerCore/PRuntime/PMachine.cs b/Src/PChecker/CheckerCore/PRuntime/PMachine.cs
index f0cf47b3c7..1781646c55 100644
--- a/Src/PChecker/CheckerCore/PRuntime/PMachine.cs
+++ b/Src/PChecker/CheckerCore/PRuntime/PMachine.cs
@@ -58,7 +58,7 @@ protected override OnExceptionOutcome OnException(Exception ex, string methodNam
: base.OnException(ex, methodName, e);
}
- return (ex as UnhandledEventException).UnhandledEvent is PHalt
+ return (ex as UnhandledEventException).UnhandledEvent is Halt
? OnExceptionOutcome.Halt
: base.OnException(ex, methodName, e);
}
@@ -182,7 +182,7 @@ public void Log(string message)
public void Announce(Event ev, object payload = null)
{
Assert(ev != null, "Machine cannot announce a null event");
- if (ev is PHalt)
+ if (ev is Halt)
{
ev = HaltEvent.Instance;
}
@@ -251,7 +251,7 @@ public object ToDict()
}
}
- public class InitializeParametersEvent : PEvent
+ public class InitializeParametersEvent : Event
{
public InitializeParametersEvent(InitializeParameters payload) : base(payload)
{
diff --git a/Src/PChecker/CheckerCore/StateMachines/Events/DefaultEvent.cs b/Src/PChecker/CheckerCore/StateMachines/Events/DefaultEvent.cs
index 3ad12575d4..678b04ac90 100644
--- a/Src/PChecker/CheckerCore/StateMachines/Events/DefaultEvent.cs
+++ b/Src/PChecker/CheckerCore/StateMachines/Events/DefaultEvent.cs
@@ -21,7 +21,6 @@ public sealed class DefaultEvent : Event
/// Initializes a new instance of the class.
///
private DefaultEvent()
- : base()
{
}
}
diff --git a/Src/PChecker/CheckerCore/StateMachines/Events/Event.cs b/Src/PChecker/CheckerCore/StateMachines/Events/Event.cs
index 1567ec5971..5e3245875b 100644
--- a/Src/PChecker/CheckerCore/StateMachines/Events/Event.cs
+++ b/Src/PChecker/CheckerCore/StateMachines/Events/Event.cs
@@ -1,15 +1,56 @@
-// Copyright (c) Microsoft Corporation.
-// Licensed under the MIT License.
-
-using System.Runtime.Serialization;
+using System;
+using PChecker.PRuntime.Values;
namespace PChecker.StateMachines.Events
{
- ///
- /// Abstract class representing an event.
- ///
- [DataContract]
- public abstract class Event
+ public class Event : IPrtValue
+ {
+ public Event()
+ {
+ }
+
+ public Event(IPrtValue payload)
+ {
+ 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 GetType().Name;
+ }
+
+ public override bool Equals(object obj)
+ {
+ return obj is Event other && Equals(other);
+ }
+
+ public override int GetHashCode()
+ {
+ return GetType().FullName.GetHashCode();
+ }
+
+ public override string ToString()
+ {
+ return GetType().Name;
+ }
+ }
+
+ public class Halt : Event
{
+ public Halt(IPrtValue payload) : base(payload)
+ {
+ }
}
}
\ No newline at end of file
diff --git a/Src/PChecker/CheckerCore/StateMachines/Events/GotoStateEvent.cs b/Src/PChecker/CheckerCore/StateMachines/Events/GotoStateEvent.cs
index d77da5dffb..0f7c92b48c 100644
--- a/Src/PChecker/CheckerCore/StateMachines/Events/GotoStateEvent.cs
+++ b/Src/PChecker/CheckerCore/StateMachines/Events/GotoStateEvent.cs
@@ -22,7 +22,6 @@ internal sealed class GotoStateEvent : Event
///
/// Type of the state.
public GotoStateEvent(Type s)
- : base()
{
State = s;
}
diff --git a/Src/PChecker/CheckerCore/StateMachines/Events/HaltEvent.cs b/Src/PChecker/CheckerCore/StateMachines/Events/HaltEvent.cs
index 659d3ca1b3..47e91c5ea2 100644
--- a/Src/PChecker/CheckerCore/StateMachines/Events/HaltEvent.cs
+++ b/Src/PChecker/CheckerCore/StateMachines/Events/HaltEvent.cs
@@ -20,7 +20,6 @@ public sealed class HaltEvent : Event
/// Initializes a new instance of the class.
///
private HaltEvent()
- : base()
{
}
}
diff --git a/Src/PChecker/CheckerCore/StateMachines/Events/WildcardEvent.cs b/Src/PChecker/CheckerCore/StateMachines/Events/WildcardEvent.cs
index 6c2c0dff94..32a7e1787a 100644
--- a/Src/PChecker/CheckerCore/StateMachines/Events/WildcardEvent.cs
+++ b/Src/PChecker/CheckerCore/StateMachines/Events/WildcardEvent.cs
@@ -15,7 +15,6 @@ public sealed class WildCardEvent : Event
/// Initializes a new instance of the class.
///
public WildCardEvent()
- : base()
{
}
}
diff --git a/Src/PChecker/CheckerCore/StateMachines/Logging/PCheckerLogJsonFormatter.cs b/Src/PChecker/CheckerCore/StateMachines/Logging/PCheckerLogJsonFormatter.cs
index e8ca7c406c..fbe857f3b3 100644
--- a/Src/PChecker/CheckerCore/StateMachines/Logging/PCheckerLogJsonFormatter.cs
+++ b/Src/PChecker/CheckerCore/StateMachines/Logging/PCheckerLogJsonFormatter.cs
@@ -75,7 +75,7 @@ private static string GetEventNameWithPayload(Event e)
return e.GetType().Name;
}
- var pe = (PEvent)(e);
+ var pe = (Event)(e);
var payload = pe.Payload == null ? "null" : pe.Payload.ToEscapedString();
var msg = pe.Payload == null ? "" : $" with payload ({payload})";
return $"{GetShortName(e.GetType().Name)}{msg}";
@@ -93,7 +93,7 @@ private static object GetEventPayloadInJson(Event e)
return null;
}
- var pe = (PEvent)(e);
+ var pe = (Event)(e);
return pe.Payload?.ToDict();
}
diff --git a/Src/PChecker/CheckerCore/StateMachines/Logging/PCheckerLogTextFormatter.cs b/Src/PChecker/CheckerCore/StateMachines/Logging/PCheckerLogTextFormatter.cs
index a707b32fde..06b94318f2 100644
--- a/Src/PChecker/CheckerCore/StateMachines/Logging/PCheckerLogTextFormatter.cs
+++ b/Src/PChecker/CheckerCore/StateMachines/Logging/PCheckerLogTextFormatter.cs
@@ -42,7 +42,7 @@ private string GetEventNameWithPayload(Event e)
{
return e.GetType().Name;
}
- var pe = (PEvent)(e);
+ var pe = (Event)(e);
var payload = pe.Payload == null ? "null" : pe.Payload.ToEscapedString();
var msg = pe.Payload == null ? "" : $" with payload ({payload})";
return $"{GetShortName(e.GetType().Name)}{msg}";
diff --git a/Src/PCompiler/CompilerCore/Backend/CSharp/CSharpCodeGenerator.cs b/Src/PCompiler/CompilerCore/Backend/CSharp/CSharpCodeGenerator.cs
index df9137281e..5027ee3989 100644
--- a/Src/PCompiler/CompilerCore/Backend/CSharp/CSharpCodeGenerator.cs
+++ b/Src/PCompiler/CompilerCore/Backend/CSharp/CSharpCodeGenerator.cs
@@ -206,7 +206,7 @@ private void WriteDecl(CompilationContext context, StringWriter output, IPDecl d
break;
- case PEvent pEvent:
+ case Event pEvent:
if (!pEvent.IsBuiltIn)
{
WriteEvent(context, output, pEvent);
@@ -472,15 +472,15 @@ private void WriteInitializeLinkMap(CompilationContext context, StringWriter out
context.WriteLine(output);
}
- private void WriteEvent(CompilationContext context, StringWriter output, PEvent pEvent)
+ private void WriteEvent(CompilationContext context, StringWriter output, Event @event)
{
WriteNameSpacePrologue(context, output);
- var declName = context.Names.GetNameForDecl(pEvent);
+ var declName = context.Names.GetNameForDecl(@event);
// initialize the payload type
- var payloadType = GetCSharpType(pEvent.PayloadType, true);
- context.WriteLine(output, $"internal partial class {declName} : PEvent");
+ var payloadType = GetCSharpType(@event.PayloadType, true);
+ context.WriteLine(output, $"internal partial class {declName} : Event");
context.WriteLine(output, "{");
context.WriteLine(output, $"public {declName}() : base() {{}}");
context.WriteLine(output, $"public {declName} ({payloadType} payload): base(payload)" + "{ }");
@@ -506,7 +506,7 @@ private void WriteMachine(CompilationContext context, StringWriter output, Machi
//create the constructor event
var cTorType = GetCSharpType(machine.PayloadType, true);
- context.Write(output, "public class ConstructorEvent : PEvent");
+ context.Write(output, "public class ConstructorEvent : Event");
context.Write(output, "{");
context.Write(output, $"public ConstructorEvent({cTorType} val) : base(val) {{ }}");
context.WriteLine(output, "}");
@@ -680,7 +680,7 @@ private void WriteNamedFunctionWrapper(CompilationContext context, StringWriter
context.WriteLine(output, $"{context.Names.GetNameForDecl(function.Owner)} currentMachine = this;");
}
- var parameter = function.Signature.Parameters.Any() ? $"({GetCSharpType(function.Signature.ParameterTypes.First())})((PEvent)currentMachine_dequeuedEvent).Payload" : "";
+ var parameter = function.Signature.Parameters.Any() ? $"({GetCSharpType(function.Signature.ParameterTypes.First())})((Event)currentMachine_dequeuedEvent).Payload" : "";
context.WriteLine(output, $"{awaitMethod}{functionName}({parameter});");
context.WriteLine(output, "}");
}
@@ -769,7 +769,7 @@ private void WriteFunctionBody(CompilationContext context, StringWriter output,
{
var param = function.Signature.Parameters.First();
context.WriteLine(output,
- $"{GetCSharpType(param.Type)} {context.Names.GetNameForDecl(param)} = ({GetCSharpType(param.Type)})(gotoPayload ?? ((PEvent)currentMachine_dequeuedEvent).Payload);");
+ $"{GetCSharpType(param.Type)} {context.Names.GetNameForDecl(param)} = ({GetCSharpType(param.Type)})(gotoPayload ?? ((Event)currentMachine_dequeuedEvent).Payload);");
context.WriteLine(output, "this.gotoPayload = null;");
}
}
@@ -1004,14 +1004,14 @@ private void WriteStmt(CompilationContext context, StringWriter output, Function
var eventName = context.Names.GetTemporaryName("recvEvent");
var eventTypeNames = receiveStmt.Cases.Keys.Select(evt => context.Names.GetNameForDecl(evt))
.ToHashSet();
- eventTypeNames.Add("PHalt"); // halt as a special case for receive
+ eventTypeNames.Add("Halt"); // halt as a special case for receive
var recvArgs = string.Join(", ", eventTypeNames.Select(name => $"typeof({name})"));
context.WriteLine(output, $"var {eventName} = await currentMachine.TryReceiveEvent({recvArgs});");
context.WriteLine(output, $"switch ({eventName}) {{");
// add halt as a special case if doesnt exist
- if (receiveStmt.Cases.All(kv => kv.Key.Name != "PHalt"))
+ if (receiveStmt.Cases.All(kv => kv.Key.Name != "Halt"))
{
- context.WriteLine(output,"case PHalt _hv: { currentMachine.TryRaiseEvent(_hv); break;} ");
+ context.WriteLine(output,"case Halt _hv: { currentMachine.TryRaiseEvent(_hv); break;} ");
}
@@ -1386,7 +1386,7 @@ private void WriteExpr(CompilationContext context, StringWriter output, IPExpr p
switch (eventName)
{
case "Halt":
- context.Write(output, "new PHalt()");
+ context.Write(output, "new Halt()");
break;
case "DefaultEvent":
@@ -1579,7 +1579,7 @@ private string GetCSharpType(PLanguageType type, bool isVar = false)
return "PrtString";
case PrimitiveType primitiveType when primitiveType.IsSameTypeAs(PrimitiveType.Event):
- return "PEvent";
+ return "Event";
case PrimitiveType primitiveType when primitiveType.IsSameTypeAs(PrimitiveType.Machine):
return "PMachineValue";
diff --git a/Src/PCompiler/CompilerCore/Backend/CSharp/CSharpNameManager.cs b/Src/PCompiler/CompilerCore/Backend/CSharp/CSharpNameManager.cs
index 01868c7b75..6213828bfe 100644
--- a/Src/PCompiler/CompilerCore/Backend/CSharp/CSharpNameManager.cs
+++ b/Src/PCompiler/CompilerCore/Backend/CSharp/CSharpNameManager.cs
@@ -49,12 +49,12 @@ protected override string ComputeNameForDecl(IPDecl decl)
#pragma warning disable CCN0002 // Non exhaustive patterns in switch block
switch (decl)
{
- case PEvent pEvent:
+ case Event pEvent:
if (pEvent.IsNullEvent)
{
return "DefaultEvent";
}
- return pEvent.IsHaltEvent ? "PHalt" : name;
+ return pEvent.IsHaltEvent ? "Halt" : name;
case State pState:
diff --git a/Src/PCompiler/CompilerCore/Backend/Debugging/IrToPseudoP.cs b/Src/PCompiler/CompilerCore/Backend/Debugging/IrToPseudoP.cs
index a135656dae..ee8a0b93eb 100644
--- a/Src/PCompiler/CompilerCore/Backend/Debugging/IrToPseudoP.cs
+++ b/Src/PCompiler/CompilerCore/Backend/Debugging/IrToPseudoP.cs
@@ -147,7 +147,7 @@ private void WriteTree(IPAST tree)
" };");
break;
- case PEvent pEvent:
+ case Event pEvent:
WriteStmt("event ",
pEvent,
" assert ",
diff --git a/Src/PCompiler/CompilerCore/Backend/Java/Constants.cs b/Src/PCompiler/CompilerCore/Backend/Java/Constants.cs
index 20de91eb60..e0a9a08754 100644
--- a/Src/PCompiler/CompilerCore/Backend/Java/Constants.cs
+++ b/Src/PCompiler/CompilerCore/Backend/Java/Constants.cs
@@ -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 PEvent class.
+ /// The fully-qualified class name of the Java P runtime's Event class.
///
- internal static readonly string PEventsClass = "prt.events.PEvent";
+ internal static readonly string PEventsClass = "prt.events.Event";
#endregion
diff --git a/Src/PCompiler/CompilerCore/Backend/Java/EventGenerator.cs b/Src/PCompiler/CompilerCore/Backend/Java/EventGenerator.cs
index b21a51cc5b..681906c7af 100644
--- a/Src/PCompiler/CompilerCore/Backend/Java/EventGenerator.cs
+++ b/Src/PCompiler/CompilerCore/Backend/Java/EventGenerator.cs
@@ -28,9 +28,9 @@ protected override void GenerateCodeImpl()
}
- private IEnumerable monitoredEvents(IEnumerable machines)
+ private IEnumerable monitoredEvents(IEnumerable machines)
{
- var events = new HashSet();
+ var events = new HashSet();
foreach (var m in machines.Where(m => m.IsSpec))
{
@@ -43,7 +43,7 @@ private IEnumerable monitoredEvents(IEnumerable machines)
return events;
}
- private void WriteEventDecl(PEvent e)
+ private void WriteEventDecl(Event e)
{
var eventName = Names.GetNameForDecl(e);
var argType = Types.JavaTypeFor(e.PayloadType);
diff --git a/Src/PCompiler/CompilerCore/Backend/Java/MachineGenerator.cs b/Src/PCompiler/CompilerCore/Backend/Java/MachineGenerator.cs
index bddba051f2..ccd69a0973 100644
--- a/Src/PCompiler/CompilerCore/Backend/Java/MachineGenerator.cs
+++ b/Src/PCompiler/CompilerCore/Backend/Java/MachineGenerator.cs
@@ -316,7 +316,7 @@ private void WriteStateBuilderEntryHandler(Function f)
WriteLine($".withEntry(this::{fname})");
}
- private void WriteStateBuilderEventHandler(PEvent e, IStateAction a)
+ private void WriteStateBuilderEventHandler(Event e, IStateAction a)
{
var ename = $"{Constants.EventNamespaceName}.{Names.GetNameForDecl(e)}";
diff --git a/Src/PCompiler/CompilerCore/Backend/Java/NameManager.cs b/Src/PCompiler/CompilerCore/Backend/Java/NameManager.cs
index 7806e7dba9..0ff26d6d54 100644
--- a/Src/PCompiler/CompilerCore/Backend/Java/NameManager.cs
+++ b/Src/PCompiler/CompilerCore/Backend/Java/NameManager.cs
@@ -95,10 +95,10 @@ protected override string ComputeNameForDecl(IPDecl decl)
switch (decl)
{
- case PEvent { IsNullEvent: true }:
+ case Event { IsNullEvent: true }:
return "DefaultEvent";
- case PEvent { IsHaltEvent: true }:
- return "PHalt";
+ case Event { IsHaltEvent: true }:
+ return "Halt";
case Interface i:
name = "I_" + i.Name;
break;
diff --git a/Src/PCompiler/CompilerCore/Backend/Java/TypeManager.cs b/Src/PCompiler/CompilerCore/Backend/Java/TypeManager.cs
index 75ec9954c8..9d2a78fbc5 100644
--- a/Src/PCompiler/CompilerCore/Backend/Java/TypeManager.cs
+++ b/Src/PCompiler/CompilerCore/Backend/Java/TypeManager.cs
@@ -102,7 +102,7 @@ internal string ReferenceTypeName
internal class JAny : JType
{
- /// A JAny can either be a PEvent, a PValue, or a collection type like ArrayList, HashSet, etc.
+ /// A JAny can either be a Event, a PValue, or a collection type like ArrayList, HashSet, etc.
/// For a complete list, see the implementation of `deepEquals()` and `deepClone` in the P java runtime:
internal JAny()
{
diff --git a/Src/PCompiler/CompilerCore/Backend/Symbolic/CompilationContext.cs b/Src/PCompiler/CompilerCore/Backend/Symbolic/CompilationContext.cs
index 84944ef9cc..915e71d954 100644
--- a/Src/PCompiler/CompilerCore/Backend/Symbolic/CompilationContext.cs
+++ b/Src/PCompiler/CompilerCore/Backend/Symbolic/CompilationContext.cs
@@ -73,7 +73,7 @@ internal string GetNameForDecl(IPDecl decl)
return $"{@interface.Name}";
case State state:
return $"{state.Name}";
- case PEvent pEvent:
+ case Event pEvent:
if (!pEvent.IsBuiltIn)
return $"{pEvent.Name}";
else return $"_{pEvent.Name}";
diff --git a/Src/PCompiler/CompilerCore/Backend/Symbolic/Continuation.cs b/Src/PCompiler/CompilerCore/Backend/Symbolic/Continuation.cs
index 56df9df642..f5a7d6662c 100644
--- a/Src/PCompiler/CompilerCore/Backend/Symbolic/Continuation.cs
+++ b/Src/PCompiler/CompilerCore/Backend/Symbolic/Continuation.cs
@@ -10,7 +10,7 @@ namespace Plang.Compiler.Backend.Symbolic
{
public class Continuation : Function
{
- public Continuation(string name, IReadOnlyDictionary cases, IPStmt after, ParserRuleContext location) : base(name, location)
+ public Continuation(string name, IReadOnlyDictionary cases, IPStmt after, ParserRuleContext location) : base(name, location)
{
Cases = cases;
After = after;
@@ -29,7 +29,7 @@ public void AddParameter(Variable local, Variable store)
storeForLocal.Add(local, store);
}
- public IReadOnlyDictionary Cases { get; }
+ public IReadOnlyDictionary Cases { get; }
public IPStmt After { get; }
public IEnumerable StoreParameters => storeParameters;
public IEnumerable LocalParameters => localParameters;
diff --git a/Src/PCompiler/CompilerCore/Backend/Symbolic/SymbolicCodeGenerator.cs b/Src/PCompiler/CompilerCore/Backend/Symbolic/SymbolicCodeGenerator.cs
index 9b4ef08a2b..e22014d1d5 100644
--- a/Src/PCompiler/CompilerCore/Backend/Symbolic/SymbolicCodeGenerator.cs
+++ b/Src/PCompiler/CompilerCore/Backend/Symbolic/SymbolicCodeGenerator.cs
@@ -222,7 +222,7 @@ private void WriteMainDriver(CompilationContext context, StringWriter output, Sc
context.WriteLine(output);
}
- private void WriteEvent(CompilationContext context, StringWriter output, PEvent ev)
+ private void WriteEvent(CompilationContext context, StringWriter output, Event ev)
{
context.WriteLine(output, $"public static Event {context.GetNameForDecl(ev)} = new Event(\"{context.GetNameForDecl(ev)}\");");
}
@@ -243,7 +243,7 @@ private void WriteDecl(CompilationContext context, StringWriter output, IPDecl d
else
WriteMachine(context, output, machine);
break;
- case PEvent ev:
+ case Event ev:
WriteEvent(context, output, ev);
break;
case SafetyTest safety:
@@ -500,7 +500,7 @@ private void WriteState(CompilationContext context, StringWriter output, State s
context.Write(output, "}");
}
- private void WriteEventHandler(CompilationContext context, StringWriter output, KeyValuePair handler, State state)
+ private void WriteEventHandler(CompilationContext context, StringWriter output, KeyValuePair handler, State state)
{
var eventTag = context.GetNameForDecl(handler.Key);
switch (handler.Value)
diff --git a/Src/PCompiler/CompilerCore/Backend/Symbolic/TransformASTPass.cs b/Src/PCompiler/CompilerCore/Backend/Symbolic/TransformASTPass.cs
index aeebf23e2d..226c75919a 100644
--- a/Src/PCompiler/CompilerCore/Backend/Symbolic/TransformASTPass.cs
+++ b/Src/PCompiler/CompilerCore/Backend/Symbolic/TransformASTPass.cs
@@ -380,7 +380,7 @@ static private IPStmt ReplaceVars(IPStmt stmt, Dictionary var
foreach(var p in raiseStmt.Payload) payload.Add(ReplaceVars(p, varMap));
return new RaiseStmt(raiseStmt.SourceLocation, ReplaceVars(raiseStmt.PEvent, varMap), payload);
case ReceiveStmt receiveStmt:
- var cases = new Dictionary();
+ var cases = new Dictionary();
foreach(var entry in receiveStmt.Cases)
{
var replacement = new Function(entry.Value.Name, entry.Value.SourceLocation);
@@ -515,7 +515,7 @@ static private IPStmt ReplaceBreaks(IPStmt stmt, List afterStmts)
case IfStmt ifStmt:
return new IfStmt(ifStmt.SourceLocation, ifStmt.Condition, ReplaceBreaks(ifStmt.ThenBranch, afterStmts), ReplaceBreaks(ifStmt.ElseBranch, afterStmts));
case ReceiveStmt receiveStmt:
- var cases = new Dictionary();
+ var cases = new Dictionary();
foreach(var entry in receiveStmt.Cases)
{
var replacement = new Function(entry.Value.Name, entry.Value.SourceLocation);
@@ -602,7 +602,7 @@ static private IPStmt HandleReceives(IPStmt statement, Function function, Machin
}
break;
case ReceiveStmt recv:
- IDictionary cases = new Dictionary();
+ IDictionary cases = new Dictionary();
var canReceiveInCase = false;
foreach (var c in recv.Cases)
{
@@ -775,11 +775,11 @@ static private IPStmt HandleReceives(IPStmt statement, Function function, Machin
}
}
- static private Continuation GetContinuation(Function function, IDictionary cases, IPStmt after, ParserRuleContext location)
+ static private Continuation GetContinuation(Function function, IDictionary cases, IPStmt after, ParserRuleContext location)
{
var continuationName = $"continuation_{continuationNumber}";
continuationNumber++;
- var continuation = new Continuation(continuationName, new Dictionary(cases), after, location);
+ var continuation = new Continuation(continuationName, new Dictionary(cases), after, location);
continuation.ParentFunction = function;
function.AddCallee(continuation);
function.Role = FunctionRole.Method;
diff --git a/Src/PCompiler/CompilerCore/DefaultTranslationErrorHandler.cs b/Src/PCompiler/CompilerCore/DefaultTranslationErrorHandler.cs
index e2a65cfbc7..10b96808aa 100644
--- a/Src/PCompiler/CompilerCore/DefaultTranslationErrorHandler.cs
+++ b/Src/PCompiler/CompilerCore/DefaultTranslationErrorHandler.cs
@@ -215,7 +215,7 @@ public Exception NoMain(ParserRuleContext sourceLocation, string message)
return IssueError(sourceLocation, $"Illegal main machine. {message}");
}
- public Exception InvalidAssertExpr(ParserRuleContext location, Machine monitor, PEvent illegalEvent)
+ public Exception InvalidAssertExpr(ParserRuleContext location, Machine monitor, Event illegalEvent)
{
return IssueError(location,
$"invalid assert operation. event {illegalEvent.Name} in observes set of {monitor.Name} is not in the sends set of the module");
@@ -310,9 +310,9 @@ public Exception StringAssignStmtLinearArgument(ParserRuleContext argSourceLocat
return IssueError(argSourceLocation, "String interpolation does not support linear arguments.");
}
- public Exception DuplicateReceiveCase(ParserRuleContext location, PEvent pEvent)
+ public Exception DuplicateReceiveCase(ParserRuleContext location, Event @event)
{
- return IssueError(location, $"Event {pEvent.Name} appears twice in receive statement argument list");
+ return IssueError(location, $"Event {@event.Name} appears twice in receive statement argument list");
}
public Exception BareLoopControlFlow(string stmtName, ParserRuleContext context)
@@ -340,7 +340,7 @@ private string DeclarationName(IPDecl method)
return method.Name.Length > 0 ? method.Name : $"at {locationResolver.GetLocation(method.SourceLocation)}";
}
- public string SpecObservesSetIncompleteWarning(ParserRuleContext ctx, PEvent ev, Machine machine)
+ public string SpecObservesSetIncompleteWarning(ParserRuleContext ctx, Event ev, Machine machine)
{
return $"[!Warning!]\n[{locationResolver.GetLocation(ctx, ctx.start)}] Event {ev.Name} is not in the observes list of the spec machine {machine.Name}. The event-handler is never triggered as the event is not observed by the spec.\n[!Warning!]";
}
diff --git a/Src/PCompiler/CompilerCore/ITranslationErrorHandler.cs b/Src/PCompiler/CompilerCore/ITranslationErrorHandler.cs
index 4d72486340..e0cab2588c 100644
--- a/Src/PCompiler/CompilerCore/ITranslationErrorHandler.cs
+++ b/Src/PCompiler/CompilerCore/ITranslationErrorHandler.cs
@@ -61,7 +61,7 @@ Exception DuplicateStartState(
// module system related
Exception InvalidBindExpr(ParserRuleContext location, string message);
- Exception InvalidAssertExpr(ParserRuleContext location, Machine monitor, PEvent illegalEvent);
+ Exception InvalidAssertExpr(ParserRuleContext location, Machine monitor, Event illegalEvent);
Exception InvalidAssertExpr(ParserRuleContext location, Machine monitor);
@@ -97,7 +97,7 @@ Exception DuplicateStartState(
Exception ChangeStateInNonVoidFunction(ParserRuleContext context);
- Exception DuplicateReceiveCase(ParserRuleContext location, PEvent pEvent);
+ Exception DuplicateReceiveCase(ParserRuleContext location, Event @event);
Exception NoMain(ParserRuleContext sourceLocation, string v);
@@ -119,6 +119,6 @@ Exception DuplicateStartState(
Exception IllegalChooseSubExprValue(PParser.ChooseExprContext context, int numChoices);
Exception IllegalFunctionUsedInSpecMachine(Function function, Machine callerOwner);
- String SpecObservesSetIncompleteWarning(ParserRuleContext loc, PEvent ev, Machine machine);
+ String SpecObservesSetIncompleteWarning(ParserRuleContext loc, Event ev, Machine machine);
}
}
\ No newline at end of file
diff --git a/Src/PCompiler/CompilerCore/TypeChecker/AST/Declarations/PEvent.cs b/Src/PCompiler/CompilerCore/TypeChecker/AST/Declarations/Event.cs
similarity index 90%
rename from Src/PCompiler/CompilerCore/TypeChecker/AST/Declarations/PEvent.cs
rename to Src/PCompiler/CompilerCore/TypeChecker/AST/Declarations/Event.cs
index ab5d3cfdf7..961b2d0c46 100644
--- a/Src/PCompiler/CompilerCore/TypeChecker/AST/Declarations/PEvent.cs
+++ b/Src/PCompiler/CompilerCore/TypeChecker/AST/Declarations/Event.cs
@@ -4,9 +4,9 @@
namespace Plang.Compiler.TypeChecker.AST.Declarations
{
- public class PEvent : IPDecl
+ public class Event : IPDecl
{
- public PEvent(string name, ParserRuleContext sourceNode)
+ public Event(string name, ParserRuleContext sourceNode)
{
Debug.Assert("halt".Equals(name) && sourceNode == null ||
"null".Equals(name) && sourceNode == null ||
diff --git a/Src/PCompiler/CompilerCore/TypeChecker/AST/Declarations/NamedEventSet.cs b/Src/PCompiler/CompilerCore/TypeChecker/AST/Declarations/NamedEventSet.cs
index 29ae11574e..b08152aaf6 100644
--- a/Src/PCompiler/CompilerCore/TypeChecker/AST/Declarations/NamedEventSet.cs
+++ b/Src/PCompiler/CompilerCore/TypeChecker/AST/Declarations/NamedEventSet.cs
@@ -7,38 +7,38 @@ namespace Plang.Compiler.TypeChecker.AST.Declarations
{
public interface IEventSet
{
- IEnumerable Events { get; }
+ IEnumerable Events { get; }
- bool AddEvent(PEvent pEvent);
+ bool AddEvent(Event @event);
- void AddEvents(IEnumerable evts);
+ void AddEvents(IEnumerable evts);
- bool Contains(PEvent pEvent);
+ bool Contains(Event @event);
bool IsSame(IEventSet eventSet);
bool IsSubsetEqOf(IEventSet eventSet);
- bool IsSubsetEqOf(IEnumerable eventSet);
+ bool IsSubsetEqOf(IEnumerable eventSet);
- bool Intersects(IEnumerable eventSet);
+ bool Intersects(IEnumerable eventSet);
}
public class EventSet : IEventSet
{
- private static readonly Comparer EventNameComparer =
- Comparer.Create((ev1, ev2) => string.Compare(ev1.Name, ev2.Name, StringComparison.Ordinal));
+ private static readonly Comparer EventNameComparer =
+ Comparer.Create((ev1, ev2) => string.Compare(ev1.Name, ev2.Name, StringComparison.Ordinal));
- private readonly SortedSet events = new SortedSet(EventNameComparer);
+ private readonly SortedSet events = new SortedSet(EventNameComparer);
- public IEnumerable Events => events;
+ public IEnumerable Events => events;
- public bool AddEvent(PEvent pEvent)
+ public bool AddEvent(Event @event)
{
- return events.Add(pEvent);
+ return events.Add(@event);
}
- public void AddEvents(IEnumerable evts)
+ public void AddEvents(IEnumerable evts)
{
foreach (var pEvent in evts)
{
@@ -46,9 +46,9 @@ public void AddEvents(IEnumerable evts)
}
}
- public bool Contains(PEvent pEvent)
+ public bool Contains(Event @event)
{
- return events.Contains(pEvent);
+ return events.Contains(@event);
}
public bool IsSame(IEventSet eventSet)
@@ -61,12 +61,12 @@ public bool IsSubsetEqOf(IEventSet eventSet)
return events.IsSubsetOf(eventSet.Events);
}
- public bool IsSubsetEqOf(IEnumerable eventsList)
+ public bool IsSubsetEqOf(IEnumerable eventsList)
{
return events.IsSubsetOf(eventsList);
}
- public bool Intersects(IEnumerable eventSet)
+ public bool Intersects(IEnumerable eventSet)
{
return events.Overlaps(eventSet);
}
@@ -89,16 +89,16 @@ sourceNode is PParser.SpecMachineDeclContext ||
SourceLocation = sourceNode;
}
- public IEnumerable Events => events.Events;
+ public IEnumerable Events => events.Events;
- public bool AddEvent(PEvent evt)
+ public bool AddEvent(Event evt)
{
return events.AddEvent(evt);
}
- public bool Contains(PEvent pEvent)
+ public bool Contains(Event @event)
{
- return events.Contains(pEvent);
+ return events.Contains(@event);
}
public bool IsSame(IEventSet eventSet)
@@ -106,7 +106,7 @@ public bool IsSame(IEventSet eventSet)
return events.IsSame(eventSet);
}
- public void AddEvents(IEnumerable evts)
+ public void AddEvents(IEnumerable evts)
{
foreach (var pEvent in evts)
{
@@ -119,12 +119,12 @@ public bool IsSubsetEqOf(IEventSet eventSet)
return events.IsSubsetEqOf(eventSet);
}
- public bool IsSubsetEqOf(IEnumerable eventsList)
+ public bool IsSubsetEqOf(IEnumerable eventsList)
{
return events.IsSubsetEqOf(eventsList);
}
- public bool Intersects(IEnumerable eventSet)
+ public bool Intersects(IEnumerable eventSet)
{
return events.Intersects(eventSet);
}
diff --git a/Src/PCompiler/CompilerCore/TypeChecker/AST/Expressions/EventRefExpr.cs b/Src/PCompiler/CompilerCore/TypeChecker/AST/Expressions/EventRefExpr.cs
index fb26afeae7..6b0a97a21c 100644
--- a/Src/PCompiler/CompilerCore/TypeChecker/AST/Expressions/EventRefExpr.cs
+++ b/Src/PCompiler/CompilerCore/TypeChecker/AST/Expressions/EventRefExpr.cs
@@ -4,15 +4,15 @@
namespace Plang.Compiler.TypeChecker.AST.Expressions
{
- public class EventRefExpr : IStaticTerm
+ public class EventRefExpr : IStaticTerm
{
- public EventRefExpr(ParserRuleContext sourceLocation, PEvent value)
+ public EventRefExpr(ParserRuleContext sourceLocation, Event value)
{
Value = value;
SourceLocation = sourceLocation;
}
- public PEvent Value { get; }
+ public Event Value { get; }
public PLanguageType Type { get; } = PrimitiveType.Event;
public ParserRuleContext SourceLocation { get; }
diff --git a/Src/PCompiler/CompilerCore/TypeChecker/AST/IStateAction.cs b/Src/PCompiler/CompilerCore/TypeChecker/AST/IStateAction.cs
index 36fa68cd41..a7c899ee81 100644
--- a/Src/PCompiler/CompilerCore/TypeChecker/AST/IStateAction.cs
+++ b/Src/PCompiler/CompilerCore/TypeChecker/AST/IStateAction.cs
@@ -4,6 +4,6 @@ namespace Plang.Compiler.TypeChecker.AST
{
public interface IStateAction : IPAST
{
- PEvent Trigger { get; }
+ Event Trigger { get; }
}
}
\ No newline at end of file
diff --git a/Src/PCompiler/CompilerCore/TypeChecker/AST/ModuleExprs/HideEventModuleExpr.cs b/Src/PCompiler/CompilerCore/TypeChecker/AST/ModuleExprs/HideEventModuleExpr.cs
index 95943e5f7c..b6c090dfed 100644
--- a/Src/PCompiler/CompilerCore/TypeChecker/AST/ModuleExprs/HideEventModuleExpr.cs
+++ b/Src/PCompiler/CompilerCore/TypeChecker/AST/ModuleExprs/HideEventModuleExpr.cs
@@ -6,7 +6,7 @@ namespace Plang.Compiler.TypeChecker.AST.ModuleExprs
{
public class HideEventModuleExpr : IPModuleExpr
{
- public HideEventModuleExpr(ParserRuleContext sourceNode, IEnumerable events, IPModuleExpr module)
+ public HideEventModuleExpr(ParserRuleContext sourceNode, IEnumerable events, IPModuleExpr module)
{
SourceLocation = sourceNode;
HideEvents = new EventSet();
diff --git a/Src/PCompiler/CompilerCore/TypeChecker/AST/Statements/ReceiveStmt.cs b/Src/PCompiler/CompilerCore/TypeChecker/AST/Statements/ReceiveStmt.cs
index 4a661a0b08..dcc5535aa9 100644
--- a/Src/PCompiler/CompilerCore/TypeChecker/AST/Statements/ReceiveStmt.cs
+++ b/Src/PCompiler/CompilerCore/TypeChecker/AST/Statements/ReceiveStmt.cs
@@ -6,13 +6,13 @@ namespace Plang.Compiler.TypeChecker.AST.Statements
{
public class ReceiveStmt : IPStmt
{
- public ReceiveStmt(ParserRuleContext sourceLocation, IReadOnlyDictionary cases)
+ public ReceiveStmt(ParserRuleContext sourceLocation, IReadOnlyDictionary cases)
{
SourceLocation = sourceLocation;
Cases = cases;
}
- public IReadOnlyDictionary Cases { get; }
+ public IReadOnlyDictionary Cases { get; }
public ParserRuleContext SourceLocation { get; }
}
}
\ No newline at end of file
diff --git a/Src/PCompiler/CompilerCore/TypeChecker/AST/States/EventDefer.cs b/Src/PCompiler/CompilerCore/TypeChecker/AST/States/EventDefer.cs
index e6b5bc09c1..f2080e1e73 100644
--- a/Src/PCompiler/CompilerCore/TypeChecker/AST/States/EventDefer.cs
+++ b/Src/PCompiler/CompilerCore/TypeChecker/AST/States/EventDefer.cs
@@ -5,13 +5,13 @@ namespace Plang.Compiler.TypeChecker.AST.States
{
public class EventDefer : IStateAction
{
- public EventDefer(ParserRuleContext sourceLocation, PEvent trigger)
+ public EventDefer(ParserRuleContext sourceLocation, Event trigger)
{
SourceLocation = sourceLocation;
Trigger = trigger;
}
public ParserRuleContext SourceLocation { get; }
- public PEvent Trigger { get; }
+ public Event Trigger { get; }
}
}
\ No newline at end of file
diff --git a/Src/PCompiler/CompilerCore/TypeChecker/AST/States/EventDoAction.cs b/Src/PCompiler/CompilerCore/TypeChecker/AST/States/EventDoAction.cs
index 98dc3242b7..ec331a7f58 100644
--- a/Src/PCompiler/CompilerCore/TypeChecker/AST/States/EventDoAction.cs
+++ b/Src/PCompiler/CompilerCore/TypeChecker/AST/States/EventDoAction.cs
@@ -5,7 +5,7 @@ namespace Plang.Compiler.TypeChecker.AST.States
{
public class EventDoAction : IStateAction
{
- public EventDoAction(ParserRuleContext sourceLocation, PEvent trigger, Function target)
+ public EventDoAction(ParserRuleContext sourceLocation, Event trigger, Function target)
{
SourceLocation = sourceLocation;
Trigger = trigger;
@@ -14,6 +14,6 @@ public EventDoAction(ParserRuleContext sourceLocation, PEvent trigger, Function
public Function Target { get; }
public ParserRuleContext SourceLocation { get; }
- public PEvent Trigger { get; }
+ public Event Trigger { get; }
}
}
\ No newline at end of file
diff --git a/Src/PCompiler/CompilerCore/TypeChecker/AST/States/EventGotoState.cs b/Src/PCompiler/CompilerCore/TypeChecker/AST/States/EventGotoState.cs
index 9fabc07113..b2ec551644 100644
--- a/Src/PCompiler/CompilerCore/TypeChecker/AST/States/EventGotoState.cs
+++ b/Src/PCompiler/CompilerCore/TypeChecker/AST/States/EventGotoState.cs
@@ -5,7 +5,7 @@ namespace Plang.Compiler.TypeChecker.AST.States
{
public class EventGotoState : IStateAction
{
- public EventGotoState(ParserRuleContext sourceLocation, PEvent trigger, State target,
+ public EventGotoState(ParserRuleContext sourceLocation, Event trigger, State target,
Function transitionFunction)
{
SourceLocation = sourceLocation;
@@ -18,6 +18,6 @@ public EventGotoState(ParserRuleContext sourceLocation, PEvent trigger, State ta
public Function TransitionFunction { get; }
public ParserRuleContext SourceLocation { get; }
- public PEvent Trigger { get; }
+ public Event Trigger { get; }
}
}
\ No newline at end of file
diff --git a/Src/PCompiler/CompilerCore/TypeChecker/AST/States/EventIgnore.cs b/Src/PCompiler/CompilerCore/TypeChecker/AST/States/EventIgnore.cs
index af38eafa34..d419449780 100644
--- a/Src/PCompiler/CompilerCore/TypeChecker/AST/States/EventIgnore.cs
+++ b/Src/PCompiler/CompilerCore/TypeChecker/AST/States/EventIgnore.cs
@@ -5,13 +5,13 @@ namespace Plang.Compiler.TypeChecker.AST.States
{
public class EventIgnore : IStateAction
{
- public EventIgnore(ParserRuleContext sourceLocation, PEvent trigger)
+ public EventIgnore(ParserRuleContext sourceLocation, Event trigger)
{
SourceLocation = sourceLocation;
Trigger = trigger;
}
public ParserRuleContext SourceLocation { get; }
- public PEvent Trigger { get; }
+ public Event Trigger { get; }
}
}
\ No newline at end of file
diff --git a/Src/PCompiler/CompilerCore/TypeChecker/AST/States/State.cs b/Src/PCompiler/CompilerCore/TypeChecker/AST/States/State.cs
index 3d1ecf70ba..4ee3a2d7f7 100644
--- a/Src/PCompiler/CompilerCore/TypeChecker/AST/States/State.cs
+++ b/Src/PCompiler/CompilerCore/TypeChecker/AST/States/State.cs
@@ -7,7 +7,7 @@ namespace Plang.Compiler.TypeChecker.AST.States
{
public class State : IPDecl
{
- private readonly IDictionary actions = new Dictionary();
+ private readonly IDictionary actions = new Dictionary();
public State(ParserRuleContext sourceNode, string name)
{
@@ -20,13 +20,13 @@ public State(ParserRuleContext sourceNode, string name)
public bool IsStart { get; set; }
public Function Entry { get; set; }
- public IEnumerable> AllEventHandlers => actions;
+ public IEnumerable> AllEventHandlers => actions;
public Function Exit { get; set; }
public Machine OwningMachine { get; set; }
public IStateContainer Container { get; set; }
- public IStateAction this[PEvent index]
+ public IStateAction this[Event index]
{
get => actions[index];
set => actions[index] = value;
@@ -51,9 +51,9 @@ public string QualifiedName
public string Name { get; }
public ParserRuleContext SourceLocation { get; }
- public bool HasHandler(PEvent pEvent)
+ public bool HasHandler(Event @event)
{
- return actions.ContainsKey(pEvent);
+ return actions.ContainsKey(@event);
}
}
}
\ No newline at end of file
diff --git a/Src/PCompiler/CompilerCore/TypeChecker/DeclarationVisitor.cs b/Src/PCompiler/CompilerCore/TypeChecker/DeclarationVisitor.cs
index b726380da1..46dc2b34fb 100644
--- a/Src/PCompiler/CompilerCore/TypeChecker/DeclarationVisitor.cs
+++ b/Src/PCompiler/CompilerCore/TypeChecker/DeclarationVisitor.cs
@@ -46,7 +46,7 @@ public static void PopulateDeclarations(
public override object VisitEventDecl(PParser.EventDeclContext context)
{
// EVENT name=Iden
- var pEvent = (PEvent) nodesToDeclarations.Get(context);
+ var pEvent = (Event) nodesToDeclarations.Get(context);
// cardinality?
var hasAssume = context.cardinality()?.ASSUME() != null;
@@ -84,7 +84,7 @@ public override object VisitInterfaceDecl(PParser.InterfaceDeclContext context)
eventSet = new EventSet();
if (context.nonDefaultEventList()?._events is IList events)
foreach (var eventContext in events)
- eventSet.AddEvent((PEvent) Visit(eventContext));
+ eventSet.AddEvent((Event) Visit(eventContext));
}
mInterface.ReceivableEvents = eventSet;
@@ -233,7 +233,7 @@ public override object VisitEventSetDecl(PParser.EventSetDeclContext context)
// EVENTSET name=iden
var es = (NamedEventSet) nodesToDeclarations.Get(context);
// ASSIGN LBRACE eventSetLiteral RBRACE
- es.AddEvents((PEvent[]) Visit(context.eventSetLiteral()));
+ es.AddEvents((Event[]) Visit(context.eventSetLiteral()));
// SEMI
return es;
}
@@ -241,14 +241,14 @@ public override object VisitEventSetDecl(PParser.EventSetDeclContext context)
public override object VisitEventSetLiteral(PParser.EventSetLiteralContext context)
{
// events+=nonDefaultEvent (COMMA events+=nonDefaultEvent)*
- return context._events.Select(Visit).Cast().ToArray();
+ return context._events.Select(Visit).Cast().ToArray();
}
public override object VisitNonDefaultEvent(PParser.NonDefaultEventContext context)
{
// HALT | iden
var eventName = context.GetText();
- if (!CurrentScope.Lookup(eventName, out PEvent pEvent))
+ if (!CurrentScope.Lookup(eventName, out Event pEvent))
throw Handler.MissingDeclaration(context, "event", eventName);
return pEvent;
}
@@ -273,7 +273,7 @@ public override object VisitImplMachineDecl(PParser.ImplMachineDeclContext conte
// receivesSends*
foreach (var receivesSends in context.receivesSends())
{
- var recvSendTuple = (Tuple) Visit(receivesSends);
+ var recvSendTuple = (Tuple) Visit(receivesSends);
var eventSetType = recvSendTuple.Item1;
if (eventSetType.Equals("RECV", StringComparison.InvariantCulture))
{
@@ -313,16 +313,16 @@ public override object VisitImplMachineDecl(PParser.ImplMachineDeclContext conte
public override object VisitMachineReceive(PParser.MachineReceiveContext context)
{
var events = context.eventSetLiteral() == null
- ? new PEvent[0]
- : (PEvent[]) Visit(context.eventSetLiteral());
+ ? new Event[0]
+ : (Event[]) Visit(context.eventSetLiteral());
return Tuple.Create("RECV", events);
}
public override object VisitMachineSend(PParser.MachineSendContext context)
{
var events = context.eventSetLiteral() == null
- ? new PEvent[0]
- : (PEvent[]) Visit(context.eventSetLiteral());
+ ? new Event[0]
+ : (Event[]) Visit(context.eventSetLiteral());
return Tuple.Create("SEND", events);
}
@@ -337,7 +337,7 @@ public override object VisitSpecMachineDecl(PParser.SpecMachineDeclContext conte
// OBSERVES eventSetLiteral
specMachine.Observes = new EventSet();
- foreach (var pEvent in (PEvent[]) Visit(context.eventSetLiteral())) specMachine.Observes.AddEvent(pEvent);
+ foreach (var pEvent in (Event[]) Visit(context.eventSetLiteral())) specMachine.Observes.AddEvent(pEvent);
// machineBody
using (currentScope.NewContext(specMachine.Scope))
@@ -509,7 +509,7 @@ public override object VisitStateDefer(PParser.StateDeferContext context)
for (var i = 0; i < eventContexts.Count; i++)
{
var token = eventContexts[i];
- if (!CurrentScope.Lookup(token.GetText(), out PEvent evt))
+ if (!CurrentScope.Lookup(token.GetText(), out Event evt))
throw Handler.MissingDeclaration(token, "event", token.GetText());
actions[i] = new EventDefer(token, evt);
}
@@ -523,7 +523,7 @@ public override object VisitStateIgnore(PParser.StateIgnoreContext context)
var actions = new List();
foreach (var token in context.nonDefaultEventList()._events)
{
- if (!CurrentScope.Lookup(token.GetText(), out PEvent evt))
+ if (!CurrentScope.Lookup(token.GetText(), out Event evt))
throw Handler.MissingDeclaration(token, "event", token.GetText());
actions.Add(new EventIgnore(token, evt));
}
@@ -554,7 +554,7 @@ public override object VisitOnEventDoAction(PParser.OnEventDoActionContext conte
var actions = new List();
foreach (var eventIdContext in context.eventList().eventId())
{
- if (!CurrentScope.Lookup(eventIdContext.GetText(), out PEvent evt))
+ if (!CurrentScope.Lookup(eventIdContext.GetText(), out Event evt))
throw Handler.MissingDeclaration(eventIdContext, "event", eventIdContext.GetText());
actions.Add(new EventDoAction(eventIdContext, evt, fun));
@@ -594,7 +594,7 @@ public override object VisitOnEventGotoState(PParser.OnEventGotoStateContext con
var actions = new List();
foreach (var eventIdContext in context.eventList().eventId())
{
- if (!CurrentScope.Lookup(eventIdContext.GetText(), out PEvent evt))
+ if (!CurrentScope.Lookup(eventIdContext.GetText(), out Event evt))
throw Handler.MissingDeclaration(eventIdContext, "event", eventIdContext.GetText());
actions.Add(new EventGotoState(eventIdContext, evt, target, transitionFunction));
diff --git a/Src/PCompiler/CompilerCore/TypeChecker/ExprVisitor.cs b/Src/PCompiler/CompilerCore/TypeChecker/ExprVisitor.cs
index 82fd330db8..01d2716f2f 100644
--- a/Src/PCompiler/CompilerCore/TypeChecker/ExprVisitor.cs
+++ b/Src/PCompiler/CompilerCore/TypeChecker/ExprVisitor.cs
@@ -513,7 +513,7 @@ public override IPExpr VisitPrimitive(PParser.PrimitiveContext context)
return new EnumElemRefExpr(context, enumElem);
}
- if (table.Lookup(symbolName, out PEvent evt))
+ if (table.Lookup(symbolName, out Event evt))
{
return new EventRefExpr(context, evt);
}
@@ -565,7 +565,7 @@ public override IPExpr VisitPrimitive(PParser.PrimitiveContext context)
if (context.HALT() != null)
{
- var success = table.Lookup("halt", out PEvent haltEvent);
+ var success = table.Lookup("halt", out Event haltEvent);
Debug.Assert(success);
return new EventRefExpr(context, haltEvent);
}
diff --git a/Src/PCompiler/CompilerCore/TypeChecker/ModuleExprVisitor.cs b/Src/PCompiler/CompilerCore/TypeChecker/ModuleExprVisitor.cs
index cba686404b..3d6d5390f1 100644
--- a/Src/PCompiler/CompilerCore/TypeChecker/ModuleExprVisitor.cs
+++ b/Src/PCompiler/CompilerCore/TypeChecker/ModuleExprVisitor.cs
@@ -109,10 +109,10 @@ public override IPModuleExpr VisitComposeModuleExpr([NotNull] PParser.ComposeMod
public override IPModuleExpr VisitHideEventsModuleExpr([NotNull] PParser.HideEventsModuleExprContext context)
{
- var eventList = new List();
+ var eventList = new List();
foreach (var eventName in context.nonDefaultEventList()._events)
{
- if (!globalScope.Get(eventName.GetText(), out PEvent @event))
+ if (!globalScope.Get(eventName.GetText(), out Event @event))
{
throw handler.MissingDeclaration(eventName, "event", eventName.GetText());
}
diff --git a/Src/PCompiler/CompilerCore/TypeChecker/ModuleSystemTypeChecker.cs b/Src/PCompiler/CompilerCore/TypeChecker/ModuleSystemTypeChecker.cs
index d8cf61fd62..cad8a5945d 100644
--- a/Src/PCompiler/CompilerCore/TypeChecker/ModuleSystemTypeChecker.cs
+++ b/Src/PCompiler/CompilerCore/TypeChecker/ModuleSystemTypeChecker.cs
@@ -18,7 +18,7 @@ public ModuleSystemTypeChecker(ITranslationErrorHandler handler, Scope globalSco
this.globalScope = globalScope;
}
- private IEnumerable GetPermissions(IEnumerable allowed)
+ private IEnumerable GetPermissions(IEnumerable allowed)
{
if (allowed == null)
{
diff --git a/Src/PCompiler/CompilerCore/TypeChecker/Scope.cs b/Src/PCompiler/CompilerCore/TypeChecker/Scope.cs
index ba5e0dfc9e..84f18001c0 100644
--- a/Src/PCompiler/CompilerCore/TypeChecker/Scope.cs
+++ b/Src/PCompiler/CompilerCore/TypeChecker/Scope.cs
@@ -19,7 +19,7 @@ public class Scope
private readonly IDictionary enumElems = new Dictionary();
private readonly IDictionary enums = new Dictionary();
- private readonly IDictionary events = new Dictionary();
+ private readonly IDictionary events = new Dictionary();
private readonly IDictionary eventSets = new Dictionary();
private readonly IDictionary functions = new Dictionary();
private readonly ICompilerConfiguration config;
@@ -42,7 +42,7 @@ private Scope(ICompilerConfiguration config, Scope parent = null)
parent?.children.Add(this);
var eventSetWithHalt = new EventSet();
- eventSetWithHalt.AddEvent(new PEvent("halt", null));
+ eventSetWithHalt.AddEvent(new Event("halt", null));
UniversalEventSet = parent == null ? eventSetWithHalt : parent.UniversalEventSet;
}
@@ -68,7 +68,7 @@ private Scope(ICompilerConfiguration config, Scope parent = null)
public IEnumerable EnumElems => enumElems.Values;
public IEnumerable Enums => enums.Values;
- public IEnumerable Events => events.Values;
+ public IEnumerable Events => events.Values;
public IEnumerable EventSets => eventSets.Values;
public IEnumerable Functions => functions.Values;
public IEnumerable Interfaces => interfaces.Values;
@@ -146,7 +146,7 @@ public bool Get(string name, out PEnum tree)
return enums.TryGetValue(name, out tree);
}
- public bool Get(string name, out PEvent tree)
+ public bool Get(string name, out Event tree)
{
return events.TryGetValue(name, out tree);
}
@@ -244,7 +244,7 @@ public bool Lookup(string name, out PEnum tree)
return false;
}
- public bool Lookup(string name, out PEvent tree)
+ public bool Lookup(string name, out Event tree)
{
var current = this;
while (current != null)
@@ -489,9 +489,9 @@ public PEnum Put(string name, PParser.EnumTypeDefDeclContext tree)
return @enum;
}
- public PEvent Put(string name, PParser.EventDeclContext tree)
+ public Event Put(string name, PParser.EventDeclContext tree)
{
- var @event = new PEvent(name, tree);
+ var @event = new Event(name, tree);
CheckConflicts(@event, Namespace(events), Namespace(enumElems));
events.Add(name, @event);
return @event;
diff --git a/Src/PCompiler/CompilerCore/TypeChecker/StatementVisitor.cs b/Src/PCompiler/CompilerCore/TypeChecker/StatementVisitor.cs
index ba3e838952..2f694d46c5 100644
--- a/Src/PCompiler/CompilerCore/TypeChecker/StatementVisitor.cs
+++ b/Src/PCompiler/CompilerCore/TypeChecker/StatementVisitor.cs
@@ -471,7 +471,7 @@ public override IPStmt VisitReceiveStmt(PParser.ReceiveStmtContext context)
throw handler.IllegalMonitorOperation(context, context.RECEIVE().Symbol, machine);
}
- var cases = new Dictionary();
+ var cases = new Dictionary();
foreach (var caseContext in context.recvCase())
{
@@ -497,7 +497,7 @@ public override IPStmt VisitReceiveStmt(PParser.ReceiveStmtContext context)
FunctionBodyVisitor.PopulateMethod(config, recvHandler);
- if (!table.Lookup(eventIdContext.GetText(), out PEvent pEvent))
+ if (!table.Lookup(eventIdContext.GetText(), out Event pEvent))
{
throw handler.MissingDeclaration(eventIdContext, "event", eventIdContext.GetText());
}
diff --git a/Src/PCompiler/CompilerCore/TypeChecker/Types/DataType.cs b/Src/PCompiler/CompilerCore/TypeChecker/Types/DataType.cs
index 1a36c2c9d2..b07d706140 100644
--- a/Src/PCompiler/CompilerCore/TypeChecker/Types/DataType.cs
+++ b/Src/PCompiler/CompilerCore/TypeChecker/Types/DataType.cs
@@ -15,8 +15,8 @@ public DataType(NamedEventSet eventSet) : base(TypeKind.Data)
public override string CanonicalRepresentation => "data";
- public override Lazy> AllowedPermissions =>
- new Lazy>(() => new List());
+ public override Lazy> AllowedPermissions =>
+ new Lazy>(() => new List());
public override bool IsAssignableFrom(PLanguageType otherType)
{
diff --git a/Src/PCompiler/CompilerCore/TypeChecker/Types/EnumType.cs b/Src/PCompiler/CompilerCore/TypeChecker/Types/EnumType.cs
index 6e8a8e6865..ee0d6481bd 100644
--- a/Src/PCompiler/CompilerCore/TypeChecker/Types/EnumType.cs
+++ b/Src/PCompiler/CompilerCore/TypeChecker/Types/EnumType.cs
@@ -16,8 +16,8 @@ public EnumType(PEnum enumDecl) : base(TypeKind.Enum)
public override string OriginalRepresentation => EnumDecl.Name;
public override string CanonicalRepresentation => EnumDecl.Name;
- public override Lazy> AllowedPermissions =>
- new Lazy>(() => new List());
+ public override Lazy> AllowedPermissions =>
+ new Lazy>(() => new List());
public override bool IsAssignableFrom(PLanguageType otherType)
{
diff --git a/Src/PCompiler/CompilerCore/TypeChecker/Types/ForeignType.cs b/Src/PCompiler/CompilerCore/TypeChecker/Types/ForeignType.cs
index e8f123e482..28b5ef03bb 100644
--- a/Src/PCompiler/CompilerCore/TypeChecker/Types/ForeignType.cs
+++ b/Src/PCompiler/CompilerCore/TypeChecker/Types/ForeignType.cs
@@ -15,7 +15,7 @@ public ForeignType(string name) : base(TypeKind.Foreign)
public override string OriginalRepresentation { get; }
public override string CanonicalRepresentation { get; }
- public override Lazy> AllowedPermissions { get; } = null;
+ public override Lazy> AllowedPermissions { get; } = null;
public override bool IsAssignableFrom(PLanguageType otherType)
{
diff --git a/Src/PCompiler/CompilerCore/TypeChecker/Types/MapType.cs b/Src/PCompiler/CompilerCore/TypeChecker/Types/MapType.cs
index 3e1f7d37a1..fcc16e50f3 100644
--- a/Src/PCompiler/CompilerCore/TypeChecker/Types/MapType.cs
+++ b/Src/PCompiler/CompilerCore/TypeChecker/Types/MapType.cs
@@ -17,7 +17,7 @@ public MapType(PLanguageType keyType, PLanguageType valueType) : base(TypeKind.M
}
else
{
- AllowedPermissions = new Lazy>(() => KeyType
+ AllowedPermissions = new Lazy>(() => KeyType
.AllowedPermissions.Value.Concat(ValueType.AllowedPermissions.Value)
.ToList());
}
@@ -32,7 +32,7 @@ public MapType(PLanguageType keyType, PLanguageType valueType) : base(TypeKind.M
public override string CanonicalRepresentation =>
$"map[{KeyType.CanonicalRepresentation},{ValueType.CanonicalRepresentation}]";
- public override Lazy> AllowedPermissions { get; }
+ public override Lazy> AllowedPermissions { get; }
public override bool IsAssignableFrom(PLanguageType otherType)
{
diff --git a/Src/PCompiler/CompilerCore/TypeChecker/Types/NamedTupleType.cs b/Src/PCompiler/CompilerCore/TypeChecker/Types/NamedTupleType.cs
index c5f4aeeb13..6810f56a16 100644
--- a/Src/PCompiler/CompilerCore/TypeChecker/Types/NamedTupleType.cs
+++ b/Src/PCompiler/CompilerCore/TypeChecker/Types/NamedTupleType.cs
@@ -20,7 +20,7 @@ public NamedTupleType(IReadOnlyList fields) : base(TypeKind.Nam
$"({string.Join(",", Fields.Select(tn => $"{tn.Name}:{tn.Type.CanonicalRepresentation}"))})";
AllowedPermissions = Fields.Any(f => f.Type.AllowedPermissions == null)
? null
- : new Lazy>(
+ : new Lazy>(
() => Fields.SelectMany(f => f.Type.AllowedPermissions.Value).ToList());
}
@@ -31,7 +31,7 @@ public NamedTupleType(IReadOnlyList fields) : base(TypeKind.Nam
public override string OriginalRepresentation { get; }
public override string CanonicalRepresentation { get; }
- public override Lazy> AllowedPermissions { get; }
+ public override Lazy> AllowedPermissions { get; }
public override bool IsAssignableFrom(PLanguageType otherType)
{
diff --git a/Src/PCompiler/CompilerCore/TypeChecker/Types/PLanguageType.cs b/Src/PCompiler/CompilerCore/TypeChecker/Types/PLanguageType.cs
index 59d08a3b63..54288ad0da 100644
--- a/Src/PCompiler/CompilerCore/TypeChecker/Types/PLanguageType.cs
+++ b/Src/PCompiler/CompilerCore/TypeChecker/Types/PLanguageType.cs
@@ -29,7 +29,7 @@ protected PLanguageType(TypeKind kind)
///
/// represents the permissions embedded in a type
///
- public abstract Lazy> AllowedPermissions { get; }
+ public abstract Lazy> AllowedPermissions { get; }
public abstract bool IsAssignableFrom(PLanguageType otherType);
diff --git a/Src/PCompiler/CompilerCore/TypeChecker/Types/PermissionType.cs b/Src/PCompiler/CompilerCore/TypeChecker/Types/PermissionType.cs
index 302e248dc1..6c96452550 100644
--- a/Src/PCompiler/CompilerCore/TypeChecker/Types/PermissionType.cs
+++ b/Src/PCompiler/CompilerCore/TypeChecker/Types/PermissionType.cs
@@ -13,25 +13,25 @@ public class PermissionType : PLanguageType
public PermissionType(Machine machine) : base(TypeKind.Base)
{
origin = machine;
- AllowedPermissions = new Lazy>(() => machine.Receives.Events.ToList());
+ AllowedPermissions = new Lazy>(() => machine.Receives.Events.ToList());
}
public PermissionType(Interface pInterface) : base(TypeKind.Base)
{
origin = pInterface;
- AllowedPermissions = new Lazy>(() => pInterface.ReceivableEvents.Events.ToList());
+ AllowedPermissions = new Lazy>(() => pInterface.ReceivableEvents.Events.ToList());
}
public PermissionType(NamedEventSet eventSet) : base(TypeKind.Base)
{
origin = eventSet;
- AllowedPermissions = new Lazy>(() => eventSet.Events.ToList());
+ AllowedPermissions = new Lazy>(() => eventSet.Events.ToList());
}
public override string OriginalRepresentation => origin.Name;
public override string CanonicalRepresentation => origin.Name;
- public override Lazy> AllowedPermissions { get; }
+ public override Lazy> AllowedPermissions { get; }
public override bool IsAssignableFrom(PLanguageType otherType)
{
diff --git a/Src/PCompiler/CompilerCore/TypeChecker/Types/PrimitiveType.cs b/Src/PCompiler/CompilerCore/TypeChecker/Types/PrimitiveType.cs
index 6bdfc4aecd..2ddb2db19d 100644
--- a/Src/PCompiler/CompilerCore/TypeChecker/Types/PrimitiveType.cs
+++ b/Src/PCompiler/CompilerCore/TypeChecker/Types/PrimitiveType.cs
@@ -28,7 +28,7 @@ private PrimitiveType(string name) : base(TypeKind.Base)
break;
default:
- AllowedPermissions = new Lazy>(() => new List());
+ AllowedPermissions = new Lazy>(() => new List());
break;
}
}
@@ -36,7 +36,7 @@ private PrimitiveType(string name) : base(TypeKind.Base)
public override string OriginalRepresentation { get; }
public override string CanonicalRepresentation { get; }
- public override Lazy> AllowedPermissions { get; }
+ public override Lazy> AllowedPermissions { get; }
public override bool IsAssignableFrom(PLanguageType otherType)
{
diff --git a/Src/PCompiler/CompilerCore/TypeChecker/Types/SequenceType.cs b/Src/PCompiler/CompilerCore/TypeChecker/Types/SequenceType.cs
index f2ca29484a..04259e2a6c 100644
--- a/Src/PCompiler/CompilerCore/TypeChecker/Types/SequenceType.cs
+++ b/Src/PCompiler/CompilerCore/TypeChecker/Types/SequenceType.cs
@@ -16,7 +16,7 @@ public SequenceType(PLanguageType elementType) : base(TypeKind.Sequence)
public override string OriginalRepresentation => $"seq[{ElementType.OriginalRepresentation}]";
public override string CanonicalRepresentation => $"seq[{ElementType.CanonicalRepresentation}]";
- public override Lazy> AllowedPermissions => ElementType.AllowedPermissions;
+ public override Lazy> AllowedPermissions => ElementType.AllowedPermissions;
public override bool IsAssignableFrom(PLanguageType otherType)
{
diff --git a/Src/PCompiler/CompilerCore/TypeChecker/Types/SetType.cs b/Src/PCompiler/CompilerCore/TypeChecker/Types/SetType.cs
index 09bc7c912d..9bcac127dc 100644
--- a/Src/PCompiler/CompilerCore/TypeChecker/Types/SetType.cs
+++ b/Src/PCompiler/CompilerCore/TypeChecker/Types/SetType.cs
@@ -16,7 +16,7 @@ public SetType(PLanguageType elementType) : base(TypeKind.Set)
public override string OriginalRepresentation => $"set[{ElementType.OriginalRepresentation}]";
public override string CanonicalRepresentation => $"set[{ElementType.CanonicalRepresentation}]";
- public override Lazy> AllowedPermissions => ElementType.AllowedPermissions;
+ public override Lazy> AllowedPermissions => ElementType.AllowedPermissions;
public override bool IsAssignableFrom(PLanguageType otherType)
{
diff --git a/Src/PCompiler/CompilerCore/TypeChecker/Types/TupleType.cs b/Src/PCompiler/CompilerCore/TypeChecker/Types/TupleType.cs
index b9919c0728..60e8676ca3 100644
--- a/Src/PCompiler/CompilerCore/TypeChecker/Types/TupleType.cs
+++ b/Src/PCompiler/CompilerCore/TypeChecker/Types/TupleType.cs
@@ -15,7 +15,7 @@ public TupleType(params PLanguageType[] types) : base(TypeKind.Tuple)
CanonicalRepresentation = $"({string.Join(",", Types.Select(type => type.CanonicalRepresentation))})";
AllowedPermissions = Types.Any(t => t.AllowedPermissions == null)
? null
- : new Lazy>(() => Types.SelectMany(t => t.AllowedPermissions.Value).ToList());
+ : new Lazy>(() => Types.SelectMany(t => t.AllowedPermissions.Value).ToList());
}
// Lifts a TupleType into an equivalent NamedTupleType, where the names of each field are numbers
@@ -40,7 +40,7 @@ public NamedTupleType ToNamedTuple()
public override string CanonicalRepresentation { get; }
- public override Lazy> AllowedPermissions { get; }
+ public override Lazy> AllowedPermissions { get; }
public override bool IsAssignableFrom(PLanguageType otherType)
{
diff --git a/Src/PCompiler/CompilerCore/TypeChecker/Types/TypeDefType.cs b/Src/PCompiler/CompilerCore/TypeChecker/Types/TypeDefType.cs
index 6a2db4053a..9a49089b5f 100644
--- a/Src/PCompiler/CompilerCore/TypeChecker/Types/TypeDefType.cs
+++ b/Src/PCompiler/CompilerCore/TypeChecker/Types/TypeDefType.cs
@@ -17,7 +17,7 @@ public TypeDefType(TypeDef typeDef) : base(TypeKind.TypeDef)
public override string OriginalRepresentation => TypeDefDecl.Name;
public override string CanonicalRepresentation => TypeDefDecl.Type.CanonicalRepresentation;
- public override Lazy> AllowedPermissions { get; }
+ public override Lazy> AllowedPermissions { get; }
public override bool IsAssignableFrom(PLanguageType otherType)
{