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


C++ Symbols类代码示例

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


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

示例1: moveToBottom

LogVars
ConstraintTree::expand (LogVar X)
{
  moveToBottom ({X});
  assert (isCountNormalized (X));
  CTNodes nodes = getNodesAtLevel (logVars_.size() - 1);
  unsigned nrSymbols = getConditionalCount (X);
  for (CTNodes::const_iterator it = nodes.begin();
       it != nodes.end(); ++ it) {
    Symbols symbols;
    const CTChilds& childs = (*it)->childs();
    for (CTChilds::const_iterator chIt = childs.begin();
         chIt != childs.end(); ++ chIt) {
      symbols.push_back ((*chIt)->symbol());
    }
    (*it)->removeAndDeleteAllChilds();
    CTNode* prev = *it;
    assert (symbols.size() == nrSymbols);
    for (size_t j = 0; j < nrSymbols; j++) {
      CTNode* newNode = new CTNode (symbols[j], (*it)->level() + j);
      prev->mergeSubtree (newNode);
      prev = newNode;
    }
  }
  LogVars newLvs;
  logVars_.pop_back();
  for (size_t i = 0; i < nrSymbols; i++) {
    logVars_.push_back (LogVar (logVarSet_.back() + 1));
    newLvs.push_back   (LogVar (logVarSet_.back() + 1));
    logVarSet_.insert  (LogVar (logVarSet_.back() + 1));
  }
  logVarSet_ -= X;
  return newLvs;
}
开发者ID:davidvaz,项目名称:yap-udi,代码行数:34,代码来源:ConstraintTree.cpp

示例2: Symbols

// This builds a reduced version of a graph, where there
// is only a new node if the number of non-array SYMBOLS
// in the descendents changes. For example (EXTRACT 0 1 n)
// will have the same "Symbols" node as n, because
// no new symbols are introduced.
Symbols* VariablesInExpression::getSymbol(const ASTNode& n) {
	if (symbol_graph.find(n.GetNodeNum()) != symbol_graph.end()) {
		return symbol_graph[n.GetNodeNum()];
	}

	Symbols* node;

	// Note we skip array variables. We never solve for them so
	// can ignore them.
	if (n.GetKind() == SYMBOL && n.GetIndexWidth() == 0) {
		node = new Symbols(n);
		insert(n, node);
		return node;
	}

	vector<Symbols*> children;
	for (size_t i = 0; i < n.Degree(); i++) {
		Symbols* v = getSymbol(n[i]);
		if (!v->empty())
			children.push_back(v);
	}

	if (children.size() == 1) {
		// If there is only a single child with a symbol. Then jump to it.
		node = children.back();
	} else
		node = new Symbols(children);

	insert(n, node);

	return node;
}
开发者ID:AmesianX,项目名称:stp,代码行数:37,代码来源:VariablesInExpression.cpp

示例3: cleaned

Symbols Preprocessor::preprocessed(const QByteArray &filename, QIODevice *file)
{
    QByteArray input = file->readAll();
    if (input.isEmpty())
        return symbols;

    // phase 1: get rid of backslash-newlines
    input = cleaned(input);

    // phase 2: tokenize for the preprocessor
    symbols = tokenize(input);

#if 0
    for (int j = 0; j < symbols.size(); ++j)
        fprintf(stderr, "line %d: %s(%s)\n",
                symbols[j].lineNum,
                symbols[j].lexem().constData(),
                tokenTypeName(symbols[j].token));
#endif

    // phase 3: preprocess conditions and substitute macros
    Symbols result;
    preprocess(filename, result);

#if 0
    for (int j = 0; j < result.size(); ++j)
        fprintf(stderr, "line %d: %s(%s)\n",
                result[j].lineNum,
                result[j].lexem().constData(),
                tokenTypeName(result[j].token));
#endif

    return result;
}
开发者ID:kaos,项目名称:QtErl,代码行数:34,代码来源:preprocessor.cpp

示例4: xl_enter_block

