Exemple #1
0
TemplateClassInstanceTypeNode* NamespaceTypeNode::addTemplateClassInstance(TemplateClassInstanceNode* node)
{
	std::string name = node->m_name->m_str;
	std::string localName = node->m_name->m_str;
	name += "<";
	localName += "<";
	auto begin = node->m_templateArguments.m_arguments.begin();
	auto end = node->m_templateArguments.m_arguments.end();
	for (auto it = begin; it != end; ++it)
	{
		if (it != begin)
		{
			name += ", ";
			localName += ", ";
		}
		TypeNode* paramTypeNode = it->m_typeNode;
		std::string paramName;
		paramTypeNode->getActualTypeFullName(paramName);
		name += paramName;
		paramTypeNode->getFullName(paramName);
		localName += paramName;
	}
	name += ">";
	localName += ">";
	TemplateClassInstanceTypeNode* result = m_children.addTypeNode<TemplateClassInstanceTypeNode>(this, name, node->m_name);
	if (result)
	{
		result->m_localName = localName;
		result->m_templateClassInstanceNode = node;
		CopyChildren(result, node->m_classTypeNode);
	}
	return result;
}
Exemple #2
0
TypeNode* TypeTree::findNodeByScopeName(ScopeNameNode* scopeNameNode, TypeNode* enclosingTypeTreeNode, TemplateArguments* templateArguments)
{
	if (templateArguments && templateArguments->m_classTypeNode->isTemplateClass())//must be TypeNameNode::calcTypeNodes
	{
		if (scopeNameNode->isTemplateForm())
		{
			TypeNode* result = enclosingTypeTreeNode->getChildNode(scopeNameNode->m_name->m_str);
			if (0 == result || !result->isTemplateClass())
			{
				return 0;
			}
			std::vector<TypeNameNode*> paramTypeNameNodes;
			scopeNameNode->m_parameterList->collectTypeNameNodes(paramTypeNameNodes);
			assert(!paramTypeNameNodes.empty());
			if (paramTypeNameNodes.size() != static_cast<ClassTypeNode*>(result)->m_parameterNodes.size())
			{
				return 0;
			}
			bool hasUndeteminedType = false;
			std::string name = scopeNameNode->m_name->m_str;
			name += "<";
			auto begin = paramTypeNameNodes.begin();
			auto end = paramTypeNameNodes.end();
			for (auto it = begin; it != end; ++it)
			{
				if (it != begin)
				{
					name += ", ";
				}
				TypeNameNode* paramTypeNameNode = *it;
				assert(paramTypeNameNode->m_startTypeNode);
				if (0 == paramTypeNameNode->m_typeNode ||
					paramTypeNameNode->m_typeNode->isTemplateParameter() ||
					paramTypeNameNode->m_typeNode->isTemplateClass() ||
					paramTypeNameNode->m_typeNode->isUnderTemplateClass())
				{
					hasUndeteminedType = true;
					break;
				}
				else
				{
					assert(paramTypeNameNode->m_typeNode->isPredefinedType() ||
						paramTypeNameNode->m_typeNode->isEnum() ||
						paramTypeNameNode->m_typeNode->isClass() ||
						paramTypeNameNode->m_typeNode->isTemplateClassInstance() ||
						paramTypeNameNode->m_typeNode->isTypedef() ||
						paramTypeNameNode->m_typeNode->isTypeDeclaration());
					std::string paramName;
					paramTypeNameNode->m_typeNode->getActualTypeFullName(paramName);
					name += paramName;
				}
			}
			name += ">";
			if (!hasUndeteminedType)
			{
				result = enclosingTypeTreeNode->getChildNode(name);
			}
			return result;
		}
		else
		{
			TypeNode* result = enclosingTypeTreeNode->getChildNode(scopeNameNode->m_name->m_str);
			if (0 == result || result->isTemplateClass())
			{
				return 0;
			}
			return result;
		}
	}
	else
	{
		if (scopeNameNode->isTemplateForm())
		{
			TypeNode* result = enclosingTypeTreeNode->getChildNode(scopeNameNode->m_name->m_str);
			if (0 == result || !result->isTemplateClass())
			{
				return 0;
			}
			std::vector<TypeNameNode*> paramTypeNameNodes;
			scopeNameNode->m_parameterList->collectTypeNameNodes(paramTypeNameNodes);
			assert(!paramTypeNameNodes.empty());
			if (paramTypeNameNodes.size() != static_cast<ClassTypeNode*>(result)->m_parameterNodes.size())
			{
				return 0;
			}
			bool hasUndeteminedType = false;
			std::string name = scopeNameNode->m_name->m_str;
			name += "<";
			auto begin = paramTypeNameNodes.begin();
			auto end = paramTypeNameNodes.end();
			for (auto it = begin; it != end; ++it)
			{
				if (it != begin)
				{
					name += ", ";
				}
				TypeNameNode* paramTypeNameNode = *it;
				TypeNode* paramTypeNode = paramTypeNameNode->getTypeNode(templateArguments);
				if(0 == paramTypeNode)
				{
					return 0;
				}
				else
				{
					std::string paramName;
					paramTypeNode->getActualTypeFullName(paramName);
					name += paramName;
				}
			}
			name += ">";
			if (!hasUndeteminedType)
			{
				result = enclosingTypeTreeNode->getChildNode(name);
			}
			return result;
		}
		else
		{
			TypeNode* result = enclosingTypeTreeNode->getChildNode(scopeNameNode->m_name->m_str);
			if (0 == result || result->isTemplateClass())
			{
				return 0;
			}
			return result;
		}
	}
}