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


C++ StructType::get_group_symbol_table方法代码示例

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


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

示例1: ConstructModuleSymbols

void ExportPass::ConstructModuleSymbols()
{
  CProcedureType* originalType = dynamic_cast<CProcedureType*>(originalProcedure->get_procedure_symbol()->get_type()) ;
  assert(originalType != NULL) ;

  // The original type takes and returns a struct.  We need to change this
  //  to a list of arguments.

  VoidType* newReturnType = create_void_type(theEnv, IInteger(0), 0) ;
  constructedType = create_c_procedure_type(theEnv,
					    newReturnType,
					    false, // has varargs
					    true, // arguments_known
					    0, // bit alignment
					    LString("ConstructedType")) ;

  StructType* returnType = 
    dynamic_cast<StructType*>(originalType->get_result_type()) ;
  assert(returnType != NULL) ;

  SymbolTable* structSymTab = returnType->get_group_symbol_table() ;
  assert(structSymTab != NULL) ;

  for (int i = 0 ; i < structSymTab->get_symbol_table_object_count() ; ++i)
  {
    VariableSymbol* nextVariable = 
      dynamic_cast<VariableSymbol*>(structSymTab->get_symbol_table_object(i));
    if (nextVariable != NULL)
    {
      // Check to see if this is an output or not
      QualifiedType* cloneType ;
      DataType* cloneBase = 
	dynamic_cast<DataType*>(nextVariable->get_type()->get_base_type()->deep_clone()) ;
      assert(cloneBase != NULL) ;
      cloneType = create_qualified_type(theEnv, cloneBase) ;
 
      if (nextVariable->lookup_annote_by_name("Output") != NULL)
      {
	cloneType->append_annote(create_brick_annote(theEnv, "Output")) ;
	// Why doesn't this stick around?
      }
      constructedType->append_argument(cloneType) ;
    }
  }

  constructedSymbol = create_procedure_symbol(theEnv,
					      constructedType,
					      originalProcedure->get_procedure_symbol()->get_name()) ;
  constructedSymbol->set_definition(NULL) ;

}
开发者ID:JehandadKhan,项目名称:roccc-2.0,代码行数:51,代码来源:exportPass.cpp

示例2: if

void CopyPropagationPass2::CollectVariables()
{
  assert(procDef != NULL) ;
  if (killMap.empty() == false)
  {
    ClearMap() ;
  }
  assert(killMap.empty() == true) ;
  assert(procDef != NULL) ;
  SymbolTable* symTab = procDef->get_symbol_table() ;
  Iter<SymbolTableObject*> symIter = 
    symTab->get_symbol_table_object_iterator() ;
  while (symIter.is_valid())
  {
    if (is_a<VariableSymbol>(symIter.current()))
    {
      // For each variable symbol, create a new list of statement/int pairs
      //  and add that to the kill map
      list<std::pair<Statement*, int> >* assocList = 
	new list<std::pair<Statement*, int> > ;
      killMap[to<VariableSymbol>(symIter.current())] = assocList ;
    }
    else if (is_a<ParameterSymbol>(symIter.current()))
    {
      // If we are compiling a module, we also have to find the argument
      //  (which should be a struct) and collect all of those variable
      //  symbols..
      ParameterSymbol* nextParm =
	dynamic_cast<ParameterSymbol*>(symIter.current()) ;
      assert(nextParm != NULL) ;

      // Now check that we have a struct type
      DataType* parmType = nextParm->get_type()->get_base_type() ;
      StructType* parmStructType =
        dynamic_cast<StructType*>(parmType) ;

      if (parmStructType == NULL)
      {
	list<std::pair<Statement*, int> >* assocList =
	  new list<std::pair<Statement*, int> > ;
	killMap[dynamic_cast<VariableSymbol*>(symIter.current())] = assocList ;
	symIter.next() ;
	continue ;
      }

      // Go through this symbol table, just like the parent table...
      SymbolTable* structSymTab = parmStructType->get_group_symbol_table() ;

      Iter<SymbolTableObject*> structSymIter =
        structSymTab->get_symbol_table_object_iterator() ;

      while (structSymIter.is_valid())
      {
	// These should all be variable symbols!
	if (is_a<FieldSymbol>(structSymIter.current()))
	{
	  // For each variable symbol, create a new list of statement/int pairs
	  //  and add that to the killMap.
	  list<std::pair<Statement*, int> >* assocList =
	    new list<std::pair<Statement*, int> > ;
	  
	  killMap[to<VariableSymbol>(structSymIter.current())] = assocList ;
	}
	else
	{
	  std::cerr << "Non variable symbol inside a struct!" << std::endl ;
	  assert(0) ;
	}
	
	structSymIter.next() ;
      }
    }
    symIter.next() ;
  }
}
开发者ID:JehandadKhan,项目名称:roccc-2.0,代码行数:75,代码来源:copy_propagation_pass2.cpp


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