public override object VisitRefinementTestDecl([NotNull] PParser.RefinementTestDeclContext context) { string symbolName = context.testName.GetText(); RefinementTest decl = CurrentScope.Put(symbolName, context); decl.Main = context.mainMachine?.GetText(); nodesToDeclarations.Put(context, decl); return(null); }
public RefinementTest Put(string name, PParser.RefinementTestDeclContext tree) { RefinementTest refineTest = new RefinementTest(tree, name); CheckConflicts(refineTest, Namespace(implementations), Namespace(safetyTests), Namespace(refinementTests)); refinementTests.Add(name, refineTest); return(refineTest); }
internal void CheckRefinementTest(RefinementTest test) { //check that the test module is closed with respect to creates var notImplementedInterface = test.LeftModExpr.ModuleInfo.Creates.Interfaces.Where(i => !test.LeftModExpr.ModuleInfo.InterfaceDef.Keys.Contains(i)); var @interface = notImplementedInterface as Interface[] ?? notImplementedInterface.ToArray(); if (@interface.Any()) { throw handler.NotClosed(test.SourceLocation, $"LHS test module is not closed with respect to created interfaces; interface {@interface.First()} is created but not implemented inside the module"); } //check that the test module main machine exists var hasMainMachine = test.LeftModExpr.ModuleInfo.InterfaceDef.Values.Any(m => m.Name == test.Main && !m.IsSpec); if (!hasMainMachine) { throw handler.NoMain(test.SourceLocation, $"machine {test.Main} does not exist in the LHS test module"); } //check that the test module is closed with respect to creates notImplementedInterface = test.RightModExpr.ModuleInfo.Creates.Interfaces.Where(i => !test.RightModExpr.ModuleInfo.InterfaceDef.Keys.Contains(i)); @interface = notImplementedInterface as Interface[] ?? notImplementedInterface.ToArray(); if (@interface.Any()) { throw handler.NotClosed(test.SourceLocation, $"RHS test module is not closed with respect to created interfaces; interface {@interface.First()} is created but not implemented inside the module"); } //check that the test module main machine exists hasMainMachine = test.RightModExpr.ModuleInfo.InterfaceDef.Values.Any(m => m.Name == test.Main && !m.IsSpec); if (!hasMainMachine) { throw handler.NoMain(test.SourceLocation, $"machine {test.Main} does not exist in the RHS test module"); } //todo: Implement the checks with respect to refinement relation throw new NotImplementedException(); }
public bool Lookup(string name, out RefinementTest tree) { Scope current = this; while (current != null) { if (current.Get(name, out tree)) { return(true); } current = current.Parent; } tree = null; return(false); }
public bool Get(string name, out RefinementTest tree) { return(refinementTests.TryGetValue(name, out tree)); }