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


C++ Var::cIdent方法代码示例

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


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

示例1: print_controller_C

void print_controller_C(ostream& out, string component, const StateMachine& machine)
{
  out << "// Auto generated C++ code started by "<<__FILE__<<":"<<__LINE__<< endl;
  out << "// " << machine.getIdent() << ": " << machine.getShorthand() << endl;
  out << endl;
  out << "#include \"Global.h\"" << endl;
  out << "#include \"slicc_util.h\"" << endl;
  out << "#include \"" << component << "_Controller.h\"" << endl;
  out << "#include \"" << component << "_State.h\"" << endl;
  out << "#include \"" << component << "_Event.h\"" << endl;
  out << "#include \"Types.h\"" << endl;
  out << "#include \"Profiler.h\"" << endl;
  out << "#include \"Network.h\"" << endl;
  out << endl;

  out << "// static profiler defn" << endl;
  out << component << "_Profiler " << component << "_Controller::s_profiler;" << endl;
  out << endl;

  out << "// constructor" << endl;
  out << component << "_Controller::" << component << "_Controller(NodeID id, Network* network_ptr)" << endl;
  out << "{" << endl;
  out << "  m_id = id;" << endl;

  // Initialize member variables
  const Vector<Symbol*>& symbols = g_sym_table.getAllSymbols();
  for (int i=0; i < symbols.size(); i++) {
    Var* var = dynamic_cast<Var*>(symbols[i]);
    if (var == NULL || var->getMachine() != &machine) {
      continue;
    }
    out << "  // " << var->cIdent() << endl;
    if (var->existPair("network")) {
      // Network port object
      string network = var->lookupPair("network");
      string ordered =  var->lookupPair("ordered");
      string vnet =  var->lookupPair("virtual_network");
      
      out << "  m_" << var->cIdent() << "_ptr = network_ptr->get" 
          << network << "NetQueue(MachineType_" << var->getMachine()->getIdent() << ", m_id, " 
          << ordered << ", " << vnet << ");\n";
    } else if (var->getType()->existPair("primitive") || (dynamic_cast<Enum*>(var->getType()) != NULL)) {
      // Normal non-object
      out << "  m_" << var->cIdent() << "_ptr = new " << var->getType()->cIdent() << ";\n";
    } else {
      // Normal Object
      out << "  m_" << var->cIdent() << "_ptr = new " << var->getType()->cIdent();
      if (!var->getType()->existPair("non_obj")) {
        if (var->existPair("constructor_hack")) {
          string constructor_hack = var->lookupPair("constructor_hack");
          out << "(m_id, " << constructor_hack << ")";
        } else {
          out << "(m_id)";
        }
        out << ";\n";
      }
    }
    out << "  assert(m_" << var->cIdent() << "_ptr != NULL);" << endl;

    // Set to the default value
    if (var->existPair("default")) {
      out << "  (*m_" << var->cIdent() << "_ptr) = " << var->lookupPair("default") 
          << "; // Object default" << endl;
    } else if (var->getType()->hasDefault()) {
      out << "  (*m_" << var->cIdent() << "_ptr) = " << var->getType()->getDefault() 
          << "; // Type " << var->getType()->getIdent() << " default" << endl;
    }
    
    // Set ordering
    if (var->existPair("ordered")) {
      // A buffer
      string ordered =  var->lookupPair("ordered");
      out << "  m_" << var->cIdent() << "_ptr->setOrdering(" << ordered << ");\n";
    }
    
    // Set randomization
    if (var->existPair("random")) {
      // A buffer
      string value =  var->lookupPair("random");
      out << "  m_" << var->cIdent() << "_ptr->setRandomization(" << value << ");\n";
    }
    out << endl;
  }

  // Set the queue consumers
  for(int i=0; i < machine.numInPorts(); i++) {
    out << "  " << machine.getInPort(i).getCode() << ".setConsumer(this);" << endl;
  }

  out << endl;
  // Set the queue descriptions
  for(int i=0; i < machine.numInPorts(); i++) {
    out << "  " << machine.getInPort(i).getCode() 
        << ".setDescription(\"[Node \" + int_to_string(m_id) + \", " 
        << component << ", " << machine.getInPort(i).toString() << "]\");" << endl;
  }

  // Initialize the transition profiling
  out << endl;
  for(int i=0; i<machine.numTransitions(); i++) {
//.........这里部分代码省略.........
开发者ID:EgoIncarnate,项目名称:FeS2-with-DRAMSim2,代码行数:101,代码来源:machine_gen.C


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