jdk.nashorn.internal.runtime.regexp.joni.constants.OPCode Java Examples

The following examples show how to use jdk.nashorn.internal.runtime.regexp.joni.constants.OPCode. 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: ArrayCompiler.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void compileOptionNode(final EncloseNode node) {
    final int prev = regex.options;

    if (isDynamic(prev ^ node.option)) {
        addOpcodeOption(OPCode.SET_OPTION_PUSH, node.option);
        addOpcodeOption(OPCode.SET_OPTION, prev);
        addOpcode(OPCode.FAIL);
    }

    regex.options = node.option;
    compileTree(node.target);
    regex.options = prev;

    if (isDynamic(prev ^ node.option)) {
        addOpcodeOption(OPCode.SET_OPTION, prev);
    }
}
 
Example #2
Source File: ArrayCompiler.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private static int selectStrOpcode(final int strLength, final boolean ignoreCase) {
    int op;

    if (ignoreCase) {
        switch(strLength) {
        case 1: op = OPCode.EXACT1_IC; break;
        default:op = OPCode.EXACTN_IC; break;
        } // switch
    } else {
        switch (strLength) {
        case 1: op = OPCode.EXACT1; break;
        case 2: op = OPCode.EXACT2; break;
        case 3: op = OPCode.EXACT3; break;
        case 4: op = OPCode.EXACT4; break;
        case 5: op = OPCode.EXACT5; break;
        default:op = OPCode.EXACTN; break;
        } // inner switch
    }
    return op;
}
 
Example #3
Source File: ArrayCompiler.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void compileOptionNode(EncloseNode node) {
    int prev = regex.options;

    if (isDynamic(prev ^ node.option)) {
        addOpcodeOption(OPCode.SET_OPTION_PUSH, node.option);
        addOpcodeOption(OPCode.SET_OPTION, prev);
        addOpcode(OPCode.FAIL);
    }

    regex.options = node.option;
    compileTree(node.target);
    regex.options = prev;

    if (isDynamic(prev ^ node.option)) {
        addOpcodeOption(OPCode.SET_OPTION, prev);
    }
}
 
Example #4
Source File: ByteCodeMachine.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private void nullCheckFound() {
    // null_check_found:
    /* empty loop founded, skip next instruction */
    switch(code[ip++]) {
    case OPCode.JUMP:
    case OPCode.PUSH:
        ip++;       // p += SIZE_RELADDR;
        break;
    case OPCode.REPEAT_INC:
    case OPCode.REPEAT_INC_NG:
    case OPCode.REPEAT_INC_SG:
    case OPCode.REPEAT_INC_NG_SG:
        ip++;        // p += SIZE_MEMNUM;
        break;
    default:
        throw new InternalException(ErrorMessages.ERR_UNEXPECTED_BYTECODE);
    } // switch
}
 
Example #5
Source File: ArrayCompiler.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private void compileTreeEmptyCheck(final Node node, final int emptyInfo) {
    final int savedNumNullCheck = regex.numNullCheck;

    if (emptyInfo != 0) {
        addOpcode(OPCode.NULL_CHECK_START);
        addMemNum(regex.numNullCheck); /* NULL CHECK ID */
        regex.numNullCheck++;
    }

    compileTree(node);

    if (emptyInfo != 0) {
        switch (emptyInfo) {
        case TargetInfo.IS_EMPTY:
            addOpcode(OPCode.NULL_CHECK_END);
            break;
        case TargetInfo.IS_EMPTY_MEM:
            addOpcode(OPCode.NULL_CHECK_END_MEMST);
            break;
        default:
            break;
        } // switch

        addMemNum(savedNumNullCheck); /* NULL CHECK ID */
    }
}
 
Example #6
Source File: ArrayCompiler.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void compileBackrefNode(final BackRefNode node) {
    if (isIgnoreCase(regex.options)) {
        addOpcode(OPCode.BACKREFN_IC);
        addMemNum(node.backRef);
    } else {
        switch (node.backRef) {
            case 1:
                addOpcode(OPCode.BACKREF1);
                break;
            case 2:
                addOpcode(OPCode.BACKREF2);
                break;
            default:
                addOpcode(OPCode.BACKREFN);
                addOpcode(node.backRef);
                break;
        } // switch
    }
}
 
