QualifiedType AmbiguousTypeParamType::forType(QualifiedType base, const Type * match, unsigned paramIndex) { base = dealias(base); match = dealias(match); switch (base->typeClass()) { case Type::Class: case Type::Struct: case Type::Interface: case Type::Protocol: { const CompositeType * ctBase = static_cast<const CompositeType *>(base.type()); if (const CompositeType * ctMatch = dyn_cast_or_null<CompositeType>(match)) { if (ctMatch != NULL) { base = ctBase->findBaseSpecializing(ctMatch); if (!base) { return QualifiedType(); } } if (paramIndex >= base->numTypeParams()) { return QualifiedType(); } else { return base->typeParam(paramIndex); } } return QualifiedType(); } case Type::NAddress: case Type::NArray: case Type::FlexibleArray: { if (paramIndex == 0 && (match == NULL || base->typeClass() == match->typeClass())) { return base->typeParam(0); } return QualifiedType(); } case Type::Tuple: { if (match != NULL || paramIndex >= base->numTypeParams()) { return QualifiedType(); } else { return base->typeParam(paramIndex); } } case Type::AmbiguousParameter: case Type::AmbiguousResult: case Type::AmbiguousTypeParam: case Type::AmbiguousPhi: case Type::Assignment: { QualifiedTypeSet expansion; base.expand(expansion); if (expansion.size() == 1) { return forType(*expansion.begin(), match, paramIndex); } return new AmbiguousTypeParamType(base, match, paramIndex); } default: return QualifiedType(); } }
static QualifiedType returnInfoFirstDeref(CallExpr* call) { QualifiedType tmp = call->get(1)->qualType(); Type* type = tmp.type()->getValType(); // if it's a tuple, also remove references in the elements if (type->symbol->hasFlag(FLAG_TUPLE)) { type = computeNonRefTuple(type); } return QualifiedType(type, QUAL_VAL); }
static Type* getArgSymbolCodegenType(ArgSymbol* arg) { QualifiedType q = arg->qualType(); Type* useType = q.type(); if (q.isRef() && !q.isRefType()) useType = getOrMakeRefTypeDuringCodegen(useType); if (q.isWideRef() && !q.isWideRefType()) { Type* refType = getOrMakeRefTypeDuringCodegen(useType); useType = getOrMakeWideTypeDuringCodegen(refType); } return useType; }
static QualifiedType returnInfoArrayIndex(CallExpr* call) { QualifiedType tmp = returnInfoArrayIndexValue(call); return QualifiedType(tmp.type()->refType, QUAL_REF); }
static QualifiedType returnInfoFirstDeref(CallExpr* call) { QualifiedType tmp = call->get(1)->qualType(); Type* type = tmp.type()->getValType(); return QualifiedType(type, QUAL_VAL); }