Example #1
0
        private void Analyse(Implementation impl, BigBlock bb)
        {
            Analyse(impl, bb.simpleCmds);

            if (bb.ec is WhileCmd)
            {
                WhileCmd wc = bb.ec as WhileCmd;

                ExprMayAffectControlFlow(impl.Name, wc.Guard);

                Analyse(impl, wc.Body);
            }
            else if (bb.ec is IfCmd)
            {
                IfCmd ifCmd = bb.ec as IfCmd;

                ExprMayAffectControlFlow(impl.Name, ifCmd.Guard);

                Analyse(impl, ifCmd.thn);
                if (ifCmd.elseBlock != null)
                {
                    Analyse(impl, ifCmd.elseBlock);
                }
                Debug.Assert(ifCmd.elseIf == null);
            }
        }
Example #2
0
 public void setBigBlocks(int bigTileIndex, BigBlock[] bigBlockIndexes)
 {
     for (int v = 0; v < bigBlockIndexes.Length; v++)
     {
        var b = bigBlockIndexes[v];
        int temp = b.indexes[1];
        b.indexes[1] = b.indexes[2];
        b.indexes[2] = temp;
     }
     Utils.setBigBlocksCapcomDefault(bigTileIndex, bigBlockIndexes);
 }
Example #3
0
        /////////////////////////////////////////////////////////////////////////////////////
        private BasicBlock addBigBlock(BigBlock bb, BasicBlock next)
        {
            var current = cfg.addNode(bb.LabelName);

//            System.Console.Out.WriteLine("Adding block: \"" + basicBlock.LabelName + "\"");

            addStatementsToBasicBlock(current, bb.simpleCmds);

            setControlStatement(current, bb, next);
            Debug.Assert(current.getControlStatement() != null);
            return(current);
        }
Example #4
0
    public void ShowChunk()
    {
        BlockServiceProvider provider = BlockServiceProvider.instance;

        for (int x = 0; x < m_Size; x++)
        {
            for (int y = 0; y < m_Size; y++)
            {
                BigBlock block = provider.GetBlockFromPool();
                block.EnableBlock(m_Data[x, y]);
                m_CachedBlocks.Push(block);
            }
        }
    }
Example #5
0
 /////////////////////////////////////////////////////////////////////////////////////
 private void setControlStatement(BasicBlock current, BigBlock bb, BasicBlock next)
 {
     Debug.Assert(bb.tc == null || bb.ec == null);
     if (bb.tc != null)
     {
         setControlStatement(current, bb.tc, next);
     }
     else if (bb.ec != null)
     {
         setControlStatement(current, bb.ec, next);
     }
     else
     {
         current.setControlStatement(new UnconditionalBranch(current, next));
     }
     Debug.Assert(current.getControlStatement() != null);
 }
Example #6
0
    public IEnumerator GenerateGroundLevel()
    {
        GenericBlockData dirt  = BlockServiceProvider.instance.GetBlock(2);
        GenericBlockData grass = BlockServiceProvider.instance.GetBlock(4);

        for (int x = 0; x < m_Size; x++)
        {
            for (int y = 0; y < m_Size; y++)
            {
                if (y < 10)
                {
                    Vector3  position = transform.position + new Vector3(x, y) * 1.5f;
                    BigBlock block    = Instantiate(m_Prefab, position, Quaternion.identity).GetComponent <BigBlock>();
                    if (y > 5)
                    {
                        if (y < 9)
                        {
                            //Dirt
                            block.Initialize(dirt);
                        }
                        else
                        {
                            //Grass
                            block.Initialize(grass);
                        }
                    }
                    block.UpdateBlock();
                    block.transform.parent = this.transform;

                    //m_Data[x, y] = block.DisableBlock(); ;
                }
            }
        }
        m_Done = true;
        yield return(new WaitForEndOfFrame());
    }
 public void setBigBlocksDt2(int bigTileIndex, BigBlock[] bigBlocks)
 {
   int[] addrPointers = getBigBlocksPtrsForLevel(bigTileIndex);
   int blocksCount = getBigBlocksCountForLevel(bigTileIndex);
   var data = Utils.linearizeBigBlocks(bigBlocks);
   Utils.writeDataToUnalignedArrays(data, Globals.romdata, addrPointers[0], addrPointers[1], addrPointers[2], addrPointers[3], blocksCount); 
 }
 private void transposeBigBlocks(BigBlock[] bblocks)
 {
     for (int i = 0; i < bblocks.Length; i++)
     {
     var bb = bblocks[i];
     var newIndexes = new int[] {
       bb.indexes[0], bb.indexes[4], bb.indexes[1], bb.indexes[5],
       bb.indexes[2], bb.indexes[6], bb.indexes[3], bb.indexes[7]
     };
     bb.indexes = newIndexes;
     }
 }
