/*
 * 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 analise;

import common.Instruction;
import java.util.ArrayList;

/**
 *
 * @author lucas
 */
public class No {

    public Instruction instruction;
    public ArrayList<No> deps = new ArrayList<>();
    public boolean root;
    public Integer index = 0;

    No(Instruction instruction, boolean root) {
        this.instruction = instruction;
        this.root = root;
    }

    @Override
    public String toString() {
        return Dump("");
    }

    protected String Dump(String space) {
        StringBuilder sb = new StringBuilder();
        sb.append("(")
                .append(instruction.Get("global.position"))
                .append(")[")
                .append(deps.size())
                .append("| ")
                .append(root)
                .append("]");

        if (instruction.eq("global.position", "168")) {
//           System.out.println("DUMP: " + instruction);
//            System.out.println("DUMP: " + deps.size());
        }

        deps.forEach((dep) -> {

            sb.append("\n")
                    .append(space)
                    .append(dep.Dump(space + "   "));
        });
        return sb.toString(); //To change body of generated methods, choose Tools | Templates.
    }
}
