public override object VisitSafetyTestDecl([NotNull] PParser.SafetyTestDeclContext context) { string symbolName = context.testName.GetText(); SafetyTest decl = CurrentScope.Put(symbolName, context); decl.Main = context.mainMachine?.GetText(); nodesToDeclarations.Put(context, decl); return(null); }
public SafetyTest Put(string name, PParser.SafetyTestDeclContext tree) { SafetyTest safetyTest = new SafetyTest(tree, name); CheckConflicts(safetyTest, Namespace(implementations), Namespace(safetyTests), Namespace(refinementTests)); safetyTests.Add(name, safetyTest); return(safetyTest); }
public bool Lookup(string name, out SafetyTest tree) { Scope current = this; while (current != null) { if (current.Get(name, out tree)) { return(true); } current = current.Parent; } tree = null; return(false); }
internal void CheckSafetyTest(SafetyTest test) { //check that the test module is closed with respect to creates IEnumerable <Interface> notImplementedInterface = test.ModExpr.ModuleInfo.Creates.Interfaces.Where(i => !test.ModExpr.ModuleInfo.InterfaceDef.Keys.Contains(i)); Interface[] @interface = notImplementedInterface as Interface[] ?? notImplementedInterface.ToArray(); if (@interface.Any()) { throw handler.NotClosed(test.SourceLocation, $"test module is not closed with respect to created interfaces; interface {@interface.First().Name} is created but not implemented inside the module"); } //check that the test module main machine exists bool hasMainMachine = test.ModExpr.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 test module"); } }
public bool Get(string name, out SafetyTest tree) { return(safetyTests.TryGetValue(name, out tree)); }