Esempio n. 1
0
 private void ProcessParCallCmd(ParCallCmd originalParCallCmd, ParCallCmd parCallCmd, List<Cmd> newCmds)
 {
     int maxCalleeLayerNum = 0;
     foreach (CallCmd iter in originalParCallCmd.CallCmds)
     {
         int calleeLayerNum = moverTypeChecker.procToActionInfo[iter.Proc].createdAtLayerNum;
         if (calleeLayerNum > maxCalleeLayerNum)
             maxCalleeLayerNum = calleeLayerNum;
     }
     if (layerNum > maxCalleeLayerNum)
     {
         for (int i = 0; i < parCallCmd.CallCmds.Count; i++) 
         {
             ProcessCallCmd(originalParCallCmd.CallCmds[i], parCallCmd.CallCmds[i], newCmds);
             absyMap[parCallCmd.CallCmds[i]] = originalParCallCmd;
         }
     }
     else
     {
         newCmds.Add(parCallCmd);
     }
 }
Esempio n. 2
0
 public override Cmd VisitParCallCmd(ParCallCmd node) {
   //Contract.Requires(node != null);
   Contract.Ensures(Contract.Result<Cmd>() != null);
   ParCallCmd clone = (ParCallCmd)node.Clone();
   Contract.Assert(clone != null);
   clone.CallCmds = new List<CallCmd>(node.CallCmds);
   return base.VisitParCallCmd(clone);
 }
Esempio n. 3
0
 public override Cmd VisitParCallCmd(ParCallCmd node)
 {
     ParCallCmd parCallCmd = (ParCallCmd) base.VisitParCallCmd(node);
     absyMap[parCallCmd] = node;
     return parCallCmd;
 }
Esempio n. 4
0
 public void DesugarParallelCallCmd(List<Cmd> newCmds, ParCallCmd parCallCmd)
 {
     List<string> parallelCalleeNames = new List<string>();
     List<Expr> ins = new List<Expr>();
     List<IdentifierExpr> outs = new List<IdentifierExpr>();
     string procName = "og";
     foreach (CallCmd callCmd in parCallCmd.CallCmds)
     {
         procName = procName + "_" + callCmd.Proc.Name;
         ins.AddRange(callCmd.Ins);
         outs.AddRange(callCmd.Outs);
     }
     Procedure proc;
     if (asyncAndParallelCallDesugarings.ContainsKey(procName))
     {
         proc = asyncAndParallelCallDesugarings[procName];
     }
     else
     {
         List<Variable> inParams = new List<Variable>();
         List<Variable> outParams = new List<Variable>();
         List<Requires> requiresSeq = new List<Requires>();
         List<Ensures> ensuresSeq = new List<Ensures>();
         int count = 0;
         foreach (CallCmd callCmd in parCallCmd.CallCmds)
         {
             Dictionary<Variable, Expr> map = new Dictionary<Variable, Expr>();
             foreach (Variable x in callCmd.Proc.InParams)
             {
                 Variable y = new Formal(Token.NoToken, new TypedIdent(Token.NoToken, string.Format("og_{0}_{1}", count, x.Name), x.TypedIdent.Type), true);
                 inParams.Add(y);
                 map[x] = Expr.Ident(y);
             }
             foreach (Variable x in callCmd.Proc.OutParams)
             {
                 Variable y = new Formal(Token.NoToken, new TypedIdent(Token.NoToken, string.Format("og_{0}_{1}", count, x.Name), x.TypedIdent.Type), false);
                 outParams.Add(y);
                 map[x] = Expr.Ident(y);
             }
             Contract.Assume(callCmd.Proc.TypeParameters.Count == 0);
             Substitution subst = Substituter.SubstitutionFromHashtable(map);
             foreach (Requires req in callCmd.Proc.Requires)
             {
                 requiresSeq.Add(new Requires(req.tok, req.Free, Substituter.Apply(subst, req.Condition), null, req.Attributes));
             }
             foreach (Ensures ens in callCmd.Proc.Ensures)
             {
                 ensuresSeq.Add(new Ensures(ens.tok, ens.Free, Substituter.Apply(subst, ens.Condition), null, ens.Attributes));
             }
             count++;
         }
         proc = new Procedure(Token.NoToken, procName, new List<TypeVariable>(), inParams, outParams, requiresSeq, globalMods, ensuresSeq);
         asyncAndParallelCallDesugarings[procName] = proc;
     }
     CallCmd dummyCallCmd = new CallCmd(parCallCmd.tok, proc.Name, ins, outs, parCallCmd.Attributes);
     dummyCallCmd.Proc = proc;
     newCmds.Add(dummyCallCmd);
 }
Esempio n. 5
0
 public override Cmd VisitParCallCmd(ParCallCmd node)
 {
     HashSet<Variable> parallelCallInvars = new HashSet<Variable>();
     foreach (CallCmd callCmd in node.CallCmds)
     {
         for (int i = 0; i < callCmd.Proc.InParams.Count; i++)
         {
             Variable formal = callCmd.Proc.InParams[i];
             string domainName = FindDomainName(formal);
             if (domainName == null) continue;
             IdentifierExpr actual = callCmd.Ins[i] as IdentifierExpr;
             if (parallelCallInvars.Contains(actual.Decl))
             {
                 Error(node, string.Format("Linear variable {0} can occur only once as an input parameter of a parallel call", actual.Decl.Name));
             }
             else
             {
                 parallelCallInvars.Add(actual.Decl);
             }
         }
     }
     return base.VisitParCallCmd(node);
 }