void xl_enter_block(Context *context, text name, native_fn fn, Tree *rtype,
                    text open, text type, text close,
                    text doc)
// ----------------------------------------------------------------------------
//    Enter a block into the context (called from .tbl files)
// ----------------------------------------------------------------------------
{
    Tree *parms = xl_parameter("c", type);
    Block *from = new Block(parms, open, close);
    Name *to = new Name(open + close);

    from = new Block(from, open, close); // Extra block removed by Define

    Rewrite *rw = context->Define(from, to);
    rw->native = (native_fn) fn;
    rw->type = rtype;

    Symbols *s = MAIN->globals;
    Rewrite *rw2 = s->EnterRewrite(from, to);
    rw2->type = rtype;
    to->code = fn;
    to->SetSymbols(s);
    xl_enter_builtin(MAIN, name, to, rw2->parameters, fn);

    xl_set_documentation(from, doc);
}
开发者ID:c3d,项目名称:XL-programming-language,代码行数:26,代码来源:opcodes.cpp

示例5: strlen

BOOL CALLBACK Symbols::SymEnumCallback(PSYMBOL_INFO pSymInfo, ULONG ulSymbolSize, PVOID pUserContext)
{
    UserContext *pContext = (UserContext *)pUserContext;
    Symbols *pThisPtr = (Symbols *)pContext->pThis;
    DWORD_PTR dwAddress = (DWORD_PTR)pSymInfo->Address;
    DWORD_PTR dwModBase = (DWORD_PTR)pSymInfo->ModBase;

    //fprintf(stderr, "Symbol found at %p. Name: %.*s. Base address of module: %p\n",
    //    dwAddress, pSymInfo->NameLen, pSymInfo->Name, dwModBase);

    bool bSuccess = false;
    SymbolInfo symbolInfo;
    symbolInfo.dwAddress = dwAddress;
    symbolInfo.strName = std::move(std::vector<char>(pSymInfo->Name, pSymInfo->Name + strlen(pSymInfo->Name)));
    symbolInfo.strName.emplace_back(0);

    IMAGEHLP_LINE64 lineInfo = pThisPtr->GetSymbolLineInfo(dwAddress, symbolInfo.dwDisplacement, bSuccess);
    if (bSuccess)
    {
        symbolInfo.dwLineNumber = lineInfo.LineNumber;
        symbolInfo.strSourceFile = std::move(std::vector<char>(lineInfo.FileName, lineInfo.FileName + strlen(lineInfo.FileName)));
        symbolInfo.strSourceFile.emplace_back(0);
    }

    ModuleSymbolInfo moduleSymbol;
    moduleSymbol.dwModuleBaseAddress = dwModBase;
    moduleSymbol.strName = std::move(std::vector<char>(pContext->pName, pContext->pName + strlen(pContext->pName)));
    moduleSymbol.strName.emplace_back(0);
    moduleSymbol.symbolInfo = std::move(symbolInfo);

    pThisPtr->m_mapSymbols.insert(std::make_pair(dwModBase, std::move(moduleSymbol)));

    return TRUE;
}
开发者ID:codereversing,项目名称:debugger,代码行数:34,代码来源:Symbols.cpp

示例6: foreach

void PdbEngine::refreshSymbols(const GdbMi &symbols)
{
    QString moduleName = symbols["module"].toUtf8();
    Symbols syms;
    foreach (const GdbMi &item, symbols["symbols"].children()) {
        Symbol symbol;
        symbol.name = item["name"].toUtf8();
        syms.append(symbol);
    }
    Internal::showModuleSymbols(moduleName, syms);
}
开发者ID:kowalikm,项目名称:qt-creator,代码行数:11,代码来源:pdbengine.cpp

示例7:

bool Wll1Loader::EncountRemark(Symbols& remark)
{
    if(this->input_pos >= this->input_symbols.size()) return false;
    Symbols symbol = this->GetSymbol();
    if(symbol.IsRemark())
    {
        remark = symbol;
        return true;
    }
    else
    {
        return false;
    }
}
开发者ID:wllxyz,项目名称:xyz,代码行数:14,代码来源:Wll1Loader.cpp

