List of usage examples for jdk.nashorn.internal.ir CallNode isNew
public boolean isNew()
From source file:edu.brown.cs.bubbles.nobase.NobaseNashorn.java
License:Open Source License
/********************************************************************************/ private static NashornAstNode createNashornAstNode(Node pn, NashornAstNode par) { if (pn == null) return null; NashornAstNode rslt = null;//from w w w .ja v a 2s. com if (pn instanceof LiteralNode.ArrayLiteralNode) { rslt = new NashornAstArrayConstructor(pn, par); } else if (pn instanceof BinaryNode) { BinaryNode bin = (BinaryNode) pn; switch (bin.tokenType()) { case COMMALEFT: case COMMARIGHT: rslt = new NashornAstCommaOperation(pn, par); break; case AND: case OR: rslt = new NashornAstControlOperation(pn, par); break; case DELETE: rslt = new NashornAstDeleteOperation(pn, par); break; case IN: rslt = new NashornAstInOperation(pn, par); break; default: break; } if (rslt == null && bin.isAssignment()) { rslt = new NashornAstAssignOperation(pn, par); } else if (rslt == null) { rslt = new NashornAstSimpleOperation(pn, par); } } else if (pn instanceof UnaryNode) { UnaryNode uny = (UnaryNode) pn; switch (uny.tokenType()) { case TYPEOF: rslt = new NashornAstTypeofOperation(pn, par); break; case VOID: rslt = new NashornAstVoidOperation(pn, par); break; default: break; } if (rslt == null) { rslt = new NashornAstSimpleOperation(pn, par); } } else if (pn instanceof TernaryNode) { rslt = new NashornAstSimpleOperation(pn, par); } else if (pn instanceof AccessNode) { return new NashornAstMemberAccess(pn, par); } else if (pn instanceof Block) { if (par instanceof NashornAstSwitchStatement) { NashornAstNode npar = new NashornAstFinallyStatement(pn, par); rslt = new NashornAstBlock(pn, npar); } else rslt = new NashornAstBlock(pn, par); } else if (pn instanceof BlockStatement) { BlockStatement bs = (BlockStatement) pn; rslt = new NashornAstBlock(bs.getBlock(), par); } else if (pn instanceof BreakNode) { rslt = new NashornAstBreakStatement(pn, par); } else if (pn instanceof CallNode) { CallNode cn = (CallNode) pn; if (cn.isNew()) rslt = new NashornAstConstructorCall(pn, par); else rslt = new NashornAstFunctionCall(pn, par); } else if (pn instanceof CaseNode) { CaseNode cn = (CaseNode) pn; if (cn.getTest() == null) rslt = new NashornAstDefaultCaseStatement(pn, par); else rslt = new NashornAstCaseStatement(pn, par); } else if (pn instanceof CatchNode) { rslt = new NashornAstCatchStatement(pn, par); } else if (pn instanceof ContinueNode) { rslt = new NashornAstContinueStatement(pn, par); } else if (pn instanceof EmptyNode) { rslt = new NashornAstNoopStatement(pn, par); } else if (pn instanceof ExpressionStatement) { rslt = new NashornAstExpressionStatement(pn, par); } else if (pn instanceof ForNode) { ForNode fn = (ForNode) pn; if (fn.isForEach() || fn.isForIn()) { rslt = new NashornAstForEachLoop(pn, par); } else rslt = new NashornAstForLoop(pn, par); } else if (pn instanceof FunctionNode) { rslt = new NashornAstFunctionConstructor(pn, par); } else if (pn instanceof IdentNode) { rslt = new NashornAstIdentifier(pn, par); } else if (pn instanceof IndexNode) { rslt = new NashornAstArrayIndex(pn, par); } else if (pn instanceof IfNode) { rslt = new NashornAstIfStatement(pn, par); } else if (pn instanceof LabelNode) { rslt = new NashornAstLabeledStatement(pn, par); } else if (pn instanceof LiteralNode) { LiteralNode<?> ln = (LiteralNode<?>) pn; if (ln.isNull()) { rslt = new NashornAstNullLiteral(pn, par); } else if (ln.isString()) { rslt = new NashornAstStringLiteral(pn, par); } else if (ln.getValue() instanceof Boolean) { rslt = new NashornAstBooleanLiteral(pn, par); } else if (ln.getValue() instanceof Long || ln.getValue() instanceof Integer) { rslt = new NashornAstIntegerLiteral(pn, par); } else if (ln.isNumeric()) { rslt = new NashornAstRealLiteral(pn, par); } else if (ln.getValue() instanceof Lexer.RegexToken) { rslt = new NashornAstRegexpLiteral(pn, par); } // handle regex } else if (pn instanceof ObjectNode) { rslt = new NashornAstObjectConstructor(pn, par); } else if (pn instanceof PropertyNode) { PropertyNode prop = (PropertyNode) pn; // getter/etter might not be correct if (prop.getGetter() != null) { rslt = new NashornAstGetterProperty(pn, par); } else if (prop.getSetter() != null) { rslt = new NashornAstSetterProperty(pn, par); } else rslt = new NashornAstValueProperty(pn, par); } else if (pn instanceof ReturnNode) { rslt = new NashornAstReturnStatement(pn, par); } else if (pn instanceof SwitchNode) { rslt = new NashornAstSwitchStatement(pn, par); } else if (pn instanceof ThrowNode) { rslt = new NashornAstThrowStatement(pn, par); } else if (pn instanceof TryNode) { rslt = new NashornAstTryStatement(pn, par); } else if (pn instanceof VarNode) { rslt = new NashornAstDeclaration(pn, par); } else if (pn instanceof WhileNode) { WhileNode wn = (WhileNode) pn; if (wn.isDoWhile()) rslt = new NashornAstDoWhileLoop(pn, par); else rslt = new NashornAstWhileLoop(pn, par); } else if (pn instanceof WithNode) { rslt = new NashornAstWithStatement(pn, par); } if (rslt == null) { System.err.println("UNKNOWN AST: " + pn); } return rslt; }