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


C++ Sym类代码示例

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


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

示例1: symToHtml

QString symToHtml(const Sym& s, int leftMargin, const TextStyle* ts, qreal _spatium)
      {
      qreal size;
      if (ts) {
            size = ts->font(_spatium).pointSizeF();
            }
      else {
#ifdef USE_GLYPHS
            size = s.font().pointSizeF();
#else
            size = s.font().pixelSize();
#endif
            }

      QString family = s.font().family();
      return QString(
      "<data>"
        "<html>"
          "<head>"
            "<meta name=\"qrichtext\" content=\"1\" >"
            "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf8\" />"
            "<style type=\"text/css\">"
              "p, li { white-space: pre-wrap; }"
              "</style>"
            "</head>"
          "<body style=\" font-family:'%1'; font-size:%2pt;\">"
            "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:%3px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">"
                "&#%4;"
              "</p>"
            "</body>"
          "</html>"
      "</data>").arg(family).arg(size).arg(leftMargin).arg(s.code());
      }
开发者ID:Skibol,项目名称:MuseScore,代码行数:33,代码来源:sym.cpp

示例2: print_opnd_type

void print_opnd_type(Opnd o) {
  if(is_reg(o)) {
    if(is_hard_reg(o)) {
      std::cout << "(is hard reg)";
    }
    else if(is_virtual_reg(o)) {
      std::cout << "(is virtual reg)[$vr"<<get_reg(o)<<"]";
    }
    else {
      std::cout << "(is undeterminate reg)";
    }
  }
  else if(is_immed(o)) {
    if(is_immed_integer(o)) {
      std::cout << "(is immed integer)";
    }
    else if(is_immed_string(o)) {
      std::cout << "(is immed string)";
    }
    else {
      std::cout << "(is undeterminate immed)";
    }
  }
  else if(is_addr(o)) {
    if(is_addr_sym(o)) {
      FormattedText ft;
      Sym *symbol = get_sym(o);
      symbol->print(ft);
      char* addr_name;
      
      addr_name =  (char*)(symbol->get_name()).c_str();
  
      std::cout << "(is addr sym)["<<addr_name<<"]";
    }
    else if(is_addr_exp(o)) {
      std::cout << "(is addr exp)";
    }
    else {
      std::cout << "(is undeterminate addr)";
    }
  }
  else if(is_var(o)) {
    FormattedText ft;
    VarSym *vsym = get_var(o);
    vsym->print(ft);
    char* var_name;
    
    var_name =  (char*)(vsym->get_name()).c_str();

    std::cout << "(is var)["<<var_name<<"]";
  }
  else if(is_null(o)) {
    std::cout << "(is null)";
  }
  else {
    std::cout << "(I don't know) !!!)";
  }

  return;
}
开发者ID:JehandadKhan,项目名称:roccc-2.0,代码行数:60,代码来源:opnd.cpp

示例3: firstLexicalOutputTpl

 Sym firstLexicalOutputTpl(Arc const* a) const {
   StateIdContainer const& tails = a->tails_;
   for (StateIdContainer::const_iterator i = tails.begin(), e = tails.end(); i != e; ++i) {
     Sym const sym = outputLabel(*i);
     if (sym.isLexical()) return sym;
   }
   return NoSymbol;
 }
开发者ID:anibalanto,项目名称:hyp,代码行数:8,代码来源:IHypergraphStates.hpp

示例4: forStates

 void forStates(V const& v, bool lexical = true, bool unlabeled = true, bool notTerminal = true) const {
   // start first
   Self& hg = const_cast<Self&>(*this);
   for (StateId state = 0, N = size(); state < N; ++state) {
     Sym in = inputLabel(state);
     if (in == NoSymbol) {
       if (unlabeled) v(hg, state);
     } else if (in.isLexical()) {
       if (lexical) v(hg, state);
     } else if (!in.isSpecialTerminal())
       if (notTerminal) v(hg, state);
   }
 }
开发者ID:anibalanto,项目名称:hyp,代码行数:13,代码来源:IHypergraphStates.hpp

示例5: print

