Exemplo n.º 1
0
int
be_visitor_amh_pre_proc::add_exception_reply (be_operation *node,
                                              be_interface *response_handler,
                                              be_valuetype *exception_holder)
{
  UTL_ScopedName *operation_name = node->compute_name ("",
                                                       "_excep");

  be_operation *node_excep = 0;
  ACE_NEW_RETURN (node_excep,
                  be_operation (be_global->void_type (),
                                AST_Operation::OP_noflags,
                                operation_name,
                                1,
                                0),
                  -1);

  node_excep->set_name (operation_name);

  Identifier *arg_id = 0;
  ACE_NEW_RETURN (arg_id,
                  Identifier ("holder"),
                  -1);

  UTL_ScopedName *arg_name = 0;
  ACE_NEW_RETURN (arg_name,
                  UTL_ScopedName (arg_id, 0),
                  -1);

  be_argument *argument = 0;
  ACE_NEW_RETURN (argument,
                  be_argument (AST_Argument::dir_IN,
                               exception_holder,
                               arg_name),
                  -1);

  argument->set_name (arg_name);
  argument->set_defined_in (node_excep);
  node_excep->be_add_argument (argument);

  node_excep->set_defined_in (response_handler);

  if (0 == response_handler->be_add_operation (node_excep))
    {
      return -1;
    }

  return 0;
}
Exemplo n.º 2
0
UTL_ScopedName *
FE_Utils::string_to_scoped_name (const char *s)
{
  UTL_ScopedName *retval = 0;
  ACE_CString str (s);
  Identifier *id = 0;
  UTL_ScopedName *sn = 0;

  while (! str.empty ())
    {
      // Skip a leading double colon.
      if (str.find (':') == 0)
        {
          str = str.substr (2);
        }

      // Find the next double colon (if any) and get the next
      // name segment.
      ACE_CString::size_type pos = str.find (':');
      ACE_CString lname (str.substr (0, pos));

      // Construct a UTL_ScopedName segment.
      ACE_NEW_RETURN (id,
                      Identifier (lname.c_str ()),
                      0);

      ACE_NEW_RETURN (sn,
                      UTL_ScopedName (id, 0),
                      0);

      // Either make it the head of a new list or the tail of
      // an existing one.
      if (retval == 0)
        {
          retval = sn;
        }
      else
        {
          retval->nconc (sn);
        }

      // Update the working string.
      str = str.substr (pos);
    }

  return retval;
}
Exemplo n.º 3
0
int
ast_visitor_tmpl_module_inst::visit_valuetype (AST_ValueType *node)
{
  UTL_NameList *parent_names =
    this->create_name_list (node->inherits (),
                            node->n_inherits ());

  UTL_NameList *supports_names =
    this->create_name_list (node->supports (),
                            node->n_supports ());

  Identifier *node_id = 0;
  ACE_NEW_RETURN (node_id,
                  Identifier (node->local_name ()->get_string ()),
                  -1);

  UTL_ScopedName *local_name = 0;
  ACE_NEW_RETURN (local_name,
                  UTL_ScopedName (node_id, 0),
                  -1);

  AST_ValueType *added_vtype = 0;

  FE_OBVHeader header (local_name,
                       parent_names,
                       supports_names,
                       (parent_names != 0
                          ? parent_names->truncatable ()
                          : false),
                       this->for_eventtype_);

  if (this->for_eventtype_)
    {
      added_vtype =
        idl_global->gen ()->create_eventtype (header.name (),
                                              header.inherits (),
                                              header.n_inherits (),
                                              header.inherits_concrete (),
                                              header.inherits_flat (),
                                              header.n_inherits_flat (),
                                              header.supports (),
                                              header.n_supports (),
                                              header.supports_concrete (),
                                              false,
                                              header.truncatable (),
                                              false);
    }
  else
    {
      added_vtype =
        idl_global->gen ()->create_valuetype (header.name (),
                                              header.inherits (),
                                              header.n_inherits (),
                                              header.inherits_concrete (),
                                              header.inherits_flat (),
                                              header.n_inherits_flat (),
                                              header.supports (),
                                              header.n_supports (),
                                              header.supports_concrete (),
                                              false,
                                              header.truncatable (),
                                              false);
    }

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

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

  idl_global->scopes ().top ()->add_to_scope (added_vtype);

  // Update the scope management.
  idl_global->scopes ().push (added_vtype);

  if (this->visit_scope (node) != 0)
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                         ACE_TEXT ("ast_visitor_tmpl_module_inst::")
                         ACE_TEXT ("visit_valuetype - ")
                         ACE_TEXT ("visit_scope failed\n")),
                        -1);
    }

  // Through with this scope.
  idl_global->scopes ().pop ();

  // Reset the flag.
  this->for_eventtype_ = false;

  return 0;
}
Exemplo n.º 4
0
int
ast_visitor_tmpl_module_inst::visit_home (AST_Home *node)
{
  UTL_ScopedName *base_name = 0;
  AST_Decl *parent =
    this->reify_type (node->base_home ());

  if (parent != 0)
    {
      base_name = parent->name ();
    }

  UTL_NameList *supports_names =
    this->create_name_list (node->supports (),
                            node->n_supports ());

  UTL_ScopedName *managed_comp_name = 0;

  AST_Component *managed_comp =
    AST_Component::narrow_from_decl (
      this->reify_type (node->managed_component ()));

  if (managed_comp != 0)
    {
      managed_comp_name = managed_comp->name ();
    }

  UTL_ScopedName *p_key_name = 0;

  AST_ValueType *p_key =
    AST_ValueType::narrow_from_decl (
      this->reify_type (node->primary_key ()));

  if (p_key != 0)
    {
      p_key_name = p_key->name ();
    }

  Identifier *node_id = 0;
  ACE_NEW_RETURN (node_id,
                  Identifier (node->local_name ()->get_string ()),
                  -1);

  UTL_ScopedName *local_name = 0;
  ACE_NEW_RETURN (local_name,
                  UTL_ScopedName (node_id, 0),
                  -1);

  FE_HomeHeader header (local_name,
                        base_name,
                        supports_names,
                        managed_comp_name,
                        p_key_name);

  AST_Home *added_home =
    idl_global->gen ()->create_home (header.name (),
                                     header.base_home (),
                                     header.managed_component (),
                                     header.primary_key (),
                                     header.supports (),
                                     header.n_supports (),
                                     header.supports_flat (),
                                     header.n_supports_flat ());

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

  idl_global->scopes ().top ()->add_to_scope (added_home);

  // Update the scope management.
  idl_global->scopes ().push (added_home);

  if (this->visit_scope (node) != 0)
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                         ACE_TEXT ("ast_visitor_tmpl_module_inst::")
                         ACE_TEXT ("visit_home - ")
                         ACE_TEXT ("visit_scope failed\n")),
                        -1);
    }

  // Through with this scope.
  idl_global->scopes ().pop ();

  return 0;
}
Exemplo n.º 5
0
int
ast_visitor_tmpl_module_inst::visit_component (AST_Component *node)
{
  UTL_ScopedName *base_name = 0;
  AST_Decl *parent =
    this->reify_type (node->base_component ());

  if (parent != 0)
    {
      base_name = parent->name ();
    }

  UTL_NameList *supports_names =
    this->create_name_list (node->supports (),
                            node->n_supports ());

  Identifier *node_id = 0;
  ACE_NEW_RETURN (node_id,
                  Identifier (node->local_name ()->get_string ()),
                  -1);

  UTL_ScopedName *local_name = 0;
  ACE_NEW_RETURN (local_name,
                  UTL_ScopedName (node_id, 0),
                  -1);

  FE_ComponentHeader header (local_name,
                             base_name,
                             supports_names,
                             false);

  AST_Component *added_comp =
    idl_global->gen ()->create_component (header.name (),
                                          header.base_component (),
                                          header.supports (),
                                          header.n_supports (),
                                          header.supports_flat (),
                                          header.n_supports_flat ());

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

  idl_global->scopes ().top ()->add_to_scope (added_comp);

  // Update the scope management.
  idl_global->scopes ().push (added_comp);

  if (this->visit_scope (node) != 0)
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                         ACE_TEXT ("ast_visitor_tmpl_module_inst::")
                         ACE_TEXT ("visit_component - ")
                         ACE_TEXT ("visit_scope failed\n")),
                        -1);
    }

  // Through with this scope.
  idl_global->scopes ().pop ();

  return 0;
}
Exemplo n.º 6
0
int
be_visitor_ami_pre_proc::create_excep_operation (be_operation *node,
                                                 be_interface *reply_handler)
{
  if (node->flags () == AST_Operation::OP_oneway)
    {
      // We do nothing for oneways!
      return 0;
    }

  // Create the return type, which is "void".
  Identifier *id = 0;
  UTL_ScopedName *sn = 0;

  // Create the argument.
  ACE_NEW_RETURN (id,
                  Identifier ("excep_holder"),
                  -1);

  ACE_NEW_RETURN (sn,
                  UTL_ScopedName (id,
                                  0),
                  -1);

  be_valuetype *excep_holder = be_global->messaging_exceptionholder ();
  be_argument *arg = 0;
  ACE_NEW_RETURN (arg,
                  be_argument (AST_Argument::dir_IN,
                               excep_holder, // is also a valuetype
                               sn),
                  -1);

  arg->set_name (sn);

  UTL_ScopedName *tmp = (UTL_ScopedName *)sn->copy ();

  // Create the new name
  // Append _excep to the name of the operation
  ACE_CString original_op_name (
                  node->name ()->last_component ()->get_string ()
                );
  ACE_CString new_op_name = original_op_name + ACE_CString ("_excep");

  UTL_ScopedName *op_name =
    static_cast<UTL_ScopedName *> (reply_handler->name ()->copy ());

  ACE_NEW_RETURN (id,
                  Identifier (new_op_name.c_str ()),
                  -1);

  ACE_NEW_RETURN (sn,
                  UTL_ScopedName (id,
                                  0),
                  -1);

  op_name->nconc (sn);

  AST_PredefinedType *rt = be_global->void_type ();

  // Create the operation.
  be_operation *operation = 0;
  ACE_NEW_RETURN (operation,
                  be_operation (rt,
                                AST_Operation::OP_noflags,
                                op_name,
                                false,
                                false),
                  -1);

  operation->set_name (op_name);
  operation->be_add_argument (arg);
  operation->set_defined_in (reply_handler);

  UTL_ScopedName *arg_name =
    dynamic_cast<UTL_ScopedName *> (op_name->copy ());
  arg_name->nconc (tmp);
  arg->set_name (arg_name);
  arg->set_defined_in (operation);

  // Copy the exceptions since the user exception information may
  // be needed when collocation is disabled.
  UTL_ExceptList *exceptions = node->exceptions ();

  if (0 != exceptions)
    {
      operation->be_add_exceptions (exceptions->copy ());
    }

  reply_handler->be_add_operation (operation);

  operation->is_excep_ami (true);
  return 0;
}
Exemplo n.º 7
0
int
be_visitor_ami_pre_proc::create_reply_handler_operation (
  be_operation *node,
  be_interface *reply_handler)
{
  if (!node)
    {
      return -1;
    }

  if (node->flags () == AST_Operation::OP_oneway)
    {
      // We do nothing for oneways!
      return 0;
    }

  Identifier *id = 0;
  UTL_ScopedName *sn = 0;

  ACE_CString original_op_name (
                  node->name ()->last_component ()->get_string ()
                );

  UTL_ScopedName *op_name =
    static_cast<UTL_ScopedName *> (reply_handler->name ()-> copy ());

  ACE_NEW_RETURN (id,
                  Identifier (original_op_name.c_str ()),
                  -1);

  ACE_NEW_RETURN (sn,
                  UTL_ScopedName (id,
                                  0),
                  -1);

  op_name->nconc (sn);

  // Create the operation.
  be_operation *operation = 0;
  ACE_NEW_RETURN (operation,
                  be_operation (be_global->void_type (),
                                AST_Operation::OP_noflags,
                                op_name,
                                0,
                                0),
                  -1);

  operation->set_name (op_name);

  // If return type is non-void add it as first argument.

  if (!node->void_return_type ())
    {
      ACE_NEW_RETURN (id,
                      Identifier ("ami_return_val"),
                      -1);

      UTL_ScopedName *tmp = 0;

      ACE_NEW_RETURN (tmp,
                      UTL_ScopedName (id,
                                      0),
                      -1);

      sn = (UTL_ScopedName *)operation->name ()->copy ();
      sn->nconc (tmp);

      // Create the argument.
      be_argument *arg = 0;
      ACE_NEW_RETURN (arg,
                      be_argument (AST_Argument::dir_IN,
                                   node->return_type (),
                                   sn),
                      -1);

      arg->set_defined_in (operation);
      arg->set_name (sn);

      // Add the reply handler to the argument list.
      operation->be_add_argument (arg);
    }

  // Iterate over the arguments and put all the in and inout
  // into the new method.
  if (node->nmembers () > 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 == 0)
            {
              operation->destroy ();
              delete operation;
              operation = 0;

              ACE_ERROR_RETURN ((LM_ERROR,
                                 ACE_TEXT ("be_visitor_ami_pre_proc::")
                                 ACE_TEXT ("create_reply_handler_operation - ")
                                 ACE_TEXT ("bad node in this scope\n")),
                                -1);

            }

          AST_Argument *original_arg = AST_Argument::narrow_from_decl (d);

          if (original_arg->direction () == AST_Argument::dir_INOUT ||
              original_arg->direction () == AST_Argument::dir_OUT)
            {
              // Create the argument.
              be_argument *arg = 0;
              UTL_ScopedName *new_name =
                (UTL_ScopedName *)original_arg->name ()->copy ();
              ACE_NEW_RETURN (arg,
                              be_argument (AST_Argument::dir_IN,
                                           original_arg->field_type (),
                                           new_name),
                              -1);

              arg->set_defined_in (operation);
              arg->set_name (new_name);
              operation->be_add_argument (arg);
            }
        } // end of while loop
    } // end of if

  operation->set_defined_in (reply_handler);

  // Copy the exceptions.
  if (node->exceptions ())
    {
      UTL_ExceptList *exceptions = node->exceptions ();

      if (0 != exceptions)
        {
          operation->be_add_exceptions (exceptions->copy ());
        }
    }

  // After having generated the operation we insert it into the
  // reply handler interface.
  if (0 == reply_handler->be_add_operation (operation))
    {
      return -1;
    }

  operation->is_attr_op (node->is_attr_op ());
  return 0;
}
Exemplo n.º 8
0
be_operation *
be_visitor_ami_pre_proc::create_sendc_operation (be_operation *node)
{
  if (node->flags () == AST_Operation::OP_oneway)
    {
      // We do nothing for oneways!
      return 0;
    }

  Identifier *id = 0;
  UTL_ScopedName *sn = 0;

  // Create the new name
  // Prepend "sendc_" to the name of the operation
  ACE_CString original_op_name (
    node->name ()->last_component ()->get_string ());
  ACE_CString new_op_name =
    ACE_CString ("sendc_") + original_op_name;

  UTL_ScopedName *op_name =
    static_cast<UTL_ScopedName *> (node->name ()->copy ());
  op_name->last_component ()->replace_string (new_op_name.c_str ());

  idl_global->scopes ().push (node->defined_in ());

  // Create the operation
  be_operation *op = 0;
  ACE_NEW_RETURN (op,
                  be_operation (be_global->void_type (),
                                AST_Operation::OP_noflags,
                                op_name,
                                false,
                                false),
                  0);

  idl_global->scopes ().pop ();

  op->set_name (op_name);

  // Create the first argument, which is a Reply Handler

  // Look up the field type.
  UTL_Scope *s = node->defined_in ();
  be_interface *parent = be_interface::narrow_from_scope (s);

  // Add the pre- and suffix
  ACE_CString handler_local_name;

  this->generate_name (
    handler_local_name,
    "AMI_",
    parent->name ()->last_component ()->get_string (),
    "Handler");

  AST_Interface *handler = parent->ami_handler ();

  if (0 == handler)
    {
      op->destroy ();
      delete op;
      op = 0;

      ACE_ERROR_RETURN ((LM_ERROR,
                         ACE_TEXT ("be_visitor_ami_pre_proc::")
                         ACE_TEXT ("create_sendc_operation - ")
                         ACE_TEXT ("null reply ")
                         ACE_TEXT ("handler found\n")),
                        0);
    }

  be_interface *field_type =
    be_interface::narrow_from_decl (handler);

  ACE_NEW_RETURN (id,
                  Identifier ("ami_handler"),
                  0);

  UTL_ScopedName *tmp = 0;

  ACE_NEW_RETURN (tmp,
                  UTL_ScopedName (id,
                                  0),
                  0);

  sn = (UTL_ScopedName *)op->name ()->copy ();
  sn->nconc (tmp);

  be_argument *arg = 0;
  ACE_NEW_RETURN (arg,
                  be_argument (AST_Argument::dir_IN,
                               field_type, // is also a valuetype
                               sn),
                  0);

  arg->set_defined_in (op);
  arg->set_name (sn);
  op->be_add_argument (arg);

  if (field_type->imported ())
    {
      field_type->seen_in_operation (false);
    }

  // Iterate over the arguments and put all the in and inout
  // into the new method.
  if (node->nmembers () > 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,
                  "(%N:%l) be_visitor_ami_pre_proc::create_sendc_method - "
                  "bad node in this scope\n"
                ),
                0
              );

            }

          AST_Argument *original_arg = AST_Argument::narrow_from_decl (d);

          if (original_arg->direction () == AST_Argument::dir_IN ||
              original_arg->direction () == AST_Argument::dir_INOUT)
            {
              // Create the argument.
              be_argument *arg = 0;
              UTL_ScopedName *new_name =
                (UTL_ScopedName *)original_arg->name ()->copy ();
              ACE_NEW_RETURN (arg,
                              be_argument (AST_Argument::dir_IN,
                                           original_arg->field_type (),
                                           new_name),
                              0);

              arg->set_defined_in (op);
              arg->set_name (new_name);
              op->be_add_argument (arg);
            }
        } // end of while loop
    } // end of if

  op->is_sendc_ami (true);
  op->is_attr_op (node->is_attr_op ());
  return op;
}
Exemplo n.º 9
0
AST_String::AST_String (AST_Decl::NodeType nt,
                        UTL_ScopedName *n,
                        AST_Expression *ms,
                        long wide)
  : COMMON_Base (),
    AST_Decl (nt, n, true),
    AST_Type (nt, n),
    AST_ConcreteType (nt, n),
    pd_max_size (ms),
    pd_width (wide)
{
  // Always the case.
  this->size_type (AST_Type::VARIABLE);

  Identifier *id = 0;
  UTL_ScopedName *new_name = 0;
  UTL_ScopedName *conc_name = 0;
  bool narrow = this->width () == (ssize_t) sizeof (char);

  ACE_NEW (id,
           Identifier (narrow ? "char *" : "WChar *"));

  ACE_NEW (conc_name,
           UTL_ScopedName (id,
                           0));

  if (narrow)
    {
      new_name = conc_name;
    }
  else
    {
      ACE_NEW (id,
               Identifier ("CORBA"));

      ACE_NEW (new_name,
               UTL_ScopedName (id,
                               conc_name));
    }

  this->set_name (new_name);

  unsigned long bound = ms->ev ()->u.ulval;

  static char namebuf[NAMEBUFSIZE];
  static char boundbuf[NAMEBUFSIZE];
  ACE_OS::memset (namebuf,
                  '\0',
                  NAMEBUFSIZE);
  ACE_OS::memset (boundbuf,
                  '\0',
                  NAMEBUFSIZE);

  if (bound)
    {
      ACE_OS::sprintf (boundbuf,
                       "_%ld",
                       bound);
    }

  ACE_OS::sprintf (namebuf,
                   "CORBA_%sSTRING%s",
                   (wide == 1 ? "" : "W"),
                   boundbuf);

  this->flat_name_ = ACE::strnew (namebuf);
}
Exemplo n.º 10
0
int
be_visitor_interface_ss::gen_abstract_ops_helper (
  be_interface *node,
  be_interface *base,
  TAO_OutStream *os)
{
  if (!base->is_abstract ())
    {
      return 0;
    }

  AST_Decl *d = 0;
  be_visitor_context ctx;
  ctx.stream (os);
  ctx.state (TAO_CodeGen::TAO_ROOT_SS);

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

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

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

      UTL_ScopedName *item_new_name = 0;
      UTL_ScopedName *new_name = 0;

      if (AST_Decl::NT_op == nt || AST_Decl::NT_attr == nt)
        {
          ACE_NEW_RETURN (item_new_name,
                          UTL_ScopedName (d->local_name ()->copy (),
                                          0),
                          -1);

          new_name = (UTL_ScopedName *) node->name ()->copy ();
          new_name->nconc (item_new_name);
        }
      else
        {
          continue;
        }

      // We pass the node's is_abstract flag to the operation
      // constructor so we will get the right generated operation
      // body if we are regenerating an operation from an
      // abstract interface in a concrete interface or component.
      if (AST_Decl::NT_op == nt)
        {
          be_operation *op = be_operation::narrow_from_decl (d);
          UTL_ScopedName *old_name =
            (UTL_ScopedName *) op->name ()->copy ();
          op->set_name (new_name);
          op->set_defined_in (node);
          op->is_abstract (node->is_abstract ());

          be_visitor_operation_ss op_visitor (&ctx);
          op_visitor.visit_operation (op);

          op->set_name (old_name);
          op->set_defined_in (base);
          op->is_abstract (base->is_abstract ());
        }
      else if (AST_Decl::NT_attr == nt)
        {
          AST_Attribute *attr =
            AST_Attribute::narrow_from_decl (d);
          be_attribute new_attr (attr->readonly (),
                                 attr->field_type (),
                                 0,
                                 attr->is_local (),
                                 attr->is_abstract ());
          new_attr.set_defined_in (node);
          new_attr.set_name (new_name);

          UTL_ExceptList *get_exceptions =
            attr->get_get_exceptions ();

          if (0 != get_exceptions)
            {
              new_attr.be_add_get_exceptions (get_exceptions->copy ());
            }

          UTL_ExceptList *set_exceptions =
            attr->get_set_exceptions ();

          if (0 != set_exceptions)
            {
              new_attr.be_add_set_exceptions (set_exceptions->copy ());
            }

          be_visitor_attribute attr_visitor (&ctx);
          attr_visitor.visit_attribute (&new_attr);
          ctx.attribute (0);
          new_attr.destroy ();
        }
    }

  return 0;
}
Exemplo n.º 11
0
int
be_visitor_interface_cs::gen_abstract_ops_helper (be_interface *node,
                                                  be_interface *base,
                                                  TAO_OutStream *os)
{
  // If the derived interface is local, the abstract parent's operation
  // was generated as pure virtual.
  if (!base->is_abstract () || node->is_local ())
    {
      return 0;
    }

  AST_Decl *d = 0;
  be_visitor_context ctx;
  ctx.stream (os);

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

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

      if (d->node_type () == AST_Decl::NT_op)
        {
          UTL_ScopedName *item_new_name  = 0;
          ACE_NEW_RETURN (item_new_name,
                          UTL_ScopedName (d->local_name ()->copy (),
                                          0),
                          -1);

          UTL_ScopedName *new_op_name =
            (UTL_ScopedName *)node->name ()->copy ();
          new_op_name->nconc (item_new_name);

          be_operation *op = be_operation::narrow_from_decl (d);
          UTL_ScopedName *old_op_name =
            (UTL_ScopedName *) op->name ()->copy ();
          op->set_name (new_op_name);
          op->set_defined_in (node);
          op->is_abstract (node->is_abstract ());

          ctx.state (TAO_CodeGen::TAO_OPERATION_CS);
          be_visitor_operation_cs op_visitor (&ctx);
          op_visitor.visit_operation (op);

          op->set_name (old_op_name);
          op->set_defined_in (base);
          op->is_abstract (base->is_abstract ());
        }
    }

  return 0;
}
Exemplo n.º 12
0
int
be_visitor_amh_pre_proc::create_raise_operation (
    be_decl *node,
    be_valuetype *excep_holder,
    Operation_Kind operation_kind
  )
{
  Identifier *id = 0;
  UTL_ScopedName *sn = 0;
  be_operation *orig_op = 0;

  if (operation_kind == NORMAL)
    {
      orig_op = be_operation::narrow_from_decl (node);
    }

  // Name the operation properly
  UTL_ScopedName *op_name =
    static_cast<UTL_ScopedName *> (excep_holder->name ()->copy ());

  ACE_CString new_local_name ("raise_");

  if (operation_kind == SET_OPERATION)
    {
      new_local_name += "set_";
    }
  else if (operation_kind == GET_OPERATION)
    {
      new_local_name += "get_";
    }

  new_local_name += node->name ()->last_component ()->get_string ();

  ACE_NEW_RETURN (id,
                  Identifier (new_local_name.c_str ()),
                  -1);

  ACE_NEW_RETURN (sn,
                  UTL_ScopedName (id,
                                  0),
                  -1);

  op_name->nconc (sn);

  be_operation *operation = 0;
  ACE_NEW_RETURN (operation,
                  be_operation (be_global->void_type (),
                                AST_Operation::OP_noflags,
                                op_name,
                                0,
                                0),
                  -1);

  operation->set_name (op_name);
  operation->set_defined_in (excep_holder);

  if (operation_kind == NORMAL)
    {
      if (orig_op)
        {
          // Copy the exceptions.
          UTL_ExceptList *exceptions = orig_op->exceptions ();

          if (0 != exceptions)
            {
              operation->be_add_exceptions (exceptions->copy ());
            }
        }
    }

  // After having generated the operation we insert it into the
  // exceptionholder valuetype.
  if (0 == excep_holder->be_add_operation (operation))
    {
      return -1;
    }

  return 0;
}
Exemplo n.º 13
0
int
be_visitor_amh_pre_proc::add_normal_reply (be_operation *node,
                                           be_interface *response_handler)
{
  Identifier *id = 0;
  UTL_ScopedName *sn = 0;

  ACE_CString original_op_name (
                  node->name ()->last_component ()->get_string ()
                );

  UTL_ScopedName *op_name =
    static_cast<UTL_ScopedName *> (response_handler->name ()->copy ());

  ACE_NEW_RETURN (id,
                  Identifier (original_op_name.c_str ()),
                  -1);

  ACE_NEW_RETURN (sn,
                  UTL_ScopedName (id,
                                  0),
                  -1);

  op_name->nconc (sn);

  // Create the operation
  be_operation *operation = 0;
  ACE_NEW_RETURN (operation,
                  be_operation (be_global->void_type (),
                                AST_Operation::OP_noflags,
                                op_name,
                                1,
                                0),
                  -1);

  operation->set_name (op_name);

  // If return type is non-void add it as first argument

  if (!node->void_return_type ())
    {
      Identifier *arg_id = 0;
      ACE_NEW_RETURN (arg_id,
                      Identifier ("return_value"),
                      -1);

      UTL_ScopedName *arg_name = 0;
      ACE_NEW_RETURN (arg_name,
                      UTL_ScopedName (arg_id, 0),
                      -1);

      // Create the argument
      be_argument *arg = 0;
      ACE_NEW_RETURN (arg,
                      be_argument (AST_Argument::dir_IN,
                                   node->return_type (),
                                   arg_name),
                      -1);

      arg->set_name (arg_name);

      // Add the response handler to the argument list
      operation->be_add_argument (arg);
    }

  // Iterate over the arguments and put all the out and inout arguments
  // into the new method.
  for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
       !si.is_done ();
       si.next ())
    {
      AST_Decl *d = si.item ();

      if (!d)
        {
          operation->destroy ();
          delete operation;
          operation = 0;

          ACE_ERROR_RETURN ((LM_ERROR,
                             ACE_TEXT ("be_visitor_amh_pre_proc::")
                             ACE_TEXT ("add_normal_reply - ")
                             ACE_TEXT ("bad node in this scope\n")),
                            -1);

        }

      //be_decl *arg = be_decl::narrow_from_decl (d);
      AST_Argument *original_arg = AST_Argument::narrow_from_decl (d);

      if (original_arg->direction () == AST_Argument::dir_INOUT ||
          original_arg->direction () == AST_Argument::dir_OUT)
        {
          // Create the argument
          be_argument *arg = 0;
          ACE_NEW_RETURN (arg,
                          be_argument (AST_Argument::dir_IN,
                                       original_arg->field_type (),
                                       original_arg->name ()),
                          -1);

          operation->be_add_argument (arg);
        }
    }

  operation->set_defined_in (response_handler);

  // We do not copy the exceptions because the exceptions
  // are delivered by the excep methods.

  // After having generated the operation we insert it into the
  // response handler interface.
  if (0 == response_handler->be_add_operation (operation))
    {
      return -1;
    }

  return 0;
}
Exemplo n.º 14
0
// Overriden method.
void
be_predefined_type::compute_tc_name (void)
{
  // Start with the head as the CORBA namespace.
  Identifier *corba_id = 0;
  ACE_NEW (corba_id,
           Identifier ("CORBA"));

  ACE_NEW (this->tc_name_,
           UTL_ScopedName (corba_id,
                           0));

  Identifier *id = 0;
  UTL_ScopedName *conc_name = 0;

  switch (this->pt ())
    {
    case AST_PredefinedType::PT_void:
      ACE_NEW (id,
               Identifier ("_tc_void"));
      break;
    case AST_PredefinedType::PT_long:
      ACE_NEW (id,
               Identifier ("_tc_long"));
      break;
    case AST_PredefinedType::PT_longlong:
      ACE_NEW (id,
               Identifier ("_tc_longlong"));
      break;
    case AST_PredefinedType::PT_ulong:
      ACE_NEW (id,
               Identifier ("_tc_ulong"));
      break;
    case AST_PredefinedType::PT_ulonglong:
      ACE_NEW (id,
               Identifier ("_tc_ulonglong"));
      break;
    case AST_PredefinedType::PT_short:
      ACE_NEW (id,
               Identifier ("_tc_short"));
      break;
    case AST_PredefinedType::PT_ushort:
      ACE_NEW (id,
               Identifier ("_tc_ushort"));
      break;
    case AST_PredefinedType::PT_float:
      ACE_NEW (id,
               Identifier ("_tc_float"));
      break;
    case AST_PredefinedType::PT_double:
      ACE_NEW (id,
               Identifier ("_tc_double"));
      break;
    case AST_PredefinedType::PT_longdouble:
      ACE_NEW (id,
               Identifier ("_tc_longdouble"));
      break;
    case AST_PredefinedType::PT_char:
      ACE_NEW (id,
               Identifier ("_tc_char"));
      break;
    case AST_PredefinedType::PT_wchar:
      ACE_NEW (id,
               Identifier ("_tc_wchar"));
      break;
    case AST_PredefinedType::PT_octet:
      ACE_NEW (id,
               Identifier ("_tc_octet"));
      break;
    case AST_PredefinedType::PT_boolean:
      ACE_NEW (id,
               Identifier ("_tc_boolean"));
      break;
    case AST_PredefinedType::PT_any:
      ACE_NEW (id,
               Identifier ("_tc_any"));
    break;
    case AST_PredefinedType::PT_object:
      ACE_NEW (id,
               Identifier ("_tc_Object"));
    break;
    case AST_PredefinedType::PT_value:
      ACE_NEW (id,
               Identifier ("_tc_ValueBase"));
    break;
    case AST_PredefinedType::PT_abstract:
      ACE_NEW (id,
               Identifier ("_tc_AbstractBase"));
    break;
    case AST_PredefinedType::PT_pseudo:
      {
        char tcname [100];
        ACE_OS::sprintf (tcname,
                         "_tc_%s",
                         this->name ()->last_component ()->get_string ());

        ACE_NEW (id,
                 Identifier (tcname));
        break;
      }
    default:
      ACE_ERROR ((LM_WARNING, "Unknown or invalid predefined type"));
      break;
    }

  ACE_NEW (conc_name,
           UTL_ScopedName (id,
                           0));

  this->tc_name_->nconc (conc_name);
}
Exemplo n.º 15
0
int
ast_visitor_tmpl_module_inst::visit_interface (AST_Interface *node)
{
  UTL_NameList *parent_names =
    this->create_name_list (node->inherits (),
                            node->n_inherits ());

  Identifier *node_id = 0;
  ACE_NEW_RETURN (node_id,
                  Identifier (node->local_name ()->get_string ()),
                  -1);

  UTL_ScopedName *local_name = 0;
  ACE_NEW_RETURN (local_name,
                  UTL_ScopedName (node_id, 0),
                  -1);

  FE_InterfaceHeader header (local_name,
                             parent_names,
                             node->is_local (),
                             node->is_abstract (),
                             true);

  AST_Interface *added_iface =
    idl_global->gen ()->create_interface (header.name (),
                                          header.inherits (),
                                          header.n_inherits (),
                                          header.inherits_flat (),
                                          header.n_inherits_flat (),
                                          header.is_local (),
                                          header.is_abstract ());

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

  idl_global->scopes ().top ()->add_to_scope (added_iface);

  // If this interface has both abstract and concrete parents,
  // extra code needs to be generated for it, such as overrides
  // of _is_nil() and release().
  added_iface->analyze_parentage ();

  // Update the scope stack.
  idl_global->scopes ().push (added_iface);

  if (this->visit_scope (node) != 0)
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                         ACE_TEXT ("ast_visitor_tmpl_module_inst::")
                         ACE_TEXT ("visit_interface - ")
                         ACE_TEXT ("visit_scope failed\n")),
                        -1);
    }

  // Through with this scope.
  idl_global->scopes ().pop ();

  return 0;
}
Exemplo n.º 16
0
void
be_type::compute_tc_name (void)
{
  static char namebuf [NAMEBUFSIZE];
  UTL_ScopedName *n = this->name ();

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

  ACE_OS::memset (namebuf,
                  '\0',
                  NAMEBUFSIZE);

  while (n->tail () != 0)
    {
      // Does not exist.
      if (this->tc_name_ == 0)
        {
          ACE_NEW (this->tc_name_,
                   UTL_ScopedName (n->head ()->copy (),
                                   0));
        }
      else
        {
          UTL_ScopedName *conc_name = 0;
          ACE_NEW (conc_name,
                   UTL_ScopedName (n->head ()->copy (),
                                   0));

          this->tc_name_->nconc (conc_name);
        }

      n = (UTL_ScopedName *)n->tail ();
    }

  ACE_OS::sprintf (namebuf,
                   "_tc_%s",
                   n->last_component ()->get_string ());

  Identifier *id = 0;
  ACE_NEW (id,
           Identifier (namebuf));

  // Does not exist.
  if (this->tc_name_ == 0)
    {
      ACE_NEW (this->tc_name_,
               UTL_ScopedName (id,
                               0));
    }
  else
    {
      UTL_ScopedName *conc_name = 0;
      ACE_NEW (conc_name,
               UTL_ScopedName (id,
                               0));

      this->tc_name_->nconc (conc_name);
    }
}
Exemplo n.º 17
0
int
be_visitor_attribute::visit_attribute (be_attribute *node)
{
    this->ctx_->node (node);
    this->ctx_->attribute (node);

    UTL_Scope *s = node->defined_in ();
    AST_Decl *d = ScopeAsDecl (s);
    ACE_CString op_name (this->ctx_->port_prefix ());
    op_name += node->local_name ()->get_string ();
    Identifier *op_id = 0;
    ACE_NEW_RETURN (op_id,
                    Identifier (op_name.c_str ()),
                    -1);

    UTL_ScopedName *op_ln = 0;
    ACE_NEW_RETURN (op_ln,
                    UTL_ScopedName (op_id, 0),
                    -1);

    UTL_ScopedName *op_sn =
        static_cast<UTL_ScopedName *> (d->name ()->copy ());
    op_sn->nconc (op_ln);

    // first the "get" operation
    be_operation get_op (node->field_type (),
                         AST_Operation::OP_noflags,
                         0,
                         node->is_local (),
                         node->is_abstract ());

    get_op.set_defined_in (s);
    get_op.set_name (op_sn);
    UTL_ExceptList *get_exceptions = node->get_get_exceptions ();

    if (0 != get_exceptions)
    {
        get_op.be_add_exceptions (get_exceptions->copy ());
    }

    be_visitor_context ctx (*this->ctx_);
    int status = 1;

    switch (this->ctx_->state ())
    {
    // These two cases are the only ones that could involve a strategy.
    case TAO_CodeGen::TAO_ROOT_CH:
    case TAO_CodeGen::TAO_INTERFACE_CH:
    {
        ctx.state (TAO_CodeGen::TAO_OPERATION_CH);
        be_visitor_operation_ch visitor (&ctx);
        status = get_op.accept (&visitor);
        break;
    }
    case TAO_CodeGen::TAO_ROOT_CS:
    {
        ctx.state (TAO_CodeGen::TAO_OPERATION_CS);
        be_visitor_operation_cs visitor (&ctx);
        status = get_op.accept (&visitor);
        break;
    }
    case TAO_CodeGen::TAO_ROOT_SH:
    {
        be_visitor_operation_sh visitor (&ctx);
        status = get_op.accept (&visitor);
        break;
    }
    case TAO_CodeGen::TAO_ROOT_IH:
    {
        be_visitor_operation_ih visitor (&ctx);
        status = get_op.accept (&visitor);
        break;
    }
    case TAO_CodeGen::TAO_ROOT_SS:
    {
        be_visitor_operation_ss visitor (&ctx);
        status = get_op.accept (&visitor);
        break;
    }
    case TAO_CodeGen::TAO_ROOT_IS:
    {
        be_visitor_operation_is visitor (&ctx);
        status = get_op.accept (&visitor);
        break;
    }
    case TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SH:
    {
        be_visitor_operation_proxy_impl_xh visitor (&ctx);
        status = get_op.accept (&visitor);
        break;
    }
    case TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SS:
    {
        be_visitor_operation_direct_proxy_impl_ss visitor (&ctx);
        status = get_op.accept (&visitor);
        break;
    }
    case TAO_CodeGen::TAO_INTERFACE_SMART_PROXY_CH:
    {
        be_visitor_operation_smart_proxy_ch visitor (&ctx);
        status = get_op.accept (&visitor);
        break;
    }
    case TAO_CodeGen::TAO_INTERFACE_SMART_PROXY_CS:
    {
        be_visitor_operation_smart_proxy_cs visitor (&ctx);
        status = get_op.accept (&visitor);
        break;
    }
    case TAO_CodeGen::TAO_ROOT_TIE_SH:
    {
        be_visitor_operation_tie_sh visitor (&ctx);
        status = get_op.accept (&visitor);
        break;
    }
    case TAO_CodeGen::TAO_ROOT_TIE_SS:
    {
        be_visitor_operation_tie_ss visitor (&ctx);
        status = get_op.accept (&visitor);
        break;
    }
    case TAO_CodeGen::TAO_ROOT_SVTH:
    case TAO_CodeGen::TAO_ROOT_SVH:
    {
        be_visitor_operation_ch visitor (&ctx);
        status = get_op.accept (&visitor);
        break;
    }
    case TAO_CodeGen::TAO_ROOT_SVTS:
    case TAO_CodeGen::TAO_ROOT_SVS:
    {
        be_visitor_operation_svs visitor (&ctx);
        visitor.scope (this->op_scope_);
        status = get_op.accept (&visitor);
        break;
    }
    case TAO_CodeGen::TAO_ROOT_EXH:
    {
        be_visitor_operation_ch visitor (&ctx);
        status = get_op.accept (&visitor);
        break;
    }
    case TAO_CodeGen::TAO_ROOT_EXS:
    {
        be_visitor_operation_exs visitor (&ctx);
        visitor.scope (this->op_scope_);
        visitor.class_extension (this->exec_class_extension_.c_str ());
        status = get_op.accept (&visitor);
        break;
    }
    case TAO_CodeGen::TAO_ROOT_CNH:
    case TAO_CodeGen::TAO_ROOT_CNS:
        break;
    default:
        get_op.destroy ();
        return 0;
    }

    if (status == -1)
    {
        get_op.destroy ();
        ACE_ERROR_RETURN ((LM_ERROR,
                           "(%N:%l) be_visitor_attribute::"
                           "visit_attribute - "
                           "codegen for get_attribute failed\n"),
                          -1);
    }

    // Do nothing for readonly attributes.
    if (node->readonly ())
    {
        get_op.destroy ();
        return 0;
    }

    status = 1;

    // Create the set method.
    Identifier id ("void");
    UTL_ScopedName sn (&id,
                       0);

    // The return type  is "void".
    be_predefined_type rt (AST_PredefinedType::PT_void,
                           &sn);

    // Argument type is the same as the attribute type.
    AST_Argument *arg =
        idl_global->gen ()->create_argument (AST_Argument::dir_IN,
                node->field_type (),
                node->name ());

    arg->set_name ((UTL_IdList *) node->name ()->copy ());

    // Create the operation.
    be_operation set_op (&rt,
                         AST_Operation::OP_noflags,
                         0,
                         node->is_local (),
                         node->is_abstract ());
    set_op.set_defined_in (node->defined_in ());
    set_op.set_name (static_cast<UTL_ScopedName *> (op_sn->copy ()));
    set_op.be_add_argument (arg);

    UTL_ExceptList *set_exceptions = node->get_set_exceptions ();

    if (0 != set_exceptions)
    {
        set_op.be_add_exceptions (set_exceptions->copy ());
    }

    ctx = *this->ctx_;
    status = 1;

    switch (this->ctx_->state ())
    {
    // These two cases are the only ones that could involved a strategy.
    case TAO_CodeGen::TAO_ROOT_CH:
    case TAO_CodeGen::TAO_INTERFACE_CH:
    {
        ctx.state (TAO_CodeGen::TAO_OPERATION_CH);
        be_visitor_operation_ch visitor (&ctx);
        status = set_op.accept (&visitor);
        break;
    }
    case TAO_CodeGen::TAO_ROOT_CS:
    {
        ctx.state (TAO_CodeGen::TAO_OPERATION_CS);
        be_visitor_operation_cs visitor (&ctx);
        status = set_op.accept (&visitor);
        break;
    }
    case TAO_CodeGen::TAO_ROOT_SH:
    {
        be_visitor_operation_sh visitor (&ctx);
        status = set_op.accept (&visitor);
        break;
    }
    case TAO_CodeGen::TAO_ROOT_IH:
    {
        be_visitor_operation_ih visitor (&ctx);
        status = set_op.accept (&visitor);
        break;
    }
    case TAO_CodeGen::TAO_ROOT_SS:
    {
        be_visitor_operation_ss visitor (&ctx);
        status = set_op.accept (&visitor);
        break;
    }
    case TAO_CodeGen::TAO_ROOT_IS:
    {
        be_visitor_operation_is visitor (&ctx);
        status = set_op.accept (&visitor);
        break;
    }
    case TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SH:
    {
        be_visitor_operation_proxy_impl_xh visitor (&ctx);
        status = set_op.accept (&visitor);
        break;
    }
    case TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SS:
    {
        be_visitor_operation_direct_proxy_impl_ss visitor (&ctx);
        status = set_op.accept (&visitor);
        break;
    }
    case TAO_CodeGen::TAO_INTERFACE_SMART_PROXY_CH:
    {
        be_visitor_operation_smart_proxy_ch visitor (&ctx);
        status = set_op.accept (&visitor);
        break;
    }
    case TAO_CodeGen::TAO_INTERFACE_SMART_PROXY_CS:
    {
        be_visitor_operation_smart_proxy_cs visitor (&ctx);
        status = set_op.accept (&visitor);
        break;
    }
    case TAO_CodeGen::TAO_ROOT_TIE_SH:
    {
        be_visitor_operation_tie_sh visitor (&ctx);
        status = set_op.accept (&visitor);
        break;
    }
    case TAO_CodeGen::TAO_ROOT_TIE_SS:
    {
        be_visitor_operation_tie_ss visitor (&ctx);
        status = set_op.accept (&visitor);
        break;
    }
    case TAO_CodeGen::TAO_ROOT_SVTH:
    case TAO_CodeGen::TAO_ROOT_SVH:
    {
        be_visitor_operation_ch visitor (&ctx);
        status = set_op.accept (&visitor);
        break;
    }
    case TAO_CodeGen::TAO_ROOT_SVTS:
    case TAO_CodeGen::TAO_ROOT_SVS:
    {
        be_visitor_operation_svs visitor (&ctx);
        visitor.scope (this->op_scope_);
        status = set_op.accept (&visitor);
        break;
    }
    case TAO_CodeGen::TAO_ROOT_EXH:
    {
        be_visitor_operation_ch visitor (&ctx);
        status = set_op.accept (&visitor);
        break;
    }
    case TAO_CodeGen::TAO_ROOT_EXS:
    {
        be_visitor_operation_exs visitor (&ctx);
        visitor.scope (this->op_scope_);
        visitor.class_extension (this->exec_class_extension_.c_str ());
        status = set_op.accept (&visitor);
        break;
    }
    case TAO_CodeGen::TAO_ROOT_CNH:
    case TAO_CodeGen::TAO_ROOT_CNS:
        break;
    default:
        // Error.
        set_op.destroy ();
        rt.destroy ();
        ACE_ERROR_RETURN ((LM_ERROR,
                           "(%N:%l) be_visitor_attribute::"
                           "visit_attribute - "
                           "bad codegen state\n"),
                          -1);
    }

    if (status == 0)
    {
        get_op.destroy ();
        set_op.destroy ();
        rt.destroy ();
        return 0;
    }
    else if (status == -1)
    {
        get_op.destroy ();
        set_op.destroy ();
        rt.destroy ();
        ACE_ERROR_RETURN ((LM_ERROR,
                           "(%N:%l) be_visitor_attribute::"
                           "visit_attribute - "
                           "codegen for get_attribute failed\n"),
                          -1);
    }

    get_op.destroy ();
    set_op.destroy ();
    rt.destroy ();
    return 0;
}