您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ toChars函数代码示例

51自学网 2021-06-03 08:52:51
  C++
这篇教程C++ toChars函数代码示例写得很实用,希望能帮到您。

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

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

示例1: printf

Expression *FuncDeclaration::interpret(InterState *istate, Expressions *arguments){#if LOG    printf("/n********/nFuncDeclaration::interpret(istate = %p) %s/n", istate, toChars());    printf("cantInterpret = %d, semanticRun = %d/n", cantInterpret, semanticRun);#endif    if (global.errors)	return NULL;    if (ident == Id::aaLen)	return interpret_aaLen(istate, arguments);    else if (ident == Id::aaKeys)	return interpret_aaKeys(istate, arguments);    else if (ident == Id::aaValues)	return interpret_aaValues(istate, arguments);    if (cantInterpret || semanticRun == 1)	return NULL;    if (needThis() || isNested() || !fbody)    {	cantInterpret = 1;	return NULL;    }    if (semanticRun == 0 && scope)    {	semantic3(scope);	if (global.errors)	// if errors compiling this function	    return NULL;    }    if (semanticRun < 2)	return NULL;    Type *tb = type->toBasetype();    assert(tb->ty == Tfunction);    TypeFunction *tf = (TypeFunction *)tb;    Type *tret = tf->next->toBasetype();    if (tf->varargs /*|| tret->ty == Tvoid*/)    {	cantInterpret = 1;	return NULL;    }    if (tf->parameters)    {	size_t dim = Argument::dim(tf->parameters);	for (size_t i = 0; i < dim; i++)	{   Argument *arg = Argument::getNth(tf->parameters, i);	    if (arg->storageClass & STClazy)	    {   cantInterpret = 1;		return NULL;	    }	}    }    InterState istatex;    istatex.caller = istate;    istatex.fd = this;    Expressions vsave;		// place to save previous parameter values    size_t dim = 0;    if (arguments)    {	dim = arguments->dim;	assert(!dim || parameters->dim == dim);	vsave.setDim(dim);	/* Evaluate all the arguments to the function,	 * store the results in eargs[]	 */	Expressions eargs;	eargs.setDim(dim);	for (size_t i = 0; i < dim; i++)	{   Expression *earg = (Expression *)arguments->data[i];	    Argument *arg = Argument::getNth(tf->parameters, i);	    if (arg->storageClass & (STCout | STCref))	    {	    }	    else	    {	/* Value parameters		 */		Type *ta = arg->type->toBasetype();		if (ta->ty == Tsarray && earg->op == TOKaddress)		{		    /* Static arrays are passed by a simple pointer.		     * Skip past this to get at the actual arg.		     */		    earg = ((AddrExp *)earg)->e1;		}		earg = earg->interpret(istate ? istate : &istatex);		if (earg == EXP_CANT_INTERPRET)		    return NULL;	    }	    eargs.data[i] = earg;	}	for (size_t i = 0; i < dim; i++)	{   Expression *earg = (Expression *)eargs.data[i];	    Argument *arg = Argument::getNth(tf->parameters, i);	    VarDeclaration *v = (VarDeclaration *)parameters->data[i];	    vsave.data[i] = v->value;//.........这里部分代码省略.........
开发者ID:apriori,项目名称:dsss,代码行数:101,


示例2: toCBuffer

void Dsymbol::toCBuffer(OutBuffer *buf, HdrGenState *hgs){    buf->writestring(toChars());}
开发者ID:DinrusGroup,项目名称:DRC,代码行数:4,


示例3: switch

unsigned Type::totym(){   unsigned t;    switch (ty)    {        case Tvoid:     t = TYvoid;     break;        case Tint8:     t = TYschar;    break;        case Tuns8:     t = TYuchar;    break;        case Tint16:    t = TYshort;    break;        case Tuns16:    t = TYushort;   break;        case Tint32:    t = TYint;      break;        case Tuns32:    t = TYuint;     break;        case Tint64:    t = TYllong;    break;        case Tuns64:    t = TYullong;   break;        case Tfloat32:  t = TYfloat;    break;        case Tfloat64:  t = TYdouble;   break;        case Tfloat80:  t = TYldouble;  break;        case Timaginary32: t = TYifloat; break;        case Timaginary64: t = TYidouble; break;        case Timaginary80: t = TYildouble; break;        case Tcomplex32: t = TYcfloat;  break;        case Tcomplex64: t = TYcdouble; break;        case Tcomplex80: t = TYcldouble; break;        case Tbool:     t = TYbool;     break;        case Tchar:     t = TYchar;     break;#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS        case Twchar:    t = TYwchar_t;  break;        case Tdchar:    t = TYdchar;    break;#else        case Twchar:    t = TYwchar_t;  break;        case Tdchar:                t = (global.params.symdebug == 1) ? TYdchar : TYulong;                break;#endif        case Taarray:   t = TYaarray;   break;        case Tclass:        case Treference:        case Tpointer:  t = TYnptr;     break;        case Tdelegate: t = TYdelegate; break;        case Tarray:    t = TYdarray;   break;#if SARRAYVALUE        case Tsarray:   t = TYstruct;   break;#else        case Tsarray:   t = TYarray;    break;#endif        case Tstruct:   t = TYstruct;   break;        case Tenum:        case Ttypedef:             t = toBasetype()->totym();             break;        case Tident:        case Ttypeof:#ifdef DEBUG            printf("ty = %d, '%s'/n", ty, toChars());#endif            error(0, "forward reference of %s", toChars());            t = TYint;            break;        default:#ifdef DEBUG            printf("ty = %d, '%s'/n", ty, toChars());            halt();#endif            assert(0);    }#if DMDV2    // Add modifiers    switch (mod)    {        case 0:            break;        case MODconst:        case MODwild:            t |= mTYconst;            break;        case MODimmutable:            t |= mTYimmutable;            break;        case MODshared:            t |= mTYshared;            break;        case MODshared | MODwild:        case MODshared | MODconst:            t |= mTYshared | mTYconst;            break;        default:            assert(0);    }#endif    return t;}
开发者ID:Rayerd,项目名称:dmd,代码行数:97,


示例4: printf

Expression *TraitsExp::semantic(Scope *sc){#if LOGSEMANTIC    printf("TraitsExp::semantic() %s/n", toChars());#endif    if (ident != Id::compiles && ident != Id::isSame &&        ident != Id::identifier && ident != Id::getProtection)    {        TemplateInstance::semanticTiargs(loc, sc, args, 1);    }    size_t dim = args ? args->dim : 0;    Declaration *d;    if (ident == Id::isArithmetic)    {        return isTypeX(&isTypeArithmetic);    }    else if (ident == Id::isFloating)    {        return isTypeX(&isTypeFloating);    }    else if (ident == Id::isIntegral)    {        return isTypeX(&isTypeIntegral);    }    else if (ident == Id::isScalar)    {        return isTypeX(&isTypeScalar);    }    else if (ident == Id::isUnsigned)    {        return isTypeX(&isTypeUnsigned);    }    else if (ident == Id::isAssociativeArray)    {        return isTypeX(&isTypeAssociativeArray);    }    else if (ident == Id::isStaticArray)    {        return isTypeX(&isTypeStaticArray);    }    else if (ident == Id::isAbstractClass)    {        return isTypeX(&isTypeAbstractClass);    }    else if (ident == Id::isFinalClass)    {        return isTypeX(&isTypeFinalClass);    }    else if (ident == Id::isPOD)    {        if (dim != 1)            goto Ldimerror;        RootObject *o = (*args)[0];        Type *t = isType(o);        StructDeclaration *sd;        if (!t)        {            error("type expected as second argument of __traits %s instead of %s", ident->toChars(), o->toChars());            goto Lfalse;        }        if (t->toBasetype()->ty == Tstruct              && ((sd = (StructDeclaration *)(((TypeStruct *)t->toBasetype())->sym)) != NULL))        {            if (sd->isPOD())                goto Ltrue;            else                goto Lfalse;        }        goto Ltrue;    }    else if (ident == Id::isNested)    {        if (dim != 1)            goto Ldimerror;        RootObject *o = (*args)[0];        Dsymbol *s = getDsymbol(o);        AggregateDeclaration *a;        FuncDeclaration *f;        if (!s) { }        else if ((a = s->isAggregateDeclaration()) != NULL)        {            if (a->isNested())                goto Ltrue;            else                goto Lfalse;        }        else if ((f = s->isFuncDeclaration()) != NULL)        {            if (f->isNested())                goto Ltrue;            else                goto Lfalse;        }        error("aggregate or function expected instead of '%s'", o->toChars());        goto Lfalse;    }    else if (ident == Id::isAbstractFunction)//.........这里部分代码省略.........
开发者ID:jacob-carlborg,项目名称:dmd,代码行数:101,


示例5: printf

void ClassDeclaration::toDt2(dt_t **pdt, ClassDeclaration *cd){    unsigned offset;    dt_t *dt;    unsigned csymoffset;#define LOG 0#if LOG    printf("ClassDeclaration::toDt2(this = '%s', cd = '%s')/n", toChars(), cd->toChars());#endif    if (baseClass)    {        baseClass->toDt2(pdt, cd);        offset = baseClass->structsize;    }    else    {        offset = Target::ptrsize * 2;    }    // Note equivalence of this loop to struct's    for (size_t i = 0; i < fields.dim; i++)    {        VarDeclaration *v = fields[i];        Initializer *init;        //printf("/t/tv = '%s' v->offset = %2d, offset = %2d/n", v->toChars(), v->offset, offset);        dt = NULL;        init = v->init;        if (init)        {   //printf("/t/t%s has initializer %s/n", v->toChars(), init->toChars());            ExpInitializer *ei = init->isExpInitializer();            Type *tb = v->type->toBasetype();            if (init->isVoidInitializer())                ;            else if (ei && tb->ty == Tsarray)                ((TypeSArray *)tb)->toDtElem(&dt, ei->exp);            else                dt = init->toDt();        }        else if (v->offset >= offset)        {   //printf("/t/tdefault initializer/n");            v->type->toDt(&dt);        }        if (dt)        {            if (v->offset < offset)                error("duplicated union initialization for %s", v->toChars());            else            {                if (offset < v->offset)                    dtnzeros(pdt, v->offset - offset);                dtcat(pdt, dt);                offset = v->offset + v->type->size();            }        }    }    // Interface vptr initializations    toSymbol();                                         // define csym    for (size_t i = 0; i < vtblInterfaces->dim; i++)    {   BaseClass *b = (*vtblInterfaces)[i];        for (ClassDeclaration *cd2 = cd; 1; cd2 = cd2->baseClass)        {            assert(cd2);            csymoffset = cd2->baseVtblOffset(b);            if (csymoffset != ~0)            {                if (offset < b->offset)                    dtnzeros(pdt, b->offset - offset);                dtxoff(pdt, cd2->toSymbol(), csymoffset);                break;            }        }        offset = b->offset + Target::ptrsize;    }    if (offset < structsize)        dtnzeros(pdt, structsize - offset);#undef LOG}
开发者ID:dymk,项目名称:dmd,代码行数:85,


示例6: printf

Expression *TraitsExp::semantic(Scope *sc){#if LOGSEMANTIC    printf("TraitsExp::semantic() %s/n", toChars());#endif    if (ident != Id::compiles && ident != Id::isSame)	TemplateInstance::semanticTiargs(loc, sc, args, 1);    size_t dim = args ? args->dim : 0;    Object *o;    FuncDeclaration *f;#define ISTYPE(cond) /	for (size_t i = 0; i < dim; i++)	/	{   Type *t = getType((Object *)args->data[i]);	/	    if (!t)				/		goto Lfalse;			/	    if (!(cond))			/		goto Lfalse;			/	}					/	if (!dim)				/	    goto Lfalse;			/	goto Ltrue;#define ISDSYMBOL(cond) /	for (size_t i = 0; i < dim; i++)	/	{   Dsymbol *s = getDsymbol((Object *)args->data[i]);	/	    if (!s)				/		goto Lfalse;			/	    if (!(cond))			/		goto Lfalse;			/	}					/	if (!dim)				/	    goto Lfalse;			/	goto Ltrue;    if (ident == Id::isArithmetic)    {	ISTYPE(t->isintegral() || t->isfloating())    }    else if (ident == Id::isFloating)    {	ISTYPE(t->isfloating())    }    else if (ident == Id::isIntegral)    {	ISTYPE(t->isintegral())    }    else if (ident == Id::isScalar)    {	ISTYPE(t->isscalar())    }    else if (ident == Id::isUnsigned)    {	ISTYPE(t->isunsigned())    }    else if (ident == Id::isAssociativeArray)    {	ISTYPE(t->toBasetype()->ty == Taarray)    }    else if (ident == Id::isStaticArray)    {	ISTYPE(t->toBasetype()->ty == Tsarray)    }    else if (ident == Id::isAbstractClass)    {	ISTYPE(t->toBasetype()->ty == Tclass && ((TypeClass *)t->toBasetype())->sym->isAbstract())    }    else if (ident == Id::isFinalClass)    {	ISTYPE(t->toBasetype()->ty == Tclass && ((TypeClass *)t->toBasetype())->sym->storage_class & STCfinal)    }    else if (ident == Id::isAbstractFunction)    {	ISDSYMBOL((f = s->isFuncDeclaration()) != NULL && f->isAbstract())    }    else if (ident == Id::isVirtualFunction)    {	ISDSYMBOL((f = s->isFuncDeclaration()) != NULL && f->isVirtual())    }    else if (ident == Id::isFinalFunction)    {	ISDSYMBOL((f = s->isFuncDeclaration()) != NULL && f->isFinal())    }    else if (ident == Id::hasMember ||	     ident == Id::getMember ||	     ident == Id::getVirtualFunctions)    {	if (dim != 2)	    goto Ldimerror;	Object *o = (Object *)args->data[0];	Expression *e = isExpression((Object *)args->data[1]);	if (!e)	{   // error("expression expected as second argument of __traits %s", ident->toChars());	    goto Lfalse;	}	e = e->optimize(WANTvalue | WANTinterpret);	if (e->op != TOKstring)	{   // error("string expected as second argument of __traits %s instead of %s", ident->toChars(), e->toChars());//.........这里部分代码省略.........
开发者ID:apriori,项目名称:dsss,代码行数:101,


示例7: toChars

llvm::Module* Module::genLLVMModule(llvm::LLVMContext& context){    bool logenabled = Logger::enabled();    if (llvmForceLogging && !logenabled)    {        Logger::enable();    }    IF_LOG Logger::println("Generating module: %s", (md ? md->toChars() : toChars()));    LOG_SCOPE;    if (global.params.verbose_cg)        printf("codegen: %s (%s)/n", toPrettyChars(), srcfile->toChars());    if (global.errors)    {        Logger::println("Aborting because of errors");        fatal();    }    // name the module#if 1    // Temporary workaround for http://llvm.org/bugs/show_bug.cgi?id=11479 
C++ toDouble函数代码示例
C++ toCallExpr函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。