当前位置: 首页>>代码示例>>C++>>正文


C++ QualifiedType类代码示例

本文整理汇总了C++中QualifiedType的典型用法代码示例。如果您正苦于以下问题:C++ QualifiedType类的具体用法?C++ QualifiedType怎么用?C++ QualifiedType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QualifiedType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: assert

void ExportPass::AddSymbols()
{
  assert(repository != NULL) ;
  assert(constructedType != NULL) ;
  assert(constructedSymbol != NULL) ;

  // By this point, the repository has been read in and the symbol table
  //  has been completely overwritten.

  SymbolTable* symTab = repository->get_external_symbol_table() ;
  assert(symTab != NULL) ;

  DataType* resultType = constructedType->get_result_type() ;
  bool resultReplaced = false ;
  for (int j = 0 ; j < symTab->get_symbol_table_object_count() ; ++j)
  {
    DataType* existingType = 
      dynamic_cast<DataType*>(symTab->get_symbol_table_object(j)) ;
    if (existingType != NULL && EquivalentTypes(resultType, existingType))
    {
      constructedType->set_result_type(existingType) ;
      resultReplaced = true ;
      delete resultType ;
      break ;
    }
  }
  if (!resultReplaced)
  {
    symTab->append_symbol_table_object(resultType) ;
  }
  
  // Go through all of the arguments and replace them with appropriate types
  //  if they already exist in the symbol table.
  for (int i = 0 ; i < constructedType->get_argument_count() ; ++i)
  {
    QualifiedType* currentArg = constructedType->get_argument(i) ;
    assert(currentArg != NULL) ;
    bool replaced = false ;
    for (int j = 0 ; j < symTab->get_symbol_table_object_count() ; ++j)
    {
      QualifiedType* existingType = 
	dynamic_cast<QualifiedType*>(symTab->get_symbol_table_object(j)) ;
      if (existingType != NULL && EquivalentTypes(currentArg, existingType) &&
	  existingType->get_annote_count() == currentArg->get_annote_count())
      {
	constructedType->replace_argument(i, existingType) ;
	replaced = true ;
	break ;
      }
    }    
    if (replaced == false)
    {
      symTab->append_symbol_table_object(currentArg) ;
      symTab->append_symbol_table_object(currentArg->get_base_type()) ;
    }
  }

  symTab->append_symbol_table_object(constructedType) ;
  symTab->append_symbol_table_object(constructedSymbol) ;
}
开发者ID:JehandadKhan,项目名称:roccc-2.0,代码行数:60,代码来源:exportPass.cpp

示例2: isMoreSpecific

bool SpCandidate::isMoreSpecific(const SpCandidate * other) const {
  const Template * tm = def_->templateSignature();
  const Template * otm = other->def_->templateSignature();

  if (tm->typeParams()->size() != otm->typeParams()->size()) {
    return false;
  }

  bool same = true;
  size_t numParams = tm->typeParams()->size();
  for (size_t i = 0; i < numParams; ++i) {
    QualifiedType param = tm->typeParam(i);
    QualifiedType oparam = otm->typeParam(i);

    if (!TypeRelation::isEqual(param, oparam)) {
      same = false;
      if (!TypeRelation::isSubtype(param, oparam)) {
        if (oparam->typeClass() != Type::TypeVar) {
          return false;
        }

        // TODO: CanBind check here...
      }
    }
  }

  if (same) {
    // TODO A temporary kludge.
    if (!def_->hasUnboundTypeParams() && other->def_->hasUnboundTypeParams()) {
      return true;
    }
  }

  return !same;
}
开发者ID:afrog33k,项目名称:tart,代码行数:35,代码来源:SpCandidate.cpp

示例3: returnInfoFirstDeref

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);
}
开发者ID:rchyena,项目名称:chapel,代码行数:10,代码来源:primitive.cpp

示例4: dealias

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();
  }
}
开发者ID:afrog33k,项目名称:tart,代码行数:60,代码来源:AmbiguousTypeParamType.cpp

示例5: expandImpl

bool TypeSetConstraint::isReferenceType() const {
  QualifiedTypeSet expansion;
  expandImpl(expansion, 0);
  for (QualifiedTypeSet::iterator it = expansion.begin(); it != expansion.end(); ++it) {
    QualifiedType ty = *it;
    if (!ty->isReferenceType()) {
      return false;
    }
  }

  return true;
}
开发者ID:afrog33k,项目名称:tart,代码行数:12,代码来源:TypeConstraint.cpp

示例6: forType

