<commit_before>/*
 * Copyright 2016 <NAME> <<EMAIL>>
 * See COPYING for terms of redistribution.
 */

#ifndef JIVE_RVSDG_STRUCTURAL_NODE_H
#define JIVE_RVSDG_STRUCTURAL_NODE_H

#include <jive/rvsdg/node.h>
#include <jive/rvsdg/region.h>

namespace jive {

/* structural node */

class structural_input;
class structural_op;
class structural_output;

class structural_node : public node {
public:
	virtual
	~structural_node();

	structural_node(
		const jive::structural_op & op,
		jive::region * region,
		size_t nsubregions);

	inline size_t
	nsubregions() const noexcept
	{
		return subregions_.size();
	}

	inline jive::region *
	subregion(size_t index) const noexcept
	{
		JIVE_DEBUG_ASSERT(index < nsubregions());
		return subregions_[index].get();
	}

	inline jive::structural_input *
	input(size_t index) const noexcept;

	inline jive::structural_output *
	output(size_t index) const noexcept;

	jive::structural_input *
	add_input(const jive::port & port, jive::output * origin);

	jive::structural_output *
	add_output(const jive::port & port);

	inline void
	remove_input(size_t index)
	{
		node::remove_input(index);
	}

	inline void
	remove_output(size_t index)
	{
		node::remove_output(index);
	}

	virtual jive::structural_node *
	copy(jive::region * region, const std::vector<jive::output*> & operands) const override;

	virtual jive::structural_node *
	copy(jive::region * region, jive::substitution_map & smap) const override;

private:
	std::vector<std::unique_ptr<jive::region>> subregions_;
};

/* structural input class */

typedef jive::detail::intrusive_list<
	jive::argument,
	jive::argument::structural_input_accessor<commit_msg>rvsdg: add is_structural_node function<commit_after>/*
 * Copyright 2016 <NAME> <<EMAIL>>
 * See COPYING for terms of redistribution.
 */

#ifndef JIVE_RVSDG_STRUCTURAL_NODE_H
#define JIVE_RVSDG_STRUCTURAL_NODE_H

#include <jive/rvsdg/node.h>
#include <jive/rvsdg/region.h>

namespace jive {

/* structural node */

class structural_input;
class structural_op;
class structural_output;

class structural_node : public node {
public:
	virtual
	~structural_node();

	structural_node(
		const jive::structural_op & op,
		jive::region * region,
		size_t nsubregions);

	inline size_t
	nsubregions() const noexcept
	{
		return subregions_.size();
	}

	inline jive::region *
	subregion(size_t index) const noexcept
	{
		JIVE_DEBUG_ASSERT(index < nsubregions());
		return subregions_[index].get();
	}

	inline jive::structural_input *
	input(size_t index) const noexcept;

	inline jive::structural_output *
	output(size_t index) const noexcept;

	jive::structural_input *
	add_input(const jive::port & port, jive::output * origin);

	jive::structural_output *
	add_output(const jive::port & port);

	inline void
	remove_input(size_t index)
	{
		node::remove_input(index);
	}

	inline void
	remove_output(size_t index)
	{
		node::remove_output(index);
	}

	virtual jive::structural_node *
	copy(jive::region * region, const std::vector<jive::output*> & operands) const override;

	virtual jive::structural_node *
	copy(jive::region * region, jive::substitution_map & smap) const override;

private:
	std::vector<std::unique_ptr<jive::region>> subregions_;
};

static inline bool
is_structural_node(const jive::node * node) noexcept
{
	return dynamic_cast<const jive::structural_node*>(node) != nullptr;
}

/* structural input class */

typedef jive::detail::intrusive_list<
	jive::argument,
	jive::argument::structural_input_accessor
{'fraction_non_alphanumeric': 0.11784995688416211, 'fraction_numerical': 0.0022995113538373095, 'mean_word_length': 5.863905325443787, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1769305', 'n_tokens_mistral': 1284, 'n_tokens_neox': 1196, 'n_words': 253}