00001 package edu.ksu.cis.bandera.abstraction.lib.integral;
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 import edu.ksu.cis.bandera.abstraction.*;
00038 public class Point extends IntegralAbstraction {
00039 private static final Point v = new Point();
00040 public static final int POINT = 0;
00041 private Point() {
00042 }
00043 public static int abs(long n) {
00044 if (n == n) return POINT;
00045 throw new RuntimeException("Point cannot abstract value '" + n + "'");
00046 }
00047 public static int add(int left$, int right$) {
00048 if (left$ == left$) return POINT;
00049 throw new RuntimeException("Point.add(" + left$ + ", " + right$ + ") is undefined");
00050 }
00051 private static int addNoChoose(int left, int right) {
00052 int result = 0;
00053 switch (left) {
00054 case 0:
00055 switch (right) {
00056 case 0:
00057 result = 1;
00058 break;
00059 }
00060 break;
00061 }
00062 if (result == 0) throw new RuntimeException("Point.addNoChoose(" + left + ", " + right + ") is undefined");
00063 return result;
00064 }
00065 public static int addSet(int leftTokens, int rightTokens) {
00066 int result = -1;
00067 for (int left = 0; (1 << left) <= leftTokens; left++) {
00068 if ((leftTokens & (1 << left)) == 0) continue;
00069 for (int right = 0; (1 << right) <= rightTokens; right++) {
00070 if ((rightTokens & (1 << right)) != 0) {
00071 if (result == -1) result = addNoChoose(left, right);
00072 else result = Abstraction.meetArith(result, addNoChoose(left, right));
00073 }
00074 }
00075 }
00076 return result;
00077 }
00078 public static int div(int left$, int right$) {
00079 if (left$ == left$) return POINT;
00080 throw new RuntimeException("Point.div(" + left$ + ", " + right$ + ") is undefined");
00081 }
00082 private static int divNoChoose(int left, int right) {
00083 int result = 0;
00084 switch (left) {
00085 case 0:
00086 switch (right) {
00087 case 0:
00088 result = 1;
00089 break;
00090 }
00091 break;
00092 }
00093 if (result == 0) throw new RuntimeException("Point.divNoChoose(" + left + ", " + right + ") is undefined");
00094 return result;
00095 }
00096 public static int divSet(int leftTokens, int rightTokens) {
00097 int result = -1;
00098 for (int left = 0; (1 << left) <= leftTokens; left++) {
00099 if ((leftTokens & (1 << left)) == 0) continue;
00100 for (int right = 0; (1 << right) <= rightTokens; right++) {
00101 if ((rightTokens & (1 << right)) != 0) {
00102 if (result == -1) result = divNoChoose(left, right);
00103 else result = Abstraction.meetArith(result, divNoChoose(left, right));
00104 }
00105 }
00106 }
00107 return result;
00108 }
00109 public static boolean eq(int left$, int right$) {
00110 if (left$ == left$) return Abstraction.choose();
00111 throw new RuntimeException("Point.eq(" + left$ + ", " + right$ + ") is undefined");
00112 }
00113 private static byte eqNoChoose(int left, int right) {
00114 byte result = -1;
00115 switch (left) {
00116 case 0:
00117 switch (right) {
00118 case 0:
00119 result = 2;
00120 break;
00121 }
00122 break;
00123 }
00124 if (result == -1) throw new RuntimeException("Point.eqNoChoose(" + left + ", " + right + ") is undefined");
00125 return result;
00126 }
00127 public static byte eqSet(int leftTokens, int rightTokens) {
00128 byte result = -1;
00129 for (int left = 0; (1 << left) <= leftTokens; left++) {
00130 if ((leftTokens & (1 << left)) == 0) continue;
00131 for (int right = 0; (1 << right) <= rightTokens; right++) {
00132 if ((rightTokens & (1 << right)) != 0) {
00133 if (result == -1) result = eqNoChoose(left, right);
00134 else result = Abstraction.meetTest(result, eqNoChoose(left, right));
00135 }
00136 }
00137 }
00138 return result;
00139 }
00140 public static boolean ge(int left$, int right$) {
00141 if (left$ == left$) return Abstraction.choose();
00142 throw new RuntimeException("Point.ge(" + left$ + ", " + right$ + ") is undefined");
00143 }
00144 private static byte geNoChoose(int left, int right) {
00145 byte result = -1;
00146 switch (left) {
00147 case 0:
00148 switch (right) {
00149 case 0:
00150 result = 2;
00151 break;
00152 }
00153 break;
00154 }
00155 if (result == -1) throw new RuntimeException("Point.geNoChoose(" + left + ", " + right + ") is undefined");
00156 return result;
00157 }
00158 public static byte geSet(int leftTokens, int rightTokens) {
00159 byte result = -1;
00160 for (int left = 0; (1 << left) <= leftTokens; left++) {
00161 if ((leftTokens & (1 << left)) == 0) continue;
00162 for (int right = 0; (1 << right) <= rightTokens; right++) {
00163 if ((rightTokens & (1 << right)) != 0) {
00164 if (result == -1) result = geNoChoose(left, right);
00165 else result = Abstraction.meetTest(result, geNoChoose(left, right));
00166 }
00167 }
00168 }
00169 return result;
00170 }
00171 public static String getBASLRepresentation() {
00172 return
00173 "abstraction Point extends integral \n"
00174 + " begin\n"
00175 + " TOKENS = {POINT};\n"
00176 + " DEFAULT = POINT;\n"
00177 + " ONE2ONE = {};\n"
00178 + " abstract (n)\n"
00179 + " begin\n"
00180 + " _ -> POINT;\n"
00181 + " end\n"
00182 + " operator + add \n"
00183 + " begin\n"
00184 + " _ -> POINT;\n"
00185 + " end\n"
00186 + " operator - sub \n"
00187 + " begin\n"
00188 + " _ -> POINT;\n"
00189 + " end\n"
00190 + " operator * mul \n"
00191 + " begin\n"
00192 + " _ -> POINT;\n"
00193 + " end\n"
00194 + " operator / div \n"
00195 + " begin\n"
00196 + " _ -> POINT;\n"
00197 + " end\n"
00198 + " operator % rem \n"
00199 + " begin\n"
00200 + " _ -> POINT;\n"
00201 + " end\n"
00202 + " test == eq \n"
00203 + " begin\n"
00204 + " _ -> T;\n"
00205 + " end\n"
00206 + " test != neq \n"
00207 + " begin\n"
00208 + " _ -> T;\n"
00209 + " end\n"
00210 + " test < lt \n"
00211 + " begin\n"
00212 + " _ -> T;\n"
00213 + " end\n"
00214 + " test <= le \n"
00215 + " begin\n"
00216 + " _ -> T;\n"
00217 + " end\n"
00218 + " test > gt \n"
00219 + " begin\n"
00220 + " _ -> T;\n"
00221 + " end\n"
00222 + " test >= ge \n"
00223 + " begin\n"
00224 + " _ -> T;\n"
00225 + " end\n"
00226 + " end\n"
00227 ;
00228 }
00229 public static String getName() {
00230 return "Point";
00231 }
00232 public static int getNumOfTokens() {
00233 return 1;
00234 }
00235 public static String getToken(int value) {
00236 switch(value) {
00237 case POINT: return "Point.POINT";
00238 }
00239 return "Point.???";
00240 }
00241 public static boolean gt(int left$, int right$) {
00242 if (left$ == left$) return Abstraction.choose();
00243 throw new RuntimeException("Point.gt(" + left$ + ", " + right$ + ") is undefined");
00244 }
00245 private static byte gtNoChoose(int left, int right) {
00246 byte result = -1;
00247 switch (left) {
00248 case 0:
00249 switch (right) {
00250 case 0:
00251 result = 2;
00252 break;
00253 }
00254 break;
00255 }
00256 if (result == -1) throw new RuntimeException("Point.gtNoChoose(" + left + ", " + right + ") is undefined");
00257 return result;
00258 }
00259 public static byte gtSet(int leftTokens, int rightTokens) {
00260 byte result = -1;
00261 for (int left = 0; (1 << left) <= leftTokens; left++) {
00262 if ((leftTokens & (1 << left)) == 0) continue;
00263 for (int right = 0; (1 << right) <= rightTokens; right++) {
00264 if ((rightTokens & (1 << right)) != 0) {
00265 if (result == -1) result = gtNoChoose(left, right);
00266 else result = Abstraction.meetTest(result, gtNoChoose(left, right));
00267 }
00268 }
00269 }
00270 return result;
00271 }
00272 public static boolean isOne2One(int value) {
00273 return false;
00274 }
00275 public static boolean le(int left$, int right$) {
00276 if (left$ == left$) return Abstraction.choose();
00277 throw new RuntimeException("Point.le(" + left$ + ", " + right$ + ") is undefined");
00278 }
00279 private static byte leNoChoose(int left, int right) {
00280 byte result = -1;
00281 switch (left) {
00282 case 0:
00283 switch (right) {
00284 case 0:
00285 result = 2;
00286 break;
00287 }
00288 break;
00289 }
00290 if (result == -1) throw new RuntimeException("Point.leNoChoose(" + left + ", " + right + ") is undefined");
00291 return result;
00292 }
00293 public static byte leSet(int leftTokens, int rightTokens) {
00294 byte result = -1;
00295 for (int left = 0; (1 << left) <= leftTokens; left++) {
00296 if ((leftTokens & (1 << left)) == 0) continue;
00297 for (int right = 0; (1 << right) <= rightTokens; right++) {
00298 if ((rightTokens & (1 << right)) != 0) {
00299 if (result == -1) result = leNoChoose(left, right);
00300 else result = Abstraction.meetTest(result, leNoChoose(left, right));
00301 }
00302 }
00303 }
00304 return result;
00305 }
00306 public static boolean lt(int left$, int right$) {
00307 if (left$ == left$) return Abstraction.choose();
00308 throw new RuntimeException("Point.lt(" + left$ + ", " + right$ + ") is undefined");
00309 }
00310 private static byte ltNoChoose(int left, int right) {
00311 byte result = -1;
00312 switch (left) {
00313 case 0:
00314 switch (right) {
00315 case 0:
00316 result = 2;
00317 break;
00318 }
00319 break;
00320 }
00321 if (result == -1) throw new RuntimeException("Point.ltNoChoose(" + left + ", " + right + ") is undefined");
00322 return result;
00323 }
00324 public static byte ltSet(int leftTokens, int rightTokens) {
00325 byte result = -1;
00326 for (int left = 0; (1 << left) <= leftTokens; left++) {
00327 if ((leftTokens & (1 << left)) == 0) continue;
00328 for (int right = 0; (1 << right) <= rightTokens; right++) {
00329 if ((rightTokens & (1 << right)) != 0) {
00330 if (result == -1) result = ltNoChoose(left, right);
00331 else result = Abstraction.meetTest(result, ltNoChoose(left, right));
00332 }
00333 }
00334 }
00335 return result;
00336 }
00337 public static int mul(int left$, int right$) {
00338 if (left$ == left$) return POINT;
00339 throw new RuntimeException("Point.mul(" + left$ + ", " + right$ + ") is undefined");
00340 }
00341 private static int mulNoChoose(int left, int right) {
00342 int result = 0;
00343 switch (left) {
00344 case 0:
00345 switch (right) {
00346 case 0:
00347 result = 1;
00348 break;
00349 }
00350 break;
00351 }
00352 if (result == 0) throw new RuntimeException("Point.mulNoChoose(" + left + ", " + right + ") is undefined");
00353 return result;
00354 }
00355 public static int mulSet(int leftTokens, int rightTokens) {
00356 int result = -1;
00357 for (int left = 0; (1 << left) <= leftTokens; left++) {
00358 if ((leftTokens & (1 << left)) == 0) continue;
00359 for (int right = 0; (1 << right) <= rightTokens; right++) {
00360 if ((rightTokens & (1 << right)) != 0) {
00361 if (result == -1) result = mulNoChoose(left, right);
00362 else result = Abstraction.meetArith(result, mulNoChoose(left, right));
00363 }
00364 }
00365 }
00366 return result;
00367 }
00368 public static boolean ne(int left$, int right$) {
00369 if (left$ == left$) return Abstraction.choose();
00370 throw new RuntimeException("Point.ne(" + left$ + ", " + right$ + ") is undefined");
00371 }
00372 private static byte neNoChoose(int left, int right) {
00373 byte result = -1;
00374 switch (left) {
00375 case 0:
00376 switch (right) {
00377 case 0:
00378 result = 2;
00379 break;
00380 }
00381 break;
00382 }
00383 if (result == -1) throw new RuntimeException("Point.neNoChoose(" + left + ", " + right + ") is undefined");
00384 return result;
00385 }
00386 public static byte neSet(int leftTokens, int rightTokens) {
00387 byte result = -1;
00388 for (int left = 0; (1 << left) <= leftTokens; left++) {
00389 if ((leftTokens & (1 << left)) == 0) continue;
00390 for (int right = 0; (1 << right) <= rightTokens; right++) {
00391 if ((rightTokens & (1 << right)) != 0) {
00392 if (result == -1) result = neNoChoose(left, right);
00393 else result = Abstraction.meetTest(result, neNoChoose(left, right));
00394 }
00395 }
00396 }
00397 return result;
00398 }
00399 public static int rem(int left$, int right$) {
00400 if (left$ == left$) return POINT;
00401 throw new RuntimeException("Point.rem(" + left$ + ", " + right$ + ") is undefined");
00402 }
00403 private static int remNoChoose(int left, int right) {
00404 int result = 0;
00405 switch (left) {
00406 case 0:
00407 switch (right) {
00408 case 0:
00409 result = 1;
00410 break;
00411 }
00412 break;
00413 }
00414 if (result == 0) throw new RuntimeException("Point.remNoChoose(" + left + ", " + right + ") is undefined");
00415 return result;
00416 }
00417 public static int remSet(int leftTokens, int rightTokens) {
00418 int result = -1;
00419 for (int left = 0; (1 << left) <= leftTokens; left++) {
00420 if ((leftTokens & (1 << left)) == 0) continue;
00421 for (int right = 0; (1 << right) <= rightTokens; right++) {
00422 if ((rightTokens & (1 << right)) != 0) {
00423 if (result == -1) result = remNoChoose(left, right);
00424 else result = Abstraction.meetArith(result, remNoChoose(left, right));
00425 }
00426 }
00427 }
00428 return result;
00429 }
00430 public static int sub(int left$, int right$) {
00431 if (left$ == left$) return POINT;
00432 throw new RuntimeException("Point.sub(" + left$ + ", " + right$ + ") is undefined");
00433 }
00434 private static int subNoChoose(int left, int right) {
00435 int result = 0;
00436 switch (left) {
00437 case 0:
00438 switch (right) {
00439 case 0:
00440 result = 1;
00441 break;
00442 }
00443 break;
00444 }
00445 if (result == 0) throw new RuntimeException("Point.subNoChoose(" + left + ", " + right + ") is undefined");
00446 return result;
00447 }
00448 public static int subSet(int leftTokens, int rightTokens) {
00449 int result = -1;
00450 for (int left = 0; (1 << left) <= leftTokens; left++) {
00451 if ((leftTokens & (1 << left)) == 0) continue;
00452 for (int right = 0; (1 << right) <= rightTokens; right++) {
00453 if ((rightTokens & (1 << right)) != 0) {
00454 if (result == -1) result = subNoChoose(left, right);
00455 else result = Abstraction.meetArith(result, subNoChoose(left, right));
00456 }
00457 }
00458 }
00459 return result;
00460 }
00461 public String toString() {
00462 return getName();
00463 }
00464 public static Point v() {
00465 return v;
00466 }
00467 }