示例8: parseDefineArguments

void Preprocessor::parseDefineArguments(Macro *m)
{
    Symbols arguments;
    while (hasNext()) {
        while (test(PP_WHITESPACE)) {}
        Token t = next();
        if (t == PP_RPAREN)
            break;
        if (t != PP_IDENTIFIER) {
            QByteArray l = lexem();
            if (l == "...") {
                m->isVariadic = true;
                arguments += Symbol(symbol().lineNum, PP_IDENTIFIER, "__VA_ARGS__");
                while (test(PP_WHITESPACE)) {}
                if (!test(PP_RPAREN))
                    error("missing ')' in macro argument list");
                break;
            } else if (!is_identifier(l.constData(), l.length())) {
                qDebug() << l;
                error("Unexpected character in macro argument list.");
            }
        }

        Symbol arg = symbol();
        if (arguments.contains(arg))
            error("Duplicate macro parameter.");
        arguments += symbol();

        while (test(PP_WHITESPACE)) {}
        t = next();
        if (t == PP_RPAREN)
            break;
        if (t == PP_COMMA)
            continue;
        if (lexem() == "...") {
            //GCC extension:    #define FOO(x, y...) x(y)
            // The last argument was already parsed. Just mark the macro as variadic.
            m->isVariadic = true;
            while (test(PP_WHITESPACE)) {}
            if (!test(PP_RPAREN))
                error("missing ')' in macro argument list");
            break;
        }
        error("Unexpected character in macro argument list.");
    }
    m->arguments = arguments;
    while (test(PP_WHITESPACE)) {}
}
开发者ID:kaos,项目名称:QtErl,代码行数:48,代码来源:preprocessor.cpp

示例9: checkArity

void FloatArityFunction::checkArity(const Symbols &args) const
{
    unsigned argsNum = args.size();
    if (arity() > argsNum)
    {
        throw MinArityError(arity(), argsNum);
    }
}
开发者ID:newmen,项目名称:micro-scheme,代码行数:8,代码来源:float_arity_function.cpp

示例10: xl_enter_prefix

void xl_enter_prefix(Context *context, text name, native_fn fn, Tree *rtype,
                     TreeList &parameters, text symbol, text doc)
// ----------------------------------------------------------------------------
//   Enter a prefix into the context (called from .tbl files)
// ----------------------------------------------------------------------------
{
    if (parameters.size())
    {
        Tree *parmtree = xl_parameters_tree(parameters);
        Prefix *from = new Prefix(new Name(symbol), parmtree);
        Name *to = new Name(symbol);

        Rewrite *rw = context->Define(from, to);
        rw->native = fn;
        rw->type = rtype;

        Symbols *s = MAIN->globals;
        Rewrite *rw2 = s->EnterRewrite(from, to);
        rw2->type = rtype;
        to->code = fn;
        to->SetSymbols(s);
        xl_enter_builtin(MAIN, name, to, rw2->parameters, fn);

        xl_set_documentation(from, doc);
    }
    else
    {
        Name *n  = new Name(symbol);
        n->SetInfo<PrefixDefinitionsInfo>(new PrefixDefinitionsInfo());
        Rewrite *rw = context->Define(n, n);
        rw->native = fn;
        rw->type = rtype;

        Symbols *s = MAIN->globals;
        Rewrite *rw2 = s->EnterName(symbol, n, Rewrite::GLOBAL);
        rw2->type = rtype;
        n->code = fn;
        n->SetSymbols(s);
        TreeList noparms;
        xl_enter_builtin(MAIN, name, n, noparms, fn);

        xl_set_documentation(n, doc);
    }
}
开发者ID:c3d,项目名称:XL-programming-language,代码行数:44,代码来源:opcodes.cpp

