Java Code Examples for jdk.nashorn.internal.ir.UnaryNode#getExpression()

The following examples show how to use jdk.nashorn.internal.ir.UnaryNode#getExpression() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AssignSymbols.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private Node leaveTYPEOF(final UnaryNode unaryNode) {
    final Expression rhs = unaryNode.getExpression();

    final List<Expression> args = new ArrayList<>();
    if (rhs instanceof IdentNode && !isParamOrVar((IdentNode)rhs)) {
        args.add(compilerConstantIdentifier(SCOPE));
        args.add(LiteralNode.newInstance(rhs, ((IdentNode)rhs).getName())); //null
    } else {
        args.add(rhs);
        args.add(LiteralNode.newInstance(unaryNode)); //null, do not reuse token of identifier rhs, it can be e.g. 'this'
    }

    final Node runtimeNode = new RuntimeNode(unaryNode, Request.TYPEOF, args);

    end(unaryNode);

    return runtimeNode;
}
 
Example 2
Source File: AssignSymbols.java    From jdk8u_nashorn with GNU General Public License v2.0 6 votes vote down vote up
private Node leaveTYPEOF(final UnaryNode unaryNode) {
    final Expression rhs = unaryNode.getExpression();

    final List<Expression> args = new ArrayList<>();
    if (rhs instanceof IdentNode && !isParamOrVar((IdentNode)rhs)) {
        args.add(compilerConstantIdentifier(SCOPE));
        args.add(LiteralNode.newInstance(rhs, ((IdentNode)rhs).getName())); //null
    } else {
        args.add(rhs);
        args.add(LiteralNode.newInstance(unaryNode)); //null, do not reuse token of identifier rhs, it can be e.g. 'this'
    }

    final Node runtimeNode = new RuntimeNode(unaryNode, Request.TYPEOF, args);

    end(unaryNode);

    return runtimeNode;
}
 
Example 3
Source File: AssignSymbols.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private Node leaveTYPEOF(final UnaryNode unaryNode) {
    final Expression rhs = unaryNode.getExpression();

    final List<Expression> args = new ArrayList<>();
    if (rhs instanceof IdentNode && !isParamOrVar((IdentNode)rhs)) {
        args.add(compilerConstantIdentifier(SCOPE));
        args.add(LiteralNode.newInstance(rhs, ((IdentNode)rhs).getName())); //null
    } else {
        args.add(rhs);
        args.add(LiteralNode.newInstance(unaryNode)); //null, do not reuse token of identifier rhs, it can be e.g. 'this'
    }

    final Node runtimeNode = new RuntimeNode(unaryNode, Request.TYPEOF, args);

    end(unaryNode);

    return runtimeNode;
}
 
Example 4
Source File: AssignSymbols.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private Node leaveTYPEOF(final UnaryNode unaryNode) {
    final Expression rhs = unaryNode.getExpression();

    final List<Expression> args = new ArrayList<>();
    if (rhs instanceof IdentNode && !isParamOrVar((IdentNode)rhs)) {
        args.add(compilerConstantIdentifier(SCOPE));
        args.add(LiteralNode.newInstance(rhs, ((IdentNode)rhs).getName())); //null
    } else {
        args.add(rhs);
        args.add(LiteralNode.newInstance(unaryNode)); //null, do not reuse token of identifier rhs, it can be e.g. 'this'
    }

    final Node runtimeNode = new RuntimeNode(unaryNode, Request.TYPEOF, args);

    end(unaryNode);

    return runtimeNode;
}
 
Example 5
Source File: AssignSymbols.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private Node leaveTYPEOF(final UnaryNode unaryNode) {
    final Expression rhs = unaryNode.getExpression();

    final List<Expression> args = new ArrayList<>();
    if (rhs instanceof IdentNode && !isParamOrVar((IdentNode)rhs)) {
        args.add(compilerConstantIdentifier(SCOPE));
        args.add(LiteralNode.newInstance(rhs, ((IdentNode)rhs).getName())); //null
    } else {
        args.add(rhs);
        args.add(LiteralNode.newInstance(unaryNode)); //null, do not reuse token of identifier rhs, it can be e.g. 'this'
    }

    final Node runtimeNode = new RuntimeNode(unaryNode, Request.TYPEOF, args);

    end(unaryNode);

    return runtimeNode;
}
 
