Java Code Examples for jdk.nashorn.internal.ir.IdentNode#getName()

The following examples show how to use jdk.nashorn.internal.ir.IdentNode#getName() . 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: Parser.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Make sure that in strict mode, the identifier name used is allowed.
 *
 * @param ident         Identifier that is verified
 * @param contextString String used in error message to give context to the user
 */
private void verifyStrictIdent(final IdentNode ident, final String contextString) {
    if (isStrictMode) {
        switch (ident.getName()) {
        case "eval":
        case "arguments":
            throw error(AbstractParser.message("strict.name", ident.getName(), contextString), ident.getToken());
        default:
            break;
        }

        if (ident.isFutureStrictName()) {
            throw error(AbstractParser.message("strict.name", ident.getName(), contextString), ident.getToken());
        }
    }
}
 
Example 2
Source File: Attr.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean enterCatchNode(final CatchNode catchNode) {
    final IdentNode exception = catchNode.getException();
    final Block     block     = lc.getCurrentBlock();

    start(catchNode);
    catchNestingLevel++;

    // define block-local exception variable
    final String exname = exception.getName();
    final Symbol def = defineSymbol(block, exname, IS_VAR | IS_LET | IS_ALWAYS_DEFINED);
    newType(def, Type.OBJECT); //we can catch anything, not just ecma exceptions

    addLocalDef(exname);

    return true;
}
 
Example 3
Source File: Parser.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Make sure that in strict mode, the identifier name used is allowed.
 *
 * @param ident         Identifier that is verified
 * @param contextString String used in error message to give context to the user
 */
private void verifyStrictIdent(final IdentNode ident, final String contextString) {
    if (isStrictMode) {
        switch (ident.getName()) {
        case "eval":
        case "arguments":
            throw error(AbstractParser.message("strict.name", ident.getName(), contextString), ident.getToken());
        default:
            break;
        }

        if (ident.isFutureStrictName()) {
            throw error(AbstractParser.message("strict.name", ident.getName(), contextString), ident.getToken());
        }
    }
}
 
Example 4
Source File: Parser.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Make sure that in strict mode, the identifier name used is allowed.
 *
 * @param ident         Identifier that is verified
 * @param contextString String used in error message to give context to the user
 */
private void verifyStrictIdent(final IdentNode ident, final String contextString) {
    if (isStrictMode) {
        switch (ident.getName()) {
        case "eval":
        case "arguments":
            throw error(AbstractParser.message("strict.name", ident.getName(), contextString), ident.getToken());
        default:
            break;
        }

        if (ident.isFutureStrictName()) {
            throw error(AbstractParser.message("strict.name", ident.getName(), contextString), ident.getToken());
        }
    }
}
 
Example 5
Source File: Parser.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Make sure that in strict mode, the identifier name used is allowed.
 *
 * @param ident         Identifier that is verified
 * @param contextString String used in error message to give context to the user
 */
private void verifyStrictIdent(final IdentNode ident, final String contextString) {
    if (isStrictMode) {
        switch (ident.getName()) {
        case "eval":
        case "arguments":
            throw error(AbstractParser.message("strict.name", ident.getName(), contextString), ident.getToken());
        default:
            break;
        }

        if (ident.isFutureStrictName()) {
            throw error(AbstractParser.message("strict.name", ident.getName(), contextString), ident.getToken());
        }
    }
}
 
Example 6
Source File: Attr.java    From nashorn with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean enterCatchNode(final CatchNode catchNode) {
    final IdentNode exception = catchNode.getException();
    final Block     block     = lc.getCurrentBlock();

    start(catchNode);
    catchNestingLevel++;

    // define block-local exception variable
    final String exname = exception.getName();
    final Symbol def = defineSymbol(block, exname, IS_VAR | IS_LET | IS_ALWAYS_DEFINED);
    newType(def, Type.OBJECT); //we can catch anything, not just ecma exceptions

    addLocalDef(exname);

    return true;
}
 
Example 7
Source File: AssignSymbols.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean enterCatchNode(final CatchNode catchNode) {
    final IdentNode exception = catchNode.getException();
    final Block     block     = lc.getCurrentBlock();

    start(catchNode);

    // define block-local exception variable
    final String exname = exception.getName();
    // If the name of the exception starts with ":e", this is a synthetic catch block, likely a catch-all. Its
    // symbol is naturally internal, and should be treated as such.
    final boolean isInternal = exname.startsWith(EXCEPTION_PREFIX.symbolName());
    // IS_LET flag is required to make sure symbol is not visible outside catch block. However, we need to
    // clear the IS_LET flag after creation to allow redefinition of symbol inside the catch block.
    final Symbol symbol = defineSymbol(block, exname, catchNode, IS_VAR | IS_LET | (isInternal ? IS_INTERNAL : 0) | HAS_OBJECT_VALUE);
    symbol.clearFlag(IS_LET);

    return true;
}
 
