<commit_before>/*
 * copyright: (c) RDO-Team, 2010
 * filename : rdo_array.cpp
 * author   :  
 * date     : 
 * bref     : 
 * indent   : 4T
 */

// ====================================================================== PCH
#include "rdo_lib/rdo_parser/pch.h"
// ====================================================================== INCLUDES
// ====================================================================== SYNOPSIS
#include "rdo_lib/rdo_parser/rdo_array.h"
#include "rdo_lib/rdo_parser/rdoparser.h"
#include "rdo_lib/rdo_parser/rdoparser_error.h"
#include "rdo_lib/rdo_parser/rdoparser_lexer.h"
// ===============================================================================

OPEN_RDO_PARSER_NAMESPACE

 //----------------------------------------------------------------------------
 //---------- RDOArrayValue
 //----------------------------------------------------------------------------
 RDOArrayValue::RDOArrayValue()
{}
 RDOArrayValue::RDOArrayValue(CREF(RDOArrayValue) pValue)
{
	m_arrayValue = pValue.m_arrayValue;
}
RDOArrayValue::~RDOArrayValue()
{}
void RDOArrayValue::insert_array(CREF(RDOValue) pArray)
{
	m_arrayValue.push_back(&pArray);
}
 //----------------------------------------------------------------------------
 //---------- RDOArrayType
 //----------------------------------------------------------------------------
RDOArrayType::RDOArrayType(CREF(LPRDOType) pType)
	: RDOType(&rdoRuntime::g_unknow)
	, m_pType(pType                )
{
	ASSERT(m_pType);
	m_type = new rdoRuntime::RDOArrayType(RDOParser::s_parser()->runtime(), m_pType->type());
	rdoParse::RDOParser::s_parser()->insertArrayType(this);
}

RDOArrayType::~RDOArrayType()
{}

inline tstring RDOArrayType::name() const
{
	return rdo::format(_T("array<%s>"), m_pType->name().c_str());
}

LPRDOType RDOArrayType::type_cast(CREF(LPRDOType) from, CREF(RDOParserSrcInfo) from_src_info, CREF(RDOParserSrcInfo) to_src_info, CREF(RDOParserSrcInfo) src_info) const
{
	switch (from->typeID())
	{
	case rdoRuntime::RDOType::t_array:
		{
			LPRDOArrayType pArray(const_cast<PTR(RDOArrayType)>(this));
			//!      
			if (pArray == from)
				return pArray;

			else
			{
				rdoParse::g_error().push_only(src_info,     _T("   "));
				rdoParse::g_error().push_only(to_src_info,   to_src_info.src_text());
				rdoParse::g_error().push_only(src_info,     _T(""));
				rdoParse::g_error().push_only(from_src_info, from_src_info.src_text());
			}
			rdoParse::g_error().push_done();
			break;
		}
	default:
		rdoParse::g_error().push_only(src_info,    rdo::format(_T("   , : %s"), from_src_info.src_text().c_str()));
		rdoParse::g_error().push_only(to_src_info, rdo::format(_T(". : %s"), to_src_info.src_text().c_str()));
		rdoParse::g_error().push_done();
		break;
	}
	return rdo::smart_ptr_null();
}

RDOValue RDOArrayType::value_cast(CREF(RDOValue) from, CREF(RDOParserSrcInfo) to_src_info, CREF(RDOParserSrcInfo) src_info) const
{
	RDOValue toValue;
	LPRDOArrayType pArray(const_cast<PTR(RDOArrayType)>(this));
	try
	{
		if (from.typeID() == rdoRuntime::RDOType::t_array)
			if (m_type == &from.type()->type())
				toValue = from;

		//case rdoRuntime::RDOType::t_int:			toValue = RDOValue(rdoRuntime::RDOValue(getArray(), from->getInt()),			pArray, from.src_info()); break;
		//case rdoRuntime::RDOType::t_real:			toValue = RDOValue(rdoRuntime::RDOValue(getArray(), from->getDouble()),			pArray, from.src_info()); break;
		//case rdoRuntime::RDOType::t_bool:			toValue = RDOValue(rdoRuntime::RDOValue(getArray(), from->getBool()),			pArray, from.src_info()); break;
		//case rdoRuntime::RDOType::t_string:			toValue = RDOValue(rdoRuntime::RDOValue(getArray(), from->getString()),			pArray, from.src_info()); break;
		//case rdoRuntime::RDOType::t_enum:			toValue = RDOValue(rdoRuntime::RDOValue(getArray(), from->getEnum()),			pArray, from.src_info()); break;
		//case rdoRuntime::RDOType::t_identificator:	toValue = RDOValue(rdoRuntime::RDOValue(getArray(), from->getIdentificator()),	pArray, from.src_info()); break;
	}
	catch (CREF(rdoRuntime::RDOValueException))
	{}

	if (toValue.typeID() == rdoRuntime::RDOType::t_unknow)
	{
		rdoParse::g_error().push_only(src_info,    rdo::format(_T("    : %s"), from.src_info().src_text().c_str()));
		rdoParse::g_error().push_only(to_src_info, rdo::format(_T(": %s"), name().c_str()));
		rdoParse::g_error().push_done();
	}
	return toValue;
}

