Example #1
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;
}
Example #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;
   }
}
Example #3
0
int
be_visitor_executor_exh::visit_provides (be_provides *node)
{
  ACE_CString prefix (this->ctx_->port_prefix ());
  prefix += node->local_name ()->get_string ();
  const char *port_name = prefix.c_str ();

  be_type *impl = node->provides_type ();

  AST_Decl *scope = ScopeAsDecl (impl->defined_in ());
  ACE_CString sname_str (scope->full_name ());
  const char *sname = sname_str.c_str ();

  // No '_cxx_' prefix.
  const char *lname =
    impl->original_local_name ()->get_string ();

  const char *global = (sname_str == "" ? "" : "::");

  os_ << be_nl_2
      << "/// Factory method and getter for " << port_name << " facet" << be_nl
      << "/// @return existing instance of facet if one exists, else creates one" << be_nl
      << "virtual " << global << sname << "::CCM_"
      << lname << "_ptr" << be_nl
      << "get_" << port_name << " (void);";

  return 0;
}
Example #4
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;
   }
}
Example #5
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);
   }
}
Example #6
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, ")");
}
Example #7
0
unsigned long be_sequence::isRecursive ()
{
   UTL_Scope * scope = 0;
   be_Type * btype = 0;
   AST_Decl * adecl = (AST_Decl *)this->narrow((long) & AST_Decl::type_id);
   assert(adecl);
   be_Type * base = (be_Type *)base_type()->narrow((long) & be_Type::type_id);
   assert(base);
   unsigned long offset = 1;

   for (
      offset = 1;
      adecl &&
      (scope = adecl->defined_in()) &&
      (btype = (be_Type *)scope->narrow((long) & be_Type::type_id));
      ++offset
   )
   {
      adecl = (AST_Decl *)scope->narrow((long) & AST_Decl::type_id);

      if (btype->TypeCodeTypeName() == base->TypeCodeTypeName())
      {
         break;
      }
   }

   if (scope && btype)
   {
      return offset;
   }

   return 0;
}
Example #8
0
int
idl2jni_visitor::visit_scope(UTL_Scope *node)
{
  if (node->nmembers() > 0) {
    UTL_ScopeActiveIterator si(node, UTL_Scope::IK_decls);
    AST_Decl *d = 0;

    while (!si.is_done()) {
      d = si.item();

      if (d == 0) {
        ACE_ERROR_RETURN((LM_ERROR,
                          ACE_TEXT("(%N:%l) idl2jni_visitor::visit_")
                          ACE_TEXT("scope - bad node in this scope\n")), -1);
      }

      if (d->node_type() == AST_Decl::NT_pre_defined) {
        si.next();
        continue;
      }

      if (d->ast_accept(this) == -1) {
        ACE_ERROR_RETURN((LM_ERROR,
                          ACE_TEXT("(%N:%l) idl2jni_visitor::visit_")
                          ACE_TEXT("scope - failed to accept visitor\n")), -1);
      }

      si.next();
    }
  }

  return 0;
}
Example #9
0
bool
AST_illegal_interface_recursion (AST_Decl *t)
{
  // Can't be 0 since we know we have an interface or valuetype.
  AST_Decl *d = 0;

  // If we encounter the argument in an enclosing scope, it's illegal.
  for (UTL_ScopeStackActiveIterator i (idl_global->scopes ());
       !i.is_done ();
       i.next ())
    {
      d = ScopeAsDecl (i.item ());

      // Exceptions cannot be recursive, but may contain a reference
      // to the interface they are defined in.
      if (d->node_type () == AST_Decl::NT_except)
        {
          return false;
        }

      if (d == t)
        {
          return true;
        }
    }

  return false;
}
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;
}
Example #11
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;
}
Example #12
0
DDS_StdString
be_Type::EnclosingScopeString(AST_Decl * decl)
{
   DDS_StdString ret;

   assert(decl);

   if (decl)
   {
      UTL_Scope * enclosingScope = decl->defined_in();
      AST_Decl * enclosingDecl;

      if (enclosingScope)
      {
         if ((enclosingDecl = (AST_Decl*)enclosingScope->narrow((long) & AST_Decl::type_id)))
         {
            ret = NameToString(enclosingDecl->name(), 0);
         }
         else
         {
            DDSError((DDS_StdString)"Can't narrow enclosing scope for " + NameToString(decl->name(), 0));
         }
      }
   }

   return ret;
}
Example #13
0
be_argument::be_argument (AST_Argument::Direction d,
                          AST_Type *ft,
                          UTL_ScopedName *n)
  : COMMON_Base (),
    AST_Decl (AST_Decl::NT_argument,
              n),
    AST_Field (AST_Decl::NT_argument,
               ft,
               n),
    AST_Argument (d,
                  ft,
                  n),
    be_decl (AST_Decl::NT_argument,
             n)
{
  AST_Decl *dcl = ScopeAsDecl (this->defined_in ());

  // If there have been previous errors, dcl may be 0,
  // and we don't want to crash, so we check for non-zero.
  // Also, we don't want to set the bit if the operation is
  // declared in an included file UNLESS the enclosing
  // interface is abstract, in which case we regenerate the
  // operation.
  if (dcl != 0
      && !dcl->is_local ()
      && (idl_global->in_main_file () || dcl->is_abstract ()))
    {
      be_type *bt = be_type::narrow_from_decl (ft);
      bt->seen_in_operation (true);
      be_util::set_arg_seen_bit (bt);
      idl_global->need_skeleton_includes_ = true;
    }
}
Example #14
0
// 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;
}
Example #15
0
void
be_type::gen_fwd_helper_name (void)
{
  AST_Decl *parent = ScopeAsDecl (this->defined_in ());
  Identifier *segment = 0;
  char *tmp = 0;
  this->fwd_helper_name_.clear (true);

  if (parent != 0 && parent->node_type () != AST_Decl::NT_root)
    {
      for (UTL_IdListActiveIterator i (parent->name ());
           !i.is_done ();
           i.next ())
        {
          segment = i.item ();
          tmp = segment->get_string ();

          if (ACE_OS::strcmp (tmp, "") == 0)
            {
              continue;
            }

          this->fwd_helper_name_ += tmp;
          this->fwd_helper_name_ += "::";
        }
    }
  else
    {
      this->fwd_helper_name_= "";
    }

  this->fwd_helper_name_ += "tao_";
  this->fwd_helper_name_ += this->local_name ()->get_string ();
}
Example #16
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;
}
Example #17
0
int
ast_visitor_reifying::visit_param_holder (AST_Param_Holder *node)
{
  size_t i = 0;
  FE_Utils::T_ARGLIST const *t_args =
    this->ctx_->template_args ();

  for (FE_Utils::T_PARAMLIST_INFO::ITERATOR iter (
         *this->ctx_->template_params ());
       !iter.done ();
       iter.advance (), ++i)
    {
      FE_Utils::T_Param_Info *item = 0;
      iter.next (item);

      ACE_CString name (item->name_);

      /// The param holder's info->name_ may be the same as the
      /// node's local name, but if the node comes from an
      /// alias, info->name_ will be the name of the alias's
      /// referenced template module parameter, while the local
      /// name will be that of the corresponding alias param
      /// name, which is what we want.
      if (name == node->local_name ()->get_string ())
        {
          AST_Decl **ret_ptr = 0;

          if (t_args->get (ret_ptr, i) == 0)
            {
              AST_Decl *candidate = *ret_ptr;

              return candidate->ast_accept (this);
            }
          else
            {
              ACE_ERROR_RETURN ((LM_ERROR,
                                 ACE_TEXT ("ast_visitor_reifying::")
                                 ACE_TEXT ("visit_param_holder() - access of ")
                                 ACE_TEXT ("current template arglist failed - ")
                                 ACE_TEXT ("param=%C scope=%C index=%d\n"),
                                 item->name_.c_str (),
                                 ScopeAsDecl (idl_global->scopes ().top ())->full_name (),
                                 i),
                                -1);
            }
        }
    }

  ACE_ERROR_RETURN ((LM_ERROR,
                     ACE_TEXT ("ast_visitor_reifying::")
                     ACE_TEXT ("visit_param_holder() - no match for ")
                     ACE_TEXT ("template param %C in %C\n"),
                     node->local_name ()->get_string (),
                     ScopeAsDecl (idl_global->scopes ().top ())->full_name ()),
                    -1);
}
Example #18
0
// 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;
}
Example #19
0
/*
 * Add this AST_InterfaceFwd node (a forward declaration of an IDL
 * interface) to this scope
 */