Example 6
Source File: AssignSymbols.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private Node leaveTYPEOF(final UnaryNode unaryNode) {
    final Expression rhs = unaryNode.getExpression();

    final List<Expression> args = new ArrayList<>();
    if (rhs instanceof IdentNode && !isParamOrVar((IdentNode)rhs)) {
        args.add(compilerConstantIdentifier(SCOPE));
        args.add((Expression)LiteralNode.newInstance(rhs, ((IdentNode)rhs).getName()).accept(this)); //null
    } else {
        args.add(rhs);
        args.add((Expression)LiteralNode.newInstance(unaryNode).accept(this)); //null, do not reuse token of identifier rhs, it can be e.g. 'this'
    }

    final Node runtimeNode = new RuntimeNode(unaryNode, Request.TYPEOF, args).accept(this);

    end(unaryNode);

    return runtimeNode;
}
 
Example 7
Source File: AssignSymbols.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private Node leaveTYPEOF(final UnaryNode unaryNode) {
    final Expression rhs = unaryNode.getExpression();

    final List<Expression> args = new ArrayList<>();
    if (rhs instanceof IdentNode && !isParamOrVar((IdentNode)rhs)) {
        args.add(compilerConstantIdentifier(SCOPE));
        args.add(LiteralNode.newInstance(rhs, ((IdentNode)rhs).getName())); //null
    } else {
        args.add(rhs);
        args.add(LiteralNode.newInstance(unaryNode)); //null, do not reuse token of identifier rhs, it can be e.g. 'this'
    }

    final Node runtimeNode = new RuntimeNode(unaryNode, Request.TYPEOF, args);

    end(unaryNode);

    return runtimeNode;
}
 
Example 8
Source File: LocalVariableTypesCalculator.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterUnaryNode(final UnaryNode unaryNode) {
    final Expression expr = unaryNode.getExpression();
    final LvarType unaryType = toLvarType(unaryNode.setExpression(visitExpression(expr).typeExpression).getType());
    if(unaryNode.isSelfModifying() && expr instanceof IdentNode) {
        onSelfAssignment((IdentNode)expr, unaryType);
    }
    typeStack.push(unaryType);
    return false;
}
 
Example 9
Source File: LocalVariableTypesCalculator.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterUnaryNode(final UnaryNode unaryNode) {
    final Expression expr = unaryNode.getExpression();
    final LvarType unaryType = toLvarType(unaryNode.setExpression(visitExpression(expr).typeExpression).getType());
    if(unaryNode.isSelfModifying() && expr instanceof IdentNode) {
        onSelfAssignment((IdentNode)expr, unaryType);
    }
    typeStack.push(unaryType);
    return false;
}
 
Example 10
Source File: LocalVariableTypesCalculator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterUnaryNode(final UnaryNode unaryNode) {
    final Expression expr = unaryNode.getExpression();
    final LvarType unaryType = toLvarType(unaryNode.setExpression(visitExpression(expr).typeExpression).getType());
    if(unaryNode.isSelfModifying() && expr instanceof IdentNode) {
        onSelfAssignment((IdentNode)expr, unaryType);
    }
    typeStack.push(unaryType);
    return false;
}
 
Example 11
Source File: LocalVariableTypesCalculator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterUnaryNode(final UnaryNode unaryNode) {
    final Expression expr = unaryNode.getExpression();
    final LvarType unaryType = toLvarType(unaryNode.setExpression(visitExpression(expr).typeExpression).getType());
    if(unaryNode.isSelfModifying() && expr instanceof IdentNode) {
        onSelfAssignment((IdentNode)expr, unaryType);
    }
    typeStack.push(unaryType);
    return false;
}
 
Example 12
Source File: LocalVariableTypesCalculator.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterUnaryNode(final UnaryNode unaryNode) {
    final Expression expr = unaryNode.getExpression();
    final LvarType unaryType = toLvarType(unaryNode.setExpression(visitExpression(expr).typeExpression).getType());
    if(unaryNode.isSelfModifying() && expr instanceof IdentNode) {
        onSelfAssignment((IdentNode)expr, unaryType);
    }
    typeStack.push(unaryType);
    return false;
}
 
Example 13
Source File: LocalVariableTypesCalculator.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterUnaryNode(final UnaryNode unaryNode) {
    final Expression expr = unaryNode.getExpression();
    final LvarType unaryType = toLvarType(unaryNode.setExpression(visitExpression(expr).typeExpression).getType());
    if(unaryNode.isSelfModifying() && expr instanceof IdentNode) {
        onSelfAssignment((IdentNode)expr, unaryType);
    }
    typeStack.push(unaryType);
    return false;
}
 
