gecko-dev/js/js2/java/ControlNode.java

68 lines
1.4 KiB
Java
Raw Normal View History

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);
}
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(""));
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;
}