示例#1
0
// Compute the size type of the node in question.
int
AST_Structure::compute_size_type (void)
{
  for (UTL_ScopeActiveIterator si (this, UTL_Scope::IK_decls);
       !si.is_done ();
       si.next ())
    {
      // Get the next AST decl node.
      AST_Decl *d = si.item ();

      if (d->node_type () == AST_Decl::NT_enum_val)
        {
          continue;
        }

      AST_Field *f = AST_Field::narrow_from_decl (d);
      AST_Type *t = f->field_type ();

      if (t != 0)
        {
          this->size_type (t->size_type ());

          // While we're iterating, we might as well do this one too.
          this->has_constructor (t->has_constructor ());
        }
      else
        {
          ACE_DEBUG ((LM_DEBUG,
                      "WARNING (%N:%l) be_structure::compute_size_type - "
                      "narrow_from_decl returned 0\n"));
        }
    }

  return 0;
}
示例#2
0
void
be_enum::FinishProtoTypeCode()
{
   // flesh out typecode
   // since enums names are all in a scope and not added directly
   // we go through the scope and add them all here
   UTL_Scope* s = (UTL_Scope*)narrow((long) & UTL_Scope::type_id);
   assert(s);

   UTL_ScopeActiveIterator* i = 0;
   i = new UTL_ScopeActiveIterator(s, UTL_Scope::IK_decls);

   if (s->nmembers() > 0)
   {
      for ( ; !(i->is_done()); i->next())
      {
         AST_Decl* d = i->item();
         assert(d);

         m_typecode->member_names.push_back(d->local_name()->get_string());
      }

      delete i;
   }
}
int
ast_visitor_tmpl_module_inst::visit_scope (UTL_Scope *node)
{
  for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
       !si.is_done ();
       si.next ())
    {
      AST_Decl *d = si.item ();

      if (d == 0)
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             ACE_TEXT ("ast_visitor_tmpl_module_inst::")
                             ACE_TEXT ("visit_scope - ")
                             ACE_TEXT ("bad node in this scope\n")),
                            -1);
        }

      // Send the visitor.
      if (d == 0 || d->ast_accept (this) == -1)
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             ACE_TEXT ("ast_visitor_tmpl_module_inst::")
                             ACE_TEXT ("visit_scope - ")
                             ACE_TEXT ("codegen for scope failed\n")),
                            -1);
        }
    }

  return 0;
}
示例#4
0
// Dump this AST_Factory node to the ostream o.
void
AST_Finder::dump (ACE_OSTREAM_TYPE &o)
{
  AST_Decl *d = 0;

  this->dump_i (o, "finder ");
  this->local_name ()->dump (o);
  this->dump_i (o, "(");

  // Iterator must be explicitly advanced inside the loop.
  for (UTL_ScopeActiveIterator i (this, IK_decls);
       !i.is_done ();)
    {
      d = i.item ();
      d->dump (o);
      i.next ();

      if (!i.is_done())
        {
          this->dump_i (o, ", ");
        }
    }

  this->dump_i (o, ")");
}
示例#5
0
void
be_visitor_valuetype_obv_cs::gen_obv_init_constructor_inits (
    be_valuetype *node
  )
{
  TAO_OutStream *os = this->ctx_->stream ();
  AST_Type *parent = node->inherits_concrete ();

  // Generate for inherited members first.
  if (parent != 0)
    {
      be_valuetype *be_parent = be_valuetype::narrow_from_decl (parent);
      this->gen_obv_init_constructor_inits (be_parent);
    }

  for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
       !si.is_done ();
       si.next())
    {
      // be_attribute inherits from be_field
      // so we have to also screen out attributes
      be_field *f = be_field::narrow_from_decl (si.item ());
      be_attribute *attr =
        be_attribute::narrow_from_decl (si.item ());

      if (f == 0 || attr != 0)
        {
          continue;
        }

      *os << be_nl
          << f->local_name () << " (_tao_init_" << f->local_name ()
          << ");";
    }
}
示例#6
0
文件: home_svs.cpp 项目: CCJY/ATCD
int
be_visitor_home_attr_set::visit_home (be_home *node)
{
  if (node == 0)
    {
      return 0;
    }

  for (UTL_ScopeActiveIterator i (node, UTL_Scope::IK_decls);
       !i.is_done ();
       i.next ())
    {
      be_decl *d = be_decl::narrow_from_decl (i.item ());

      if (d->accept (this) == -1)
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             ACE_TEXT ("be_visitor_home_attr_set")
                             ACE_TEXT ("::visit_home - ")
                             ACE_TEXT ("accept () failed\n")),
                            -1);
        }
    }

  be_home *h = be_home::narrow_from_decl (node->base_home ());

  return this->visit_home (h);
}
示例#7
0
bool
AST_Structure::is_local (void)
{
  if (this->local_struct_ == -1)
    {
      if (this->is_local_)
        {
          this->local_struct_ = this->is_local_;
        }
      else
        {
          this->local_struct_ = 0;

          if (this->nmembers () > 0)
            {
              // Instantiate a scope iterator.
              for (UTL_ScopeActiveIterator si (this, UTL_Scope::IK_decls);
                   !si.is_done ();
                   si.next ())
                {
                  if (si.item ()->is_local ())
                    {
                      this->local_struct_ = true;
                      break;
                    }
                }
            }
        }
    }

  return this->local_struct_;
}
示例#8
0
void be_exception::GenerateAssignmentOperator (be_ClientImplementation& source)
{
   ostream & os = source.Stream ();
   DDS_StdString that ("");
   be_Type * btype;

   if (nmembers ())
   {
      that = " that";
   }

   os << ScopedName () << " & "
      << ScopedName () << "::operator = (const "
      << LocalName () << " &" << that << ")" << nl;
   os << "{" << nl;

   UTL_Scope * s = (UTL_Scope*)narrow((long) & UTL_Scope::type_id);
   assert (s);

   UTL_ScopeActiveIterator *it;

   // Iterate through decls

   for 
   (
      it = new UTL_ScopeActiveIterator (s, UTL_Scope::IK_decls);
      ! it->is_done ();
      it->next ()
   )
   {
      AST_Decl * adecl = it->item ();
      assert (adecl);

      be_field *bfield = (be_field *) adecl->narrow ((long) & be_field::type_id);

      if (bfield)
      {
         btype = bfield->get_be_type ();
         if (btype && btype->IsArrayType ())
         {
            // Need to copy array elements

            os << "   "
               << (char*) BE_Globals::RelativeScope (ScopedName (), bfield->StructMemberTypeName ())
               << "_copy (" << bfield->get_local_name () 
               << ", that." << bfield->get_local_name () << ");" << nl;
         }
         else
         {
            os << "   " << bfield->get_local_name () << " = that."
               << bfield->get_local_name() << ";" << nl;
         }
      }
   }

   delete it;

   os << "   return *this;" << nl;
   os << "}" << nl << nl;
}
示例#9
0
bool
be_valuetype::has_member (void)
{
  AST_Type *parent = this->pd_inherits_concrete;

  // We're looking for inherited members too.
  if (parent != 0)
    {
      be_valuetype *be_parent =
        be_valuetype::narrow_from_decl (parent);

      if (be_parent->has_member ())
        {
          return true;
        }
    }

  for (UTL_ScopeActiveIterator si (this, UTL_Scope::IK_decls);
       !si.is_done ();
       si.next())
    {
      if (si.item ()->node_type () == AST_Decl::NT_field)
        {
          return true;
        }
    }

  return false;
}
示例#10
0
文件: ast_union.cpp 项目: CCJY/ATCD
// Look up the default branch in union.
AST_UnionBranch *
AST_Union::lookup_default (void)
{
  AST_UnionBranch *b = 0;
  AST_Decl *d = 0;

  for (UTL_ScopeActiveIterator i (this, UTL_Scope::IK_both);
       !i.is_done();
       i.next ())
    {
      d = i.item ();

      if (d->node_type () == AST_Decl::NT_union_branch)
        {
          b = AST_UnionBranch::narrow_from_decl (d);

          if (b == 0)
            {
              continue;
            }

          if (b->label () != 0
              && b->label ()->label_kind () == AST_UnionLabel::UL_default)
            {
              idl_global->err ()->error2 (UTL_Error::EIDL_MULTIPLE_BRANCH,
                                          this,
                                          b);
              return b;
            }
        }
    }

  return 0;
}
示例#11
0
文件: be_home.cpp 项目: asdlei00/ACE
void
be_home::scan (UTL_Scope *s)
{
  if (s == 0)
    {
      return;
    }

  for (UTL_ScopeActiveIterator i (s, UTL_Scope::IK_both);
       !i.is_done ();
       i.next ())
    {
      AST_Decl *d = i.item ();
      AST_Attribute *attr =
        AST_Attribute::narrow_from_decl (d);

      if (attr != 0 && ! attr->readonly ())
        {
          this->has_rw_attributes_ = true;
          return;
        }
    }

  AST_Home *h = AST_Home::narrow_from_scope (s);

  if (h != 0)
    {
      this->scan (h->base_home ());
    }
}
示例#12
0
void
be_CodeGenerator::Generate(be_ClientImplementation& source)
{
   UTL_ScopeActiveIterator* i;
   AST_Decl * d;
   UTL_Scope * s = (UTL_Scope*)narrow((long) & UTL_Scope::type_id);

   if (s)
   {
      i = new UTL_ScopeActiveIterator(s, UTL_Scope::IK_decls);

      while (!(i->is_done()))
      {
         be_CodeGenerator * cg;

         d = i->item();

         if (!d->imported() &&
             (cg = (be_CodeGenerator*)d->narrow((long) & be_CodeGenerator::type_id)))
         {
            cg->Generate(source);
         }

         i->next();
      }

      delete i;
   }
   else
   {
      assert(pbfalse);
   }
}
示例#13
0
void be_root::GenerateGlobalDecls (be_ClientHeader & source)
{
   UTL_ScopeActiveIterator * i;
   be_CodeGenerator * cg;
   AST_Decl * d;
   UTL_Scope * s = (UTL_Scope*) narrow ((long) & UTL_Scope::type_id);

   if (s)
   {
      // Iterate through decls

      i = new UTL_ScopeActiveIterator (s, UTL_Scope::IK_decls);

      while (!(i->is_done ()))
      {
         d = i->item ();

         if (!d->imported ())
         {
            cg = (be_CodeGenerator*) d->narrow
               ((long) & be_CodeGenerator::type_id);

            if (cg)
            {
               cg->Generate (source);
            }
         }

         i->next ();
      }

      delete i;
   }
}
示例#14
0
bool
AST_Structure::legal_for_primary_key (void) const
{
  bool retval = true;

  if (!this->recursing_in_legal_pk_)
    {
      this->recursing_in_legal_pk_ = true;

      for (UTL_ScopeActiveIterator si (const_cast<AST_Structure *> (this),
                                      UTL_Scope::IK_decls);
          !si.is_done ();
          si.next ())
        {
          AST_Field *f = AST_Field::narrow_from_decl (si.item ());

          if (f != 0 && !f->field_type ()->legal_for_primary_key ())
            {
              retval = false;
              break;
            }
        }

      this->recursing_in_legal_pk_ = false;
    }

  return retval;
}
示例#15
0
// Operations for field marshaling.
int
be_visitor_valuetype_marshal_cs::gen_fields (be_valuetype *node,
                                             be_visitor_context &ctx)
{
  int n_processed = 0;
  TAO_OutStream *os = ctx.stream ();
  this->elem_number_ = 0;

  // Initialize an iterator to iterate thru our scope.
  for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
       !si.is_done ();
       si.next())
    {
      AST_Decl *d = si.item ();

      if (!d)
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             ACE_TEXT ("be_visitor_scope::visit_scope - ")
                             ACE_TEXT ("bad node in this scope\n")),
                            -1);
        }

      // (JP) 2010-10-21
      // be_attribute now inherits from be_field, so we need this check.
      be_attribute *attr = be_attribute::narrow_from_decl (d);

      be_field *field = be_field::narrow_from_decl (d);

      if (field != 0 && attr == 0)
        {
          if (n_processed > 0)
            {
              *os << " &&" << be_nl;
            }

          ++n_processed;
          be_visitor_valuetype_field_cdr_cs visitor (&ctx);
          visitor.pre_ = node->field_pd_prefix ();
          visitor.post_ = node->field_pd_postfix ();

          if (visitor.visit_field (field) == -1)
            {
              ACE_ERROR_RETURN ((LM_ERROR,
                                 ACE_TEXT ("be_visitor_valuetype_marshal_cs::")
                                 ACE_TEXT ("visit_valuetype - ")
                                 ACE_TEXT ("codegen for scope failed\n")),
                                -1);
            }
        }
    }

  if (n_processed == 0)
    {
      *os << "true";
    }

  return 0;
}
示例#16
0
void be_exception::GenerateConvenienceConstructor (be_ClientHeader& source)
{
   ostream & os = source.Stream ();
   const char * argPrefix = "_";
   pbbool first = pbtrue;
   be_Tab tab (source);

   os << tab << LocalName () << " (";

   UTL_Scope * s = (UTL_Scope*)narrow ((long) & UTL_Scope::type_id);
   assert (s);

   // Iterate through decls

   UTL_ScopeActiveIterator *it;

   for
   (
      it = new UTL_ScopeActiveIterator (s, UTL_Scope::IK_decls);
      !it->is_done ();
      it->next ()
   )
   {
      AST_Decl * adecl = it->item();
      assert (adecl);
      be_field * bfield = be_field::_narrow (adecl);
      be_Type * btype;

      if (bfield)
      {
         btype = bfield->get_be_type ();

         if (!first)
         {
            os << ", ";
         }

         first = pbfalse;

         if (btype && btype->IsStringType ())
         {
            // Strings are special case

            os << (char*) BE_Globals::RelativeScope (ScopedName (), bfield->InTypeName ());
         }
         else
         {
            os << (char*) BE_Globals::RelativeScope (ScopedName (), bfield->StructMemberTypeName ());
         }

         os << " " << argPrefix << (char*) bfield->get_local_name ();
      }
   }

   delete it;

   os << ");" << nl;
}
示例#17
0
// Compute total number of members.
int
AST_Operation::compute_argument_attr (void)
{
  if (this->argument_count_ != -1)
    {
      return 0;
    }

  AST_Decl *d = 0;
  AST_Type *type = 0;
  AST_Argument *arg = 0;

  this->argument_count_ = 0;

  // If there are elements in this scope.
  if (this->nmembers () > 0)
    {
      // Instantiate a scope iterator.
      for (UTL_ScopeActiveIterator si (this, UTL_Scope::IK_decls);
           !si.is_done ();
           si.next ())
        {
          // Get the next AST decl node.
          d = si.item ();

          if (d->node_type () == AST_Decl::NT_argument)
            {
              this->argument_count_++;

              arg = AST_Argument::narrow_from_decl (d);

              if (arg->direction() == AST_Argument::dir_IN ||
                  arg->direction() == AST_Argument::dir_INOUT)
                {
                  this->has_in_arguments_ = true;
                }


              type = AST_Type::narrow_from_decl (arg->field_type ());

              if (type->node_type () == AST_Decl::NT_native)
                {
                  this->has_native_ = 1;
                }
            }
        }
    }

  type = AST_Type::narrow_from_decl (this->return_type ());

  if (type->node_type () == AST_Decl::NT_native)
    {
      this->has_native_ = 1;
    }

  return 0;
}
示例#18
0
文件: amh_sh.cpp 项目: CCJY/ATCD
int
be_visitor_amh_operation_sh::visit_operation (be_operation *node)
{
  /// If there is an argument of type "native", return immediately.
  if (node->has_native ())
    {
      return 0;
    }

  /// These are not for the server side.
  if (node->is_sendc_ami ())
    {
      return 0;
    }

  // Output stream.
  TAO_OutStream *os = this->ctx_->stream ();
  this->ctx_->node (node);

  this->generate_shared_prologue (node, os, "");

  be_visitor_context ctx (*this->ctx_);
  be_visitor_args_arglist arglist_visitor (&ctx);
  arglist_visitor.set_fixed_direction (AST_Argument::dir_IN);
  ctx.scope (node);

  for (UTL_ScopeActiveIterator i (node, UTL_Scope::IK_decls);
       !i.is_done ();
       i.next ())
    {
      be_argument *argument =
        be_argument::narrow_from_decl (i.item ());

      if (argument == 0
          || argument->direction () == AST_Argument::dir_OUT)
        {
          continue;
        }

      *os << "," << be_nl;

      if (arglist_visitor.visit_argument (argument) == -1)
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             "(%N:%l) be_visitor_amh_operation_sh::"
                             "visit_operation - "
                             "codegen for upcall args failed\n"),
                            -1);
        }
    }

  *os << be_uidt_nl
      << ") = 0;" << be_uidt_nl;

  return 0;
}
示例#19
0
文件: ast_union.cpp 项目: CCJY/ATCD
// Compute the default index.
int
AST_Union::compute_default_index (void)
{
  AST_Decl *d = 0;
  AST_UnionBranch *ub = 0;
  int i = 0;

  // If default case does not exist, it will have a value of -1 according to
  // the spec.
  this->default_index_ = -1;

  // If there are elements in this scope...
  if (this->nmembers () > 0)
    {
      // Instantiate a scope iterator.
      for (UTL_ScopeActiveIterator si (this, UTL_Scope::IK_decls);
           !si.is_done ();
           si.next ())
        {
          // Get the next AST decl node.
          d = si.item ();

          // If an enum is declared in our scope, its members are
          // added to our scope as well, to detect clashes.
          if (d->node_type () == AST_Decl::NT_enum_val)
            {
              continue;
            }

          if (!d->imported ())
            {
              ub = AST_UnionBranch::narrow_from_decl (d);

              for (unsigned long j = 0; j < ub->label_list_length (); ++j)
                {
                  // Check if we are printing the default case.
                  AST_UnionLabel::UnionLabel ulk = ub->label (j)->label_kind ();
                  if (ulk == AST_UnionLabel::UL_default)
                    {
                      // Zero based indexing.
                      this->default_index_ = i;
                    }
                }

              // TAO's Typecode class keeps only a member count (not
              // a label count) so this increment has been moved
              // out of the inner loop.
              ++i;
            }
        }
    }

  return 0;
}
示例#20
0
文件: ast_union.cpp 项目: CCJY/ATCD
// Look up a branch by label.
AST_UnionBranch *
AST_Union::lookup_label (AST_UnionBranch *b)
{
  AST_UnionLabel *label = b->label ();
  AST_Expression *lv = label->label_val ();

  if (label->label_val () == 0)
    {
      return b;
    }

  AST_Decl *d = 0;
  AST_UnionBranch *fb = 0;

  lv->set_ev (lv->coerce (this->pd_udisc_type));

  if (lv->ev () == 0)
    {
      idl_global->err ()->eval_error (lv);
      return b;
    }

  for (UTL_ScopeActiveIterator i (this, UTL_Scope::IK_decls);
       !i.is_done();
       i.next ())
    {
      d = i.item ();

      if (d->node_type () == AST_Decl::NT_union_branch)
        {
          fb = AST_UnionBranch::narrow_from_decl (d);

          if (fb == 0)
            {
              continue;
            }

          if (fb->label() != 0
              && fb->label ()->label_kind () == AST_UnionLabel::UL_label
              && fb->label ()->label_val ()->compare (lv))
            {
              idl_global->err ()->error2  (UTL_Error::EIDL_MULTIPLE_BRANCH,
                                           this,
                                           b);
              return b;
            }
        }
    }

  return 0;
}
示例#21
0
文件: valuetype.cpp 项目: CCJY/ATCD
int
be_visitor_valuetype::visit_valuetype_scope (be_valuetype *node)
{
  this->elem_number_ = 0;

  for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
       !si.is_done ();
       si.next())
    {
      AST_Decl *d = si.item ();

      if (!d)
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             "(%N:%l) be_visitor_scope::visit_scope - "
                             "bad node in this scope\n"),
                            -1);
        }

      be_decl *bd = be_decl::narrow_from_decl (d);
      // Set the scope node as "node" in which the code is being
      // generated so that elements in the node's scope can use it
      // for code generation.

      this->ctx_->scope (node);
      this->ctx_->node (bd);
      this->elem_number_++;

      AST_Field *field = AST_Field::narrow_from_decl (d);

      if (field != 0 && field->visibility () == AST_Field::vis_PRIVATE)
        {
          this->begin_private ();
        }
      else
        {
          this->begin_public ();
        }

      if (bd == 0 || bd->accept (this) == -1)
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             "(%N:%l) be_visitor_scope::visit_scope - "
                             "codegen for scope failed\n"),
                            -1);

        }
    }

  return 0;
}
示例#22
0
文件: valuetype.cpp 项目: CCJY/ATCD
// Private data fields for scope.
int
be_visitor_valuetype::gen_pd (be_valuetype *node)
{
  int n_processed = 0;
  this->elem_number_ = 0;

  for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
       !si.is_done ();
       si.next())
    {
      AST_Decl *d = si.item ();

      if (!d)
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             "(%N:%l) be_visitor_scope::visit_scope - "
                             "bad node in this scope\n"),
                            -1);
        }

      be_field *field = be_field::narrow_from_decl (d);
      be_attribute *attr = be_attribute::narrow_from_decl (d);

      if (field == 0 || attr != 0)
        {
          continue;
        }

      ++n_processed;

      // Set the scope node as "node" in which the code is being
      // generated so that elements in the node's scope can use it
      // for code generation.
      this->ctx_->scope (node);

      // Set the node to be visited.
      this->ctx_->node (field);
      this->elem_number_++;

      if (this->gen_field_pd (field) == -1)
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             "(%N:%l) be_visitor_scope::visit_scope - "
                             "codegen for scope failed\n"),
                            -1);
        }
    }

  return 0;
}
示例#23
0
void
be_visitor_valuetype_obv_cs::gen_obv_call_base_constructor_args (
  be_valuetype *node,
  unsigned long &index
  )
{
  TAO_OutStream *os = this->ctx_->stream ();

  // Generate for inherited members first.
  AST_Type *parent = node->inherits_concrete ();
  if (parent != 0)
    {
      be_valuetype *be_parent =
        be_valuetype::narrow_from_decl (parent);
      this->gen_obv_call_base_constructor_args (be_parent, index);
    }

  // Now generate for each "derived" added members
  for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
       !si.is_done ();
       si.next())
    {
      // be_attribute inherits from be_field
      // so we have to also screen out attributes
      be_field *f = be_field::narrow_from_decl (si.item ());
      if (f && !be_attribute::narrow_from_decl (si.item ()))
        {
          if (index++) // comma before 2nd onwards
            *os << ",";

          // output each accessor on new line
          *os << be_nl;

          // Check the member type for nested valuetypes
          be_type *t = be_type::narrow_from_decl (f->field_type ());
          if (be_valuetype_fwd::narrow_from_decl (t) ||
              be_valuetype::narrow_from_decl (t) ||
              be_valuebox::narrow_from_decl (t) )
            {
              // Nested valuetypes/boxes need to be deep copied also
              *os << "(" << f->local_name () << " () ?" << be_idt_nl
                  << t->full_name () << "::_downcast (" << f->local_name ()
                  << " ()->_copy_value ())" << be_nl
                  << ": 0)" << be_uidt;
            }
          else // Simple non-nested type
            *os << f->local_name () << " ()";
        }
    }
}
示例#24
0
//
// visit_scope
//
int Provides_Svnt_Impl::visit_scope (UTL_Scope * node)
{
  // Interfaces could be in a different IDL file, so we don't want to
  // skip them as the default visit_scope implementation does
  for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
       !si.is_done (); si.next ())
  {
    AST_Decl * d = si.item ();

    if (0 != d->ast_accept (this))
      return -1;
  }
  return 0;
}
示例#25
0
void
be_component::mirror_scan (AST_PortType *pt)
{
  AST_Uses *u = 0;
  AST_Provides *p = 0;
  AST_Attribute *a = 0;

  for (UTL_ScopeActiveIterator i (pt, UTL_Scope::IK_decls);
       !i.is_done ();
       i.next ())
    {
      AST_Decl *d = i.item ();

      switch (d->node_type ())
        {
          case AST_Decl::NT_provides:
            ++this->n_uses_;
            p = AST_Provides::narrow_from_decl (d);

            if (!p->provides_type ()->is_local ())
              {
                ++this->n_remote_uses_;
              }

            continue;
          case AST_Decl::NT_uses:
            ++this->n_provides_;
            u = AST_Uses::narrow_from_decl (d);

            if (!u->uses_type ()->is_local ())
              {
                ++this->n_remote_provides_;
              }

            continue;
          case AST_Decl::NT_attr:
            a = AST_Attribute::narrow_from_decl (d);;

            if (!a->readonly ())
              {
                this->has_rw_attributes_ = true;
              }

            continue;
          default:
            continue;
        }
    }
}
示例#26
0
void
be_visitor_valuetype_cs::gen_ostream_operator_r (be_valuetype *node,
                                                 unsigned long &index)
{
  TAO_OutStream *os = this->ctx_->stream ();
  AST_Type *parent = node->inherits_concrete ();

  // Recurse up the parent chain.
  if (parent != 0)
    {
      this->gen_ostream_operator_r (be_valuetype::narrow_from_decl (parent),
                                    index);
    }

  // Generate output for the members of whichever recursion we are in.
  for (UTL_ScopeActiveIterator i (node, UTL_Scope::IK_decls);
       !i.is_done ();
       i.next ())
    {
      be_field *f = be_field::narrow_from_decl (i.item ());
      be_attribute *attr =
        be_attribute::narrow_from_decl (i.item ());

      // No way to access the private members from generated code.
      if (f == 0
          || f->visibility () != AST_Field::vis_PUBLIC
          || attr != 0)
        {
          continue;
        }

      if (index++ != 0)
        {
          *os << " << \", \"";
        }

      *os << be_nl
          << "     << ";

      ACE_CString instance_name ("this->");
      instance_name += f->local_name ()->get_string ();
      f->gen_member_ostream_operator (os,
                                      instance_name.c_str (),
                                      false,
                                      true);
    }
}
示例#27
0
AST_Module *
be_generator::create_module (UTL_Scope *s,
                             UTL_ScopedName *n)
{
  AST_Module *retval = 0;

  // Check for another module of the same name in this scope.
  for (UTL_ScopeActiveIterator iter (s, UTL_Scope::IK_decls);
       !iter.is_done ();
       iter.next ())
    {
      // Can't just check node type here, since it could be a
      // template module or template module instantiation.
      AST_Module *m = AST_Module::narrow_from_decl (iter.item ());

      if (m && m->local_name ()->compare (n->last_component ()))
        {
          // Create this new module with referance to the
          // "first" previous module found in scope.
          ACE_NEW_RETURN (retval, be_module (n, m), 0);
          retval->prefix (const_cast<char *> (m->prefix ()));
          return retval;
        }
    }

  // Since the scope didn't contain the same module name, it
  // doesn't mean that we haven't see it before. If the scope
  // is itself a module, and has been previously opened, any
  // of the previous openings may contain a previous opening
  // of the module we're creating.
  AST_Module *prev_module = AST_Module::narrow_from_scope (s);
  if (prev_module)
    {
      while (!!(prev_module = prev_module->previous_opening ()))
        {
          for (UTL_ScopeActiveIterator iter (prev_module, UTL_Scope::IK_decls);
               !iter.is_done ();
               iter.next ())
            {
              AST_Module *m = AST_Module::narrow_from_decl (iter.item ());
              if (m && m->local_name ()->compare (n->last_component ()))
                {
                  // Create this new module with referance to the
                  // "first" previous module found in scope.
                  ACE_NEW_RETURN (retval, be_module (n, m), 0);
                  return retval;
                }
            }
        }
    }

  // There is no previous module to be found
  ACE_NEW_RETURN (retval, be_module (n), 0);
  return retval;
}
示例#28
0
bool
AST_InterfaceFwd::full_def_seen (void)
{
  UTL_Scope *s = this->defined_in ();
  AST_Interface *i = 0;

  // If a full definition is seen in a previous module opening
  // or anywhere in the current scope (before or after our
  // declaration, reture TRUE.

  if (AST_Decl::NT_module == s->scope_node_type ())
    {
      AST_Module *m = AST_Module::narrow_from_scope (s);
      AST_Decl *d =
        m->look_in_prev_mods_local (this->local_name (),
                                    false);

      if (0 != d)
        {
          i = AST_Interface::narrow_from_decl (d);

          if (0 != i && i->is_defined ())
            {
              return true;
            }
        }
    }

  for (UTL_ScopeActiveIterator iter (s, UTL_Scope::IK_decls);
        !iter.is_done ();
        iter.next ())
    {
      i = AST_Interface::narrow_from_decl (iter.item ());

      if (0 != i && this->local_name ()->compare (i->local_name ()))
        {
          if (i->is_defined ())
            {
              return true;
            }
        }
    }

  return false;
}
示例#29
0
文件: ast_root.cpp 项目: CCJY/ATCD
// Overrides the one in UTL_Scope - this one doesn't
// count the predefined types.
unsigned long
AST_Root::nmembers (void)
{
  unsigned long retval = 0;

  for (UTL_ScopeActiveIterator si (this, UTL_Scope::IK_decls);
        !si.is_done ();
        si.next ())
    {
      if (si.item ()->node_type () == AST_Decl::NT_pre_defined)
        {
          continue;
        }

      ++retval;
    }

  return retval;
}
示例#30
0
// Compute total number of members.
int
AST_Structure::compute_member_count (void)
{
  this->member_count_ = 0;

  // If there are elements in this scope.
  if (this->nmembers () > 0)
    {
      // Instantiate a scope iterator.
      for (UTL_ScopeActiveIterator si (this, UTL_Scope::IK_decls);
           !si.is_done ();
           si.next ())
        {
          ++this->member_count_;
        }
    }

  return 0;
}