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


C++ SgInitializedName::get_typeptr方法代码示例

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


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

示例1: isSgArrayType

/**
 * class: SgVarRefExp
 * term: var_ref_exp_annotation(tpe,name,static,scope)
 * arg tpe: type
 * arg name: name
 * arg static: wether the declaration was static
 * arg scope: scope name (either from a namespace, a class or "null")
 */
PrologCompTerm* 
RoseToTerm::getVarRefExpSpecific(SgVarRefExp* vr) {
  SgInitializedName* n = vr->get_symbol()->get_declaration();
  /* type: in general, this can be taken "as is" from the ROSE AST. However,
   * ROSE (up to 0.9.4a-8xxx at least) gets a detail wrong: a declaration
   * like "int arr[]" as a function parameter declares a *pointer*, not an
   * array. Thus we check whether the variable might be of this sort, and if
   * yes, we must make a pointer type for it. */
  PrologTerm* typeSpecific = NULL;
  SgInitializedName* vardecl = vr->get_symbol()->get_declaration();
  SgType* t = vr->get_type()->stripType(SgType::STRIP_MODIFIER_TYPE
                                      | SgType::STRIP_REFERENCE_TYPE
                                      | SgType::STRIP_TYPEDEF_TYPE);
  if (isSgFunctionParameterList(vardecl->get_parent()) && isSgArrayType(t)) {
    SgType* baseType = isSgArrayType(t)->get_base_type();
    PrologTerm* baseTypeSpecific = getTypeSpecific(baseType);
    typeSpecific = new PrologCompTerm("pointer_type", /*1,*/ baseTypeSpecific);
  } else {
    typeSpecific = getTypeSpecific(n->get_typeptr());
  }
  /* static? (relevant for unparsing if scope is a class)*/
  PrologTerm *isStatic;
  SgDeclarationStatement* vdec = n->get_declaration();
  if (vdec != NULL) {
    isStatic = 
      getEnum(vdec->get_declarationModifier().get_storageModifier().isStatic(),
	      re.static_flags);
  } else {
    isStatic = getEnum(0, re.static_flags);
  }
  PrologTerm* scope;
  if (vdec != NULL) {
    /* named scope or irrelevant?*/
    if (SgNamespaceDefinitionStatement* scn = 
	isSgNamespaceDefinitionStatement(vdec->get_parent())) {
      scope = getNamespaceScopeName(scn);
    } else if (SgClassDefinition* scn = 
	       isSgClassDefinition(vdec->get_parent())) {
      scope = getClassScopeName(scn);
    } else {
      scope = new PrologAtom("null");
    }
  } else {
    scope = new PrologAtom("null");
  }

  return new PrologCompTerm
    ("var_ref_exp_annotation", //5,
     typeSpecific,
     /* name*/ new PrologAtom(n->get_name().getString()),
     isStatic,
     scope,
     PPI(vr));
}
开发者ID:8l,项目名称:rose,代码行数:62,代码来源:RoseToTerm.C


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