From 9de26508819cdf8d1104b5f8ccd004a6c4d1c45c Mon Sep 17 00:00:00 2001 From: adam Date: Tue, 4 Jul 2006 22:48:59 -0400 Subject: [PATCH] checkpoint darcs-hash:20060705024859-5007d-2cfd69a4bb9894bf5f2beae8ef8e07843987a474.gz --- src/edu/berkeley/sbp/misc/Demo.java | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/src/edu/berkeley/sbp/misc/Demo.java b/src/edu/berkeley/sbp/misc/Demo.java index 08a8a89..8a3b793 100644 --- a/src/edu/berkeley/sbp/misc/Demo.java +++ b/src/edu/berkeley/sbp/misc/Demo.java @@ -88,15 +88,15 @@ public class Demo { public Sequence tryResolveTag(String tag, String nonTerminalName, Element[] els, Object[] labels, boolean[] drops) { Production p = new Production(tag, nonTerminalName, els, labels, drops); for(Method m : _cl.getMethods()) - if (new TargetMethod(m).isCompatible(p)) - return new TargetMethod(m).makeSequence(p); + if (new Target(m).isCompatible(p)) + return new Target(m).makeSequence(p); for(Class c : _inner) for(Constructor con : c.getConstructors()) - if (new TargetConstructor(con).isCompatible(p)) - return new TargetConstructor(con).makeSequence(p); + if (new Target(con).isCompatible(p)) + return new Target(con).makeSequence(p); for(Class c : _inner) - if (new TargetClass(c).isCompatible(p)) - return new TargetClass(c).makeSequence(p); + if (new Target(c).isCompatible(p)) + return new Target(c).makeSequence(p); return null; } public Sequence resolveTag(String tag, String nonTerminalName, Element[] els, Object[] labels, boolean[] drops) { @@ -179,7 +179,7 @@ public class Demo { } } - public static abstract class Target { + public static class Target { public int[] buildSequence(Production p) { Annotation[][] annotations = _bindable.getArgAnnotations(); String[] names = _bindable.getArgNames(); @@ -194,6 +194,8 @@ public class Demo { return Target.this.buildSequence(p, names, argtags); } private Reflection.Bindable _bindable; + + public Target(Object o) { this(Reflection.Bindable.create(o)); } public Target(Reflection.Bindable b) { this._bindable = b; } public String getName() { return _bindable.getSimpleName(); } @@ -280,20 +282,6 @@ public class Demo { } } - public static class TargetClass extends Target { - public final Class _class; - public TargetClass(Class _class) { super(Reflection.Bindable.create(_class)); this._class = _class; } - } - - public static class TargetConstructor extends Target { - public final Constructor _ctor; - public TargetConstructor(Constructor _ctor) { super(Reflection.Bindable.create(_ctor)); this._ctor = _ctor; } - } - public static class TargetMethod extends Target { - public final Method _method; - public TargetMethod(Method _method) { super(Reflection.Bindable.create(_method)); this._method = _method; } - } - public static Union cached = null; public static Union make() { if (cached != null) return cached; -- 1.7.10.4