import edu.berkeley.sbp.chr.*;
import edu.berkeley.sbp.util.*;
-public class ReflectiveGrammar extends MetaGrammar {
-
+public class ReflectiveGrammar /*extends MetaGrammar*/ {
+ /*
final Class baseClass;
public ReflectiveGrammar(Class baseClass) { this.baseClass = baseClass; }
} else if (h==arrayMark && c==null) {
c = Object[].class;
}
- if (c==null) System.out.println(h + " -- " + t.toPrettyString());
if (c.isArray()) {
Object[] ret = new Object[t.numChildren()];
for(int i=0; i<ret.length; i++)
}
public Object buildBody(Tree<Object> t, Class c) throws Exception {
- System.out.println("buildBody " + (c==null?null:c.getName()) + " " + t);
+ //System.out.println("buildBody " + (c==null?null:c.getName()) + " " + t);
c = resolveClass(t, c);
if (c==null) return buildHead(t, null);
Object o = c.newInstance();
else {
Object tgt = Reflection.rebuild(buildHead(t.child(i), field.getType()), field.getType());
//if (tgt instanceof Object[]) tgt = Reflection.lub(tgt);
- System.err.println("setting field " + field.getName() + " on " + c.getName() + " to " + tgt);
+ //System.err.println("setting field " + field.getName() + " on " + c.getName() + " to " + tgt);
try {
field.set(o, tgt);
} catch (Exception e) {
if (c==null) return null;
if (c==int.class) return c;
if (c==String.class) return c;
- System.out.println("resolving " + c.getName());
+ //System.out.println("resolving " + c.getName());
if (Reflection.isConcrete(c)) return c;
Class ret = null;
Class[] subs = (Class[])c.getField("subclasses").get(null);
OUTER: for(int i=0; i<subs.length; i++) {
- System.err.println("trying " + subs[i].getName());
+ //System.err.println("trying " + subs[i].getName());
for(int j=0; j<t.numChildren(); j++)
if (Reflection.getField(subs[i], t.label(j)+"")==null) {
- System.err.println("skipping due to " + t.label(j));
+ //System.err.println("skipping due to " + t.label(j));
continue OUTER;
}
if (ret != null)
if (ret==null) throw new RuntimeException("couldn't find a class to match tree: " + t);
return ret;
}
-
+ */
}