comparison graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java @ 19526:8fc336a04d77

Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Fri, 20 Feb 2015 22:22:55 +0100
parents d216de21bfe8
children 353669a84287
comparison
equal deleted inserted replaced
19525:35481bcb5882 19526:8fc336a04d77
69 } 69 }
70 70
71 /** 71 /**
72 * Gets the {@link NodeClass} associated with a given {@link Class}. 72 * Gets the {@link NodeClass} associated with a given {@link Class}.
73 */ 73 */
74 public static <T> NodeClass<T> get(Class<T> c) { 74 public static <T> NodeClass<T> create(Class<T> c) {
75 assert getNodeClassViaReflection(c) == null; 75 assert get(c) == null;
76 Class<? super T> superclass = c.getSuperclass(); 76 Class<? super T> superclass = c.getSuperclass();
77 NodeClass<? super T> nodeSuperclass = null; 77 NodeClass<? super T> nodeSuperclass = null;
78 if (superclass != NODE_CLASS) { 78 if (superclass != NODE_CLASS) {
79 nodeSuperclass = getNodeClassViaReflection(superclass); 79 nodeSuperclass = get(superclass);
80 } 80 }
81 return new NodeClass<>(c, nodeSuperclass); 81 return new NodeClass<>(c, nodeSuperclass);
82 } 82 }
83 83
84 @SuppressWarnings("unchecked") 84 @SuppressWarnings("unchecked")
85 public static <T> NodeClass<T> getNodeClassViaReflection(Class<T> superclass) { 85 public static <T> NodeClass<T> get(Class<T> superclass) {
86 try { 86 try {
87 Field field = superclass.getDeclaredField("TYPE"); 87 Field field = superclass.getDeclaredField("TYPE");
88 field.setAccessible(true); 88 field.setAccessible(true);
89 return (NodeClass<T>) field.get(null); 89 return (NodeClass<T>) field.get(null);
90 } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) { 90 } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) {