public Dictionary <string, Expr> PermissionExprs(Absy absy)
        {
            var domainNameToScope = new Dictionary <string, HashSet <Variable> >();

            foreach (var domainName in linearTypeChecker.linearDomains.Keys)
            {
                domainNameToScope[domainName] = new HashSet <Variable>();
            }

            var availableVars = AvailableLinearLocalVars(absy).Union(LinearGlobalVars());

            foreach (var v in availableVars)
            {
                var domainName = linearTypeChecker.FindDomainName(v);
                domainNameToScope[domainName].Add(MapVariable(v));
            }

            var domainNameToExpr = new Dictionary <string, Expr>();

            foreach (var domainName in domainNameToScope.Keys)
            {
                var permissionExprs =
                    linearTypeChecker.PermissionExprForEachVariable(domainName, domainNameToScope[domainName]);
                domainNameToExpr[domainName] = linearTypeChecker.UnionExprForPermissions(domainName, permissionExprs);
            }

            return(domainNameToExpr);
        }
示例#2
0
        private List <Requires> DisjointnessRequires(Program program, AtomicActionInfo first, AtomicActionInfo second, HashSet <Variable> frame)
        {
            List <Requires> requires = new List <Requires>();
            Dictionary <string, HashSet <Variable> > domainNameToScope = new Dictionary <string, HashSet <Variable> >();

            foreach (var domainName in linearTypeChecker.linearDomains.Keys)
            {
                domainNameToScope[domainName] = new HashSet <Variable>();
            }
            foreach (Variable v in frame)
            {
                var domainName = linearTypeChecker.FindDomainName(v);
                if (domainName == null)
                {
                    continue;
                }
                if (!linearTypeChecker.linearDomains.ContainsKey(domainName))
                {
                    continue;
                }
                domainNameToScope[domainName].Add(v);
            }
            if (first != null)
            {
                foreach (Variable v in first.thatInParams)
                {
                    var domainName = linearTypeChecker.FindDomainName(v);
                    if (domainName == null)
                    {
                        continue;
                    }
                    if (!linearTypeChecker.linearDomains.ContainsKey(domainName))
                    {
                        continue;
                    }
                    domainNameToScope[domainName].Add(v);
                }
            }
            foreach (Variable v in second.thisInParams)
            {
                var domainName = linearTypeChecker.FindDomainName(v);
                if (domainName == null)
                {
                    continue;
                }
                if (!linearTypeChecker.linearDomains.ContainsKey(domainName))
                {
                    continue;
                }
                domainNameToScope[domainName].Add(v);
            }
            foreach (string domainName in domainNameToScope.Keys)
            {
                requires.Add(new Requires(false, linearTypeChecker.DisjointnessExpr(domainName, domainNameToScope[domainName])));
            }
            return(requires);
        }
示例#3
0
        private IEnumerable <Expr> DisjointnessExpr(Program program, IEnumerable <Variable> paramVars, HashSet <Variable> frame)
        {
            Dictionary <string, HashSet <Variable> > domainNameToScope = new Dictionary <string, HashSet <Variable> >();

            foreach (var domainName in linearTypeChecker.linearDomains.Keys)
            {
                domainNameToScope[domainName] = new HashSet <Variable>();
            }
            foreach (Variable v in paramVars.Union(frame))
            {
                var domainName = linearTypeChecker.FindDomainName(v);
                if (domainName == null)
                {
                    continue;
                }
                if (!linearTypeChecker.linearDomains.ContainsKey(domainName))
                {
                    continue;
                }
                domainNameToScope[domainName].Add(v);
            }
            foreach (string domainName in domainNameToScope.Keys)
            {
                yield return(linearTypeChecker.DisjointnessExpr(domainName, domainNameToScope[domainName]));
            }
        }
示例#4
0
        private List <Requires> DisjointnessRequires(Program program, ActionInfo first, ActionInfo second)
        {
            List <Requires> requires = new List <Requires>();
            Dictionary <string, HashSet <Variable> > domainNameToScope = new Dictionary <string, HashSet <Variable> >();

            foreach (var domainName in linearTypeChecker.linearDomains.Keys)
            {
                domainNameToScope[domainName] = new HashSet <Variable>();
            }
            foreach (Variable v in program.GlobalVariables())
            {
                var domainName = linearTypeChecker.FindDomainName(v);
                if (domainName == null)
                {
                    continue;
                }
                domainNameToScope[domainName].Add(v);
            }
            foreach (Variable v in first.thisInParams)
            {
                var domainName = linearTypeChecker.FindDomainName(v);
                if (domainName == null)
                {
                    continue;
                }
                domainNameToScope[domainName].Add(v);
            }
            for (int i = 0; i < second.thatInParams.Count; i++)
            {
                var domainName = linearTypeChecker.FindDomainName(second.thisInParams[i]);
                if (domainName == null)
                {
                    continue;
                }
                domainNameToScope[domainName].Add(second.thatInParams[i]);
            }
            foreach (string domainName in domainNameToScope.Keys)
            {
                requires.Add(new Requires(false, linearTypeChecker.DisjointnessExpr(domainName, domainNameToScope[domainName])));
            }
            return(requires);
        }
示例#5
0
    private static List<Expr> PendingAsyncLinearParams(LinearTypeChecker linearTypeChecker, LinearDomain domain, AtomicAction pendingAsync, IdentifierExpr pa)
    {
      var pendingAsyncLinearParams = new List<Expr>();

      for (int i = 0; i < pendingAsync.proc.InParams.Count; i++)
      {
        var inParam = pendingAsync.proc.InParams[i];
        if (linearTypeChecker.FindDomainName(inParam) == domain.domainName && InKinds.Contains(linearTypeChecker.FindLinearKind(inParam)))
        {
          var pendingAsyncParam = ExprHelper.FunctionCall(pendingAsync.pendingAsyncCtor.selectors[i], pa);
          pendingAsyncLinearParams.Add(pendingAsyncParam);
        }
      }

      return pendingAsyncLinearParams;
    }
示例#6
0
        public List <Cmd> CreateInitCmds(Implementation impl)
        {
            Dictionary <string, Expr> domainNameToExpr = ComputeAvailableExprs(impl.InParams.FindAll(x => linearTypeChecker.FindDomainName(x) != null));
            List <AssignLhs>          lhss             = new List <AssignLhs>();
            List <Expr> rhss = new List <Expr>();

            foreach (string domainName in linearTypeChecker.linearDomains.Keys)
            {
                lhss.Add(new SimpleAssignLhs(Token.NoToken, Expr.Ident(domainNameToLocalVar[domainName])));
                rhss.Add(domainNameToExpr[domainName]);
            }
            var initCmds = new List <Cmd>();

            if (lhss.Count > 0)
            {
                initCmds.Add(new AssignCmd(Token.NoToken, lhss, rhss));
            }
            return(initCmds);
        }