@Test
  public void replaceCompValueTest1() {
    DummyValue dummyValue1 = new DummyValue();
    DummyValue dummyValue2 = new DummyValue();
    DummyValue dummyValue3 = new DummyValue();
    NestedCompositeValue compValue1 = createNestedCompValue(dummyValue1, 1);
    LIRInstruction op1 = new TestOp(compValue1);
    LIRInstruction op2 = new TestOp(compValue1);

    op1.forEachInputPos(
        (instruction, position) -> {
          Value value = position.get(instruction);
          assertEquals(dummyValue1, value);
          position.set(instruction, dummyValue2);
        });

    op2.forEachInputPos(
        (instruction, position) -> {
          Value value = position.get(instruction);
          assertEquals(dummyValue1, value);
          position.set(instruction, dummyValue3);
        });

    op1.forEachInputPos(
        (instruction, position) -> {
          Value value = position.get(instruction);
          assertEquals(dummyValue2, value);
        });

    op2.forEachInputPos(
        (instruction, position) -> {
          Value value = position.get(instruction);
          assertEquals(dummyValue3, value);
        });
  }
Пример #2
0
  private boolean verifyBlock(AbstractBlockBase<?> block) {
    currentBlock = block;
    assert !visited.get(block.getId()) : "Block already visited: " + block;
    visited.set(block.getId());
    for (LIRInstruction op : lir.getLIRforBlock(block)) {
      op.visitEachAlive(this::useConsumer);
      op.visitEachState(this::useConsumer);
      op.visitEachInput(this::useConsumer);

      op.visitEachTemp(this::defConsumer);
      op.visitEachOutput(this::defConsumer);
    }
    currentBlock = null;
    return true;
  }