Examples of JMultiExpression


Examples of com.google.gwt.dev.jjs.ast.js.JMultiExpression

     * expression of the method. If the method is void, the output of the
     * multi-expression should be considered undefined.
     */
    private JMultiExpression createMultiExpressionFromBody(JMethodBody body,
        boolean ignoringReturnValue) {
      JMultiExpression multi = new JMultiExpression(program,
          body.getSourceInfo());
      CloneCalleeExpressionVisitor cloner = new CloneCalleeExpressionVisitor();

      for (JStatement stmt : body.getStatements()) {
        if (stmt instanceof JExpressionStatement) {
View Full Code Here

Examples of com.google.gwt.dev.jjs.ast.js.JMultiExpression

     * Creates a multi expression for evaluating a method call instance,
     * possible clinit, and all arguments. This is a precursor for inlining the
     * remainder of a method that does not reference any parameters.
     */
    private JMultiExpression createMultiExpressionIncludingArgs(JMethodCall x) {
      JMultiExpression multi = createMultiExpressionForInstanceAndClinit(x);

      for (int i = 0, c = x.getArgs().size(); i < c; ++i) {
        JExpression arg = x.getArgs().get(i);
        ExpressionAnalyzer analyzer = new ExpressionAnalyzer();
        analyzer.accept(arg);
View Full Code Here

Examples of com.google.gwt.dev.jjs.ast.js.JMultiExpression

      /*
       * A method that doesn't touch any parameters is trivially inlinable (this
       * covers the empty method case)
       */
      if (orderVisitor.checkResults() == SideEffectCheck.NO_REFERENCES) {
        JMultiExpression multi = createMultiExpressionIncludingArgs(x);
        multi.exprs.add(targetExpr);
        replaceWithMulti(ctx, multi);
        return true;
      }

      /*
       * We can still inline in the case where all of the actual arguments are
       * "safe". They must have no side effects, and also have values which
       * could not be affected by the execution of any code within the callee.
       */
      if (orderVisitor.checkResults() == SideEffectCheck.FAILS) {
        for (JExpression arg : x.getArgs()) {
          ExpressionAnalyzer argAnalyzer = new ExpressionAnalyzer();
          argAnalyzer.accept(arg);

          if (argAnalyzer.hasAssignment() || argAnalyzer.accessesField()
              || argAnalyzer.createsObject() || argAnalyzer.canThrowException()) {

            /*
             * This argument evaluation could affect or be affected by the
             * callee so we cannot inline here.
             */
            return true;
          }
        }
      }

      // We're safe to inline.
      JMultiExpression multi = createMultiExpressionForInstanceAndClinit(x);

      // Replace all params in the target expression with the actual arguments.
      new ParameterReplacer(x).accept(targetExpr);

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

Examples of com.google.gwt.dev.jjs.ast.js.JMultiExpression

        }

        ArrayList<JExpression> args = x.getArgs();
        ArrayList<JParameter> originalParams = methodToOriginalParamsMap.get(method);

        JMultiExpression currentMulti = null;
        for (int i = 0, c = args.size(); i < c; ++i) {
          JExpression arg = args.get(i);
          JParameter param = null;
          if (i < originalParams.size()) {
            param = originalParams.get(i);
          }

          if (param != null && referencedNonTypes.contains(param)) {
            // If there is an existing multi, terminate it.
            if (currentMulti != null) {
              currentMulti.exprs.add(arg);
              newCall.getArgs().add(currentMulti);
              currentMulti = null;
            } else {
              newCall.getArgs().add(arg);
            }
          } else if (arg.hasSideEffects()) {
            // The argument is only needed for side effects, add it to a multi.
            if (currentMulti == null) {
              currentMulti = new JMultiExpression(program, x.getSourceInfo());
            }
            currentMulti.exprs.add(arg);
          }
        }
View Full Code Here

Examples of com.google.gwt.dev.jjs.ast.js.JMultiExpression

    }

    private JExpression makeReplacementForAssignment(SourceInfo info,
        JVariableRef variableRef, JExpression rhs) {
      // Replace with a multi, which may wind up empty.
      JMultiExpression multi = new JMultiExpression(program, info);

      // If the lhs is a field ref, evaluate it first.
      if (variableRef instanceof JFieldRef) {
        JFieldRef fieldRef = (JFieldRef) variableRef;
        JExpression instance = fieldRef.getInstance();
View Full Code Here

Examples of com.google.gwt.dev.jjs.ast.js.JMultiExpression

       * expressions that could have side effects with temporaries, so that they
       * are only run once.
       */
      enterTempUsageScope();
      ReplaceSideEffectsInLvalue replacer = new ReplaceSideEffectsInLvalue(
          new JMultiExpression(program, x.getSourceInfo()));
      JExpression newLhs = replacer.accept(x.getLhs());
      exitTempUsageScope();

      JBinaryOperation operation = new JBinaryOperation(program,
          x.getSourceInfo(), newLhs.getType(), op.getNonAssignmentOf(), newLhs,
          x.getRhs());
      // newLhs is cloned below because it was used in operation
      JBinaryOperation asg = new JBinaryOperation(program, x.getSourceInfo(),
          newLhs.getType(), JBinaryOperator.ASG,
          cloner.cloneExpression(newLhs), operation);

      JMultiExpression multiExpr = replacer.getMultiExpr();
      if (multiExpr.exprs.isEmpty()) {
        // just use the split assignment expression
        ctx.replaceMe(asg);
      } else {
        // add the assignment as the last item in the multi
View Full Code Here

Examples of com.google.gwt.dev.jjs.ast.js.JMultiExpression

      // Convert into a comma operation, such as:
      // (t = x, x += 1, t)

      // First, replace the arg with a non-side-effect causing one.
      enterTempUsageScope();
      JMultiExpression multi = new JMultiExpression(program, x.getSourceInfo());
      ReplaceSideEffectsInLvalue replacer = new ReplaceSideEffectsInLvalue(
          multi);
      JExpression newArg = replacer.accept(x.getArg());

      JExpression expressionReturn = expressionToReturn(newArg);
View Full Code Here

Examples of com.google.gwt.dev.jjs.ast.js.JMultiExpression

    return false;
  }

  @Override
  public boolean visit(JMultiExpression x, Context ctx) {
    JMultiExpression multi = new JMultiExpression(program, x.getSourceInfo());
    multi.exprs.addAll(cloneExpressions(x.exprs));
    expression = multi;
    return false;
  }
View Full Code Here

Examples of com.google.gwt.dev.jjs.ast.js.JMultiExpression

       */
      //   (a, b).foo() --> (a, foo(b))
      // Or in checked mode:
      //   (a, b).foo() --> (a, foo(checkNotNull(b)))
      if (original.getInstance() instanceof JMultiExpression) {
        JMultiExpression multi = (JMultiExpression) original.getInstance();
        int lastIndex = multi.getNumberOfExpressions() - 1;
        newCall.addArg(makeNullCheck(multi.getExpression(lastIndex), original));
        newCall.addArgs(original.getArgs());
        multi.setExpression(lastIndex, newCall);
        return multi;
      } else {
        // The qualifier becomes the first argument.
        //   a.foo(b) --> foo(a,b)
        // or in checked mode:
View Full Code Here

Examples of com.google.gwt.dev.jjs.ast.js.JMultiExpression

    return false;
  }

  @Override
  public boolean visit(JMultiExpression x, Context ctx) {
    expression = new JMultiExpression(x.getSourceInfo(), cloneExpressions(x.getExpressions()));
    return false;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.