static Type* returnInfoVal(CallExpr* call) { AggregateType* ct = toAggregateType(call->get(1)->typeInfo()); if (!ct || !ct->symbol->hasFlag(FLAG_REF)) INT_FATAL(call, "attempt to get value type of non-reference type"); return ct->getField(1)->type; }
static QualifiedType returnInfoVal(CallExpr* call) { AggregateType* ct = toAggregateType(call->get(1)->typeInfo()); if (ct) { if (call->get(1)->isRef()) { if(ct->symbol->hasFlag(FLAG_REF)) { return QualifiedType(ct->getField(1)->type, QUAL_VAL); } else { return QualifiedType(ct, QUAL_VAL); } } else if (call->get(1)->isWideRef()) { if(ct->symbol->hasFlag(FLAG_WIDE_REF)) { return QualifiedType(ct->getField(2)->type, QUAL_VAL); } else { return QualifiedType(ct, QUAL_VAL); } } else if (ct->symbol->hasFlag(FLAG_WIDE_CLASS)) { // insertWideReferences will sometimes insert a PRIM_DEREF to a // wide class. There should probably be a better way of expressing the // desired pattern... return QualifiedType(ct, QUAL_VAL); } } INT_FATAL(call, "attempt to get value type of non-reference type"); return QualifiedType(NULL); }
static QualifiedType returnInfoVal(CallExpr* call) { AggregateType* ct = toAggregateType(call->get(1)->typeInfo()); if (ct) { if(ct->symbol->hasFlag(FLAG_REF)) { return QualifiedType(ct->getField(1)->type, QUAL_VAL); } else if(ct->symbol->hasFlag(FLAG_WIDE_REF)) { return QualifiedType(ct->getField(2)->type, QUAL_VAL); } } INT_FATAL(call, "attempt to get value type of non-reference type"); return QualifiedType(NULL); }
static QualifiedType returnInfoGetMember(CallExpr* call) { AggregateType* ct = toAggregateType(call->get(1)->typeInfo()); if (ct->symbol->hasFlag(FLAG_REF)) ct = toAggregateType(ct->getValType()); if (!ct) INT_FATAL(call, "bad member primitive"); SymExpr* sym = toSymExpr(call->get(2)); if (!sym) INT_FATAL(call, "bad member primitive"); VarSymbol* var = toVarSymbol(sym->symbol()); if (!var) INT_FATAL(call, "bad member primitive"); if (var->immediate) { const char* name = var->immediate->v_string; for_fields(field, ct) { if (!strcmp(field->name, name)) return field->qualType(); } } else return sym->qualType();
void VarSymbol::codegenDefC(bool global, bool isHeader) { GenInfo* info = gGenInfo; if (this->hasFlag(FLAG_EXTERN)) return; if (type == dtVoid) return; AggregateType* ct = toAggregateType(type); QualifiedType qt = qualType(); if (qt.isRef() && !qt.isRefType()) { Type* refType = getOrMakeRefTypeDuringCodegen(type); ct = toAggregateType(refType); } if (qt.isWideRef() && !qt.isWideRefType()) { Type* refType = getOrMakeRefTypeDuringCodegen(type); Type* wideType = getOrMakeWideTypeDuringCodegen(refType); ct = toAggregateType(wideType); } Type* useType = type; if (ct) useType = ct; std::string typestr = (this->hasFlag(FLAG_SUPER_CLASS) ? std::string(toAggregateType(useType)->classStructName(true)) : useType->codegen().c); // // a variable can be codegen'd as static if it is global and neither // exported nor external. // std::string str; if(fIncrementalCompilation) { bool addExtern = global && isHeader; str = (addExtern ? "extern " : "") + typestr + " " + cname; } else { bool isStatic = global && !hasFlag(FLAG_EXPORT) && !hasFlag(FLAG_EXTERN); str = (isStatic ? "static " : "") + typestr + " " + cname; } if (ct) { if (ct->isClass()) { if (isFnSymbol(defPoint->parentSymbol)) { str += " = NULL"; } } else if (ct->symbol->hasFlag(FLAG_WIDE_REF) || ct->symbol->hasFlag(FLAG_WIDE_CLASS)) { if (isFnSymbol(defPoint->parentSymbol)) { if (widePointersStruct) { // // CHPL_LOCALEID_T_INIT is #defined in the chpl-locale-model.h // file in the runtime, for the selected locale model. // str += " = {CHPL_LOCALEID_T_INIT, NULL}"; } else { str += " = ((wide_ptr_t) NULL)"; } } } } if (fGenIDS) str = idCommentTemp(this) + str; if (printCppLineno && !isHeader && !isTypeSymbol(defPoint->parentSymbol)) str = zlineToString(this) + str; info->cLocalDecls.push_back(str); }