本文整理汇总了C++中TypeList::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ TypeList::push_back方法的具体用法?C++ TypeList::push_back怎么用?C++ TypeList::push_back使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TypeList
的用法示例。
在下文中一共展示了TypeList::push_back方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FieldDecl
/**
* Create a new field declaration with exactly one variable in it.
* If the field is uninitialized, the initializer may be
* <code>null</code>.
*
* @param context Context indicating what line and file this
* field is created at
* @param type Type of the field
* @param name Name of the field
* @param init Expression initializing the field, or
* <code>null</code> if the field is uninitialized
*/
FieldDecl(FEContext *context, Type *type, string name,
Expression *init) : FENode(context)
{
types = new TypeList;
names = new NameList;
inits = new ExpressionList;
types->push_back(type);
names->push_back(name);
inits->push_back(init);
}
示例2: writeSchema
void ObjectWrapper::writeSchema( StringList& properties, TypeList& types )
{
SerializerList::iterator sitr = _serializers.begin();
TypeList::iterator titr = _typeList.begin();
while(sitr!=_serializers.end() && titr!=_typeList.end())
{
if ((*sitr)->supportsReadWrite())
{
properties.push_back( (*sitr)->getName() );
types.push_back( (*titr) );
}
++sitr;
++titr;
}
}
示例3: createKernelCallLambda
ExpressionPtr KernelReplacer::createKernelCallLambda(const ExpressionAddress localKernel,
const ExpressionPtr work_dim, const ExpressionPtr local_work_size, const ExpressionPtr global_work_size) {
NodeManager& mgr = prog->getNodeManager();
IRBuilder builder(mgr);
ExpressionPtr k = utils::getRootVariable(localKernel).as<ExpressionPtr>();
/*
std::cout << "searching " << *k << " from " << *localKernel << std::endl;
if(kernelFunctions.empty()) std::cout << "\tnothing\n";
for_each(kernelFunctions, [](std::pair<core::ExpressionPtr, core::LambdaExprPtr> kernel) {
std::cout << "in " << *kernel.first << std::endl;
});
*/
// try to find coresponding kernel function
assert(kernelFunctions.find(k) != kernelFunctions.end() && "Cannot find OpenCL Kernel");
const ExpressionPtr local = anythingToVec3(work_dim, local_work_size);
const ExpressionPtr global = anythingToVec3(work_dim, global_work_size);
LambdaExprPtr lambda = kernelFunctions[k].as<LambdaExprPtr>();
//dumpPretty(lambda);
//for_each(kernelTypes[k], [&](TypePtr ty) {
// std::cout << "->\t" << *ty << std::endl;
//});
/* assert(kernelArgs.find(k) != kernelArgs.end() && "No arguments for call to kernel function found");
const VariablePtr& args = kernelArgs[k];
const TupleTypePtr& argTypes = dynamic_pointer_cast<const TupleType>(args->getType());*/
const VariableList& interface = lambda->getParameterList()->getElements();
vector<ExpressionPtr> innerArgs;
const core::lang::BasicGenerator& gen = builder.getLangBasic();
// construct call to kernel function
// if(localMemDecls.find(k) == localMemDecls.end() || localMemDecls[k].size() == 0) {
//std::cout << "lmd " << localMemDecls[k] << std::endl;
TypeList kernelType = kernelTypes[k];
/* body of a newly created function which replaces clNDRangeKernel. It contains
* the kernel call
* return 0;
*/
StatementList body;
// Kernel variable to be used inside the newly created function
VariablePtr innerKernel = builder.variable(builder.tupleType(kernelType));
for(size_t i = 0; i < interface.size() -2 /*argTypes->getElementTypes().size()*/; ++i) {
//?? TypePtr argTy = utils::vectorArrayTypeToScalarArrayType(interface.at(i)->getType(), builder);
TypePtr argTy = interface.at(i)->getType();
TypePtr memberTy = kernelType.at(i);
ExpressionPtr tupleMemberAccess = builder.callExpr(memberTy, gen.getTupleMemberAccess(), utils::removeDoubleRef(innerKernel),
builder.literal(gen.getUInt8(), toString(i)), builder.getTypeLiteral(memberTy));
ExpressionPtr argument = handleArgument(argTy, memberTy, tupleMemberAccess, body);
innerArgs.push_back(argument);
}
const TypePtr vecTy = builder.vectorType(gen.getUInt8(), builder.concreteIntTypeParam(static_cast<size_t>(3)));
// local and global size to be used inside the newly created function
VariablePtr innerGlobal = builder.variable(vecTy);
VariablePtr innerLocal = builder.variable(vecTy);
// add global and local size to arguments
innerArgs.push_back(innerGlobal);
innerArgs.push_back(innerLocal);
ExpressionPtr kernelCall = builder.callExpr(gen.getInt4(), lambda, innerArgs);
body.push_back(kernelCall); // calling the kernel function
body.push_back(builder.returnStmt(builder.intLit(0))); // return CL_SUCCESS
// create function type for inner function: kernel tuple, global size, local size
TypeList innerFctInterface;
innerFctInterface.push_back(innerKernel->getType());
innerFctInterface.push_back(vecTy);
innerFctInterface.push_back(vecTy);
FunctionTypePtr innerFctTy = builder.functionType(innerFctInterface, gen.getInt4());
// collect inner function parameters
VariableList innerFctParams;
innerFctParams.push_back(innerKernel);
innerFctParams.push_back(innerGlobal);
innerFctParams.push_back(innerLocal);
// create lambda for inner function
LambdaExprPtr innerLambda = builder.lambdaExpr(innerFctTy, builder.parameters(innerFctParams), builder.compoundStmt(body));
return builder.callExpr(gen.getInt4(), innerLambda, builder.deref(localKernel), global, local);
}
示例4: getJoinMeetType
/**
* Computes a join or meet type for the given pair of types. The join flag allows to determine
* whether the join or meet type is computed.
*/
TypePtr getJoinMeetType(const TypePtr& typeA, const TypePtr& typeB, bool join) {
static const TypePtr fail = 0;
// add a structure based algorithm for computing the Join-Type
// shortcut for equal types
if (*typeA == *typeB) {
return typeA;
}
// the rest depends on the node types
NodeType nodeTypeA = typeA->getNodeType();
NodeType nodeTypeB = typeB->getNodeType();
// handle generic types
if (nodeTypeA == NT_GenericType && nodeTypeB == NT_GenericType) {
// let the join computation handle the case
const GenericTypePtr& genTypeA = static_pointer_cast<const GenericType>(typeA);
const GenericTypePtr& genTypeB = static_pointer_cast<const GenericType>(typeB);
return (join) ? getJoinType(genTypeA, genTypeB) : getMeetType(genTypeA, genTypeB);
}
// handle vector types (only if array super type of A is a super type of B)
// make sure typeA is the vector
if (nodeTypeA != NT_VectorType && nodeTypeB == NT_VectorType) {
// switch sides
return getJoinMeetType(typeB, typeA, join);
}
// handle vector-array conversion (only works for joins)
if (join && nodeTypeA == NT_VectorType) {
VectorTypePtr vector = static_pointer_cast<const VectorType>(typeA);
// the only potential super type is an array of the same element type
IRBuilder builder(vector->getNodeManager());
ArrayTypePtr array = builder.arrayType(vector->getElementType());
if (isSubTypeOf(typeB, array)) {
return array;
}
// no common super type!
return fail;
}
// the rest can only work if it is of the same kind
if (nodeTypeA != nodeTypeB) {
// => no common super type
return fail;
}
// check for functions
if (nodeTypeA == NT_FunctionType) {
FunctionTypePtr funTypeA = static_pointer_cast<const FunctionType>(typeA);
FunctionTypePtr funTypeB = static_pointer_cast<const FunctionType>(typeB);
// check number of arguments
auto paramsA = funTypeA->getParameterTypes();
auto paramsB = funTypeB->getParameterTypes();
if (paramsA.size() != paramsB.size()) {
// not matching
return fail;
}
// check function kind
FunctionKind resKind = funTypeA->getKind();
if (funTypeA->getKind() != funTypeB->getKind()) {
// differences are only allowed when going from plain to closure type
if ((funTypeA->isPlain() && funTypeB->isClosure()) || (funTypeA->isClosure() && funTypeB->isPlain())) {
resKind = FK_CLOSURE;
} else {
return fail;
}
}
// compute join type
// JOIN/MEET result and argument types - if possible
TypePtr cur = getJoinMeetType(funTypeA->getReturnType(), funTypeB->getReturnType(), join);
TypePtr resType = cur;
// continue with parameters
TypeList params;
for (std::size_t i=0; i<paramsA.size(); i++) {
// ATTENTION: this goes in the reverse direction
cur = getJoinMeetType(paramsA[i], paramsB[i], !join);
// if a pair can not be matched => fail
if (!cur) return fail;
params.push_back(cur);
}
// construct resulting type
IRBuilder builder(funTypeA->getNodeManager());
return builder.functionType(params, resType, resKind);
}
//.........这里部分代码省略.........