示例11: TEST

	TEST(Symbol, Test){
		Symbols symbols;
		Scanner::Plugins::Symbol sym(symbols);

		symbols.init();
		Scanner::StringCharacterWell mcw_1("string"), mcw_2("$4518"), mcw_3("+"), mcw_4("++"), mcw_5("+++"), mcw_6("==="), mcw_7("[]ll");

		CHECK(sym.type() == Scanner::TokenType::TOKEN_TYPE_SYMBOL);

		CHECK(!sym.matches(mcw_1));
		CHECK(sym.get(mcw_1) == Scanner::Token(Scanner::TokenType::TOKEN_TYPE_NONE, ""));
		mcw_1.commit();
		CHECK(mcw_1.dump() == "string");

		CHECK(!sym.matches(mcw_2));
		CHECK(sym.get(mcw_2) == Scanner::Token(Scanner::TokenType::TOKEN_TYPE_NONE, ""));
		mcw_2.commit();
		CHECK(mcw_2.dump() == "$4518");

		CHECK(sym.matches(mcw_3));
		CHECK(sym.get(mcw_3) == Scanner::Token(Scanner::TokenType::TOKEN_TYPE_SYMBOL, "+"));
		mcw_3.commit();
		CHECK(mcw_3.dump() == "");

		CHECK(sym.matches(mcw_4));
		CHECK(sym.get(mcw_4) == Scanner::Token(Scanner::TokenType::TOKEN_TYPE_SYMBOL, "++"));
		mcw_4.commit();
		CHECK(mcw_4.dump() == "");

		CHECK(sym.matches(mcw_5));
		CHECK(sym.get(mcw_5) == Scanner::Token(Scanner::TokenType::TOKEN_TYPE_SYMBOL, "++"));
		mcw_5.commit();
		CHECK(mcw_5.dump() == "+");

		CHECK(sym.matches(mcw_6));
		CHECK(sym.get(mcw_6) == Scanner::Token(Scanner::TokenType::TOKEN_TYPE_SYMBOL, "==="));
		mcw_6.commit();
		CHECK(mcw_6.dump() == "");

		CHECK(sym.matches(mcw_7));
		CHECK(sym.get(mcw_7) == Scanner::Token(Scanner::TokenType::TOKEN_TYPE_SYMBOL, "[]"));
		mcw_7.commit();
		CHECK(mcw_7.dump() == "ll");
	}
开发者ID:benbraide,项目名称:StructuredScript,代码行数:44,代码来源:SymbolTest.cpp

示例12: readLiftedEvidence

void
readLiftedEvidence (
    YAP_Term observedList,
    ObservedFormulas& obsFormulas)
{
  while (observedList != YAP_TermNil()) {
    YAP_Term pair = YAP_HeadOfTerm (observedList);
    YAP_Term ground = YAP_ArgOfTerm (1, pair);
    Symbol functor;
    Symbols args;
    if (YAP_IsAtomTerm (ground)) {
      string name ((char*) YAP_AtomName (YAP_AtomOfTerm (ground)));
      functor = LiftedUtils::getSymbol (name);
    } else {
      assert (YAP_IsApplTerm (ground));
      YAP_Functor yapFunctor = YAP_FunctorOfTerm (ground);
      string name ((char*) (YAP_AtomName (YAP_NameOfFunctor (yapFunctor))));
      functor = LiftedUtils::getSymbol (name);
      unsigned arity = (unsigned) YAP_ArityOfFunctor (yapFunctor);
      for (unsigned i = 1; i <= arity; i++) {
        YAP_Term ti = YAP_ArgOfTerm (i, ground);
        assert (YAP_IsAtomTerm (ti));
        string arg ((char *) YAP_AtomName (YAP_AtomOfTerm (ti)));
        args.push_back (LiftedUtils::getSymbol (arg));
      }
    }
    unsigned evidence = (unsigned) YAP_IntOfTerm (YAP_ArgOfTerm (2, pair));
    bool found = false;
    for (size_t i = 0; i < obsFormulas.size(); i++) {
      if (obsFormulas[i].functor()  == functor &&
          obsFormulas[i].arity()    == args.size() &&
          obsFormulas[i].evidence() == evidence) {
        obsFormulas[i].addTuple (args);
        found = true;
      }
    }
    if (found == false) {
      obsFormulas.push_back (ObservedFormula (functor, evidence, args));
    }
    observedList = YAP_TailOfTerm (observedList);
  } 
}
开发者ID:davidvaz,项目名称:yap-cmake,代码行数:42,代码来源:HorusYap.cpp