void AmbiguousTypeParamType::expandImpl(QualifiedTypeSet & out, unsigned qualifiers) const {
  QualifiedTypeSet baseExpansion;
  base_.expand(baseExpansion);
  for (QualifiedTypeSet::iterator it = baseExpansion.begin(); it != baseExpansion.end(); ++it) {
    QualifiedType ty = forType(*it, match_, paramIndex_);
    if (ty) {
      ty.expand(out, qualifiers);
    } else {
      out.insert(&BadType::instance);
    }
  }
}
开发者ID:afrog33k,项目名称:tart,代码行数:12,代码来源:AmbiguousTypeParamType.cpp

示例7: qualType

GenRet ArgSymbol::codegen() {
  GenInfo* info = gGenInfo;
  FILE* outfile = info->cfile;
  GenRet ret;

  if( outfile ) {
    QualifiedType qt = qualType();
    ret.c = '&';
    ret.c += cname;
    ret.isLVPtr = GEN_PTR;
    if (qt.isRef() && !qt.isRefType())
      ret.chplType = getOrMakeRefTypeDuringCodegen(typeInfo());
    else if (qt.isWideRef() && !qt.isWideRefType()) {
      Type* refType = getOrMakeRefTypeDuringCodegen(typeInfo());
      ret.chplType = getOrMakeWideTypeDuringCodegen(refType);
    }
    /*
    // BHARSH TODO: Is this still necessary?
    if (q.isRef() && !q.isRefType()) {
      ret.c = cname;
      ret.isLVPtr = GEN_PTR;
    } else if(q.isWideRef() && !q.isWideRefType()) {
      ret.c = cname;
      ret.isLVPtr = GEN_WIDE_PTR;
    } else {
      ret.c = '&';
      ret.c += cname;
      ret.isLVPtr = GEN_PTR;
    }
    */
  } else {
#ifdef HAVE_LLVM
    ret = info->lvt->getValue(cname);
#endif
  }

  // BHARSH TODO: Is this still necessary?
  //if( requiresCPtr() ) {
  //  // Don't try to use chplType.
  //  ret.chplType = NULL;
  //  ret = codegenLocalDeref(ret);
  //}

  //ret.chplType = this->type;

  return ret;
}
开发者ID:rlugojr,项目名称:chapel,代码行数:47,代码来源:symbol.cpp

示例8: combineConversionRanks

ConversionRank CallCandidate::updateConversionRank() {
  conversionRank_ = IdenticalTypes;
  conversionCount_ = 0;

  size_t argCount = callExpr_->argCount();
  for (size_t argIndex = 0; argIndex < argCount; ++argIndex) {
    Expr * argExpr = callExpr_->arg(argIndex);
    QualifiedType paramType = this->paramType(argIndex);
    combineConversionRanks(TypeConversion::check(argExpr, paramType, TypeConversion::COERCE));
  }

  QualifiedType expectedReturnType = callExpr_->expectedReturnType();
  if (!expectedReturnType.isNull() && callExpr_->exprType() != Expr::Construct) {
    AnalyzerBase::analyzeType(resultType_, Task_PrepTypeComparison);
    combineConversionRanks(
        TypeConversion::check(resultType_, expectedReturnType, TypeConversion::COERCE));
  }

  // If there are explicit specializations, then check those too.
  // Note that these must be an exact match.
  if (spCandidate_ != NULL) {
    combineConversionRanks(spCandidate_->updateConversionRank());
  }

  if (method_ != NULL && !method_->checkMutableSelf(base_)) {
    combineConversionRanks(QualifierLoss);
  }

#if 0
  if (typeArgs_ != NULL) {
    size_t typeArgCount = typeArgs_->size();
    for (size_t i = 0; i < typeArgCount; ++i) {
      const Type * typeArg = (*typeArgs_)[i];
      const Type * typeParam = (*typeParams_)[i];
      ConversionRank rank = typeParam->canConvert(typeArg);
      if (rank < IdenticalTypes) {
        conversionRank_ = Incompatible;
        break;
      }
    }
  }
#endif

  return conversionRank_;
}
开发者ID:afrog33k,项目名称:tart,代码行数:45,代码来源:CallCandidate.cpp

示例9: assert