Example #7
Source File: ArrayCompiler.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private static int selectStrOpcode(final int strLength, final boolean ignoreCase) {
    int op;

    if (ignoreCase) {
        switch(strLength) {
        case 1: op = OPCode.EXACT1_IC; break;
        default:op = OPCode.EXACTN_IC; break;
        } // switch
    } else {
        switch (strLength) {
        case 1: op = OPCode.EXACT1; break;
        case 2: op = OPCode.EXACT2; break;
        case 3: op = OPCode.EXACT3; break;
        case 4: op = OPCode.EXACT4; break;
        case 5: op = OPCode.EXACT5; break;
        default:op = OPCode.EXACTN; break;
        } // inner switch
    }
    return op;
}
 
Example #8
Source File: ArrayCompiler.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private int selectStrOpcode(int strLength, boolean ignoreCase) {
    int op;

    if (ignoreCase) {
        switch(strLength) {
        case 1: op = OPCode.EXACT1_IC; break;
        default:op = OPCode.EXACTN_IC; break;
        } // switch
    } else {
        switch (strLength) {
        case 1: op = OPCode.EXACT1; break;
        case 2: op = OPCode.EXACT2; break;
        case 3: op = OPCode.EXACT3; break;
        case 4: op = OPCode.EXACT4; break;
        case 5: op = OPCode.EXACT5; break;
        default:op = OPCode.EXACTN; break;
        } // inner switch
    }
    return op;
}
 
Example #9
Source File: ArrayCompiler.java    From jdk8u_nashorn with GNU General Public License v2.0 6 votes vote down vote up
private static int selectStrOpcode(final int strLength, final boolean ignoreCase) {
    int op;

    if (ignoreCase) {
        switch(strLength) {
        case 1: op = OPCode.EXACT1_IC; break;
        default:op = OPCode.EXACTN_IC; break;
        } // switch
    } else {
        switch (strLength) {
        case 1: op = OPCode.EXACT1; break;
        case 2: op = OPCode.EXACT2; break;
        case 3: op = OPCode.EXACT3; break;
        case 4: op = OPCode.EXACT4; break;
        case 5: op = OPCode.EXACT5; break;
        default:op = OPCode.EXACTN; break;
        } // inner switch
    }
    return op;
}
 
Example #10
Source File: ArrayCompiler.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void compileOptionNode(EncloseNode node) {
    int prev = regex.options;

    if (isDynamic(prev ^ node.option)) {
        addOpcodeOption(OPCode.SET_OPTION_PUSH, node.option);
        addOpcodeOption(OPCode.SET_OPTION, prev);
        addOpcode(OPCode.FAIL);
    }

    regex.options = node.option;
    compileTree(node.target);
    regex.options = prev;

    if (isDynamic(prev ^ node.option)) {
        addOpcodeOption(OPCode.SET_OPTION, prev);
    }
}
 
Example #11
Source File: ArrayCompiler.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void compileOptionNode(final EncloseNode node) {
    final int prev = regex.options;

    if (isDynamic(prev ^ node.option)) {
        addOpcodeOption(OPCode.SET_OPTION_PUSH, node.option);
        addOpcodeOption(OPCode.SET_OPTION, prev);
        addOpcode(OPCode.FAIL);
    }

    regex.options = node.option;
    compileTree(node.target);
    regex.options = prev;

    if (isDynamic(prev ^ node.option)) {
        addOpcodeOption(OPCode.SET_OPTION, prev);
    }
}
 
Example #12
Source File: ByteCodeMachine.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private void nullCheckFound() {
    // null_check_found:
    /* empty loop founded, skip next instruction */
    switch(code[ip++]) {
    case OPCode.JUMP:
    case OPCode.PUSH:
        ip++;       // p += SIZE_RELADDR;
        break;
    case OPCode.REPEAT_INC:
    case OPCode.REPEAT_INC_NG:
    case OPCode.REPEAT_INC_SG:
    case OPCode.REPEAT_INC_NG_SG:
        ip++;        // p += SIZE_MEMNUM;
        break;
    default:
        throw new InternalException(ErrorMessages.ERR_UNEXPECTED_BYTECODE);
    } // switch
}
 
Example #13
Source File: ArrayCompiler.java    From jdk8u_nashorn with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void compileOptionNode(final EncloseNode node) {
    final int prev = regex.options;

    if (isDynamic(prev ^ node.option)) {
        addOpcodeOption(OPCode.SET_OPTION_PUSH, node.option);
        addOpcodeOption(OPCode.SET_OPTION, prev);
        addOpcode(OPCode.FAIL);
    }

    regex.options = node.option;
    compileTree(node.target);
    regex.options = prev;

    if (isDynamic(prev ^ node.option)) {
        addOpcodeOption(OPCode.SET_OPTION, prev);
    }
}
 
