本文整理汇总了C++中AST_Decl::defined_in方法的典型用法代码示例。如果您正苦于以下问题:C++ AST_Decl::defined_in方法的具体用法?C++ AST_Decl::defined_in怎么用?C++ AST_Decl::defined_in使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AST_Decl
的用法示例。
在下文中一共展示了AST_Decl::defined_in方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isRecursive
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;
}
示例2:
/*
* Add this AST_InterfaceFwd node (a forward declaration of an IDL
* interface) to this scope
*/
AST_InterfaceFwd * AST_Module::fe_add_interface_fwd (AST_InterfaceFwd * i)
{
AST_Decl * d = lookup_for_add (i);
AST_Interface * itf;
/*
* Already defined and cannot be redefined? Or already used?
*/
if (d)
{
if (d->node_type() == AST_Decl::NT_interface && d->defined_in() == this)
{
itf = AST_Interface::narrow_from_decl (d);
if (itf == 0)
{
return 0;
}
i->set_full_definition (itf);
return i;
}
if (!can_be_redefined (d))
{
idl_global->err()->error3(UTL_Error::EIDL_REDEF, i, this, d);
return NULL;
}
if (referenced (d))
{
idl_global->err()->error3(UTL_Error::EIDL_DEF_USE, i, this, d);
return NULL;
}
if (i->has_ancestor (d))
{
idl_global->err()->redefinition_in_scope(i, d);
return NULL;
}
}
/*
* Add it to scope
*/
add_to_scope (i);
/*
* Add it to set of locally referenced symbols
*/
add_to_referenced (i, false);
return i;
}
示例3:
AST_ValueFwd *AST_Module::fe_add_valuetype_fwd(AST_ValueFwd *v)
{
AST_Decl *d;
AST_Value *val;
/*
* Already defined and cannot be redefined? Or already used?
*/
if ((d = lookup_for_add (v)) != NULL)
{
if (d->node_type() == AST_Decl::NT_value && d->defined_in() == this)
{
val = AST_Value::narrow_from_decl(d);
if (val == NULL)
return NULL;
v->set_full_definition(val);
return v;
}
if (!can_be_redefined(d))
{
idl_global->err()->error3(UTL_Error::EIDL_REDEF, v, this, d);
return NULL;
}
if (referenced(d))
{
idl_global->err()->error3(UTL_Error::EIDL_DEF_USE, v, this, d);
return NULL;
}
if (v->has_ancestor(d))
{
idl_global->err()->redefinition_in_scope(v, d);
return NULL;
}
}
/*
* Add it to scope
*/
add_to_scope(v);
/*
* Add it to set of locally referenced symbols
*/
add_to_referenced(v, I_FALSE);
return v;
}
示例4: ScopeAsDecl
void
be_util::gen_nesting_close (TAO_OutStream &os, AST_Decl *node)
{
AST_Decl *d = ScopeAsDecl (node->defined_in ());
AST_Decl::NodeType nt = d->node_type ();
while (nt != AST_Decl::NT_root)
{
os << be_uidt_nl
<< "};";
d = ScopeAsDecl (d->defined_in ());
nt = d->node_type ();
}
}
示例5: while
AST_Template_Module *
FE_Utils::get_tm_container (AST_Decl *contained)
{
AST_Decl *d = contained;
while (d != 0)
{
AST_Template_Module *tm =
AST_Template_Module::narrow_from_decl (d);
if (tm != 0)
{
return tm;
}
d = ScopeAsDecl (d->defined_in ());
}
return 0;
}
示例6: name
UTL_ScopedName *
ast_visitor_reifying::template_module_rel_name (AST_Decl *d)
{
AST_Decl *tmp = d;
ACE_CString name (d->full_name ());
while (tmp != 0)
{
if (AST_Template_Module::narrow_from_decl (tmp) != 0)
{
ACE_CString head (tmp->local_name ()->get_string ());
ACE_CString::size_type start = name.find (head) + 2;
ACE_CString tail (name.substr (start + head.length ()));
return FE_Utils::string_to_scoped_name (tail.c_str ());
}
tmp = ScopeAsDecl (tmp->defined_in ());
}
return 0;
}
示例7: name
UTL_ScopedName *
be_visitor_xplicit_pre_proc::xplicit_iface_rel_name (AST_Decl *d)
{
AST_Decl *tmp = d;
ACE_CString name (d->full_name ());
while (tmp != 0)
{
if (be_home::narrow_from_decl (tmp) != 0)
{
ACE_CString head (tmp->local_name ()->get_string ());
ACE_CString::size_type start = name.find (head) + 2;
ACE_CString tail (name.substr (start + head.length ()));
return FE_Utils::string_to_scoped_name (tail.c_str ());
}
tmp = ScopeAsDecl (tmp->defined_in ());
}
return 0;
}
示例8: while
//.........这里部分代码省略.........
<< "{" << be_idt_nl
<< "return false;" << be_uidt_nl
<< "}";
*os << be_nl_2
<< "template<>" << be_nl
<< "::CORBA::Boolean" << be_nl
<< "Any_Impl_T<" << node->name ()
<< ">::demarshal_value (TAO_InputCDR &)" << be_nl
<< "{" << be_idt_nl
<< "return false;" << be_uidt_nl
<< "}" << be_uidt_nl
<< "}";
}
*os << be_global->core_versioning_end () << be_nl;
be_module *module = 0;
if (node->is_nested ())
{
AST_Decl *d = node;
AST_Decl::NodeType nt = d->node_type ();
while (nt != AST_Decl::NT_root)
{
if (nt == AST_Decl::NT_module)
{
module = be_module::narrow_from_decl (d);
break;
}
else
{
d = ScopeAsDecl (d->defined_in ());
nt = d->node_type ();
}
}
if (module != 0)
{
// Some compilers handle "any" operators in a namespace corresponding
// to their module, others do not.
*os << "\n\n#if defined (ACE_ANY_OPS_USE_NAMESPACE)\n";
be_util::gen_nested_namespace_begin (os, module);
// emit nested variation of any operators
*os << be_nl_2
<< "/// Copying insertion." << be_nl
<< "void" << be_nl
<< "operator<<= (" << be_idt << be_idt_nl
<< "::CORBA::Any &_tao_any," << be_nl
<< node->local_name () << "_ptr _tao_elem)" << be_uidt << be_uidt_nl
<< "{" << be_idt_nl
<< node->local_name () << "_ptr _tao_objptr =" << be_idt_nl
<< node->local_name () << "::_duplicate (_tao_elem);" << be_uidt_nl
<< "_tao_any <<= &_tao_objptr;" << be_uidt_nl
<< "}" << be_nl_2;
*os << "/// Non-copying insertion." << be_nl
<< "void" << be_nl
<< "operator<<= (" << be_idt << be_idt_nl
<< "::CORBA::Any &_tao_any," << be_nl
<< node->local_name () << "_ptr *_tao_elem)" << be_uidt << be_uidt_nl
<< "{" << be_idt_nl
<< "TAO::Any_Impl_T<" << node->local_name () << ">::insert ("
示例9: ctx
int
be_visitor_union_any_op_ch::visit_union (be_union *node)
{
if (node->cli_hdr_any_op_gen ()
|| node->imported ())
{
return 0;
}
TAO_OutStream *os = this->ctx_->stream ();
const char *macro = this->ctx_->export_macro ();
*os << be_nl_2 << "// TAO_IDL - Generated from" << be_nl
<< "// " << __FILE__ << ":" << __LINE__ << be_nl_2;
be_module *module = 0;
AST_Decl *decl = node;
if (decl->is_nested ())
{
if (node->defined_in ()->scope_node_type () == AST_Decl::NT_interface)
{
be_interface *intf = 0;
intf = be_interface::narrow_from_scope (node->defined_in ());
decl = intf;
}
if (decl->defined_in ()->scope_node_type () == AST_Decl::NT_module)
{
module = be_module::narrow_from_scope (decl->defined_in ());
if (!module)
{
ACE_ERROR_RETURN ((LM_ERROR,
"be_visitor_union_any_op_ch::"
"visit_union - "
"Error parsing nested name\n"),
-1);
}
// Some compilers handle "any" operators in a namespace
// corresponding to their module, others do not.
*os << "\n\n#if defined (ACE_ANY_OPS_USE_NAMESPACE)\n";
be_util::gen_nested_namespace_begin (os, module);
*os << macro << " void operator<<= (::CORBA::Any &, const ::" << node->name ()
<< " &); // copying version" << be_nl;
*os << macro << " void operator<<= (::CORBA::Any &, ::" << node->name ()
<< "*); // noncopying version" << be_nl;
*os << macro << " ::CORBA::Boolean operator>>= (const ::CORBA::Any &, ::"
<< node->name () << " *&); // deprecated\n";
*os << macro << " ::CORBA::Boolean operator>>= (const ::CORBA::Any &, const ::"
<< node->name () << " *&);";
be_util::gen_nested_namespace_end (os, module);
// Emit #else.
*os << be_nl_2
<< "#else\n\n";
}
}
*os << be_global->core_versioning_begin () << be_nl;
*os << macro << " void operator<<= (::CORBA::Any &, const " << node->name ()
<< " &); // copying version" << be_nl;
*os << macro << " void operator<<= (::CORBA::Any &, " << node->name ()
<< "*); // noncopying version" << be_nl;
*os << macro << " ::CORBA::Boolean operator>>= (const ::CORBA::Any &, "
<< node->name () << " *&); // deprecated\n";
*os << macro << " ::CORBA::Boolean operator>>= (const ::CORBA::Any &, const "
<< node->name () << " *&);";
*os << be_global->core_versioning_end () << be_nl;
if (module != 0)
{
*os << "\n\n#endif";
}
be_visitor_context ctx (*this->ctx_);
for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_localtypes);
!si.is_done ();
si.next ())
{
AST_Decl *d = si.item ();
be_enum *e = be_enum::narrow_from_decl (d);
if (e != 0)
{
be_visitor_enum_any_op_ch visitor (&ctx);
if (e->accept (&visitor) == -1)
{
ACE_ERROR ((LM_ERROR,
"(%N:%l) be_visitor_union_any_op_ch::visit_union"
" - codegen for enum failed\n"));
}
//.........这里部分代码省略.........
示例10: if
//.........这里部分代码省略.........
*os << be_nl_2
<< "template<>" << be_nl
<< "::CORBA::Boolean" << be_nl
<< "Any_Dual_Impl_T<" << node->name ()
<< ">::demarshal_value (TAO_InputCDR &)" << be_nl
<< "{" << be_idt_nl
<< "return false;" << be_uidt_nl
<< "}" << be_uidt_nl
<< "}" << be_nl;
}
*os << be_global->core_versioning_end () << be_nl;
// If this is non-zero, we want to call its tc_name()
// for the TypeCode to pass to the Any operator impls.
be_typedef *td = this->ctx_->tdef ();
be_module *module = 0;
if (node->is_nested ())
{
AST_Decl *d = node;
AST_Decl::NodeType nt = d->node_type ();
while (nt != AST_Decl::NT_root)
{
if (nt == AST_Decl::NT_module)
{
module = be_module::narrow_from_decl (d);
break;
}
else
{
d = ScopeAsDecl (d->defined_in ());
nt = d->node_type ();
}
}
if (module != 0)
{
// Some compilers handle "any" operators in a namespace
// corresponding to their module, others do not.
*os << "\n\n#if defined (ACE_ANY_OPS_USE_NAMESPACE)\n";
be_util::gen_nested_namespace_begin (os, module);
// Copying insertion.
*os << be_nl
<< "// Copying insertion." << be_nl
<< "void operator<<= (" << be_idt << be_idt_nl
<< "::CORBA::Any &_tao_any," << be_nl
<< "const ::" << node->name () << " &_tao_elem" << be_uidt_nl
<< ")" << be_uidt_nl
<< "{" << be_idt_nl
<< "TAO::Any_Dual_Impl_T< ::" << node->name () << ">::insert_copy ("
<< be_idt << be_idt_nl
<< "_tao_any," << be_nl
<< "::" << node->name () << "::_tao_any_destructor," << be_nl
<< "::" << (td != 0 ? td->tc_name () : node->tc_name ()) << "," << be_nl
<< "_tao_elem" << be_uidt_nl
<< ");" << be_uidt << be_uidt << be_uidt_nl
<< "}" << be_nl_2;
// Non-copying insertion.
*os << "// Non-copying insertion." << be_nl
示例11:
// Look up a branch in an enum which is the discriminator type for this
// union, based on the label value which must be an enumerator in that
// enum.
AST_UnionBranch *
AST_Union::lookup_enum (AST_UnionBranch *b)
{
AST_UnionLabel *label = b->label();
AST_Expression *lv = label->label_val ();
AST_Enum *e = AST_Enum::narrow_from_decl (this->pd_disc_type);
AST_Decl *d = 0;
AST_UnionBranch *fb = 0;
if (e == 0)
{
return 0;
}
if (lv == 0)
{
return b;
}
// Expecting a symbol label.
if (lv->ec () != AST_Expression::EC_symbol)
{
idl_global->err ()->enum_val_expected (this,
label);
return b;
}
// See if the symbol defines a constant in the discriminator enum.
UTL_ScopedName *sn = lv->n ();
d = e->lookup_by_name (sn,
true);
if (d == 0 || d->defined_in () != e)
{
idl_global->err ()->enum_val_lookup_failure (this,
e,
sn);
return b;
}
// OK, now see if this symbol is already used as the label of
// some other branch.
for (UTL_ScopeActiveIterator i (this, UTL_Scope::IK_decls);
!i.is_done();
i.next ())
{
d = i.item ();
if (d->node_type () == AST_Decl::NT_union_branch)
{
fb = AST_UnionBranch::narrow_from_decl (d);
if (fb == 0)
{
continue;
}
if (fb->label() != 0
&& fb->label ()->label_kind () == AST_UnionLabel::UL_label
&& fb->label ()->label_val ()->compare (lv))
{
idl_global->err ()->error2 (UTL_Error::EIDL_MULTIPLE_BRANCH,
this,
b);
return b;
}
}
}
return 0;
}
示例12: arg_flat_name
int
be_visitor_arg_traits::visit_argument (be_argument *node)
{
if (this->ctx_->alias () != 0 || this->generated (node))
{
return 0;
}
AST_Type *bt = node->field_type ();
AST_Decl::NodeType nt = bt->node_type ();
// We are interested here only in unaliased, bounded
// (w)strings.
if (nt != AST_Decl::NT_string && nt != AST_Decl::NT_wstring)
{
return 0;
}
be_string *st = be_string::narrow_from_decl (bt);
ACE_CDR::ULong bound = st->max_size ()->ev ()->u.ulval;
if (bound == 0)
{
return 0;
}
TAO_OutStream *os = this->ctx_->stream ();
*os << be_nl_2 << "// TAO_IDL - Generated from" << be_nl
<< "// " << __FILE__ << ":" << __LINE__;
std::string guard_suffix =
std::string (this->S_) + std::string ("arg_traits");
// The guard should be generated to prevent multiple declarations,
// since a bounded (w)string of the same length may be used or typedef'd
// more than once.
os->gen_ifdef_macro (node->flat_name (), guard_suffix.c_str (), false);
bool wide = (st->width () != 1);
// It is legal IDL to declare a bounded (w)string as an operation
// parameter type. There could be any number of identical
// declarations in the same build, translation unit, or even in
// the same operation, so we use the argument's flat name to
// declare an empty struct, and use that struct as the template
// parameter for Arg_Traits<>.
*os << be_nl_2;
AST_Decl *op = ScopeAsDecl (node->defined_in ());
AST_Decl *intf = ScopeAsDecl (op->defined_in ());
ACE_CString arg_flat_name (intf->flat_name ());
arg_flat_name += '_';
arg_flat_name += op->local_name ()->get_string ();
arg_flat_name += '_';
arg_flat_name += node->local_name ()->get_string ();
// Avoid generating a duplicate structure in the skeleton.
if (ACE_OS::strlen (this->S_) == 0)
{
*os << "struct " << arg_flat_name.c_str () << " {};"
<< be_nl_2;
}
*os << "template<>" << be_nl
<< "class "
<< this->S_ << "Arg_Traits<"
<< arg_flat_name.c_str ()
<< ">" << be_idt_nl
<< ": public" << be_idt << be_idt_nl
<< "BD_String_" << this->S_ << "Arg_Traits_T<" << be_nl
<< "CORBA::" << (wide ? "W" : "") << "String_var," << be_nl
<< bound << "," << be_nl
<< this->insert_policy()
<< be_uidt_nl
<< ">"
<< be_uidt << be_uidt << be_uidt_nl
<< "{" << be_nl
<< "};";
os->gen_endif ();
this->generated (node, true);
return 0;
}
示例13: ScopeAsDecl
/*
* 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.
//.........这里部分代码省略.........
示例14: while
int
be_visitor_interface_any_op_ch::visit_interface (be_interface *node)
{
if (node->cli_hdr_any_op_gen ()
|| node->imported ()
|| (node->is_local () && !be_global->gen_local_iface_anyops ()))
{
return 0;
}
TAO_OutStream *os = this->ctx_->stream ();
const char *macro = this->ctx_->export_macro ();
*os << be_nl_2;
*os << "// TAO_IDL - Generated from" << be_nl
<< "// " << __FILE__ << ":" << __LINE__;
*os << be_nl_2;
be_module *module = 0;
if (node->is_nested ())
{
AST_Decl *d = node;
AST_Decl::NodeType nt = d->node_type ();
while (nt != AST_Decl::NT_root)
{
if (nt == AST_Decl::NT_module)
{
module = be_module::narrow_from_decl (d);
break;
}
else
{
d = ScopeAsDecl (d->defined_in ());
nt = d->node_type ();
}
}
if (module != 0)
{
// Some compilers handle "any" operators in a namespace
// corresponding to their module, others do not.
*os << "\n\n#if defined (ACE_ANY_OPS_USE_NAMESPACE)\n";
be_util::gen_nested_namespace_begin (os, module);
// emit nested variation of any operators
*os << macro << " void"
<< " operator<<= ( ::CORBA::Any &, " << node->local_name ()
<< "_ptr); // copying" << be_nl;
*os << macro << " void"
<< " operator<<= ( ::CORBA::Any &, " << node->local_name ()
<< "_ptr *); // non-copying" << be_nl;
*os << macro << " ::CORBA::Boolean"
<< " operator>>= (const ::CORBA::Any &, "
<< node->local_name () << "_ptr &);";
be_util::gen_nested_namespace_end (os, module);
// Emit #else.
*os << be_nl_2
<< "#else\n\n";
}
}
*os << be_global->core_versioning_begin () << be_nl;
*os << macro << " void operator<<= (::CORBA::Any &, " << node->name ()
<< "_ptr); // copying" << be_nl;
*os << macro << " void operator<<= (::CORBA::Any &, " << node->name ()
<< "_ptr *); // non-copying" << be_nl;
*os << macro << " ::CORBA::Boolean operator>>= (const ::CORBA::Any &, "
<< node->name () << "_ptr &);";
*os << be_global->core_versioning_end () << be_nl;
if (module != 0)
{
*os << "\n\n#endif";
}
// All we have to do is to visit the scope and generate code.
if (this->visit_scope (node) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("be_visitor_interface_any_op_ch::")
ACE_TEXT ("visit_interface - ")
ACE_TEXT ("codegen for scope failed\n")),
-1);
}
node->cli_hdr_any_op_gen (1);
return 0;
}