void ReferenceCleanupPass::CleanupCall(CallStatement* c)
{
  assert(procDef != NULL) ;
  assert(c != NULL) ;

  // We only need to clean up module calls.  If they are built in
  //  functions, like boolsel, we don't want to do this.
  if (IsBuiltIn(c))
  {
    return ;
  }
  
  // Go through the arguments and see if any of them are load variable
  //  expressions to a reference typed variable, and replace those with
  //  symbol address expressions
  for (unsigned int i = 0 ; i < c->get_argument_count() ; ++i)
  {
    Expression* currentArg = c->get_argument(i) ;
    LoadVariableExpression* currentLoadVar = 
      dynamic_cast<LoadVariableExpression*>(currentArg) ;
    if (currentLoadVar != NULL)
    {
      VariableSymbol* currentVar = currentLoadVar->get_source() ;
      DataType* varType = currentVar->get_type()->get_base_type() ;
      ReferenceType* refType = dynamic_cast<ReferenceType*>(varType) ;
      if (refType != NULL)
      {
	QualifiedType* internalType = 
	  dynamic_cast<QualifiedType*>(refType->get_reference_type()) ;
	assert(internalType != NULL) ;
	//	currentVar->set_type(internalType) ;
	SymbolAddressExpression* symAddrExp = 
	  create_symbol_address_expression(theEnv, 
					   internalType->get_base_type(),
					   currentVar) ;
	if (currentLoadVar->lookup_annote_by_name("UndefinedPath") != NULL)
	{
	  symAddrExp->append_annote(create_brick_annote(theEnv, "UndefinedPath")) ;
	}
	currentLoadVar->get_parent()->replace(currentLoadVar, symAddrExp) ;
      }
    }
  }
}
开发者ID:JehandadKhan,项目名称:roccc-2.0,代码行数:44,代码来源:reference_cleanup_pass.cpp

示例10: compatibilityError

void CallCandidate::reportConversionErrors() {
  diag.info(method_) << Format_Type << method_ << " [" << conversionRank_ << "]";

  size_t argCount = callExpr_->argCount();
  for (size_t argIndex = 0; argIndex < argCount; ++argIndex) {
    Expr * argExpr = callExpr_->arg(argIndex);
    QualifiedType paramType = this->paramType(argIndex);
    ConversionRank rank = TypeConversion::check(argExpr, paramType, TypeConversion::COERCE);
    if (isConversionWarning(rank)) {
      diag.indent();
      diag.info(callExpr_) << compatibilityError(rank) << Format_Dealias << " converting argument " <<
          argIndex << " from '" << argExpr->type() << "' to '" << paramType << "'.";
      diag.unindent();
    }
  }

  QualifiedType expectedReturnType = callExpr_->expectedReturnType();
  if (!expectedReturnType.isNull() && callExpr_->exprType() != Expr::Construct) {
    AnalyzerBase::analyzeType(resultType_, Task_PrepTypeComparison);
    ConversionRank rank = TypeConversion::check(
        resultType_, expectedReturnType, TypeConversion::COERCE);
    if (isConversionWarning(rank)) {
      diag.indent();
      diag.info(callExpr_) << compatibilityError(rank) << Format_Dealias <<
          " converting return value from '" << resultType_ << "' to '" <<
          expectedReturnType << "'.";
      diag.unindent();
    }
  }

  // If there are explicit specializations, then check those too.
  // Note that these must be an exact match.
  if (spCandidate_ != NULL) {
    spCandidate_->reportConversionErrors();
  }

  if (method_ != NULL && !method_->checkMutableSelf(base_)) {
    diag.indent();
    diag.info(callExpr_) << "Non-readonly method with a readonly 'self' argument";
    diag.unindent();
  }
}
开发者ID:afrog33k,项目名称:tart,代码行数:42,代码来源:CallCandidate.cpp

示例11: assert

bool ConstantArrayPropagationPass::ValidSymbol(VariableSymbol* var)
{
  assert(var != NULL) ;
  // The variable should be an array type and have the const qualifier.
  if (dynamic_cast<ArrayType*>(var->get_type()->get_base_type()) == NULL)
  {
    return false ;
  }
  QualifiedType* qualType = var->get_type() ;
  while (dynamic_cast<ArrayType*>(qualType->get_base_type()) != NULL)
  {
    ArrayType* array = dynamic_cast<ArrayType*>(qualType->get_base_type()) ;
    qualType = array->get_element_type() ;
  }
  assert(qualType != NULL) ;
  for (int i = 0 ; i < qualType->get_qualification_count(); ++i)
  {
    if (qualType->get_qualification(i) == LString("const"))
    {
      return true ;
    }
  }
  return false ;
}
开发者ID:JehandadKhan,项目名称:roccc-2.0,代码行数:24,代码来源:constantArrayPropagationPass.cpp

示例12: getArgSymbolCodegenType

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;
}
开发者ID:rlugojr,项目名称:chapel,代码行数:13,代码来源:symbol.cpp

示例13: compare

int LexicalTypeOrdering::compare(const QualifiedType & t0, const QualifiedType & t1) {
  int result = compare(t0.unqualified(), t1.unqualified());
  if (result != 0) {
    return result;
  }

  if (t0.qualifiers() < t1.qualifiers()) {
    return -1;
  } else if (t0.qualifiers() > t1.qualifiers()) {
    return 1;
  } else {
    return 0;
  }
}
开发者ID:afrog33k,项目名称:tart,代码行数:14,代码来源:LexicalTypeOrdering.cpp

示例14: create_parameter_symbol

