1 /* 2 * Permission is hereby granted, free of charge, to any person obtaining a copy of 3 * this software and associated documentation files (the "Software"), to deal in 4 * the Software without restriction, including without limitation the rights to 5 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 6 * of the Software, and to permit persons to whom the Software is furnished to do 7 * so, subject to the following conditions: 8 * 9 * The above copyright notice and this permission notice shall be included in all 10 * copies or substantial portions of the Software. 11 * 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 13 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 15 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 17 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 18 * SOFTWARE. 19 */ 20 package jdk.nashorn.internal.runtime.regexp.joni; 21 22 import jdk.nashorn.internal.runtime.regexp.joni.constants.TokenType; 23 24 final class Token { 25 TokenType type; 26 boolean escaped; 27 int base; /* is number: 8, 16 (used in [....]) */ 28 int backP; 29 30 // union fields 31 private int INT1, INT2, INT3, INT4, INT5; 32 private int []INTA1; 33 34 // union accessors 35 int getC() { 36 return INT1; 37 } 38 void setC(int c) { 39 INT1 = c; 40 } 41 42 int getCode() { 43 return INT1; 44 } 45 void setCode(int code) { 46 INT1 = code; 47 } 48 49 int getAnchor() { 50 return INT1; 51 } 52 void setAnchor(int anchor) { 53 INT1 = anchor; 54 } 55 56 int getSubtype() { 57 return INT1; 58 } 59 void setSubtype(int subtype) { 60 INT1 = subtype; 61 } 62 63 // repeat union member 64 int getRepeatLower() { 65 return INT1; 66 } 67 void setRepeatLower(int lower) { 68 INT1 = lower; 69 } 70 71 int getRepeatUpper() { 72 return INT2; 73 } 74 void setRepeatUpper(int upper) { 75 INT2 = upper; 76 } 77 78 boolean getRepeatGreedy() { 79 return INT3 != 0; 80 } 81 void setRepeatGreedy(boolean greedy) { 82 INT3 = greedy ? 1 : 0; 83 } 84 85 boolean getRepeatPossessive() { 86 return INT4 != 0; 87 } 88 void setRepeatPossessive(boolean possessive) { 89 INT4 = possessive ? 1 : 0; 90 } 91 92 // backref union member 93 int getBackrefNum() { 94 return INT1; 95 } 96 void setBackrefNum(int num) { 97 INT1 = num; 98 } 99 100 int getBackrefRef1() { 101 return INT2; 102 } 103 void setBackrefRef1(int ref1) { 104 INT2 = ref1; 105 } 106 107 int[]getBackrefRefs() { 108 return INTA1; 109 } 110 void setBackrefRefs(int[]refs) { 111 INTA1 = refs; 112 } 113 114 boolean getBackrefByName() { 115 return INT3 != 0; 116 } 117 void setBackrefByName(boolean byName) { 118 INT3 = byName ? 1 : 0; 119 } 120 121 // USE_BACKREF_AT_LEVEL 122 boolean getBackrefExistLevel() { 123 return INT4 != 0; 124 } 125 void setBackrefExistLevel(boolean existLevel) { 126 INT4 = existLevel ? 1 : 0; 127 } 128 129 int getBackrefLevel() { 130 return INT5; 131 } 132 void setBackrefLevel(int level) { 133 INT5 = level; 134 } 135 136 // call union member 137 int getCallNameP() { 138 return INT1; 139 } 140 void setCallNameP(int nameP) { 141 INT1 = nameP; 142 } 143 144 int getCallNameEnd() { 145 return INT2; 146 } 147 void setCallNameEnd(int nameEnd) { 148 INT2 = nameEnd; 149 } 150 151 int getCallGNum() { 152 return INT3; 153 } 154 void setCallGNum(int gnum) { 155 INT3 = gnum; 156 } 157 158 // prop union member 159 int getPropCType() { 160 return INT1; 161 } 162 void setPropCType(int ctype) { 163 INT1 = ctype; 164 } 165 166 boolean getPropNot() { 167 return INT2 != 0; 168 } 169 void setPropNot(boolean not) { 170 INT2 = not ? 1 : 0; 171 } 172 }