use of org.mozilla.javascript.ast.NewExpression in project HL4A by HL4A.
the class Parser method memberExpr.
/**
* Parse a new-expression, or if next token isn't {@link Token#NEW},
* a primary expression.
* @param allowCallSyntax passed down to {@link #memberExprTail}
*/
private AstNode memberExpr(boolean allowCallSyntax) throws IOException {
int tt = peekToken(), lineno = ts.lineno;
AstNode pn;
if (tt != Token.NEW) {
pn = primaryExpr();
} else {
consumeToken();
int pos = ts.tokenBeg;
NewExpression nx = new NewExpression(pos);
AstNode target = memberExpr(false);
int end = getNodeEnd(target);
nx.setTarget(target);
int lp = -1;
if (matchToken(Token.LP)) {
lp = ts.tokenBeg;
List<AstNode> args = argumentList();
if (args != null && args.size() > ARGC_LIMIT)
reportError("msg.too.many.constructor.args");
int rp = ts.tokenBeg;
end = ts.tokenEnd;
if (args != null)
nx.setArguments(args);
nx.setParens(lp - pos, rp - pos);
}
// additional argument to the constructor.
if (matchToken(Token.LC)) {
ObjectLiteral initializer = objectLiteral();
end = getNodeEnd(initializer);
nx.setInitializer(initializer);
}
nx.setLength(end - pos);
pn = nx;
}
pn.setLineno(lineno);
AstNode tail = memberExprTail(allowCallSyntax, pn);
return tail;
}
use of org.mozilla.javascript.ast.NewExpression in project st-js by st-js.
the class RhinoJavaScriptBuilder method newExpression.
/**
* {@inheritDoc}
*/
@Override
public AstNode newExpression(AstNode target, Iterable<AstNode> arguments) {
NewExpression ne = new NewExpression();
ne.setTarget(target);
if (!Iterables.isEmpty(arguments)) {
ne.setArguments(list(arguments));
}
return ne;
}
Aggregations