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


C++ Symbol::GetSymbolType方法代码示例

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


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

示例1:

Symbol * DACGenerator::AddSymbol(Symbol * pSymbol)
{
	if (pSymbol == 0) {
		Error("AddSymbol: invalid symbol");
		return 0;
	}

	// check if symbol already exists
	Symbol* result = mSymbolTable.Find(pSymbol->GetName());

	if (result != 0)
	{
		if (result->GetSymbolType() != eConst)
		{
			std::wstring wname = std::wstring(result->GetName());
			std::string name = std::string(wname.begin(), wname.end());
			Error("Symbol " + name + " already defined");
		}
		delete pSymbol; pSymbol = result;
	}
	else
	{
		result = mSymbolTable.Add(pSymbol);
	}

	return result;
}
开发者ID:Djon,项目名称:COM,代码行数:27,代码来源:DACGenerator.cpp

示例2: WriteMetaData

// --------------------------------------------------------------------------------
//	Writes the data out for a given symbol.
// --------------------------------------------------------------------------------
void CodeGenerator::WriteMetaData(Symbol* symbol)
{
	if (symbol->GeneratedSymbolData == false)
	{
		symbol->GeneratedSymbolData = true;
		
		// Write out the header.
		WriteLine(symbol->UniqueASMName + "_meta:");
	
			// General information.
			switch (symbol->GetSymbolType())
			{
				case ST_VARIABLE:	WriteLine("\tdd " + StringHelper::IntToString(META_TYPE_VARIABLE)); break;
				case ST_FUNCTION:	WriteLine("\tdd " + StringHelper::IntToString(META_TYPE_FUNCTION)); break;
				case ST_CLASS:		WriteLine("\tdd " + StringHelper::IntToString(META_TYPE_CLASS)); break;
				case ST_NAMESPACE:	WriteLine("\tdd " + StringHelper::IntToString(META_TYPE_NAMESPACE)); break;
			}

			// Source code declaration.
			WriteLine("\tdd " + FindStringLiteralLabel(symbol->DefinitionToken.Path, true));
			WriteLine("\tdd " + StringHelper::IntToString(symbol->DefinitionToken.Line));
			WriteLine("\tdd " + StringHelper::IntToString(symbol->DefinitionToken.Column));
		
			// General properties.
			WriteLine("\tdd " + FindStringLiteralLabel(symbol->Identifier, true));
		
			// Child properties.
			WriteLine("\tdd " + symbol->UniqueASMName + "_meta_children");

			// Write in specific symbol information.
			switch (symbol->GetSymbolType())
			{
				// Emit a namespace!
				case ST_NAMESPACE:
				{
					NamespaceSymbol* func = (NamespaceSymbol*)symbol;
					break;
				}

				// Emit metadata for a function.
				case ST_FUNCTION:
				{
					FunctionSymbol* func = (FunctionSymbol*)symbol;
					
					WriteLine("\tdd " + std::string(func->IsExtern == false ? func->UniqueASMName : "0"));
					WriteLine("\tdd " + StringHelper::IntToString((int)func->ReturnDataType->GetPrimitive()));
					WriteLine("\tdd " + StringHelper::IntToString(func->ReturnDataType->GetPrimitive() == PDT_CLASS ? ((ClassDataType*)func->ReturnDataType)->Class->ClassDefinitionIndex : 0));
					WriteLine("\tdd " + StringHelper::IntToString(func->ParameterCount));
					WriteLine("\tdd " + StringHelper::IntToString(func->ParameterSize));
					WriteLine("\tdd " + StringHelper::IntToString(func->LocalCount));
					WriteLine("\tdd " + StringHelper::IntToString(func->LocalSize));
					WriteLine("\tdd " + StringHelper::IntToString((int)func->IsExtern));
					WriteLine("\tdd " + StringHelper::IntToString((int)func->IsMethod));
					WriteLine("\tdd " + StringHelper::IntToString((int)func->IsGenerator));
					WriteLine("\tdd " + StringHelper::IntToString((int)func->IsVirtual));
					WriteLine("\tdd " + StringHelper::IntToString((int)func->IsBase));
					WriteLine("\tdd " + StringHelper::IntToString((int)func->VirtualFunctionTableOffset));
					WriteLine("\tdd " + StringHelper::IntToString((int)func->AccessModifier));

					break;
				}
			
				// Emit metadata for a variable.
				case ST_VARIABLE:
				{
					VariableSymbol* var = (VariableSymbol*)symbol;
					
					WriteLine("\tdd " + std::string(var->Scope == _globalScope ? var->UniqueASMName : "0"));
					WriteLine("\tdd " + StringHelper::IntToString((int)var->VariableType));
					WriteLine("\tdd " + StringHelper::IntToString((int)var->DataType->GetPrimitive()));
					WriteLine("\tdd " + StringHelper::IntToString(var->DataType->GetPrimitive() == PDT_CLASS ? ((ClassDataType*)var->DataType)->Class->ClassDefinitionIndex : 0));
					WriteLine("\tdd " + StringHelper::IntToString(var->StackOffset));
					WriteLine("\tdd " + StringHelper::IntToString(var->ParamStackOffset));
					WriteLine("\tdd " + StringHelper::IntToString(var->ClassOffset));
					WriteLine("\tdd " + StringHelper::IntToString((int)var->IsConst));
					WriteLine("\tdd " + StringHelper::IntToString((int)var->IsBase));			
					WriteLine("\tdd " + StringHelper::IntToString((int)var->AccessModifier));

					break;
				}
			
				// Emit metadata for a class.
				case ST_CLASS:
				{
					ClassSymbol* classSymbol = (ClassSymbol*)symbol;

					WriteLine("\tdd " + classSymbol->UniqueASMName + "_vftable");
					WriteLine("\tdd " + StringHelper::IntToString(classSymbol->VirtualFunctionTableSize));
				
					WriteLine("\tdd " + StringHelper::IntToString(classSymbol->MemoryDataSize));
					
					if (classSymbol->SuperClass != NULL)
						WriteLine("\tdd " + StringHelper::IntToString(classSymbol->SuperClass->ClassDefinitionIndex));
					else
						WriteLine("\tdd -1");
					
					WriteLine("\tdd " + StringHelper::IntToString(classSymbol->ClassDefinitionIndex));
//.........这里部分代码省略.........
开发者ID:HampsterEater,项目名称:IcarusCompiler,代码行数:101,代码来源:CodeGenerator.cpp


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