コード例 #1
0
ファイル: Duplicator.cs プロジェクト: luckysunda/hice-dt
        public override Expr VisitCodeExpr(CodeExpr node)
        {
            //Contract.Requires(node != null);
            Contract.Ensures(Contract.Result <Expr>() != null);
            CodeExpr clone = (CodeExpr)base.VisitCodeExpr((CodeExpr)node.Clone());

            // Before returning, fix up the resolved goto targets
            Contract.Assert(node.Blocks.Count == clone.Blocks.Count);
            Dictionary <Block, Block> subst = new Dictionary <Block, Block>();

            for (int i = 0; i < node.Blocks.Count; i++)
            {
                subst.Add(node.Blocks[i], clone.Blocks[i]);
            }
            foreach (Block /*!*/ b in clone.Blocks)
            {
                Contract.Assert(b != null);
                GotoCmd g = b.TransferCmd as GotoCmd;
                if (g != null)
                {
                    List <Block> targets = new List <Block>();
                    foreach (Block t in cce.NonNull(g.labelTargets))
                    {
                        Block nt = subst[t];
                        targets.Add(nt);
                    }
                    g.labelTargets = targets;
                }
            }
            return(clone);
        }
コード例 #2
0
        public override Expr VisitCodeExpr(CodeExpr node)
        {
            var clone = (CodeExpr)node.Clone();

            clone.Blocks  = new List <Block>(node.Blocks);
            clone.LocVars = new List <Variable>(node.LocVars);

            clone = (CodeExpr)base.VisitCodeExpr(clone);


            // Before returning, fix up the resolved goto targets
            Dictionary <Block, Block> subst = new Dictionary <Block, Block>();

            for (int i = 0; i < node.Blocks.Count; i++)
            {
                subst.Add(node.Blocks[i], clone.Blocks[i]);
            }
            foreach (Block b in clone.Blocks)
            {
                GotoCmd g = b.TransferCmd as GotoCmd;
                if (g != null)
                {
                    List <Block> targets = new List <Block>();
                    foreach (Block t in g.labelTargets)
                    {
                        Block nt = subst[t];
                        targets.Add(nt);
                    }
                    g.labelTargets = targets;
                }
            }
            return(clone);
        }
コード例 #3
0
ファイル: Duplicator.cs プロジェクト: Chenguang-Zhu/ICE-C5
 public override Expr VisitCodeExpr(CodeExpr node) {
   //Contract.Requires(node != null);
   Contract.Ensures(Contract.Result<Expr>() != null);
   CodeExpr clone = (CodeExpr)base.VisitCodeExpr((CodeExpr)node.Clone());
   // Before returning, fix up the resolved goto targets
   Contract.Assert(node.Blocks.Count == clone.Blocks.Count);
   Dictionary<Block, Block> subst = new Dictionary<Block, Block>();
   for (int i = 0; i < node.Blocks.Count; i++) {
     subst.Add(node.Blocks[i], clone.Blocks[i]);
   }
   foreach (Block/*!*/ b in clone.Blocks) {
     Contract.Assert(b != null);
     GotoCmd g = b.TransferCmd as GotoCmd;
     if (g != null) {
       List<Block> targets = new List<Block>();
       foreach (Block t in cce.NonNull(g.labelTargets)) {
         Block nt = subst[t];
         targets.Add(nt);
       }
       g.labelTargets = targets;
     }
   }
   return clone;
 }