本文整理汇总了C++中AST_Expression::ev方法的典型用法代码示例。如果您正苦于以下问题:C++ AST_Expression::ev方法的具体用法?C++ AST_Expression::ev怎么用?C++ AST_Expression::ev使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AST_Expression
的用法示例。
在下文中一共展示了AST_Expression::ev方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: id
int
be_visitor_xplicit_pre_proc::visit_string (be_string *node)
{
if (this->ref_type_)
{
this->check_and_store (node);
return 0;
}
AST_Expression *b = node->max_size ();
if (b->ev ()->u.ulval == 0)
{
this->type_holder_ = node;
return 0;
}
AST_Expression *bound = 0;
ACE_NEW_RETURN (bound,
AST_Expression (b,
AST_Expression::EV_ulong),
-1);
Identifier id ("string");
UTL_ScopedName sn (&id, 0);
ACE_NEW_RETURN (this->type_holder_,
be_string (AST_Decl::NT_string,
&sn,
bound,
node->width ()),
-1);
return 0;
}
示例2: Bailout
void
AST_UnionBranch::add_labels (AST_Union *u)
{
for (UTL_LabellistActiveIterator i (this->pd_ll);
!i.is_done ();
i.next ())
{
if (AST_UnionLabel::UL_default == i.item ()->label_kind ())
{
return;
}
}
const bool enum_labels = (u->udisc_type () == AST_Expression::EV_enum);
for (UTL_LabellistActiveIterator i (this->pd_ll);
!i.is_done ();
i.next ())
{
AST_Expression *ex = i.item ()->label_val ();
UTL_ScopedName *n = ex->n ();
if (n)
{
u->add_to_name_referenced (n->first_component ());
}
// If we have enum val labels, we need to set the type and
// evaluate here, so the value will be available when the
// default index in calculated.
if (enum_labels)
{
ex->ev ()->et = AST_Expression::EV_enum;
AST_Enum *disc = AST_Enum::narrow_from_decl (u->disc_type ());
AST_EnumVal *dval = disc->lookup_by_value (ex);
if (dval == 0)
{
idl_global->err ()->incompatible_disc_error (disc, ex);
throw Bailout ();
}
ex->ev ()->u.eval = dval->constant_value ()->ev ()->u.ulval;
}
}
}
示例3:
// Look up a branch by label.
AST_UnionBranch *
AST_Union::lookup_label (AST_UnionBranch *b)
{
AST_UnionLabel *label = b->label ();
AST_Expression *lv = label->label_val ();
if (label->label_val () == 0)
{
return b;
}
AST_Decl *d = 0;
AST_UnionBranch *fb = 0;
lv->set_ev (lv->coerce (this->pd_udisc_type));
if (lv->ev () == 0)
{
idl_global->err ()->eval_error (lv);
return b;
}
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;
}
示例4: if
int
ast_visitor_reifying::visit_string (AST_String *node)
{
AST_Expression *b = node->max_size ();
AST_Param_Holder *ph = b->param_holder ();
if (ph != 0)
{
if (this->visit_param_holder (ph) != 0)
{
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("ast_visitor_reifying::")
ACE_TEXT ("visit_string - ")
ACE_TEXT ("visit_param_holder() ")
ACE_TEXT ("failed\n")),
-1);
}
AST_Constant *c =
AST_Constant::narrow_from_decl (this->reified_node_);
b = c->constant_value ();
}
else if (b->ev ()->u.ulval == 0)
{
this->reified_node_ = node;
return 0;
}
AST_Expression *bound = 0;
ACE_NEW_RETURN (bound,
AST_Expression (b,
AST_Expression::EV_ulong),
-1);
Identifier id ("string");
UTL_ScopedName sn (&id, 0);
ACE_NEW_RETURN (this->reified_node_,
AST_String (AST_Decl::NT_string,
&sn,
bound,
node->width ()),
-1);
return 0;
}
示例5: visit_array
//.........这里部分代码省略.........
-1);
}
*os << ", 0);" << be_nl;
*os << "return retval;" << be_uidt_nl;
*os << "}" << be_nl_2;
// free method.
*os << "void" << be_nl
<< fname << "_free (" << be_idt << be_idt_nl
<< fname << "_slice *_tao_slice)" << be_uidt
<< be_uidt_nl;
*os << "{" << be_idt_nl;
*os << "delete [] _tao_slice;" << be_uidt_nl;
*os << "}" << be_nl_2;
// copy method.
*os << "void" << be_nl;
*os << fname << "_copy (" << be_idt << be_idt_nl
<< fname << "_slice * _tao_to," << be_nl
<< "const " << fname << "_slice *_tao_from)" << be_uidt
<< be_uidt_nl;
*os << "{" << be_idt_nl;
*os << "// Copy each individual element." << be_nl;
ACE_CDR::ULong ndims = node->n_dims ();
// Generate nested loops for as many dimensions as there are.
for (i = 0; i < ndims; ++i)
{
// Retrieve the ith dimension value.
AST_Expression *expr = node->dims ()[i];
if ((expr == 0) || ((expr != 0) && (expr->ev () == 0)))
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_array_cs::"
"visit_array - "
"bad array dimension\n"),
-1);
}
if (expr->ev ()->et == AST_Expression::EV_ulong)
{
// Generate a loop for each dimension.
*os << "for ( ::CORBA::ULong i" << i << " = 0; i" << i << " < "
<< expr->ev ()->u.ulval << "; ++i" << i << ")" << be_idt_nl
<< "{" << be_idt_nl;
}
else
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_array_cs::"
"visit_array - "
"bad array dimension value\n"),
-1);
}
}
// Now generate code such that every element of the array gets assigned
// inside the innermost level of the nested loops generated above.
be_array *primitive_type = 0;
if (bt->node_type () == AST_Decl::NT_typedef)
{
// Base type of the array node is a typedef. We need to make sure that
示例6: visit_array
//.........这里部分代码省略.........
}
}
TAO_OutStream *os = this->ctx_->stream ();
*os << be_nl_2 << "// TAO_IDL - Generated from" << be_nl
<< "// " << __FILE__ << ":" << __LINE__;
// Generate the array traits specialization definitions,
// guarded by #ifdef on unaliased array element type and length.
ACE_CString unique;
if (nt == AST_Decl::NT_typedef)
{
be_typedef *td = be_typedef::narrow_from_decl (bt);
unique = td->primitive_base_type ()->flat_name ();
}
else
{
unique = bt->flat_name ();
}
char buf[NAMEBUFSIZE];
ACE_CDR::ULong i;
for (i = 0UL; i < node->n_dims (); ++i)
{
ACE_OS::memset (buf,
'\0',
NAMEBUFSIZE);
ACE_OS::sprintf (buf,
"_" ACE_UINT32_FORMAT_SPECIFIER_ASCII,
node->dims ()[i]->ev ()->u.ulval);
unique += buf;
}
unique += "_traits";
*os << be_nl_2
<< "ACE_INLINE" << be_nl
<< "void" << be_nl
<< "TAO::Array_Traits<" << fname << "_forany>::free ("
<< be_idt << be_idt_nl
<< fname << "_slice * _tao_slice" << be_uidt_nl
<< ")" << be_uidt_nl
<< "{" << be_idt_nl
<< fname << "_free (_tao_slice);" << be_uidt_nl
<< "}";
*os << be_nl_2
<< "ACE_INLINE" << be_nl
<< fname << "_slice *" << be_nl
<< "TAO::Array_Traits<" << fname << "_forany>::dup ("
<< be_idt << be_idt_nl
<< "const " << fname << "_slice * _tao_slice" << be_uidt_nl
<< ")" << be_uidt_nl
<< "{" << be_idt_nl
<< "return " << fname << "_dup (_tao_slice);" << be_uidt_nl
<< "}";
*os << be_nl_2
<< "ACE_INLINE" << be_nl
<< "void" << be_nl
<< "TAO::Array_Traits<" << fname << "_forany>::copy ("
<< be_idt << be_idt_nl
示例7: if
// Helper.
int
be_visitor_array_cdr_op_cs::visit_node (be_type *bt)
{
TAO_OutStream *os = this->ctx_->stream ();
ACE_CDR::ULong i;
be_array *node =
be_array::narrow_from_decl (this->ctx_->node ());
AST_Decl::NodeType nt = bt->node_type ();
if (node == 0)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_array_cdr_op_cs::"
"visit_node - "
"bad array node\n"),
-1);
}
// Initialize a boolean variable.
*os << "CORBA::Boolean _tao_marshal_flag = true;" << be_nl;
ACE_CDR::ULong ndims = node->n_dims ();
// We get here if the "type" of individual elements of the array is not a
// primitive type. In this case, we are left with no other alternative but to
// encode/decode element by element.
// generate nested loops for as many dimensions as there are
for (i = 0; i < ndims; ++i)
{
// Retrieve the ith dimension value.
AST_Expression *expr = node->dims ()[i];
if ((expr == 0) || ((expr != 0) && (expr->ev () == 0)))
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_array_cdr_op_cs::"
"visit_node - "
"bad array dimension\n"),
-1);
}
if (expr->ev ()->et == AST_Expression::EV_ulong)
{
// Generate a loop for each dimension.
*os << be_nl << "for ( ::CORBA::ULong i" << i
<< " = 0; i" << i << " < "
<< expr->ev ()->u.ulval << " && _tao_marshal_flag; ++i" << i
<< ")" << be_idt_nl
<< "{" << be_idt;
}
else
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_array_cdr_op_cs::"
"visit_node - "
"bad array dimension value\n"),
-1);
}
}
// @@ (JP) Need to factor out some of this into method call(s).
switch (this->ctx_->sub_state ())
{
case TAO_CodeGen::TAO_CDR_INPUT:
*os << be_nl;
// Handle the array of array case, where we need to pass the
// forany type.
if (nt == AST_Decl::NT_array)
{
*os << bt->name () << "_forany tmp ("
<< bt->name () << "_alloc ());" << be_nl;
*os << "_tao_marshal_flag = (strm >> tmp);" << be_nl;
*os << bt->name () << "_copy (_tao_array";
for (i = 0; i < ndims; ++i)
{
*os << "[i" << i << "]";
}
*os << ", tmp.in ());" << be_nl;
*os << bt->name () << "_free (tmp.inout ());";
}
else
{
be_string *str = 0;
if (bt->node_type () == AST_Decl::NT_string ||
bt->node_type () == AST_Decl::NT_wstring)
{
str = be_string::narrow_from_decl (bt);
if (!str)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_array_cdr_op_cs::"
"visit_node - "
"bad string node\n"),
-1);
}
//.........这里部分代码省略.........
示例8: switch
//.........这里部分代码省略.........
break;
case AST_PredefinedType::PT_ushort:
*os << "ACE_CDR::UShort";
break;
case AST_PredefinedType::PT_octet:
*os << "ACE_CDR::Octet";
break;
case AST_PredefinedType::PT_char:
*os << "ACE_CDR::Char";
break;
case AST_PredefinedType::PT_wchar:
*os << "ACE_CDR::WChar";
break;
case AST_PredefinedType::PT_float:
*os << "ACE_CDR::Float";
break;
case AST_PredefinedType::PT_double:
*os << "ACE_CDR::Double";
break;
case AST_PredefinedType::PT_longlong:
*os << "ACE_CDR::LongLong";
break;
case AST_PredefinedType::PT_ulonglong:
*os << "ACE_CDR::ULongLong";
break;
case AST_PredefinedType::PT_longdouble:
*os << "ACE_CDR::LongDouble";
break;
case AST_PredefinedType::PT_boolean:
*os << "ACE_CDR::Boolean";
break;
default:
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_array_cdr_op_cs::"
"visit_predefined_type - "
"bad primitive type for optimized code gen\n"),
-1);
}
// Handle special case to avoid compiler errors.
switch (this->ctx_->sub_state ())
{
case TAO_CodeGen::TAO_CDR_INPUT:
*os << " *> (_tao_array.out ())," << be_nl;
break;
case TAO_CodeGen::TAO_CDR_OUTPUT:
*os << " *> (_tao_array.in ())," << be_nl;
break;
default:
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_array_cdr_op_cs::"
"visit_predefined_type - "
"bad substate in context\n"),
-1);
}
unsigned long ndims = array->n_dims ();
// Generate a product of all the dimensions. This will be the total length
// of the "unfolded" single dimensional array.
for (i = 0; i < ndims; ++i)
{
// Retrieve the ith dimension value.
AST_Expression *expr = array->dims ()[i];
if ((expr == 0) || ((expr != 0) && (expr->ev () == 0)))
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_array_cdr_op_cs::"
"visit_predefined_type - "
"bad array dimension\n"),
-1);
}
if (i != 0)
{
// Do not generate the multiplication operator the first time in.
*os << "*";
}
if (expr->ev ()->et == AST_Expression::EV_ulong)
{
// Generate a loop for each dimension.
*os << expr->ev ()->u.ulval;
}
else
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_array_cdr_op_cs::"
"visit_predefined_type - "
"bad array dimension value\n"),
-1);
}
}
*os << ");" << be_uidt
<< be_uidt << be_uidt << be_uidt_nl;
return 0;
}
示例9: switch
//.........这里部分代码省略.........
for (UTL_ScopeActiveIterator si (this, UTL_Scope::IK_decls);
!si.is_done () && break_loop == 0;
si.next ())
{
// Get the next AST decl node
AST_UnionBranch *ub =
AST_UnionBranch::narrow_from_decl (si.item ());
if (ub != 0)
{
for (unsigned long i = 0;
i < ub->label_list_length () && !break_loop;
++i)
{
if (ub->label (i)->label_kind () == AST_UnionLabel::UL_label)
{
// Not a default.
AST_Expression *expr = ub->label (i)->label_val ();
if (expr == 0)
{
// Error.
this->default_value_.computed_ = -1;
ACE_ERROR_RETURN ((
LM_ERROR,
ACE_TEXT ("(%N:%l) AST_Union::")
ACE_TEXT ("compute_default_value - ")
ACE_TEXT ("Bad case label value\n")
),
-1
);
}
switch (expr->ev ()->et)
{
// Check if they match in which case this
// cannot be the implicit default value. So
// start with a new value and try the whole loop
// again because our case labels may not be sorted.
case AST_Expression::EV_short:
if (this->default_value_.u.short_val
== expr->ev ()->u.sval)
{
this->default_value_.u.short_val++;
break_loop = 1;
}
break;
case AST_Expression::EV_ushort:
if (this->default_value_.u.ushort_val
== expr->ev ()->u.usval)
{
this->default_value_.u.ushort_val++;
break_loop = 1;
}
break;
case AST_Expression::EV_long:
if (this->default_value_.u.long_val
== expr->ev ()->u.lval)
{
this->default_value_.u.long_val++;
break_loop = 1;
}
break;