Example #9
0
        public Image[] makeBigBlocks(int videoNo, int bigBlockNo, BigBlock[] bigBlockIndexes, int palleteNo, MapViewType smallObjectsViewType = MapViewType.Tiles,
            float smallBlockScaleFactor = 2.0f, float curButtonScale = 2, MapViewType curViewType = MapViewType.Tiles, bool showAxis = false)
        {
            int blockCount = ConfigScript.getBigBlocksCount();
            var bigBlocks = new Image[blockCount];

            byte blockId = (byte)bigBlockNo;
            byte backId = (byte)videoNo;
            byte palId = (byte)palleteNo;

            var im = makeObjectsStrip(backId, blockId, palId, smallBlockScaleFactor, smallObjectsViewType);
            var smallBlocks = new System.Windows.Forms.ImageList();
            smallBlocks.ImageSize = new Size((int)(16 * smallBlockScaleFactor), (int)(16 * smallBlockScaleFactor));
            smallBlocks.Images.AddStrip(im);
            Image[] smallBlocksPack = smallBlocks.Images.Cast<Image>().ToArray();

            //tt version hardcode
            Image[][] smallBlocksAll = null;
            if (GameType.TT == Globals.getGameType())
            {
                smallBlocksAll = new Image[4][];
                for (int i = 0; i < 4; i++)
                {
                    var il = new ImageList();
                    il.ImageSize = new System.Drawing.Size((int)(16 * smallBlockScaleFactor), (int)(16 * smallBlockScaleFactor));
                    il.Images.AddStrip(makeObjectsStrip((byte)backId, (byte)blockId, (byte)palId, smallBlockScaleFactor, smallObjectsViewType, i));
                    smallBlocksAll[i] = il.Images.Cast<Image>().ToArray();
                }
            }
            else
            {
                smallBlocksAll = new Image[1][];
                smallBlocksAll[0] = smallBlocksPack;
            }

            for (int btileId = 0; btileId < blockCount; btileId++)
            {
                Image b;
                if (ConfigScript.isBuildScreenFromSmallBlocks())
                {
                    var sb = smallBlocks.Images[btileId];
                    b = Utils.ResizeBitmap(sb, (int)(sb.Width * curButtonScale), (int)(sb.Height * curButtonScale));
                }
                else
                {
                    b = makeBigBlock(btileId, bigBlockIndexes, smallBlocksAll);
                }
                if (curViewType == MapViewType.ObjNumbers)
                    b = VideoHelper.addObjNumber(b, btileId);
                if (showAxis)
                    b = VideoHelper.addAxisRectangle(b);
                bigBlocks[btileId] = b;
            }
            return bigBlocks;
        }