PTR(rdoRuntime::RDOCalc) RDOArrayType::calc_cast(PTR(rdoRuntime::RDOCalc) pCalc, CREF(LPRDOType) pType) const
{
	return RDOType::calc_cast(pCalc, pType);
}

RDOValue RDOArrayType::get_default() const
{
	NEVER_REACH_HERE;
	return RDOValue();
	//LPRDOArrayType pArray(const_cast<PTR(RDOArrayType)>(this));
	//return RDOValue(rdoRuntime::RDOValue(__array()), pArray, RDOParserSrcInfo());
}

void RDOArrayType::writeModelStructure(REF(std::ostream) stream) const
{
	CPTR(RDOArrayType) pArray(const_cast<PTR(RDOArrayType)>(this));
	stream << (*pArray).name()<< std::endl;
}

CLOSE_RDO_PARSER_NAMESPACE<commit_msg> - сделано добавление элемента в rdoRuntime::RDOArrayValue при добавлении элемента в RDOParser::RDOArrayValue.<commit_after>/*
 * copyright: (c) RDO-Team, 2010
 * filename : rdo_array.cpp
 * author   :  
 * date     : 
 * bref     : 
 * indent   : 4T
 */

// ====================================================================== PCH
#include "rdo_lib/rdo_parser/pch.h"
// ====================================================================== INCLUDES
// ====================================================================== SYNOPSIS
#include "rdo_lib/rdo_parser/rdo_array.h"
#include "rdo_lib/rdo_parser/rdoparser.h"
#include "rdo_lib/rdo_parser/rdoparser_error.h"
#include "rdo_lib/rdo_parser/rdoparser_lexer.h"
// ===============================================================================

OPEN_RDO_PARSER_NAMESPACE

 //----------------------------------------------------------------------------
 //---------- RDOArrayValue
 //----------------------------------------------------------------------------
 RDOArrayValue::RDOArrayValue()
{}
 RDOArrayValue::RDOArrayValue(CREF(RDOArrayValue) pValue)
{
	m_arrayValue = pValue.m_arrayValue;
}
RDOArrayValue::~RDOArrayValue()
{}
void RDOArrayValue::insert_array(CREF(RDOValue) pArray)
{
	m_arrayValue.push_back(&pArray);
	rdoRuntime::RDOArrayValue m_Array;
	m_Array.insert_array(pArray.value());
}
 //----------------------------------------------------------------------------
 //---------- RDOArrayType
 //----------------------------------------------------------------------------
RDOArrayType::RDOArrayType(CREF(LPRDOType) pType)
	: RDOType(&rdoRuntime::g_unknow)
	, m_pType(pType                )
{
	ASSERT(m_pType);
	m_type = new rdoRuntime::RDOArrayType(RDOParser::s_parser()->runtime(), m_pType->type());
	rdoParse::RDOParser::s_parser()->insertArrayType(this);
}

RDOArrayType::~RDOArrayType()
{}

inline tstring RDOArrayType::name() const
{
	return rdo::format(_T("array<%s>"), m_pType->name().c_str());
}

