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 static void PopulateAllModuleExprs( ITranslationErrorHandler handler, Scope globalScope) { ModuleExprVisitor modExprVisitor = new ModuleExprVisitor(handler, globalScope); // first do all the named modules foreach (NamedModule mod in globalScope.NamedModules) { PParser.NamedModuleDeclContext context = (PParser.NamedModuleDeclContext)mod.SourceLocation; mod.ModExpr = modExprVisitor.Visit(context.modExpr()); } // all the test declarations foreach (SafetyTest test in globalScope.SafetyTests) { PParser.SafetyTestDeclContext context = (PParser.SafetyTestDeclContext)test.SourceLocation; test.ModExpr = modExprVisitor.Visit(context.modExpr()); } foreach (RefinementTest test in globalScope.RefinementTests) { PParser.RefinementTestDeclContext context = (PParser.RefinementTestDeclContext)test.SourceLocation; test.LeftModExpr = modExprVisitor.Visit(context.modExpr()[0]); test.RightModExpr = modExprVisitor.Visit(context.modExpr()[1]); } if (globalScope.Implementations.Any()) { // all user defind implementations foreach (Implementation impl in globalScope.Implementations) { PParser.ImplementationDeclContext context = (PParser.ImplementationDeclContext)impl.SourceLocation; impl.ModExpr = modExprVisitor.Visit(context.modExpr()); } } else if (!globalScope.SafetyTests.Any()) { Implementation defaultImplDecl = new Implementation(ParserRuleContext.EmptyContext, "DefaultImpl") { Main = "Main" }; // create bindings from each machine to itself List <Tuple <Interface, Machine> > defaultBindings = new List <Tuple <Interface, Machine> >(); foreach (Machine machine in globalScope.Machines.Where(m => !m.IsSpec)) { globalScope.Get(machine.Name, out Interface @interface); defaultBindings.Add(new Tuple <Interface, Machine>(@interface, machine)); } defaultImplDecl.ModExpr = new BindModuleExpr(ParserRuleContext.EmptyContext, defaultBindings); globalScope.AddDefaultImpl(defaultImplDecl); } }
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); }