예제 #1
0
OOModel::Expression* CallDescriptor::create(const QList<OOModel::Expression*>& operands)
{
	Q_ASSERT(operands.size() == 2);
	auto varName = dynamic_cast<OOModel::VariableAccess*>( operands.first());
	Q_ASSERT(varName);

	OOModel::MethodCallExpression* opr = new OOModel::MethodCallExpression();
	opr->ref()->set(varName->ref()->path());
	OOModel::Expression* prefix = varName->prefix();
	varName->replaceChild(prefix, new OOModel::EmptyExpression());
	SAFE_DELETE(varName);
	opr->setPrefix(prefix);

	if (auto comma = dynamic_cast<OOModel::CommaExpression*>(operands.last()))
	{
		for(auto arg : comma->allSubOperands(true))
			opr->arguments()->append(arg);

		SAFE_DELETE(comma);
	}
	else
		if (!dynamic_cast<OOModel::EmptyExpression*>(operands.last()) )
				opr->arguments()->append(operands.last());

	return opr;
}
예제 #2
0
OOModel::Expression* CallDescriptor::create(const QList<OOModel::Expression*>& operands)
{
	Q_ASSERT(operands.size() == 2);
	auto ref = dynamic_cast<OOModel::ReferenceExpression*>( operands.first());
	Q_ASSERT(ref);

	OOModel::MethodCallExpression* opr = new OOModel::MethodCallExpression();
	opr->setRef(ref);

	if (auto comma = dynamic_cast<OOModel::CommaExpression*>(operands.last()))
	{
		for(auto arg : comma->allSubOperands(true))
			opr->arguments()->append(arg);

		SAFE_DELETE(comma);
	}
	else
		if (!dynamic_cast<OOModel::EmptyExpression*>(operands.last()) )
				opr->arguments()->append(operands.last());

	return opr;
}