Example #14
Source File: ArrayCompiler.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private void compileTreeEmptyCheck(final Node node, final int emptyInfo) {
    final int savedNumNullCheck = regex.numNullCheck;

    if (emptyInfo != 0) {
        addOpcode(OPCode.NULL_CHECK_START);
        addMemNum(regex.numNullCheck); /* NULL CHECK ID */
        regex.numNullCheck++;
    }

    compileTree(node);

    if (emptyInfo != 0) {
        switch (emptyInfo) {
        case TargetInfo.IS_EMPTY:
            addOpcode(OPCode.NULL_CHECK_END);
            break;
        case TargetInfo.IS_EMPTY_MEM:
            addOpcode(OPCode.NULL_CHECK_END_MEMST);
            break;
        default:
            break;
        } // switch

        addMemNum(savedNumNullCheck); /* NULL CHECK ID */
    }
}
 
Example #15
Source File: ArrayCompiler.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private void compileRangeRepeatNode(final QuantifierNode qn, final int targetLen, final int emptyInfo) {
    final int numRepeat = regex.numRepeat;
    addOpcode(qn.greedy ? OPCode.REPEAT : OPCode.REPEAT_NG);
    addMemNum(numRepeat); /* OP_REPEAT ID */
    regex.numRepeat++;
    addRelAddr(targetLen + OPSize.REPEAT_INC);

    entryRepeatRange(numRepeat, qn.lower, qn.upper);

    compileTreeEmptyCheck(qn.target, emptyInfo);

    if (qn.isInRepeat()) {
        addOpcode(qn.greedy ? OPCode.REPEAT_INC_SG : OPCode.REPEAT_INC_NG_SG);
    } else {
        addOpcode(qn.greedy ? OPCode.REPEAT_INC : OPCode.REPEAT_INC_NG);
    }

    addMemNum(numRepeat); /* OP_REPEAT ID */
}
 
Example #16
Source File: ArrayCompiler.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private int selectStrOpcode(int strLength, boolean ignoreCase) {
    int op;

    if (ignoreCase) {
        switch(strLength) {
        case 1: op = OPCode.EXACT1_IC; break;
        default:op = OPCode.EXACTN_IC; break;
        } // switch
    } else {
        switch (strLength) {
        case 1: op = OPCode.EXACT1; break;
        case 2: op = OPCode.EXACT2; break;
        case 3: op = OPCode.EXACT3; break;
        case 4: op = OPCode.EXACT4; break;
        case 5: op = OPCode.EXACT5; break;
        default:op = OPCode.EXACTN; break;
        } // inner switch
    }
    return op;
}
 
Example #17
Source File: ArrayCompiler.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private void compileRangeRepeatNode(QuantifierNode qn, int targetLen, int emptyInfo) {
    int numRepeat = regex.numRepeat;
    addOpcode(qn.greedy ? OPCode.REPEAT : OPCode.REPEAT_NG);
    addMemNum(numRepeat); /* OP_REPEAT ID */
    regex.numRepeat++;
    addRelAddr(targetLen + OPSize.REPEAT_INC);

    entryRepeatRange(numRepeat, qn.lower, qn.upper);

    compileTreeEmptyCheck(qn.target, emptyInfo);

    if (qn.isInRepeat()) {
        addOpcode(qn.greedy ? OPCode.REPEAT_INC_SG : OPCode.REPEAT_INC_NG_SG);
    } else {
        addOpcode(qn.greedy ? OPCode.REPEAT_INC : OPCode.REPEAT_INC_NG);
    }

    addMemNum(numRepeat); /* OP_REPEAT ID */
}
 
Example #18
Source File: ArrayCompiler.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private void compileTreeEmptyCheck(final Node node, final int emptyInfo) {
    final int savedNumNullCheck = regex.numNullCheck;

    if (emptyInfo != 0) {
        addOpcode(OPCode.NULL_CHECK_START);
        addMemNum(regex.numNullCheck); /* NULL CHECK ID */
        regex.numNullCheck++;
    }

    compileTree(node);

    if (emptyInfo != 0) {
        switch (emptyInfo) {
        case TargetInfo.IS_EMPTY:
            addOpcode(OPCode.NULL_CHECK_END);
            break;
        case TargetInfo.IS_EMPTY_MEM:
            addOpcode(OPCode.NULL_CHECK_END_MEMST);
            break;
        default:
            break;
        } // switch

        addMemNum(savedNumNullCheck); /* NULL CHECK ID */
    }
}
 