LPRDOType RDOArrayType::type_cast(CREF(LPRDOType) from, CREF(RDOParserSrcInfo) from_src_info, CREF(RDOParserSrcInfo) to_src_info, CREF(RDOParserSrcInfo) src_info) const
{
	switch (from->typeID())
	{
	case rdoRuntime::RDOType::t_array:
		{
			LPRDOArrayType pArray(const_cast<PTR(RDOArrayType)>(this));
			//!      
			if (pArray == from)
				return pArray;

			else
			{
				rdoParse::g_error().push_only(src_info,     _T("   "));
				rdoParse::g_error().push_only(to_src_info,   to_src_info.src_text());
				rdoParse::g_error().push_only(src_info,     _T(""));
				rdoParse::g_error().push_only(from_src_info, from_src_info.src_text());
			}
			rdoParse::g_error().push_done();
			break;
		}
	default:
		rdoParse::g_error().push_only(src_info,    rdo::format(_T("   , : %s"), from_src_info.src_text().c_str()));
		rdoParse::g_error().push_only(to_src_info, rdo::format(_T(". : %s"), to_src_info.src_text().c_str()));
		rdoParse::g_error().push_done();
		break;
	}
	return rdo::smart_ptr_null();
}

RDOValue RDOArrayType::value_cast(CREF(RDOValue) from, CREF(RDOParserSrcInfo) to_src_info, CREF(RDOParserSrcInfo) src_info) const
{
	RDOValue toValue;
	LPRDOArrayType pArray(const_cast<PTR(RDOArrayType)>(this));
	try
	{
		if (from.typeID() == rdoRuntime::RDOType::t_array)
			if (m_type == &from.type()->type())
				toValue = from;

		//case rdoRuntime::RDOType::t_int:			toValue = RDOValue(rdoRuntime::RDOValue(getArray(), from->getInt()),			pArray, from.src_info()); break;
		//case rdoRuntime::RDOType::t_real:			toValue = RDOValue(rdoRuntime::RDOValue(getArray(), from->getDouble()),			pArray, from.src_info()); break;
		//case rdoRuntime::RDOType::t_bool:			toValue = RDOValue(rdoRuntime::RDOValue(getArray(), from->getBool()),			pArray, from.src_info()); break;
		//case rdoRuntime::RDOType::t_string:			toValue = RDOValue(rdoRuntime::RDOValue(getArray(), from->getString()),			pArray, from.src_info()); break;
		//case rdoRuntime::RDOType::t_enum:			toValue = RDOValue(rdoRuntime::RDOValue(getArray(), from->getEnum()),			pArray, from.src_info()); break;
		//case rdoRuntime::RDOType::t_identificator:	toValue = RDOValue(rdoRuntime::RDOValue(getArray(), from->getIdentificator()),	pArray, from.src_info()); break;
	}
	catch (CREF(rdoRuntime::RDOValueException))
	{}

	if (toValue.typeID() == rdoRuntime::RDOType::t_unknow)
	{
		rdoParse::g_error().push_only(src_info,    rdo::format(_T("    : %s"), from.src_info().src_text().c_str()));
		rdoParse::g_error().push_only(to_src_info, rdo::format(_T(": %s"), name().c_str()));
		rdoParse::g_error().push_done();
	}
	return toValue;
}

PTR(rdoRuntime::RDOCalc) RDOArrayType::calc_cast(PTR(rdoRuntime::RDOCalc) pCalc, CREF(LPRDOType) pType) const
{
	return RDOType::calc_cast(pCalc, pType);
}

RDOValue RDOArrayType::get_default() const
{
	NEVER_REACH_HERE;
	return RDOValue();
	//LPRDOArrayType pArray(const_cast<PTR(RDOArrayType)>(this));
	//return RDOValue(rdoRuntime::RDOValue(__array()), pArray, RDOParserSrcInfo());
}

void RDOArrayType::writeModelStructure(REF(std::ostream) stream) const
{
	CPTR(RDOArrayType) pArray(const_cast<PTR(RDOArrayType)>(this));
	stream << (*pArray).name()<< std::endl;
}

CREF(LPRDOType) RDOArrayType::type() const
{
	return m_pType;
}

CLOSE_RDO_PARSER_NAMESPACE
{'fraction_non_alphanumeric': 0.27324385225825415, 'fraction_numerical': 0.0009797198001371607, 'mean_word_length': 4.2946058091286305, 'pattern_counts': {'":': 2, '<': 21, '<?xml version=': 0, '>': 37, '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': '6720629', 'n_tokens_mistral': 3852, 'n_tokens_neox': 3667, 'n_words': 451}