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


C++ AST_Type::ast_accept方法代码示例

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


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

示例1: id

int
ast_visitor_reifying::visit_sequence (AST_Sequence *node)
{
  AST_Type *bt = node->base_type ();

  if (bt->ast_accept (this) != 0)
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                         ACE_TEXT ("ast_visitor_reifying::")
                         ACE_TEXT ("visit_sequence - ")
                         ACE_TEXT ("visit of base type failed\n")),
                        -1);
    }

  bt = AST_Type::narrow_from_decl (this->reified_node_);

  AST_Expression *v = node->max_size ();
  AST_Param_Holder *ph = v->param_holder ();

  if (ph != 0)
    {
      if (this->visit_param_holder (ph) != 0)
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             ACE_TEXT ("ast_visitor_reifying::")
                             ACE_TEXT ("visit_sequence - ")
                             ACE_TEXT ("visit_param_holder() ")
                             ACE_TEXT ("failed\n")),
                            -1);
        }

      AST_Constant *c =
        AST_Constant::narrow_from_decl (this->reified_node_);

      v = c->constant_value ();
    }

  AST_Expression *bound =
    idl_global->gen ()->create_expr (v,
                                     AST_Expression::EV_ulong);
  Identifier id ("sequence");
  UTL_ScopedName sn (&id, 0);

  this->reified_node_ =
    idl_global->gen ()->create_sequence (bound,
                                         bt,
                                         &sn,
                                         false,
                                         false);

  // No need to add this new node to any scope - it's anonymous
  // and owned by the node that references it.

  return 0;
}
开发者ID:CCJY,项目名称:ATCD,代码行数:55,代码来源:ast_visitor_reifying.cpp

示例2: visit_scope

// Specialized visit_scope method for stucts only.
int
ifr_adding_visitor_structure::visit_scope (UTL_Scope *node)
{
    // If the struct has members that are scopes but not structs,
    // the regular visit_scope method should be called instead.
    if (node->scope_node_type () != AST_Decl::NT_struct)
    {
        return ifr_adding_visitor::visit_scope (node);
    }

    AST_Structure *s = AST_Structure::narrow_from_scope (node);
    CORBA::ULong nfields = static_cast<CORBA::ULong> (s->nfields ());
    this->members_.length (nfields);
    AST_Field **f = 0;

    try
    {
        // Visit each field.
        for (CORBA::ULong i = 0; i < nfields; ++i)
        {
            if (s->field (f, i) != 0)
            {
                ORBSVCS_ERROR_RETURN ((
                                          LM_ERROR,
                                          ACE_TEXT ("(%N:%l) ifr_adding_visitor_structure::")
                                          ACE_TEXT ("visit_scope -")
                                          ACE_TEXT (" field node access failed\n")),
                                      -1);
            }

            AST_Type *ft = (*f)->field_type ();
            bool defined_here = ft->is_child (this->scope_);

            // If the struct member is defined in the struct, we have to
            // do some visiting - otherwise we can just look up the entry.
            if (defined_here)
            {
                if (ft->node_type () == AST_Decl::NT_struct)
                {
                    // Since the enclosing scope hasn't been created yet,
                    // we make a special visitor to create this member
                    // at global scope and move it into the struct later.
                    ifr_adding_visitor_structure visitor (ft);

                    if (ft->ast_accept (&visitor) == -1)
                    {
                        ORBSVCS_ERROR_RETURN ((
                                                  LM_ERROR,
                                                  ACE_TEXT ("(%N:%l) ifr_adding_visitor_structure::")
                                                  ACE_TEXT ("visit_scope -")
                                                  ACE_TEXT (" failed to accept visitor\n")),
                                              -1);
                    }

                    this->ir_current_ =
                        CORBA::IDLType::_duplicate (visitor.ir_current ());
                }
                else
                {
                    if (ft->ast_accept (this) == -1)
                    {
                        ORBSVCS_ERROR_RETURN ((
                                                  LM_ERROR,
                                                  ACE_TEXT ("(%N:%l) ifr_adding_visitor_structure::")
                                                  ACE_TEXT ("visit_scope -")
                                                  ACE_TEXT (" failed to accept visitor\n")),
                                              -1);
                    }
                }
            }
            else
            {
                // Updates ir_current_.
                this->get_referenced_type (ft);
            }

            this->members_[i].name =
                CORBA::string_dup ((*f)->local_name ()->get_string ());

            // IfR method create_struct does not use this - it just needs
            // to be non-zero for marshaling.
            this->members_[i].type =
                CORBA::TypeCode::_duplicate (CORBA::_tc_void);

            this->members_[i].type_def =
                CORBA::IDLType::_duplicate (this->ir_current_.in ());
        }
    }
    catch (const CORBA::Exception& ex)
    {
        ex._tao_print_exception (
            ACE_TEXT (
                "ifr_adding_visitor_structure::visit_scope"));

        return -1;
    }

    return 0;
}
开发者ID:akostrikov,项目名称:ATCD,代码行数:100,代码来源:ifr_adding_visitor_structure.cpp

示例3: sn

