changeset 17286:afafc0aad977

Make InstructionValueProcedureBase an interface.
author Josef Eisl <josef.eisl@jku.at>
date Tue, 30 Sep 2014 18:41:18 +0200
parents 3a834111a632
children 0f8b1fb632df
files graal/com.oracle.graal.lir/src/com/oracle/graal/lir/InstructionValueConsumer.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/InstructionValueProcedure.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/InstructionValueProcedureBase.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRFrameState.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRInstruction.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/ValueConsumer.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/ValueProcedure.java
diffstat 7 files changed, 46 insertions(+), 86 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/InstructionValueConsumer.java	Thu Sep 25 17:04:52 2014 +0200
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/InstructionValueConsumer.java	Tue Sep 30 18:41:18 2014 +0200
@@ -32,7 +32,7 @@
  * Non-modifying version of {@link InstructionValueProcedure}.
  */
 @FunctionalInterface
-public interface InstructionValueConsumer {
+public interface InstructionValueConsumer extends InstructionValueProcedureBase {
 
     /**
      * Iterator method to be overwritten.
@@ -43,4 +43,9 @@
      * @param flags A set of flags for the value.
      */
     void visitValue(LIRInstruction instruction, Value value, OperandMode mode, EnumSet<OperandFlag> flags);
+
+    default Value processValue(LIRInstruction instruction, Value value, OperandMode mode, EnumSet<OperandFlag> flags) {
+        visitValue(instruction, value, mode, flags);
+        return value;
+    }
 }
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/InstructionValueProcedure.java	Thu Sep 25 17:04:52 2014 +0200
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/InstructionValueProcedure.java	Tue Sep 30 18:41:18 2014 +0200
@@ -34,7 +34,7 @@
  * {@link InstructionValueProcedureBase#processValue} instead.
  */
 @FunctionalInterface
-public interface InstructionValueProcedure {
+public interface InstructionValueProcedure extends InstructionValueProcedureBase {
 
     /**
      * Iterator method to be overwritten.
@@ -46,4 +46,8 @@
      * @return The new value to replace the value that was passed in.
      */
     Value doValue(LIRInstruction instruction, Value value, OperandMode mode, EnumSet<OperandFlag> flags);
+
+    default Value processValue(LIRInstruction instruction, Value value, OperandMode mode, EnumSet<OperandFlag> flags) {
+        return doValue(instruction, value, mode, flags);
+    }
 }
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/InstructionValueProcedureBase.java	Thu Sep 25 17:04:52 2014 +0200
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/InstructionValueProcedureBase.java	Tue Sep 30 18:41:18 2014 +0200
@@ -38,7 +38,7 @@
  * @see InstructionValueConsumer
  * @see ValueConsumer
  */
-public abstract class InstructionValueProcedureBase {
+public interface InstructionValueProcedureBase {
 
     /**
      * Iterator method to be overwritten. This version of the iterator gets additional parameters
@@ -50,63 +50,6 @@
      * @param flags A set of flags for the value.
      * @return The new value to replace the value that was passed in.
      */
-    abstract public Value processValue(LIRInstruction instruction, Value value, OperandMode mode, EnumSet<OperandFlag> flags);
-
-    /**
-     * Wraps an {@link InstructionValueProcedure} into an {@link InstructionValueProcedureBase}.
-     */
-    public static InstructionValueProcedureBase wrap(InstructionValueProcedure proc) {
-        return new InstructionValueProcedureBase() {
-
-            @Override
-            public Value processValue(LIRInstruction instruction, Value value, OperandMode mode, EnumSet<OperandFlag> flags) {
-                return proc.doValue(instruction, value, mode, flags);
-            }
-        };
-
-    }
-
-    /**
-     * Wraps a {@link ValueProcedure} into an {@link InstructionValueProcedureBase}.
-     */
-    public static InstructionValueProcedureBase wrap(ValueProcedure proc) {
-        return new InstructionValueProcedureBase() {
-
-            @Override
-            public Value processValue(LIRInstruction instruction, Value value, OperandMode mode, EnumSet<OperandFlag> flags) {
-                return proc.doValue(value, mode, flags);
-            }
-        };
-
-    }
+    Value processValue(LIRInstruction instruction, Value value, OperandMode mode, EnumSet<OperandFlag> flags);
 
-    /**
-     * Wraps an {@link InstructionValueConsumer} into an {@link InstructionValueProcedureBase}.
-     */
-    public static InstructionValueProcedureBase wrap(InstructionValueConsumer proc) {
-        return new InstructionValueProcedureBase() {
-
-            @Override
-            public Value processValue(LIRInstruction instruction, Value value, OperandMode mode, EnumSet<OperandFlag> flags) {
-                proc.visitValue(instruction, value, mode, flags);
-                return value;
-            }
-        };
-
-    }
-
-    /**
-     * Wraps a {@link ValueConsumer} into an {@link InstructionValueProcedureBase}.
-     */
-    public static InstructionValueProcedureBase wrap(ValueConsumer proc) {
-        return new InstructionValueProcedureBase() {
-
-            @Override
-            public Value processValue(LIRInstruction instruction, Value value, OperandMode mode, EnumSet<OperandFlag> flags) {
-                proc.visitValue(value, mode, flags);
-                return value;
-            }
-        };
-
-    }
 }
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRFrameState.java	Thu Sep 25 17:04:52 2014 +0200
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRFrameState.java	Tue Sep 30 18:41:18 2014 +0200
@@ -63,7 +63,7 @@
      * @param proc The procedure called for variables.
      */
     public void forEachState(LIRInstruction inst, InstructionValueProcedure proc) {
-        forEachState(inst, InstructionValueProcedureBase.wrap(proc));
+        forEachState(inst, proc);
     }
 
     void forEachState(LIRInstruction inst, InstructionValueProcedureBase proc) {
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRInstruction.java	Thu Sep 25 17:04:52 2014 +0200
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRInstruction.java	Tue Sep 30 18:41:18 2014 +0200
@@ -236,44 +236,44 @@
 
     // InstructionValueProcedures
     public final void forEachInput(InstructionValueProcedure proc) {
-        instructionClass.forEachUse(this, InstructionValueProcedureBase.wrap(proc));
+        instructionClass.forEachUse(this, proc);
     }
 
     public final void forEachAlive(InstructionValueProcedure proc) {
-        instructionClass.forEachAlive(this, InstructionValueProcedureBase.wrap(proc));
+        instructionClass.forEachAlive(this, proc);
     }
 
     public final void forEachTemp(InstructionValueProcedure proc) {
-        instructionClass.forEachTemp(this, InstructionValueProcedureBase.wrap(proc));
+        instructionClass.forEachTemp(this, proc);
     }
 
     public final void forEachOutput(InstructionValueProcedure proc) {
-        instructionClass.forEachDef(this, InstructionValueProcedureBase.wrap(proc));
+        instructionClass.forEachDef(this, proc);
     }
 
     public final void forEachState(InstructionValueProcedure proc) {
-        instructionClass.forEachState(this, InstructionValueProcedureBase.wrap(proc));
+        instructionClass.forEachState(this, proc);
     }
 
     // ValueProcedures
     public final void forEachInput(ValueProcedure proc) {
-        instructionClass.forEachUse(this, InstructionValueProcedureBase.wrap(proc));
+        instructionClass.forEachUse(this, proc);
     }
 
     public final void forEachAlive(ValueProcedure proc) {
-        instructionClass.forEachAlive(this, InstructionValueProcedureBase.wrap(proc));
+        instructionClass.forEachAlive(this, proc);
     }
 
     public final void forEachTemp(ValueProcedure proc) {
-        instructionClass.forEachTemp(this, InstructionValueProcedureBase.wrap(proc));
+        instructionClass.forEachTemp(this, proc);
     }
 
     public final void forEachOutput(ValueProcedure proc) {
-        instructionClass.forEachDef(this, InstructionValueProcedureBase.wrap(proc));
+        instructionClass.forEachDef(this, proc);
     }
 
     public final void forEachState(ValueProcedure proc) {
-        instructionClass.forEachState(this, InstructionValueProcedureBase.wrap(proc));
+        instructionClass.forEachState(this, proc);
     }
 
     // States
@@ -283,44 +283,44 @@
 
     // InstructionValueConsumers
     public final void visitEachInput(InstructionValueConsumer proc) {
-        instructionClass.forEachUse(this, InstructionValueProcedureBase.wrap(proc));
+        instructionClass.forEachUse(this, proc);
     }
 
     public final void visitEachAlive(InstructionValueConsumer proc) {
-        instructionClass.forEachAlive(this, InstructionValueProcedureBase.wrap(proc));
+        instructionClass.forEachAlive(this, proc);
     }
 
     public final void visitEachTemp(InstructionValueConsumer proc) {
-        instructionClass.forEachTemp(this, InstructionValueProcedureBase.wrap(proc));
+        instructionClass.forEachTemp(this, proc);
     }
 
     public final void visitEachOutput(InstructionValueConsumer proc) {
-        instructionClass.forEachDef(this, InstructionValueProcedureBase.wrap(proc));
+        instructionClass.forEachDef(this, proc);
     }
 
     public final void visitEachState(InstructionValueConsumer proc) {
-        instructionClass.forEachState(this, InstructionValueProcedureBase.wrap(proc));
+        instructionClass.forEachState(this, proc);
     }
 
     // ValueConsumers
     public final void visitEachInput(ValueConsumer proc) {
-        instructionClass.forEachUse(this, InstructionValueProcedureBase.wrap(proc));
+        instructionClass.forEachUse(this, proc);
     }
 
     public final void visitEachAlive(ValueConsumer proc) {
-        instructionClass.forEachAlive(this, InstructionValueProcedureBase.wrap(proc));
+        instructionClass.forEachAlive(this, proc);
     }
 
     public final void visitEachTemp(ValueConsumer proc) {
-        instructionClass.forEachTemp(this, InstructionValueProcedureBase.wrap(proc));
+        instructionClass.forEachTemp(this, proc);
     }
 
     public final void visitEachOutput(ValueConsumer proc) {
-        instructionClass.forEachDef(this, InstructionValueProcedureBase.wrap(proc));
+        instructionClass.forEachDef(this, proc);
     }
 
     public final void visitEachState(ValueConsumer proc) {
-        instructionClass.forEachState(this, InstructionValueProcedureBase.wrap(proc));
+        instructionClass.forEachState(this, proc);
     }
 
     /**
@@ -339,7 +339,7 @@
      * @return The non-null value returned by the procedure, or null.
      */
     public Value forEachRegisterHint(Value value, OperandMode mode, InstructionValueProcedure proc) {
-        return instructionClass.forEachRegisterHint(this, mode, InstructionValueProcedureBase.wrap(proc));
+        return instructionClass.forEachRegisterHint(this, mode, proc);
     }
 
     /**
@@ -352,7 +352,7 @@
      * @return The non-null value returned by the procedure, or null.
      */
     public Value forEachRegisterHint(Value value, OperandMode mode, ValueProcedure proc) {
-        return instructionClass.forEachRegisterHint(this, mode, InstructionValueProcedureBase.wrap(proc));
+        return instructionClass.forEachRegisterHint(this, mode, proc);
     }
 
     protected void verify() {
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/ValueConsumer.java	Thu Sep 25 17:04:52 2014 +0200
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/ValueConsumer.java	Tue Sep 30 18:41:18 2014 +0200
@@ -32,7 +32,7 @@
  * Non-modifying version of {@link ValueProcedure}.
  */
 @FunctionalInterface
-public interface ValueConsumer {
+public interface ValueConsumer extends InstructionValueProcedureBase {
 
     /**
      * Iterator method to be overwritten.
@@ -43,4 +43,8 @@
      */
     void visitValue(Value value, OperandMode mode, EnumSet<OperandFlag> flags);
 
+    default Value processValue(LIRInstruction instruction, Value value, OperandMode mode, EnumSet<OperandFlag> flags) {
+        visitValue(value, mode, flags);
+        return value;
+    }
 }
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/ValueProcedure.java	Thu Sep 25 17:04:52 2014 +0200
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/ValueProcedure.java	Tue Sep 30 18:41:18 2014 +0200
@@ -32,7 +32,7 @@
  * Similar to {@link InstructionValueProcedure} but without an {@link LIRInstruction} parameter.
  */
 @FunctionalInterface
-public interface ValueProcedure {
+public interface ValueProcedure extends InstructionValueProcedureBase {
 
     /**
      * Iterator method to be overwritten.
@@ -43,4 +43,8 @@
      * @return The new value to replace the value that was passed in.
      */
     Value doValue(Value value, OperandMode mode, EnumSet<OperandFlag> flags);
+
+    default Value processValue(LIRInstruction instruction, Value value, OperandMode mode, EnumSet<OperandFlag> flags) {
+        return doValue(value, mode, flags);
+    }
 }