Example 14
Source File: JSONWriter.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean enterUnaryNode(final UnaryNode unaryNode) {
    enterDefault(unaryNode);

    final TokenType tokenType = unaryNode.tokenType();
    if (tokenType == TokenType.NEW) {
        type("NewExpression");
        comma();

        final CallNode callNode = (CallNode)unaryNode.getExpression();
        property("callee");
        callNode.getFunction().accept(this);
        comma();

        array("arguments", callNode.getArgs());
    } else {
        final String operator;
        final boolean prefix;
        switch (tokenType) {
        case INCPOSTFIX:
            prefix = false;
            operator = "++";
            break;
        case DECPOSTFIX:
            prefix = false;
            operator = "--";
            break;
        case INCPREFIX:
            operator = "++";
            prefix = true;
            break;
        case DECPREFIX:
            operator = "--";
            prefix = true;
            break;
        default:
            prefix = true;
            operator = tokenType.getName();
            break;
        }

        type(unaryNode.isAssignment()? "UpdateExpression" : "UnaryExpression");
        comma();

        property("operator", operator);
        comma();

        property("prefix", prefix);
        comma();

        property("argument");
        unaryNode.getExpression().accept(this);
    }

    return leave();
}
 
Example 15
Source File: JSONWriter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean enterUnaryNode(final UnaryNode unaryNode) {
    enterDefault(unaryNode);

    final TokenType tokenType = unaryNode.tokenType();
    if (tokenType == TokenType.NEW) {
        type("NewExpression");
        comma();

        final CallNode callNode = (CallNode)unaryNode.getExpression();
        property("callee");
        callNode.getFunction().accept(this);
        comma();

        array("arguments", callNode.getArgs());
    } else {
        final String operator;
        final boolean prefix;
        switch (tokenType) {
        case INCPOSTFIX:
            prefix = false;
            operator = "++";
            break;
        case DECPOSTFIX:
            prefix = false;
            operator = "--";
            break;
        case INCPREFIX:
            operator = "++";
            prefix = true;
            break;
        case DECPREFIX:
            operator = "--";
            prefix = true;
            break;
        default:
            prefix = true;
            operator = tokenType.getName();
            break;
        }

        type(unaryNode.isAssignment()? "UpdateExpression" : "UnaryExpression");
        comma();

        property("operator", operator);
        comma();

        property("prefix", prefix);
        comma();

        property("argument");
        unaryNode.getExpression().accept(this);
    }

    return leave();
}
 
Example 16
Source File: JSONWriter.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean enterUnaryNode(final UnaryNode unaryNode) {
    enterDefault(unaryNode);

    final TokenType tokenType = unaryNode.tokenType();
    if (tokenType == TokenType.NEW) {
        type("NewExpression");
        comma();

        final CallNode callNode = (CallNode)unaryNode.getExpression();
        property("callee");
        callNode.getFunction().accept(this);
        comma();

        array("arguments", callNode.getArgs());
    } else {
        final String operator;
        final boolean prefix;
        switch (tokenType) {
        case INCPOSTFIX:
            prefix = false;
            operator = "++";
            break;
        case DECPOSTFIX:
            prefix = false;
            operator = "--";
            break;
        case INCPREFIX:
            operator = "++";
            prefix = true;
            break;
        case DECPREFIX:
            operator = "--";
            prefix = true;
            break;
        default:
            prefix = true;
            operator = tokenType.getName();
            break;
        }

        type(unaryNode.isAssignment()? "UpdateExpression" : "UnaryExpression");
        comma();

        property("operator", operator);
        comma();

        property("prefix", prefix);
        comma();

        property("argument");
        unaryNode.getExpression().accept(this);
    }

    return leave();
}
 
