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

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

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

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

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

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

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

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

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

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

        return -1;
    }

    return 0;
}