< prev index next >

make/data/characterdata/CharacterDataLatin1.java.template

Print this page
rev 52948 : 8213754: PPC64: Add Intrinsics for isDigit/isLowerCase/isUpperCase/isWhitespace
Reviewed-by: kvn, rriggs, mdoerr, gromero


   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package java.lang;
  27 


  28 /** The CharacterData class encapsulates the large tables found in
  29     Java.lang.Character. */
  30 
  31 class CharacterDataLatin1 extends CharacterData {
  32 
  33     /* The character properties are currently encoded into 32 bits in the following manner:
  34         1 bit   mirrored property
  35         4 bits  directionality property
  36         9 bits  signed offset used for converting case
  37         1 bit   if 1, adding the signed offset converts the character to lowercase
  38         1 bit   if 1, subtracting the signed offset converts the character to uppercase
  39         1 bit   if 1, this character has a titlecase equivalent (possibly itself)
  40         3 bits  0  may not be part of an identifier
  41                 1  ignorable control; may continue a Unicode identifier or Java identifier
  42                 2  may continue a Java identifier but not a Unicode identifier (unused)
  43                 3  may continue a Unicode identifier or Java identifier
  44                 4  is a Java whitespace character
  45                 5  may start or continue a Java identifier;
  46                    may continue but not start a Unicode identifier (underscores)
  47                 6  may start or continue a Java identifier but not a Unicode identifier ($)


  61                    character code, then masking with 0x1F, then adding 10
  62                    will produce the desired numeric value
  63         5 bits  digit offset
  64         5 bits  character type
  65 
  66         The encoding of character properties is subject to change at any time.
  67      */
  68 
  69     int getProperties(int ch) {
  70         char offset = (char)ch;
  71         int props = $$Lookup(offset);
  72         return props;
  73     }
  74 
  75     int getPropertiesEx(int ch) {
  76         char offset = (char)ch;
  77         int props = $$LookupEx(offset);
  78         return props;
  79     }
  80 

















  81     boolean isOtherLowercase(int ch) {
  82         int props = getPropertiesEx(ch);
  83         return (props & $$maskOtherLowercase) != 0;
  84     }
  85 
  86     boolean isOtherUppercase(int ch) {
  87         int props = getPropertiesEx(ch);
  88         return (props & $$maskOtherUppercase) != 0;
  89     }
  90 
  91     boolean isOtherAlphabetic(int ch) {
  92         int props = getPropertiesEx(ch);
  93         return (props & $$maskOtherAlphabetic) != 0;
  94     }
  95 
  96     boolean isIdeographic(int ch) {
  97         int props = getPropertiesEx(ch);
  98         return (props & $$maskIdeographic) != 0;
  99     }
 100 


 197         int retval = -1;
 198 
 199         switch (val & $$maskNumericType) {
 200             default: // cannot occur
 201             case ($$valueNotNumeric):         // not numeric
 202                 retval = -1;
 203                 break;
 204             case ($$valueDigit):              // simple numeric
 205                 retval = ch + ((val & $$maskDigitOffset) >> $$shiftDigitOffset) & $$maskDigit;
 206                 break;
 207             case ($$valueStrangeNumeric)      :       // "strange" numeric
 208                  retval = -2; 
 209                  break;
 210             case ($$valueJavaSupradecimal):           // Java supradecimal
 211                 retval = (ch + ((val & $$maskDigitOffset) >> $$shiftDigitOffset) & $$maskDigit) + 10;
 212                 break;
 213         }
 214         return retval;
 215     }
 216 

 217     boolean isWhitespace(int ch) {
 218         int props = getProperties(ch);
 219         return ((props & $$maskIdentifierInfo) == $$valueJavaWhitespace);
 220     }
 221 
 222     byte getDirectionality(int ch) {
 223         int val = getProperties(ch);
 224         byte directionality = (byte)((val & $$maskBidi) >> $$shiftBidi);
 225 
 226         if (directionality == 0xF ) {
 227             directionality = -1;
 228         }
 229         return directionality;
 230     }
 231 
 232     boolean isMirrored(int ch) {
 233         int props = getProperties(ch);
 234         return ((props & $$maskMirrored) != 0);
 235     }
 236 




   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package java.lang;
  27 
  28 import jdk.internal.HotSpotIntrinsicCandidate;
  29 
  30 /** The CharacterData class encapsulates the large tables found in
  31     Java.lang.Character. */
  32 
  33 class CharacterDataLatin1 extends CharacterData {
  34 
  35     /* The character properties are currently encoded into 32 bits in the following manner:
  36         1 bit   mirrored property
  37         4 bits  directionality property
  38         9 bits  signed offset used for converting case
  39         1 bit   if 1, adding the signed offset converts the character to lowercase
  40         1 bit   if 1, subtracting the signed offset converts the character to uppercase
  41         1 bit   if 1, this character has a titlecase equivalent (possibly itself)
  42         3 bits  0  may not be part of an identifier
  43                 1  ignorable control; may continue a Unicode identifier or Java identifier
  44                 2  may continue a Java identifier but not a Unicode identifier (unused)
  45                 3  may continue a Unicode identifier or Java identifier
  46                 4  is a Java whitespace character
  47                 5  may start or continue a Java identifier;
  48                    may continue but not start a Unicode identifier (underscores)
  49                 6  may start or continue a Java identifier but not a Unicode identifier ($)


  63                    character code, then masking with 0x1F, then adding 10
  64                    will produce the desired numeric value
  65         5 bits  digit offset
  66         5 bits  character type
  67 
  68         The encoding of character properties is subject to change at any time.
  69      */
  70 
  71     int getProperties(int ch) {
  72         char offset = (char)ch;
  73         int props = $$Lookup(offset);
  74         return props;
  75     }
  76 
  77     int getPropertiesEx(int ch) {
  78         char offset = (char)ch;
  79         int props = $$LookupEx(offset);
  80         return props;
  81     }
  82 
  83     @HotSpotIntrinsicCandidate
  84     boolean isDigit(int ch) {
  85         return '0' <= ch && ch <= '9';
  86     }
  87 
  88     @HotSpotIntrinsicCandidate
  89     boolean isLowerCase(int ch) {
  90         int props = getProperties(ch);
  91         return (props & $$maskType) == Character.LOWERCASE_LETTER;
  92     }
  93 
  94     @HotSpotIntrinsicCandidate
  95     boolean isUpperCase(int ch) {
  96         int props = getProperties(ch);
  97         return (props & $$maskType) == Character.UPPERCASE_LETTER;
  98     }
  99 
 100     boolean isOtherLowercase(int ch) {
 101         int props = getPropertiesEx(ch);
 102         return (props & $$maskOtherLowercase) != 0;
 103     }
 104 
 105     boolean isOtherUppercase(int ch) {
 106         int props = getPropertiesEx(ch);
 107         return (props & $$maskOtherUppercase) != 0;
 108     }
 109 
 110     boolean isOtherAlphabetic(int ch) {
 111         int props = getPropertiesEx(ch);
 112         return (props & $$maskOtherAlphabetic) != 0;
 113     }
 114 
 115     boolean isIdeographic(int ch) {
 116         int props = getPropertiesEx(ch);
 117         return (props & $$maskIdeographic) != 0;
 118     }
 119 


 216         int retval = -1;
 217 
 218         switch (val & $$maskNumericType) {
 219             default: // cannot occur
 220             case ($$valueNotNumeric):         // not numeric
 221                 retval = -1;
 222                 break;
 223             case ($$valueDigit):              // simple numeric
 224                 retval = ch + ((val & $$maskDigitOffset) >> $$shiftDigitOffset) & $$maskDigit;
 225                 break;
 226             case ($$valueStrangeNumeric)      :       // "strange" numeric
 227                  retval = -2; 
 228                  break;
 229             case ($$valueJavaSupradecimal):           // Java supradecimal
 230                 retval = (ch + ((val & $$maskDigitOffset) >> $$shiftDigitOffset) & $$maskDigit) + 10;
 231                 break;
 232         }
 233         return retval;
 234     }
 235 
 236     @HotSpotIntrinsicCandidate
 237     boolean isWhitespace(int ch) {
 238         int props = getProperties(ch);
 239         return ((props & $$maskIdentifierInfo) == $$valueJavaWhitespace);
 240     }
 241 
 242     byte getDirectionality(int ch) {
 243         int val = getProperties(ch);
 244         byte directionality = (byte)((val & $$maskBidi) >> $$shiftBidi);
 245 
 246         if (directionality == 0xF ) {
 247             directionality = -1;
 248         }
 249         return directionality;
 250     }
 251 
 252     boolean isMirrored(int ch) {
 253         int props = getProperties(ch);
 254         return ((props & $$maskMirrored) != 0);
 255     }
 256 


< prev index next >