Exemplo n.º 1
0
  public static BytecodeExpr transformLogicalExpression(
      Expression exp, CompilerTransformer compiler, Label label, boolean onTrue) {
    if (exp instanceof StaticMethodCallExpression) {
      StaticMethodCallExpression smce = (StaticMethodCallExpression) exp;
      MethodCallExpression mce =
          new MethodCallExpression(
              new ClassExpression(smce.getOwnerType()), smce.getMethod(), smce.getArguments());
      mce.setSourcePosition(smce);
      return transformLogicalExpression(mce, compiler, label, onTrue);
    }

    ExprTransformer t = transformers.get(exp.getClass());
    return t.transformLogical(exp, compiler, label, onTrue);
  }
 protected Expression transformBinaryExpression(BinaryExpression be) {
   int type = be.getOperation().getType();
   boolean oldInLeftExpression;
   Expression right = transform(be.getRightExpression());
   be.setRightExpression(right);
   Expression left;
   if (type == Types.EQUAL && be.getLeftExpression() instanceof VariableExpression) {
     oldInLeftExpression = inLeftExpression;
     inLeftExpression = true;
     left = transform(be.getLeftExpression());
     inLeftExpression = oldInLeftExpression;
     if (left instanceof StaticMethodCallExpression) {
       StaticMethodCallExpression smce = (StaticMethodCallExpression) left;
       StaticMethodCallExpression result =
           new StaticMethodCallExpression(smce.getOwnerType(), smce.getMethod(), right);
       setSourcePosition(result, be);
       return result;
     }
   } else {
     left = transform(be.getLeftExpression());
   }
   be.setLeftExpression(left);
   return be;
 }
    @Override
    public void visitStaticMethodCallExpression(StaticMethodCallExpression expression) {
      // LOG.debug "Transforming expression '${expression}':"

      if (expression.getLineNumber() >= 0 && expression.getLineNumber() < lineNumbers.length) {
        // LOG.debug "   start from ${expression.lineNumber} to ${lineNumbers[expression.lineNumber
        // - 1]}"
        expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1]);
      }

      if (expression.getLastLineNumber() > 0
          && expression.getLastLineNumber() < lineNumbers.length) {
        // LOG.debug "   end from ${expression.lastLineNumber} to
        // ${lineNumbers[expression.lastLineNumber - 1]}"
        expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1]);
      }
      super.visitStaticMethodCallExpression(expression);
    }
 public void visitStaticMethodCallExpression(StaticMethodCallExpression call) {
   call.getArguments().visit(this);
 }