comparison graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LowLevelPhaseSuite.java @ 19226:9c47b23fb0a2

LowLevelPhase: add support for custom name.
author Josef Eisl <josef.eisl@jku.at>
date Mon, 09 Feb 2015 15:10:13 +0100
parents 1487207db440
children 6340d851894b
comparison
equal deleted inserted replaced
19225:e20a4aab49ad 19226:9c47b23fb0a2
29 import com.oracle.graal.lir.gen.*; 29 import com.oracle.graal.lir.gen.*;
30 30
31 public class LowLevelPhaseSuite<C, B extends AbstractBlock<B>> extends LowLevelPhase<C, B> { 31 public class LowLevelPhaseSuite<C, B extends AbstractBlock<B>> extends LowLevelPhase<C, B> {
32 private final List<LowLevelPhase<C, B>> phases; 32 private final List<LowLevelPhase<C, B>> phases;
33 33
34 public LowLevelPhaseSuite() { 34 public LowLevelPhaseSuite(Class<C> contextClass) {
35 super(getNameFromContext(contextClass));
35 phases = new ArrayList<>(); 36 phases = new ArrayList<>();
37 }
38
39 private static <C> String getNameFromContext(Class<C> contextClass) {
40 String className = contextClass.getName();
41 String s0 = className.substring(className.lastIndexOf(".") + 1); // strip the package name
42 String s = s0.substring(s0.lastIndexOf("$") + 1); // strip the enclosing class name
43 if (s.endsWith("Context")) {
44 s = s.substring(0, s.length() - "Context".length());
45 }
46 return s;
36 } 47 }
37 48
38 /** 49 /**
39 * Add a new phase at the beginning of this suite. 50 * Add a new phase at the beginning of this suite.
40 */ 51 */