// NEEDS TO BE FINISHED WHEN PRIMITIVES ARE REDONE static Type* returnInfoNumericUp(CallExpr* call) { Type* t1 = call->get(1)->typeInfo(); Type* t2 = call->get(2)->typeInfo(); if (is_int_type(t1) && is_real_type(t2)) return t2; if (is_real_type(t1) && is_int_type(t2)) return t1; if (is_int_type(t1) && is_bool_type(t2)) return t1; if (is_bool_type(t1) && is_int_type(t2)) return t2; return t1; }
// NEEDS TO BE FINISHED WHEN PRIMITIVES ARE REDONE static QualifiedType returnInfoNumericUp(CallExpr* call) { Type* t1 = call->get(1)->typeInfo(); Type* t2 = call->get(2)->typeInfo(); if (is_int_type(t1) && is_real_type(t2)) return QualifiedType(t2, QUAL_VAL); if (is_real_type(t1) && is_int_type(t2)) return QualifiedType(t1, QUAL_VAL); if (is_int_type(t1) && is_bool_type(t2)) return QualifiedType(t1, QUAL_VAL); if (is_bool_type(t1) && is_int_type(t2)) return QualifiedType(t2, QUAL_VAL); return QualifiedType(t1, QUAL_VAL); }
IntentTag blankIntentForType(Type* t) { if (isSyncType(t) || isAtomicType(t) || t->symbol->hasFlag(FLAG_ARRAY)) { return INTENT_REF; } else if (is_bool_type(t) || is_int_type(t) || is_uint_type(t) || is_real_type(t) || is_imag_type(t) || is_complex_type(t) || is_enum_type(t) || is_string_type(t) || t == dtStringC || t == dtStringCopy || isClass(t) || isRecord(t) || isUnion(t) || t == dtTaskID || t == dtFile || t == dtTaskList || t == dtNil || t == dtOpaque || t->symbol->hasFlag(FLAG_DOMAIN) || t->symbol->hasFlag(FLAG_DISTRIBUTION) || t->symbol->hasFlag(FLAG_EXTERN)) { return constIntentForType(t); } INT_FATAL(t, "Unhandled type in blankIntentForType()"); return INTENT_BLANK; }
static IntentTag constIntentForType(Type* t) { if (isSyncType(t) || isRecordWrappedType(t) || // domain, array, or distribution isRecord(t) || // may eventually want to decide based on size is_string_type(t)) { return INTENT_CONST_REF; } else if (is_bool_type(t) || is_int_type(t) || is_uint_type(t) || is_real_type(t) || is_imag_type(t) || is_complex_type(t) || is_enum_type(t) || isClass(t) || isUnion(t) || isAtomicType(t) || t == dtOpaque || t == dtTaskID || t == dtFile || t == dtTaskList || t == dtNil || t == dtStringC || t == dtStringCopy || t->symbol->hasFlag(FLAG_EXTERN)) { return INTENT_CONST_IN; } INT_FATAL(t, "Unhandled type in constIntentForType()"); return INTENT_CONST; }
// Is this type OK to pass by value (e.g. it's reasonably-sized)? static bool passableByVal(Type* type) { if (is_bool_type(type) || is_int_type(type) || is_uint_type(type) || is_real_type(type) || is_imag_type(type) || is_complex_type(type) || is_enum_type(type) || isClass(type) || type == dtTaskID || // For now, allow ranges as a special case, not records in general. type->symbol->hasFlag(FLAG_RANGE) || 0) return true; // TODO: allow reasonably-sized records. NB this-in-taskfns-in-ctors.chpl // TODO: allow reasonably-sized tuples - heterogeneous and homogeneous. return false; }
IntentTag blankIntentForType(Type* t) { IntentTag retval = INTENT_BLANK; if (isSyncType(t) || isAtomicType(t) || t->symbol->hasFlag(FLAG_DEFAULT_INTENT_IS_REF) || t->symbol->hasFlag(FLAG_ARRAY)) { retval = INTENT_REF; } else if (is_bool_type(t) || is_int_type(t) || is_uint_type(t) || is_real_type(t) || is_imag_type(t) || is_complex_type(t) || is_enum_type(t) || t == dtStringC || t == dtStringCopy || t == dtCVoidPtr || t == dtCFnPtr || isClass(t) || isRecord(t) || isUnion(t) || t == dtTaskID || t == dtFile || t == dtNil || t == dtOpaque || t->symbol->hasFlag(FLAG_DOMAIN) || t->symbol->hasFlag(FLAG_DISTRIBUTION) || t->symbol->hasFlag(FLAG_EXTERN)) { retval = constIntentForType(t); } else { INT_FATAL(t, "Unhandled type in blankIntentForType()"); } return retval; }