Exemplo n.º 1
0
  public static void compileIRStatement(IRStatement statement, IRBytecodeContext context) {
    if (statement == null) {
      return;
    }

    context.setLineNumber(statement.getLineNumber());
    if (statement instanceof IRAssignmentStatement) {
      IRAssignmentStatementCompiler.compile((IRAssignmentStatement) statement, context);
    } else if (statement instanceof IRFieldSetStatement) {
      IRFieldSetStatementCompiler.compile((IRFieldSetStatement) statement, context);
    } else if (statement instanceof IRIfStatement) {
      IRIfStatementCompiler.compile((IRIfStatement) statement, context);
    } else if (statement instanceof IRMethodCallStatement) {
      IRMethodCallStatementCompiler.compile((IRMethodCallStatement) statement, context);
    } else if (statement instanceof IRNewStatement) {
      IRNewStatementCompiler.compile((IRNewStatement) statement, context);
    } else if (statement instanceof IRNoOpStatement) {
      // Do nothing
    } else if (statement instanceof IRReturnStatement) {
      IRReturnStatementCompiler.compile((IRReturnStatement) statement, context);
    } else if (statement instanceof IRStatementList) {
      IRStatementListCompiler.compile((IRStatementList) statement, context);
    } else if (statement instanceof IRArrayStoreStatement) {
      IRArrayStoreStatementCompiler.compile((IRArrayStoreStatement) statement, context);
    } else if (statement instanceof IRThrowStatement) {
      IRThrowStatementCompiler.compile((IRThrowStatement) statement, context);
    } else if (statement instanceof IRForEachStatement) {
      IRForEachStatementCompiler.compile((IRForEachStatement) statement, context);
    } else if (statement instanceof IRWhileStatement) {
      IRWhileStatementCompiler.compile((IRWhileStatement) statement, context);
    } else if (statement instanceof IRDoWhileStatement) {
      IRDoWhileStatementCompiler.compile((IRDoWhileStatement) statement, context);
    } else if (statement instanceof IRBreakStatement) {
      IRBreakStatementCompiler.compile((IRBreakStatement) statement, context);
    } else if (statement instanceof IRContinueStatement) {
      IRContinueStatementCompiler.compile((IRContinueStatement) statement, context);
    } else if (statement instanceof IRTryCatchFinallyStatement) {
      IRTryCatchFinallyStatementCompiler.compile((IRTryCatchFinallyStatement) statement, context);
    } else if (statement instanceof IRMonitorLockAcquireStatement) {
      IRMonitorLockAcquireCompiler.compile((IRMonitorLockAcquireStatement) statement, context);
    } else if (statement instanceof IRMonitorLockReleaseStatement) {
      IRMonitorLockReleaseCompiler.compile((IRMonitorLockReleaseStatement) statement, context);
    } else if (statement instanceof IRSyntheticStatement) {
      IRSyntheticStatementCompiler.compile((IRSyntheticStatement) statement, context);
    } else if (statement instanceof IRSwitchStatement) {
      IRSwitchStatementCompiler.compile((IRSwitchStatement) statement, context);
    } else if (statement instanceof IREvalStatement) {
      IREvalStatementCompiler.compile((IREvalStatement) statement, context);
    } else {
      throw new IllegalArgumentException("Unrecognized statement of type " + statement.getClass());
    }
  }
