private TransitionRelationComputation( AtomicActionCopyAdapter first, AtomicActionCopyAdapter second, IEnumerable <Variable> frame, List <WitnessFunction> witnesses, bool ignorePostState, string messagePrefix) { this.first = first; this.second = second; this.frame = new HashSet <Variable>(frame); this.ignorePostState = ignorePostState; this.messagePrefix = messagePrefix; this.checkingContext = new CheckingContext(null); this.pathTranslations = new List <Expr>(); this.globalVarToWitnesses = new Dictionary <GlobalVariable, List <WitnessFunction> >(); if (witnesses != null) { foreach (var witness in witnesses) { var gVar = witness.globalVar; if (!globalVarToWitnesses.ContainsKey(gVar)) { globalVarToWitnesses[gVar] = new List <WitnessFunction>(); } globalVarToWitnesses[gVar].Add(witness); } } }
public LinearTypeChecker(Program program) { this.program = program; this.errorCount = 0; this.checkingContext = new CheckingContext(null); this.domainNameToType = new Dictionary <string, Type>(); this.availableLinearVars = new Dictionary <Absy, HashSet <Variable> >(); this.inoutParamToDomainName = new Dictionary <Variable, string>(); this.varToDomainName = new Dictionary <Variable, string>(); this.linearDomains = new Dictionary <string, LinearDomain>(); }
public LinearTypeChecker(Program program) { this.program = program; this.errorCount = 0; this.checkingContext = new CheckingContext(null); this.domainNameToCollectors = new Dictionary<string, Dictionary<Type, Function>>(); this.availableLinearVars = new Dictionary<Absy, HashSet<Variable>>(); this.inParamToLinearQualifier = new Dictionary<Variable, LinearQualifier>(); this.outParamToDomainName = new Dictionary<Variable, string>(); this.varToDomainName = new Dictionary<Variable, string>(); this.globalVarToDomainName = new Dictionary<Variable, string>(); this.linearDomains = new Dictionary<string, LinearDomain>(); }
public LinearTypeChecker(CivlTypeChecker civlTypeChecker) { this.civlTypeChecker = civlTypeChecker; this.program = civlTypeChecker.program; this.checkingContext = civlTypeChecker.checkingContext; this.domainNameToCollectors = new Dictionary<string, Dictionary<Type, Function>>(); this.availableLinearVars = new Dictionary<Absy, HashSet<Variable>>(); this.inParamToLinearQualifier = new Dictionary<Variable, LinearQualifier>(); this.outParamToDomainName = new Dictionary<Variable, string>(); this.globalVarToDomainName = new Dictionary<Variable, string>(); this.linearDomains = new Dictionary<string, LinearDomain>(); this.varToDomainName = new Dictionary<Variable, string>(); }
public MoverTypeChecker(Program program) { this.qedGlobalVariables = new HashSet <Variable>(); foreach (var g in program.GlobalVariables()) { if (QKeyValue.FindBoolAttribute(g.Attributes, "qed")) { this.qedGlobalVariables.Add(g); g.Attributes = OwickiGries.RemoveQedAttribute(g.Attributes); } } this.procToActionInfo = new Dictionary <Procedure, ActionInfo>(); this.assertionPhaseNums = new HashSet <int>(); this.errorCount = 0; this.checkingContext = new CheckingContext(null); this.program = program; this.enclosingProcPhaseNum = int.MaxValue; this.inAtomicSpecification = false; }
private TransitionRelationComputation( CivlTypeChecker civlTypeChecker, Implementation first, Implementation second, IEnumerable <Variable> frame, IEnumerable <CommutativityWitness> witnesses, Dictionary <Variable, Function> triggers, bool ignorePostState, string messagePrefix) { this.civlTypeChecker = civlTypeChecker; this.first = first; this.second = second; this.triggers = triggers; this.frame = new HashSet <Variable>(frame); this.ignorePostState = ignorePostState; allInParams = new HashSet <Variable>(first.InParams); allOutParams = new HashSet <Variable>(first.OutParams); allLocVars = new HashSet <Variable>(first.LocVars); if (IsJoint) { allInParams.UnionWith(second.InParams); allOutParams.UnionWith(second.OutParams); allLocVars.UnionWith(second.LocVars); } this.messagePrefix = messagePrefix; this.checkingContext = new CheckingContext(null); this.pathTranslations = new List <Expr>(); this.globalVarToWitnesses = new Dictionary <Variable, List <CommutativityWitness> >(); if (witnesses != null) { foreach (var witness in witnesses) { var gVar = witness.witnessedVariable; if (!globalVarToWitnesses.ContainsKey(gVar)) { globalVarToWitnesses[gVar] = new List <CommutativityWitness>(); } globalVarToWitnesses[gVar].Add(witness); } } }
public CivlTypeChecker(Program program) { this.errorCount = 0; this.checkingContext = new CheckingContext(null); this.program = program; this.enclosingProc = null; this.enclosingImpl = null; this.sharedVarsAccessed = null; this.introducedLocalVarsUpperBound = int.MinValue; this.localVarToLocalVariableInfo = new Dictionary <Variable, LocalVariableInfo>(); this.absyToLayerNums = new Dictionary <Absy, HashSet <int> >(); this.globalVarToSharedVarInfo = new Dictionary <Variable, SharedVariableInfo>(); this.procToActionInfo = new Dictionary <Procedure, ActionInfo>(); this.procToAtomicProcedureInfo = new Dictionary <Procedure, AtomicProcedureInfo>(); this.pureCallLayer = new Dictionary <CallCmd, int>(); foreach (var g in program.GlobalVariables) { List <int> layerNums = FindLayers(g.Attributes); if (layerNums.Count == 0) { // Inaccessible from yielding and atomic procedures } else if (layerNums.Count == 1) { this.globalVarToSharedVarInfo[g] = new SharedVariableInfo(layerNums[0], int.MaxValue); } else if (layerNums.Count == 2) { this.globalVarToSharedVarInfo[g] = new SharedVariableInfo(layerNums[0], layerNums[1]); } else { Error(g, "Too many layer numbers"); } } }
public MoverTypeChecker(Program program) { this.ghostVars = new HashSet <Variable>(); this.absyToLayerNums = new Dictionary <Absy, HashSet <int> >(); this.globalVarToSharedVarInfo = new Dictionary <Variable, SharedVariableInfo>(); this.procToActionInfo = new Dictionary <Procedure, ActionInfo>(); this.errorCount = 0; this.checkingContext = new CheckingContext(null); this.program = program; this.enclosingProc = null; this.enclosingImpl = null; this.canAccessSharedVars = false; this.canAccessGhostVars = false; this.minLayerNum = int.MaxValue; this.maxLayerNum = -1; this.leastUnimplementedLayerNum = int.MaxValue; foreach (var g in program.GlobalVariables) { List <int> layerNums = FindLayers(g.Attributes); if (layerNums.Count == 0) { // Cannot access atomic actions } else if (layerNums.Count == 1) { this.globalVarToSharedVarInfo[g] = new SharedVariableInfo(layerNums[0], int.MaxValue); } else if (layerNums.Count == 2) { this.globalVarToSharedVarInfo[g] = new SharedVariableInfo(layerNums[0], layerNums[1]); } else { Error(g, "Too many layer numbers"); } } }
public CivlTypeChecker(Program program) { this.errorCount = 0; this.checkingContext = new CheckingContext(null); this.program = program; this.enclosingProc = null; this.enclosingImpl = null; this.sharedVarsAccessed = null; this.introducedLocalVarsUpperBound = int.MinValue; this.localVarToLocalVariableInfo = new Dictionary<Variable, LocalVariableInfo>(); this.absyToLayerNums = new Dictionary<Absy, HashSet<int>>(); this.globalVarToSharedVarInfo = new Dictionary<Variable, SharedVariableInfo>(); this.procToActionInfo = new Dictionary<Procedure, ActionInfo>(); this.procToAtomicProcedureInfo = new Dictionary<Procedure, AtomicProcedureInfo>(); this.pureCallLayer = new Dictionary<CallCmd, int>(); // Global variables foreach (var g in program.GlobalVariables) { List<int> layerNums = FindLayers(g.Attributes); if (layerNums.Count == 0) { // Inaccessible from yielding and atomic procedures } else if (layerNums.Count == 1) { this.globalVarToSharedVarInfo[g] = new SharedVariableInfo(layerNums[0], int.MaxValue); } else if (layerNums.Count == 2) { this.globalVarToSharedVarInfo[g] = new SharedVariableInfo(layerNums[0], layerNums[1]); } else { Error(g, "Too many layer numbers"); } } }
public YieldTypeChecker(CivlTypeChecker civlTypeChecker) { this.civlTypeChecker = civlTypeChecker; this.checkingContext = new CheckingContext(null); this.moverProcedureCallGraph = new Graph <MoverProc>(); }
public static bool Check(Program program) { var checkingContext = new CheckingContext(null); var functionDependencyChecker = new FunctionDependencyChecker(); program.TopLevelDeclarations.OfType <Function>().Iter(function => { var expr = QKeyValue.FindExprAttribute(function.Attributes, "inline"); if (expr != null && expr.Type != Type.Bool) { checkingContext.Error(function.tok, "Parameter to :inline attribute on a function must be Boolean"); } if (QKeyValue.FindBoolAttribute(function.Attributes, "inline") && QKeyValue.FindBoolAttribute(function.Attributes, "define")) { checkingContext.Error(function.tok, "A function may not have both :inline and :define attributes"); } if (QKeyValue.FindBoolAttribute(function.Attributes, "inline") && function.Body == null) { checkingContext.Error(function.tok, "Function with :inline attribute must have a body"); } if (QKeyValue.FindBoolAttribute(function.Attributes, "define") && function.DefinitionBody == null) { checkingContext.Error(function.tok, "Function with :define attribute must have a body"); } }); if (checkingContext.ErrorCount > 0) { return(false); } program.TopLevelDeclarations.OfType <Function>() .Iter(function => functionDependencyChecker.VisitFunction(function)); var functionDependencyGraph = functionDependencyChecker.functionDependencyGraph; var selfLoops = functionDependencyGraph.Edges.SelectMany(edge => edge.Item1 == edge.Item2 ? new[] { edge.Item1 } : Enumerable.Empty <Function>()).ToHashSet(); var sccs = new StronglyConnectedComponents <Function>( functionDependencyGraph.Nodes, functionDependencyGraph.Predecessors, functionDependencyGraph.Successors); sccs.Compute(); sccs.Iter(scc => { if (scc.Count > 1 || scc.Count == 1 && selfLoops.Contains(scc.First())) { var errorMsg = "Call cycle detected among functions"; var first = true; var token = Token.NoToken; scc.Iter(function => { if (first) { first = false; errorMsg += ": "; token = function.tok; } else { errorMsg += ", "; } errorMsg += function.Name; }); checkingContext.Error(token, errorMsg); } }); return(checkingContext.ErrorCount == 0); }
public YieldSufficiencyTypeChecker(CivlTypeChecker civlTypeChecker) { this.civlTypeChecker = civlTypeChecker; this.checkingContext = civlTypeChecker.checkingContext; this.moverProcedureCallGraph = new Graph <MoverProc>(); }
public LinearTypeChecker(Program program) { this.program = program; this.errorCount = 0; this.checkingContext = new CheckingContext(null); this.domainNameToType = new Dictionary<string, Type>(); this.availableLinearVars = new Dictionary<Absy, HashSet<Variable>>(); this.inoutParamToDomainName = new Dictionary<Variable, string>(); this.varToDomainName = new Dictionary<Variable, string>(); this.linearDomains = new Dictionary<string, LinearDomain>(); }
public MoverTypeChecker(Program program) { this.ghostVars = new HashSet<Variable>(); this.absyToLayerNums = new Dictionary<Absy, HashSet<int>>(); this.globalVarToSharedVarInfo = new Dictionary<Variable, SharedVariableInfo>(); this.procToActionInfo = new Dictionary<Procedure, ActionInfo>(); this.errorCount = 0; this.checkingContext = new CheckingContext(null); this.program = program; this.enclosingProc = null; this.enclosingImpl = null; this.canAccessSharedVars = false; this.canAccessGhostVars = false; this.minLayerNum = int.MaxValue; this.maxLayerNum = -1; this.leastUnimplementedLayerNum = int.MaxValue; foreach (var g in program.GlobalVariables) { List<int> layerNums = FindLayers(g.Attributes); if (layerNums.Count == 0) { // Cannot access atomic actions } else if (layerNums.Count == 1) { this.globalVarToSharedVarInfo[g] = new SharedVariableInfo(layerNums[0], int.MaxValue); } else if (layerNums.Count == 2) { this.globalVarToSharedVarInfo[g] = new SharedVariableInfo(layerNums[0], layerNums[1]); } else { Error(g, "Too many layer numbers"); } } }
public MoverTypeChecker(Program program) { this.qedGlobalVariables = new HashSet<Variable>(); foreach (var g in program.GlobalVariables()) { if (QKeyValue.FindBoolAttribute(g.Attributes, "qed")) { this.qedGlobalVariables.Add(g); g.Attributes = OwickiGries.RemoveQedAttribute(g.Attributes); } } this.procToActionInfo = new Dictionary<Procedure, ActionInfo>(); this.assertionPhaseNums = new HashSet<int>(); this.errorCount = 0; this.checkingContext = new CheckingContext(null); this.program = program; this.enclosingProcPhaseNum = int.MaxValue; this.inAtomicSpecification = false; }