本文整理汇总了C++中TypeStruct类的典型用法代码示例。如果您正苦于以下问题:C++ TypeStruct类的具体用法?C++ TypeStruct怎么用?C++ TypeStruct使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TypeStruct类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: SetTypeCurrentAttrib
/******************************************************************************
* SetTypeCurrentAttrib
*/
short API::SetTypeCurrentAttrib(long filePosition, long typePosition)
{
#ifdef SHAREWARE
return RC_NO_LICENSE;
#endif
if (apiView == NULL)
return RC_NO_ACTIVE_DOC;
CCEtoODBDoc *doc = apiView->GetDocument();
POSITION pos = (POSITION)filePosition;
if (!AfxIsValidAddress(pos, 3 * sizeof(void*)))
return RC_ILLEGAL_POSITION;
FileStruct *file = doc->getFileList().GetAt(pos);
pos = (POSITION)typePosition;
if (!AfxIsValidAddress(pos, 3 * sizeof(void*)))
return RC_ILLEGAL_POSITION;
TypeStruct *type = file->getTypeList().GetAt(pos);
currentAttribMap = &type->getAttributesRef();
currentDoc = doc;
return RC_SUCCESS;
}
开发者ID:mpatwa,项目名称:CCEtoODB_Translator,代码行数:29,代码来源:Api_Attr.cpp
示例2: addType
TypeStruct* CDeviceTypeDirectory::addType(const TypeStruct& otherTypeStruct,int entityNumber)
{
TypeStruct* typeStruct = m_deviceTypeList.addType(otherTypeStruct,entityNumber);
// if more than one type has the same name, the last added type is in the map
getDeviceTypeMap().add(typeStruct->getName(),typeStruct);
return typeStruct;
}
开发者ID:mpatwa,项目名称:CCEtoODB_Translator,代码行数:9,代码来源:DcaType.cpp
示例3: takeData
void CDeviceTypeDirectory::takeData(CDeviceTypeDirectory& other)
{
for (POSITION pos = other.getHeadPosition();pos != NULL;)
{
POSITION oldPos = pos;
TypeStruct* typeStruct = other.getNext(pos);
other.removeAt(oldPos);
TypeStruct* newTypeStruct = this->addType(*typeStruct,typeStruct->getEntityNumber());
newTypeStruct->getTypePinList().takeData(typeStruct->getTypePinList());
}
}
开发者ID:mpatwa,项目名称:CCEtoODB_Translator,代码行数:12,代码来源:DcaType.cpp
示例4: getNext
void CDeviceTypeDirectory::removeUnusedDeviceTypes()
{
for (POSITION pos = getHeadPosition();pos != NULL;)
{
POSITION oldPos = pos;
TypeStruct* typeStruct = getNext(pos);
if (typeStruct->getBlockNumber() < 0)
{
deleteAt(oldPos);
}
}
}
开发者ID:mpatwa,项目名称:CCEtoODB_Translator,代码行数:13,代码来源:DcaType.cpp
示例5: max
void CDeviceTypeDirectory::reallocateMap() const
{
delete m_deviceTypeMap;
int size = max(100,(int)(1.3 * m_deviceTypeList.GetCount()));
m_deviceTypeMap = new CDeviceTypeArrayWithMap(size,false);
for (POSITION pos = m_deviceTypeList.GetHeadPosition();pos != NULL;)
{
TypeStruct* typeStruct = m_deviceTypeList.GetNext(pos);
m_deviceTypeMap->add(typeStruct->getName(),typeStruct);
}
}
开发者ID:mpatwa,项目名称:CCEtoODB_Translator,代码行数:14,代码来源:DcaType.cpp
示例6: getType
TypeStruct& CDeviceTypeDirectory::getDefinedType(const CString& deviceName)
{
TypeStruct* typeStruct = getType(deviceName);
if (typeStruct == NULL)
{
typeStruct = m_deviceTypeList.addType(deviceName,m_camCadData.allocateEntityNumber());
typeStruct->setBlockNumber( -1); // no name assigned
getDeviceTypeMap().add(deviceName,typeStruct);
}
return *typeStruct;
}
开发者ID:mpatwa,项目名称:CCEtoODB_Translator,代码行数:15,代码来源:DcaType.cpp
示例7: getCamCadData
// does not copy the CTypePinList
TypeStruct::TypeStruct(const TypeStruct& other,int entityNumber)
: m_parentList(other.m_parentList)
, m_attributes(NULL)
, m_blockNumber(other.getBlockNumber())
, m_entityNumber(entityNumber)
, m_name(other.getName())
, m_typePinList(*this)
{
if (m_entityNumber < 0)
{
m_entityNumber = getCamCadData().allocateEntityNumber();
}
if (other.getAttributes() != NULL)
{
attributes() = *(other.getAttributes());
}
}
开发者ID:mpatwa,项目名称:CCEtoODB_Translator,代码行数:19,代码来源:DcaType.cpp
示例8: getAt
void CDeviceTypeDirectory::deleteAt(POSITION pos)
{
TypeStruct* listTypeStruct = getAt(pos);
if (m_deviceTypeMap != NULL)
{
TypeStruct* mapTypeStruct = getDeviceTypeMap().getAt(listTypeStruct->getName());
// If the map contains a different TypeStruct, no need to deallocate map.
// If the map contains this TypeStruct, deallocate it so that when it is rebuilt, another TypeStruct with the same name
// will be put into the map.
if (mapTypeStruct == listTypeStruct)
{
deallocateMap();
}
}
m_deviceTypeList.deleteAt(pos);
}
开发者ID:mpatwa,项目名称:CCEtoODB_Translator,代码行数:19,代码来源:DcaType.cpp
示例9: findType
TypeStruct* CDeviceTypeList::findType(const CString& name) const
{
TypeStruct* typeStruct = NULL;
for (POSITION pos = m_typeList.GetHeadPosition();;)
{
if (pos == NULL)
{
typeStruct = NULL;
break;
}
typeStruct = m_typeList.GetNext(pos);
if (typeStruct->getName().Compare(name) == 0)
{
break;
}
}
return typeStruct;
}
开发者ID:mpatwa,项目名称:CCEtoODB_Translator,代码行数:22,代码来源:DcaType.cpp
示例10: dtxoff
void TypeInfoStructDeclaration::toDt(dt_t **pdt)
{
//printf("TypeInfoStructDeclaration::toDt() '%s'\n", toChars());
unsigned offset = Type::typeinfostruct->structsize;
dtxoff(pdt, Type::typeinfostruct->toVtblSymbol(), 0, TYnptr); // vtbl for TypeInfo_Struct
dtsize_t(pdt, 0); // monitor
assert(tinfo->ty == Tstruct);
TypeStruct *tc = (TypeStruct *)tinfo;
StructDeclaration *sd = tc->sym;
/* Put out:
* char[] name;
* void[] init;
* hash_t function(in void*) xtoHash;
* bool function(in void*, in void*) xopEquals;
* int function(in void*, in void*) xopCmp;
* string function(const(void)*) xtoString;
* uint m_flags;
* xgetMembers;
* xdtor;
* xpostblit;
* uint m_align;
* version (X86_64)
* TypeInfo m_arg1;
* TypeInfo m_arg2;
*
* name[]
*/
const char *name = sd->toPrettyChars();
size_t namelen = strlen(name);
dtsize_t(pdt, namelen);
//dtabytes(pdt, TYnptr, 0, namelen + 1, name);
dtxoff(pdt, toSymbol(), offset, TYnptr);
offset += namelen + 1;
// void[] init;
dtsize_t(pdt, sd->structsize); // init.length
if (sd->zeroInit)
dtsize_t(pdt, 0); // NULL for 0 initialization
else
dtxoff(pdt, sd->toInitializer(), 0, TYnptr); // init.ptr
FuncDeclaration *fd;
FuncDeclaration *fdx;
TypeFunction *tf;
Type *ta;
Dsymbol *s;
static TypeFunction *tftohash;
static TypeFunction *tftostring;
if (!tftohash)
{
Scope sc;
tftohash = new TypeFunction(NULL, Type::thash_t, 0, LINKd);
tftohash->mod = MODconst;
tftohash = (TypeFunction *)tftohash->semantic(0, &sc);
tftostring = new TypeFunction(NULL, Type::tchar->invariantOf()->arrayOf(), 0, LINKd);
tftostring = (TypeFunction *)tftostring->semantic(0, &sc);
}
TypeFunction *tfcmpptr;
{
Scope sc;
Parameters *arguments = new Parameters;
#if STRUCTTHISREF
// arg type is ref const T
Parameter *arg = new Parameter(STCref, tc->constOf(), NULL, NULL);
#else
// arg type is const T*
Parameter *arg = new Parameter(STCin, tc->pointerTo(), NULL, NULL);
#endif
arguments->push(arg);
tfcmpptr = new TypeFunction(arguments, Type::tint32, 0, LINKd);
tfcmpptr->mod = MODconst;
tfcmpptr = (TypeFunction *)tfcmpptr->semantic(0, &sc);
}
s = search_function(sd, Id::tohash);
fdx = s ? s->isFuncDeclaration() : NULL;
if (fdx)
{ fd = fdx->overloadExactMatch(tftohash);
if (fd)
dtxoff(pdt, fd->toSymbol(), 0, TYnptr);
else
//fdx->error("must be declared as extern (D) uint toHash()");
dtsize_t(pdt, 0);
}
else
dtsize_t(pdt, 0);
if (sd->eq)
//.........这里部分代码省略.........
开发者ID:spott,项目名称:dmd,代码行数:101,代码来源:typinf.c
示例11: DtoType
LLType* DtoType(Type* t)
{
t = stripModifiers( t );
if (t->ctype)
{
return t->ctype->getLLType();
}
IF_LOG Logger::println("Building type: %s", t->toChars());
LOG_SCOPE;
assert(t);
switch (t->ty)
{
// basic types
case Tvoid:
case Tint8:
case Tuns8:
case Tint16:
case Tuns16:
case Tint32:
case Tuns32:
case Tint64:
case Tuns64:
case Tint128:
case Tuns128:
case Tfloat32:
case Tfloat64:
case Tfloat80:
case Timaginary32:
case Timaginary64:
case Timaginary80:
case Tcomplex32:
case Tcomplex64:
case Tcomplex80:
//case Tbit:
case Tbool:
case Tchar:
case Twchar:
case Tdchar:
{
return IrTypeBasic::get(t)->getLLType();
}
// pointers
case Tnull:
case Tpointer:
{
return IrTypePointer::get(t)->getLLType();
}
// arrays
case Tarray:
{
return IrTypeArray::get(t)->getLLType();
}
case Tsarray:
{
return IrTypeSArray::get(t)->getLLType();
}
// aggregates
case Tstruct:
{
TypeStruct* ts = static_cast<TypeStruct*>(t);
if (ts->sym->type->ctype)
{
// This should not happen, but the frontend seems to be buggy. Not
// sure if this is the best way to handle the situation, but we
// certainly don't want to override ts->sym->type->ctype.
IF_LOG Logger::cout() << "Struct with multiple Types detected: " <<
ts->toChars() << " (" << ts->sym->locToChars() << ")" << std::endl;
return ts->sym->type->ctype->getLLType();
}
return IrTypeStruct::get(ts->sym)->getLLType();
}
case Tclass:
{
TypeClass* tc = static_cast<TypeClass*>(t);
if (tc->sym->type->ctype)
{
// See Tstruct case.
IF_LOG Logger::cout() << "Class with multiple Types detected: " <<
tc->toChars() << " (" << tc->sym->locToChars() << ")" << std::endl;
return tc->sym->type->ctype->getLLType();
}
return IrTypeClass::get(tc->sym)->getLLType();
}
// functions
case Tfunction:
{
return IrTypeFunction::get(t)->getLLType();
}
// delegates
case Tdelegate:
{
//.........这里部分代码省略.........
开发者ID:mleise,项目名称:ldc,代码行数:101,代码来源:tollvm.cpp
示例12: printf
void VarDeclaration::semantic(Scope *sc)
{
#if 0
printf("VarDeclaration::semantic('%s', parent = '%s')\n", toChars(), sc->parent->toChars());
printf(" type = %s\n", type ? type->toChars() : "null");
printf(" stc = x%x\n", sc->stc);
printf(" storage_class = x%x\n", storage_class);
printf("linkage = %d\n", sc->linkage);
//if (strcmp(toChars(), "mul") == 0) halt();
#endif
storage_class |= sc->stc;
if (storage_class & STCextern && init)
error("extern symbols cannot have initializers");
AggregateDeclaration *ad = isThis();
if (ad)
storage_class |= ad->storage_class & STC_TYPECTOR;
/* If auto type inference, do the inference
*/
int inferred = 0;
if (!type)
{ inuse++;
type = init->inferType(sc);
inuse--;
inferred = 1;
/* This is a kludge to support the existing syntax for RAII
* declarations.
*/
storage_class &= ~STCauto;
originalType = type;
}
else
{ if (!originalType)
originalType = type;
type = type->semantic(loc, sc);
}
//printf(" semantic type = %s\n", type ? type->toChars() : "null");
type->checkDeprecated(loc, sc);
linkage = sc->linkage;
this->parent = sc->parent;
//printf("this = %p, parent = %p, '%s'\n", this, parent, parent->toChars());
protection = sc->protection;
//printf("sc->stc = %x\n", sc->stc);
//printf("storage_class = x%x\n", storage_class);
#if DMDV2
if (storage_class & STCgshared && global.params.safe && !sc->module->safe)
{
error("__gshared not allowed in safe mode; use shared");
}
#endif
Dsymbol *parent = toParent();
FuncDeclaration *fd = parent->isFuncDeclaration();
Type *tb = type->toBasetype();
if (tb->ty == Tvoid && !(storage_class & STClazy))
{ error("voids have no value");
type = Type::terror;
tb = type;
}
if (tb->ty == Tfunction)
{ error("cannot be declared to be a function");
type = Type::terror;
tb = type;
}
if (tb->ty == Tstruct)
{ TypeStruct *ts = (TypeStruct *)tb;
if (!ts->sym->members)
{
error("no definition of struct %s", ts->toChars());
}
}
if ((storage_class & STCauto) && !inferred)
error("storage class 'auto' has no effect if type is not inferred, did you mean 'scope'?");
if (tb->ty == Ttuple)
{ /* Instead, declare variables for each of the tuple elements
* and add those.
*/
TypeTuple *tt = (TypeTuple *)tb;
size_t nelems = Parameter::dim(tt->arguments);
Objects *exps = new Objects();
exps->setDim(nelems);
Expression *ie = init ? init->toExpression() : NULL;
for (size_t i = 0; i < nelems; i++)
{ Parameter *arg = Parameter::getNth(tt->arguments, i);
OutBuffer buf;
buf.printf("_%s_field_%zu", ident->toChars(), i);
buf.writeByte(0);
const char *name = (const char *)buf.extractData();
Identifier *id = Lexer::idPool(name);
//.........这里部分代码省略.........
开发者ID:smunix,项目名称:ldc,代码行数:101,代码来源:declaration.c
示例13: toChars
void TypeInfoStructDeclaration::llvmDefine()
{
Logger::println("TypeInfoStructDeclaration::llvmDefine() %s", toChars());
LOG_SCOPE;
// make sure struct is resolved
assert(tinfo->ty == Tstruct);
TypeStruct *tc = static_cast<TypeStruct *>(tinfo);
StructDeclaration *sd = tc->sym;
// can't emit typeinfo for forward declarations
if (sd->sizeok != 1)
{
sd->error("cannot emit TypeInfo for forward declaration");
fatal();
}
sd->codegen(Type::sir);
IrStruct* irstruct = sd->ir.irStruct;
RTTIBuilder b(Type::typeinfostruct);
// char[] name
b.push_string(sd->toPrettyChars());
// void[] init
// never emit a null array, even for zero initialized typeinfo
// the size() method uses this array!
size_t init_size = getTypeStoreSize(tc->irtype->getType());
b.push_void_array(init_size, irstruct->getInitSymbol());
// toX functions ground work
static TypeFunction *tftohash;
static TypeFunction *tftostring;
if (!tftohash)
{
Scope sc;
tftohash = new TypeFunction(NULL, Type::thash_t, 0, LINKd);
#if DMDV2
tftohash ->mod = MODconst;
#endif
tftohash = static_cast<TypeFunction *>(tftohash->semantic(0, &sc));
#if DMDV2
Type *retType = Type::tchar->invariantOf()->arrayOf();
#else
Type *retType = Type::tchar->arrayOf();
#endif
tftostring = new TypeFunction(NULL, retType, 0, LINKd);
tftostring = static_cast<TypeFunction *>(tftostring->semantic(0, &sc));
}
// this one takes a parameter, so we need to build a new one each time
// to get the right type. can we avoid this?
TypeFunction *tfcmpptr;
{
Scope sc;
Parameters *arguments = new Parameters;
#if STRUCTTHISREF
// arg type is ref const T
Parameter *arg = new Parameter(STCref, tc->constOf(), NULL, NULL);
#else
// arg type is const T*
Parameter *arg = new Parameter(STCin, tc->pointerTo(), NULL, NULL);
#endif
arguments->push(arg);
tfcmpptr = new TypeFunction(arguments, Type::tint32, 0, LINKd);
#if DMDV2
tfcmpptr->mod = MODconst;
#endif
tfcmpptr = static_cast<TypeFunction *>(tfcmpptr->semantic(0, &sc));
}
// well use this module for all overload lookups
Module *gm = getModule();
// toHash
FuncDeclaration* fd = find_method_overload(sd, Id::tohash, tftohash, gm);
b.push_funcptr(fd);
// opEquals
#if DMDV2
fd = sd->xeq;
#else
fd = find_method_overload(sd, Id::eq, tfcmpptr, gm);
#endif
b.push_funcptr(fd);
// opCmp
fd = find_method_overload(sd, Id::cmp, tfcmpptr, gm);
b.push_funcptr(fd);
// toString
fd = find_method_overload(sd, Id::tostring, tftostring, gm);
b.push_funcptr(fd);
// uint m_flags;
unsigned hasptrs = tc->hasPointers() ? 1 : 0;
b.push_uint(hasptrs);
//.........这里部分代码省略.........
开发者ID:alexrp,项目名称:ldc,代码行数:101,代码来源:typinf.cpp
示例14: verifyStructSize
void TypeInfoStructDeclaration::toDt(dt_t **pdt)
{
//printf("TypeInfoStructDeclaration::toDt() '%s'\n", toChars());
if (global.params.is64bit)
verifyStructSize(Type::typeinfostruct, 17 * PTRSIZE);
else
verifyStructSize(Type::typeinfostruct, 15 * PTRSIZE);
dtxoff(pdt, Type::typeinfostruct->toVtblSymbol(), 0, TYnptr); // vtbl for TypeInfo_Struct
dtsize_t(pdt, 0); // monitor
assert(tinfo->ty == Tstruct);
TypeStruct *tc = (TypeStruct *)tinfo;
StructDeclaration *sd = tc->sym;
/* Put out:
* char[] name;
* void[] init;
* hash_t function(in void*) xtoHash;
* bool function(in void*, in void*) xopEquals;
* int function(in void*, in void*) xopCmp;
* string function(const(void)*) xtoString;
* uint m_flags;
* //xgetMembers;
* xdtor;
* xpostblit;
* uint m_align;
* version (X86_64)
* TypeInfo m_arg1;
* TypeInfo m_arg2;
* xgetRTInfo
*/
const char *name = sd->toPrettyChars();
size_t namelen = strlen(name);
dtsize_t(pdt, namelen);
dtabytes(pdt, TYnptr, 0, namelen + 1, name);
// void[] init;
dtsize_t(pdt, sd->structsize); // init.length
if (sd->zeroInit)
dtsize_t(pdt, 0); // NULL for 0 initialization
else
dtxoff(pdt, sd->toInitializer(), 0, TYnptr); // init.ptr
FuncDeclaration *fd;
FuncDeclaration *fdx;
Dsymbol *s;
static TypeFunction *tftohash;
static TypeFunction *tftostring;
if (!tftohash)
{
Scope sc;
/* const hash_t toHash();
*/
tftohash = new TypeFunction(NULL, Type::thash_t, 0, LINKd);
tftohash->mod = MODconst;
tftohash = (TypeFunction *)tftohash->semantic(0, &sc);
tftostring = new TypeFunction(NULL, Type::tchar->invariantOf()->arrayOf(), 0, LINKd);
tftostring = (TypeFunction *)tftostring->semantic(0, &sc);
}
TypeFunction *tfcmpptr;
{
Scope sc;
/* const int opCmp(ref const KeyType s);
*/
Parameters *arguments = new Parameters;
#if STRUCTTHISREF
// arg type is ref const T
Parameter *arg = new Parameter(STCref, tc->constOf(), NULL, NULL);
#else
// arg type is const T*
Parameter *arg = new Parameter(STCin, tc->pointerTo(), NULL, NULL);
#endif
arguments->push(arg);
tfcmpptr = new TypeFunction(arguments, Type::tint32, 0, LINKd);
tfcmpptr->mod = MODconst;
tfcmpptr = (TypeFunction *)tfcmpptr->semantic(0, &sc);
}
s = search_function(sd, Id::tohash);
fdx = s ? s->isFuncDeclaration() : NULL;
if (fdx)
{ fd = fdx->overloadExactMatch(tftohash);
if (fd)
{
dtxoff(pdt, fd->toSymbol(), 0, TYnptr);
TypeFunction *tf = (TypeFunction *)fd->type;
assert(tf->ty == Tfunction);
/* I'm a little unsure this is the right way to do it. Perhaps a better
* way would to automatically add these attributes to any struct member
* function with the name "toHash".
//.........这里部分代码省略.........
开发者ID:dsagal,项目名称:dmd,代码行数:101,代码来源:typinf.c
示例15: dtxoff
void TypeInfoStructDeclaration::toDt(dt_t **pdt)
{
//printf("TypeInfoStructDeclaration::toDt() '%s'\n", toChars());
unsigned offset = Type::typeinfostruct->structsize;
dtxoff(pdt, Type::typeinfostruct->toVtblSymbol(), 0, TYnptr); // vtbl for TypeInfo_Struct
dtdword(pdt, 0); // monitor
assert(tinfo->ty == Tstruct);
TypeStruct *tc = (TypeStruct *)tinfo;
StructDeclaration *sd = tc->sym;
/* Put out:
* char[] name;
* void[] init;
* hash_t function(void*) xtoHash;
* int function(void*,void*) xopEquals;
* int function(void*,void*) xopCmp;
* char[] function(void*) xtoString;
* uint m_flags;
*
* name[]
*/
const char *name = sd->toPrettyChars();
size_t namelen = strlen(name);
dtdword(pdt, namelen);
//dtabytes(pdt, TYnptr, 0, namelen + 1, name);
dtxoff(pdt, toSymbol(), offset, TYnptr);
offset += namelen + 1;
// void[] init;
dtdword(pdt, sd->structsize); // init.length
if (sd->zeroInit)
dtdword(pdt, 0); // NULL for 0 initialization
else
dtxoff(pdt, sd->toInitializer(), 0, TYnptr); // init.ptr
FuncDeclaration *fd;
FuncDeclaration *fdx;
TypeFunction *tf;
Type *ta;
Dsymbol *s;
static TypeFunction *tftohash;
static TypeFunction *tftostring;
if (!tftohash)
{
Scope sc;
tftohash = new TypeFunction(NULL, Type::thash_t, 0, LINKd);
tftohash = (TypeFunction *)tftohash->semantic(0, &sc);
tftostring = new TypeFunction(NULL, Type::tchar->arrayOf(), 0, LINKd);
tftostring = (TypeFunction *)tftostring->semantic(0, &sc);
}
TypeFunction *tfeqptr;
{
Scope sc;
Parameters *arguments = new Parameters;
#if STRUCTTHISREF
// arg type is ref const T
Parameter *arg = new Parameter(STCref, tc->constOf(), NULL, NULL);
#else
// arg type is const T*
Parameter *arg = new Parameter(STCin, tc->pointerTo(), NULL, NULL);
#endif
arguments->push(arg);
tfeqptr = new TypeFunction(arguments, Type::tint32, 0, LINKd);
tfeqptr = (TypeFunction *)tfeqptr->semantic(0, &sc);
}
#if 0
TypeFunction *tfeq;
{
Scope sc;
Array *arguments = new Array;
Parameter *arg = new Parameter(In, tc, NULL, NULL);
arguments->push(arg);
tfeq = new TypeFunction(arguments, Type::tint32, 0, LINKd);
tfeq = (TypeFunction *)tfeq->semantic(0, &sc);
}
#endif
s = search_function(sd, Id::tohash);
fdx = s ? s->isFuncDeclaration() : NULL;
if (fdx)
{ fd = fdx->overloadExactMatch(tftohash);
if (fd)
dtxoff(pdt, fd->toSymbol(), 0, TYnptr);
else
//fdx->error("must be declared as extern (D) uint toHash()");
dtdword(pdt, 0);
}
//.........这里部分代码省略.........
开发者ID:DinrusGroup,项目名称:DRC,代码行数:101,代码来源:typinf.c
示例16: verifyStructSize
void TypeInfoStructDeclaration::toDt(dt_t **pdt)
{
//printf("TypeInfoStructDeclaration::toDt() '%s'\n", toChars());
if (global.params.is64bit)
verifyStructSize(Type::typeinfostruct, 17 * Target::ptrsize);
else
verifyStructSize(Type::typeinfostruct, 15 * Target::ptrsize);
dtxoff(pdt, Type::typeinfostruct->toVtblSymbol(), 0); // vtbl for TypeInfo_Struct
dtsize_t(pdt, 0); // monitor
assert(tinfo->ty == Tstruct);
TypeStruct *tc = (TypeStruct *)tinfo;
StructDeclaration *sd = tc->sym;
if (!sd->members)
return;
/* Put out:
* char[] name;
* void[] init;
* hash_t function(in void*) xtoHash;
* bool function(in void*, in void*) xopEquals;
* int function(in void*, in void*) xopCmp;
* string function(const(void)*) xtoString;
* StructFlags m_flags;
* //xgetMembers;
* xdtor;
* xpostblit;
* uint m_align;
* version (X86_64)
* TypeInfo m_arg1;
* TypeInfo m_arg2;
* xgetRTInfo
*/
const char *name = sd->toPrettyChars();
size_t namelen = strlen(name);
dtsize_t(pdt, namelen);
dtabytes(pdt, 0, namelen + 1, name);
// void[] init;
dtsize_t(pdt, sd->structsize); // init.length
if (sd->zeroInit)
dtsize_t(pdt, 0); // NULL for 0 initialization
else
dtxoff(pdt, sd->toInitializer(), 0); // init.ptr
if (FuncDeclaration *fd = search_toHash(sd))
{
dtxoff(pdt, fd->toSymbol(), 0);
TypeFunction *tf = (TypeFunction *)fd->type;
assert(tf->ty == Tfunction);
/* I'm a little unsure this is the right way to do it. Perhaps a better
* way would to automatically add these attributes to any struct member
* function with the name "toHash".
* So I'm leaving this here as an experiment for the moment.
*/
if (!tf->isnothrow || tf->trust == TRUSTsystem /*|| tf->purity == PUREimpure*/)
warning(fd->loc, "toHash() must be declared as extern (D) size_t toHash() const nothrow @safe, not %s", tf->toChars());
}
else
dtsize_t(pdt, 0);
if (sd->xeq)
dtxoff(pdt, sd->xeq->toSymbol(), 0);
else
dtsize_t(pdt, 0);
if (sd->xcmp)
dtxoff(pdt, sd->xcmp->toSymbol(), 0);
else
dtsize_t(pdt, 0);
if (FuncDeclaration *fd = search_toString(sd))
{
dtxoff(pdt, fd->toSymbol(), 0);
}
else
dtsize_t(pdt, 0);
// StructFlags m_flags;
StructFlags::Type m_flags = 0;
if (tc->hasPointers()) m_flags |= StructFlags::hasPointers;
dtsize_t(pdt, m_flags);
#if DMDV2
#if 0
// xgetMembers
FuncDeclaration *sgetmembers = sd->findGetMembers();
if (sgetmembers)
dtxoff(pdt, sgetmembers->toSymbol(), 0);
else
dtsize_t(pdt, 0); // xgetMembers
#endif
// xdtor
FuncDeclaration *sdtor = sd->dtor;
if (sdtor)
//.........这里部分代码省略.........
开发者ID:niceDreamer,项目名称:dmd,代码行数:101,代码来源:typinf.c
示例17: stripModifiers
LLType *DtoType(Type *t) {
t = stripModifiers(t);
if (t->ctype) {
return t->ctype->getLLType();
}
IF_LOG Logger::println("Building type: %s", t->toChars());
LOG_SCOPE;
assert(t);
switch (t->ty) {
// basic types
case Tvoid:
case Tint8:
case Tuns8:
case Tint16:
case Tuns16:
case Tint32:
case Tuns32:
case Tint64:
case Tuns64:
case Tint128:
case Tuns128:
case Tfloat32:
case Tfloat64:
case Tfloat80:
case Timaginary32:
case Timaginary64:
case Timaginary80:
case Tcomplex32:
case Tcomplex64:
case Tcomplex80:
// case Tbit:
case Tbool:
case Tchar:
case Twchar:
case Tdchar: {
return IrTypeBasic::get(t)->getLLType();
}
// pointers
case Tnull:
case Tpointer:
case Treference: { // CALYPSO
return IrTypePointer::get(t)->getLLType();
}
// arrays
case Tarray: {
return IrTypeArray::get(t)->getLLType();
}
case Tsarray: {
return IrTypeSArray::get(t)->getLLType();
}
// aggregates
case Tstruct: {
TypeStruct *ts = static_cast<TypeStruct *>(t);
if (ts->sym->type->ctype) {
// This should not happen, but the frontend seems to be buggy. Not
// sure if this is the best way to handle the situation, but we
// certainly don't want to override ts->sym->type->ctype.
IF_LOG Logger::cout()
<< "Struct with multiple Types detected: " << ts->toChars() << " ("
<< ts->sym->locToChars() << ")" << std::endl;
return ts->sym->type->ctype->getLLType();
}
return IrTypeStruct::get(ts->sym)->getLLType();
}
case Tclass: {
TypeClass *tc = static_cast<TypeClass *>(t);
if (tc->sym->type->ctype) {
// See Tstruct case.
IF_LOG Logger::cout()
<< "Class with multiple Types detected: " << tc->toChars() << " ("
<< tc->sym->locToChars() << ")" << std::endl;
return tc->sym->type->ctype->getLLType();
}
return IrTypeClass::get(tc->sym)->getLLType();
}
// functions
case Tfunction: {
return IrTypeFunction::get(t)->getLLType();
}
// delegates
case Tdelegate: {
return IrTypeDelegate::get(t)->getLLType();
}
// typedefs
// enum
// FIXME: maybe just call toBasetype first ?
case Tenum: {
Type *bt = t->toBasetype();
assert(bt);
//.........这里部分代码省略.........
开发者ID:Syniurge,项目名称:Calypso,代码行数:101,代码来源:tollvm.cpp
示例18: visit
void visit(TypeInfoStructDeclaration *decl) override {
IF_LOG Logger::println("TypeInfoStructDeclaration::llvmDefine() %s",
decl->toChars());
LOG_SCOPE;
// make sure struct is resolved
assert(decl->tinfo->ty == Tstruct);
TypeStruct *tc = static_cast<TypeStruct *>(decl->tinfo);
StructDeclaration *sd = tc->sym;
// check declaration in object.d
const auto structTypeInfoType = getStructTypeInfoType();
const auto structTypeInfoDecl = Type::typeinfostruct;
// On x86_64, class TypeInfo_Struct contains 2 additional fields
// (m_arg1/m_arg2) which are used for the X86_64 System V ABI varargs
// implementation. They are not present on any other cpu/os.
const bool isX86_64 =
global.params.targetTriple->getArch() == llvm::Triple::x86_64;
const unsigned expectedFields = 11 + (isX86_64 ? 2 : 0);
const unsigned actualFields =
structTypeInfoDecl->fields.dim -
1; // union of xdtor/xdtorti counts as 2 overlapping fields
if (actualFields != expectedFields) {
error(Loc(), "Unexpected number of `object.TypeInfo_Struct` fields; "
"druntime version does not match compiler");
fatal();
}
RTTIBuilder b(structTypeInfoType);
// handle opaque structs
if (!sd->members) {
Logger::println("is opaque struct, emitting dummy TypeInfo_Struct");
b.push_null_void_array(); // name
b.push_null_void_array(); // m_init
b.push_null_vp(); // xtoHash
b.push_null_vp(); // xopEquals
b.push_null_vp(); // xopCmp
b.push_null_vp(); // xtoString
b.push_uint(0); // m_flags
b.push_null_vp(); // xdtor/xdtorti
b.push_null_vp(); // xpostblit
b.push_uint(0); // m_align
if (isX86_64) {
b.push_null_vp(); // m_arg1
b.push_null_vp(); // m_arg2
}
b.push_null_vp(); // m_RTInfo
b.finalize(gvar);
return;
}
// can't emit typeinfo for forward declarations
if (sd->sizeok != SIZEOKdone) {
sd->error("cannot emit `TypeInfo` for forward declaration");
fatal();
}
DtoResolveStruct(sd);
if (TemplateInstance *ti = sd->isInstantiated()) {
if (!ti->needsCodegen()) {
assert(ti->minst || sd->requestTypeInfo);
// We won't emit ti, so emit the special member functions in here.
if (sd->xeq && sd->xeq != StructDeclaration::xerreq &&
sd->xeq->semanticRun >= PASSsemantic3) {
Declaration_codegen(sd->xeq);
}
if (sd->xcmp && sd->xcmp != StructDeclaration::xerrcmp &&
sd->xcmp->semanticRun >= PASSsemantic3) {
Declaration_codegen(sd->xcmp);
}
if (FuncDeclaration *ftostr = search_toString(sd)) {
if (ftostr->semanticRun >= PASSsemantic3)
Declaration_codegen(ftostr);
}
if (sd->xhash && sd->xhash->semanticRun >= PASSsemantic3) {
Declaration_codegen(sd->xhash);
}
if (sd->postblit && sd->postblit->semanticRun >= PASSsemantic3) {
Declaration_codegen(sd->postblit);
}
if (sd->dtor && sd->dtor->semanticRun >= PASSsemantic3) {
Declaration_codegen(sd->dtor);
}
if (sd->tidtor && sd->tidtor->semanticRun >= PASSsemantic3) {
Declaration_codegen(sd->tidtor);
}
}
}
IrAggr *iraggr = getIrAggr(sd);
// string name
b.push_string(sd->toPrettyChars());
//.........这里部分代码省略.........
开发者ID:wilzbach,项目名称:ldc,代码行数:101,代码来源:typinf.cpp
示例19: visit
void visit(TypeInfoStructDeclaration *decl)
{
IF_LOG Logger::println("TypeInfoStructDeclaration::llvmDefine() %s", decl->toChars());
LOG_SCOPE;
// make sure struct is resolved
assert(decl->tinfo->ty == Tstruct);
TypeStruct *tc = static_cast<TypeStruct *>(decl->tinfo);
StructDeclaration *sd = tc->sym;
// handle opaque structs
if (!sd->members) {
RTTIBuilder b(Type::typeinfostruct);
b.finalize(getIrGlobal(decl));
return;
}
// can't emit typeinfo for forward declarations
if (sd->sizeok != SIZEOKdone)
{
sd->error("cannot emit TypeInfo for forward declaration");
fatal();
}
DtoResolveStruct(sd);
IrAggr* iraggr = getIrAggr(sd);
RTTIBuilder b(Type::typeinfostruct);
// char[] name
b.push_string(sd->toPrettyChars());
// void[] init
// The protocol is to write a null pointer for zero-initialized arrays. The
// length field is always needed for tsize().
llvm::Constant *initPtr;
if (tc->isZeroInit(Loc()))
initPtr = getNullValue(getVoidPtrType());
else
initPtr = iraggr->getInitSymbol();
b.push_void_array(getTypeStoreSize(DtoType(tc)), initPtr);
// well use this module for all overload lookups
// toHash
FuncDeclaration* fd = sd->xhash;
b.push_funcptr(fd);
// opEquals
fd = sd->xeq;
b.push_funcptr(fd);
// opCmp
fd = sd->xcmp;
b.push_funcptr(fd);
// toString
fd = search_toString(sd);
b.push_funcptr(fd);
// uint m_flags;
unsigned hasptrs = tc->hasPointers() ? 1 : 0;
b.push_uint(hasptrs);
// On x86_64, class TypeInfo_Struct contains 2 additional fields
// (m_arg1/m_arg2) which are used for the X86_64 System V ABI varargs
// implementation. They are not present on any other cpu/os.
assert((global.params.targetTriple.getArch() != llvm::Triple::x86_64 && Type::typeinfostruct->fields.dim == 11) ||
(global.params.targetTriple.getArch() == llvm::Triple::x86_64 && Type::typeinfostruct->fields.dim == 13));
//void function(void*) xdtor;
b.push_funcptr(sd->dtor);
//void function(void*) xpostblit;
FuncDeclaration *xpostblit = sd->postblit;
if (xpostblit && sd->postblit->storage_class & STCdisable)
xpostblit = 0;
b.push_funcptr(xpostblit);
//uint m_align;
b.push_uint(tc->alignsize());
if (global.params.is64bit)
{
// TypeInfo m_arg1;
// TypeInfo m_arg2;
Type *t = sd->arg1type;
for (unsigned i = 0; i < 2; i++)
{
if (t)
{
t = t->merge();
b.push_typeinfo(t);
}
else
b.push_null(Type::dtypeinfo->type);
t = sd->arg2type;
}
}
//.........这里部分代码省略.........
开发者ID:Philpax,项目名称:ldc,代码行数:101,代码来源:typinf.cpp
注:本文中的TypeStruct类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论