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


C++ OutBuffer::writeByte方法代码示例

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


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

示例1: visit

    void visit(TypeFunction *t)
    {
        /*
         *  <function-type> ::= F [Y] <bare-function-type> E
         *  <bare-function-type> ::= <signature type>+
         *  # types are possible return type, then parameter types
         */

        /* ABI says:
            "The type of a non-static member function is considered to be different,
            for the purposes of substitution, from the type of a namespace-scope or
            static member function whose type appears similar. The types of two
            non-static member functions are considered to be different, for the
            purposes of substitution, if the functions are members of different
            classes. In other words, for the purposes of substitution, the class of
            which the function is a member is considered part of the type of
            function."

            BUG: Right now, types of functions are never merged, so our simplistic
            component matcher always finds them to be different.
            We should use Type::equals on these, and use different
            TypeFunctions for non-static member functions, and non-static
            member functions of different classes.
         */
        if (substitute(t))
            return;
        buf.writeByte('F');
        if (t->linkage == LINKc)
            buf.writeByte('Y');
        t->next->accept(this);
        argsCppMangle(t->parameters, t->varargs);
        buf.writeByte('E');
        store(t);
    }
开发者ID:Arpit007,项目名称:GDC,代码行数:34,代码来源:cppmangle.c

示例2: Module

Module *Module::load(Loc loc, Identifiers *packages, Identifier *ident)
{
    //printf("Module::load(ident = '%s')\n", ident->toChars());

    // Build module filename by turning:
    //  foo.bar.baz
    // into:
    //  foo\bar\baz
    char *filename = ident->toChars();
    if (packages && packages->dim)
    {
        OutBuffer buf;

        for (size_t i = 0; i < packages->dim; i++)
        {   Identifier *pid = (*packages)[i];

            buf.writestring(pid->toChars());
#if _WIN32
            buf.writeByte('\\');
#else
            buf.writeByte('/');
#endif
        }
        buf.writestring(filename);
        buf.writeByte(0);
        filename = (char *)buf.extractData();
    }

    Module *m = new Module(filename, ident, 0, 0);
    m->loc = loc;

    /* Look for the source file
     */
    const char *result = lookForSourceFile(filename);
    if (result)
        m->srcfile = new File(result);

    if (!m->read(loc))
        return NULL;

    if (global.params.verbose)
    {
        fprintf(global.stdmsg, "import    ");
        if (packages)
        {
            for (size_t i = 0; i < packages->dim; i++)
            {
                Identifier *pid = (*packages)[i];
                fprintf(global.stdmsg, "%s.", pid->toChars());
            }
        }
        fprintf(global.stdmsg, "%s\t(%s)\n", ident->toChars(), m->srcfile->toChars());
    }

    m->parse();

    Target::loadModule(m);

    return m;
}
开发者ID:CyberShadow,项目名称:dmd,代码行数:60,代码来源:module.c

示例3: cpp_mangle_name

    void cpp_mangle_name(Dsymbol *s)
    {
        Dsymbol *p = s->toParent();
        if (p && !p->isModule())
        {
            buf.writeByte('N');

            FuncDeclaration *fd = s->isFuncDeclaration();
            VarDeclaration *vd = s->isVarDeclaration();
            if (fd && fd->type->isConst())
            {
                buf.writeByte('K');
            }
            if (vd && !(vd->storage_class & (STCextern | STCgshared)))
            {
                s->error("C++ static non- __gshared non-extern variables not supported");
            }
            if (vd || fd)
            {
                prefix_name(p);
                source_name(s);
            }
            else
            {
                assert(0);
            }
            buf.writeByte('E');
        }
        else
            source_name(s);
    }
开发者ID:Arpit007,项目名称:GDC,代码行数:31,代码来源:cppmangle.c

示例4: mangle_variable

    void mangle_variable(VarDeclaration *d, bool is_temp_arg_ref)
    {

        if (!(d->storage_class & (STCextern | STCgshared)))
        {
            d->error("ICE: C++ static non- __gshared non-extern variables not supported");
            assert(0);
        }

        Dsymbol *p = d->toParent();
        if (p && !p->isModule()) //for example: char Namespace1::beta[6] should be mangled as "_ZN10Namespace14betaE"
        {
            buf.writestring(global.params.isOSX ? "__ZN" : "_ZN");      // "__Z" for OSX, "_Z" for other
            prefix_name(p);
            source_name(d);
            buf.writeByte('E');
        }
        else //char beta[6] should mangle as "beta"
        {
            if (!is_temp_arg_ref)
            {
                if (global.params.isOSX)
                    buf.writeByte('_');
                buf.writestring(d->ident->toChars());
            }
            else
            {
                buf.writestring(global.params.isOSX ? "__Z" : "_Z");
                source_name(d);
            }
        }
    }
