/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package target.mips;

import IntermediaryCode.Block;
import IntermediaryCode.Code;
import IntermediaryCode.CodeProcessing;
import java.util.LinkedHashMap;

/**
 *
 * @author EUGENIO CARVALHO
 */
class CopyDeps implements CodeProcessing {

    private Code tac;

    public CopyDeps() {
    }

    CopyDeps(Code tac) {
        this.tac = tac;
    }

    @Override
    public void Exec(Code c, LinkedHashMap<String, CodeProcessing> cp) throws Exception {
        Block currentBlock = c.Block(),
                tacBlock = tac.getBlocks().get(currentBlock.getName());
//        System.out.println("EXEC COPY DEPS:" + currentBlock.getName() + "\n" + tacBlock.GetDependences());
        for (String dep : tacBlock.GetDependences()) {
            currentBlock.AddDependence(dep);
        }
    }

}
