本文整理汇总了C++中AST_Decl类的典型用法代码示例。如果您正苦于以下问题:C++ AST_Decl类的具体用法?C++ AST_Decl怎么用?C++ AST_Decl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AST_Decl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: that
void be_exception::GenerateAssignmentOperator (be_ClientImplementation& source)
{
ostream & os = source.Stream ();
DDS_StdString that ("");
be_Type * btype;
if (nmembers ())
{
that = " that";
}
os << ScopedName () << " & "
<< ScopedName () << "::operator = (const "
<< LocalName () << " &" << that << ")" << nl;
os << "{" << nl;
UTL_Scope * s = (UTL_Scope*)narrow((long) & UTL_Scope::type_id);
assert (s);
UTL_ScopeActiveIterator *it;
// Iterate through decls
for
(
it = new UTL_ScopeActiveIterator (s, UTL_Scope::IK_decls);
! it->is_done ();
it->next ()
)
{
AST_Decl * adecl = it->item ();
assert (adecl);
be_field *bfield = (be_field *) adecl->narrow ((long) & be_field::type_id);
if (bfield)
{
btype = bfield->get_be_type ();
if (btype && btype->IsArrayType ())
{
// Need to copy array elements
os << " "
<< (char*) BE_Globals::RelativeScope (ScopedName (), bfield->StructMemberTypeName ())
<< "_copy (" << bfield->get_local_name ()
<< ", that." << bfield->get_local_name () << ");" << nl;
}
else
{
os << " " << bfield->get_local_name () << " = that."
<< bfield->get_local_name() << ";" << nl;
}
}
}
delete it;
os << " return *this;" << nl;
os << "}" << nl << nl;
}
示例2: assert
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;
}
}
示例3: prefix
int
be_visitor_executor_exh::visit_provides (be_provides *node)
{
ACE_CString prefix (this->ctx_->port_prefix ());
prefix += node->local_name ()->get_string ();
const char *port_name = prefix.c_str ();
be_type *impl = node->provides_type ();
AST_Decl *scope = ScopeAsDecl (impl->defined_in ());
ACE_CString sname_str (scope->full_name ());
const char *sname = sname_str.c_str ();
// No '_cxx_' prefix.
const char *lname =
impl->original_local_name ()->get_string ();
const char *global = (sname_str == "" ? "" : "::");
os_ << be_nl_2
<< "/// Factory method and getter for " << port_name << " facet" << be_nl
<< "/// @return existing instance of facet if one exists, else creates one" << be_nl
<< "virtual " << global << sname << "::CCM_"
<< lname << "_ptr" << be_nl
<< "get_" << port_name << " (void);";
return 0;
}
示例4: GenerateGlobalDecls
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;
}
}
示例5: while
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);
}
}
示例6:
// Dump this AST_Factory node to the ostream o.
void
AST_Finder::dump (ACE_OSTREAM_TYPE &o)
{
AST_Decl *d = 0;
this->dump_i (o, "finder ");
this->local_name ()->dump (o);
this->dump_i (o, "(");
// Iterator must be explicitly advanced inside the loop.
for (UTL_ScopeActiveIterator i (this, IK_decls);
!i.is_done ();)
{
d = i.item ();
d->dump (o);
i.next ();
if (!i.is_done())
{
this->dump_i (o, ", ");
}
}
this->dump_i (o, ")");
}
示例7: assert
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;
}
示例8: si
int
idl2jni_visitor::visit_scope(UTL_Scope *node)
{
if (node->nmembers() > 0) {
UTL_ScopeActiveIterator si(node, UTL_Scope::IK_decls);
AST_Decl *d = 0;
while (!si.is_done()) {
d = si.item();
if (d == 0) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("(%N:%l) idl2jni_visitor::visit_")
ACE_TEXT("scope - bad node in this scope\n")), -1);
}
if (d->node_type() == AST_Decl::NT_pre_defined) {
si.next();
continue;
}
if (d->ast_accept(this) == -1) {
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT("(%N:%l) idl2jni_visitor::visit_")
ACE_TEXT("scope - failed to accept visitor\n")), -1);
}
si.next();
}
}
return 0;
}
示例9: AST_illegal_interface_recursion
bool
AST_illegal_interface_recursion (AST_Decl *t)
{
// Can't be 0 since we know we have an interface or valuetype.
AST_Decl *d = 0;
// If we encounter the argument in an enclosing scope, it's illegal.
for (UTL_ScopeStackActiveIterator i (idl_global->scopes ());
!i.is_done ();
i.next ())
{
d = ScopeAsDecl (i.item ());
// Exceptions cannot be recursive, but may contain a reference
// to the interface they are defined in.
if (d->node_type () == AST_Decl::NT_except)
{
return false;
}
if (d == t)
{
return true;
}
}
return false;
}
示例10:
int
ast_visitor_tmpl_module_inst::visit_scope (UTL_Scope *node)
{
for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
!si.is_done ();
si.next ())
{
AST_Decl *d = si.item ();
if (d == 0)
{
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("ast_visitor_tmpl_module_inst::")
ACE_TEXT ("visit_scope - ")
ACE_TEXT ("bad node in this scope\n")),
-1);
}
// Send the visitor.
if (d == 0 || d->ast_accept (this) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("ast_visitor_tmpl_module_inst::")
ACE_TEXT ("visit_scope - ")
ACE_TEXT ("codegen for scope failed\n")),
-1);
}
}
return 0;
}
示例11:
// Compute the size type of the node in question.
int
AST_Structure::compute_size_type (void)
{
for (UTL_ScopeActiveIterator si (this, UTL_Scope::IK_decls);
!si.is_done ();
si.next ())
{
// Get the next AST decl node.
AST_Decl *d = si.item ();
if (d->node_type () == AST_Decl::NT_enum_val)
{
continue;
}
AST_Field *f = AST_Field::narrow_from_decl (d);
AST_Type *t = f->field_type ();
if (t != 0)
{
this->size_type (t->size_type ());
// While we're iterating, we might as well do this one too.
this->has_constructor (t->has_constructor ());
}
else
{
ACE_DEBUG ((LM_DEBUG,
"WARNING (%N:%l) be_structure::compute_size_type - "
"narrow_from_decl returned 0\n"));
}
}
return 0;
}
示例12: assert
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;
}
示例13: COMMON_Base
be_argument::be_argument (AST_Argument::Direction d,
AST_Type *ft,
UTL_ScopedName *n)
: COMMON_Base (),
AST_Decl (AST_Decl::NT_argument,
n),
AST_Field (AST_Decl::NT_argument,
ft,
n),
AST_Argument (d,
ft,
n),
be_decl (AST_Decl::NT_argument,
n)
{
AST_Decl *dcl = ScopeAsDecl (this->defined_in ());
// If there have been previous errors, dcl may be 0,
// and we don't want to crash, so we check for non-zero.
// Also, we don't want to set the bit if the operation is
// declared in an included file UNLESS the enclosing
// interface is abstract, in which case we regenerate the
// operation.
if (dcl != 0
&& !dcl->is_local ()
&& (idl_global->in_main_file () || dcl->is_abstract ()))
{
be_type *bt = be_type::narrow_from_decl (ft);
bt->seen_in_operation (true);
be_util::set_arg_seen_bit (bt);
idl_global->need_skeleton_includes_ = true;
}
}
示例14:
// Look up the default branch in union.
AST_UnionBranch *
AST_Union::lookup_default (void)
{
AST_UnionBranch *b = 0;
AST_Decl *d = 0;
for (UTL_ScopeActiveIterator i (this, UTL_Scope::IK_both);
!i.is_done();
i.next ())
{
d = i.item ();
if (d->node_type () == AST_Decl::NT_union_branch)
{
b = AST_UnionBranch::narrow_from_decl (d);
if (b == 0)
{
continue;
}
if (b->label () != 0
&& b->label ()->label_kind () == AST_UnionLabel::UL_default)
{
idl_global->err ()->error2 (UTL_Error::EIDL_MULTIPLE_BRANCH,
this,
b);
return b;
}
}
}
return 0;
}
示例15: ScopeAsDecl
void
be_type::gen_fwd_helper_name (void)
{
AST_Decl *parent = ScopeAsDecl (this->defined_in ());
Identifier *segment = 0;
char *tmp = 0;
this->fwd_helper_name_.clear (true);
if (parent != 0 && parent->node_type () != AST_Decl::NT_root)
{
for (UTL_IdListActiveIterator i (parent->name ());
!i.is_done ();
i.next ())
{
segment = i.item ();
tmp = segment->get_string ();
if (ACE_OS::strcmp (tmp, "") == 0)
{
continue;
}
this->fwd_helper_name_ += tmp;
this->fwd_helper_name_ += "::";
}
}
else
{
this->fwd_helper_name_= "";
}
this->fwd_helper_name_ += "tao_";
this->fwd_helper_name_ += this->local_name ()->get_string ();
}