Java Code Examples for jdk.nashorn.internal.ir.Symbol#setType()

The following examples show how to use jdk.nashorn.internal.ir.Symbol#setType() . 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: Attr.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Node leaveReturnNode(final ReturnNode returnNode) {
    final Expression expr = returnNode.getExpression();
    final Type returnType;

    if (expr != null) {
        //we can't do parameter specialization if we return something that hasn't been typed yet
        final Symbol symbol = expr.getSymbol();
        if (expr.getType().isUnknown() && symbol.isParam()) {
            symbol.setType(Type.OBJECT);
        }

        returnType = widestReturnType(returnTypes.pop(), symbol.getSymbolType());
    } else {
        returnType = Type.OBJECT; //undefined
    }
    LOG.info("Returntype is now ", returnType);
    returnTypes.push(returnType);

    end(returnNode);

    return returnNode;
}
 
Example 2
Source File: Attr.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Node leaveReturnNode(final ReturnNode returnNode) {
    final Expression expr = returnNode.getExpression();
    final Type returnType;

    if (expr != null) {
        //we can't do parameter specialization if we return something that hasn't been typed yet
        final Symbol symbol = expr.getSymbol();
        if (expr.getType().isUnknown() && symbol.isParam()) {
            symbol.setType(Type.OBJECT);
        }

        returnType = widestReturnType(returnTypes.pop(), symbol.getSymbolType());
    } else {
        returnType = Type.OBJECT; //undefined
    }
    LOG.info("Returntype is now ", returnType);
    returnTypes.push(returnType);

    end(returnNode);

    return returnNode;
}
 
Example 3
Source File: Attr.java    From nashorn with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Node leaveReturnNode(final ReturnNode returnNode) {
    final Expression expr = returnNode.getExpression();
    final Type returnType;

    if (expr != null) {
        //we can't do parameter specialization if we return something that hasn't been typed yet
        final Symbol symbol = expr.getSymbol();
        if (expr.getType().isUnknown() && symbol.isParam()) {
            symbol.setType(Type.OBJECT);
        }

        returnType = Type.widest(returnTypes.pop(), symbol.getSymbolType());
    } else {
        returnType = Type.OBJECT; //undefined
    }
    LOG.info("Returntype is now ", returnType);
    returnTypes.push(returnType);

    end(returnNode);

    return returnNode;
}
 
Example 4
Source File: Attr.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private static void newType(final Symbol symbol, final Type type) {
    final Type oldType = symbol.getSymbolType();
    symbol.setType(type);

    if (symbol.getSymbolType() != oldType) {
        LOG.info("New TYPE ", type, " for ", symbol," (was ", oldType, ")");
    }

    if (symbol.isParam()) {
        symbol.setType(type);
        LOG.info("Param type change ", symbol);
    }
}
 
Example 5
Source File: CodeGenerator.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Quick symbol generates an extra local variable, always using the same
 * slot, one that is available after the end of the frame.
 *
 * @param type the type of the symbol
 * @param prefix the prefix for the variable name for the symbol
 *
 * @return the quick symbol
 */
private Symbol quickSymbol(final Type type, final String prefix) {
    final String name = lc.getCurrentFunction().uniqueName(prefix);
    final Symbol symbol = new Symbol(name, IS_TEMP | IS_INTERNAL);

    symbol.setType(type);

    symbol.setSlot(lc.quickSlot(symbol));

    return symbol;
}
 
Example 6
Source File: Attr.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void newType(final Symbol symbol, final Type type) {
    final Type oldType = symbol.getSymbolType();
    symbol.setType(type);

    if (symbol.getSymbolType() != oldType) {
        LOG.info("New TYPE ", type, " for ", symbol," (was ", oldType, ")");
    }

    if (symbol.isParam()) {
        symbol.setType(type);
        LOG.info("Param type change ", symbol);
    }
}
 
Example 7
Source File: CodeGenerator.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Quick symbol generates an extra local variable, always using the same
 * slot, one that is available after the end of the frame.
 *
 * @param type the type of the symbol
 * @param prefix the prefix for the variable name for the symbol
 *
 * @return the quick symbol
 */
private Symbol quickSymbol(final Type type, final String prefix) {
    final String name = lc.getCurrentFunction().uniqueName(prefix);
    final Symbol symbol = new Symbol(name, IS_TEMP | IS_INTERNAL);

    symbol.setType(type);

    symbol.setSlot(lc.quickSlot(symbol));

    return symbol;
}
 
Example 8
Source File: Attr.java    From nashorn with GNU General Public License v2.0 5 votes vote down vote up
private static void newType(final Symbol symbol, final Type type) {
    final Type oldType = symbol.getSymbolType();
    symbol.setType(type);

    if (symbol.getSymbolType() != oldType) {
        LOG.info("New TYPE ", type, " for ", symbol," (was ", oldType, ")");
    }

    if (symbol.isParam()) {
        symbol.setType(type);
        LOG.info("Param type change ", symbol);
    }
}
 
Example 9
Source File: CodeGenerator.java    From nashorn with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Quick symbol generates an extra local variable, always using the same
 * slot, one that is available after the end of the frame.
 *
 * @param type the type of the symbol
 * @param prefix the prefix for the variable name for the symbol
 *
 * @return the quick symbol
 */
private Symbol quickSymbol(final Type type, final String prefix) {
    final String name = lc.getCurrentFunction().uniqueName(prefix);
    final Symbol symbol = new Symbol(name, IS_TEMP | IS_INTERNAL);

    symbol.setType(type);

    symbol.setSlot(lc.quickSlot(symbol));

    return symbol;
}
 
Example 10
Source File: Attr.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
private Symbol newInternal(final String name, final Type type) {
    final Symbol iter = defineSymbol(lc.getCurrentBlock(), name, IS_VAR | IS_INTERNAL);
    iter.setType(type); // NASHORN-73
    return iter;
}
 
Example 11
Source File: Attr.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
private Symbol newInternal(final String name, final Type type) {
    final Symbol iter = defineSymbol(lc.getCurrentBlock(), name, IS_VAR | IS_INTERNAL);
    iter.setType(type); // NASHORN-73
    return iter;
}
 
Example 12
Source File: Attr.java    From nashorn with GNU General Public License v2.0 4 votes vote down vote up
private Symbol newInternal(final String name, final Type type) {
    final Symbol iter = defineSymbol(lc.getCurrentBlock(), name, IS_VAR | IS_INTERNAL);
    iter.setType(type); // NASHORN-73
    return iter;
}