1999-05-07 22:18:39 +00:00
|
|
|
|
|
|
|
import java.util.Vector;
|
|
|
|
|
|
|
|
class ControlNode {
|
|
|
|
|
|
|
|
private static Vector gList = new Vector();
|
|
|
|
|
|
|
|
static String printAll()
|
|
|
|
{
|
|
|
|
StringBuffer result = new StringBuffer();
|
|
|
|
for (int i = 0; i < gList.size(); i++) {
|
|
|
|
result.append(((ControlNode)(gList.elementAt(i))).print());
|
|
|
|
}
|
|
|
|
return result.toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
ControlNode(ExpressionNode anExpr)
|
|
|
|
{
|
|
|
|
expr = anExpr;
|
|
|
|
index = gList.size();
|
|
|
|
gList.addElement(this);
|
|
|
|
}
|
|
|
|
|
1999-05-18 22:49:59 +00:00
|
|
|
ExpressionNode getExpression()
|
|
|
|
{
|
|
|
|
return expr;
|
|
|
|
}
|
|
|
|
|
1999-05-07 22:18:39 +00:00
|
|
|
void setNext(ControlNode aNext)
|
|
|
|
{
|
|
|
|
next = aNext;
|
|
|
|
}
|
|
|
|
|
|
|
|
ControlNode eval(Environment theEnv)
|
|
|
|
{
|
1999-06-11 00:21:26 +00:00
|
|
|
if (expr != null) theEnv.resultValue = expr.eval(theEnv);
|
1999-05-07 22:18:39 +00:00
|
|
|
return next;
|
|
|
|
}
|
|
|
|
|
|
|
|
String print()
|
|
|
|
{
|
1999-05-21 00:54:26 +00:00
|
|
|
StringBuffer result = new StringBuffer(getClass().toString().substring(6));
|
|
|
|
result.append(" #");
|
1999-05-07 22:18:39 +00:00
|
|
|
result.append(index);
|
1999-05-21 00:54:26 +00:00
|
|
|
result.append("\nexpr: \n");
|
1999-05-07 22:18:39 +00:00
|
|
|
if (expr == null)
|
|
|
|
result.append("expr = null\n");
|
|
|
|
else
|
|
|
|
result.append(expr.print(""));
|
1999-05-18 22:49:59 +00:00
|
|
|
result.append("next: ");
|
1999-05-07 22:18:39 +00:00
|
|
|
if (next == null)
|
|
|
|
result.append("next = null\n");
|
|
|
|
else
|
|
|
|
result.append("next->" + next.index + "\n");
|
|
|
|
return result.toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected ExpressionNode expr;
|
|
|
|
protected ControlNode next;
|
|
|
|
protected int index;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|