Esempio n. 1
0
ExportIndex operator*(	const ExportIndex& _arg1,
						const ExportIndex& _arg2
						)
{
	ExportIndex tmp;

	if (_arg1.isGiven() == BT_TRUE && _arg2.isGiven() == BT_TRUE)
	{
		tmp.assignNode(new ExportIndexNode(_arg1.getGivenValue() * _arg2.getGivenValue()));

		return tmp;
	}

	if (_arg1.isVariable() == BT_TRUE && _arg2.isGiven() == BT_TRUE)
	{
		tmp.assignNode(new ExportIndexNode(_arg1.getName(), _arg1.getPrefix(), _arg1->getFactor() * _arg2.getGivenValue(), _arg1->getOffset() * _arg2.getGivenValue()));

		return tmp;
	}

	if (_arg1.isGiven() == BT_TRUE && _arg2.isVariable() == BT_TRUE)
	{
		tmp.assignNode(new ExportIndexNode(_arg2.getName(), _arg2.getPrefix(), _arg2->getFactor() * _arg1.getGivenValue(), _arg2->getOffset() * _arg1.getGivenValue()));

		return tmp;
	}

	tmp.assignNode(new ExportIndexNode(ESO_MULTIPLY, _arg1, _arg2));

	return tmp;
}
Esempio n. 2
0
ExportIndex operator+(	const ExportIndex& _arg1,
						const ExportIndex& _arg2
						)
{
	ExportIndex tmp;

	if (_arg1.isGiven() == BT_TRUE && _arg2.isGiven() == BT_TRUE)
	{
		tmp.assignNode(new ExportIndexNode(_arg1.getGivenValue() + _arg2.getGivenValue()));

		return tmp;
	}

	if (_arg1.isVariable() == BT_TRUE && _arg2.isGiven() == BT_TRUE)
	{
		tmp.assignNode(new ExportIndexNode(_arg1.getName(), _arg1.getPrefix(), _arg1->getFactor(), _arg1->getOffset() + _arg2.getGivenValue()));

		return tmp;
	}

	if (_arg1.isGiven() == BT_TRUE && _arg2.isVariable() == BT_TRUE)
	{
		tmp.assignNode(new ExportIndexNode(_arg2.getName(), _arg2.getPrefix(),  _arg2->getFactor(), _arg2->getOffset() + _arg1.getGivenValue()));

		return tmp;
	}

	if(_arg1.isVariable() == BT_TRUE && _arg2.isVariable() == BT_TRUE && _arg1.getFullName() == _arg2.getFullName())
	{
		if ((_arg1->getFactor() + _arg2->getFactor()) == 0)
			tmp.assignNode(new ExportIndexNode(_arg1->getOffset() + _arg2->getOffset()));
		else
			tmp.assignNode(new ExportIndexNode(_arg1.getName(), _arg1.getPrefix(), _arg1->getFactor() + _arg2->getFactor(), _arg1->getOffset() + _arg2->getOffset()));
	}
	else
	{
		tmp.assignNode(new ExportIndexNode(ESO_ADD, _arg1, _arg2));
	}

	return tmp;
}