void DismantleStructuredReturns::do_file_set_block( FileSetBlock* file_set_block ) {
    suif_map<CProcedureType *,QualifiedType *> type_map;
    list<ArrayReferenceExpression*> ref_exprs;
    SuifEnv *env = 0;
    TypeBuilder *tb = 0;
    VoidType *vt = 0;
    for (Iter<ProcedureSymbol> iter =
                object_iterator<ProcedureSymbol>(file_set_block);
	iter.is_valid();
	iter.next()) {
	ProcedureSymbol *sym = &iter.current();
	Type *type = sym->get_type();
	if (!is_kind_of<CProcedureType>(type))
	    continue;
	CProcedureType *cp_type = to<CProcedureType>(type);
	type = cp_type->get_result_type();
	if (!env) {
	    env = type->get_suif_env();
	    tb = (TypeBuilder*)
                env->get_object_factory(TypeBuilder::get_class_name());
	    vt = tb->get_void_type();
	    }
	suif_map<CProcedureType *,QualifiedType *>::iterator t_iter = type_map.find(cp_type);

	QualifiedType *qtype;
	
 	if (t_iter == type_map.end()) {
	    if (!is_kind_of<GroupType>(type) && !is_kind_of<ArrayType>(type))
                continue;
	    qtype = tb->get_qualified_type(
                        tb->get_pointer_type(to<DataType>(type)));

	    cp_type->set_result_type(vt);
	    
	    cp_type->insert_argument(0,qtype);
	    type_map.enter_value(cp_type,qtype);
	    }
	else {
	    qtype = (*t_iter).second;
	    }
	ProcedureDefinition *def = sym->get_definition();
	if (!def) 
	    continue;
	ParameterSymbol *par = create_parameter_symbol(env,qtype);
	def->get_symbol_table()->append_symbol_table_object(par);
        def->insert_formal_parameter(0,par);
	//	Convert all returns into assigned and returns
	for (Iter<ReturnStatement> ret_iter = object_iterator<ReturnStatement>(def->get_body());
        	ret_iter.is_valid();
        	ret_iter.next()) {
	    ReturnStatement *ret = &ret_iter.current();
	    Expression *retval = ret->get_return_value();
	    ret->set_return_value(0);
	    retval->set_parent(0);
	    insert_statement_before(ret,
			create_store_statement(env,retval,create_var_use(par)));
	    }
	}
    //	Change all calls to the new form
    for (Iter<CallStatement> cs_iter =
                object_iterator<CallStatement>(file_set_block);
        cs_iter.is_valid();
        cs_iter.next()) {
        CallStatement *call = &cs_iter.current();
	Type *type = call->get_callee_address()->get_result_type();
	Type *p_type = tb->unqualify_type(to<PointerType>(type)->get_reference_type());
        if (!is_kind_of<PointerType>(p_type))
            continue;
        p_type = tb->unqualify_type(to<PointerType>(p_type)->get_reference_type());

	if (!is_kind_of<CProcedureType>(p_type))
	    continue;
	CProcedureType *cp_type = to<CProcedureType>(p_type);
	
	suif_map<CProcedureType *,QualifiedType *>::iterator t_iter = type_map.find(cp_type);
	if (t_iter == type_map.end())
	    continue;
	QualifiedType *qtype = (*t_iter).second;
	DataType *var_type = to<DataType>(tb->unqualify_type(to<PointerType>(qtype->get_base_type())
		->get_reference_type()));
	VariableSymbol *var =
      	    new_anonymous_variable(env,call,tb->get_qualified_type(var_type));
	Expression *exp = create_symbol_address_expression(
		env,
		tb->get_pointer_type(var_type),
		var);
        call->insert_argument(0,exp);
        call->set_destination(0);
	}

    for (Iter<CallExpression> ce_iter =
                object_iterator<CallExpression>(file_set_block);
        ce_iter.is_valid();
        ce_iter.next()) {
        CallExpression *call = &ce_iter.current();
        Type *type = call->get_callee_address()->get_result_type();
        Type *p_type = tb->unqualify_type(to<PointerType>(type)->get_reference_type());
	if (!is_kind_of<PointerType>(p_type))
            continue;
	p_type = tb->unqualify_type(to<PointerType>(p_type)->get_reference_type());
//.........这里部分代码省略.........
开发者ID:JehandadKhan,项目名称:roccc-2.0,代码行数:101,代码来源:function_dismantlers.cpp

示例15: returnInfoArrayIndex

static QualifiedType
returnInfoArrayIndex(CallExpr* call) {
  QualifiedType tmp = returnInfoArrayIndexValue(call);
  return QualifiedType(tmp.type()->refType, QUAL_REF);
}
开发者ID:rchyena,项目名称:chapel,代码行数:5,代码来源:primitive.cpp


注:本文中的QualifiedType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。