本文整理汇总了C++中Vec::add方法的典型用法代码示例。如果您正苦于以下问题:C++ Vec::add方法的具体用法?C++ Vec::add怎么用?C++ Vec::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vec
的用法示例。
在下文中一共展示了Vec::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SymbolMapCacheEntry
void
addCache(SymbolMapCache& cache, FnSymbol* oldFn, FnSymbol* fn, SymbolMap* map) {
Vec<SymbolMapCacheEntry*>* entries = cache.get(oldFn);
SymbolMapCacheEntry* entry = new SymbolMapCacheEntry(fn, map);
if (entries) {
entries->add(entry);
} else {
entries = new Vec<SymbolMapCacheEntry*>();
entries->add(entry);
cache.put(oldFn, entries);
}
}
示例2: addModuleToParseList
void addModuleToParseList(const char* name, UseStmt* useExpr) {
const char* modName = astr(name);
if (sModDoneSet.set_in(modName) == NULL &&
sModNameSet.set_in(modName) == NULL) {
if (currentModuleType == MOD_INTERNAL ||
sHandlingInternalModulesNow == true) {
sModReqdByInt.add(useExpr);
}
sModNameSet.set_add(modName);
sModNameList.add(modName);
}
}
示例3: handleLocalBlocks
//
// Do a breadth first search starting from functions generated for local blocks
// for all function calls in each level of the search, if they directly cause
// communication, add a local temp that isn't wide. If it is a resolved call,
// meaning that it isn't a primitive or external function, clone it and add it
// to the queue of functions to handle at the next iteration of the BFS.
//
static void handleLocalBlocks() {
Map<FnSymbol*,FnSymbol*> cache; // cache of localized functions
Vec<BlockStmt*> queue; // queue of blocks to localize
forv_Vec(BlockStmt, block, gBlockStmts) {
if (block->parentSymbol) {
// NOAKES 2014/11/25 Transitional. Avoid calling blockInfoGet()
if (block->isLoopStmt() == true) {
} else if (block->blockInfoGet()) {
if (block->blockInfoGet()->isPrimitive(PRIM_BLOCK_LOCAL)) {
queue.add(block);
}
}
}
}
forv_Vec(BlockStmt, block, queue) {
std::vector<CallExpr*> calls;
collectCallExprs(block, calls);
for_vector(CallExpr, call, calls) {
localizeCall(call);
if (FnSymbol* fn = call->isResolved()) {
SET_LINENO(fn);
if (FnSymbol* alreadyLocal = cache.get(fn)) {
call->baseExpr->replace(new SymExpr(alreadyLocal));
} else {
if (!fn->hasFlag(FLAG_EXTERN)) {
FnSymbol* local = fn->copy();
local->addFlag(FLAG_LOCAL_FN);
local->name = astr("_local_", fn->name);
local->cname = astr("_local_", fn->cname);
fn->defPoint->insertBefore(new DefExpr(local));
call->baseExpr->replace(new SymExpr(local));
queue.add(local->body);
cache.put(fn, local);
cache.put(local, local); // to handle recursion
if (local->retType->symbol->hasFlag(FLAG_WIDE_REF)) {
CallExpr* ret = toCallExpr(local->body->body.tail);
INT_ASSERT(ret && ret->isPrimitive(PRIM_RETURN));
// Capture the return expression in a local temp.
insertLocalTemp(ret->get(1));
local->retType = ret->get(1)->typeInfo();
}
}
}
}
}
示例4: RT_lights
//alg for calculating shading. Calls diffuseShade and SpecularShade
Color RT_lights(Figure* obj, const Ray& ray, const Vec& thePoint, const Vec& normal)
{
Color c = Color();
for (list<Light*>::iterator iterator = lightList.begin(), end = lightList.end(); iterator != end; ++iterator) {
Light* theLight = *iterator;
pair<double, Figure*> inter = nearestIntersection(Ray(Vec(thePoint), theLight->getPos()), MIN_T / SHAD_RES, 1.0, EPSILON, false);
if (inter.first <= 0) {
Vec* toLight = thePoint.normalize(theLight->getPos());
double dotProduct = toLight->dot(normal);
Vec* subt = (thePoint.sub(theLight->getPos()));
double dist = abs(subt->getMag());
Color dif = diffuseShade(obj, theLight, max(dotProduct, 0.0), dist);
Vec* Q = normal.scale(normal.dot(*toLight));
Vec* S = Q->sub(*toLight);
Vec* S2 = S->scale(2.0);
Vec* R = toLight->add(*S2);
Vec* norm = ray.getNorm();
Vec* scaledNorm = norm->scale(-1.0);
dotProduct = max(0.0, R->dot(*scaledNorm));
Color spec = specularShade(obj, normal, theLight, *toLight, pow(dotProduct, obj->getShininess()), ray, dist);
c = c.add(dif.add(spec));
delete(toLight);
delete(Q);
delete(S);
delete(R);
delete(S2);
delete(subt);
delete(norm);
delete(scaledNorm);
}
}
return c;
}
示例5: collectMyCallExprs
void collectMyCallExprs(BaseAST* ast, Vec<CallExpr*>& callExprs,
FnSymbol* parent_fn) {
AST_CHILDREN_CALL(ast, collectMyCallExprs, callExprs, parent_fn);
if (CallExpr* callExpr = toCallExpr(ast))
if (callExpr->parentSymbol == parent_fn)
callExprs.add(callExpr);
}
示例6: collect_stmts
void collect_stmts(BaseAST* ast, Vec<Expr*>& stmts) {
if (Expr* expr = toExpr(ast)) {
stmts.add(expr);
if (isBlockStmt(expr) || isCondStmt(expr)) {
AST_CHILDREN_CALL(ast, collect_stmts, stmts);
}
}
}
示例7: flattenNestedFunction
void flattenNestedFunction(FnSymbol* nestedFunction) {
if (isFnSymbol(nestedFunction->defPoint->parentSymbol)) {
Vec<FnSymbol*> nestedFunctions;
nestedFunctions.add(nestedFunction);
flattenNestedFunctions(nestedFunctions);
}
}
示例8: flattenFunctions
void flattenFunctions() {
Vec<FnSymbol*> nestedFunctions;
forv_Vec(FnSymbol, fn, gFnSymbols) {
if (isFnSymbol(fn->defPoint->parentSymbol)) {
nestedFunctions.add(fn);
}
}
markTaskFunctionsInIterators(nestedFunctions);
flattenNestedFunctions(nestedFunctions);
}
示例9: RT_reflect
//calculates reflections. Recursively calls RT_Trace
Color RT_reflect(Figure* obj, const Ray& ray, const Vec& i, const Vec& normal, double depth)
{
if (obj->isR()) {
Vec* V = ray.getV2().normalize(ray.getV1());
Vec* Q = normal.scale(normal.dot(*V));
Vec* S = Q->sub(*V);
Vec* S2 = S->scale(2.0);
Vec* R = V->add(*S2);
Vec* inter = new Vec(i);
Vec* dest = R->add(*inter);
Ray* theRay = new Ray(*inter, *dest);
Color newColor = RT_Trace(*theRay, depth + 1).mult(obj->getRef());
delete(V);
delete(Q);
delete(S);
delete(S2);
delete(R);
delete(inter);
delete(dest);
delete(theRay);
return newColor;
}
else return Color(0, 0, 0);
}
示例10: RT_transmit
//calctulates refractions. Recursively calls RT_Trace
Color RT_transmit(Figure* obj, const Ray& ray, const Vec& i, const Vec& normal,
bool inside, double depth)
{
Color returnColor = Color(0, 0, 0);
if (obj->isT()) {
double ratio = 0;
Ray transmittedRay = Ray();
double dir = 1.0;
if (!inside) {
ratio = SPACE_INDEX / obj->getIOR();
}
else {
ratio = obj->getIOR() / SPACE_INDEX;
dir = -1.0;
}
Vec* norm = normal.scale(dir);
Vec* V = ray.getV2().normalize(ray.getV1());
double dp = norm->dot(*V);
double rsqrd = pow(ratio, 2.0);
double coeff = (ratio * dp) - pow(((1 - rsqrd) + (rsqrd * pow(dp, 2.0))), 0.5);
Vec* scaledN = norm->scale(coeff);
Vec* rV = V->scale(ratio);
Vec* T = scaledN->sub(*rV);
Vec* dest = i.add(*T);
Vec* iCopy = new Vec(i);
Ray* tranRay = new Ray(*iCopy, *dest);
if (inside) {
tranRay->setInside(nullptr);
}
else tranRay->setInside(obj);
returnColor = RT_Trace(*tranRay, depth + 1);
delete(scaledN);
delete(rV);
delete(V);
delete(T);
delete(dest);
delete(iCopy);
delete(tranRay);
delete(norm);
}
return returnColor;
}
示例11: flattenClasses
void flattenClasses(void) {
//
// collect nested classes
//
Vec<AggregateType*> nestedClasses;
forv_Vec(TypeSymbol, ts, gTypeSymbols) {
if (AggregateType* ct = toAggregateType(ts->type))
if (toAggregateType(ct->symbol->defPoint->parentSymbol->type))
nestedClasses.add(ct);
}
//
// move nested classes to module level
//
forv_Vec(AggregateType, ct, nestedClasses) {
ModuleSymbol* mod = ct->getModule();
DefExpr *def = ct->symbol->defPoint;
def->remove();
mod->block->insertAtTail(def);
}
示例12: while
void
get_lines(char *b, Vec<Line *> &lines) {
int index = 0;
while (1) {
Line *l = new Line;
l->index = index++;
do {
while (*b && isspace(*b)) b++;
if (*b != '/')
break;
while (*b && *b != '\n') b++;
} while (*b);
if ((l->name = get(b)) == EOF_TOK) return;
if ((l->string = get(b)) == EOF_TOK) return;
if ((l->nargs = get(b)) == EOF_TOK) return;
if ((l->pos = get(b)) == EOF_TOK) return;
if ((l->nres = get(b, 1)) == EOF_TOK) return;
if ((l->argtypes = get(b)) == EOF_TOK) return;
if ((l->rettypes = get(b)) == EOF_TOK) return;
if ((l->options = get(b)) == EOF_TOK) return;
lines.add(l);
}
}
示例13: collectCallExprs
void collectCallExprs(BaseAST* ast, Vec<CallExpr*>& callExprs) {
AST_CHILDREN_CALL(ast, collectCallExprs, callExprs);
if (CallExpr* callExpr = toCallExpr(ast))
callExprs.add(callExpr);
}
示例14: collectDefExprs
void collectDefExprs(BaseAST* ast, Vec<DefExpr*>& defExprs) {
AST_CHILDREN_CALL(ast, collectDefExprs, defExprs);
if (DefExpr* defExpr = toDefExpr(ast))
defExprs.add(defExpr);
}
示例15: collectFnCalls
void collectFnCalls(BaseAST* ast, Vec<CallExpr*>& calls) {
AST_CHILDREN_CALL(ast, collectFnCalls, calls);
if (CallExpr* call = toCallExpr(ast))
if (call->isResolved())
calls.add(call);
}