/**
 * (c) 2014-2016 Alexandro Sanchez Bach. All rights reserved.
 * Released under GPL v2 license. Read LICENSE for more details.
 */

#pragma once

#include "nucleus/common.h"
#include "nucleus/graphics/hir/hir.h"

#include <string>
#include <vector>

namespace gfx {
namespace hir {

// Forward declarations
class Function;
class Instruction;

class Block {
    Function& parent;

public:
    std::vector<Instruction*> variables;
    std::vector<Instruction*> instructions;

    // Constructor
    Block(Function& parent);
    Block(Function& parent, Literal id);
    ~Block();

    /**
     * Get the ID of this block generated by the starting Label instruction
     * @return  Block ID
     */
    Literal getId();

    /**
     * Get the parent function of this block
     * @return  Parent function
     */
    Function& getParent() const;

    /**
     * Save a human-readable version of this HIR block
     * @return  String containing the readable version of this HIR block
     */
    std::string dump();
};

}  // namespace hir
}  // namespace gfx
