// Mike Maxim
// Basic Block

package edu.cmu.cs.l3.canon;

import edu.cmu.cs.l3.tree.*;

public class Block {

    public Block() {
	m_body = new IRStatementList();
    }

    public Block(IRLabel label) {
	m_label = label;
	m_body = new IRStatementList();
    }

    public Block(IRLabel label, IRStatementList body) {
	m_label = label; m_body = body;
    }

    public void setLabel(IRLabel l) {
	m_label = l;
    }

    public IRLabel getLabel() {
	return m_label;
    }

    public IRStatementList getBody() {
	return m_body;
    }

    public IRStatement getJump() {
	return m_body.getStatement(m_body.getSize()-1);
    }

    public void mark() {
	m_marked = true;
    }

    public void unmark() {
	m_marked = false;
    }

    public boolean isMarked() {
	return m_marked;
    }

    public String toString() {

	String str = m_label.toString() + "\n";
	int i;

	for (i = 0; i < m_body.getSize(); i++) {
	    str += m_body.getStatement(i).toString() + "\n";
	}

	return str;
    }

    private boolean m_marked=false;
    private IRLabel m_label;
    private IRStatementList m_body;
}
