本文整理汇总了C++中TOWORD函数的典型用法代码示例。如果您正苦于以下问题:C++ TOWORD函数的具体用法?C++ TOWORD怎么用?C++ TOWORD使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TOWORD函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
void TypedefDeclaration::toDebug()
{
//printf("TypedefDeclaration::toDebug('%s')\n", toChars());
assert(config.fulltypes >= CV4);
// If it is a member, it is handled by cvMember()
if (!isMember())
{
if (basetype->ty == Ttuple)
return;
const char *id = toPrettyChars();
idx_t typidx = cv4_typidx(basetype->toCtype());
if (config.fulltypes == CV8)
cv8_udt(id, typidx);
else
{
unsigned len = strlen(id);
unsigned char *debsym = (unsigned char *) alloca(39 + IDOHD + len);
// Output a 'user-defined type' for the tag name
TOWORD(debsym + 2,S_UDT);
TOIDX(debsym + 4,typidx);
unsigned length = 2 + 2 + cgcv.sz_idx;
length += cv_namestring(debsym + length,id);
TOWORD(debsym,length - 2);
assert(length <= 40 + len);
objmod->write_bytes(SegData[DEBSYM],length,debsym);
}
}
}
示例2: assert
void EnumDeclaration::toDebug()
{
//printf("EnumDeclaration::toDebug('%s')\n", toChars());
assert(config.fulltypes >= CV4);
// If it is a member, it is handled by cvMember()
if (!isMember())
{
unsigned length;
const char *id = toPrettyChars();
idx_t typidx = cv4_Denum(this);
unsigned len = strlen(id);
unsigned char *debsym = (unsigned char *) alloca(39 + IDOHD + len);
// Output a 'user-defined type' for the tag name
TOWORD(debsym + 2,S_UDT);
TOIDX(debsym + 4,typidx);
length = 2 + 2 + cgcv.sz_idx;
length += cv_namestring(debsym + length,id);
TOWORD(debsym,length - 2);
assert(length <= 40 + len);
obj_write_bytes(SegData[DEBSYM],length,debsym);
}
}
示例3: cvMemberCommon
void cvMemberCommon(Dsymbol *s, char *id, idx_t typidx)
{
if (!p)
result = cv_stringbytes(id);
switch (config.fulltypes)
{
case CV8:
if (!p)
{
result += 8;
result = cv_align(NULL, result);
}
else
{
TOWORD(p,LF_NESTTYPE_V3);
TOWORD(p + 2,0);
TOLONG(p + 4,typidx);
result = 8 + cv_namestring(p + 8, id);
result = cv_align(p + result, result);
}
break;
case CV4:
if (!p)
{
result += 4;
}
else
{
TOWORD(p,LF_NESTTYPE);
TOWORD(p + 2,typidx);
result = 4 + cv_namestring(p + 4, id);
}
break;
default:
assert(0);
}
#ifdef DEBUG
if (p)
{
int save = result;
p = NULL;
cvMemberCommon(s, id, typidx);
assert(result == save);
}
#endif
}
示例4: cv8_fwdref
/***************************************
* Put out a forward ref for structs, unions, and classes.
* Only put out the real definitions with toDebug().
*/
idx_t cv8_fwdref(Symbol *s)
{
assert(config.fulltypes == CV8);
// if (s->Stypidx && !global.params.multiobj)
// return s->Stypidx;
struct_t *st = s->Sstruct;
unsigned leaf;
unsigned numidx;
if (st->Sflags & STRunion)
{
leaf = LF_UNION_V3;
numidx = 10;
}
else if (st->Sflags & STRclass)
{
leaf = LF_CLASS_V3;
numidx = 18;
}
else
{
leaf = LF_STRUCTURE_V3;
numidx = 18;
}
unsigned len = numidx + cv4_numericbytes(0);
int idlen = strlen(s->Sident);
if (idlen > CV8_MAX_SYMBOL_LENGTH)
idlen = CV8_MAX_SYMBOL_LENGTH;
debtyp_t *d = debtyp_alloc(len + idlen + 1);
TOWORD(d->data, leaf);
TOWORD(d->data + 2, 0); // number of fields
TOWORD(d->data + 4, 0x80); // property
TOLONG(d->data + 6, 0); // field list
if (leaf == LF_CLASS_V3 || leaf == LF_STRUCTURE_V3)
{
TOLONG(d->data + 10, 0); // dList
TOLONG(d->data + 14, 0); // vshape
}
cv4_storenumeric(d->data + numidx, 0);
cv_namestring(d->data + len, s->Sident, idlen);
d->data[len + idlen] = 0;
idx_t typidx = cv_debtyp(d);
s->Stypidx = typidx;
return typidx;
}
示例5: cvMember
int cvMember(unsigned char *p, char *id, idx_t typidx)
{
int nwritten = 0;
if (!p)
nwritten = cv_stringbytes(id);
switch (config.fulltypes)
{
case CV8:
if (!p)
{
nwritten += 8;
nwritten = cv_align(NULL, nwritten);
}
else
{
TOWORD(p,LF_NESTTYPE_V3);
TOWORD(p + 2,0);
TOLONG(p + 4,typidx);
nwritten = 8 + cv_namestring(p + 8, id);
nwritten = cv_align(p + nwritten, nwritten);
}
break;
case CV4:
if (!p)
{
nwritten += 4;
}
else
{
TOWORD(p,LF_NESTTYPE);
TOWORD(p + 2,typidx);
nwritten = 4 + cv_namestring(p + 4, id);
}
break;
default:
assert(0);
}
#ifdef DEBUG
if (p)
assert(nwritten == cvMember(NULL, id, typidx));
#endif
return nwritten;
}
示例6: if
INLINE UINT16 *address_to_vram(offs_t *address)
{
offs_t original = *address;
*address = TOWORD(original & 0x001fffff);
if (original >= 0x00000000 && original < 0x001fffff)
return artmagic_vram0;
else if (original >= 0x00400000 && original < 0x005fffff)
return artmagic_vram1;
return NULL;
}
示例7: toChars
int EnumDeclaration::cvMember(unsigned char *p)
{
char *id;
idx_t typidx;
int nwritten = 0;
//printf("EnumDeclaration::cvMember() '%s'\n", toChars());
id = toChars();
if (!p)
{
nwritten = 4 + cv_stringbytes(id);
}
else
{
TOWORD(p,LF_NESTTYPE);
typidx = cv4_Denum(this);
TOWORD(p + 2,typidx);
nwritten = 4 + cv_namestring(p + 4, id);
}
return nwritten;
}
示例8: toChars
int TypedefDeclaration::cvMember(unsigned char *p)
{
char *id;
idx_t typidx;
unsigned attribute;
int nwritten = 0;
debtyp_t *d;
//printf("TypedefDeclaration::cvMember() '%s'\n", toChars());
id = toChars();
if (!p)
{
nwritten = 4 + cv_stringbytes(id);
}
else
{
TOWORD(p,LF_NESTTYPE);
typidx = cv4_typidx(basetype->toCtype());
TOWORD(p + 2,typidx);
nwritten = 4 + cv_namestring(p + 4, id);
}
return nwritten;
}
示例9: cv4_memfunctypidx
unsigned cv4_memfunctypidx(FuncDeclaration *fd)
{ type *t;
debtyp_t *d;
unsigned char *p;
AggregateDeclaration *ad;
//printf("cv4_memfunctypidx(fd = '%s')\n", fd->toChars());
t = fd->type->toCtype();
ad = fd->isMember2();
if (ad)
{
unsigned nparam;
idx_t paramidx;
idx_t thisidx;
unsigned u;
unsigned char call;
// It's a member function, which gets a special type record
if (fd->isStatic())
thisidx = dttab4[TYvoid];
else
{
assert(ad->handle);
thisidx = cv4_typidx(ad->handle->toCtype());
}
paramidx = cv4_arglist(t,&nparam);
call = cv4_callconv(t);
d = debtyp_alloc(18);
p = d->data;
TOWORD(p,LF_MFUNCTION);
TOWORD(p + 2,cv4_typidx(t->Tnext));
TOWORD(p + 4,cv4_typidx(ad->type->toCtype()));
TOWORD(p + 6,thisidx);
p[8] = call;
p[9] = 0; // reserved
TOWORD(p + 10,nparam);
TOWORD(p + 12,paramidx);
TOLONG(p + 14,0); // thisadjust
return cv_debtyp(d);
}
return cv4_typidx(t);
}
示例10: cv4_Denum
unsigned cv4_Denum(EnumDeclaration *e)
{
//dbg_printf("cv4_Denum(%s)\n", e->toChars());
unsigned property = 0;
if (!e->members || !e->memtype || !e->memtype->isintegral())
property |= 0x80; // enum is forward referenced or non-integer
// Compute the number of fields, and the length of the fieldlist record
unsigned nfields = 0;
unsigned fnamelen = 2;
if (!property)
{
for (size_t i = 0; i < e->members->dim; i++)
{ EnumMember *sf = (*e->members)[i]->isEnumMember();
if (sf)
{
dinteger_t value = sf->value->toInteger();
unsigned fnamelen1 = fnamelen;
// store only member's simple name
fnamelen += 4 + cv4_numericbytes(value) + cv_stringbytes(sf->toChars());
if (config.fulltypes != CV8)
{
/* Optlink dies on longer ones, so just truncate
*/
if (fnamelen > 0xB000) // 0xB000 found by trial and error
{ fnamelen = fnamelen1; // back up
break; // and skip the rest
}
}
nfields++;
}
}
}
const char *id = e->toPrettyChars();
unsigned len;
debtyp_t *d;
unsigned memtype = e->memtype ? cv4_typidx(e->memtype->toCtype()) : 0;
switch (config.fulltypes)
{
case CV8:
len = 14;
d = debtyp_alloc(len + cv_stringbytes(id));
TOWORD(d->data,LF_ENUM_V3);
TOLONG(d->data + 6,memtype);
TOWORD(d->data + 4,property);
len += cv_namestring(d->data + len,id);
break;
case CV4:
len = 10;
d = debtyp_alloc(len + cv_stringbytes(id));
TOWORD(d->data,LF_ENUM);
TOWORD(d->data + 4,memtype);
TOWORD(d->data + 8,property);
len += cv_namestring(d->data + len,id);
break;
default:
assert(0);
}
unsigned length_save = d->length;
d->length = 0; // so cv_debtyp() will allocate new
idx_t typidx = cv_debtyp(d);
d->length = length_save; // restore length
TOWORD(d->data + 2,nfields);
unsigned fieldlist = 0;
if (!property) // if forward reference, then fieldlist is 0
{
// Generate fieldlist type record
debtyp_t *dt = debtyp_alloc(fnamelen);
TOWORD(dt->data,(config.fulltypes == CV8) ? LF_FIELDLIST_V2 : LF_FIELDLIST);
// And fill it in
unsigned j = 2;
unsigned fieldi = 0;
for (size_t i = 0; i < e->members->dim; i++)
{ EnumMember *sf = (*e->members)[i]->isEnumMember();
if (sf)
{
fieldi++;
if (fieldi > nfields)
break; // chop off the rest
dinteger_t value = sf->value->toInteger();
TOWORD(dt->data + j,(config.fulltypes == CV8) ? LF_ENUMERATE_V3 : LF_ENUMERATE);
unsigned attribute = 0;
TOWORD(dt->data + j + 2,attribute);
cv4_storenumeric(dt->data + j + 4,value);
j += 4 + cv4_numericbytes(value);
// store only member's simple name
j += cv_namestring(dt->data + j, sf->toChars());
// If enum is not a member of a class, output enum members as constants
//.........这里部分代码省略.........
示例11: cv8_func_term
void cv8_func_term(Symbol *sfunc)
{
//printf("cv8_func_term(%s)\n", sfunc->Sident);
assert(currentfuncdata.sfunc == sfunc);
currentfuncdata.section_length = retoffset + retsize;
funcdata->write(¤tfuncdata, sizeof(currentfuncdata));
// Write function symbol
assert(tyfunc(sfunc->ty()));
idx_t typidx;
func_t* fn = sfunc->Sfunc;
if(fn->Fclass)
{
// generate member function type info
// it would be nicer if this could be in cv4_typidx, but the function info is not available there
unsigned nparam;
unsigned char call = cv4_callconv(sfunc->Stype);
idx_t paramidx = cv4_arglist(sfunc->Stype,&nparam);
unsigned next = cv4_typidx(sfunc->Stype->Tnext);
type* classtype = (type*)fn->Fclass;
unsigned classidx = cv4_typidx(classtype);
type *tp = type_allocn(TYnptr, classtype);
unsigned thisidx = cv4_typidx(tp); // TODO
debtyp_t *d = debtyp_alloc(2 + 4 + 4 + 4 + 1 + 1 + 2 + 4 + 4);
TOWORD(d->data,LF_MFUNCTION_V2);
TOLONG(d->data + 2,next); // return type
TOLONG(d->data + 6,classidx); // class type
TOLONG(d->data + 10,thisidx); // this type
d->data[14] = call;
d->data[15] = 0; // reserved
TOWORD(d->data + 16,nparam);
TOLONG(d->data + 18,paramidx);
TOLONG(d->data + 22,0); // this adjust
typidx = cv_debtyp(d);
}
else
typidx = cv_typidx(sfunc->Stype);
const char *id = sfunc->prettyIdent ? sfunc->prettyIdent : prettyident(sfunc);
size_t len = strlen(id);
if(len > CV8_MAX_SYMBOL_LENGTH)
len = CV8_MAX_SYMBOL_LENGTH;
/*
* 2 length (not including these 2 bytes)
* 2 S_GPROC_V3
* 4 parent
* 4 pend
* 4 pnext
* 4 size of function
* 4 size of function prolog
* 4 offset to function epilog
* 4 type index
* 6 seg:offset of function start
* 1 flags
* n 0 terminated name string
*/
Outbuffer *buf = currentfuncdata.f1buf;
buf->reserve(2 + 2 + 4 * 7 + 6 + 1 + len + 1);
buf->writeWordn( 2 + 4 * 7 + 6 + 1 + len + 1);
buf->writeWordn(sfunc->Sclass == SCstatic ? S_LPROC_V3 : S_GPROC_V3);
buf->write32(0); // parent
buf->write32(0); // pend
buf->write32(0); // pnext
buf->write32(currentfuncdata.section_length); // size of function
buf->write32(startoffset); // size of prolog
buf->write32(retoffset); // offset to epilog
buf->write32(typidx);
F1_Fixups f1f;
f1f.s = sfunc;
f1f.offset = buf->size();
currentfuncdata.f1fixup->write(&f1f, sizeof(f1f));
buf->write32(0);
buf->writeWordn(0);
buf->writeByte(0);
buf->writen(id, len);
buf->writeByte(0);
// Write local symbol table
bool endarg = false;
for (SYMIDX si = 0; si < globsym.top; si++)
{ //printf("globsym.tab[%d] = %p\n",si,globsym.tab[si]);
symbol *sa = globsym.tab[si];
if (endarg == false &&
sa->Sclass != SCparameter &&
sa->Sclass != SCfastpar &&
sa->Sclass != SCshadowreg)
{
buf->writeWord(2);
buf->writeWord(S_ENDARG);
endarg = true;
}
cv8_outsym(sa);
}
/* Put out function return record S_RETURN
//.........这里部分代码省略.........
示例12: WRITE16_HANDLER
static WRITE16_HANDLER( exterm_host_data_w )
{
tms34010_host_w(space->machine().device("slave"), offset / TOWORD(0x00100000), data);
}
示例13: cv8_darray
/****************************************
* Return type index for a darray of type E[]
* Input:
* t darray type
* etypidx type index for E
*/
idx_t cv8_darray(type *t, idx_t etypidx)
{
//printf("cv8_darray(etypidx = %x)\n", etypidx);
/* Put out a struct:
* struct dArray {
* size_t length;
* E* ptr;
* }
*/
#if 0
d = debtyp_alloc(18);
TOWORD(d->data, 0x100F);
TOWORD(d->data + 2, OEM);
TOWORD(d->data + 4, 1); // 1 = dynamic array
TOLONG(d->data + 6, 2); // count of type indices to follow
TOLONG(d->data + 10, 0x23); // index type, T_UQUAD
TOLONG(d->data + 14, next); // element type
return cv_debtyp(d);
#endif
type *tp = type_pointer(t->Tnext);
idx_t ptridx = cv4_typidx(tp);
type_free(tp);
static const unsigned char fl[] =
{
0x03, 0x12, // LF_FIELDLIST_V2
0x0d, 0x15, // LF_MEMBER_V3
0x03, 0x00, // attribute
0x23, 0x00, 0x00, 0x00, // size_t
0x00, 0x00, // offset
'l', 'e', 'n', 'g', 't', 'h', 0x00,
0xf3, 0xf2, 0xf1, // align to 4-byte including length word before data
0x0d, 0x15,
0x03, 0x00,
0x00, 0x00, 0x00, 0x00, // etypidx
0x08, 0x00,
'p', 't', 'r', 0x00,
0xf2, 0xf1,
};
debtyp_t *f = debtyp_alloc(sizeof(fl));
memcpy(f->data,fl,sizeof(fl));
TOLONG(f->data + 6, I64 ? 0x23 : 0x22); // size_t
TOLONG(f->data + 26, ptridx);
TOWORD(f->data + 30, NPTRSIZE);
idx_t fieldlist = cv_debtyp(f);
const char *id;
switch (t->Tnext->Tty)
{
case mTYimmutable | TYchar:
id = "string";
break;
case mTYimmutable | TYwchar_t:
id = "wstring";
break;
case mTYimmutable | TYdchar:
id = "dstring";
break;
default:
id = t->Tident ? t->Tident : "dArray";
break;
}
int idlen = strlen(id);
if (idlen > CV8_MAX_SYMBOL_LENGTH)
idlen = CV8_MAX_SYMBOL_LENGTH;
debtyp_t *d = debtyp_alloc(20 + idlen + 1);
TOWORD(d->data, LF_STRUCTURE_V3);
TOWORD(d->data + 2, 2); // count
TOWORD(d->data + 4, 0); // property
TOLONG(d->data + 6, fieldlist);
TOLONG(d->data + 10, 0); // dList
TOLONG(d->data + 14, 0); // vtshape
TOWORD(d->data + 18, 2 * NPTRSIZE); // size
cv_namestring(d->data + 20, id, idlen);
d->data[20 + idlen] = 0;
idx_t top = cv_numdebtypes();
idx_t debidx = cv_debtyp(d);
if(top != cv_numdebtypes())
cv8_udt(id, debidx);
return debidx;
}
示例14: WRITE16_HANDLER
static WRITE16_HANDLER( exterm_host_data_w )
{
tms34010_host_w(cputag_get_cpu(space->machine, "slave"), offset / TOWORD(0x00100000), data);
}
示例15: cv4_memfunctypidx
unsigned cv4_memfunctypidx(FuncDeclaration *fd)
{
//printf("cv4_memfunctypidx(fd = '%s')\n", fd->toChars());
type *t = fd->type->toCtype();
AggregateDeclaration *ad = fd->isMember2();
if (ad)
{
// It's a member function, which gets a special type record
idx_t thisidx;
if (fd->isStatic())
thisidx = dttab4[TYvoid];
else
{
assert(ad->handle);
thisidx = cv4_typidx(ad->handle->toCtype());
}
unsigned nparam;
idx_t paramidx = cv4_arglist(t,&nparam);
unsigned char call = cv4_callconv(t);
debtyp_t *d;
switch (config.fulltypes)
{
case CV4:
{
d = debtyp_alloc(18);
unsigned char *p = d->data;
TOWORD(p,LF_MFUNCTION);
TOWORD(p + 2,cv4_typidx(t->Tnext));
TOWORD(p + 4,cv4_typidx(ad->type->toCtype()));
TOWORD(p + 6,thisidx);
p[8] = call;
p[9] = 0; // reserved
TOWORD(p + 10,nparam);
TOWORD(p + 12,paramidx);
TOLONG(p + 14,0); // thisadjust
break;
}
case CV8:
{
d = debtyp_alloc(26);
unsigned char *p = d->data;
TOWORD(p,0x1009);
TOLONG(p + 2,cv4_typidx(t->Tnext));
TOLONG(p + 6,cv4_typidx(ad->type->toCtype()));
TOLONG(p + 10,thisidx);
p[14] = call;
p[15] = 0; // reserved
TOWORD(p + 16,nparam);
TOLONG(p + 18,paramidx);
TOLONG(p + 22,0); // thisadjust
break;
}
default:
assert(0);
}
return cv_debtyp(d);
}
return cv4_typidx(t);
}