00001 package edu.ksu.cis.bandera.abstraction.lib.real;
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 RealAbstraction {
00039 private static final Point v = new Point();
00040 public static final int POINT = 0;
00041 private Point() {
00042 }
00043 public static int abs(double 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 real \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 + " test == eq \n"
00199 + " begin\n"
00200 + " _ -> T;\n"
00201 + " end\n"
00202 + " test != neq \n"
00203 + " begin\n"
00204 + " _ -> T;\n"
00205 + " end\n"
00206 + " test < lt \n"
00207 + " begin\n"
00208 + " _ -> T;\n"
00209 + " end\n"
00210 + " test <= le \n"
00211 + " begin\n"
00212 + " _ -> T;\n"
00213 + " end\n"
00214 + " test > gt \n"
00215 + " begin\n"
00216 + " _ -> T;\n"
00217 + " end\n"
00218 + " test >= ge \n"
00219 + " begin\n"
00220 + " _ -> T;\n"
00221 + " end\n"
00222 + " end\n"
00223 ;
00224 }
00225 public static String getName() {
00226 return "Point";
00227 }
00228 public static int getNumOfTokens() {
00229 return 1;
00230 }
00231 public static String getToken(int value) {
00232 switch(value) {
00233 case POINT: return "Point.POINT";
00234 }
00235 return "Point.???";
00236 }
00237 public static boolean gt(int left$, int right$) {
00238 if (left$ == left$) return Abstraction.choose();
00239 throw new RuntimeException("Point.gt(" + left$ + ", " + right$ + ") is undefined");
00240 }
00241 private static byte gtNoChoose(int left, int right) {
00242 byte result = -1;
00243 switch (left) {
00244 case 0:
00245 switch (right) {
00246 case 0:
00247 result = 2;
00248 break;
00249 }
00250 break;
00251 }
00252 if (result == -1) throw new RuntimeException("Point.gtNoChoose(" + left + ", " + right + ") is undefined");
00253 return result;
00254 }
00255 public static byte gtSet(int leftTokens, int rightTokens) {
00256 byte result = -1;
00257 for (int left = 0; (1 << left) <= leftTokens; left++) {
00258 if ((leftTokens & (1 << left)) == 0) continue;
00259 for (int right = 0; (1 << right) <= rightTokens; right++) {
00260 if ((rightTokens & (1 << right)) != 0) {
00261 if (result == -1) result = gtNoChoose(left, right);
00262 else result = Abstraction.meetTest(result, gtNoChoose(left, right));
00263 }
00264 }
00265 }
00266 return result;
00267 }
00268 public static boolean isOne2One(int value) {
00269 return false;
00270 }
00271 public static boolean le(int left$, int right$) {
00272 if (left$ == left$) return Abstraction.choose();
00273 throw new RuntimeException("Point.le(" + left$ + ", " + right$ + ") is undefined");
00274 }
00275 private static byte leNoChoose(int left, int right) {
00276 byte result = -1;
00277 switch (left) {
00278 case 0:
00279 switch (right) {
00280 case 0:
00281 result = 2;
00282 break;
00283 }
00284 break;
00285 }
00286 if (result == -1) throw new RuntimeException("Point.leNoChoose(" + left + ", " + right + ") is undefined");
00287 return result;
00288 }
00289 public static byte leSet(int leftTokens, int rightTokens) {
00290 byte result = -1;
00291 for (int left = 0; (1 << left) <= leftTokens; left++) {
00292 if ((leftTokens & (1 << left)) == 0) continue;
00293 for (int right = 0; (1 << right) <= rightTokens; right++) {
00294 if ((rightTokens & (1 << right)) != 0) {
00295 if (result == -1) result = leNoChoose(left, right);
00296 else result = Abstraction.meetTest(result, leNoChoose(left, right));
00297 }
00298 }
00299 }
00300 return result;
00301 }
00302 public static boolean lt(int left$, int right$) {
00303 if (left$ == left$) return Abstraction.choose();
00304 throw new RuntimeException("Point.lt(" + left$ + ", " + right$ + ") is undefined");
00305 }
00306 private static byte ltNoChoose(int left, int right) {
00307 byte result = -1;
00308 switch (left) {
00309 case 0:
00310 switch (right) {
00311 case 0:
00312 result = 2;
00313 break;
00314 }
00315 break;
00316 }
00317 if (result == -1) throw new RuntimeException("Point.ltNoChoose(" + left + ", " + right + ") is undefined");
00318 return result;
00319 }
00320 public static byte ltSet(int leftTokens, int rightTokens) {
00321 byte result = -1;
00322 for (int left = 0; (1 << left) <= leftTokens; left++) {
00323 if ((leftTokens & (1 << left)) == 0) continue;
00324 for (int right = 0; (1 << right) <= rightTokens; right++) {
00325 if ((rightTokens & (1 << right)) != 0) {
00326 if (result == -1) result = ltNoChoose(left, right);
00327 else result = Abstraction.meetTest(result, ltNoChoose(left, right));
00328 }
00329 }
00330 }
00331 return result;
00332 }
00333 public static int mul(int left$, int right$) {
00334 if (left$ == left$) return POINT;
00335 throw new RuntimeException("Point.mul(" + left$ + ", " + right$ + ") is undefined");
00336 }
00337 private static int mulNoChoose(int left, int right) {
00338 int result = 0;
00339 switch (left) {
00340 case 0:
00341 switch (right) {
00342 case 0:
00343 result = 1;
00344 break;
00345 }
00346 break;
00347 }
00348 if (result == 0) throw new RuntimeException("Point.mulNoChoose(" + left + ", " + right + ") is undefined");
00349 return result;
00350 }
00351 public static int mulSet(int leftTokens, int rightTokens) {
00352 int result = -1;
00353 for (int left = 0; (1 << left) <= leftTokens; left++) {
00354 if ((leftTokens & (1 << left)) == 0) continue;
00355 for (int right = 0; (1 << right) <= rightTokens; right++) {
00356 if ((rightTokens & (1 << right)) != 0) {
00357 if (result == -1) result = mulNoChoose(left, right);
00358 else result = Abstraction.meetArith(result, mulNoChoose(left, right));
00359 }
00360 }
00361 }
00362 return result;
00363 }
00364 public static boolean ne(int left$, int right$) {
00365 if (left$ == left$) return Abstraction.choose();
00366 throw new RuntimeException("Point.ne(" + left$ + ", " + right$ + ") is undefined");
00367 }
00368 private static byte neNoChoose(int left, int right) {
00369 byte result = -1;
00370 switch (left) {
00371 case 0:
00372 switch (right) {
00373 case 0:
00374 result = 2;
00375 break;
00376 }
00377 break;
00378 }
00379 if (result == -1) throw new RuntimeException("Point.neNoChoose(" + left + ", " + right + ") is undefined");
00380 return result;
00381 }
00382 public static byte neSet(int leftTokens, int rightTokens) {
00383 byte result = -1;
00384 for (int left = 0; (1 << left) <= leftTokens; left++) {
00385 if ((leftTokens & (1 << left)) == 0) continue;
00386 for (int right = 0; (1 << right) <= rightTokens; right++) {
00387 if ((rightTokens & (1 << right)) != 0) {
00388 if (result == -1) result = neNoChoose(left, right);
00389 else result = Abstraction.meetTest(result, neNoChoose(left, right));
00390 }
00391 }
00392 }
00393 return result;
00394 }
00395 public static int sub(int left$, int right$) {
00396 if (left$ == left$) return POINT;
00397 throw new RuntimeException("Point.sub(" + left$ + ", " + right$ + ") is undefined");
00398 }
00399 private static int subNoChoose(int left, int right) {
00400 int result = 0;
00401 switch (left) {
00402 case 0:
00403 switch (right) {
00404 case 0:
00405 result = 1;
00406 break;
00407 }
00408 break;
00409 }
00410 if (result == 0) throw new RuntimeException("Point.subNoChoose(" + left + ", " + right + ") is undefined");
00411 return result;
00412 }
00413 public static int subSet(int leftTokens, int rightTokens) {
00414 int result = -1;
00415 for (int left = 0; (1 << left) <= leftTokens; left++) {
00416 if ((leftTokens & (1 << left)) == 0) continue;
00417 for (int right = 0; (1 << right) <= rightTokens; right++) {
00418 if ((rightTokens & (1 << right)) != 0) {
00419 if (result == -1) result = subNoChoose(left, right);
00420 else result = Abstraction.meetArith(result, subNoChoose(left, right));
00421 }
00422 }
00423 }
00424 return result;
00425 }
00426 public String toString() {
00427 return getName();
00428 }
00429 public static Point v() {
00430 return v;
00431 }
00432 }