static int f77_charconstant(Generator* generator, Bytebuffer* codebuf, ...) { /* Escapes and quoting will be handled in genc_write */ /* Just transfer charbuf to codebuf */ Bytebuffer* charbuf; va_list ap; vastart(ap,codebuf); charbuf = va_arg(ap, Bytebuffer*); va_end(ap); bbNull(charbuf); bbCatbuf(codebuf,charbuf); return 1; }
static int c_vlendecl(Generator* generator, Bytebuffer* codebuf, Symbol* tsym, int uid, size_t count, ...) { /* Build a bytebuffer to capture the vlen decl */ List* declstack = (List*)generator->state; Bytebuffer* decl = bbNew(); Bytebuffer* vlenbuf; va_list ap; vastart(ap,count); vlenbuf = va_arg(ap, Bytebuffer*); va_end(ap); bbprintf0(decl,"static const %s vlen_%u[] = {", ctypename(tsym->typ.basetype), uid); commify(vlenbuf); bbCatbuf(decl,vlenbuf); bbCat(decl,"} ;"); listpush(declstack,(void*)decl); /* Now generate the reference to buffer */ bbprintf(codebuf,"{%u,(void*)vlen_%u}",count,uid); return 1; }
static void expr(Node *n) { switch(n->t){ case NCOMMA: comma(n); break; case NCAST: cast(n); break; case NSTR: str(n); break; case NSIZEOF: outi("movq $%lld, %%rax\n", n->Sizeof.type->size); break; case NNUM: outi("movq $%lld, %%rax\n", n->Num.v); break; case NIDENT: ident(n); break; case NUNOP: unop(n); break; case NASSIGN: assign(n); break; case NBINOP: binop(n); break; case NIDX: idx(n); break; case NSEL: sel(n); break; case NCOND: cond(n); break; case NCALL: call(n); break; case NPTRADD: ptradd(n); break; case NINCDEC: incdec(n); break; case NBUILTIN: switch(n->Builtin.t) { case BUILTIN_VASTART: vastart(n); break; default: errorposf(&n->pos, "unimplemented builtin"); } break; default: errorf("unimplemented emit expr %d\n", n->t); } }