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

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

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

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

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

示例1: listv

void JoinStrFunc::execute() {  ComValue listv(stack_arg(0));  static int sym_symid = symbol_add("sym");  ComValue symflagv(stack_key(sym_symid));  boolean symflag = symflagv.is_true();  reset_stack();  if (listv.is_array()) {    AttributeValueList* avl = listv.array_val();    if (avl) {      char cbuf[avl->Number()+1];      Iterator i;      int cnt=0;      for (avl->First(i); !avl->Done(i); avl->Next(i)) {	cbuf[cnt] = avl->GetAttrVal(i)->char_val();	cnt++;      }      cbuf[cnt] = '/0';    ComValue retval(symbol_add(cbuf), symflag ? ComValue::SymbolType : ComValue::StringType);    push_stack(retval);    return;    }  }  push_stack(ComValue::nullval());}
开发者ID:barak,项目名称:ivtools-cvs,代码行数:26,


示例2: nteh_declarvars

void nteh_declarvars(Blockx *bx){   symbol *s;#if MARS    if (!(bx->funcsym->Sfunc->Fflags3 & Fnteh)) // if haven't already done it    {   bx->funcsym->Sfunc->Fflags3 |= Fnteh;        s = symbol_name(s_name_context,SCbprel,tsint);        s->Soffset = -5 * 4;            // -6 * 4 for C __try, __except, __finally        s->Sflags |= SFLfree | SFLnodebug;        type_setty(&s->Stype,mTYvolatile | TYint);        symbol_add(s);        bx->context = s;    }#else    if (!(funcsym_p->Sfunc->Fflags3 & Fnteh))   // if haven't already done it    {   funcsym_p->Sfunc->Fflags3 |= Fnteh;        if (!s_context)            s_context = scope_search(s_name_context_tag,CPP ? SCTglobal : SCTglobaltag);        symbol_debug(s_context);        s = symbol_name(s_name_context,SCbprel,s_context->Stype);        s->Soffset = -6 * 4;            // -5 * 4 for C++        s->Sflags |= SFLfree;        symbol_add(s);        type_setty(&s->Stype,mTYvolatile | TYstruct);        s = symbol_name(s_name_ecode,SCauto,type_alloc(mTYvolatile | TYint));        s->Sflags |= SFLfree;        symbol_add(s);    }#endif}
开发者ID:spott,项目名称:dmd,代码行数:32,


示例3: symbol_add

void WhileFunc::execute() {    static int body_symid = symbol_add("body");    static int until_symid = symbol_add("until");    static int nilchk_symid = symbol_add("nilchk");    ComValue untilflag(stack_key_post_eval(until_symid));    ComValue nilchkflag(stack_key_post_eval(nilchk_symid));    ComValue* bodyexpr = nil;    while (1) {        if (untilflag.is_false()) {            ComValue doneexpr(stack_arg_post_eval(0));            if (nilchkflag.is_false() ? doneexpr.is_false() : doneexpr.is_unknown()) break;        }        delete bodyexpr;        ComValue keybody(stack_key_post_eval(body_symid, false, ComValue::unkval(), true));        if (keybody.is_unknown() && nargsfixed()>= 2)            bodyexpr = new ComValue(stack_arg_post_eval(1));        else            bodyexpr = new ComValue(keybody);        if (untilflag.is_true()) {            ComValue doneexpr(stack_arg_post_eval(0));            if (nilchkflag.is_false() ? doneexpr.is_true() : doneexpr.is_unknown()) break;        }    }    reset_stack();    if (bodyexpr) {        push_stack(*bodyexpr);        delete bodyexpr;    } else        push_stack(ComValue::nullval());}
开发者ID:steinarb,项目名称:interviews,代码行数:30,


示例4: booltest

void IfThenElseFunc::execute() {    ComValue booltest(stack_arg_post_eval(0));    static int then_symid = symbol_add("then");    static int else_symid = symbol_add("else");    ComValue retval(booltest.is_true()                    ? stack_key_post_eval(then_symid)                    : stack_key_post_eval(else_symid));    reset_stack();    push_stack(retval);}
开发者ID:steinarb,项目名称:interviews,代码行数:10,


示例5: visit

    void visit(WithStatement *s)    {        Symbol *sp;        elem *e;        elem *ei;        ExpInitializer *ie;        Blockx *blx = irs->blx;        //printf("WithStatement::toIR()/n");        if (s->exp->op == TOKimport || s->exp->op == TOKtype)        {        }        else        {            // Declare with handle            sp = toSymbol(s->wthis);            symbol_add(sp);            // Perform initialization of with handle            ie = s->wthis->_init->isExpInitializer();            assert(ie);            ei = toElemDtor(ie->exp, irs);            e = el_var(sp);            e = el_bin(OPeq,e->Ety, e, ei);            elem_setLoc(e, s->loc);            incUsage(irs, s->loc);            block_appendexp(blx->curblock,e);        }        // Execute with block        if (s->_body)            Statement_toIR(s->_body, irs);    }
开发者ID:Faianca,项目名称:dmd,代码行数:32,


示例6: symbol_add

Attribute::Attribute(const char* name, AttributeValue* value) {    if (name)	symbolid = symbol_add((char *)name);    else	symbolid = -1;    valueptr = value;}
开发者ID:jmzaleski,项目名称:ivtools-1.2,代码行数:7,


示例7: symbol_add

Transformer* CreateGraphicFunc::get_transformer(AttributeList* al) {  static int transform_symid = symbol_add("transform");  AttributeValue* transformv = nil;  Transformer* rel = nil;  AttributeValueList* avl = nil;  if (al &&       (transformv=al->find(transform_symid)) &&       transformv->is_array() &&       (avl=transformv->array_val()) &&      avl->Number()==6) {    float a00, a01, a10, a11, a20, a21;    Iterator it;    avl->First(it); a00=avl->GetAttrVal(it)->float_val();    avl->Next(it); a01=avl->GetAttrVal(it)->float_val();    avl->Next(it); a10=avl->GetAttrVal(it)->float_val();    avl->Next(it); a11=avl->GetAttrVal(it)->float_val();    avl->Next(it); a20=avl->GetAttrVal(it)->float_val();    avl->Next(it); a21=avl->GetAttrVal(it)->float_val();    rel = new Transformer(a00, a01, a10, a11, a20, a21);  } else {    rel = ((OverlayViewer*)_ed->GetViewer())->GetRel();    if (rel != nil) {      rel = new Transformer(rel);      rel->Invert();    }  }  return rel;  }
开发者ID:jmzaleski,项目名称:ivtools-1.2,代码行数:30,


示例8: stack_arg

void CreateOpenSplineFunc::execute() {    ComValue& vect = stack_arg(0);    if (!vect.is_type(ComValue::ArrayType) || vect.array_len()==0) {        reset_stack();	push_stack(ComValue::nullval());	return;    }    const int len = vect.array_len();    const int npts = len/2;    int x[npts];    int y[npts];    ALIterator i;    AttributeValueList* avl = vect.array_val();    avl->First(i);    for (int j=0; j<npts && !avl->Done(i); j++) {        x[j] = avl->GetAttrVal(i)->int_val();	avl->Next(i);        y[j] = avl->GetAttrVal(i)->int_val();	avl->Next(i);    }    AttributeList* al = stack_keys();    Resource::ref(al);    reset_stack();    PasteCmd* cmd = nil;    if (npts) {	BrushVar* brVar = (BrushVar*) _ed->GetState("BrushVar");	PatternVar* patVar = (PatternVar*) _ed->GetState("PatternVar");	ColorVar* colVar = (ColorVar*) _ed->GetState("ColorVar");        Transformer* rel = get_transformer(al);	ArrowVar* aVar = (ArrowVar*) _ed->GetState("ArrowVar");	ArrowOpenBSpline* openspline = new ArrowOpenBSpline(x, y, npts, aVar->Head(), aVar->Tail(), 					_ed->GetViewer()->GetMagnification(), stdgraphic);	if (brVar != nil) openspline->SetBrush(brVar->GetBrush());	if (patVar != nil) openspline->SetPattern(patVar->GetPattern());	if (colVar != nil) {	    openspline->FillBg(!colVar->GetBgColor()->None());	    openspline->SetColors(colVar->GetFgColor(), colVar->GetBgColor());            }	openspline->SetTransformer(rel);	Unref(rel);	ArrowSplineOvComp* comp = new ArrowSplineOvComp(openspline);	comp->SetAttributeList(al);	if (PasteModeFunc::paste_mode()==0)	  cmd = new PasteCmd(_ed, new Clipboard(comp));	ComValue compval(new OverlayViewRef(comp), symbol_add("ArrowSplineComp"));	push_stack(compval);	execute_log(cmd);    } else 	push_stack(ComValue::nullval());    Unref(al);}
开发者ID:jmzaleski,项目名称:ivtools-1.2,代码行数:60,


示例9: switch

void Module::genhelpers(bool iscomdat){    // If module assert    for (int i = 0; i < 3; i++)    {        Symbol *ma;        unsigned rt;        unsigned bc;        switch (i)        {            case 0:     ma = marray;    rt = RTLSYM_DARRAY;     bc = BCexit; break;            case 1:     ma = massert;   rt = RTLSYM_DASSERT;    bc = BCexit; break;            case 2:     ma = munittest; rt = RTLSYM_DUNITTEST;  bc = BCret;  break;            default:    assert(0);        }        if (ma)        {            elem *elinnum;            localgot = NULL;            // Call dassert(filename, line)            // Get sole parameter, linnum            {                Symbol *sp = symbol_calloc("linnum");                sp->Stype = type_fake(TYint);                sp->Stype->Tcount++;                sp->Sclass = (config.exe == EX_WIN64) ? SCshadowreg : SCfastpar;                FuncParamRegs fpr(TYjfunc);                fpr.alloc(sp->Stype, sp->Stype->Tty, &sp->Spreg, &sp->Spreg2);                sp->Sflags &= ~SFLspill;                sp->Sfl = (sp->Sclass == SCshadowreg) ? FLpara : FLfast;                cstate.CSpsymtab = &ma->Sfunc->Flocsym;                symbol_add(sp);                elinnum = el_var(sp);            }            elem *efilename = toEfilename(this);            elem *e = el_var(rtlsym[rt]);            e = el_bin(OPcall, TYvoid, e, el_param(elinnum, efilename));            block *b = block_calloc();            b->BC = bc;            b->Belem = e;            ma->Sfunc->Fstartline.Sfilename = arg;            ma->Sfunc->Fstartblock = b;            ma->Sclass = iscomdat ? SCcomdat : SCglobal;            ma->Sfl = 0;            ma->Sflags |= rtlsym[rt]->Sflags & SFLexit;            writefunc(ma);        }    }}
开发者ID:abhishekkumar-,项目名称:dmd,代码行数:59,


示例10: mystate

void IfStatement::toIR(IRState *irs){    elem *e;    Blockx *blx = irs->blx;    //printf("IfStatement::toIR('%s')/n", condition->toChars());    IRState mystate(irs, this);    // bexit is the block that gets control after this IfStatement is done    block *bexit = mystate.breakBlock ? mystate.breakBlock : block_calloc();    incUsage(irs, loc);#if 0    if (match)    {   /* Generate:         *  if (match = RTLSYM_IFMATCH(string, pattern)) ...         */        assert(condition->op == TOKmatch);        e = matchexp_toelem((MatchExp *)condition, &mystate, RTLSYM_IFMATCH);        Symbol *s = match->toSymbol();        symbol_add(s);        e = el_bin(OPeq, TYnptr, el_var(s), e);    }    else#endif        e = condition->toElemDtor(&mystate);    block_appendexp(blx->curblock, e);    block *bcond = blx->curblock;    block_next(blx, BCiftrue, NULL);    list_append(&bcond->Bsucc, blx->curblock);    if (ifbody)        ifbody->toIR(&mystate);    list_append(&blx->curblock->Bsucc, bexit);    if (elsebody)    {        block_next(blx, BCgoto, NULL);        list_append(&bcond->Bsucc, blx->curblock);        elsebody->toIR(&mystate);        list_append(&blx->curblock->Bsucc, bexit);    }    else        list_append(&bcond->Bsucc, bexit);    block_next(blx, BCgoto, bexit);}
开发者ID:Rayerd,项目名称:dmd,代码行数:49,


示例11: gram_ADDTOSYMBOL

void gram_ADDTOSYMBOL(){    register char *name;    char *text;    parser_push_fun("ADDTOSYMBOL");    name = parser_name_parlist(&parser,  true);    text = parser_parlist(&parser, COLLECT_SET);    symbol_add(hashmap_find(&symtab, name, SYMBOL), text);    if (message_show(MSG_NOTICE))        message("ADDTOSYMBOL tos(%s) += /"%s/"",  name, string_short(text));    parser_pop_fun();    free(text);    free(name);}
开发者ID:Distrotech,项目名称:yodl,代码行数:17,


示例12: check_for_label

//donechar* check_for_label (char* token) {  if(util_get_opcode (token) == -1){		//if it is then is it a vaild label?		    if(util_is_valid_label(token)){			//if it is a vaild label add that shit			//return the next token broski      //fprintf(stderr, "adding symbol: %s/n",token);      if(symbol_add(lc3_sym_tab,token,currAddr) == 0){        asm_error(ERR_DUPLICATE_LABEL,token);      }      return next_token();    }	else{      //damn that shit anint wokring right    asm_error(ERR_BAD_LABEL,token);    }		  }  return token;}
开发者ID:davedennis,项目名称:LC3-Assembler,代码行数:20,


示例13: convertv

void GrStreamFunc::execute() {  ComValue convertv(stack_arg_post_eval(0));    if (convertv.object_compview()) {    reset_stack();        static StreamNextFunc* snfunc = nil;    if (!snfunc) {      snfunc = new StreamNextFunc(comterp());      snfunc->funcid(symbol_add("stream"));    }    AttributeValueList* avl = new AttributeValueList();    Component* comp = ((ComponentView*)convertv.obj_val())->GetSubject();    if (!comp->IsA(OVERLAYS_COMP)) {      push_stack(ComValue::nullval());      return;    }    OverlaysComp* ovcomps = (OverlaysComp*)comp;    Iterator it;    for(ovcomps->First(it); !ovcomps->Done(it); ovcomps->Next(it)) {      OverlayComp* subcomp = (OverlayComp*) ovcomps->GetComp(it);      AttributeValue* av =         new AttributeValue(new OverlayViewRef(subcomp), subcomp->classid());      avl->Append(av);    }    ComValue stream(snfunc, avl);    stream.stream_mode(-1); // for internal use (use by this func)    push_stack(stream);      } else {        StreamFunc strmfunc(comterp());    strmfunc.exec(funcstate()->nargs(), funcstate()->nkeys(), pedepth());    return;      }  }
开发者ID:jmzaleski,项目名称:ivtools-1.2,代码行数:39,


示例14: obj_initfile

//.........这里部分代码省略.........#endif	}	if (edtor)	{	    localgot = NULL;	    sdtor = toSymbolX("__moddtor", SCglobal, t, moddeco);	    block *b = block_calloc();	    b->BC = BCret;	    b->Belem = edtor;	    sdtor->Sfunc->Fstartblock = b;	    writefunc(sdtor);	}	if (etest)	{	    localgot = NULL;	    stest = toSymbolX("__modtest", SCglobal, t, moddeco);	    block *b = block_calloc();	    b->BC = BCret;	    b->Belem = etest;	    stest->Sfunc->Fstartblock = b;	    writefunc(stest);	}	if (doppelganger)	    genmoduleinfo();    }    if (doppelganger)    {	obj_termfile();	return;    }    if (global.params.multiobj)    {	/* This is necessary because the main .obj for this module is written	 * first, but determining whether marray or massert are needed is done	 * possibly later in the doppelganger modules.	 * Another way to fix it is do the main one last.	 */	toModuleAssert();	toModuleArray();    }    // If module assert    for (int i = 0; i < 2; i++)    {	Symbol *ma = i ? marray : massert;	if (ma)	{	    elem *elinnum;	    elem *efilename;	    localgot = NULL;	    // Call dassert(filename, line)	    // Get sole parameter, linnum	    {		Symbol *sp;		sp = symbol_calloc("linnum");		sp->Stype = type_fake(TYint);		sp->Stype->Tcount++;		sp->Sclass = SCfastpar;		sp->Spreg = AX;		sp->Sflags &= ~SFLspill;		sp->Sfl = FLpara;	// FLauto?		cstate.CSpsymtab = &ma->Sfunc->Flocsym;		symbol_add(sp);		elinnum = el_var(sp);	    }	    efilename = toEmodulename();	    elem *e = el_var(rtlsym[i ? RTLSYM_DARRAY : RTLSYM_DASSERT]);	    e = el_bin(OPcall, TYvoid, e, el_param(elinnum, efilename));	    block *b = block_calloc();	    b->BC = BCret;	    b->Belem = e;	    ma->Sfunc->Fstartblock = b;	    ma->Sclass = SCglobal;	    ma->Sfl = 0;	    writefunc(ma);	}    }#if 1    // Always generate module info, because of templates and -cov    if (1 || needModuleInfo())	genmoduleinfo();#endif        obj_termfile();}
开发者ID:Geod24,项目名称:dnet,代码行数:101,


示例15: FuncDeclaration_toObjFile

//.........这里部分代码省略.........        pi++;    }    if (sthis)    {#if 0        // sthis becomes last parameter        params[pi] = sthis;#else        // sthis becomes first parameter        memmove(params + 1, params, pi * sizeof(params[0]));        params[0] = sthis;#endif        pi++;    }    if ((global.params.isLinux || global.params.isOSX || global.params.isFreeBSD || global.params.isSolaris) &&         fd->linkage != LINKd && shidden && sthis)    {        /* swap shidden and sthis         */        Symbol *sp = params[0];        params[0] = params[1];        params[1] = sp;    }    for (size_t i = 0; i < pi; i++)    {        Symbol *sp = params[i];        sp->Sclass = SCparameter;        sp->Sflags &= ~SFLspill;        sp->Sfl = FLpara;        symbol_add(sp);    }    // Determine register assignments    if (pi)    {        FuncParamRegs fpr(tyf);        for (size_t i = 0; i < pi; i++)        {            Symbol *sp = params[i];            if (fpr.alloc(sp->Stype, sp->Stype->Tty, &sp->Spreg, &sp->Spreg2))            {                sp->Sclass = (config.exe == EX_WIN64) ? SCshadowreg : SCfastpar;                sp->Sfl = (sp->Sclass == SCshadowreg) ? FLpara : FLfast;            }        }    }    // Done with params    if (params != paramsbuf)        free(params);    params = NULL;    if (fd->fbody)    {        localgot = NULL;        Statement *sbody = fd->fbody;        Blockx bx;        memset(&bx,0,sizeof(bx));        bx.startblock = block_calloc();
开发者ID:AlexBezzubenko,项目名称:dmd,代码行数:67,


示例16: toPrettyChars

//.........这里部分代码省略.........            b->Belem = eictor;            sictor->Sfunc->Fstartline.Sfilename = arg;            sictor->Sfunc->Fstartblock = b;            writefunc(sictor);        }        sctor = callFuncsAndGates(this, &sctors, &ectorgates, "__modctor");        sdtor = callFuncsAndGates(this, &sdtors, NULL, "__moddtor");#if DMDV2        ssharedctor = callFuncsAndGates(this, &ssharedctors, (StaticDtorDeclarations *)&esharedctorgates, "__modsharedctor");        sshareddtor = callFuncsAndGates(this, &sshareddtors, NULL, "__modshareddtor");#endif        stest = callFuncsAndGates(this, &stests, NULL, "__modtest");        if (doppelganger)            genmoduleinfo();    }    if (doppelganger)    {        objmod->termfile();        return;    }    if (global.params.multiobj)    {   /* This is necessary because the main .obj for this module is written         * first, but determining whether marray or massert or munittest are needed is done         * possibly later in the doppelganger modules.         * Another way to fix it is do the main one last.         */        toModuleAssert();        toModuleUnittest();        toModuleArray();    }    /* Always generate module info, because of templates and -cov.     * But module info needs the runtime library, so disable it for betterC.     */    if (!global.params.betterC /*|| needModuleInfo()*/)        genmoduleinfo();    // If module assert    for (int i = 0; i < 3; i++)    {        Symbol *ma;        unsigned rt;        unsigned bc;        switch (i)        {            case 0:     ma = marray;    rt = RTLSYM_DARRAY;     bc = BCexit; break;            case 1:     ma = massert;   rt = RTLSYM_DASSERTM;   bc = BCexit; break;            case 2:     ma = munittest; rt = RTLSYM_DUNITTESTM; bc = BCret;  break;            default:    assert(0);        }        if (ma)        {            elem *elinnum;            localgot = NULL;            // Call dassert(filename, line)            // Get sole parameter, linnum            {                Symbol *sp = symbol_calloc("linnum");                sp->Stype = type_fake(TYint);                sp->Stype->Tcount++;                sp->Sclass = (config.exe == EX_WIN64) ? SCshadowreg : SCfastpar;                FuncParamRegs fpr(TYjfunc);                fpr.alloc(sp->Stype, sp->Stype->Tty, &sp->Spreg, &sp->Spreg2);                sp->Sflags &= ~SFLspill;                sp->Sfl = (sp->Sclass == SCshadowreg) ? FLpara : FLfast;                cstate.CSpsymtab = &ma->Sfunc->Flocsym;                symbol_add(sp);                elinnum = el_var(sp);            }            elem *efilename = el_ptr(toSymbol());            elem *e = el_var(rtlsym[rt]);            e = el_bin(OPcall, TYvoid, e, el_param(elinnum, efilename));            block *b = block_calloc();            b->BC = bc;            b->Belem = e;            ma->Sfunc->Fstartline.Sfilename = arg;            ma->Sfunc->Fstartblock = b;            ma->Sclass = SCglobal;            ma->Sfl = 0;            ma->Sflags |= rtlsym[rt]->Sflags & SFLexit;            writefunc(ma);        }    }    objmod->termfile();}
开发者ID:alexrp,项目名称:dmd,代码行数:101,


示例17: buildClosure

/************************************* * Closures are implemented by taking the local variables that * need to survive the scope of the function, and copying them * into a gc allocated chuck of memory. That chunk, called the * closure here, is inserted into the linked list of stack * frames instead of the usual stack frame. * * buildClosure() inserts code just after the function prolog * is complete. It allocates memory for the closure, allocates * a local variable (sclosure) to point to it, inserts into it * the link to the enclosing frame, and copies into it the parameters * that are referred to in nested functions. * In VarExp::toElem and SymOffExp::toElem, when referring to a * variable that is in a closure, takes the offset from sclosure rather * than from the frame pointer. * * getEthis() and NewExp::toElem need to use sclosure, if set, rather * than the current frame pointer. */void buildClosure(FuncDeclaration *fd, IRState *irs){    if (fd->needsClosure())    {        // Generate closure on the heap        // BUG: doesn't capture variadic arguments passed to this function        /* BUG: doesn't handle destructors for the local variables.         * The way to do it is to make the closure variables the fields         * of a class object:         *    class Closure {         *        vtbl[]         *        monitor         *        ptr to destructor         *        sthis         *        ... closure variables ...         *        ~this() { call destructor }         *    }         */        //printf("FuncDeclaration::buildClosure() %s/n", toChars());        /* Generate type name for closure struct */        const char *name1 = "CLOSURE.";        const char *name2 = fd->toPrettyChars();        size_t namesize = strlen(name1)+strlen(name2)+1;        char *closname = (char *) calloc(namesize, sizeof(char));        strcat(strcat(closname, name1), name2);        /* Build type for closure */        type *Closstru = type_struct_class(closname, Target::ptrsize, 0, NULL, NULL, false, false, true);        symbol_struct_addField(Closstru->Ttag, "__chain", Type_toCtype(Type::tvoidptr), 0);        Symbol *sclosure;        sclosure = symbol_name("__closptr", SCauto, type_pointer(Closstru));        sclosure->Sflags |= SFLtrue | SFLfree;        symbol_add(sclosure);        irs->sclosure = sclosure;        unsigned offset = Target::ptrsize;      // leave room for previous sthis        for (size_t i = 0; i < fd->closureVars.dim; i++)        {            VarDeclaration *v = fd->closureVars[i];            //printf("closure var %s/n", v->toChars());            assert(v->isVarDeclaration());            if (v->needsAutoDtor())            {                /* Because the value needs to survive the end of the scope!                 */                v->error("has scoped destruction, cannot build closure");            }            if (v->isargptr)            {                /* See Bugzilla 2479                 * This is actually a bug, but better to produce a nice                 * message at compile time rather than memory corruption at runtime                 */                v->error("cannot reference variadic arguments from closure");            }            /* Align and allocate space for v in the closure             * just like AggregateDeclaration::addField() does.             */            unsigned memsize;            unsigned memalignsize;            structalign_t xalign;            if (v->storage_class & STClazy)            {                /* Lazy variables are really delegates,                 * so give same answers that TypeDelegate would                 */                memsize = Target::ptrsize * 2;                memalignsize = memsize;                xalign = STRUCTALIGN_DEFAULT;            }            else if (ISWIN64REF(v))            {                memsize = v->type->size();                memalignsize = v->type->alignsize();                xalign = v->alignment;            }            else if (ISREF(v, NULL))//.........这里部分代码省略.........
开发者ID:joakim-brannstrom,项目名称:dmd,代码行数:101,


示例18: obj_append

//.........这里部分代码省略.........#endif	pi++;    }    if (sthis)    {#if 0	// sthis becomes last parameter	params[pi] = sthis;#else	// sthis becomes first parameter	memmove(params + 1, params, pi * sizeof(params[0]));	params[0] = sthis;#endif	pi++;    }    if ((global.params.isLinux || global.params.isOSX || global.params.isFreeBSD || global.params.isSolaris) &&	 linkage != LINKd && shidden && sthis)    {	/* swap shidden and sthis	 */	Symbol *sp = params[0];	params[0] = params[1];	params[1] = sp;    }    for (i = 0; i < pi; i++)    {	Symbol *sp = params[i];	sp->Sclass = SCparameter;	sp->Sflags &= ~SFLspill;	sp->Sfl = FLpara;	symbol_add(sp);    }    // First parameter goes in register    if (pi)    {	Symbol *sp = params[0];	if ((tyf == TYjfunc || tyf == TYmfunc) &&	    type_jparam(sp->Stype))	{   sp->Sclass = SCfastpar;	    sp->Spreg = (tyf == TYjfunc) ? AX : CX;	    sp->Sfl = FLauto;	    //printf("'%s' is SCfastpar/n",sp->Sident);	}    }    if (func->fbody)    {   block *b;	Blockx bx;	Statement *sbody;	localgot = NULL;	sbody = func->fbody;	memset(&bx,0,sizeof(bx));	bx.startblock = block_calloc();	bx.curblock = bx.startblock;	bx.funcsym = s;	bx.scope_index = -1;	bx.classdec = cd;	bx.member = func;	bx.module = getModule();	irs.blx = &bx;
开发者ID:Geod24,项目名称:dnet,代码行数:67,


示例19: main

/** Entry point of the program * @param argc count of arguments, will always be at least 1 * @param argv array of parameters to program argv[0] is the name of * the program, so additional parameters will begin at index 1. * @return 0 the Linux convention for success. */int main (int argc, char* argv[]) {  char line[MAX_LINE_LENGTH];  int  count, addr;  char *cmd, *name;  sym_table_t* symTab;  if (argc != 2)    usage();  symTab = symbol_init(atoi(argv[1]));  while (fgets(line, sizeof(line), stdin) != NULL) {    char *cr = strchr(line ,'/n'); /* get rid of trailing /n, if any */    if (cr)      *cr = '/0';    cmd = strtok(line, delim);    if (! cmd)      continue;    if (strcmp(cmd, "add") == 0) {      name = nextToken();      addr = nextInt();      printf("%s/n", (symbol_add(symTab, name, addr) ? "OK" : "Duplicate"));    }    else if (strcmp(cmd, "count") == 0) {      count = 0;      symbol_iterate(symTab, countSymbols, &count);      printf("symbol count: %d/n", count);    }    else if ((strcmp(cmd, "exit") == 0) || (strcmp(cmd, "quit") == 0)) {      break;    }    else if (strcmp(cmd, "get") == 0) {      name = nextToken();      printResult(symbol_find_by_name(symTab, name), stdout);    }    else if (strcmp(cmd, "help") == 0) {      help();    }    else if (strcmp(cmd, "label") == 0) {      addr = nextInt();      printf("label at addr %d '%s'/n", addr,             symbol_find_by_addr(symTab, addr));    }    else if (strcmp(cmd, "list") == 0) {      symbol_iterate(symTab, printResult, stdout);    }    else if (strcmp(cmd, "reset") == 0) {      symbol_reset(symTab);    }    else if (strcmp(cmd, "search") == 0) {      int hash, index;      name              = nextToken();      struct node* node = symbol_search(symTab, name, &hash, &index);      printf("symbol '%s' hash: %d index: %d is %s in symbol table/n", name,             hash, index, (node ? "" : "NOT"));    }    else {      help();    }  }  symbol_term(symTab); /* can check for memory leaks now */  return 0;}
开发者ID:MetalBurning,项目名称:CS_Files,代码行数:75,


示例20: symbol_name

void FuncDeclaration::buildClosure(IRState *irs){    if (needsClosure())    {   // Generate closure on the heap        // BUG: doesn't capture variadic arguments passed to this function#if DMDV2        /* BUG: doesn't handle destructors for the local variables.         * The way to do it is to make the closure variables the fields         * of a class object:         *    class Closure         *    {   vtbl[]         *        monitor         *        ptr to destructor         *        sthis         *        ... closure variables ...         *        ~this() { call destructor }         *    }         */#endif        //printf("FuncDeclaration::buildClosure()/n");        Symbol *sclosure;        sclosure = symbol_name("__closptr",SCauto,Type::tvoidptr->toCtype());        sclosure->Sflags |= SFLtrue | SFLfree;        symbol_add(sclosure);        irs->sclosure = sclosure;        unsigned offset = PTRSIZE;      // leave room for previous sthis        for (size_t i = 0; i < closureVars.dim; i++)        {   VarDeclaration *v = closureVars[i];            assert(v->isVarDeclaration());#if DMDV2            if (v->needsAutoDtor())                /* Because the value needs to survive the end of the scope!                 */                v->error("has scoped destruction, cannot build closure");            if (v->isargptr)                /* See Bugzilla 2479                 * This is actually a bug, but better to produce a nice                 * message at compile time rather than memory corruption at runtime                 */                v->error("cannot reference variadic arguments from closure");#endif            /* Align and allocate space for v in the closure             * just like AggregateDeclaration::addField() does.             */            unsigned memsize;            unsigned memalignsize;            structalign_t xalign;#if DMDV2            if (v->storage_class & STClazy)            {                /* Lazy variables are really delegates,                 * so give same answers that TypeDelegate would                 */                memsize = PTRSIZE * 2;                memalignsize = memsize;                xalign = global.structalign;            }            else if (v->isRef() || v->isOut())            {    // reference parameters are just pointers                memsize = PTRSIZE;                memalignsize = memsize;                xalign = global.structalign;            }            else#endif            {                memsize = v->type->size();                memalignsize = v->type->alignsize();                xalign = v->alignment;            }            AggregateDeclaration::alignmember(xalign, memalignsize, &offset);            v->offset = offset;            offset += memsize;            /* Can't do nrvo if the variable is put in a closure, since             * what the shidden points to may no longer exist.             */            if (nrvo_can && nrvo_var == v)            {                nrvo_can = 0;            }        }        // offset is now the size of the closure        // Allocate memory for the closure        elem *e;        e = el_long(TYsize_t, offset);        e = el_bin(OPcall, TYnptr, el_var(rtlsym[RTLSYM_ALLOCMEMORY]), e);        // Assign block of memory to sclosure        //    sclosure = allocmemory(sz);        e = el_bin(OPeq, TYvoid, el_var(sclosure), e);        // Set the first element to sthis        //    *(sclosure + 0) = sthis;        elem *ethis;        if (irs->sthis)//.........这里部分代码省略.........
开发者ID:dheld,项目名称:dmd,代码行数:101,


示例21: symbol_add

 * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. *  */#include <Unidraw/Components/grview.h>#include <ComTerp/boolfunc.h>#include <ComTerp/comvalue.h>#include <ComTerp/comterp.h>#include <string.h>#define TITLE "BoolFunc"static int sym_symid = symbol_add("sym");static int n_symid = symbol_add("n");/*****************************************************************************/AndFunc::AndFunc(ComTerp* comterp) : NumFunc(comterp) {}void AndFunc::execute() {    ComValue& operand1 = stack_arg(0);    ComValue& operand2 = stack_arg(1);    promote(operand1, operand2);    ComValue result(operand1);    result.type(ComValue::BooleanType);    switch (result.type()) {
开发者ID:barak,项目名称:ivtools-cvs,代码行数:31,


示例22: obj_append

//.........这里部分代码省略.........#endif        pi++;    }    if (sthis)    {#if 0        // sthis becomes last parameter        params[pi] = sthis;#else        // sthis becomes first parameter        memmove(params + 1, params, pi * sizeof(params[0]));        params[0] = sthis;#endif        pi++;    }    if ((global.params.isLinux || global.params.isOSX || global.params.isFreeBSD || global.params.isSolaris) &&         linkage != LINKd && shidden && sthis)    {        /* swap shidden and sthis         */        Symbol *sp = params[0];        params[0] = params[1];        params[1] = sp;    }    for (size_t i = 0; i < pi; i++)    {   Symbol *sp = params[i];        sp->Sclass = SCparameter;        sp->Sflags &= ~SFLspill;        sp->Sfl = FLpara;        symbol_add(sp);    }    // Determine register assignments    if (pi)    {        size_t numintegerregs = 0, numfloatregs = 0;        const unsigned char* argregs = getintegerparamsreglist(tyf, &numintegerregs);        const unsigned char* floatregs = getfloatparamsreglist(tyf, &numfloatregs);        // Order of assignment of pointer or integer parameters        int r = 0;        int xmmcnt = 0;        for (size_t i = 0; i < pi; i++)        {   Symbol *sp = params[i];            tym_t ty = tybasic(sp->Stype->Tty);            // BUG: doesn't work for structs            if (r < numintegerregs)            {                if ((I64 || (i == 0 && (tyf == TYjfunc || tyf == TYmfunc))) && type_jparam(sp->Stype))                {                    sp->Sclass = SCfastpar;                    sp->Spreg = argregs[r];                    sp->Sfl = FLauto;                    ++r;                }            }            if (xmmcnt < numfloatregs)            {                if (tyxmmreg(ty))                {                    sp->Sclass = SCfastpar;
开发者ID:iteratif,项目名称:dmd,代码行数:67,


示例23: intern2

pointer intern2(VM, char *name) {  pointer obj;  obj = symbol_add(vm, name);  AR_FLAG(obj) = GC_FLAG_INTERN;  return obj;}
开发者ID:wsxiaoys,项目名称:carc,代码行数:6,


示例24: obj_initfile

//.........这里部分代码省略.........            block *b = block_calloc();            b->BC = BCret;            b->Belem = eictor;            sictor->Sfunc->Fstartline.Sfilename = arg;            sictor->Sfunc->Fstartblock = b;            writefunc(sictor);        }        sctor = callFuncsAndGates(this, &sctors, &ectorgates, "__modctor");        sdtor = callFuncsAndGates(this, &sdtors, NULL, "__moddtor");#if DMDV2        ssharedctor = callFuncsAndGates(this, &ssharedctors, (StaticDtorDeclarations *)&esharedctorgates, "__modsharedctor");        sshareddtor = callFuncsAndGates(this, &sshareddtors, NULL, "__modshareddtor");#endif        stest = callFuncsAndGates(this, &stests, NULL, "__modtest");        if (doppelganger)            genmoduleinfo();    }    if (doppelganger)    {        obj_termfile();        return;    }    if (global.params.multiobj)    {   /* This is necessary because the main .obj for this module is written         * first, but determining whether marray or massert or munittest are needed is done         * possibly later in the doppelganger modules.         * Another way to fix it is do the main one last.         */        toModuleAssert();        toModuleUnittest();        toModuleArray();    }#if 1    // Always generate module info, because of templates and -cov    if (1 || needModuleInfo())        genmoduleinfo();#endif    // If module assert    for (int i = 0; i < 3; i++)    {        Symbol *ma;        unsigned rt;        unsigned bc;        switch (i)        {            case 0:     ma = marray;    rt = RTLSYM_DARRAY;     bc = BCexit; break;            case 1:     ma = massert;   rt = RTLSYM_DASSERTM;   bc = BCexit; break;            case 2:     ma = munittest; rt = RTLSYM_DUNITTESTM; bc = BCret;  break;            default:    assert(0);        }        if (ma)        {            elem *elinnum;            localgot = NULL;            // Call dassert(filename, line)            // Get sole parameter, linnum            {                Symbol *sp = symbol_calloc("linnum");                sp->Stype = type_fake(TYint);                sp->Stype->Tcount++;                sp->Sclass = SCfastpar;                size_t num;                sp->Spreg = getintegerparamsreglist(TYjfunc, &num)[0];                sp->Sflags &= ~SFLspill;                sp->Sfl = FLpara;       // FLauto?                cstate.CSpsymtab = &ma->Sfunc->Flocsym;                symbol_add(sp);                elinnum = el_var(sp);            }            elem *efilename = el_ptr(toSymbol());            elem *e = el_var(rtlsym[rt]);            e = el_bin(OPcall, TYvoid, e, el_param(elinnum, efilename));            block *b = block_calloc();            b->BC = bc;            b->Belem = e;            ma->Sfunc->Fstartline.Sfilename = arg;            ma->Sfunc->Fstartblock = b;            ma->Sclass = SCglobal;            ma->Sfl = 0;            ma->Sflags |= rtlsym[rt]->Sflags & SFLexit;            writefunc(ma);        }    }    obj_termfile();}
开发者ID:iteratif,项目名称:dmd,代码行数:101,



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


C++ symbol_calloc函数代码示例
C++ symbolTable函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。