Example 8
Source File: JSONWriter.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterIdentNode(final IdentNode identNode) {
    enterDefault(identNode);

    final String name = identNode.getName();
    if ("this".equals(name)) {
        type("ThisExpression");
    } else {
        type("Identifier");
        comma();
        property("name", identNode.getName());
    }

    return leave();
}
 
Example 9
Source File: Parser.java    From nashorn with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Detect calls to special functions.
 * @param ident Called function.
 */
private void detectSpecialFunction(final IdentNode ident) {
    final String name = ident.getName();

    if (EVAL.symbolName().equals(name)) {
        markEval(lc);
    }
}
 
Example 10
Source File: JSONWriter.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterIdentNode(final IdentNode identNode) {
    enterDefault(identNode);

    final String name = identNode.getName();
    if ("this".equals(name)) {
        type("ThisExpression");
    } else {
        type("Identifier");
        comma();
        property("name", identNode.getName());
    }

    return leave();
}
 
Example 11
Source File: Parser.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Detect calls to special functions.
 * @param ident Called function.
 */
private void detectSpecialFunction(final IdentNode ident) {
    final String name = ident.getName();

    if (EVAL.symbolName().equals(name)) {
        markEval(lc);
    }
}
 
Example 12
Source File: Parser.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Detect calls to special functions.
 * @param ident Called function.
 */
private void detectSpecialFunction(final IdentNode ident) {
    final String name = ident.getName();

    if (EVAL.symbolName().equals(name)) {
        markEval(lc);
    }
}
 
Example 13
Source File: Parser.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Detect calls to special functions.
 * @param ident Called function.
 */
private void detectSpecialFunction(final IdentNode ident) {
    final String name = ident.getName();

    if (EVAL.symbolName().equals(name)) {
        markEval(lc);
    }
}
 
Example 14
Source File: Parser.java    From nashorn with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Make sure that in strict mode, the identifier name used is allowed.
 *
 * @param ident         Identifier that is verified
 * @param contextString String used in error message to give context to the user
 */
private void verifyStrictIdent(final IdentNode ident, final String contextString) {
    if (isStrictMode) {
        switch (ident.getName()) {
        case "eval":
        case "arguments":
            throw error(AbstractParser.message("strict.name", ident.getName(), contextString), ident.getToken());
        default:
            break;
        }
    }
}
 
Example 15
Source File: JSONWriter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterIdentNode(final IdentNode identNode) {
    enterDefault(identNode);

    final String name = identNode.getName();
    if ("this".equals(name)) {
        type("ThisExpression");
    } else {
        type("Identifier");
        comma();
        property("name", identNode.getName());
    }

    return leave();
}
 
Example 16
Source File: JSONWriter.java    From nashorn with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterIdentNode(final IdentNode identNode) {
    enterDefault(identNode);

    final String name = identNode.getName();
    if ("this".equals(name)) {
        type("ThisExpression");
    } else {
        type("Identifier");
        comma();
        property("name", identNode.getName());
    }

    return leave();
}
 
Example 17
Source File: Parser.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Detect calls to special functions.
 * @param ident Called function.
 */
private void detectSpecialFunction(final IdentNode ident) {
    final String name = ident.getName();

    if (EVAL.symbolName().equals(name)) {
        markEval(lc);
    }
}
 
Example 18
Source File: JSONWriter.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterIdentNode(final IdentNode identNode) {
    enterDefault(identNode);

    final String name = identNode.getName();
    if ("this".equals(name)) {
        type("ThisExpression");
    } else {
        type("Identifier");
        comma();
        property("name", identNode.getName());
    }

    return leave();
}
 
Example 19
Source File: Parser.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Detect calls to special functions.
 * @param ident Called function.
 */
private void detectSpecialFunction(final IdentNode ident) {
    final String name = ident.getName();

    if (EVAL.symbolName().equals(name)) {
        markEval(lc);
    }
}
 
Example 20
Source File: Parser.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Detect calls to special functions.
 * @param ident Called function.
 */
private void detectSpecialFunction(final IdentNode ident) {
    final String name = ident.getName();

    if (EVAL.symbolName().equals(name)) {
        markEval(lc);
    }
}