/*
 * 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 targets.mips;

import common.Block;
import common.Code;
import java.util.LinkedHashMap;
import API.MiddlewareInterface;

/**
 *
 * @author EUGENIO CARVALHO
 */
public class MipsCopyDepsMiddleware implements MiddlewareInterface {

    protected Code tac;

    public MipsCopyDepsMiddleware() {
    }

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

}
