@Override
public Object getValue() { return null; }
public void render(RenderContext rc) {
TokenConsumer out = rc.getOut();
out.mark(getFilePosition());
Expression e = getExpression();
if (e instanceof FunctionConstructor
|| e instanceof ObjectConstructor
|| startsWithRegex(e)) {
// We need to parenthesize Object constructors because otherwise an
// object constructor with only one entry:
// { x : 4 }
// is ambiguous. It could be a block containing a labeled expression
// statement, and depending on semicolon insertion.
// We need to parenthesize Function constructors because otherwise
// we might output something like
// function a () {
// ;
// };
// which is interpreted as two statements -- a declaration and a noop for
// the semicolon.
// Rhino fails to parse
// if(...)/foo/.test(x)?bar:baz;
// so we parenthesize operator trees whose left-most operand is a regex
// literal.
out.consume("(");
e.render(rc);
out.consume(")");
} else {
e.render(rc);
}
}