//TODO: it would be nice to put print in a .cpp somewhere since performance
//isn't critical. but we have no lib for the toplevel xmt/ headers.
inline void print(std::ostream &out, Sym sym, IVocabulary const* vocab
                  , char const* variablePrefix="X") {
  //TODO: consider always escaping for syntax rule formats (anything with
  //delimiters other than space, which we never allow inside tokens, etc)
  if (variablePrefix && sym.isVariable())
    out << "X" << sym.index();
  // some unit tests use vocabularies that don't set a variables vocab. if
  // that's fixed, we can remove the variablePrefix arg
  else if (vocab)
    out << vocab->str(sym); // if you want quotes + escaping, use Hypergraph/SymbolPrint.hpp
  else
    out << sym.getTypeNameShort() << sym.index();
}
开发者ID:graehl,项目名称:hyp,代码行数:15,代码来源:Syms.hpp

示例6: AssertMsg

PropertySym *
SymTable::FindPropertySym(SymID id) const
{
    Sym *   sym;

    sym = this->Find(id);

    if (sym)
    {
        AssertMsg(sym->IsPropertySym(), "Looking for PropertySym, found something else");
        return sym->AsPropertySym();
    }

    return NULL;
}
开发者ID:280185386,项目名称:ChakraCore,代码行数:15,代码来源:SymTable.cpp

示例7: get_addr_name

char* get_addr_name(Opnd addr_sym) {
  
  claim(is_addr_sym(addr_sym), "opnd.cpp::get_addr_name:the type must be addr_sym!");
  
  
  FormattedText ft;
  Sym *symbol = get_sym(addr_sym);
  symbol->print(ft);
  char* addr_name;
  
  addr_name =  (char*)(symbol->get_name()).c_str();
  
  return   addr_name;
  
}
开发者ID:JehandadKhan,项目名称:roccc-2.0,代码行数:15,代码来源:opnd.cpp

示例8: get_deref_type

  TypeId
get_deref_type(Opnd opnd)
{
  if (is_addr_sym(opnd)) {
    Sym *sym = get_sym(opnd);
    if (is_kind_of<LabelSym>(sym))
      return NULL;
    else {
      claim(is_kind_of<VarSym>(sym) || is_kind_of<ProcSym>(sym));
      return sym->get_type();
    }
  }
  claim(is_addr_exp(opnd));

  IrOpnd *o = opnd;
  return static_cast<OpndAddrExp*>(o)->get_deref_type();
}
开发者ID:JehandadKhan,项目名称:roccc-2.0,代码行数:17,代码来源:opnd.cpp

示例9: find_code

/* finds and inserts the full code in a hashmap */
HashMap::iterator find_code(Sym sym, HashMap& map) {
    HashMap::iterator result = map.find(sym);

    if (result == map.end()) { // new entry
	const SymVec& args = sym.args();
	vector<string> argstr(args.size());
	for (unsigned i = 0; i < args.size(); ++i) {
	    argstr[i] = find_code(args[i], map)->second;
	}

	// write out the code
	const FunDef& fun = get_element(sym.token());
	string code = fun.c_print(argstr, vector<string>());
	result = map.insert( make_pair(sym, code) ).first; // only want iterator
    }
    
    return result;
}
开发者ID:AdeleH,项目名称:paradiseo,代码行数:19,代码来源:sym_compile.cpp

示例10: insert_subtree_impl

std::pair<Sym,bool> insert_subtree_impl(const Sym& cur, size_t w, const Sym& nw) {
    if (w-- == 0) return make_pair(nw, !(nw == cur));
    
    const SymVec& vec = cur.args();
    std::pair<Sym,bool> result;
    unsigned i; 
    
    for (i = 0; i < vec.size(); ++i) {
	if (w < vec[i].size()) {
	    result = insert_subtree_impl(vec[i], w, nw);
	    if (result.second == false) return std::make_pair(cur, false); // unchanged
	    break;
	}
	w -= vec[i].size();
    }
    SymVec newvec = cur.args();
    newvec[i] = result.first;
    return make_pair(Sym(cur.token(), newvec), true);
}
开发者ID:AdeleH,项目名称:paradiseo,代码行数:19,代码来源:Sym.cpp