Example #19
Source File: ArrayCompiler.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void compileBackrefNode(final BackRefNode node) {
    if (isIgnoreCase(regex.options)) {
        addOpcode(OPCode.BACKREFN_IC);
        addMemNum(node.backRef);
    } else {
        switch (node.backRef) {
            case 1:
                addOpcode(OPCode.BACKREF1);
                break;
            case 2:
                addOpcode(OPCode.BACKREF2);
                break;
            default:
                addOpcode(OPCode.BACKREFN);
                addOpcode(node.backRef);
                break;
        } // switch
    }
}
 
Example #20
Source File: ArrayCompiler.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private void compileRangeRepeatNode(final QuantifierNode qn, final int targetLen, final int emptyInfo) {
    final int numRepeat = regex.numRepeat;
    addOpcode(qn.greedy ? OPCode.REPEAT : OPCode.REPEAT_NG);
    addMemNum(numRepeat); /* OP_REPEAT ID */
    regex.numRepeat++;
    addRelAddr(targetLen + OPSize.REPEAT_INC);

    entryRepeatRange(numRepeat, qn.lower, qn.upper);

    compileTreeEmptyCheck(qn.target, emptyInfo);

    if (qn.isInRepeat()) {
        addOpcode(qn.greedy ? OPCode.REPEAT_INC_SG : OPCode.REPEAT_INC_NG_SG);
    } else {
        addOpcode(qn.greedy ? OPCode.REPEAT_INC : OPCode.REPEAT_INC_NG);
    }

    addMemNum(numRepeat); /* OP_REPEAT ID */
}
 
Example #21
Source File: ByteCodeMachine.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private void nullCheckFound() {
    // null_check_found:
    /* empty loop founded, skip next instruction */
    switch(code[ip++]) {
    case OPCode.JUMP:
    case OPCode.PUSH:
        ip++;       // p += SIZE_RELADDR;
        break;
    case OPCode.REPEAT_INC:
    case OPCode.REPEAT_INC_NG:
    case OPCode.REPEAT_INC_SG:
    case OPCode.REPEAT_INC_NG_SG:
        ip++;        // p += SIZE_MEMNUM;
        break;
    default:
        throw new InternalException(ErrorMessages.ERR_UNEXPECTED_BYTECODE);
    } // switch
}
 
Example #22
Source File: ArrayCompiler.java    From nashorn with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void compileBackrefNode(BackRefNode node) {
    if (isIgnoreCase(regex.options)) {
        addOpcode(OPCode.BACKREFN_IC);
        addMemNum(node.backRef);
    } else {
        switch (node.backRef) {
            case 1:
                addOpcode(OPCode.BACKREF1);
                break;
            case 2:
                addOpcode(OPCode.BACKREF2);
                break;
            default:
                addOpcode(OPCode.BACKREFN);
                addOpcode(node.backRef);
                break;
        } // switch
    }
}
 
Example #23
Source File: ArrayCompiler.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private static int selectStrOpcode(final int strLength, final boolean ignoreCase) {
    int op;

    if (ignoreCase) {
        switch(strLength) {
        case 1: op = OPCode.EXACT1_IC; break;
        default:op = OPCode.EXACTN_IC; break;
        } // switch
    } else {
        switch (strLength) {
        case 1: op = OPCode.EXACT1; break;
        case 2: op = OPCode.EXACT2; break;
        case 3: op = OPCode.EXACT3; break;
        case 4: op = OPCode.EXACT4; break;
        case 5: op = OPCode.EXACT5; break;
        default:op = OPCode.EXACTN; break;
        } // inner switch
    }
    return op;
}
 
Example #24
Source File: ArrayCompiler.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private void compileTreeEmptyCheck(final Node node, final int emptyInfo) {
    final int savedNumNullCheck = regex.numNullCheck;

    if (emptyInfo != 0) {
        addOpcode(OPCode.NULL_CHECK_START);
        addMemNum(regex.numNullCheck); /* NULL CHECK ID */
        regex.numNullCheck++;
    }

    compileTree(node);

    if (emptyInfo != 0) {
        switch (emptyInfo) {
        case TargetInfo.IS_EMPTY:
            addOpcode(OPCode.NULL_CHECK_END);
            break;
        case TargetInfo.IS_EMPTY_MEM:
            addOpcode(OPCode.NULL_CHECK_END_MEMST);
            break;
        default:
            break;
        } // switch

        addMemNum(savedNumNullCheck); /* NULL CHECK ID */
    }
}
 