Example #10
0
    public IEnumerator PopulateCaves(byte[,] caveData)
    {
        byte[,] caves = caveData;
        Stack <Vector2> m_cachedCave = new Stack <Vector2>();

        for (int x = 0; x < m_Size; x++)
        {
            for (int y = 0; y < m_Size; y++)
            {
                if (caves[x, y] > 15)
                {
                    if (x - 1 > 0 && x + 1 < m_Size)
                    {
                        if (y - 1 > 0)
                        {
                            if (caves[x - 1, y] > 15 && caves[x + 1, y] > 15)
                            {
                                //Ground Check
                                if (caves[x - 1, y - 1] < 15 && caves[x, y - 1] < 15 && caves[x + 1, y - 1] < 15)
                                {
                                    for (int heightCheck = 0; heightCheck < 4;)
                                    {
                                        if (caves[x - 1, y + heightCheck] > 15 && caves[x, y + heightCheck] > 15 && caves[x + 1, y + heightCheck] > 15)
                                        {
                                            heightCheck++;
                                        }
                                        else
                                        {
                                            break;
                                        }
                                        yield return(new WaitForEndOfFrame());

                                        if (y + heightCheck < m_Size)
                                        {
                                            Debug.Log(heightCheck);
                                            if (heightCheck == 4)
                                            {
                                                //GenerateStore (Test)

                                                int RandomStore = Random.Range(0, 2);

                                                if (RandomStore > 0)
                                                {
                                                    GenericBlockData dirt = BlockServiceProvider.instance.GetBlock(2);

                                                    Vector3 leftPosition   = transform.position + new Vector3(x - 1, y) * 1.5f;
                                                    Vector3 centerPosition = transform.position + new Vector3(x, y) * 1.5f;
                                                    Vector3 rightPosition  = transform.position + new Vector3(x + 1, y) * 1.5f;

                                                    BigBlock leftBlock   = Instantiate(m_Prefab, leftPosition, Quaternion.identity).GetComponent <BigBlock>();
                                                    BigBlock centerBlock = Instantiate(m_Prefab, centerPosition, Quaternion.identity).GetComponent <BigBlock>();
                                                    BigBlock rightBlock  = Instantiate(m_Prefab, rightPosition, Quaternion.identity).GetComponent <BigBlock>();

                                                    leftBlock.Initialize(dirt);
                                                    centerBlock.Initialize(dirt);
                                                    rightBlock.Initialize(dirt);

                                                    leftBlock.UpdateBlock();
                                                    centerBlock.UpdateBlock();
                                                    rightBlock.UpdateBlock();

                                                    if (RandomStore == 1)
                                                    {
                                                        Vector3 storePosition = transform.position + new Vector3(x, y + 1) * 1.5f;
                                                        Instantiate(m_Shop, storePosition, Quaternion.identity);
                                                    }

                                                    yield return(new WaitForEndOfFrame());
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
Example #11
0
    public IEnumerator GenerateChunk()
    {
        Stack <GenericBlockData> blocks = m_Pool.GetObjectData();

        m_CaveGenerator.ResetGeneration();
        yield return(StartCoroutine(m_CaveGenerator.CaveCourotine()));

        while (!m_CaveGenerator.done)
        {
            yield return(new WaitForEndOfFrame());
        }
        byte[,] caves = m_CaveGenerator.ReturnData();

        Debug.Log("Caves Done");

        //byte[,] dirt = m_CaveGenerator.GenerateCave();

        m_CaveGenerator.SetMaxOres(40);
        yield return(StartCoroutine(m_CaveGenerator.OresCourotine()));

        while (!m_CaveGenerator.done)
        {
            yield return(new WaitForEndOfFrame());
        }
        byte[,] diamons = m_CaveGenerator.ReturnData();

        Debug.Log("Diamonds Done");

        m_CaveGenerator.SetMaxOres(85);
        yield return(StartCoroutine(m_CaveGenerator.OresCourotine()));

        while (!m_CaveGenerator.done)
        {
            yield return(new WaitForEndOfFrame());
        }
        byte[,] emeralds = m_CaveGenerator.ReturnData();

        Debug.Log("Emeralds Done");

        m_CaveGenerator.SetMaxOres(50);
        yield return(StartCoroutine(m_CaveGenerator.OresCourotine()));

        while (!m_CaveGenerator.done)
        {
            yield return(new WaitForEndOfFrame());
        }
        byte[,] gold = m_CaveGenerator.ReturnData();

        Debug.Log("Gold Done");

        m_CaveGenerator.SetMaxOres(110);
        yield return(StartCoroutine(m_CaveGenerator.OresCourotine()));

        while (!m_CaveGenerator.done)
        {
            yield return(new WaitForEndOfFrame());
        }
        byte[,] iron = m_CaveGenerator.ReturnData();

        Debug.Log("Iron Done");

        m_CaveGenerator.SetMaxOres(75);
        yield return(StartCoroutine(m_CaveGenerator.OresCourotine()));

        while (!m_CaveGenerator.done)
        {
            yield return(new WaitForEndOfFrame());
        }
        byte[,] ruby = m_CaveGenerator.ReturnData();

        Debug.Log("Ruby Done");

        m_CaveGenerator.SetMaxOres(75);
        yield return(StartCoroutine(m_CaveGenerator.OresCourotine()));

        while (!m_CaveGenerator.done)
        {
            yield return(new WaitForEndOfFrame());
        }
        byte[,] sapphire = m_CaveGenerator.ReturnData();

        Debug.Log("Sapphire Done");


        int Xmax = caves.GetLength(0);
        int Ymax = caves.GetLength(1);

        for (int x = 0; x < m_Size; x++)
        {
            for (int y = 0; y < m_Size; y++)
            {
                if (caves[x, y] < 16)
                {
                    Vector3  position = transform.position + new Vector3(x, y) * 1.5f;
                    BigBlock block    = Instantiate(m_Prefab, position, Quaternion.identity).GetComponent <BigBlock>();

                    //if (dirt[x, y]>16)
                    //{
                    //    block.Initialize(BlockServiceProvider.instance.GetBlock(1));
                    //}

                    BigBlock ore = null;

                    //SpawnOre
                    if (iron[x, y] > 15)
                    {
                        ore = Instantiate(m_Prefab, position, Quaternion.identity).GetComponent <BigBlock>();
                        ore.Initialize(BlockServiceProvider.instance.GetOre(4));
                        ore.gameObject.name = "Iron";
                    }
                    else if (emeralds[x, y] > 15)
                    {
                        ore = Instantiate(m_Prefab, position, Quaternion.identity).GetComponent <BigBlock>();
                        ore.Initialize(BlockServiceProvider.instance.GetOre(2));
                        ore.gameObject.name = "Emeralds";
                    }
                    else if (ruby[x, y] > 15)
                    {
                        ore = Instantiate(m_Prefab, position, Quaternion.identity).GetComponent <BigBlock>();
                        ore.Initialize(BlockServiceProvider.instance.GetOre(5));
                        ore.gameObject.name = "Ruby";
                    }
                    else if (sapphire[x, y] > 15)
                    {
                        ore = Instantiate(m_Prefab, position, Quaternion.identity).GetComponent <BigBlock>();
                        ore.Initialize(BlockServiceProvider.instance.GetOre(6));
                        ore.gameObject.name = "Sapphire";
                    }
                    else if (gold[x, y] > 15)
                    {
                        ore = Instantiate(m_Prefab, position, Quaternion.identity).GetComponent <BigBlock>();
                        ore.Initialize(BlockServiceProvider.instance.GetOre(3));
                        ore.gameObject.name = "Gold";
                    }

                    else if (diamons[x, y] > 15)
                    {
                        ore = Instantiate(m_Prefab, position, Quaternion.identity).GetComponent <BigBlock>();
                        ore.Initialize(BlockServiceProvider.instance.GetOre(1));
                        ore.gameObject.name = "Diamond";
                    }

                    //LeftTop
                    if (x - 1 > 0 && y + 1 < Ymax)
                    {
                        if (caves[x - 1, y + 1] > 16)
                        {
                            block.SetBlockState(0, BlockState.Mined);
                            if (ore != null)
                            {
                                ore.SetBlockState(0, BlockState.Mined);
                            }
                        }
                    }
                    //Left
                    if (x - 1 > 0)
                    {
                        if (caves[x - 1, y] > 16)
                        {
                            block.SetBlockState(0, BlockState.Mined);
                            block.SetBlockState(2, BlockState.Mined);
                            if (ore != null)
                            {
                                ore.SetBlockState(0, BlockState.Mined);
                                ore.SetBlockState(2, BlockState.Mined);
                            }
                        }
                    }
                    //LeftBottom
                    if (x - 1 > 0 && y - 1 > 0)
                    {
                        if (caves[x - 1, y - 1] > 16)
                        {
                            block.SetBlockState(2, BlockState.Mined);
                            if (ore != null)
                            {
                                ore.SetBlockState(2, BlockState.Mined);
                            }
                        }
                    }
                    //Top
                    if (y + 1 < Ymax)
                    {
                        if (caves[x, y + 1] > 16)
                        {
                            block.SetBlockState(0, BlockState.Mined);
                            block.SetBlockState(1, BlockState.Mined);
                            if (ore != null)
                            {
                                ore.SetBlockState(0, BlockState.Mined);
                                ore.SetBlockState(1, BlockState.Mined);
                            }
                        }
                    }
                    //Bottom
                    if (y - 1 > 0)
                    {
                        if (caves[x, y - 1] > 16)
                        {
                            block.SetBlockState(2, BlockState.Mined);
                            block.SetBlockState(3, BlockState.Mined);
                            if (ore != null)
                            {
                                ore.SetBlockState(2, BlockState.Mined);
                                ore.SetBlockState(3, BlockState.Mined);
                            }
                        }
                    }
                    //RightTop
                    if (x + 1 < Xmax && y + 1 < Ymax)
                    {
                        if (caves[x + 1, y + 1] > 16)
                        {
                            block.SetBlockState(1, BlockState.Mined);
                            if (ore != null)
                            {
                                ore.SetBlockState(1, BlockState.Mined);
                            }
                        }
                    }
                    //Right
                    if (x + 1 < Xmax)
                    {
                        if (caves[x + 1, y] > 16)
                        {
                            block.SetBlockState(1, BlockState.Mined);
                            block.SetBlockState(3, BlockState.Mined);
                            if (ore != null)
                            {
                                ore.SetBlockState(1, BlockState.Mined);
                                ore.SetBlockState(3, BlockState.Mined);
                            }
                        }
                    }
                    //RightBottom
                    if (x + 1 < Xmax && y - 1 > 0)
                    {
                        if (caves[x + 1, y - 1] > 16)
                        {
                            block.SetBlockState(3, BlockState.Mined);
                            if (ore != null)
                            {
                                ore.SetBlockState(3, BlockState.Mined);
                            }
                        }
                    }

                    block.UpdateBlock();
                    block.transform.parent = this.transform;
                    if (ore != null)
                    {
                        ore.UpdateBlock();
                        ore.transform.parent = this.transform;
                        ore.gameObject.GetComponent <SpriteRenderer>().sortingOrder = 1;
                    }

                    //yield return new WaitForEndOfFrame();
                }
            }
        }
        m_Done = true;
        yield return(StartCoroutine(PopulateCaves(caves)));
    }
 public void setBigBlocksJB(int bigTileIndex, BigBlock[] bigBlockIndexes)
 {
   var data = Utils.linearizeBigBlocks(bigBlockIndexes);
   var bigBlockRec = BigBlocksAddrs[bigTileIndex];
   var secondPart  = new byte[bigBlockRec.loCount*4];
   Array.Copy(data, 128*4, secondPart, 0, bigBlockRec.loCount*4);
   Utils.writeDataToAlignedArrays(data      , Globals.romdata, bigBlockRec.hiAddr, bigBlockRec.hiCount);
   Utils.writeDataToAlignedArrays(secondPart, Globals.romdata, bigBlockRec.loAddr, bigBlockRec.loCount);
 }
 public static void setBigBlocks(int bigTileIndex, BigBlock[] bigBlockIndexes)
 {
     transposeBigBlocks(bigBlockIndexes);
     var data = Utils.linearizeBigBlocks(bigBlockIndexes);
     Utils.writeLinearBigBlockData(0, bigTileIndex, data);
 }
 private static void transposeBigBlocks(BigBlock[] bblocks)
 {
     for (int i = 0; i < bblocks.Length; i++)
     {
     var bb = bblocks[i];
     xchg(bb.indexes, 1, 4);
     xchg(bb.indexes, 2, 8);
     xchg(bb.indexes, 3, 12);
     xchg(bb.indexes, 6, 9);
     xchg(bb.indexes, 7, 13);
     xchg(bb.indexes, 11, 14);
     }
 }
Example #15
0
 public void AddToPool(BigBlock block)
 {
     block.transform.position = Vector2.one * 99f;
     m_BlockPool.Push(block);
 }
Example #16
0
 public Bitmap makeBigBlock(int i, BigBlock[] bigBlocks, Image[][] smallBlockss)
 {
     Bitmap b;
     switch (Globals.getGameType())
     {
         case GameType.TT:
             b = (smallBlockss.Length > 1) ? makeBigBlockTT(i, bigBlocks, smallBlockss) : makeBigBlockCapcom(i, bigBlocks, smallBlockss);
             break;
         default:
             b = makeBigBlockCapcom(i, bigBlocks, smallBlockss);
             break;
     }
     return b;
 }
Example #17
0
 public Bitmap makeBigBlockCapcom(int i, BigBlock[] bigBlocks, Image[][] smallBlockss)
 {
     var smallBlocks = smallBlockss[0];
     int bWidth = smallBlocks[0].Width;
     int bHeight = smallBlocks[0].Height;
     var bb = bigBlocks[i];
     var b = new Bitmap(bWidth*bb.width, bHeight*bb.height);
     using (Graphics g = Graphics.FromImage(b))
     {
         for (int h = 0; h < bb.height; h++)
         {
             for (int w = 0; w < bb.width; w++)
             {
                 int sbX = w * bWidth;
                 int sbY = h * bHeight;
                 int idx = h * bb.width + w;
                 var r = new Rectangle(sbX, sbY, bWidth, bHeight);
                 g.DrawImage(smallBlocks[bb.indexes[idx]], r);
             }
         }
     }
     return b;
 }
 public static void setBigBlocksTT(int bigTileIndex, BigBlock[] bigBlockIndexes)
 {
     var bigBlocksAddr = ConfigScript.getBigTilesAddr(0, bigTileIndex);
     var data = Utils.linearizeBigBlocks(bigBlockIndexes);
     Utils.writeDataToAlignedArrays(data, Globals.romdata, bigBlocksAddr, ConfigScript.getBigBlocksCount(0));
 }
Example #19
0
 public Bitmap makeBigBlockTT(int i, BigBlock[] bigBlocks, Image[][] smallBlocksAll)
 {
     //calc size
     var smallBlocks = smallBlocksAll[0];
     int bWidth = smallBlocks[0].Width;
     int bHeight = smallBlocks[0].Height;
     var bb = bigBlocks[i];
     var b = new Bitmap(bWidth * bb.width, bHeight * bb.height);
     using (Graphics g = Graphics.FromImage(b))
     {
         int scb = getTTSmallBlocksColorByte(i);
         g.DrawImage(smallBlocksAll[scb >> 0 & 0x3][bigBlocks[i].indexes[0]], new Rectangle(0, 0, bWidth, bHeight));
         g.DrawImage(smallBlocksAll[scb >> 2 & 0x3][bigBlocks[i].indexes[1]], new Rectangle(bWidth, 0, bWidth, bHeight));
         g.DrawImage(smallBlocksAll[scb >> 4 & 0x3][bigBlocks[i].indexes[2]], new Rectangle(0, bHeight, bWidth, bHeight));
         g.DrawImage(smallBlocksAll[scb >> 6 & 0x3][bigBlocks[i].indexes[3]], new Rectangle(bWidth, bHeight, bWidth, bHeight));
     }
     return b;
 }
Example #20
0
        public static Duple <Procedure, Implementation> EqualityReduction(Implementation i1, Implementation i2, ParamMap argMap, HashSet <Variable> ignoreSet, out List <Variable> outputVarsForVFTask)
        {
            //map ins1
            //map outs1
            //save globals (1)
            //...
            //call
            //...
            //save outs
            //save globals (2)
            //restore globals (1)
            //...
            //call
            //...
            //compare

            Procedure
                d1 = i1.Proc,
                d2 = i2.Proc;

            var globals = new List <Variable>();

            foreach (IdentifierExpr ie in d1.Modifies)
            {
                globals.Add(ie.Decl);
            }
            foreach (IdentifierExpr ie in d2.Modifies)
            {
                if (!globals.Contains(ie.Decl))
                {
                    globals.Add(ie.Decl);
                }
            }

            /***** Produce mapped list of identifiers *****/

            string
                d1n = d1.Name,
                d2n = d2.Name;

            List <Variable>
            outs1     = FreshVariables(d1.OutParams, B.Factory.MakeLocal),
                outs2 = FreshVariables(d2.OutParams, B.Factory.MakeLocal),
                ins1  = FreshVariables(d1.InParams, (x, y) => B.Factory.MakeFormal(x, y, true)),
                ins2  = FreshVariables(d2.InParams, (x, y) => B.Factory.MakeFormal(x, y, true));

            /***** Compute correspondence between d1's ins/outs and d2's ins/outs *****/

            List <Variable>
            unionIns,
                unionOuts,
                newIns1,
                newOuts1,
                interIns,
                interOuts;

            MergeVariableSequencesByMap(ins1, ins2, argMap, out newIns1, out unionIns, out interIns);
            MergeVariableSequencesByMap(outs1, outs2, argMap, out newOuts1, out unionOuts, out interOuts);

            ins1  = newIns1;
            outs1 = newOuts1;

            /***** Map ignore set to the new variables *****/

            for (int i = 0; i < i2.OutParams.Count; i++)
            {
                if (ignoreSet.Contains(i2.OutParams[i]))
                {
                    Log.Out(Log.Warning, "Equality reduction ignoring variable: " + outs2[i].Name);
                    ignoreSet.Add(outs2[i]);
                }
            }

            /***** Emit instructions for saving and restoring *****/

            SaveBlock savedInitialGlobals = new SaveBlock(globals.Count);
            SaveBlock savedc1Globals      = new SaveBlock(globals.Count);
            SaveBlock savedOutputs        = new SaveBlock(interOuts.Count);

            var globalsArr = B.U.VariablesOfVariableSeq(globals);

            Cmd[]
            prec1Copy = savedInitialGlobals.EmitSave(globalsArr),
            postc1Copy    = savedc1Globals.EmitSave(globalsArr),
            postc1Restore = savedInitialGlobals.EmitRestore(globalsArr),
            prec2Copy     = savedOutputs.EmitSave(B.U.VariablesOfVariableSeq(interOuts));


            /***** Emit function calls *****/

            var c1Ins  = B.U.ExprSeqOfVariableSeq(ins1);
            var c1Outs = B.U.IdentifierExprSeqOfVariableSeq(outs1);
            var c2Ins  = B.U.ExprSeqOfVariableSeq(ins2);
            var c2Outs = B.U.IdentifierExprSeqOfVariableSeq(outs2);

            CallCmd
                c1 = new CallCmd(Token.NoToken, d1n, c1Ins, c1Outs),
                c2 = new CallCmd(Token.NoToken, d2n, c2Ins, c2Outs);

            /***** Emit comparison, outputVars *****/
            var outputVars     = new List <Duple <string, Variable> >();
            int numComparables = savedOutputs.Count + savedc1Globals.Count;

            //wait! if there aren't any comparable values, don't bother emitting a comparator
            if (numComparables == 0)
            {
                Log.Out(Log.Verifier, "No outputs: skipping (" + d1n + ", " + d2n + ")");
                outputVarsForVFTask = null;
                return(null);
            }

            if (Options.CheckOutputsForMaps)
            {
                foreach (Variable v in savedOutputs.Decls)
                {
                    if (v.TypedIdent.Type is MapType)
                    {
                        Log.Out(Log.MapEquivs, v.Name + " in " + i1.Name + " is a map comparable!");
                    }
                }
                foreach (Variable v in savedc1Globals.Decls)
                {
                    if (v.TypedIdent.Type is MapType || v.TypedIdent.Type is TypeSynonymAnnotation)
                    {
                        Log.Out(Log.MapEquivs, v.Name + " global is a map comparable!");
                    }
                }
            }

            StateBlock outputEqualityState = new StateBlock(numComparables, StateBlock.StateKind.FormalOut);

            Tuple <Expr, Variable>[] outputEqualityExprs = new Tuple <Expr, Variable> [numComparables];
            outputEqualityState.Initialize(Microsoft.Boogie.Type.Bool);

            IdentifierExpr[]
            comparisonPostc1Vars = savedc1Globals.Idents,
            comparisonPrec2Vars = savedOutputs.Idents;

            List <IdentifierExpr>
            comparisonOutIds      = B.U.IdentifierExprSeqOfVariableSeq(outs2),
                comparisonGlobals = B.U.IdentifierExprSeqOfVariableSeq(globals);

            for (int i = 0; i < savedOutputs.Count; i++)
            {
                outputEqualityExprs[i] = Tuple.Create(EmitEq(comparisonPrec2Vars[i], comparisonOutIds[i], ignoreSet), comparisonOutIds[i].Decl);
                outputVars.Add(new Duple <string, Variable>("Output_of_" + d1.Name + "_" + outs1[i].Name, savedOutputs.Decls[i]));
                outputVars.Add(new Duple <string, Variable>("Output_of_" + d2.Name + "_" + outs2[i].Name, outs2[i]));
            }
            for (int i = 0; i < savedc1Globals.Count; i++)
            {
                outputEqualityExprs[savedOutputs.Count + i] = Tuple.Create(EmitEq(comparisonPostc1Vars[i], comparisonGlobals[i], ignoreSet), comparisonGlobals[i].Decl);
                outputVars.Add(new Duple <string, Variable>("Output_of_" + d1.Name + "_" + globals[i].Name, savedc1Globals.Decls[i]));
                outputVars.Add(new Duple <string, Variable>("Output_of_" + d2.Name + "_" + globals[i].Name, globals[i]));
            }
            //new: we translate equalities as havoc lhs; lhs := lhs || x == x'; to enable diff counterexamples for each equality
            //havoc all lhs
            HavocCmd    hcmd = new HavocCmd(Token.NoToken, outputEqualityState.Idents.ToList());
            List <Expr> rhs  = new List <Expr>(outputEqualityExprs.Map(i => i.Item1));

            for (int i = 0; i < rhs.Count; ++i)
            {
                rhs[i] = Expr.Or(outputEqualityState.Idents[i], rhs[i]);
            }
            List <AssignLhs> lhs =
                new List <AssignLhs>(outputEqualityState.Idents.Map(x => new SimpleAssignLhs(Token.NoToken, x)));
            Cmd assgnCmd = new AssignCmd(Token.NoToken, lhs, rhs);

            /***** Save outputVars as globals (outputVarsForVFTask) *****/
            //note that this list is order dependent. later code will assume that variables are paired

            SaveBlock leftRightOutputs = new SaveBlock(outputVars.Count, StateBlock.StateKind.Global);

            leftRightOutputs.Initialize(outputVars.Map(x => new Duple <string, Microsoft.Boogie.Type>(x.fst, x.snd.TypedIdent.Type)));
            Cmd[] saveOutputsIntoGlobals = leftRightOutputs.EmitSave(outputVars.Map(x => x.snd).ToArray());
            outputVarsForVFTask = leftRightOutputs.Decls.ToList();

            /***** Compile procedure body ****/

            List <Cmd> body = new List <Cmd>();

            foreach (Cmd c in prec1Copy)
            {
                body.Add(c);
            }
            body.Add(c1);
            foreach (Cmd c in postc1Copy)
            {
                body.Add(c);
            }
            foreach (Cmd c in postc1Restore)
            {
                body.Add(c);
            }
            foreach (Cmd c in prec2Copy)
            {
                body.Add(c);
            }
            body.Add(c2);
            foreach (Cmd c in saveOutputsIntoGlobals)
            {
                body.Add(c);
            }
            body.Add(hcmd);
            body.Add(assgnCmd);

            //special hack to limit outvar to {:stmtTaintCollectorGlobalVar}
            if (Options.refinedStmtTaint)
            {
                Options.OutputVars.Clear();
                globals.Where(x => QKeyValue.FindBoolAttribute(x.Attributes, "stmtTaintCollectorGlobalVar")).Iter(x => Options.OutputVars.Add(x.ToString()));
            }

            List <Ensures> outputPostConditions = new List <Ensures>();

            if (Options.splitOutputEqualities)
            {
                outputPostConditions.AddRange(outputEqualityState.Idents.Map(y => new Ensures(false, y)));
                System.Diagnostics.Debug.Assert(outputEqualityState.Count == outputEqualityExprs.Length);
                for (int i = 0; i < outputPostConditions.Count; ++i)
                {
                    var name = outputEqualityExprs[i].Item2.Name;
                    //check if name matches with at least one of the outputVars patterns
                    if (Options.OutputVars.Count() > 0 && !Options.OutputVars.Any(x => name.Contains(x)))
                    {
                        outputPostConditions[i] = new Ensures(true, outputPostConditions[i].Condition);
                    }
                    outputPostConditions[i].Attributes =
                        new QKeyValue(Token.NoToken, "EqVar", new List <object>()
                    {
                        name
                    }, null);
                }
            }
            else if (!Options.EnumerateAllPaths)
            {
                outputPostConditions.Add(new Ensures(false, B.U.BigAnd(outputEqualityState.Idents)));
            }
            else //assert(false) causes all the paths to be enumerated
            {
                outputPostConditions.Add(new Ensures(false, Expr.False)); //to get exhaustive paths
            }
            var eqModifiesDupe = new List <IdentifierExpr>(d1.Modifies);

            eqModifiesDupe.AddRange(d2.Modifies);
            foreach (var v in leftRightOutputs.Decls)
            {
                eqModifiesDupe.Add(Expr.Ident(v));
            }

            //uniqueify eqModifies
            var eqModifiesUn   = new List <IdentifierExpr>();
            var eqModifiesVars = new HashSet <Variable>();
            var eqModifies     = new List <IdentifierExpr>();

            foreach (IdentifierExpr ie in eqModifiesDupe)
            {
                if (!eqModifiesVars.Contains(ie.Decl))
                {
                    eqModifies.Add(ie);
                }
                eqModifiesVars.Add(ie.Decl);
            }


            //var procName = "EQ_" + d1.Name + "__xx__" + d2.Name;
            var procName = mkEqProcName(d1.Name, d2.Name);

            Procedure eqProc =
                new Procedure(Token.NoToken, procName, B.C.empTypeVariableSeq, unionIns,
                              new List <Variable>(outputEqualityState.Decls),
                              B.C.empRequiresSeq, eqModifies, new List <Ensures>(outputPostConditions));

            BigBlock bl =
                new BigBlock(Token.NoToken, "AA_INSTR_EQ_BODY", body, null, B.C.dmyTransferCmd);
            List <BigBlock> bll = new List <BigBlock>();

            bll.Add(bl);

            List <Variable> locals = new List <Variable>();

            foreach (Variable v in savedOutputs.Decls)
            {
                locals.Add(v);
            }
            foreach (Variable v in savedc1Globals.Decls)
            {
                locals.Add(v);
            }
            foreach (Variable v in savedInitialGlobals.Decls)
            {
                locals.Add(v);
            }
            locals.AddRange(unionOuts);

            Implementation eqImp =
                new Implementation(Token.NoToken, procName, B.C.empTypeVariableSeq, unionIns,
                                   new List <Variable>(outputEqualityState.Decls),
                                   locals, new StmtList(bll, Token.NoToken));

            List <Declaration> l = new List <Declaration>();

            return(new Duple <Procedure, Implementation>(eqProc, eqImp));
        }