示例11: get_subtree

Sym get_subtree(const Sym& cur, size_t w) {
    if (w-- == 0) return cur;
    
    const SymVec& vec = cur.args();
    for (unsigned i = 0; i < vec.size(); ++i) {
	if (w < vec[i].size()) return get_subtree(vec[i], w);
	w-=vec[i].size();
    }
    return cur;
}
开发者ID:AdeleH,项目名称:paradiseo,代码行数:10,代码来源:Sym.cpp

示例12: find_entry

HashMap::iterator find_entry(const Sym& sym, string& str, HashMap& map) {
    HashMap::iterator result = map.find(sym);

    if (result == map.end()) { // new entry
	const SymVec& args = sym.args();
	
	vector<string> argstr(args.size());
	for (unsigned i = 0; i < args.size(); ++i) {
	    argstr[i] = find_entry(args[i], str, map)->second;
	}

	string var = make_var(map.size()); // map.size(): unique id
	string code;	
	// write out the code
	const FunDef& fun = get_element(sym.token());
	code = fun.c_print(argstr, vector<string>() );
	    
	str += "double " + var + "=" + code + ";\n";
	result = map.insert( make_pair(sym, var ) ).first; // only want iterator
    }
    
    return result;
}
开发者ID:AdeleH,项目名称:paradiseo,代码行数:23,代码来源:sym_compile.cpp

示例13: do_mutate

std::pair<Sym, bool> do_mutate(Sym sym, double p, const LanguageTable& table) {
    
    bool changed = false;
    SymVec args = sym.args();
    if (rng.flip(p)) {
	token_t new_token = table.get_random_function(sym.token(), args.size());
	if (new_token != sym.token()) {
	    changed = true;
	    sym = Sym(new_token, args);
	}
    }

    for (unsigned i = 0; i < args.size(); ++i) {
	std::pair<Sym,bool> r = do_mutate(args[i], p, table);	
	changed |= r.second;
	if (r.second) 
	    args[i] = r.first;
    }

    if (changed)
	return std::make_pair(Sym(sym.token(), args), true);
    // else
    return std::make_pair(sym, false);
}
开发者ID:AdeleH,项目名称:paradiseo,代码行数:24,代码来源:eoSymMutate.cpp

示例14:

Sym Sym::operator+(Sym &symbolic)
{
//    bool **comp;
//    comp = compSym(*this, symbolic);

   Sym ret;
   int max = this->rowSym;

   if(symbolic.rowSym > this->rowSym)
       max = symbolic.rowSym;

   ret.initSym(this->rowSym+symbolic.rowSym, max);

   for(int i = 0; i < ret.rowSym; i++)
       for(int j = 0; j < ret.colSym; j++)
       {
           if( i == this->rowSym)
               ret.var[i+this->rowSym-1][j] = symbolic.var[i-this->rowSym][j];
           else
               ret.var[i][j] = this->var[i][j];
       }

   return ret;
}
开发者ID:LuizPaulo21,项目名称:Multipoly,代码行数:24,代码来源:sym.cpp

示例15: handleKeyEvent

    bool handleKeyEvent (const Sym &s, bool pressed)
    {
        bool res = false;
        switch ( s.getKey() )
        {
        case Key_Escape: //Quit
            if (!pressed)
            {
                logger << nl << "Quit requested !" << std::endl;

                App::getInstance().requestTermination();
                res=true;
            }
            break;

        case Key_F5: //iconify
            if (pressed)
                App::getInstance().getDisplay().getWindow().iconify();
            res = true;
            break;

        case Key_F6: //FullScreen
            if (pressed)
            {
                App::getInstance().getDisplay().requestSize(640, 480);
                App::getInstance().getDisplay().requestBPP(App::getInstance().getDisplay().getRequestedBPP());
                App::getInstance().getDisplay().requestFullscreen(!App::getInstance().getDisplay().getScreenBuffer().getScreenInfo().isFullscreen());
            }
            res = true;
            break;

        default:
            res = false;
        }

        return res;
    }
开发者ID:asmodehn,项目名称:sdlut,代码行数:37,代码来源:sdluthelloworld.cpp


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