From aa5e50b703565aa27e77042b7df4aa04dde0efe6 Mon Sep 17 00:00:00 2001 From: ChristineZh0u <48167738+ChristineZh0u@users.noreply.github.com> Date: Fri, 23 Aug 2024 09:34:18 -0700 Subject: [PATCH] [Cleanup] Merging PEvent with Event (#764) Co-authored-by: Christine Zhou --- Src/PChecker/CheckerCore/PRuntime/PEvent.cs | 57 ------------------- Src/PChecker/CheckerCore/PRuntime/PMachine.cs | 2 +- .../CheckerCore/StateMachines/Events/Event.cs | 53 ++++++++++++++++- .../Logging/PCheckerLogJsonFormatter.cs | 4 +- .../Logging/PCheckerLogTextFormatter.cs | 2 +- .../Backend/CSharp/CSharpCodeGenerator.cs | 18 +++--- .../Backend/CSharp/CSharpNameManager.cs | 2 +- .../Backend/Debugging/IrToPseudoP.cs | 6 +- .../CompilerCore/Backend/IRTransformer.cs | 4 +- .../CompilerCore/Backend/Java/Constants.cs | 6 +- .../Backend/Java/EventGenerator.cs | 8 +-- .../Backend/Java/MachineGenerator.cs | 4 +- .../CompilerCore/Backend/Java/NameManager.cs | 4 +- .../CompilerCore/Backend/Java/TypeManager.cs | 4 +- .../Backend/Symbolic/CompilationContext.cs | 2 +- .../Backend/Symbolic/Continuation.cs | 4 +- .../Backend/Symbolic/SymbolicCodeGenerator.cs | 10 ++-- .../Backend/Symbolic/TransformASTPass.cs | 14 ++--- .../DefaultTranslationErrorHandler.cs | 6 +- .../CompilerCore/ITranslationErrorHandler.cs | 6 +- .../AST/Declarations/{PEvent.cs => Event.cs} | 4 +- .../AST/Declarations/NamedEventSet.cs | 42 +++++++------- .../AST/Expressions/EventRefExpr.cs | 6 +- .../TypeChecker/AST/IStateAction.cs | 2 +- .../AST/ModuleExprs/HideEventModuleExpr.cs | 2 +- .../AST/Statements/AnnounceStmt.cs | 4 +- .../TypeChecker/AST/Statements/RaiseStmt.cs | 4 +- .../TypeChecker/AST/Statements/ReceiveStmt.cs | 4 +- .../TypeChecker/AST/States/EventDefer.cs | 4 +- .../TypeChecker/AST/States/EventDoAction.cs | 4 +- .../TypeChecker/AST/States/EventGotoState.cs | 4 +- .../TypeChecker/AST/States/EventIgnore.cs | 4 +- .../TypeChecker/AST/States/State.cs | 8 +-- .../TypeChecker/DeclarationVisitor.cs | 30 +++++----- .../CompilerCore/TypeChecker/ExprVisitor.cs | 4 +- .../TypeChecker/InferMachineCreates.cs | 4 +- .../TypeChecker/ModuleExprVisitor.cs | 4 +- .../TypeChecker/ModuleSystemTypeChecker.cs | 2 +- .../CompilerCore/TypeChecker/Scope.cs | 14 ++--- .../TypeChecker/StatementVisitor.cs | 4 +- .../TypeChecker/Types/DataType.cs | 4 +- .../TypeChecker/Types/EnumType.cs | 4 +- .../TypeChecker/Types/ForeignType.cs | 2 +- .../CompilerCore/TypeChecker/Types/MapType.cs | 4 +- .../TypeChecker/Types/NamedTupleType.cs | 4 +- .../TypeChecker/Types/PLanguageType.cs | 2 +- .../TypeChecker/Types/PermissionType.cs | 8 +-- .../TypeChecker/Types/PrimitiveType.cs | 4 +- .../TypeChecker/Types/SequenceType.cs | 2 +- .../CompilerCore/TypeChecker/Types/SetType.cs | 2 +- .../TypeChecker/Types/TupleType.cs | 4 +- .../TypeChecker/Types/TypeDefType.cs | 2 +- 52 files changed, 202 insertions(+), 210 deletions(-) delete mode 100644 Src/PChecker/CheckerCore/PRuntime/PEvent.cs rename Src/PCompiler/CompilerCore/TypeChecker/AST/Declarations/{PEvent.cs => Event.cs} (90%) diff --git a/Src/PChecker/CheckerCore/PRuntime/PEvent.cs b/Src/PChecker/CheckerCore/PRuntime/PEvent.cs deleted file mode 100644 index 23a16cc4d..000000000 --- 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 f0cf47b3c..7555973f9 100644 --- a/Src/PChecker/CheckerCore/PRuntime/PMachine.cs +++ b/Src/PChecker/CheckerCore/PRuntime/PMachine.cs @@ -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/Event.cs b/Src/PChecker/CheckerCore/StateMachines/Events/Event.cs index 1567ec597..286968cfb 100644 --- a/Src/PChecker/CheckerCore/StateMachines/Events/Event.cs +++ b/Src/PChecker/CheckerCore/StateMachines/Events/Event.cs @@ -1,15 +1,64 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +using System; using System.Runtime.Serialization; +using PChecker.PRuntime.Values; namespace PChecker.StateMachines.Events { /// - /// Abstract class representing an event. + /// 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 this.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 PHalt : Event + { + public PHalt(IPrtValue payload) : base(payload) + { + } } } \ No newline at end of file diff --git a/Src/PChecker/CheckerCore/StateMachines/Logging/PCheckerLogJsonFormatter.cs b/Src/PChecker/CheckerCore/StateMachines/Logging/PCheckerLogJsonFormatter.cs index e8ca7c406..fbe857f3b 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 a707b32fd..06b94318f 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 df9137281..51e770b0f 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,7 +472,7 @@ 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 pEvent) { WriteNameSpacePrologue(context, output); @@ -480,7 +480,7 @@ private void WriteEvent(CompilationContext context, StringWriter output, PEvent // initialize the payload type var payloadType = GetCSharpType(pEvent.PayloadType, true); - context.WriteLine(output, $"internal partial class {declName} : PEvent"); + 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;"); } } @@ -795,7 +795,7 @@ private void WriteStmt(CompilationContext context, StringWriter output, Function { case AnnounceStmt announceStmt: context.Write(output, "currentMachine.Announce((Event)"); - WriteExpr(context, output, announceStmt.PEvent); + WriteExpr(context, output, announceStmt.Event); if (announceStmt.Payload != null) { context.Write(output, ", "); @@ -989,7 +989,7 @@ private void WriteStmt(CompilationContext context, StringWriter output, Function case RaiseStmt raiseStmt: //last statement context.Write(output, "currentMachine.TryRaiseEvent((Event)"); - WriteExpr(context, output, raiseStmt.PEvent); + WriteExpr(context, output, raiseStmt.Event); if (raiseStmt.Payload.Any()) { context.Write(output, ", "); @@ -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 01868c7b7..6fbab8998 100644 --- a/Src/PCompiler/CompilerCore/Backend/CSharp/CSharpNameManager.cs +++ b/Src/PCompiler/CompilerCore/Backend/CSharp/CSharpNameManager.cs @@ -49,7 +49,7 @@ 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"; diff --git a/Src/PCompiler/CompilerCore/Backend/Debugging/IrToPseudoP.cs b/Src/PCompiler/CompilerCore/Backend/Debugging/IrToPseudoP.cs index a135656da..23c7968fb 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 ", @@ -168,7 +168,7 @@ private void WriteTree(IPAST tree) break; case AnnounceStmt announceStmt: - WriteStmt("announce ", announceStmt.PEvent, ", ", announceStmt.Payload, ";"); + WriteStmt("announce ", announceStmt.Event, ", ", announceStmt.Payload, ";"); break; case AssertStmt assertStmt: @@ -235,7 +235,7 @@ private void WriteTree(IPAST tree) break; case RaiseStmt raiseStmt: - WriteStmt("raise ", raiseStmt.PEvent, ", ", raiseStmt.Payload, ";"); + WriteStmt("raise ", raiseStmt.Event, ", ", raiseStmt.Payload, ";"); break; case ReceiveStmt receiveStmt: diff --git a/Src/PCompiler/CompilerCore/Backend/IRTransformer.cs b/Src/PCompiler/CompilerCore/Backend/IRTransformer.cs index 943eba0df..3de4fc381 100644 --- a/Src/PCompiler/CompilerCore/Backend/IRTransformer.cs +++ b/Src/PCompiler/CompilerCore/Backend/IRTransformer.cs @@ -338,7 +338,7 @@ private List SimplifyStatement(IPStmt statement) case null: throw new ArgumentNullException(nameof(statement)); case AnnounceStmt announceStmt: - (var annEvt, var annEvtDeps) = SimplifyExpression(announceStmt.PEvent); + (var annEvt, var annEvtDeps) = SimplifyExpression(announceStmt.Event); (IExprTerm annPayload, List annPayloadDeps) = announceStmt.Payload == null ? (null, new List()) : SimplifyExpression(announceStmt.Payload); @@ -477,7 +477,7 @@ private List SimplifyStatement(IPStmt statement) return deps.Concat(new[] { new PrintStmt(location, newMessage) }).ToList(); case RaiseStmt raiseStmt: - (var raiseEvent, var raiseEventDeps) = SimplifyExpression(raiseStmt.PEvent); + (var raiseEvent, var raiseEventDeps) = SimplifyExpression(raiseStmt.Event); (var raiseEventTmp, var raiseEventTempDep) = SaveInTemporary(new CloneExpr(raiseEvent)); (var raiseArgs, var raiseArgDeps) = SimplifyArgPack(raiseStmt.Payload); diff --git a/Src/PCompiler/CompilerCore/Backend/Java/Constants.cs b/Src/PCompiler/CompilerCore/Backend/Java/Constants.cs index 20de91eb6..d3ab2b30e 100644 --- a/Src/PCompiler/CompilerCore/Backend/Java/Constants.cs +++ b/Src/PCompiler/CompilerCore/Backend/Java/Constants.cs @@ -52,7 +52,7 @@ internal static IEnumerable ImportStatements() #region Event source generation - public static readonly string EventNamespaceName = "PEvents"; + public static readonly string EventNamespaceName = "Events"; public static readonly string EventDefnFileName = $"{EventNamespaceName}.java"; #endregion @@ -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 EventsClass = "prt.events.Event"; #endregion diff --git a/Src/PCompiler/CompilerCore/Backend/Java/EventGenerator.cs b/Src/PCompiler/CompilerCore/Backend/Java/EventGenerator.cs index b21a51cc5..ba57cc4a9 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); @@ -51,7 +51,7 @@ private void WriteEventDecl(PEvent e) var payloadType = argType.TypeName; var payloadRefType = argType.ReferenceTypeName; - WriteLine($"public static class {eventName} extends {Constants.PEventsClass}<{payloadRefType}> implements Serializable {{"); + WriteLine($"public static class {eventName} extends {Constants.EventsClass}<{payloadRefType}> implements Serializable {{"); var hasPayload = !(argType is TypeManager.JType.JVoid); if (hasPayload) diff --git a/Src/PCompiler/CompilerCore/Backend/Java/MachineGenerator.cs b/Src/PCompiler/CompilerCore/Backend/Java/MachineGenerator.cs index bddba051f..8356b1ff3 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)}"; @@ -492,7 +492,7 @@ private void WriteStmt(IPStmt stmt) case RaiseStmt raiseStmt: Write($"{Constants.TryRaiseEventMethodName}(new "); - WriteExpr(raiseStmt.PEvent); + WriteExpr(raiseStmt.Event); Write("("); foreach (var (sep, expr) in raiseStmt.Payload.WithPrefixSep(", ")) { diff --git a/Src/PCompiler/CompilerCore/Backend/Java/NameManager.cs b/Src/PCompiler/CompilerCore/Backend/Java/NameManager.cs index 7806e7dba..f07332257 100644 --- a/Src/PCompiler/CompilerCore/Backend/Java/NameManager.cs +++ b/Src/PCompiler/CompilerCore/Backend/Java/NameManager.cs @@ -95,9 +95,9 @@ protected override string ComputeNameForDecl(IPDecl decl) switch (decl) { - case PEvent { IsNullEvent: true }: + case Event { IsNullEvent: true }: return "DefaultEvent"; - case PEvent { IsHaltEvent: true }: + case Event { IsHaltEvent: true }: return "PHalt"; case Interface i: name = "I_" + i.Name; diff --git a/Src/PCompiler/CompilerCore/Backend/Java/TypeManager.cs b/Src/PCompiler/CompilerCore/Backend/Java/TypeManager.cs index 75ec9954c..1afbace9d 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() { @@ -304,7 +304,7 @@ internal class JEvent : JType { internal JEvent() { - _unboxedType = $"{Constants.PEventsClass}"; + _unboxedType = $"{Constants.EventsClass}"; } internal override bool IsPrimitive => false; } diff --git a/Src/PCompiler/CompilerCore/Backend/Symbolic/CompilationContext.cs b/Src/PCompiler/CompilerCore/Backend/Symbolic/CompilationContext.cs index 84944ef9c..915e71d95 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 56df9df64..f5a7d6662 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 9b4ef08a2..f2129613e 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) @@ -1039,7 +1039,7 @@ private void WriteStmt(Function function, CompilationContext context, StringWrit context.WriteLine(output, "// NOTE (TODO): We currently perform no typechecking on the payload!"); context.Write(output, $"outcome.raiseGuardedEvent({flowContext.pcScope.PathConstraintVar}, "); - WriteExpr(context, output, flowContext.pcScope, raiseStmt.PEvent); + WriteExpr(context, output, flowContext.pcScope, raiseStmt.Event); if (raiseStmt.Payload.Count > 0) { // TODO: Determine how multi-payload raise statements are supposed to work @@ -1312,7 +1312,7 @@ private void WriteStmt(Function function, CompilationContext context, StringWrit } case AnnounceStmt announceStmt: context.Write(output, $"{CompilationContext.SchedulerVar}.announce("); - WriteExpr(context, output, flowContext.pcScope, announceStmt.PEvent); + WriteExpr(context, output, flowContext.pcScope, announceStmt.Event); context.Write(output, ", "); if (announceStmt.Payload == null) context.Write(output, "null"); diff --git a/Src/PCompiler/CompilerCore/Backend/Symbolic/TransformASTPass.cs b/Src/PCompiler/CompilerCore/Backend/Symbolic/TransformASTPass.cs index aeebf23e2..49ceae0df 100644 --- a/Src/PCompiler/CompilerCore/Backend/Symbolic/TransformASTPass.cs +++ b/Src/PCompiler/CompilerCore/Backend/Symbolic/TransformASTPass.cs @@ -346,7 +346,7 @@ static private IPStmt ReplaceVars(IPStmt stmt, Dictionary var case AddStmt addStmt: return new AddStmt(addStmt.SourceLocation, ReplaceVars(addStmt.Variable, varMap), ReplaceVars(addStmt.Value, varMap)); case AnnounceStmt announceStmt: - return new AnnounceStmt(announceStmt.SourceLocation, ReplaceVars(announceStmt.PEvent, varMap), ReplaceVars(announceStmt.Payload, varMap)); + return new AnnounceStmt(announceStmt.SourceLocation, ReplaceVars(announceStmt.Event, varMap), ReplaceVars(announceStmt.Payload, varMap)); case AssertStmt assertStmt: return new AssertStmt(assertStmt.SourceLocation, ReplaceVars(assertStmt.Assertion, varMap), ReplaceVars(assertStmt.Message, varMap)); case AssignStmt assignStmt: @@ -378,9 +378,9 @@ static private IPStmt ReplaceVars(IPStmt stmt, Dictionary var case RaiseStmt raiseStmt: var payload = new List(); foreach(var p in raiseStmt.Payload) payload.Add(ReplaceVars(p, varMap)); - return new RaiseStmt(raiseStmt.SourceLocation, ReplaceVars(raiseStmt.PEvent, varMap), payload); + return new RaiseStmt(raiseStmt.SourceLocation, ReplaceVars(raiseStmt.Event, 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 e2a65cfbc..927c22cf0 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,7 +310,7 @@ 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 pEvent) { return IssueError(location, $"Event {pEvent.Name} appears twice in receive statement argument list"); } @@ -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 4d7248634..81e70516a 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 pEvent); 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 ab5d3cfdf..961b2d0c4 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 29ae11574..e2b7ec201 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 pEvent); - void AddEvents(IEnumerable evts); + void AddEvents(IEnumerable evts); - bool Contains(PEvent pEvent); + bool Contains(Event pEvent); 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 pEvent) { return events.Add(pEvent); } - public void AddEvents(IEnumerable evts) + public void AddEvents(IEnumerable evts) { foreach (var pEvent in evts) { @@ -46,7 +46,7 @@ public void AddEvents(IEnumerable evts) } } - public bool Contains(PEvent pEvent) + public bool Contains(Event pEvent) { return events.Contains(pEvent); } @@ -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,14 +89,14 @@ 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 pEvent) { return events.Contains(pEvent); } @@ -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 fb26afeae..6b0a97a21 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 36fa68cd4..a7c899ee8 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 95943e5f7..b6c090dfe 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/AnnounceStmt.cs b/Src/PCompiler/CompilerCore/TypeChecker/AST/Statements/AnnounceStmt.cs index 46847981e..eb6faecaa 100644 --- a/Src/PCompiler/CompilerCore/TypeChecker/AST/Statements/AnnounceStmt.cs +++ b/Src/PCompiler/CompilerCore/TypeChecker/AST/Statements/AnnounceStmt.cs @@ -7,11 +7,11 @@ public class AnnounceStmt : IPStmt public AnnounceStmt(ParserRuleContext sourceLocation, IPExpr pEvent, IPExpr payload) { SourceLocation = sourceLocation; - PEvent = pEvent; + Event = pEvent; Payload = payload; } - public IPExpr PEvent { get; } + public IPExpr Event { get; } public IPExpr Payload { get; } public ParserRuleContext SourceLocation { get; } diff --git a/Src/PCompiler/CompilerCore/TypeChecker/AST/Statements/RaiseStmt.cs b/Src/PCompiler/CompilerCore/TypeChecker/AST/Statements/RaiseStmt.cs index 73bf19ca2..09b7c1b16 100644 --- a/Src/PCompiler/CompilerCore/TypeChecker/AST/Statements/RaiseStmt.cs +++ b/Src/PCompiler/CompilerCore/TypeChecker/AST/Statements/RaiseStmt.cs @@ -8,11 +8,11 @@ public class RaiseStmt : IPStmt public RaiseStmt(ParserRuleContext sourceLocation, IPExpr pEvent, IReadOnlyList payload) { SourceLocation = sourceLocation; - PEvent = pEvent; + Event = pEvent; Payload = payload; } - public IPExpr PEvent { get; } + public IPExpr Event { get; } public IReadOnlyList Payload { get; } public ParserRuleContext SourceLocation { get; } diff --git a/Src/PCompiler/CompilerCore/TypeChecker/AST/Statements/ReceiveStmt.cs b/Src/PCompiler/CompilerCore/TypeChecker/AST/Statements/ReceiveStmt.cs index 4a661a0b0..dcc5535aa 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 e6b5bc09c..f2080e1e7 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 98dc3242b..ec331a7f5 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 9fabc0711..b2ec55164 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 af38eafa3..d41944978 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 3d1ecf70b..15881aa6e 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,7 +51,7 @@ public string QualifiedName public string Name { get; } public ParserRuleContext SourceLocation { get; } - public bool HasHandler(PEvent pEvent) + public bool HasHandler(Event pEvent) { return actions.ContainsKey(pEvent); } diff --git a/Src/PCompiler/CompilerCore/TypeChecker/DeclarationVisitor.cs b/Src/PCompiler/CompilerCore/TypeChecker/DeclarationVisitor.cs index b726380da..46dc2b34f 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 82fd330db..01d2716f2 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/InferMachineCreates.cs b/Src/PCompiler/CompilerCore/TypeChecker/InferMachineCreates.cs index bb8e43493..4327ed099 100644 --- a/Src/PCompiler/CompilerCore/TypeChecker/InferMachineCreates.cs +++ b/Src/PCompiler/CompilerCore/TypeChecker/InferMachineCreates.cs @@ -47,7 +47,7 @@ private static IEnumerable InferCreates(IPAST tree, ITranslationError .Union(InferCreatesForExpr(addStmt.Value, handler)); case AnnounceStmt announce: - return InferCreatesForExpr(announce.PEvent, handler) + return InferCreatesForExpr(announce.Event, handler) .Union(InferCreatesForExpr(announce.Payload, handler)); case AssertStmt assertStmt: @@ -92,7 +92,7 @@ private static IEnumerable InferCreates(IPAST tree, ITranslationError return InferCreatesForExpr(printStmt.Message, handler); case RaiseStmt raiseStmt: - return InferCreatesForExpr(raiseStmt.PEvent, handler) + return InferCreatesForExpr(raiseStmt.Event, handler) .Union(raiseStmt.Payload.SelectMany(expr => InferCreatesForExpr(expr, handler))); case ReceiveStmt receiveStmt: diff --git a/Src/PCompiler/CompilerCore/TypeChecker/ModuleExprVisitor.cs b/Src/PCompiler/CompilerCore/TypeChecker/ModuleExprVisitor.cs index cba686404..3d6d5390f 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 d8cf61fd6..cad8a5945 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 ba5e0dfc9..84f18001c 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 ba3e83895..2f694d46c 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 1a36c2c9d..b07d70614 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 6e8a8e686..ee0d6481b 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 e8f123e48..28b5ef03b 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 3e1f7d37a..fcc16e50f 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 c5f4aeeb1..6810f56a1 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 59d08a3b6..54288ad0d 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 302e248dc..6c9645255 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 6bdfc4aec..2ddb2db19 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 f2ca29484..04259e2a6 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 09bc7c912..9bcac127d 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 b9919c072..60e8676ca 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 6a2db4053..9a49089b5 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) {