Package com.google.gwt.dev.jjs.ast

Examples of com.google.gwt.dev.jjs.ast.JConditional


      }
    } else {
      // e.g. (!cond ? then : else) -> (cond ? else : then)
      JExpression unflipped = maybeUnflipBoolean(condExpr);
      if (unflipped != null) {
        return new JConditional(program, original.getSourceInfo(),
            original.getType(), unflipped, elseExpr, thenExpr);
      }
    }

    // no simplification made
    if (original != null) {
      return original;
    }
    return new JConditional(program, sourceInfo, type, condExpr, thenExpr,
        elseExpr);
  }
View Full Code Here


    @Override
    public void endVisit(JConditional x, Context ctx) {
      JExpression newThen = checkAndReplace(x.getThenExpr(), x.getType());
      JExpression newElse = checkAndReplace(x.getElseExpr(), x.getType());
      if (newThen != x.getThenExpr() || newElse != x.getElseExpr()) {
        JConditional newCond = new JConditional(program, x.getSourceInfo(),
            x.getType(), x.getIfTest(), newThen, newElse);
        ctx.replaceMe(newCond);
      }
    }
View Full Code Here

    return false;
  }

  @Override
  public boolean visit(JConditional x, Context ctx) {
    expression = new JConditional(program, x.getSourceInfo(), x.getType(),
        cloneExpression(x.getIfTest()), cloneExpression(x.getThenExpr()),
        cloneExpression(x.getElseExpr()));
    return false;
  }
View Full Code Here

        SourceInfo info = makeSourceInfo(x);
        JType type = typeMap.get(x.resolvedType);
        JExpression valueIfFalse = pop(x.valueIfFalse);
        JExpression valueIfTrue = pop(x.valueIfTrue);
        JExpression condition = pop(x.condition);
        push(new JConditional(info, type, condition, valueIfTrue, valueIfFalse));
      } catch (Throwable e) {
        throw translateException(x, e);
      }
    }
View Full Code Here

      }
    } else {
      // e.g. (!cond ? then : else) -> (cond ? else : then)
      JExpression unflipped = maybeUnflipBoolean(condExpr);
      if (unflipped != null) {
        return new JConditional(info, type, unflipped, elseExpr, thenExpr);
      }
    }

    // no simplification made
    if (original != null) {
      return original;
    }
    return new JConditional(info, type, condExpr, thenExpr, elseExpr);
  }
View Full Code Here

      if (thenExpression == null || elseExpression == null) {
        // empty returns are not supported.
        return null;
      }

      JConditional conditional =
          new JConditional(sourceInfo, currentMethod.getType(), condExpr, thenExpression,
              elseExpression);

      JReturnStatement returnStatement = new JReturnStatement(sourceInfo, conditional);
      return returnStatement;
    }

    if (elseStmt != null) {
      // if () { } else { } -> ... ? ... : ... ;
      JExpression thenExpression = extractExpression(thenStmt);
      JExpression elseExpression = extractExpression(elseStmt);

      if (thenExpression != null && elseExpression != null) {
        JConditional conditional =
            new JConditional(sourceInfo, JPrimitiveType.VOID, condExpr, thenExpression,
                elseExpression);

        return conditional.makeStatement();
      }
    } else {
      // if () { } -> ... && ...;
      JExpression thenExpression = extractExpression(thenStmt);
View Full Code Here

      return falseDispatch;
    }
    JMethodCall condition =
        new JMethodCall(trueDispatch.getSourceInfo(), null, checkMethod, target);

    return new JConditional(condition.getSourceInfo(), trueDispatch.getType(), condition,
        trueDispatch, falseDispatch);
  }
View Full Code Here

        elseValue.addArg(new JParameterRef(sourceInfo, param));
      }
    }

    // isJavaObject(temp) ? temp.method(args) : jso$method(temp, args)
    JConditional conditional = new JConditional(sourceInfo,
        polyMethod.getType(),
        condition, thenValue, elseValue);


    multi.exprs.add(conditional);
View Full Code Here

        SourceInfo info = makeSourceInfo(x);
        JType type = typeMap.get(x.resolvedType);
        JExpression valueIfFalse = pop(x.valueIfFalse);
        JExpression valueIfTrue = pop(x.valueIfTrue);
        JExpression condition = pop(x.condition);
        push(new JConditional(info, type, condition, valueIfTrue, valueIfFalse));
      } catch (Throwable e) {
        throw translateException(x, e);
      }
    }
View Full Code Here

    return false;
  }

  @Override
  public boolean visit(JConditional x, Context ctx) {
    expression = new JConditional(x.getSourceInfo(), x.getType(),
        cloneExpression(x.getIfTest()), cloneExpression(x.getThenExpr()),
        cloneExpression(x.getElseExpr()));
    return false;
  }
View Full Code Here

TOP

Related Classes of com.google.gwt.dev.jjs.ast.JConditional

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.