Beispiel #1
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;
   }
}
Beispiel #2
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;
}
Beispiel #3
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;
}
Beispiel #4
0
// Add a node to set of nodes referenced in this scope
void
UTL_Scope::add_to_referenced(AST_Decl *e, idl_bool recursive)
{
   UTL_Scope *s;
   AST_Decl **tmp;
   AST_Interface *itf;
   long oreferenced_allocated;
   long i;

   if (e == NULL)
      return ;

   // Special cases for forward declared interfaces and valuetypes in
   // the scope in which they're defined. Cannot add before full
   // definition is seen
   if ((e->node_type() == AST_Decl::NT_interface)
       || (e->node_type() == AST_Decl::NT_value))
   {
      itf = AST_Interface::narrow_from_decl(e);

      if (itf != NULL && itf->defined_in() == this && !itf->is_defined())
         return ;
   }

   // Only insert if it is not there already
   if (referenced(e))
      return ;

   // Make sure there's space for one more
   if (pd_referenced_allocated == pd_referenced_used)
   {

      oreferenced_allocated = pd_referenced_allocated;
      pd_referenced_allocated += INCREMENT;
      tmp = new AST_Decl * [pd_referenced_allocated];

      for (i = 0; i < oreferenced_allocated; i++)
         tmp[i] = pd_referenced[i];

      delete [] pd_referenced;

      pd_referenced = tmp;
   }

   // Insert new reference
   pd_referenced[pd_referenced_used++] = e;

   // Now, if recursive is specified and "this" is not a common ancestor
   // of the referencing scope and the scope of definition of "e" then
   // add "e" to the set of referenced nodes in the parent of "this"
   if (recursive && !(e->has_ancestor(ScopeAsDecl(this))))
   {
      s = e->defined_in();

      if (s != NULL)
         s->add_to_referenced(e, recursive);
   }
}
Beispiel #5
0
static
AST_Decl * add_type(AST_Type *type)
{
   AST_Decl * result = 0;
   UTL_Scope * scope = 0;

   switch (type->node_type())
   {

         case AST_Decl::NT_array:
         result =
            idl_global->root()->add_array(AST_Array::narrow_from_decl(type));
         break;

         case AST_Decl::NT_enum:
         result = type->defined_in()->add_enum(AST_Enum::narrow_from_decl(type));
         scope = AST_Enum::narrow_from_decl(type);
         break;

         case AST_Decl::NT_sequence:
         result =
            idl_global->root()->add_sequence(AST_Sequence::narrow_from_decl(type));
         break;

         case AST_Decl::NT_string:
         result =
            idl_global->root()->add_string(AST_String::narrow_from_decl(type));
         break;

         case AST_Decl::NT_struct:
         result =
            type->defined_in()->
            add_structure(AST_Structure::narrow_from_decl(type));
         scope = AST_Structure::narrow_from_decl(type);
         break;

         case AST_Decl::NT_union:
         result =
            type->defined_in()->add_union(AST_Union::narrow_from_decl(type));
         scope = AST_Union::narrow_from_decl(type);
         break;

         default:
         // for non-complex types, like predefined types
         // no additional add needed, assume everything is ok
         result = (AST_Decl *) 1;
         break;
   }

   if (scope)
      result = scope->call_add();

   return result;
}
Beispiel #6
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;
}
Beispiel #7
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;
    }
}
Beispiel #8
0
bool
AST_illegal_recursive_type (AST_Decl *t)
{
  if (t == 0)
    {
      return false;
    }

  AST_Decl::NodeType nt;
  AST_Type *ut = AST_Type::narrow_from_decl (t);

  if (ut != 0)
    {
      ut = ut->unaliased_type ();
      nt = ut->node_type ();
    }
  else
    {
      nt = t->node_type ();
    }

  if (nt == AST_Decl::NT_interface)
    {
      // Check for interface->struct/union->....->interface nesting.
//      return AST_illegal_interface_recursion (t);
    }
  else if (nt != AST_Decl::NT_struct && nt != AST_Decl::NT_union)
    {
      // Structs and unions fall through to the check below.
      return false;  // NOT ILLEGAL.
    }

  bool check_for_struct = false;
  bool check_for_union = false;
  AST_Structure  *st1 = 0;
  AST_Union  *un1 = 0;

  // Narrow the type appropriately so comparison will work.
  if (t->node_type () == AST_Decl::NT_struct)
    {
      check_for_struct = true;
      st1 = AST_Structure::narrow_from_decl (t);

      if (st1 == 0)
        {
          return false;  // NOT ILLEGAL.
        }
    }
  else if (t->node_type () == AST_Decl::NT_union)
    {
      check_for_union = true;
      un1 = AST_Union::narrow_from_decl (t);

      if (un1 == 0)
        {
          return false;  // NOT ILLEGAL.
        }
    }

  UTL_Scope  *s = 0;
  AST_Structure *st2 = 0;
  AST_Union *un2 = 0;

  // OK, iterate up the stack.
  for (UTL_ScopeStackActiveIterator i (idl_global->scopes ());
       !i.is_done ();
       i.next ())
    {
      s = i.item ();

      // If we hit a NULL we're done since it means that we're nested inside
      // a sequence, where recursive types may be used.
      if (s == 0)
        {
          return false;  // NOT ILLEGAL.
        }

      // OK, must check this scope.
      if (s->scope_node_type () == AST_Decl::NT_struct
          && check_for_struct == true)
        {
          st2 = AST_Structure::narrow_from_scope (s);

          if (st2 != 0 && st2 == st1)
            {
              return true;  // ILLEGAL RECURSIVE TYPE USE.
            }
        }
      else if (s->scope_node_type () == AST_Decl::NT_union
               && check_for_union == true)
        {
          un2 = AST_Union::narrow_from_scope (s);

          if (un2 != 0 && un2 == un1)
            {
              return true;  // ILLEGAL RECURSIVE TYPE USE.
            }
        }
    }

  // No more scopes to check. This type was used legally.
  return false;    // NOT ILLEGAL.
}
int
be_visitor_ami_pre_proc::visit_interface (be_interface *node)
{
  // We check for an imported node after generating the reply handler.
  if (node->is_local () || node->is_abstract ())
    {
      return 0;
    }

  // The following 3 IF blocks are checks for CCM-related nodes, which
  // we want to skip until we get AMI integrated with CIAO.

  // Skip the *EventConsumer added for each eventtype.
  if (node->is_event_consumer ())
    {
      return 0;
    }

  // Check for home equivalent interface. The lookup will find the
  // home itself, which was declared first.
  Identifier *node_lname = node->AST_Decl::local_name ();
  AST_Decl *first_stored =
    node->defined_in ()->lookup_by_name_local (node_lname, false);

  if (0 != first_stored && first_stored->node_type () == AST_Decl::NT_home)
    {
      return 0;
    }

  ACE_CString lname (node_lname->get_string ());

  // Skip the *Explict and *Implicit interfaces added for a home.
  if (lname.substr (lname.length () - 6) == "plicit")
    {
      UTL_Scope *s = node->defined_in ();
      Identifier local_id (lname.substr (0, lname.length () - 8).c_str ());
      AST_Decl *d = s->lookup_by_name_local (&local_id, false);
      local_id.destroy ();

      if (0 != d)
        {
          return 0;
        }
    }

  AST_Module *module =
    AST_Module::narrow_from_scope (node->defined_in ());

  if (!module)
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                         "(%N:%l) be_visitor_ami_pre_proc::"
                         "visit_interface - "
                         "module is null\n"),
                        -1);
    }

  be_interface *reply_handler = this->create_reply_handler (node);

  if (reply_handler)
    {
      reply_handler->set_defined_in (node->defined_in ());

      // Insert the ami handler after the node, the
      // exception holder will be placed between these two later.
      module->be_add_interface (reply_handler, node);

      // Remember from whom we were cloned
      reply_handler->original_interface (node);

      // If this was created for an imported node, it will be wrong
      // unless we set it.
      reply_handler->set_imported (node->imported ());
    }
  else
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                         "(%N:%l) be_visitor_ami_pre_proc::"
                         "visit_interface - "
                         "creating the reply handler failed\n"),
                        -1);
    }

  if (this->visit_scope (node) == -1)
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                         "(%N:%l) be_visitor_ami_pre_proc::"
                         "visit_interface - "
                         "visit scope failed\n"),
                        -1);
    }

  return 0;
}
Beispiel #10
0
void
FE_ComponentHeader::compile_supports (UTL_NameList *supports)
{
  if (supports == 0)
    {
      return;
    }

  AST_Decl *d = 0;
  UTL_ScopedName *item = 0;
  AST_Interface *iface = 0;
  AST_Type *t = 0;
  long j = 0;
  long k = 0;

  // Compute expanded flattened non-repeating list of interfaces
  // which this one inherits from.

  for (UTL_NamelistActiveIterator l (supports); !l.is_done (); l.next ())
    {
      item = l.item ();

      // Check that scope stack is valid.
      if (idl_global->scopes ().top () == 0)
        {
          idl_global->err ()->lookup_error (item);

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

      // Look it up.
      UTL_Scope *s = idl_global->scopes ().top ();

      d = s->lookup_by_name  (item, true);

      if (d == 0)
        {
          AST_Decl *sad = ScopeAsDecl (s);

          if (sad->node_type () == AST_Decl::NT_module)
            {
              AST_Module *m = AST_Module::narrow_from_decl (sad);

              d = m->look_in_prev_mods_local (item->last_component ());
            }
        }

      // Not found?
      if (d == 0)
        {
          idl_global->err ()->lookup_error (item);

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

      // Remove typedefs, if any.
      if (d->node_type () == AST_Decl::NT_typedef)
        {
          d = AST_Typedef::narrow_from_decl (d)->primitive_base_type ();
        }

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

      if (nt == AST_Decl::NT_interface)
        {
          iface = AST_Interface::narrow_from_decl (d);

          // Undefined interface?
          if (!iface->is_defined ())
            {
              idl_global->err ()->inheritance_fwd_error (
                this->interface_name_,
                iface);

              continue;
            }

          // Local interface? (illegal for components to support).
          if (iface->is_local ())
            {
              idl_global->err ()->unconstrained_interface_expected (
                this->name (),
                iface->name ());

              continue;
           }
        }
      else if (nt == AST_Decl::NT_param_holder)
        {
          AST_Param_Holder *ph =
            AST_Param_Holder::narrow_from_decl (d);

          nt = ph->info ()->type_;

          if (nt != AST_Decl::NT_type
              && nt != AST_Decl::NT_interface)
            {
              idl_global->err ()->mismatched_template_param (
                ph->info ()->name_.c_str ());

              continue;
            }
        }
      else
        {
          idl_global->err ()->interface_expected (d);
          continue;
        }

      // OK, see if we have to add this to the list of interfaces
      // inherited from.
      this->compile_one_inheritance (t);
    }

  // OK, install in interface header.
  // First the flat list (all ancestors).
  if (this->iused_flat_ > 0)
    {
      ACE_NEW (this->inherits_flat_,
               AST_Interface *[this->iused_flat_]);

      for (j = 0; j < this->iused_flat_; ++j)
        {
          this->inherits_flat_[j] = this->iseen_flat_[j];
        }

      this->n_inherits_flat_ = this->iused_flat_;
    }
Beispiel #11
0
AST_Decl *UTL_Scope::call_add()
{
   AST_Decl *result = NULL;
   AST_Decl *decl;

   UTL_ScopeActiveIterator *i;
   UTL_Scope *scope;

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

   while (!(i->is_done()))
   {
      decl = i->item();
      scope = 0;

      switch (decl->node_type())
      {

      case AST_Decl::NT_argument:
         result = add_argument(AST_Argument::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_array:
         result = add_array(AST_Array::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_attr:
         result = add_attribute(AST_Attribute::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_const:
         result = add_constant(AST_Constant::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_enum:
         scope = AST_Enum::narrow_from_decl(decl);
         result = add_enum(AST_Enum::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_enum_val:
         result = add_enum_val(AST_EnumVal::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_except:
         scope = AST_Exception::narrow_from_decl(decl);
         result = add_exception(AST_Exception::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_field:
         result = add_field(AST_Field::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_interface:
         scope = AST_Interface::narrow_from_decl(decl);
         result = add_interface(AST_Interface::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_interface_fwd:
         result = add_interface_fwd(AST_InterfaceFwd::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_module:
         scope = AST_Module::narrow_from_decl(decl);
         result = add_module(AST_Module::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_op:
         result = add_operation(AST_Operation::narrow_from_decl(decl));
         scope = AST_Operation::narrow_from_decl(decl);
         break;

      case AST_Decl::NT_pre_defined:
         result =
         add_predefined_type(AST_PredefinedType::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_sequence:
         result = add_sequence(AST_Sequence::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_string:
         result = add_string(AST_String::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_struct:
         result = add_structure(AST_Structure::narrow_from_decl(decl));
         scope = AST_Structure::narrow_from_decl(decl);
         break;

      case AST_Decl::NT_typedef:
         result = add_typedef(AST_Typedef::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_union:
         result = add_union(AST_Union::narrow_from_decl(decl));
         scope = AST_Union::narrow_from_decl(decl);
         break;

      case AST_Decl::NT_union_branch:
         result = add_union_branch(AST_UnionBranch::narrow_from_decl(decl));
         break;
         //   case AST_Decl::NT_opaque:
         //  result = add_opaque(AST_Opaque::narrow_from_decl(decl));
         // break;

      case AST_Decl::NT_value:
         result = add_valuetype (AST_Value::narrow_from_decl (decl));
         scope = AST_Value::narrow_from_decl (decl);
         break;

      case AST_Decl::NT_value_fwd:
         result = add_valuetype_fwd(AST_ValueFwd::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_state_member:
         result = add_state_member(AST_StateMember::narrow_from_decl(decl));
         break;

      default:
         return NULL;
      }

      if (scope)
         scope->call_add();

      i->next();
   }

   delete i;
   return result;
}
Beispiel #12
0
/*
 * Implements lookup by name for scoped names
 */
AST_Decl *
UTL_Scope::lookup_by_name(UTL_ScopedName *e, idl_bool treat_as_ref, 
                          idl_bool in_parent)
{
   AST_Decl *d;
   UTL_Scope *t = NULL;

   /*
    * Empty name? error
    */

   if (e == NULL)
   {
      return NULL;
   }

   /*
    * If name starts with "::" or "" start search up in global scope
    */
   if (is_global_name(e->head()))
   {
      /*
       * Get parent scope
       */
      d = ScopeAsDecl(this);

      if (d == NULL)
         return NULL;

      t = d->defined_in();

      /*
       * If this is the global scope..
       */
      if (t == NULL)
      {
         /*
          * Look up tail of name starting here
          */
         d = lookup_by_name((UTL_ScopedName *) e->tail(), treat_as_ref);
         /*
          * Now return whatever we have
          */ 
         return d;
      }

      /*
       * OK, not global scope yet, so simply iterate with parent scope
       */
      d = t->lookup_by_name(e, treat_as_ref);

      /*
       * If treat_as_ref is true and d is not NULL, add d to
       * set of nodes referenced here
       */
      if (treat_as_ref && d != NULL)
         add_to_referenced(d, I_FALSE);

      /*
       * Now return what we have
       */ 
      return d;
   }

   /*
    * The name does not start with "::"
    *
    * Is name defined here?
    */
   d = lookup_by_name_local (e->head ());

   /*
    * Special case for scope which is an interface. We have to look
    * in the inherited interfaces as well..
    */
   if (d == NULL)
   {
      if (pd_scope_node_type == AST_Decl::NT_interface)
      {
         d = look_in_inherited(e, treat_as_ref);

         if (treat_as_ref && d != NULL)
         {
            add_to_referenced(d, I_FALSE);
            /*
             * OK, now return whatever we found
             */ 
            return d;
         }
      }
   }

   /* Only traverse parent scope chain if not in inherited interface. */
   if (d == NULL && !in_parent)
   {
      /*
       * OK, not found. Go down parent scope chain.
       */
      d = ScopeAsDecl(this);

      if (d != NULL)
      {
         t = d->defined_in();

         if (t == NULL)
            d = NULL;
         else
            d = t->lookup_by_name(e, treat_as_ref);
      }

      /*
       * If treat_as_ref is true and d is not NULL, add d to
       * set of nodes referenced here
       */
      if (treat_as_ref && d != NULL)
         add_to_referenced(d, I_FALSE);

      /*
       * OK, now return whatever we found
       */ 
      return d;
   }

   /*
    * OK, start of name is defined. Now loop doing local lookups
    * of subsequent elements of the name
    */
   d = iter_lookup_by_name_local(d, e, treat_as_ref);

   /*
    * If treat_as_ref is true and d is not NULL, add d to set
    * of nodes referenced here.
    */
   if (treat_as_ref && d != NULL)
      add_to_referenced(d, I_FALSE);

   /*
    * All OK, name fully resolved
    */ 
   return d;
}
Beispiel #13
0
/*
 * Helper function for lookup_by_name. Iterates doing local lookups of
 * subsequent components of a scoped name
 */
static AST_Decl *
iter_lookup_by_name_local(AST_Decl *d, UTL_ScopedName *e,
                          idl_bool treat_as_ref)
{
   Identifier *s;
   AST_Typedef *td;
   UTL_IdListActiveIterator *i;
   UTL_Scope *sc;

   i = new UTL_IdListActiveIterator(e);

   for (i->next(); !(i->is_done()); )
   {
      s = i->item();
      /*
       * Update iterator before loop. This is needed for the check for
       * typedef, since we only want to look at the base type if there
       * actually are more components of the name to resolve.
       */
      i->next();
      /*
       * Next component in name was not found
       */

      if (d == NULL)
      {
         return NULL;
      }

      /*
       * If this is a typedef and we're not done, we should get the
       * base type to get the scope it defines (if any)
       */
      if (!(i->is_done()))
      {
         while (d != NULL && d->node_type() == AST_Decl::NT_typedef)
         {
            td = AST_Typedef::narrow_from_decl(d);

            if (td == NULL)
               return NULL;

            d = td->base_type();
         }

         if (d == NULL)
            return NULL;
      }

      /*
       * Try to convert the AST_Decl to a UTL_Scope
       */
      sc = DeclAsScope(d);

      if (sc == NULL)
         return NULL;

      /*
       * Look up the next element
       */
      d = sc->lookup_by_name_local (s);
   }

   /*
    * OK, done with the loop
    */ 
   return d;
}
Beispiel #14
0
AST_Decl * UTL_Scope::lookup_primitive_type (AST_Expression::ExprType et)
{
   AST_Decl *as_decl;
   UTL_Scope *ancestor;
   AST_PredefinedType *t;
   UTL_ScopeActiveIterator *i;
   AST_PredefinedType::PredefinedType pdt = AST_PredefinedType::PT_unknown;

   as_decl = ScopeAsDecl (this);

   if (as_decl == NULL)
      return NULL;

   ancestor = as_decl->defined_in();

   if (ancestor != NULL)
      return ancestor->lookup_primitive_type(et);

   switch (et)
   {
      case AST_Expression::EV_short:
      pdt = AST_PredefinedType::PT_short;
      break;

      case AST_Expression::EV_ushort:
      pdt = AST_PredefinedType::PT_ushort;
      break;

      case AST_Expression::EV_long:
      pdt = AST_PredefinedType::PT_long;
      break;

      case AST_Expression::EV_ulong:
      pdt = AST_PredefinedType::PT_ulong;
      break;

      case AST_Expression::EV_longlong:
      pdt = AST_PredefinedType::PT_longlong;
      break;

      case AST_Expression::EV_ulonglong:
      pdt = AST_PredefinedType::PT_ulonglong;
      break;

      case AST_Expression::EV_float:
      pdt = AST_PredefinedType::PT_float;
      break;

      case AST_Expression::EV_double:
      pdt = AST_PredefinedType::PT_double;
      break;

      case AST_Expression::EV_longdouble:
      pdt = AST_PredefinedType::PT_longdouble;
      break;

      case AST_Expression::EV_char:
      pdt = AST_PredefinedType::PT_char;
      break;

      case AST_Expression::EV_wchar:
      pdt = AST_PredefinedType::PT_wchar;
      break;

      case AST_Expression::EV_octet:
      pdt = AST_PredefinedType::PT_octet;
      break;

      case AST_Expression::EV_bool:
      pdt = AST_PredefinedType::PT_boolean;
      break;

      case AST_Expression::EV_any:
      pdt = AST_PredefinedType::PT_any;
      break;

      case AST_Expression::EV_void:
      pdt = AST_PredefinedType::PT_void;
      break;

      case AST_Expression::EV_string:
      case AST_Expression::EV_wstring:
      case AST_Expression::EV_none:
      return NULL;
   }

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

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

      if (as_decl->node_type() == AST_Decl::NT_pre_defined)
      {
         t = AST_PredefinedType::narrow_from_decl(as_decl);

         if (t == NULL)
         {
            i->next();
            continue;
         }

         if (t->pt() == pdt)
         {
            delete i;
            return t;
         }
      }

      i->next();
   }

   delete i;
   return NULL;
}