开发者ID:yeswalrus,项目名称:dmd,代码行数:32,代码来源:cppmangle.c

示例5: ErrorExp

Expression *BinExp::arrayOp(Scope *sc)
{
    //printf("BinExp::arrayOp() %s\n", toChars());

    Type *tb = type->toBasetype();
    assert(tb->ty == Tarray || tb->ty == Tsarray);
    if (tb->nextOf()->toBasetype()->ty == Tvoid)
    {
        error("Cannot perform array operations on void[] arrays");
        return new ErrorExp();
    }

    if (!isArrayOpValid(e2))
    {
        e2->error("invalid array operation %s (did you forget a [] ?)", toChars());
        return new ErrorExp();
    }

    Expressions *arguments = new Expressions();

    /* The expression to generate an array operation for is mangled
     * into a name to use as the array operation function name.
     * Mangle in the operands and operators in RPN order, and type.
     */
    OutBuffer buf;
    buf.writestring("_array");
    buildArrayIdent(&buf, arguments);
    buf.writeByte('_');

    /* Append deco of array element type
     */
#if DMDV2
    buf.writestring(type->toBasetype()->nextOf()->toBasetype()->mutableOf()->deco);
#else
    buf.writestring(type->toBasetype()->nextOf()->toBasetype()->deco);
#endif

    buf.writeByte(0);
    char *name = buf.toChars();
    Identifier *ident = Lexer::idPool(name);

#if IN_LLVM
    ArrayOp **pOp = (ArrayOp **)_aaGet(&sc->module->arrayfuncs, ident);
#else
    ArrayOp **pOp = (ArrayOp **)_aaGet(&arrayfuncs, ident);
#endif
    ArrayOp *op = *pOp;

    if (!op)
        op = buildArrayOp(ident, this, sc, loc);

    *pOp = op;

    FuncDeclaration *fd = op->cFunc ? op->cFunc : op->dFunc;
    Expression *ec = new VarExp(loc, fd);
    Expression *e = new CallExp(loc, ec, arguments);

    return e->semantic(sc);
}
开发者ID:AlexeyProkhin,项目名称:ldc,代码行数:59,代码来源:arrayop.c

示例6: assert

const char *ProtDeclaration::toPrettyChars(bool)
{
    assert(protection.kind > PROTundefined);

    OutBuffer buf;
    buf.writeByte('\'');
    protectionToBuffer(&buf, protection);
    buf.writeByte('\'');
    return buf.extractString();
}
开发者ID:NativeAPI,项目名称:dmd,代码行数:10,代码来源:attrib.c

示例7: if

 void writeBase36(size_t i)
 {
     if (i >= 36)
     {
         writeBase36(i / 36);
         i %= 36;
     }
     if (i < 10)
         buf.writeByte((char)(i + '0'));
     else if (i < 36)
         buf.writeByte((char)(i - 10 + 'A'));
     else
         assert(0);
 }
开发者ID:yeswalrus,项目名称:dmd,代码行数:14,代码来源:cppmangle.c

示例8: visit

    void visit(TypePointer *t)
    {
        if (substitute(t)) return;
        if (t->isImmutable() || t->isShared())
        {
            visit((Type *)t);
        }
        if (t->isConst())
            buf.writeByte('K');
        buf.writeByte('P');
        t->next->accept(this);
        store(t);


    }
开发者ID:yeswalrus,项目名称:dmd,代码行数:15,代码来源:cppmangle.c

示例9: indent

void JsonOut::indent()
{
    if (buf->offset >= 1 &&
        buf->data[buf->offset - 1] == '\n')
        for (int i = 0; i < indentLevel; i++)
            buf->writeByte(' ');
}
开发者ID:1100110,项目名称:dmd,代码行数:7,代码来源:json.c

示例10: memset

char *cpp_mangle(Dsymbol *s)
{
    /*
     * <mangled-name> ::= _Z <encoding>
     * <encoding> ::= <function name> <bare-function-type>
     *         ::= <data name>
     *         ::= <special-name>
     */

    CppMangleState cms;
    memset(&cms, 0, sizeof(cms));
    cms.components.setDim(0);

    OutBuffer buf;
#if MACHOBJ
    buf.writestring("__Z");
#else
    buf.writestring("_Z");
#endif

    cpp_mangle_name(&buf, &cms, s);

    FuncDeclaration *fd = s->isFuncDeclaration();
    if (fd)
    {   // add <bare-function-type>
        TypeFunction *tf = (TypeFunction *)fd->type;
        assert(tf->ty == Tfunction);
        Parameter::argsCppMangle(&buf, &cms, tf->parameters, tf->varargs);
    }
    buf.writeByte(0);
    return (char *)buf.extractData();
}
开发者ID:MessiahAndrw,项目名称:dmd,代码行数:32,代码来源:cppmangle.c

