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

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

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

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

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

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

      v = c->constant_value ();
    }

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

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

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

  return 0;
}
Example #2
0
int
ast_visitor_reifying::visit_string (AST_String *node)
{
  AST_Expression *b = node->max_size ();
  AST_Param_Holder *ph = b->param_holder ();

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

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

      b = c->constant_value ();
    }
  else if (b->ev ()->u.ulval == 0)
    {
      this->reified_node_ = node;
      return 0;
    }

  AST_Expression *bound = 0;
  ACE_NEW_RETURN (bound,
                  AST_Expression (b,
                                  AST_Expression::EV_ulong),
                  -1);

  Identifier id ("string");
  UTL_ScopedName sn (&id, 0);

  ACE_NEW_RETURN (this->reified_node_,
                  AST_String (AST_Decl::NT_string,
                              &sn,
                              bound,
                              node->width ()),
                  -1);

  return 0;
}