当前位置: 首页>>代码示例>>C++>>正文


C++ ASTType::CombineWithHead方法代码示例

本文整理汇总了C++中ASTType::CombineWithHead方法的典型用法代码示例。如果您正苦于以下问题:C++ ASTType::CombineWithHead方法的具体用法?C++ ASTType::CombineWithHead怎么用?C++ ASTType::CombineWithHead使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ASTType的用法示例。


在下文中一共展示了ASTType::CombineWithHead方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Traverse

	void Traverse(State* state, ASTNode* node)
	{
		bool recurse = true;
		
		StructureScope scope;
		StructureScope* backup;
		// PRE
		switch (node->GetType())
		{
		case ASTNode::Type::Root:
			*state->Data += string_format("namespace reflector {\n");
			backup = state->StructScope;
			state->StructScope = &scope;
			state->StructScope->Name = "~ROOT~";

			break;
		case ASTNode::Type::File:
			*state->Data += string_format("// FILE: \"%s\"\n", node->ToString().c_str());
			break;
		case ASTNode::Type::Namespace:
			*state->Data += string_format("// NAMESPACE: \"%s\"\n", node->ToString().c_str());
			break;
		case ASTNode::Type::Public:
			state->StructScope->VisibilityType = "Public";
			break;
		case ASTNode::Type::Protected:
			state->StructScope->VisibilityType = "Protected";
			break;
		case ASTNode::Type::Private:
			state->StructScope->VisibilityType = "Private";
			break;
		case ASTNode::Type::Class:
		case ASTNode::Type::Struct:
			backup = state->StructScope;
			state->StructScope = &scope;
			state->StructScope->Name = node->ToString();
			break;
		case ASTNode::Type::DclHead:    // recurse these
			break;
		case ASTNode::Type::AntFwd:		// ignore these
		case ASTNode::Type::AntBack:
		case ASTNode::Type::DclSub:
			recurse = false;
			break;

		default: 
			*state->Data += string_format("// UNKNOWN: %s \"%s\"\n", node->GetTypeString(), node->ToString().c_str());
			recurse = false;
		};


		// recurse

		if (recurse)
		{
			auto& children = node->Children();
			for (size_t i = 0; i < children.size(); i++)
			{
				Traverse(state, children[i]);
			}
		}

			
		// POST
		switch (node->GetType())
		{
		case ASTNode::Type::DclSub:
		{
			ASTType* typeNode = (ASTType*)node;
			ASTType combined(typeNode->tokenSource);
			if (typeNode->head != 0)
				combined = typeNode->CombineWithHead();
			else
				combined.MergeData(typeNode);
			state->StructScope->Members[Types::Member].push_back(vCount);
			*state->Data += string_format("StructureMember m_%d = { VisibilityEnum::%s, \"%s\", \"%s\", reflector_offsetof(%s, %s), reflector_sizeof(%s, %s), 1 };\n", 
				vCount++, state->StructScope->VisibilityType, combined.ToIdentifierString().c_str(), combined.ToString(false).c_str(),
				state->StructScope->Name.c_str(), combined.ToIdentifierString().c_str(), state->StructScope->Name.c_str(), combined.ToIdentifierString().c_str());
			recurse = false;
			break;
		}
		case ASTNode::Type::Root:
			*state->Data += string_format("} // end namespace reflector\n\n");
			state->StructScope = backup;
			break;
		case ASTNode::Type::File:
			*state->Data += string_format("// END FILE: \"%s\"\n", node->ToString().c_str());
			break;
		case ASTNode::Type::Class:
		case ASTNode::Type::Struct:
			// collect members
			std::string memberLocation = "0";
			if (state->StructScope->Members[Types::Member].size() > 0)
			{
				std::string members;
				for (auto it : state->StructScope->Members[Types::Member])
				{
					members += string_format("&m_%d,", it);
				}
				if (members.size() > 0)
//.........这里部分代码省略.........
开发者ID:Lssikkes,项目名称:CppReflector,代码行数:101,代码来源:moduleReflectionData.cpp


注:本文中的ASTType::CombineWithHead方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。