From 9a51c5df6d121f44c34a60fea128c5da7c3dba87 Mon Sep 17 00:00:00 2001 From: adam Date: Wed, 28 Jun 2006 18:09:24 -0400 Subject: [PATCH] checkpoint darcs-hash:20060628220924-5007d-c2445187f5807325bda5f062bbc4ab45acfac345.gz --- src/edu/berkeley/sbp/misc/Demo.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/edu/berkeley/sbp/misc/Demo.java b/src/edu/berkeley/sbp/misc/Demo.java index 02482fa..9c205d8 100644 --- a/src/edu/berkeley/sbp/misc/Demo.java +++ b/src/edu/berkeley/sbp/misc/Demo.java @@ -70,14 +70,14 @@ public class Demo { Production p = new Production(tag, nonTerminalName, els, labels, drops); for(Method m : _cl.getMethods()) if (new TargetMethod(m).isCompatible(p)) - return Sequence.rewritingSequence(m, els, labels, drops); + return new TargetMethod(m).makeSequence(p); for(Class c : _inner) for(Constructor con : c.getConstructors()) if (new TargetConstructor(con).isCompatible(p)) - return Sequence.rewritingSequence(con, els, labels, drops); + return new TargetConstructor(con).makeSequence(p); for(Class c : _inner) if (new TargetClass(c).isCompatible(p)) - return Sequence.rewritingSequence(c, els, labels, drops); + return new TargetClass(c).makeSequence(p); throw new RuntimeException("could not find a Java method/class/ctor matching tag \""+tag+"\", nonterminal \""+nonTerminalName+"\""); } } @@ -156,6 +156,7 @@ public class Demo { public abstract tag getTag(); public abstract nonterminal getNonTerminal(); public abstract boolean buildSequence(Production p); + public abstract Sequence makeSequence(Production p); public boolean isCompatible(Production p) { tag t = getTag(); if (t != null && @@ -215,6 +216,9 @@ public class Demo { return true; return false; } + public Sequence makeSequence(Production p) { + return Sequence.rewritingSequence(_class, p.elements, p.labels, p.drops); + } } public static class TargetConstructor extends Target { public final Constructor _ctor; @@ -241,6 +245,9 @@ public class Demo { if (ret!=null) return true; return false; } + public Sequence makeSequence(Production p) { + return Sequence.rewritingSequence(_ctor, p.elements, p.labels, p.drops); + } } public static class TargetMethod extends Target { public final Method _method; @@ -260,6 +267,9 @@ public class Demo { if (ret!=null) return true; return false; } + public Sequence makeSequence(Production p) { + return Sequence.rewritingSequence(_method, p.elements, p.labels, p.drops); + } } public class MG { -- 1.7.10.4