Exemplo n.º 2
0
  public static void compileIRExpression(IRExpression expression, IRBytecodeContext context) {
    if (expression == null) {
      return;
    }

    int previousLineNumber = context.setLineNumber(expression.getLineNumber());
    try {
      if (expression instanceof IRArithmeticExpression) {
        IRArithmeticExpressionCompiler.compile((IRArithmeticExpression) expression, context);
      } else if (expression instanceof IRArrayLoadExpression) {
        IRArrayLoadExpressionCompiler.compile((IRArrayLoadExpression) expression, context);
      } else if (expression instanceof IRBooleanLiteral) {
        IRBooleanLiteralCompiler.compile((IRBooleanLiteral) expression, context);
      } else if (expression instanceof IRCompositeExpression) {
        IRCompositeExpressionCompiler.compile((IRCompositeExpression) expression, context);
      } else if (expression instanceof IREqualityExpression) {
        IREqualityExpressionCompiler.compile((IREqualityExpression) expression, context);
      } else if (expression instanceof IRFieldGetExpression) {
        IRFieldGetExpressionCompiler.compile((IRFieldGetExpression) expression, context);
      } else if (expression instanceof IRIdentifier) {
        IRIdentifierCompiler.compile((IRIdentifier) expression, context);
      } else if (expression instanceof IRMethodCallExpression) {
        IRMethodCallExpressionCompiler.compile((IRMethodCallExpression) expression, context);
      } else if (expression instanceof IRNullLiteral) {
        IRNullLiteralCompiler.compile((IRNullLiteral) expression, context);
      } else if (expression instanceof IRPrimitiveTypeConversion) {
        IRPrimitiveTypeConversionCompiler.compile((IRPrimitiveTypeConversion) expression, context);
      } else if (expression instanceof IRTernaryExpression) {
        IRTernaryExpressionCompiler.compile((IRTernaryExpression) expression, context);
      } else if (expression instanceof IRNumericLiteral) {
        IRNumericLiteralCompiler.compile((IRNumericLiteral) expression, context);
      } else if (expression instanceof IRCharacterLiteral) {
        IRCharacterLiteralCompiler.compile((IRCharacterLiteral) expression, context);
      } else if (expression instanceof IRStringLiteralExpression) {
        IRStringLiteralExpressionCompiler.compile((IRStringLiteralExpression) expression, context);
      } else if (expression instanceof IRNewArrayExpression) {
        IRNewArrayExpressionCompiler.compile((IRNewArrayExpression) expression, context);
      } else if (expression instanceof IRArrayLengthExpression) {
        IRArrayLengthExpressionCompiler.compile((IRArrayLengthExpression) expression, context);
      } else if (expression instanceof IRCastExpression) {
        IRCastExpressionCompiler.compile((IRCastExpression) expression, context);
      } else if (expression instanceof IRNewExpression) {
        IRNewExpressionCompiler.compile((IRNewExpression) expression, context);
      } else if (expression instanceof IRRelationalExpression) {
        IRRelationalExpressionCompiler.compile((IRRelationalExpression) expression, context);
      } else if (expression instanceof IRClassLiteral) {
        IRClassLiteralCompiler.compile((IRClassLiteral) expression, context);
      } else if (expression instanceof IRNegationExpression) {
        IRNegationExpressionCompiler.compile((IRNegationExpression) expression, context);
      } else if (expression instanceof IRNotExpression) {
        IRNotExpressionCompiler.compile((IRNotExpression) expression, context);
      } else if (expression instanceof IRConditionalAndExpression) {
        IRConditionalAndExpressionCompiler.compile(
            (IRConditionalAndExpression) expression, context);
      } else if (expression instanceof IRConditionalOrExpression) {
        IRConditionalOrExpressionCompiler.compile((IRConditionalOrExpression) expression, context);
      } else if (expression instanceof IRInstanceOfExpression) {
        IRInstanceOfExpressionCompiler.compile((IRInstanceOfExpression) expression, context);
      } else if (expression instanceof IRNewMultiDimensionalArrayExpression) {
        IRNewMultiDimensionalArrayExpressionCompiler.compile(
            (IRNewMultiDimensionalArrayExpression) expression, context);
      } else if (expression instanceof IRNoOpExpression) {
        // Do nothing
      } else {
        throw new IllegalArgumentException(
            "Unrecognized expression of type " + expression.getClass());
      }
    } finally {
      context.setLineNumber(previousLineNumber);
    }
  }