<commit_before>/*!
  \copyright (c) RDO-Team, 2011
  \file      param.cpp
  \author      (<EMAIL>)
  \date      09.01.2011
  \brief     
  \indent    4T
*/

// ---------------------------------------------------------------------------- PCH
#include "simulator/compiler/parser/pch.h"
// ----------------------------------------------------------------------- INCLUDES
// ----------------------------------------------------------------------- SYNOPSIS
#include "simulator/compiler/parser/rdoparser.h"
#include "simulator/compiler/parser/param.h"
#include "simulator/compiler/parser/rdortp.h"
#include "simulator/runtime/rdo_resource.h"
// --------------------------------------------------------------------------------

OPEN_RDO_PARSER_NAMESPACE

RDOParam::RDOParam(CREF(tstring) name, CREF(LPTypeInfo) pType, CREF(LPRDOValue) pDefault)
	: RDOParserSrcInfo(name    )
	, m_pType         (pType   )
	, m_pDefault      (pDefault)
{
	checkDefault();
}

RDOParam::RDOParam(CREF(RDOParserSrcInfo) srcInfo, CREF(LPTypeInfo) pType, CREF(LPRDOValue) pDefault)
	: RDOParserSrcInfo(srcInfo )
	, m_pType         (pType   )
	, m_pDefault      (pDefault)
{
	checkDefault();
}

RDOParam::~RDOParam()
{}

void RDOParam::checkDefault()
{
	if (m_pDefault && m_pDefault->defined())
	{
		m_pType->type()->type_cast(m_pDefault->typeInfo()->type(), m_pDefault->src_info(), this->src_info(), m_pDefault->src_info());
		m_pDefault = m_pType->type()->value_cast(m_pDefault, this->src_info(), m_pDefault->src_info());
	}
}

Context::FindResult RDOParam::onSwitchContext(CREF(LPExpression) pSwitchExpression, CREF(LPRDOValue) pValue) const
{
	ASSERT(pSwitchExpression);
	ASSERT(pValue           );

	LPRDORTPResType pResType = pSwitchExpression->typeInfo()->type().object_dynamic_cast<RDORTPResType>();
	if (pResType)
	{
		LPIContextSwitch pContextSwitch = pResType.interface_dynamic_cast<IContextSwitch>();
		ASSERT(pContextSwitch);
		return pContextSwitch->onSwitchContext(pSwitchExpression, pValue);
	}
	RDOParser::s_parser()->error().error(
		pSwitchExpression->src_info(),
		rdo::format(_T("  '%s'  "), pSwitchExpression->src_info().src_text().c_str())
	);
}

CLOSE_RDO_PARSER_NAMESPACE<commit_msg> - подавление ворнинга<commit_after>/*!
  \copyright (c) RDO-Team, 2011
  \file      param.cpp
  \author      (<EMAIL>)
  \date      09.01.2011
  \brief     
  \indent    4T
*/

// ---------------------------------------------------------------------------- PCH
#include "simulator/compiler/parser/pch.h"
// ----------------------------------------------------------------------- INCLUDES
// ----------------------------------------------------------------------- SYNOPSIS
#include "simulator/compiler/parser/rdoparser.h"
#include "simulator/compiler/parser/param.h"
#include "simulator/compiler/parser/rdortp.h"
#include "simulator/runtime/rdo_resource.h"
// --------------------------------------------------------------------------------

OPEN_RDO_PARSER_NAMESPACE

RDOParam::RDOParam(CREF(tstring) name, CREF(LPTypeInfo) pType, CREF(LPRDOValue) pDefault)
	: RDOParserSrcInfo(name    )
	, m_pType         (pType   )
	, m_pDefault      (pDefault)
{
	checkDefault();
}

RDOParam::RDOParam(CREF(RDOParserSrcInfo) srcInfo, CREF(LPTypeInfo) pType, CREF(LPRDOValue) pDefault)
	: RDOParserSrcInfo(srcInfo )
	, m_pType         (pType   )
	, m_pDefault      (pDefault)
{
	checkDefault();
}

RDOParam::~RDOParam()
{}

void RDOParam::checkDefault()
{
	if (m_pDefault && m_pDefault->defined())
	{
		m_pType->type()->type_cast(m_pDefault->typeInfo()->type(), m_pDefault->src_info(), this->src_info(), m_pDefault->src_info());
		m_pDefault = m_pType->type()->value_cast(m_pDefault, this->src_info(), m_pDefault->src_info());
	}
}

Context::FindResult RDOParam::onSwitchContext(CREF(LPExpression) pSwitchExpression, CREF(LPRDOValue) pValue) const
{
	ASSERT(pSwitchExpression);
	ASSERT(pValue           );

	LPRDORTPResType pResType = pSwitchExpression->typeInfo()->type().object_dynamic_cast<RDORTPResType>();
	if (pResType)
	{
		LPIContextSwitch pContextSwitch = pResType.interface_dynamic_cast<IContextSwitch>();
		ASSERT(pContextSwitch);
		return pContextSwitch->onSwitchContext(pSwitchExpression, pValue);
	}

	RDOParser::s_parser()->error().error(
		pSwitchExpression->src_info(),
		rdo::format(_T("  '%s'  "), pSwitchExpression->src_info().src_text().c_str())
	);

	return FindResult();
}

CLOSE_RDO_PARSER_NAMESPACE
{'fraction_non_alphanumeric': 0.2676088443127422, 'fraction_numerical': 0.0059266013220879874, 'mean_word_length': 2.5559157212317665, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 45, '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': '412795', 'n_tokens_mistral': 1480, 'n_tokens_neox': 1448, 'n_words': 187}