Example 17
Source File: JSONWriter.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean enterUnaryNode(final UnaryNode unaryNode) {
    enterDefault(unaryNode);

    final TokenType tokenType = unaryNode.tokenType();
    if (tokenType == TokenType.NEW) {
        type("NewExpression");
        comma();

        final CallNode callNode = (CallNode)unaryNode.getExpression();
        property("callee");
        callNode.getFunction().accept(this);
        comma();

        array("arguments", callNode.getArgs());
    } else {
        final String operator;
        final boolean prefix;
        switch (tokenType) {
        case INCPOSTFIX:
            prefix = false;
            operator = "++";
            break;
        case DECPOSTFIX:
            prefix = false;
            operator = "--";
            break;
        case INCPREFIX:
            operator = "++";
            prefix = true;
            break;
        case DECPREFIX:
            operator = "--";
            prefix = true;
            break;
        default:
            prefix = true;
            operator = tokenType.getName();
            break;
        }

        type(unaryNode.isAssignment()? "UpdateExpression" : "UnaryExpression");
        comma();

        property("operator", operator);
        comma();

        property("prefix", prefix);
        comma();

        property("argument");
        unaryNode.getExpression().accept(this);
    }

    return leave();
}
 
Example 18
Source File: JSONWriter.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean enterUnaryNode(final UnaryNode unaryNode) {
    enterDefault(unaryNode);

    final TokenType tokenType = unaryNode.tokenType();
    if (tokenType == TokenType.NEW) {
        type("NewExpression");
        comma();

        final CallNode callNode = (CallNode)unaryNode.getExpression();
        property("callee");
        callNode.getFunction().accept(this);
        comma();

        array("arguments", callNode.getArgs());
    } else {
        final String operator;
        final boolean prefix;
        switch (tokenType) {
        case INCPOSTFIX:
            prefix = false;
            operator = "++";
            break;
        case DECPOSTFIX:
            prefix = false;
            operator = "--";
            break;
        case INCPREFIX:
            operator = "++";
            prefix = true;
            break;
        case DECPREFIX:
            operator = "--";
            prefix = true;
            break;
        default:
            prefix = true;
            operator = tokenType.getName();
            break;
        }

        type(unaryNode.isAssignment()? "UpdateExpression" : "UnaryExpression");
        comma();

        property("operator", operator);
        comma();

        property("prefix", prefix);
        comma();

        property("argument");
        unaryNode.getExpression().accept(this);
    }

    return leave();
}
 
Example 19
Source File: JSONWriter.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean enterUnaryNode(final UnaryNode unaryNode) {
    enterDefault(unaryNode);

    final TokenType tokenType = unaryNode.tokenType();
    if (tokenType == TokenType.NEW) {
        type("NewExpression");
        comma();

        final CallNode callNode = (CallNode)unaryNode.getExpression();
        property("callee");
        callNode.getFunction().accept(this);
        comma();

        array("arguments", callNode.getArgs());
    } else {
        final String operator;
        final boolean prefix;
        switch (tokenType) {
        case INCPOSTFIX:
            prefix = false;
            operator = "++";
            break;
        case DECPOSTFIX:
            prefix = false;
            operator = "--";
            break;
        case INCPREFIX:
            operator = "++";
            prefix = true;
            break;
        case DECPREFIX:
            operator = "--";
            prefix = true;
            break;
        default:
            prefix = true;
            operator = tokenType.getName();
            break;
        }

        type(unaryNode.isAssignment()? "UpdateExpression" : "UnaryExpression");
        comma();

        property("operator", operator);
        comma();

        property("prefix", prefix);
        comma();

        property("argument");
        unaryNode.getExpression().accept(this);
    }

    return leave();
}
 
Example 20
Source File: JSONWriter.java    From jdk8u_nashorn with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean enterUnaryNode(final UnaryNode unaryNode) {
    enterDefault(unaryNode);

    final TokenType tokenType = unaryNode.tokenType();
    if (tokenType == TokenType.NEW) {
        type("NewExpression");
        comma();

        final CallNode callNode = (CallNode)unaryNode.getExpression();
        property("callee");
        callNode.getFunction().accept(this);
        comma();

        array("arguments", callNode.getArgs());
    } else {
        final String operator;
        final boolean prefix;
        switch (tokenType) {
        case INCPOSTFIX:
            prefix = false;
            operator = "++";
            break;
        case DECPOSTFIX:
            prefix = false;
            operator = "--";
            break;
        case INCPREFIX:
            operator = "++";
            prefix = true;
            break;
        case DECPREFIX:
            operator = "--";
            prefix = true;
            break;
        default:
            prefix = true;
            operator = tokenType.getName();
            break;
        }

        type(unaryNode.isAssignment()? "UpdateExpression" : "UnaryExpression");
        comma();

        property("operator", operator);
        comma();

        property("prefix", prefix);
        comma();

        property("argument");
        unaryNode.getExpression().accept(this);
    }

    return leave();
}