示例11: substitute

 int substitute(RootObject *p)
 {
     for (size_t i = 0; i < components.dim; i++)
     {
         if (p == components[i])
         {
             /* Sequence is S_, S0_, .., S9_, SA_, ..., SZ_, S10_, ...
              */
             buf.writeByte('S');
             if (i)
                 writeBase36(i - 1);
             buf.writeByte('_');
             return 1;
         }
     }
     return 0;
 }
开发者ID:yeswalrus,项目名称:dmd,代码行数:17,代码来源:cppmangle.c

示例12: mangle

char *mangle(Declaration *sthis)
{
    OutBuffer buf;
    char *id;
    Dsymbol *s;

    //printf("::mangle(%s)\n", sthis->toChars());
    s = sthis;
    do
    {
        //printf("mangle: s = %p, '%s', parent = %p\n", s, s->toChars(), s->parent);
        if (s->ident)
        {
            FuncDeclaration *fd = s->isFuncDeclaration();
            if (s != sthis && fd)
            {
                id = mangle(fd);
                buf.prependstring(id);
                goto L1;
            }
            else
            {
                id = s->ident->toChars();
                int len = strlen(id);
                char tmp[sizeof(len) * 3 + 1];
                buf.prependstring(id);
                sprintf(tmp, "%d", len);
                buf.prependstring(tmp);
            }
        }
        else
            buf.prependstring("0");
        s = s->parent;
    } while (s);

//    buf.prependstring("_D");
L1:
    //printf("deco = '%s'\n", sthis->type->deco ? sthis->type->deco : "null");
    //printf("sthis->type = %s\n", sthis->type->toChars());
    FuncDeclaration *fd = sthis->isFuncDeclaration();
    if (fd && (fd->needThis() || fd->isNested()))
        buf.writeByte(Type::needThisPrefix());
    if (sthis->type->deco)
        buf.writestring(sthis->type->deco);
    else
    {
#ifdef DEBUG
        if (!fd->inferRetType)
            printf("%s\n", fd->toChars());
#endif
        assert(fd && fd->inferRetType);
    }

    id = buf.toChars();
    buf.data = NULL;
    return id;
}
开发者ID:smunix,项目名称:ldc,代码行数:57,代码来源:mangle.c

示例13: argsCppMangle

    void argsCppMangle(Parameters *arguments, int varargs)
    {
        if (arguments)
            Parameter::foreach(arguments, &argsCppMangleDg, (void*)this);

        if (varargs)
            buf.writestring("z");
        else if (!arguments || !arguments->dim)
            buf.writeByte('v');            // encode ( ) arguments
    }
开发者ID:yeswalrus,项目名称:dmd,代码行数:10,代码来源:cppmangle.c

示例14: mangle_function

    void mangle_function(FuncDeclaration *d)
    {
        /*
         * <mangled-name> ::= _Z <encoding>
         * <encoding> ::= <function name> <bare-function-type>
         *         ::= <data name>
         *         ::= <special-name>
         */
        TypeFunction *tf = (TypeFunction *)d->type;

        buf.writestring(global.params.isOSX ? "__Z" : "_Z");      // "__Z" for OSX, "_Z" for other
        Dsymbol *p = d->toParent();
        if (p && !p->isModule() && tf->linkage == LINKcpp)
        {
            buf.writeByte('N');
            if (d->type->isConst())
                buf.writeByte('K');
            prefix_name(p);
            if (d->isDtorDeclaration())
            {
                buf.writestring("D1");
            }
            else
            {
                source_name(d);
            }
            buf.writeByte('E');
        }
        else
        {
            source_name(d);
        }

        if (tf->linkage == LINKcpp) //Template args accept extern "C" symbols with special mangling
        {
            assert(tf->ty == Tfunction);
            argsCppMangle(tf->parameters, tf->varargs);
        }
    }
开发者ID:yeswalrus,项目名称:dmd,代码行数:39,代码来源:cppmangle.c

示例15: argsCppMangle

 void argsCppMangle(Parameters *arguments, int varargs)
 {
     size_t n = 0;
     if (arguments)
     {
         ArgsCppMangleCtx ctx = { this, 0 };
         Parameter::foreach(arguments, &argsCppMangleDg, &ctx);
         n = ctx.cnt;
     }
     if (varargs)
         buf.writestring("z");
     else if (!n)
         buf.writeByte('v');            // encode ( ) arguments
 }
开发者ID:Arpit007,项目名称:GDC,代码行数:14,代码来源:cppmangle.c


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