当前位置: 首页>>代码示例>>C++>>正文


C++ AST_Expression类代码示例

本文整理汇总了C++中AST_Expression的典型用法代码示例。如果您正苦于以下问题:C++ AST_Expression类的具体用法?C++ AST_Expression怎么用?C++ AST_Expression使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了AST_Expression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ACE_NEW_RETURN

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;
}
开发者ID:CCJY,项目名称:ATCD,代码行数:35,代码来源:be_visitor_xplicit_pre_proc.cpp

示例2: constant_value

unsigned long be_enum_val::Value ()
{
   AST_Expression * enumExpr;
   AST_Expression::AST_ExprValue * exprValue;

   enumExpr = constant_value ();
   if (enumExpr)
   {
      exprValue = enumExpr->eval (AST_Expression::EK_positive_int);
      if (exprValue)
      {
         assert (exprValue->et == AST_Expression::EV_ulong);
         return exprValue->u.eval;
      }
      else
      {
         assert(pbfalse);
      }
   }
   else
   {
      assert(pbfalse);
   }

   return 0;
}
开发者ID:osrf,项目名称:opensplice,代码行数:26,代码来源:xbe_enum.cpp

示例3:

int
be_union_branch::gen_label_value (TAO_OutStream *os, unsigned long index)
{
  AST_Expression *e = this->label (index)->label_val ();

  if (e->ec () != AST_Expression::EC_symbol)
    {
      // Easy, just a number...
      *os << e;
      return 0;
    }

  // If the enum is not in the global scope we have to prefix it.
  be_union *u =
    be_union::narrow_from_scope (this->defined_in ());

  if (u == 0)
    {
      return -1;
    }

  be_type* dt =
    be_type::narrow_from_decl (u->disc_type ());

  if (dt == 0)
    {
      return -1;
    }

  // Check if discriminator is a typedef of an integer. If so, and the
  // first IF block in this function didn't catch it, then we
  // are a constant of this type. We can't generate the constant's name,
  // we must generate the underlying integer value for the
  // label value.
  if (dt->node_type () == AST_Decl::NT_pre_defined)
    {
      *os << e;
      return 0;
    }

  // Find where was the enum defined, if it was defined in the globa
  // scope, then it is easy to generate the enum values....
  be_scope* scope =
    be_scope::narrow_from_scope (dt->defined_in ());

  if (scope == 0)
    {
      *os << e->n ();
      return 0;
    }

  // But if it was generated inside a module or something similar then
  // we must prefix the enum value with something...
  be_decl* decl = scope->decl ();

  *os << decl->full_name () << "::" << e->n ()->last_component ();

  return 0;
}
开发者ID:DOCGroup,项目名称:ACE_TAO,代码行数:59,代码来源:be_union_branch.cpp

示例4: ACE_ERROR_RETURN

int
ast_visitor_reifying::visit_sequence (AST_Sequence *node)
{
  AST_Type *bt = node->base_type ();

  if (bt->ast_accept (this) != 0)
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                         ACE_TEXT ("ast_visitor_reifying::")
                         ACE_TEXT ("visit_sequence - ")
                         ACE_TEXT ("visit of base type failed\n")),
                        -1);
    }

  bt = AST_Type::narrow_from_decl (this->reified_node_);

  AST_Expression *v = node->max_size ();
  AST_Param_Holder *ph = v->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_sequence - ")
                             ACE_TEXT ("visit_param_holder() ")
                             ACE_TEXT ("failed\n")),
                            -1);
        }

      AST_Constant *c =
        AST_Constant::narrow_from_decl (this->reified_node_);

      v = c->constant_value ();
    }

  AST_Expression *bound =
    idl_global->gen ()->create_expr (v,
                                     AST_Expression::EV_ulong);
  Identifier id ("sequence");
  UTL_ScopedName sn (&id, 0);

  this->reified_node_ =
    idl_global->gen ()->create_sequence (bound,
                                         bt,
                                         &sn,
                                         false,
                                         false);

  // No need to add this new node to any scope - it's anonymous
  // and owned by the node that references it.

  return 0;
}
开发者ID:CCJY,项目名称:ATCD,代码行数:55,代码来源:ast_visitor_reifying.cpp

示例5: eval_binary_exp_exp_test

void eval_binary_exp_exp_test()
{
  AST_Expression_Integer intExp =  (AST_Expression_Integer) newAST_Expression_Integer(2);
  AST_Expression_Integer intExp2 = (AST_Expression_Integer) newAST_Expression_Integer(3);
  AST_Expression_BinOp binOp = (AST_Expression_BinOp) newAST_Expression_BinOp(intExp, intExp2, BINOPEXP);

  EvalExp *evalExp = new EvalExp(NULL);
  AST_Expression result = evalExp->eval(binOp);

  BOOST_CHECK(result->expressionType() == EXPINTEGER);
  BOOST_CHECK(result->getAsInteger()->val() == 8);
}
开发者ID:RexFuzzle,项目名称:ModelicaCC,代码行数:12,代码来源:EvalExpTest.cpp

示例6:

// 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;
}
开发者ID:CCJY,项目名称:ATCD,代码行数:52,代码来源:ast_union.cpp

示例7:

void
AST_UnionBranch::coerce_labels (AST_Union *u)
{
  for (unsigned long i = 0; i < this->label_list_length (); ++i)
    {
      AST_UnionLabel *ul = this->label (i);

      if (ul->label_kind () == AST_UnionLabel::UL_default)
        {
          continue;
        }

      AST_Expression *lv = ul->label_val ();
      lv->set_ev (lv->coerce (u->udisc_type ()));
    }
}
开发者ID:asdlei00,项目名称:ACE,代码行数:16,代码来源:ast_union_branch.cpp

示例8: 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;
        }
    }
}
开发者ID:asdlei00,项目名称:ACE,代码行数:46,代码来源:ast_union_branch.cpp

示例9: next

AST_Real BraceIterator::next() {
  AST_Expression exp = *_braceExpElementsIter;
  AST_Real value;
  switch (exp->expressionType()){
  case EXPINTEGER:
    value = exp->getAsInteger()->val();
    break;
  case EXPREAL:
    value = (int)exp->getAsReal()->val();
    break;
  default:
    ERROR("BraceIterator::next():\n"
        "Incorrect brace expression element's type.");
  }
  _braceExpElementsIter++;
  return value;
}
开发者ID:lucciano,项目名称:modelica-cc,代码行数:17,代码来源:for_index_iterator.cpp

示例10: find_identifiers

void find_identifiers(AST_Expression &exp, IdMap &idmap) {
    switch(exp.getType()) {
        case AST_BEXP:  find_identifiers((AST_BinaryExpression&)exp, idmap); break;
        case AST_UEXP:  find_identifiers((AST_UnaryExpression&)exp,  idmap); break;
        case AST_ID:    find_identifiers((AST_Identifier&)exp,       idmap); break;
        default: std::cout << "Error?" << std::endl;
    }
}
开发者ID:fumyuun,项目名称:pfpga,代码行数:8,代码来源:main.cpp

示例11: evaluate

bool evaluate(AST_Expression &exp, ValueMap &valmap) {
    switch(exp.getType()) {
        case AST_BEXP:  return evaluate((AST_BinaryExpression&)exp, valmap);
        case AST_UEXP:  return evaluate((AST_UnaryExpression&)exp,  valmap);
        case AST_ID:    return evaluate((AST_Identifier&)exp,       valmap);
        default: std::cout << "Error?" << std::endl;
    }
    return false;
}
开发者ID:fumyuun,项目名称:pfpga,代码行数:9,代码来源:main.cpp

示例12: eval_binary_exp_combi_test

void eval_binary_exp_combi_test()
{
  // 24 / ((2 + 1 + (-1)) ^ 3)
  AST_Expression_Integer intExp =  (AST_Expression_Integer) newAST_Expression_Integer(24);
  AST_Expression_Integer intExp2 = (AST_Expression_Integer) newAST_Expression_Real(2);
  AST_Expression_Integer intExp3 = (AST_Expression_Integer) newAST_Expression_Integer(1);
  AST_Expression_Integer intExp4 = (AST_Expression_Integer) newAST_Expression_Integer(1);
  AST_Expression_Integer intExp5 = (AST_Expression_Integer) newAST_Expression_Integer(3);
  AST_Expression_BinOp binOp = (AST_Expression_BinOp) newAST_Expression_BinOp(intExp2, intExp3, BINOPADD);
  AST_Expression_UMinus uMinus = (AST_Expression_UMinus) newAST_Expression_UnaryMinus(intExp4);
  AST_Expression_BinOp binOp1 = (AST_Expression_BinOp) newAST_Expression_BinOp(binOp, uMinus, BINOPADD);
  AST_Expression_BinOp binOp2 = (AST_Expression_BinOp) newAST_Expression_BinOp(binOp1, intExp5, BINOPEXP);
  AST_Expression_BinOp binOp3 = (AST_Expression_BinOp) newAST_Expression_BinOp(intExp, binOp2, BINOPDIV);

  EvalExp *evalExp = new EvalExp(NULL);
  AST_Expression result = evalExp->eval(binOp3);

  BOOST_CHECK(result->expressionType() == EXPREAL);
  BOOST_CHECK(result->getAsReal()->val() == 3);
}
开发者ID:RexFuzzle,项目名称:ModelicaCC,代码行数:20,代码来源:EvalExpTest.cpp

示例13: evaluator

AST_Real RangeIterator::eval(AST_Expression exp, VarSymbolTable symbolTable) {
  EvalExp evaluator(symbolTable);
  AST_Expression result =  evaluator.eval(exp);
  ERROR_UNLESS(result->expressionType() == EXPREAL || result->expressionType() == EXPINTEGER, "RangeIterator::getVal:\n"
      "Expression type should be EXPREAL or EXPINTEGER \n");
  if (result->expressionType() == EXPREAL) {
    return result->getAsReal()->val();
  } else {
    return result->getAsInteger()->val();
  }
}
开发者ID:lucciano,项目名称:modelica-cc,代码行数:11,代码来源:for_index_iterator.cpp

示例14: return

AST_Expression
MMO_ConvertCondition_::foldTraverseElementUMinus (AST_Expression exp)
{
  return (foldTraverse (exp->getAsUMinus ()->exp ()));
}
开发者ID:RexFuzzle,项目名称:qss-solver,代码行数:5,代码来源:expression.cpp

示例15: 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;
}
开发者ID:DOCGroup,项目名称:ACE_TAO,代码行数:101,代码来源:cdr_op_cs.cpp


注:本文中的AST_Expression类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。