示例13: xl_enter_form

void xl_enter_form(Context *context, text name, native_fn fn,
                   Tree *rtype, text form, TreeList &parameters,
                   text doc)
// ----------------------------------------------------------------------------
//    Enter an arbitrary form in the symbol table
// ----------------------------------------------------------------------------
{
    Tree *from = xl_parse_text(form);
    Name *to = new Name(name);

    Rewrite *rw = context->Define(from, to);
    rw->native = fn;
    rw->type = rtype;

    Symbols *s = MAIN->globals;
    Rewrite *rw2 = s->EnterRewrite(from, to);
    rw2->type = rtype;
    to->code = fn;
    to->SetSymbols(s);
    xl_enter_builtin(MAIN, name, to, rw2->parameters, fn);

    ulong sz = parameters.size();
    if (sz != rw2->parameters.size())
    {
        std::cerr << "WARNING: Internal error on parameter count for "
                  << name << "\n"
                  << "         " << form << "\n";
        ulong sz2 = rw2->parameters.size();
        for (ulong i = 0; i < sz || i < sz2; i++)
        {
            std::cerr << "  #" << i << ": ";
            if (i < sz)
                std::cerr << "spec(" << parameters[i] << ") ";
            if (i < sz2)
                std::cerr << "form(" << rw2->parameters[i] << ") ";
            std::cerr << "\n";
        }
    }

    xl_set_documentation(from, doc);
}
开发者ID:c3d,项目名称:XL-programming-language,代码行数:41,代码来源:opcodes.cpp

示例14: xl_enter_postfix

void xl_enter_postfix(Context *context, text name, native_fn fn, Tree *rtype,
                      TreeList &parameters, text symbol, text doc)
// ----------------------------------------------------------------------------
//   Enter a postfdix into the context (called from .tbl files)
// ----------------------------------------------------------------------------
{
    Tree *parmtree = xl_parameters_tree(parameters);
    Postfix *from = new Postfix(parmtree, new Name(symbol));
    Name *to = new Name(symbol);

    Rewrite *rw = context->Define(from, to);
    rw->native = (native_fn) fn;
    rw->type = rtype;

    Symbols *s = MAIN->globals;
    Rewrite *rw2 = s->EnterRewrite(from, to);
    rw2->type = rtype;
    to->code = fn;
    to->SetSymbols(s);
    xl_enter_builtin(MAIN, name, to, rw2->parameters, fn);

    xl_set_documentation(from, doc);
}
开发者ID:c3d,项目名称:XL-programming-language,代码行数:23,代码来源:opcodes.cpp

示例15: macroExpandIdentifier

Symbols Preprocessor::macroExpand(Preprocessor *that, Symbols &toExpand, int &index, int lineNum, bool one)
{
    SymbolStack symbols;
    SafeSymbols sf;
    sf.symbols = toExpand;
    sf.index = index;
    symbols.push(sf);

    Symbols result;
    if (toExpand.isEmpty())
        return result;

    for (;;) {
        QByteArray macro;
        Symbols newSyms = macroExpandIdentifier(that, symbols, lineNum, &macro);

        if (macro.isEmpty()) {
            result += newSyms;
        } else {
            SafeSymbols sf;
            sf.symbols = newSyms;
            sf.index = 0;
            sf.expandedMacro = macro;
            symbols.push(sf);
        }
        if (!symbols.hasNext() || (one && symbols.size() == 1))
            break;
        symbols.next();
    }

    if (symbols.size())
        index = symbols.top().index;
    else
        index = toExpand.size();

    return result;
}
开发者ID:kaos,项目名称:QtErl,代码行数:37,代码来源:preprocessor.cpp


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