void be_CodeGenerator::Generate(be_ClientImplementation& source) { UTL_ScopeActiveIterator* i; AST_Decl * d; UTL_Scope * s = (UTL_Scope*)narrow((long) & UTL_Scope::type_id); if (s) { i = new UTL_ScopeActiveIterator(s, UTL_Scope::IK_decls); while (!(i->is_done())) { be_CodeGenerator * cg; d = i->item(); if (!d->imported() && (cg = (be_CodeGenerator*)d->narrow((long) & be_CodeGenerator::type_id))) { cg->Generate(source); } i->next(); } delete i; } else { assert(pbfalse); } }
void be_root::GenerateGlobalDecls (be_ClientHeader & source) { UTL_ScopeActiveIterator * i; be_CodeGenerator * cg; AST_Decl * d; UTL_Scope * s = (UTL_Scope*) narrow ((long) & UTL_Scope::type_id); if (s) { // Iterate through decls i = new UTL_ScopeActiveIterator (s, UTL_Scope::IK_decls); while (!(i->is_done ())) { d = i->item (); if (!d->imported ()) { cg = (be_CodeGenerator*) d->narrow ((long) & be_CodeGenerator::type_id); if (cg) { cg->Generate (source); } } i->next (); } delete i; } }
// Compute the default index. int AST_Union::compute_default_index (void) { AST_Decl *d = 0; AST_UnionBranch *ub = 0; int i = 0; // If default case does not exist, it will have a value of -1 according to // the spec. this->default_index_ = -1; // If there are elements in this scope... if (this->nmembers () > 0) { // Instantiate a scope iterator. for (UTL_ScopeActiveIterator si (this, UTL_Scope::IK_decls); !si.is_done (); si.next ()) { // Get the next AST decl node. d = si.item (); // If an enum is declared in our scope, its members are // added to our scope as well, to detect clashes. if (d->node_type () == AST_Decl::NT_enum_val) { continue; } if (!d->imported ()) { ub = AST_UnionBranch::narrow_from_decl (d); for (unsigned long j = 0; j < ub->label_list_length (); ++j) { // Check if we are printing the default case. AST_UnionLabel::UnionLabel ulk = ub->label (j)->label_kind (); if (ulk == AST_UnionLabel::UL_default) { // Zero based indexing. this->default_index_ = i; } } // TAO's Typecode class keeps only a member count (not // a label count) so this increment has been moved // out of the inner loop. ++i; } } } return 0; }
int be_visitor_union_branch_cdr_op_cs::explicit_default (void) { be_union *bu = be_union::narrow_from_decl (this->ctx_->scope ()->decl ()); int def_index = bu->default_index (); if (def_index != -1) { be_union_branch *ub = be_union_branch::narrow_from_decl (this->ctx_->node ()); int i = 0; // Instantiate a scope iterator. for (UTL_ScopeActiveIterator si (bu, UTL_Scope::IK_decls); !si.is_done (); si.next ()) { be_union_branch *bub = 0; // union branch node AST_Decl *d = si.item (); if (!d->imported ()) { bub = be_union_branch::narrow_from_decl (d); } if (bub == ub) { return (i == def_index); } else { ++i; } } } return 0; }
void be_root::GenerateGlobalTypes (be_ClientHeader& source) { UTL_ScopeActiveIterator * i; be_CodeGenerator * cg; AST_Decl * d; be_Type * bt; DDS_StdString scope; UTL_Scope * s = (UTL_Scope*) narrow ((long) & UTL_Scope::type_id); if (s) { // Iterate through types i = new UTL_ScopeActiveIterator (s, UTL_Scope::IK_localtypes); while (! i->is_done ()) { d = i->item (); if (! d->imported ()) { cg = (be_CodeGenerator*) d->narrow ((long) & be_CodeGenerator::type_id); if (cg) { bt = (be_Type*) d->narrow ((long) & be_Type::type_id); scope = bt->EnclosingScope (); if (! bt->HasTypeDef () && scope == NULL) { cg->Generate (source); } } } i->next (); } delete i; } }
void be_structure::Generate (be_ClientImplementation & source) { UTL_ScopeActiveIterator * i; AST_Decl * d; UTL_Scope * s = (UTL_Scope*)narrow((long) & UTL_Scope::type_id); if (BE_Globals::ignore_interfaces && IsInterfaceDependant ()) { return; } if (s) { i = new UTL_ScopeActiveIterator(s, UTL_Scope::IK_localtypes); while (!(i->is_done())) { be_CodeGenerator * cg; d = i->item(); if (!d->imported() && (cg = (be_CodeGenerator*)d->narrow((long) & be_CodeGenerator::type_id))) { cg->Generate (source); } i->next(); } delete i; } else { assert(pbfalse); } }
void be_CodeGenerator::Generate(be_ClientHeader& source) { UTL_Scope* s = (UTL_Scope*)narrow((long) & UTL_Scope::type_id); assert(s); // ITERATE THROUGH DECLS UTL_ScopeActiveIterator iter(s, UTL_Scope::IK_both); while (!(iter.is_done())) { be_CodeGenerator* cg; AST_Decl* d = iter.item(); if (!d->imported() && (cg = (be_CodeGenerator*)d->narrow((long) & be_CodeGenerator::type_id))) { cg->Generate(source); } iter.next(); } }
// AST Dumping void UTL_Scope::dump(ostream &o) { UTL_ScopeActiveIterator *i; AST_Decl *d; if (idl_global->indent() == NULL) idl_global->set_indent(new UTL_Indenter()); idl_global->indent()->increase(); if (pd_locals_used > 0) { i = new UTL_ScopeActiveIterator(this, UTL_Scope::IK_localtypes); o << GTDEVEL("\n/* Current Pragma: */\n"); pd_pragmas.dump(o); o << GTDEVEL("\n/* Locally defined types: */\n"); while (!(i->is_done())) { d = i->item(); if (!d->imported()) { idl_global->indent()->skip_to(o); d->dump(o); o << "\n"; } i->next(); } delete i; } if (pd_decls_used > 0) { i = new UTL_ScopeActiveIterator(this, UTL_Scope::IK_decls); o << GTDEVEL("\n/* Declarations: */\n"); while (!(i->is_done())) { d = i->item(); if (!d->imported()) { idl_global->indent()->skip_to(o); d->dump(o); o << ";\n"; } i->next(); } delete i; } idl_global->indent()->decrease(); }