Example #25
Source File: ArrayCompiler.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void compileOptionNode(final EncloseNode node) {
    final int prev = regex.options;

    if (isDynamic(prev ^ node.option)) {
        addOpcodeOption(OPCode.SET_OPTION_PUSH, node.option);
        addOpcodeOption(OPCode.SET_OPTION, prev);
        addOpcode(OPCode.FAIL);
    }

    regex.options = node.option;
    compileTree(node.target);
    regex.options = prev;

    if (isDynamic(prev ^ node.option)) {
        addOpcodeOption(OPCode.SET_OPTION, prev);
    }
}
 
Example #26
Source File: ByteCodeMachine.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private void nullCheckFound() {
    // null_check_found:
    /* empty loop founded, skip next instruction */
    switch(code[ip++]) {
    case OPCode.JUMP:
    case OPCode.PUSH:
        ip++;       // p += SIZE_RELADDR;
        break;
    case OPCode.REPEAT_INC:
    case OPCode.REPEAT_INC_NG:
    case OPCode.REPEAT_INC_SG:
    case OPCode.REPEAT_INC_NG_SG:
        ip++;        // p += SIZE_MEMNUM;
        break;
    default:
        throw new InternalException(ErrorMessages.ERR_UNEXPECTED_BYTECODE);
    } // switch
}
 
Example #27
Source File: ArrayCompiler.java    From nashorn with GNU General Public License v2.0 6 votes vote down vote up
private int selectStrOpcode(int strLength, boolean ignoreCase) {
    int op;

    if (ignoreCase) {
        switch(strLength) {
        case 1: op = OPCode.EXACT1_IC; break;
        default:op = OPCode.EXACTN_IC; break;
        } // switch
    } else {
        switch (strLength) {
        case 1: op = OPCode.EXACT1; break;
        case 2: op = OPCode.EXACT2; break;
        case 3: op = OPCode.EXACT3; break;
        case 4: op = OPCode.EXACT4; break;
        case 5: op = OPCode.EXACT5; break;
        default:op = OPCode.EXACTN; break;
        } // inner switch
    }
    return op;
}
 
Example #28
Source File: ArrayCompiler.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private void compileTreeEmptyCheck(final Node node, final int emptyInfo) {
    final int savedNumNullCheck = regex.numNullCheck;

    if (emptyInfo != 0) {
        addOpcode(OPCode.NULL_CHECK_START);
        addMemNum(regex.numNullCheck); /* NULL CHECK ID */
        regex.numNullCheck++;
    }

    compileTree(node);

    if (emptyInfo != 0) {
        switch (emptyInfo) {
        case TargetInfo.IS_EMPTY:
            addOpcode(OPCode.NULL_CHECK_END);
            break;
        case TargetInfo.IS_EMPTY_MEM:
            addOpcode(OPCode.NULL_CHECK_END_MEMST);
            break;
        default:
            break;
        } // switch

        addMemNum(savedNumNullCheck); /* NULL CHECK ID */
    }
}
 
Example #29
Source File: ArrayCompiler.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void compileBackrefNode(final BackRefNode node) {
    if (isIgnoreCase(regex.options)) {
        addOpcode(OPCode.BACKREFN_IC);
        addMemNum(node.backRef);
    } else {
        switch (node.backRef) {
            case 1:
                addOpcode(OPCode.BACKREF1);
                break;
            case 2:
                addOpcode(OPCode.BACKREF2);
                break;
            default:
                addOpcode(OPCode.BACKREFN);
                addOpcode(node.backRef);
                break;
        } // switch
    }
}
 
Example #30
Source File: ArrayCompiler.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void compileOptionNode(final EncloseNode node) {
    final int prev = regex.options;

    if (isDynamic(prev ^ node.option)) {
        addOpcodeOption(OPCode.SET_OPTION_PUSH, node.option);
        addOpcodeOption(OPCode.SET_OPTION, prev);
        addOpcode(OPCode.FAIL);
    }

    regex.options = node.option;
    compileTree(node.target);
    regex.options = prev;

    if (isDynamic(prev ^ node.option)) {
        addOpcodeOption(OPCode.SET_OPTION, prev);
    }
}