int
ast_visitor_reifying::visit_array (AST_Array *node)
{
  AST_Type *bt = node->base_type ();

  if (bt->ast_accept (this) != 0)
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                         ACE_TEXT ("ast_visitor_reifying::")
                         ACE_TEXT ("visit_array - ")
                         ACE_TEXT ("visit of base type failed\n")),
                        -1);
    }

  bt = AST_Type::narrow_from_decl (this->reified_node_);

  AST_Expression **dims = node->dims ();
  AST_Expression *v = 0;
  UTL_ExprList *v_list = 0;

  for (ACE_CDR::ULong i = 0; i < node->n_dims (); ++i)
    {
      AST_Param_Holder *ph = dims[i]->param_holder ();

      if (ph != 0)
        {
          if (this->visit_param_holder (ph) != 0)
            {
              if (v_list != 0)
                {
                  v_list->destroy ();
                  delete v_list;
                  v_list = 0;
                }

              ACE_ERROR_RETURN ((LM_ERROR,
                                 ACE_TEXT ("ast_visitor_reifying::")
                                 ACE_TEXT ("visit_array - ")
                                 ACE_TEXT ("visit_param_holder() ")
                                 ACE_TEXT ("failed\n")),
                                -1);
            }

          AST_Constant *c =
            AST_Constant::narrow_from_decl (this->reified_node_);

          ACE_NEW_RETURN (v,
                          AST_Expression (c->constant_value (),
                                          AST_Expression::EV_ulong),
                          -1);
        }
      else
        {
          ACE_NEW_RETURN (v,
                          AST_Expression (dims[i],
                                          AST_Expression::EV_ulong),
                          -1);
        }

      UTL_ExprList *el = 0;
      ACE_NEW_RETURN (el,
                      UTL_ExprList (v, 0),
                      -1);

      if (v_list == 0)
        {
          v_list = el;
        }
      else
        {
          v_list->nconc (el);
        }
    }

  UTL_ScopedName sn (node->local_name (), 0);

  AST_Array *arr =
    idl_global->gen ()->create_array (&sn,
                                      node->n_dims (),
                                      v_list,
                                      false,
                                      false);

  // No need to add this new node to any scope - it's anonymous
  // and owned by the node that references it.

  if (v_list != 0)
    {
      v_list->destroy ();
      delete v_list;
      v_list = 0;
    }

  arr->set_base_type (bt);
  this->reified_node_ = arr;

  return 0;
}
开发者ID:CCJY,项目名称:ATCD,代码行数:98,代码来源:ast_visitor_reifying.cpp

示例4: visit_scope

// Specialized visit_scope method for unions only.
int
ifr_adding_visitor_union::visit_scope (UTL_Scope *node)
{
  // If the union has members that are scopes but not unions,
  // the regular visit_scope method should be called instead.
  if (node->scope_node_type () != AST_Decl::NT_union)
    {
      return ifr_adding_visitor::visit_scope (node);
    }

  AST_Union *u = AST_Union::narrow_from_scope (node);

  CORBA::ULong nfields = static_cast<CORBA::ULong> (u->nfields ());

  this->members_.length (nfields);

  AST_Field **f = 0;

  // Index into members_.
  CORBA::ULong index = 0;

  try
    {
      // Visit each field.
      for (CORBA::ULong i = 0; i < nfields; ++i)
        {
          if (u->field (f, i) != 0)
            {
              ORBSVCS_ERROR_RETURN ((
                  LM_ERROR,
                  ACE_TEXT ("(%N:%l) ifr_adding_visitor_union::")
                  ACE_TEXT ("visit_scope -")
                  ACE_TEXT (" field node access failed\n")
                ),
                -1
              );
            }

          AST_Type *ft = (*f)->field_type ();

          bool defined_here = ft->is_child (this->scope_);

          // If the union member is defined in the union, we have to
          // do some visiting - otherwise we can just look up the entry.
          if (defined_here)
            {
              if (ft->node_type () == AST_Decl::NT_union)
                {
                  // Since the enclosing scope hasn't been created yet,
                  // we make a special visitor to create this member
                  // at global scope and move it into the union later.
                  ifr_adding_visitor_union visitor (ft);

                  if (ft->ast_accept (&visitor) == -1)
                    {
                      ORBSVCS_ERROR_RETURN ((
                        LM_ERROR,
                        ACE_TEXT ("(%N:%l) ifr_adding_visitor_union::")
                        ACE_TEXT ("visit_scope -")
                        ACE_TEXT (" failed to accept visitor\n")),
                       -1);
                    }

                  this->ir_current_ =
                    CORBA::IDLType::_duplicate (visitor.ir_current ());
                }
              else
                {
                  if (ft->ast_accept (this) == -1)
                    {
                      ORBSVCS_ERROR_RETURN ((
                        LM_ERROR,
                        ACE_TEXT ("(%N:%l) ifr_adding_visitor_union::")
                        ACE_TEXT ("visit_scope -")
                        ACE_TEXT (" failed to accept visitor\n")),
                       -1);
                    }
                }
            }
          else
            {
              // Updates ir_current_.
              this->get_referenced_type (ft);
            }

          // Get the case label(s).

          AST_UnionLabel *case_label = 0;
          AST_UnionBranch *ub = AST_UnionBranch::narrow_from_decl (*f);
          unsigned long len = ub->label_list_length ();

          // If there are multiple case labels, we will have an element
          // in the UnionMemberSeq for each label, not just for each member,
          // so the list length and the loop terminator must both be
          // increased accordingly.
          if (len > 1)
            {
              this->members_.length (this->members_.length () + len - 1);
            }
//.........这里部分代码省略.........
开发者ID:CCJY,项目名称:ATCD,代码行数:101,代码来源:ifr_adding_visitor_union.cpp


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