AST_InterfaceFwd * AST_Module::fe_add_interface_fwd (AST_InterfaceFwd * i)
{
   AST_Decl * d = lookup_for_add (i);
   AST_Interface * itf;

   /*
    * Already defined and cannot be redefined? Or already used?
    */
   if (d)
   {
      if (d->node_type() == AST_Decl::NT_interface && d->defined_in() == this)
      {
         itf = AST_Interface::narrow_from_decl (d);

         if (itf == 0)
         {
            return 0;
         }

         i->set_full_definition (itf);
         return i;
      }

      if (!can_be_redefined (d))
      {
         idl_global->err()->error3(UTL_Error::EIDL_REDEF, i, this, d);
         return NULL;
      }

      if (referenced (d))
      {
         idl_global->err()->error3(UTL_Error::EIDL_DEF_USE, i, this, d);
         return NULL;
      }

      if (i->has_ancestor (d))
      {
         idl_global->err()->redefinition_in_scope(i, d);
         return NULL;
      }
   }

   /*
    * Add it to scope
    */
   add_to_scope (i);

   /*
    * Add it to set of locally referenced symbols
    */
   add_to_referenced (i, false);

   return i;
}
Example #20
0
AST_ValueFwd *AST_Module::fe_add_valuetype_fwd(AST_ValueFwd *v)
{
   AST_Decl *d;
   AST_Value *val;

   /*
    * Already defined and cannot be redefined? Or already used?
    */
   if ((d = lookup_for_add (v)) != NULL)
   {
      if (d->node_type() == AST_Decl::NT_value && d->defined_in() == this)
      {
         val = AST_Value::narrow_from_decl(d);

         if (val == NULL)
            return NULL;

         v->set_full_definition(val);

         return v;
      }

      if (!can_be_redefined(d))
      {
         idl_global->err()->error3(UTL_Error::EIDL_REDEF, v, this, d);
         return NULL;
      }

      if (referenced(d))
      {
         idl_global->err()->error3(UTL_Error::EIDL_DEF_USE, v, this, d);
         return NULL;
      }

      if (v->has_ancestor(d))
      {
         idl_global->err()->redefinition_in_scope(v, d);
         return NULL;
      }
   }

   /*
    * Add it to scope
    */
   add_to_scope(v);

   /*
    * Add it to set of locally referenced symbols
    */
   add_to_referenced(v, I_FALSE);

   return v;
}
Example #21
0
// NOTE: No attempt is made to ensure that exceptions are mentioned
//       only once..
UTL_NameList *
AST_Attribute::fe_add_get_exceptions (UTL_NameList *t)
{
  UTL_ScopedName *nl_n = 0;
  AST_Type *fe = 0;
  AST_Decl *d = 0;

  this->pd_get_exceptions = 0;

  for (UTL_NamelistActiveIterator nl_i (t);
       !nl_i.is_done ();
       nl_i.next ())
    {
      nl_n = nl_i.item ();

      d = this->defined_in ()->lookup_by_name (nl_n, true);

      if (d == 0)
        {
          idl_global->err ()->lookup_error (nl_n);
          return 0;
        }

      AST_Decl::NodeType nt = d->node_type ();

      if (nt != AST_Decl::NT_except
          && nt != AST_Decl::NT_param_holder)
        {
          idl_global->err ()->error1 (UTL_Error::EIDL_ILLEGAL_RAISES,
                                      this);
          return 0;
        }

      fe = AST_Type::narrow_from_decl (d);

      UTL_ExceptList *el = 0;
      ACE_NEW_RETURN (el,
                      UTL_ExceptList (fe, 0),
                      0);

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

  return t;
}
Example #22
0
// 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;
}
Example #23
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;
}
Example #24
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;
        }
    }
}
Example #25
0
void
be_util::gen_nesting_close (TAO_OutStream &os, AST_Decl *node)
{
  AST_Decl *d = ScopeAsDecl (node->defined_in ());
  AST_Decl::NodeType nt = d->node_type ();

  while (nt != AST_Decl::NT_root)
    {
      os << be_uidt_nl
         << "};";

      d = ScopeAsDecl (d->defined_in ());
      nt = d->node_type ();
    }
}
Example #26
0
int
be_visitor_executor_exs::visit_provides (be_provides *node)
{
  ACE_CString prefix (this->ctx_->port_prefix ());
  prefix += node->local_name ()->get_string ();
  const char *port_name = prefix.c_str ();

  be_type *obj = node->provides_type ();
  const char *iname =
    obj->original_local_name ()->get_string ();

  AST_Decl *scope = ScopeAsDecl (obj->defined_in ());
  ACE_CString sname_str (scope->full_name ());
  const char *sname = sname_str.c_str ();
  const char *global = (sname_str == "" ? "" : "::");

  ACE_CString lname_str (this->ctx_->port_prefix ());
  lname_str += node->original_local_name ()->get_string ();
  const char *lname = lname_str.c_str ();

  os_ << be_nl_2
      << global << sname << "::CCM_"
      << iname << "_ptr" << be_nl
      << node_->local_name () << "_exec_i::get_"
      << port_name << " (void)" << be_nl
      << "{" << be_idt_nl
      << "if ( ::CORBA::is_nil (this->ciao_" << port_name
      << "_.in ()))" << be_idt_nl
      << "{" << be_idt_nl
      << lname << "_exec_i *tmp = 0;" << be_nl
      << "ACE_NEW_RETURN (" << be_idt_nl
      << "tmp," << be_nl
      << lname << "_exec_i (" << be_idt_nl
      << "this->ciao_context_.in ())," << be_nl
      << global << sname << "::CCM_" << iname << "::_nil ());"
      << be_uidt << be_nl_2
      << "this->ciao_" << port_name << "_ = tmp;" << be_uidt << be_uidt_nl
      << "}" << be_uidt << be_nl_2
      << "return" << be_idt_nl
      << global << sname << "::CCM_" << iname
      << "::_duplicate (" << be_idt_nl
      << "this->ciao_" << port_name << "_.in ());"
      << be_uidt << be_uidt << be_uidt_nl
      << "}";

  return 0;
}
Example #27
0
void
AST_Root::destroy (void)
{
  long i = 0;
  AST_Decl *d = 0;

  // Just destroy and delete everything but the CORBA
  // module, and the 'void' keyword, in case we are
  // processing multiple IDL files.
  // Final cleanup will be done in fini().
  long end = this->pd_decls_used;

  for (i = 2; i < end; ++i)
    {
      d = this->pd_decls[i];

      d->destroy ();
      delete d;
      d = 0;
      --this->pd_decls_used;
    }

  // Same goes for the references and the name
  // references, leave the first 2.

  // This array of pointers holds references, no need
  // for destruction. The array itself will be cleaned
  // up when AST_Root::fini() calls UTL_Scope::destroy ().
  for (i = 2; i < this->pd_referenced_used; ++i)
    {
      this->pd_referenced[i] = 0;
    }

  this->pd_referenced_used = 2;

  for (i = 2; i < this->pd_name_referenced_used; ++i)
    {
      Identifier *id = this->pd_name_referenced[i];
      id->destroy ();
      delete id;
      id = 0;
    }

  this->pd_name_referenced_used = 2;
}
Example #28
0
void
FE_ComponentHeader::compile_inheritance (UTL_ScopedName *base_component)
{
  // If there is a base component, look up the decl and assign our member.
  // We also inherit its supported interfaces.
  if (base_component == 0)
    {
      return;
    }

  UTL_Scope *s = idl_global->scopes ().top_non_null ();
  AST_Decl *d = s->lookup_by_name (base_component,
                                   true);

  if (d == 0)
    {
      idl_global->err ()->lookup_error (base_component);

      // This is probably the result of bad IDL.
      // We will crash if we continue from here.
      throw Bailout ();
    }

  if (d->node_type () == AST_Decl::NT_typedef)
    {
      d = AST_Typedef::narrow_from_decl (d)->primitive_base_type ();
    }

  this->base_component_ = AST_Component::narrow_from_decl (d);

  if (this->base_component_ == 0)
    {
      idl_global->err ()->error1 (UTL_Error::EIDL_ILLEGAL_USE,
                                  d);
    }
  else if (!this->base_component_->is_defined ())
    {
      idl_global->err ()->inheritance_fwd_error (
                              this->name (),
                              this->base_component_
                            );
      this->base_component_ = 0;
    }
}
Example #29
0
int
dds_visitor::visit_constant(AST_Constant* node)
{
  const char* name = node->local_name()->get_string();

  BE_Comment_Guard g("CONST", name);

  ACE_UNUSED_ARG(g);

  AST_Decl* d = ScopeAsDecl(node->defined_in());

  bool nested = d && (d->node_type() == AST_Decl::NT_interface);

  if (!java_ts_only_) {
    error_ |= !gen_target_.gen_const(node->name(), nested, node);
  }

  return 0;
}
Example #30
0
AST_Structure * AST_Module::fe_add_structure (AST_Structure * s)
{
   AST_Decl * d = lookup_for_add (s);

   if (d)
   { 
      /* Check for existing declaration or pre-declaration */

      if (d->node_type () == AST_Decl::NT_struct)
      {
         AST_Structure * fwd = AST_Structure::narrow_from_decl (d);
         if (fwd->is_defined () && s->is_defined ())
         {
            /* Invalid duplicate declaration */

            idl_global->err()->error3 (UTL_Error::EIDL_REDEF, s, this, d);
         }
         else
         {
            if (! fwd->is_defined () && s->is_defined ())
            {
               reorder (d);
            }

            // Return existing

            delete s;
            s = fwd;
         }
      }
      else
      {
         idl_global->err()->error3 (UTL_Error::EIDL_REDEF, s, this, d);
      }
   }
   else
   {
      add_to_scope (s);
      add_to_referenced (s, false);
   }

   return s;
}