001: //
002: // Copyright (C) 2005 United States Government as represented by the
003: // Administrator of the National Aeronautics and Space Administration
004: // (NASA). All Rights Reserved.
005: //
006: // This software is distributed under the NASA Open Source Agreement
007: // (NOSA), version 1.3. The NOSA has been approved by the Open Source
008: // Initiative. See the file NOSA-1.3-JPF at the top of the distribution
009: // directory tree for the complete NOSA document.
010: //
011: // THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY OF ANY
012: // KIND, EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT
013: // LIMITED TO, ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL CONFORM TO
014: // SPECIFICATIONS, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR
015: // A PARTICULAR PURPOSE, OR FREEDOM FROM INFRINGEMENT, ANY WARRANTY THAT
016: // THE SUBJECT SOFTWARE WILL BE ERROR FREE, OR ANY WARRANTY THAT
017: // DOCUMENTATION, IF PROVIDED, WILL CONFORM TO THE SUBJECT SOFTWARE.
018: //
019: package gov.nasa.jpf.jvm;
020:
021: /**
022: * MJI NativePeer class for java.lang.Character library abstraction
023: * Whoever is using this seriously is definitely screwed, performance-wise
024: */
025: public class JPF_java_lang_Character {
026: public static boolean isDefined__C(MJIEnv env, int clsObjRef, char c) {
027: return Character.isDefined(c);
028: }
029:
030: public static boolean isDigit__C(MJIEnv env, int clsObjRef, char c) {
031: return Character.isDigit(c);
032: }
033:
034: public static boolean isISOControl__C(MJIEnv env, int clsObjRef,
035: char c) {
036: return Character.isISOControl(c);
037: }
038:
039: public static boolean isIdentifierIgnorable__C(MJIEnv env,
040: int clsObjRef, char c) {
041: return Character.isIdentifierIgnorable(c);
042: }
043:
044: public static boolean isJavaIdentifierPart__C(MJIEnv env,
045: int clsObjRef, char c) {
046: return Character.isJavaIdentifierPart(c);
047: }
048:
049: public static boolean isJavaIdentifierStart__C(MJIEnv env,
050: int clsObjRef, char c) {
051: return Character.isJavaIdentifierStart(c);
052: }
053:
054: public static boolean isJavaLetterOrDigit__C(MJIEnv env,
055: int clsObjRef, char c) {
056: return Character.isJavaIdentifierPart(c);
057: }
058:
059: public static boolean isJavaLetter__C(MJIEnv env, int clsObjRef,
060: char c) {
061: return Character.isJavaIdentifierStart(c);
062: }
063:
064: public static boolean isLetterOrDigit__C(MJIEnv env, int clsObjRef,
065: char c) {
066: return Character.isLetterOrDigit(c);
067: }
068:
069: public static boolean isLetter__C(MJIEnv env, int clsObjRef, char c) {
070: return Character.isLetter(c);
071: }
072:
073: public static boolean isLowerCase__C(MJIEnv env, int clsObjRef,
074: char c) {
075: return Character.isLowerCase(c);
076: }
077:
078: public static int getNumericValue__C(MJIEnv env, int clsObjRef,
079: char c) {
080: return Character.getNumericValue(c);
081: }
082:
083: public static boolean isSpaceChar__C(MJIEnv env, int clsObjRef,
084: char c) {
085: return Character.isSpaceChar(c);
086: }
087:
088: public static boolean isSpace__C(MJIEnv env, int clsObjRef, char c) {
089: return Character.isWhitespace(c);
090: }
091:
092: public static boolean isTitleCase__C(MJIEnv env, int clsObjRef,
093: char c) {
094: return Character.isTitleCase(c);
095: }
096:
097: public static int getType__C(MJIEnv env, int clsObjRef, char c) {
098: return Character.getType(c);
099: }
100:
101: public static boolean isUnicodeIdentifierPart__C(MJIEnv env,
102: int clsObjRef, char c) {
103: return Character.isUnicodeIdentifierPart(c);
104: }
105:
106: public static boolean isUnicodeIdentifierStart__C(MJIEnv env,
107: int clsObjRef, char c) {
108: return Character.isUnicodeIdentifierStart(c);
109: }
110:
111: public static boolean isUpperCase__C(MJIEnv env, int clsObjRef,
112: char c) {
113: return Character.isUpperCase(c);
114: }
115:
116: public static boolean isWhitespace__C(MJIEnv env, int clsObjRef,
117: char c) {
118: return Character.isWhitespace(c);
119: }
120:
121: // pcm - we keep this in here to avoid the potentially expensive
122: // real clinit. This has changed a lot in Java 1.4.2 (deferred init, i.e.
123: // we could actually use it now), but in <= 1.4.1 it executes some
124: // 200,000 insns, and some people who didn't grew up with Java might
125: // deduce that JPF is hanging. It's not, it just shows why a real VM has to
126: // be fast.
127: // It is actually Ok to bypass the real clinit if we turn all the
128: // important methods into native ones, i.e. delegate to the real thing.
129: public static void $clinit(MJIEnv env, int clsObjRef) {
130: env.setStaticByteField("java.lang.Character", "UNASSIGNED",
131: (byte) 0);
132: env.setStaticByteField("java.lang.Character",
133: "UPPERCASE_LETTER", (byte) 1);
134: env.setStaticByteField("java.lang.Character",
135: "LOWERCASE_LETTER", (byte) 2);
136: env.setStaticByteField("java.lang.Character",
137: "TITLECASE_LETTER", (byte) 3);
138: env.setStaticByteField("java.lang.Character",
139: "MODIFIER_LETTER", (byte) 4);
140: env.setStaticByteField("java.lang.Character", "OTHER_LETTER",
141: (byte) 5);
142: env.setStaticByteField("java.lang.Character",
143: "NON_SPACING_MARK", (byte) 6);
144: env.setStaticByteField("java.lang.Character", "ENCLOSING_MARK",
145: (byte) 7);
146: env.setStaticByteField("java.lang.Character",
147: "COMBINING_SPACING_MARK", (byte) 8);
148: env.setStaticByteField("java.lang.Character",
149: "DECIMAL_DIGIT_NUMBER", (byte) 9);
150: env.setStaticByteField("java.lang.Character", "LETTER_NUMBER",
151: (byte) 10);
152: env.setStaticByteField("java.lang.Character", "OTHER_NUMBER",
153: (byte) 11);
154: env.setStaticByteField("java.lang.Character",
155: "SPACE_SEPARATOR", (byte) 12);
156: env.setStaticByteField("java.lang.Character", "LINE_SEPARATOR",
157: (byte) 13);
158: env.setStaticByteField("java.lang.Character",
159: "PARAGRAPH_SEPARATOR", (byte) 14);
160: env.setStaticByteField("java.lang.Character", "CONTROL",
161: (byte) 15);
162: env.setStaticByteField("java.lang.Character", "FORMAT",
163: (byte) 16);
164: env.setStaticByteField("java.lang.Character", "PRIVATE_USE",
165: (byte) 18);
166: env.setStaticByteField("java.lang.Character", "SURROGATE",
167: (byte) 19);
168: env.setStaticByteField("java.lang.Character",
169: "DASH_PUNCTUATION", (byte) 20);
170: env.setStaticByteField("java.lang.Character",
171: "START_PUNCTUATION", (byte) 21);
172: env.setStaticByteField("java.lang.Character",
173: "END_PUNCTUATION", (byte) 22);
174: env.setStaticByteField("java.lang.Character",
175: "CONNECTOR_PUNCTUATION", (byte) 23);
176: env.setStaticByteField("java.lang.Character",
177: "OTHER_PUNCTUATION", (byte) 24);
178: env.setStaticByteField("java.lang.Character", "MATH_SYMBOL",
179: (byte) 25);
180: env.setStaticByteField("java.lang.Character",
181: "CURRENCY_SYMBOL", (byte) 26);
182: env.setStaticByteField("java.lang.Character",
183: "MODIFIER_SYMBOL", (byte) 27);
184: env.setStaticByteField("java.lang.Character", "OTHER_SYMBOL",
185: (byte) 28);
186: env.setStaticIntField("java.lang.Character", "MIN_RADIX", 2);
187: env.setStaticIntField("java.lang.Character", "MAX_RADIX", 36);
188: env.setStaticCharField("java.lang.Character", "MIN_VALUE",
189: '\u0000');
190: env.setStaticCharField("java.lang.Character", "MAX_VALUE",
191: '\uffff');
192:
193: ClassInfo ci = ClassInfo.getClassInfo("char");
194: env.setStaticReferenceField("java.lang.Character", "TYPE", ci
195: .getClassObjectRef());
196:
197: env.setBooleanField(clsObjRef, "isPrimitive", true);
198: }
199:
200: public static int digit__CI(MJIEnv env, int clsObjRef, char c,
201: int radix) {
202: return Character.digit(c, radix);
203: }
204:
205: public static char forDigit__II(MJIEnv env, int clsObjRef,
206: int digit, int radix) {
207: return Character.forDigit(digit, radix);
208: }
209:
210: public static char toLowerCase__C(MJIEnv env, int clsObjRef, char c) {
211: return Character.toLowerCase(c);
212: }
213:
214: public static char toTitleCase__C(MJIEnv env, int clsObjRef, char c) {
215: return Character.toTitleCase(c);
216: }
217:
218: public static char toUpperCase__C(MJIEnv env, int clsObjRef, char c) {
219: return Character.toUpperCase(c);
220: }
221: }
|