X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2Fmisc%2FDemo.java;h=fa6d733125025a6b81bb70caf0f2ac2fd1912335;hp=467ff383bee67704bc12019c5a85b79ffde6e5cb;hb=0bf2fced924400a496fb154be71188864296564c;hpb=3ba82cd7dde22a9ef2c9c094a51ea5df6bcf687e diff --git a/src/edu/berkeley/sbp/misc/Demo.java b/src/edu/berkeley/sbp/misc/Demo.java index 467ff38..fa6d733 100644 --- a/src/edu/berkeley/sbp/misc/Demo.java +++ b/src/edu/berkeley/sbp/misc/Demo.java @@ -148,10 +148,10 @@ public class Demo { argtags[i+ofs] = (bind.arg)a; return Target.this.buildSequence(p, names, argtags); } - private Reflection.Bindable _bindable; + private Bindable _bindable; - public Target(Object o) { this(Reflection.Bindable.create(o)); } - public Target(Reflection.Bindable b) { this._bindable = b; } + public Target(Object o) { this(Bindable.create(o)); } + public Target(Bindable b) { this._bindable = b; } public String getName() { return _bindable.getSimpleName(); } public bind.as getBindAs() { return (bind.as)_bindable.getAnnotation(bind.as.class); } @@ -201,46 +201,44 @@ public class Demo { p.elements, p.labels, p.drops); } - public static class TargetReducer implements Tree.TreeFunctor { - private Production p; - private int[] map; - private String name; - private Reflection.Bindable _bindable; - private boolean _israw; - public TargetReducer(Production p, int[] map, String name, Reflection.Bindable b, boolean raw) { - this.p = p; - this.map = map; - this.name = name; - this._bindable = b; - this._israw = raw; - } - public String toString() { return name; } - public Object invoke(Iterable> t) { - if (_israw) return _bindable.impose(new Object[] { t }); - ArrayList ret = new ArrayList(); - for(Tree tc : t) { - if (tc.head() != null && tc.head() instanceof Functor) - ret.add(((Tree.TreeFunctor)tc.head()).invoke(tc.children())); - else if (tc.numChildren() == 0) - ret.add(tc.head()); - else { - System.err.println("FIXME: don't know what to do about " + tc); - ret.add(null); - } + } + + public static class TargetReducer implements Tree.TreeFunctor { + private int[] map; + private String name; + private Bindable _bindable; + private boolean _israw; + public TargetReducer(Production p, int[] map, String name, Bindable b, boolean raw) { + this.map = map; + this.name = name; + this._bindable = b; + this._israw = raw; + } + public String toString() { return name; } + public Object invoke(Iterable> t) { + if (_israw) return _bindable.impose(new Object[] { t }); + ArrayList ret = new ArrayList(); + for(Tree tc : t) { + if (tc.head() != null && tc.head() instanceof Functor) + ret.add(((Tree.TreeFunctor)tc.head()).invoke(tc.children())); + else if (tc.numChildren() == 0) + ret.add(tc.head()); + else { + System.err.println("FIXME: don't know what to do about " + tc); + ret.add(null); } - System.err.println("input tree: " + t); - Object[] o = (Object[])ret.toArray(new Object[0]); - int max = 0; - for(int i=0; i