Esempio n. 6
0
 public void AddAvailableVars(ParCallCmd parCallCmd, HashSet<Variable> start)
 {
     foreach (CallCmd callCmd in parCallCmd.CallCmds)
     {
         AddAvailableVars(callCmd, start);
     }
 }
Esempio n. 7
0
 public override Cmd VisitParCallCmd(ParCallCmd node)
 {
     Contract.Ensures(Contract.Result<Cmd>() == node);
     for (int i = 0; i < node.CallCmds.Count; i++)
     {
         if (node.CallCmds[i] != null)
             this.VisitCallCmd(node.CallCmds[i]);
     }
     return node;
 }
Esempio n. 8
0
 public virtual Cmd VisitParCallCmd(ParCallCmd node)
 {
     Contract.Requires(node != null);
     Contract.Ensures(Contract.Result<Cmd>() != null);
     for (int i = 0; i < node.CallCmds.Count; i++)
     {
         if (node.CallCmds[i] != null)
             node.CallCmds[i] = (CallCmd)this.VisitCallCmd(node.CallCmds[i]);
     }
     return node;
 }
Esempio n. 9
0
 public override Cmd VisitParCallCmd(ParCallCmd node)
 {
     int enclosingProcLayerNum = procToActionInfo[enclosingImpl.Proc].createdAtLayerNum;
     bool isLeftMover = true;
     bool isRightMover = true;
     int maxCalleeLayerNum = 0;
     int atomicActionCalleeLayerNum = 0;
     int numAtomicActions = 0;
     foreach (CallCmd iter in node.CallCmds)
     {
         ActionInfo actionInfo = procToActionInfo[iter.Proc];
         isLeftMover = isLeftMover && actionInfo.IsLeftMover;
         isRightMover = isRightMover && actionInfo.IsRightMover;
         if (actionInfo.createdAtLayerNum > maxCalleeLayerNum)
         {
             maxCalleeLayerNum = actionInfo.createdAtLayerNum;
         }
         if (actionInfo is AtomicActionInfo)
         {
             numAtomicActions++;
             if (atomicActionCalleeLayerNum == 0)
             {
                 atomicActionCalleeLayerNum = actionInfo.createdAtLayerNum;
             }
             else if (atomicActionCalleeLayerNum != actionInfo.createdAtLayerNum)
             {
                 Error(node, "All atomic actions must be introduced at the same layer");
             }
         }
     }
     if (numAtomicActions > 1 && !isLeftMover && !isRightMover)
     {
         Error(node, "The atomic actions in the parallel call must be all right movers or all left movers");
     }
     if (0 < atomicActionCalleeLayerNum && atomicActionCalleeLayerNum < maxCalleeLayerNum)
     {
         Error(node, "Atomic actions must be introduced at the highest layer");
     }
     return base.VisitParCallCmd(node);
 }
Esempio n. 10
0
 public override Cmd VisitParCallCmd(ParCallCmd node)
 {
     civlTypeChecker.Error(node, "Atomic procedures cannot make parallel calls");
     return node;
 }
Esempio n. 11
0
	void ParCallCmd(out Cmd d) {
		Contract.Ensures(Contract.ValueAtReturn(out d) != null); 
		IToken x; 
		QKeyValue kv = null;
		Cmd c = null;
		List<CallCmd> callCmds = new List<CallCmd>();
		
		Expect(54);
		x = t; 
		while (la.kind == 28) {
			Attribute(ref kv);
		}
		CallParams(false, false, kv, x, out c);
		callCmds.Add((CallCmd)c); 
		while (la.kind == 55) {
			Get();
			CallParams(false, false, kv, x, out c);
			callCmds.Add((CallCmd)c); 
		}
		Expect(9);
		d = new ParCallCmd(x, callCmds, kv); 
	}
Esempio n. 12
0
 public override Cmd VisitParCallCmd(ParCallCmd node)
 {
     //Contract.Requires(callCmd != null);
     Contract.Ensures(Contract.Result<Cmd>() != null);
     Cmd ret = base.VisitParCallCmd(node);
     if (!yieldingProcs.Contains(enclosingProc))
     {
         yieldingProcs.Add(enclosingProc);
         moreProcessingRequired = true;
     }
     foreach (CallCmd callCmd in node.CallCmds)
     {
         if (!yieldingProcs.Contains(callCmd.Proc))
         {
             yieldingProcs.Add(callCmd.Proc);
             moreProcessingRequired = true;
         }
     }
     return ret;
 }
Esempio n. 13
0
        public override Cmd VisitParCallCmd(ParCallCmd node)
        {
            int maxCalleePhaseNum = 0;
            foreach (CallCmd iter in node.CallCmds)
            {
                int calleePhaseNum = FindPhaseNumber(iter.Proc);
                if (calleePhaseNum > maxCalleePhaseNum)
                    maxCalleePhaseNum = calleePhaseNum;
            }

            if (enclosingProcPhaseNum > maxCalleePhaseNum)
            {
                bool isLeftMover = true;
                bool isRightMover = true;
                foreach (CallCmd iter in node.CallCmds)
                {
                    ActionInfo actionInfo = procToActionInfo[iter.Proc];
                    isLeftMover = isLeftMover && actionInfo.IsLeftMover;
                    isRightMover = isRightMover && actionInfo.IsRightMover;
                    actionInfo.callerPhaseNums.Add(enclosingProcPhaseNum);
                }
                if (!isLeftMover && !isRightMover && node.CallCmds.Count > 1)
                {
                    Error(node, "The procedures in the parallel call must be all right mover or all left mover");
                }
            }
            return node;
        }