std::string idl_mapping_java::type(AST_Type *decl) { switch (decl->node_type()) { case AST_Decl::NT_pre_defined: { AST_PredefinedType *p = AST_PredefinedType::narrow_from_decl(decl); switch (p->pt()) { case AST_PredefinedType::PT_boolean: return "boolean"; case AST_PredefinedType::PT_char: case AST_PredefinedType::PT_wchar: return "char"; case AST_PredefinedType::PT_octet: return "byte"; case AST_PredefinedType::PT_short: case AST_PredefinedType::PT_ushort: return "short"; case AST_PredefinedType::PT_long: case AST_PredefinedType::PT_ulong: return "int"; case AST_PredefinedType::PT_longlong: case AST_PredefinedType::PT_ulonglong: return "long"; case AST_PredefinedType::PT_float: return "float"; case AST_PredefinedType::PT_double: return "double"; default: ;//fall through } } case AST_Decl::NT_string: return "String"; case AST_Decl::NT_enum: case AST_Decl::NT_interface: case AST_Decl::NT_interface_fwd: case AST_Decl::NT_native: case AST_Decl::NT_union: case AST_Decl::NT_struct: case AST_Decl::NT_struct_fwd: return scoped(decl->name()); case AST_Decl::NT_typedef: { AST_Typedef *td = AST_Typedef::narrow_from_decl(decl); return type(td->primitive_base_type()); } case AST_Decl::NT_sequence: { AST_Sequence *seq = AST_Sequence::narrow_from_decl(decl); return type(seq->base_type()) + "[]"; } case AST_Decl::NT_array: { AST_Array *arr = AST_Array::narrow_from_decl(decl); return type(arr->base_type()) + "[]"; } default: ;//fall through } cerr << "ERROR - unknown Java type " << decl->node_type() << " for IDL type: " << decl->local_name()->get_string() << endl; return "**unknown**"; }
int be_visitor_array::visit_typedef (be_typedef *node) { TAO_OutStream *os = this->ctx_->stream (); AST_Type *pbt = node->primitive_base_type (); AST_Decl::NodeType nt = pbt->node_type (); AST_PredefinedType::PredefinedType pt = AST_PredefinedType:: PT_void; int result = 0; // We check for these first, because in these cases, we replace the // entire slice type with one of the strings below, instead of using // the node's type name, possibly suffixed with '_var'. if (nt == AST_Decl::NT_string) { *os << "::TAO::String_Manager"; return 0; } else if (nt == AST_Decl::NT_wstring) { *os << "::TAO::WString_Manager"; return 0; } result = this->visit_node (node); if (nt == AST_Decl::NT_pre_defined) { AST_PredefinedType *pdt = AST_PredefinedType::narrow_from_decl (pbt); pt = pdt->pt (); } // We must append a "_var" for typedefs of interfaces, CORBA::Objects or // typecodes. if (nt == AST_Decl::NT_interface || nt == AST_Decl::NT_interface_fwd || pt == AST_PredefinedType::PT_pseudo || pt == AST_PredefinedType::PT_object) { *os << "_var"; } return result; }
AST_Operation::AST_Operation (AST_Type *rt, Flags fl, UTL_ScopedName *n, bool local, bool abstract) : COMMON_Base (local, abstract), AST_Decl(AST_Decl::NT_op, n), UTL_Scope(AST_Decl::NT_op), pd_return_type (rt), pd_flags (fl), pd_context (0), pd_exceptions (0), argument_count_ (-1), has_in_arguments_ (false), has_native_ (0) { AST_PredefinedType *pdt = 0; // Check that if the operation is oneway, the return type must be void. if (rt != 0 && pd_flags == OP_oneway) { if (rt->node_type () != AST_Decl::NT_pre_defined) { idl_global->err ()->error1 (UTL_Error::EIDL_NONVOID_ONEWAY, this); } else { pdt = AST_PredefinedType::narrow_from_decl (rt); if (pdt == 0 || pdt->pt () != AST_PredefinedType::PT_void) { idl_global->err ()->error1 (UTL_Error::EIDL_NONVOID_ONEWAY, this); } } } }
void be_util::set_arg_seen_bit (be_type *bt) { if (bt == 0) { return; } switch (bt->node_type ()) { case AST_Decl::NT_typedef: { AST_Typedef *td = AST_Typedef::narrow_from_decl (bt); be_util::set_arg_seen_bit ( be_type::narrow_from_decl (td->primitive_base_type ()) ); break; } case AST_Decl::NT_interface: case AST_Decl::NT_interface_fwd: case AST_Decl::NT_valuetype: case AST_Decl::NT_valuetype_fwd: case AST_Decl::NT_component: case AST_Decl::NT_component_fwd: case AST_Decl::NT_home: case AST_Decl::NT_eventtype: case AST_Decl::NT_eventtype_fwd: idl_global->object_arg_seen_ = true; break; case AST_Decl::NT_union: case AST_Decl::NT_struct: if (bt->size_type () == AST_Type::FIXED) { idl_global->fixed_size_decl_seen_ = true; } else { idl_global->var_size_decl_seen_ = true; } break; case AST_Decl::NT_struct_fwd: case AST_Decl::NT_union_fwd: { AST_StructureFwd *fwd = AST_StructureFwd::narrow_from_decl (bt); be_type *fd = be_type::narrow_from_decl (fwd->full_definition ()); be_util::set_arg_seen_bit (fd); break; } case AST_Decl::NT_enum: case AST_Decl::NT_enum_val: // idl_global->basic_arg_seen_ = true; break; case AST_Decl::NT_string: case AST_Decl::NT_wstring: { AST_String *str = AST_String::narrow_from_decl (bt); if (str->max_size ()->ev ()->u.ulval == 0) { idl_global->ub_string_seen_ = true; } else { idl_global->bd_string_seen_ = true; } break; } case AST_Decl::NT_array: if (bt->size_type () == AST_Type::FIXED) { idl_global->fixed_array_decl_seen_ = true; } else { idl_global->var_array_decl_seen_ = true; } break; case AST_Decl::NT_sequence: idl_global->var_size_decl_seen_ = true; break; case AST_Decl::NT_pre_defined: { AST_PredefinedType *pdt = AST_PredefinedType::narrow_from_decl (bt); switch (pdt->pt ()) { case AST_PredefinedType::PT_object: case AST_PredefinedType::PT_pseudo: case AST_PredefinedType::PT_value: case AST_PredefinedType::PT_abstract: idl_global->object_arg_seen_ = true; break; case AST_PredefinedType::PT_any: idl_global->var_size_decl_seen_ = true; idl_global->any_arg_seen_ = true; break; case AST_PredefinedType::PT_char: case AST_PredefinedType::PT_wchar: case AST_PredefinedType::PT_octet: case AST_PredefinedType::PT_boolean: idl_global->special_basic_decl_seen_ = true; break; default: break; } } default: break; } }
AST_Union::AST_Union (AST_ConcreteType *dt, UTL_ScopedName *n, bool local, bool abstract) : COMMON_Base (local, abstract), AST_Decl (AST_Decl::NT_union, n), AST_Type (AST_Decl::NT_union, n), AST_ConcreteType (AST_Decl::NT_union, n), UTL_Scope (AST_Decl::NT_union), AST_Structure (n, local, abstract), default_index_ (-2) { this->default_value_.computed_ = -2; AST_PredefinedType *pdt = 0; if (dt == 0) { this->pd_disc_type = 0; this->pd_udisc_type = AST_Expression::EV_none; return; } // If the discriminator type is a predefined type // then install the equivalent coercion target type in // the pd_udisc_type field. if (dt->node_type () == AST_Decl::NT_pre_defined) { pdt = AST_PredefinedType::narrow_from_decl (dt); if (pdt == 0) { this->pd_disc_type = 0; this->pd_udisc_type = AST_Expression::EV_none; return; } pd_disc_type = dt; switch (pdt->pt ()) { case AST_PredefinedType::PT_long: this->pd_udisc_type = AST_Expression::EV_long; break; case AST_PredefinedType::PT_ulong: this->pd_udisc_type = AST_Expression::EV_ulong; break; case AST_PredefinedType::PT_longlong: this->pd_udisc_type = AST_Expression::EV_longlong; break; case AST_PredefinedType::PT_ulonglong: this->pd_udisc_type = AST_Expression::EV_ulonglong; break; case AST_PredefinedType::PT_short: this->pd_udisc_type = AST_Expression::EV_short; break; case AST_PredefinedType::PT_ushort: this->pd_udisc_type = AST_Expression::EV_ushort; break; case AST_PredefinedType::PT_char: this->pd_udisc_type = AST_Expression::EV_char; break; case AST_PredefinedType::PT_wchar: this->pd_udisc_type = AST_Expression::EV_wchar; break; case AST_PredefinedType::PT_octet: this->pd_udisc_type = AST_Expression::EV_octet; break; case AST_PredefinedType::PT_boolean: this->pd_udisc_type = AST_Expression::EV_bool; break; default: this->pd_udisc_type = AST_Expression::EV_none; this->pd_disc_type = 0; break; } } else if (dt->node_type () == AST_Decl::NT_enum) { this->pd_udisc_type = AST_Expression::EV_enum; this->pd_disc_type = dt; } else { this->pd_udisc_type = AST_Expression::EV_none; this->pd_disc_type = 0; } if (this->pd_disc_type == 0) { idl_global->err ()->error2 (UTL_Error::EIDL_DISC_TYPE, this, dt); } }
bool be_union::gen_empty_default_label (void) { // A non-empty explicit default label will be generated. if (this->default_index () != -1) { return false; } AST_ConcreteType *disc = this->disc_type (); if (disc == 0) { return true; // In reality this is an error. } AST_Decl::NodeType nt = disc->node_type (); ACE_UINT64 n_labels = this->nlabels (); if (nt == AST_Decl::NT_enum) { // Enums in CORBA are always 32bits in size, so unless // there are that many enum labels in the set, it is // incomplete (reguardless as to the actual member_count). return (n_labels <= ACE_UINT32_MAX); } AST_PredefinedType *pdt = AST_PredefinedType::narrow_from_decl (disc); if (pdt == 0) { return true; // In reality this is an error. } switch (pdt->pt ()) { case AST_PredefinedType::PT_boolean: return (n_labels < 2); case AST_PredefinedType::PT_char: return (n_labels <= ACE_OCTET_MAX); case AST_PredefinedType::PT_short: case AST_PredefinedType::PT_ushort: return (n_labels <= ACE_UINT16_MAX); case AST_PredefinedType::PT_long: case AST_PredefinedType::PT_ulong: return (n_labels <= ACE_UINT32_MAX); case AST_PredefinedType::PT_longlong: case AST_PredefinedType::PT_ulonglong: // We would wrap to 0 here - we are using a 64 bit count // this case is so marginal as to always be incomplete. return true; // Keep fussy compilers happy. default: break; } return true; }
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; }