Package org.eclipse.cdt.core.dom.ast

Examples of org.eclipse.cdt.core.dom.ast.IASTBinaryExpression


    return PROCESS_SKIP;
  }
 
  public int visit(IASTExpression expr) {
    if (expr instanceof IASTBinaryExpression) {
      IASTBinaryExpression bexpr = (IASTBinaryExpression)expr;
      boolean isCondition = checkIsCondition(bexpr);
      if (isCondition) {
        return visit_condition_expression(bexpr);
      } else {
        return visit_binary_expression(bexpr);
View Full Code Here


  }
   
  @Override
  public int visit(IASTExpression expr) {
    if (expr instanceof IASTBinaryExpression) {
      IASTBinaryExpression bexpr = (IASTBinaryExpression) expr;
   
      if (isAssign(bexpr)) {
                               
        ExprVisitor rhsVisitor = new ExprVisitor();
        bexpr.getOperand2().accept(rhsVisitor);
        Expression rhs = rhsVisitor.getExpr();
       
        ExprVisitor lhsVisitor = new ExprVisitor();
       
        switch (bexpr.getOperator()) {
          case IASTBinaryExpression.op_plusAssign:
            bexpr.getOperand1().accept(lhsVisitor);
            rhs = lhsVisitor.getExpr().add(rhs);
            break;
          case IASTBinaryExpression.op_minusAssign:
            bexpr.getOperand1().accept(lhsVisitor);
            rhs=lhsVisitor.getExpr().sub(rhs);
            break;
          case IASTBinaryExpression.op_divideAssign:
            bexpr.getOperand1().accept(lhsVisitor);
            rhs=lhsVisitor.getExpr().div(rhs);
            break;
          case IASTBinaryExpression.op_multiplyAssign:
            bexpr.getOperand1().accept(lhsVisitor);
            rhs=lhsVisitor.getExpr().mul(rhs);
            break;
          case IASTBinaryExpression.op_assign:
            break;
          default:         
            System.err.println ("Operator is not handled !");
        }
       
        IASTExpression operand1 = bexpr.getOperand1();
        while(operand1 instanceof IASTUnaryExpression && ((IASTUnaryExpression)operand1).getOperator() == IASTUnaryExpression.op_bracketedPrimary){
          IASTUnaryExpression unOperand1 = (IASTUnaryExpression)operand1;
          operand1 = unOperand1.getOperand();
        }
       
        if(operand1 instanceof IASTIdExpression){
          Statement stmt = new Statement(new Assignment (operand1.getRawSignature(),rhs));
          if(inElse) parent.Enclose(stmt, true);
          else parent.Enclose(stmt, false);
        }
        else if (operand1 instanceof IASTArraySubscriptExpression) {
          ArrayAccessVisitor aVisitor = new ArrayAccessVisitor();
          operand1.accept(aVisitor);
          List<Expression> flist = aVisitor.indices;
          Collections.reverse(flist);
         
          Statement stmt = new Statement(new Assignment (aVisitor.id, new FADA_Index(flist), rhs));

          if(inElse) parent.Enclose(stmt, true);
          else parent.Enclose(stmt, false);
        } else {
         
          //bexpr.getOperand1().accept(lhsVisitor);
          //FadaExpression lhs = lhsVisitor.getExpr();
         
         
          System.err.println("StmtVisitor.visit: unknown binary operand " + bexpr.getOperand1() + " " +  expr.getRawSignature());
         
        }
      } else {
        System.err.println("StmtVisitor.visit: unknown binary expression " + expr.getRawSignature());
      }
View Full Code Here

TOP

Related Classes of org.eclipse.cdt.core.dom.ast.IASTBinaryExpression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.