utl_scope.cpp
来自「这是广泛使用的通信开源项目,对于大容量,高并发的通讯要求完全能够胜任,他广泛可用」· C++ 代码 · 共 2,436 行 · 第 1/4 页
CPP
2,436 行
UTL_Scope::add_attribute (AST_Attribute *a)
{
if (a == 0)
{
return 0;
}
a->set_added (I_TRUE);
if (!a->field_type ()->added ())
{
return add_type (a->field_type ()) ? a : 0;
}
else
{
return a;
}
}
AST_Operation *
UTL_Scope::add_operation (AST_Operation *o)
{
if (o == 0)
{
return 0;
}
o->set_added (I_TRUE);
if (!o->return_type ()->added ())
{
return add_type (o->return_type ()) ? o : 0;
}
else
{
return o;
}
}
AST_Argument *
UTL_Scope::add_argument (AST_Argument *a)
{
if (a == 0)
{
return 0;
}
a->set_added (I_TRUE);
if (!a->field_type ()->added ())
{
return add_type (a->field_type ()) ? a : 0;
}
else
{
return a;
}
}
AST_Union *
UTL_Scope::add_union (AST_Union *u)
{
if (u == 0)
{
return 0;
}
u->set_added (I_TRUE);
return u;
}
AST_UnionFwd *
UTL_Scope::add_union_fwd (AST_UnionFwd *u)
{
if (u == 0)
{
return 0;
}
u->set_added (I_TRUE);
return u;
}
AST_UnionBranch *
UTL_Scope::add_union_branch (AST_UnionBranch *u)
{
if (u == 0)
{
return 0;
}
u->set_added (I_TRUE);
if (!u->field_type ()->added ())
{
return add_type (u->field_type ()) ? u : 0;
}
else
{
return u;
}
}
AST_Structure *
UTL_Scope::add_structure (AST_Structure *s)
{
if (s == 0)
{
return 0;
}
s->set_added (I_TRUE);
return s;
}
AST_StructureFwd *
UTL_Scope::add_structure_fwd (AST_StructureFwd *s)
{
if (s == 0)
{
return 0;
}
s->set_added (I_TRUE);
return s;
}
AST_Field *
UTL_Scope::add_field (AST_Field *f)
{
if (f == 0)
{
return 0;
}
f->set_added (I_TRUE);
if (!f->field_type ()->added ())
{
return add_type (f->field_type ()) ? f : 0;
}
else
{
return f;
}
}
AST_Enum *
UTL_Scope::add_enum (AST_Enum *e)
{
if (e == 0)
{
return 0;
}
e->set_added (I_TRUE);
return e;
}
AST_EnumVal *
UTL_Scope::add_enum_val (AST_EnumVal *e)
{
if (e == 0)
{
return 0;
}
e->set_added (I_TRUE);
return e;
}
AST_Typedef *
UTL_Scope::add_typedef (AST_Typedef *t)
{
if (t == 0)
{
return 0;
}
t->set_added (I_TRUE);
if (!t->base_type ()->added ())
{
return add_type (t->base_type ()) ? t : 0;
}
else
{
return t;
}
}
AST_Sequence *
UTL_Scope::add_sequence (AST_Sequence *s)
{
if (s == 0)
{
return 0;
}
s->set_added (I_TRUE);
if (!s->base_type ()->added ())
{
return add_type (s->base_type ()) ? s : 0;
}
else
{
return s;
}
}
AST_String *
UTL_Scope::add_string (AST_String *s)
{
if (s == 0)
{
return 0;
}
s->set_added (I_TRUE);
return s;
}
AST_Array *
UTL_Scope::add_array (AST_Array *a)
{
if (a == 0)
{
return 0;
}
a->set_added (I_TRUE);
if (!a->base_type ()->added ())
{
return add_type (a->base_type ()) ? a : 0;
}
else
{
return a;
}
}
AST_Native *
UTL_Scope::add_native (AST_Native *n)
{
if (n == 0)
{
return 0;
}
n->set_added (I_TRUE);
return n;
}
AST_Factory *
UTL_Scope::add_factory (AST_Factory *f)
{
//We don't invite any new types so there is nothing actually to add
if (f == 0)
{
return 0;
}
f->set_added (I_TRUE);
return f;
}
// Protected Front End Scope Management Protocol.
//
// All members of the protocol defined in UTL_Scope simply return NULL
// and don't do a thing. This ensures that runtime errors will discover
// operations which should have been redefined to allow certain kinds of
// AST nodes to appear in a given context.
AST_PredefinedType *
UTL_Scope::fe_add_predefined_type (AST_PredefinedType *)
{
return 0;
}
AST_Module *
UTL_Scope::fe_add_module (AST_Module *)
{
return 0;
}
AST_Interface *
UTL_Scope::fe_add_interface (AST_Interface *)
{
return 0;
}
AST_InterfaceFwd *
UTL_Scope::fe_add_interface_fwd (AST_InterfaceFwd *)
{
return 0;
}
AST_ValueType *
UTL_Scope::fe_add_valuetype (AST_ValueType *)
{
return 0;
}
AST_ValueTypeFwd *
UTL_Scope::fe_add_valuetype_fwd (AST_ValueTypeFwd *)
{
return 0;
}
AST_EventType *
UTL_Scope::fe_add_eventtype (AST_EventType *)
{
return 0;
}
AST_EventTypeFwd *
UTL_Scope::fe_add_eventtype_fwd (AST_EventTypeFwd *)
{
return 0;
}
AST_Component *
UTL_Scope::fe_add_component (AST_Component *)
{
return 0;
}
AST_ComponentFwd *
UTL_Scope::fe_add_component_fwd (AST_ComponentFwd *)
{
return 0;
}
AST_Home *
UTL_Scope::fe_add_home (AST_Home *)
{
return 0;
}
AST_Exception *
UTL_Scope::fe_add_exception (AST_Exception *)
{
return 0;
}
AST_Constant *
UTL_Scope::fe_add_constant (AST_Constant *)
{
return 0;
}
UTL_StrList *
UTL_Scope::fe_add_context (UTL_StrList *)
{
return 0;
}
UTL_NameList *
UTL_Scope::fe_add_exceptions (UTL_NameList *)
{
return 0;
}
AST_Attribute *
UTL_Scope::fe_add_attribute (AST_Attribute *)
{
return 0;
}
AST_Operation *
UTL_Scope::fe_add_operation (AST_Operation *)
{
return 0;
}
AST_Argument *
UTL_Scope::fe_add_argument (AST_Argument *)
{
return 0;
}
AST_Union *
UTL_Scope::fe_add_union (AST_Union *)
{
return 0;
}
AST_UnionFwd *
UTL_Scope::fe_add_union_fwd (AST_UnionFwd *)
{
return 0;
}
AST_UnionBranch *
UTL_Scope::fe_add_union_branch (AST_UnionBranch *)
{
return 0;
}
AST_Structure *
UTL_Scope::fe_add_structure (AST_Structure *)
{
return 0;
}
AST_StructureFwd *
UTL_Scope::fe_add_structure_fwd (AST_StructureFwd *)
{
return 0;
}
AST_Field *
UTL_Scope::fe_add_field (AST_Field *)
{
return 0;
}
AST_Enum *
UTL_Scope::fe_add_enum (AST_Enum *)
{
return 0;
}
AST_EnumVal *
UTL_Scope::fe_add_enum_val (AST_EnumVal *)
{
return 0;
}
AST_Typedef *
UTL_Scope::fe_add_typedef (AST_Typedef *)
{
return 0;
}
AST_Sequence *
UTL_Scope::fe_add_sequence (AST_Sequence *)
{
return 0;
}
AST_String *
UTL_Scope::fe_add_string (AST_String *)
{
return 0;
}
AST_Array *
UTL_Scope::fe_add_array (AST_Array *)
{
return 0;
}
AST_Native *
UTL_Scope::fe_add_native (AST_Native *)
{
return 0;
}
AST_Factory *
UTL_Scope::fe_add_factory (AST_Factory *)
{
return 0;
}
// This is the second pass of the front end
// It calls the public add protocol on everything in scope.
// It calls the add_xx functions of the most derived AST_Node.
AST_Decl *
UTL_Scope::call_add (void)
{
AST_Decl *result = 0;
AST_Decl *decl = 0;
UTL_ScopeActiveIterator i (this,
UTL_Scope::IK_decls);
UTL_Scope *scope = 0;
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_native:
result = add_native (AST_Native::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:
case AST_Decl::NT_wstring:
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_factory:
result = add_factory (AST_Factory::narrow_from_decl (decl));
scope = AST_Factory::narrow_from_decl (decl);
break;
default:
return 0;
}
if (scope != 0)
{
scope->call_add ();
}
i.next ();
}
return result;
}
// Private lookup mechanism.
// For dealing with lookups of 'Object' and 'TypeCode'.
AST_Decl *
UTL_Scope::lookup_pseudo (Identifier *e)
{
if (e->escaped ())
{
return 0;
}
Identifier *item_name = 0;
AST_Decl *d = 0;
UTL_ScopeActiveIterator *i = 0;
char *name_string = e->get_string ();
idl_bool tc_lookup = I_FALSE;
idl_bool obj_lookup = I_FALSE;
idl_bool vb_lookup = I_FALSE;
if (ACE_OS::strcasecmp (name_string, "Object") == 0)
{
obj_lookup = I_TRUE;
}
else if (ACE_OS::strcasecmp (name_string, "ValueBase") == 0)
{
vb_lookup = I_TRUE;
}
if (obj_lookup || vb_lookup)
{
// Iterate over the global scope.
ACE_NEW_RETURN (i,
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?