本文整理汇总了C++中TypeVector类的典型用法代码示例。如果您正苦于以下问题:C++ TypeVector类的具体用法?C++ TypeVector怎么用?C++ TypeVector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TypeVector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
CallerInstrumentation* CallerInstrumentation::Build(
LLVMContext &Context, Module &M, StringRef FnName,
FunctionEvent::Direction Dir)
{
Function *Fn = M.getFunction(FnName);
if (Fn == NULL) return NULL;
// Instrumentation functions do not return.
Type *VoidTy = Type::getVoidTy(Context);
// Get the argument types of the function to be instrumented.
TypeVector ArgTypes;
for (auto &Arg : Fn->getArgumentList()) ArgTypes.push_back(Arg.getType());
// Declare or retrieve instrumentation functions.
string Name = (CALLER_ENTER + FnName).str();
auto InstrType = FunctionType::get(VoidTy, ArgTypes, Fn->isVarArg());
Function *Call = cast<Function>(M.getOrInsertFunction(Name, InstrType));
assert(Call != NULL);
// Instrumentation of returns must include the returned value...
TypeVector RetTypes(ArgTypes);
if (!Fn->getReturnType()->isVoidTy())
RetTypes.push_back(Fn->getReturnType());
Name = (CALLER_LEAVE + FnName).str();
InstrType = FunctionType::get(VoidTy, RetTypes, Fn->isVarArg());
Function *Return = cast<Function>(M.getOrInsertFunction(Name, InstrType));
assert(Return != NULL);
return new CallerInstrumentation(Call, Return, Dir);
}
示例2: displayOpenTag
void
herschel::xml::displayTypeVector(Port<Octet>& port, zstring tagName, const TypeVector& types)
{
if (!types.empty()) {
displayOpenTag(port, tagName);
for (size_t i = 0; i < types.size(); i++)
herschel::display(port, types[i].toString());
displayCloseTag(port, tagName);
}
}
示例3:
bool
FunctionType::isLike (TypeVector arguments, Type* return_type)
{
if (_return_type != return_type) return false;
if (_arguments.size() != arguments.size()) return false;
for (size_t i = 0; i < arguments.size(); ++i)
{
if (arguments[i] != _arguments[i]) return false;
}
return true;
}
示例4: equal
static bool equal(const TypeVector& l, const TypeVector& r) {
if (&l == &r)
return true;
if (l.size() != r.size())
return false;
TypeVector::const_iterator itl = l.begin(), itr = r.begin(),
endl = l.end();
while (itl != endl) {
if (!(*itl)->equals(*itr))
return false;
++itl;
++itr;
}
return true;
}
示例5:
bool
TupleType::hasTypes (TypeVector tys)
{
if (_subtypes.size() == tys.size())
{
for (size_t i = 0; i < tys.size(); ++i)
{
if (_subtypes[i] != tys[i])
{
return false;
}
}
return true;
}
return false;
}
示例6: addArgument
void
FunctionType::addArguments (TypeVector tys)
{
for (size_t i = 0; i < tys.size(); ++i)
{
addArgument(tys[i]);
}
}
示例7: addChild
bool
TupleType::addTypes (TypeVector tys)
{
for (size_t i = 0; i < tys.size(); ++i)
{
addChild(tys[i]);
}
_recomputeName();
return true;
}
示例8: DtoType
ldc::DIType ldc::DIBuilder::CreateVectorType(Type *type) {
LLType *T = DtoType(type);
Type *t = type->toBasetype();
assert(t->ty == Tvector &&
"Only vectors allowed for debug info in DIBuilder::CreateVectorType");
TypeVector *tv = static_cast<TypeVector *>(t);
Type *te = tv->elementType();
// translate void vectors to byte vectors
if (te->toBasetype()->ty == Tvoid)
te = Type::tuns8;
int64_t Dim = tv->size(Loc()) / te->size(Loc());
LLMetadata *subscripts[] = {DBuilder.getOrCreateSubrange(0, Dim)};
return DBuilder.createVectorType(
getTypeAllocSize(T) * 8, // size (bits)
getABITypeAlign(T) * 8, // align (bits)
CreateTypeDescription(te, false), // element type
DBuilder.getOrCreateArray(subscripts) // subscripts
);
}
示例9: DtoType
llvm::DIType ldc::DIBuilder::CreateVectorType(Type *type)
{
LLType* T = DtoType(type);
Type* t = type->toBasetype();
assert(t->ty == Tvector && "Only vectors allowed for debug info in DIBuilder::CreateVectorType");
TypeVector *tv = static_cast<TypeVector *>(t);
Type *te = tv->elementType();
int64_t Dim = tv->size(Loc()) / te->size(Loc());
llvm::Value *subscripts[] =
{
DBuilder.getOrCreateSubrange(0, Dim)
};
llvm::DIType basetype = CreateTypeDescription(te, NULL);
return DBuilder.createVectorType(
getTypeBitSize(T), // size (bits)
getABITypeAlign(T)*8, // align (bits)
basetype, // element type
DBuilder.getOrCreateArray(subscripts) // subscripts
);
}
示例10: match_types
// The scalar cases in llsd_matches() use this helper. In most cases, we can
// accept not only the exact type specified in the prototype, but also other
// types convertible to the expected type. That implies looping over an array
// of such types. If the actual type doesn't match any of them, we want to
// provide a list of acceptable conversions as well as the exact type, e.g.:
// "Integer (or Boolean, Real, String) required instead of UUID". Both the
// implementation and the calling logic are simplified by separating out the
// expected type from the convertible types.
static std::string match_types(LLSD::Type expect, // prototype.type()
const TypeVector& accept, // types convertible to that type
LLSD::Type actual, // type we're checking
const std::string& pfx) // as for llsd_matches
{
// Trivial case: if the actual type is exactly what we expect, we're good.
if (actual == expect)
return "";
// For the rest of the logic, build up a suitable error string as we go so
// we only have to make a single pass over the list of acceptable types.
// If we detect success along the way, we'll simply discard the partial
// error string.
std::ostringstream out;
out << colon(pfx) << sTypes.lookup(expect);
// If there are any convertible types, append that list.
if (! accept.empty())
{
out << " (";
const char* sep = "or ";
for (TypeVector::const_iterator ai(accept.begin()), aend(accept.end());
ai != aend; ++ai, sep = ", ")
{
// Don't forget to return success if we match any of those types...
if (actual == *ai)
return "";
out << sep << sTypes.lookup(*ai);
}
out << ')';
}
// If we got this far, it's because 'actual' was not one of the acceptable
// types, so we must return an error. 'out' already contains colon(pfx)
// and the formatted list of acceptable types, so just append the mismatch
// phrase and the actual type.
out << op << sTypes.lookup(actual);
return out.str();
}
示例11: build_class_scope
void RenameClassesPass::run_pass(DexClassesVector& dexen, ConfigFiles& cfg) {
auto scope = build_class_scope(dexen);
std::unordered_set<const DexType*> untouchables;
for (const auto& base : m_untouchable_hierarchies) {
auto base_type = DexType::get_type(base.c_str());
if (base_type != nullptr) {
untouchables.insert(base_type);
TypeVector children;
get_all_children(base_type, children);
untouchables.insert(children.begin(), children.end());
}
}
rename_classes(
scope, m_pre_filter_whitelist, m_post_filter_whitelist, m_path,
untouchables, cfg.get_proguard_map(), m_rename_annotations);
TRACE(RENAME, 1,
"renamed classes: %d anon classes, %d from single char patterns, "
"%d from multi char patterns\n",
match_inner,
match_short,
match_long);
TRACE(RENAME, 1, "String savings, at least %d bytes \n",
base_strings_size - ren_strings_size);
}
示例12: printf
MATCH ArrayLiteralExp::implicitConvTo(Type *t)
{ MATCH result = MATCHexact;
#if 0
printf("ArrayLiteralExp::implicitConvTo(this=%s, type=%s, t=%s)\n",
toChars(), type->toChars(), t->toChars());
#endif
Type *typeb = type->toBasetype();
Type *tb = t->toBasetype();
if ((tb->ty == Tarray || tb->ty == Tsarray) &&
(typeb->ty == Tarray || typeb->ty == Tsarray))
{
if (tb->ty == Tsarray)
{ TypeSArray *tsa = (TypeSArray *)tb;
if (elements->dim != tsa->dim->toInteger())
result = MATCHnomatch;
}
if (!elements->dim && typeb->nextOf()->toBasetype()->ty != Tvoid)
result = MATCHnomatch;
Type *telement = tb->nextOf();
for (size_t i = 0; i < elements->dim; i++)
{ Expression *e = (*elements)[i];
if (result == MATCHnomatch)
break; // no need to check for worse
MATCH m = (MATCH)e->implicitConvTo(telement);
if (m < result)
result = m; // remember worst match
}
if (!result)
result = type->implicitConvTo(t);
return result;
}
#if DMDV2
else if (tb->ty == Tvector &&
(typeb->ty == Tarray || typeb->ty == Tsarray))
{
// Convert array literal to vector type
TypeVector *tv = (TypeVector *)tb;
TypeSArray *tbase = (TypeSArray *)tv->basetype;
assert(tbase->ty == Tsarray);
if (elements->dim != tbase->dim->toInteger())
return MATCHnomatch;
Type *telement = tv->elementType();
for (size_t i = 0; i < elements->dim; i++)
{ Expression *e = (*elements)[i];
MATCH m = (MATCH)e->implicitConvTo(telement);
if (m < result)
result = m; // remember worst match
if (result == MATCHnomatch)
break; // no need to check for worse
}
return result;
}
#endif
else
return Expression::implicitConvTo(t);
}
示例13: 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:
error(0, "forward reference of %s", toChars());
t = TYint;
break;
case Tnull:
t = TYnptr;
break;
case Tvector:
{ TypeVector *tv = (TypeVector *)this;
TypeBasic *tb = tv->elementType();
switch (tb->ty)
{ case Tvoid:
case Tint8: t = TYschar16; break;
case Tuns8: t = TYuchar16; break;
case Tint16: t = TYshort8; break;
case Tuns16: t = TYushort8; break;
case Tint32: t = TYlong4; break;
case Tuns32: t = TYulong4; break;
case Tint64: t = TYllong2; break;
case Tuns64: t = TYullong2; break;
case Tfloat32: t = TYfloat4; break;
case Tfloat64: t = TYdouble2; break;
default:
assert(0);
break;
}
if (tv->size(0) == 32)
error(0, "AVX vector types not supported");
break;
}
default:
#ifdef DEBUG
printf("ty = %d, '%s'\n", ty, toChars());
halt();
#endif
assert(0);
}
#if DMDV2
// Add modifiers
switch (mod)
{
case 0:
//.........这里部分代码省略.........
示例14: DistanceSquare
Type DistanceSquare(const VVector& b) const {
assert(x.size() == b.x.size());
Type sum = 0.0;
for (size_t i = 0; i < x.size(); ++i)
sum += (x[i] - b.x[i]) * (x[i] - b.x[i]);
return sum;
}
示例15: GetType
Type* Protobuf::GetType(const Descriptor* descriptor) {
TypeMap::iterator it = mTypeMap.find(descriptor);
if (it != mTypeMap.end())
return it->second;
Type* result = mTypeMap[descriptor] =
new Type(this,
factory.GetPrototype(descriptor)->New(),
TypeTemplate->GetFunction()->NewInstance(),
handles.size());
handles.push_back(result);
Handle<Array> types = handle_->GetInternalField(1).As<Array>();
types->Set(types->Length(), result->handle_);
return result;
}