1 /* 2 * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 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.reflect.code.interpreter; 27 28 final class InvokableLeafOps { 29 30 public static String add(String a, String b) { 31 return a.concat(b); 32 } 33 34 35 public static boolean eq(Object a, Object b) { 36 return a == b; 37 } 38 39 public static boolean neq(Object a, Object b) { 40 return a != b; 41 } 42 43 44 public static boolean not(boolean l) { 45 return !l; 46 } 47 48 // int 49 50 public static int neg(int l) { 51 return -l; 52 } 53 54 public static int add(int l, int r) { 55 return l + r; 56 } 57 58 public static int sub(int l, int r) { 59 return l - r; 60 } 61 62 public static int mul(int l, int r) { 63 return l * r; 64 } 65 66 public static int div(int l, int r) { 67 return l / r; 68 } 69 70 public static int mod(int l, int r) { 71 return l % r; 72 } 73 74 public static int or(int l, int r) { 75 return l | r; 76 } 77 78 public static int and(int l, int r) { 79 return l & r; 80 } 81 82 public static int xor(int l, int r) { 83 return l ^ r; 84 } 85 86 public static int lshl(int l, int r) { 87 return l << r; 88 } 89 90 public static int ashr(int l, int r) { 91 return l >> r; 92 } 93 94 public static int lshr(int l, int r) { 95 return l >>> r; 96 } 97 98 public static int lshl(int l, long r) { 99 return l << r; 100 } 101 102 public static int ashr(int l, long r) { 103 return l >> r; 104 } 105 106 public static int lshr(int l, long r) { 107 return l >>> r; 108 } 109 110 public static boolean eq(int l, int r) { 111 return l == r; 112 } 113 114 public static boolean neq(int l, int r) { 115 return l != r; 116 } 117 118 public static boolean gt(int l, int r) { 119 return l > r; 120 } 121 122 public static boolean ge(int l, int r) { 123 return l >= r; 124 } 125 126 public static boolean lt(int l, int r) { 127 return l < r; 128 } 129 130 public static boolean le(int l, int r) { 131 return l <= r; 132 } 133 134 // byte 135 136 public static byte neg(byte l) { 137 return (byte) -l; 138 } 139 140 public static byte add(byte l, byte r) { 141 return (byte) (l + r); 142 } 143 144 public static byte sub(byte l, byte r) { 145 return (byte) (l - r); 146 } 147 148 public static byte mul(byte l, byte r) { 149 return (byte) (l * r); 150 } 151 152 public static byte div(byte l, byte r) { 153 return (byte) (l / r); 154 } 155 156 public static byte mod(byte l, byte r) { 157 return (byte) (l % r); 158 } 159 160 public static byte or(byte l, byte r) { 161 return (byte) (l | r); 162 } 163 164 public static byte and(byte l, byte r) { 165 return (byte) (l & r); 166 } 167 168 public static byte xor(byte l, byte r) { 169 return (byte) (l ^ r); 170 } 171 172 public static byte ashr(byte l, long r) { 173 return (byte) (l >> r); 174 } 175 176 public static byte lshr(byte l, long r) { 177 return (byte) (l >>> r); 178 } 179 180 public static byte lshl(byte l, int r) { 181 return (byte) (l << r); 182 } 183 184 public static byte ashr(byte l, int r) { 185 return (byte) (l >> r); 186 } 187 188 public static byte lshr(byte l, int r) { 189 return (byte) (l >>> r); 190 } 191 192 // short 193 194 public static short neg(short l) { 195 return (short) -l; 196 } 197 198 public static short add(short l, short r) { 199 return (short) (l + r); 200 } 201 202 public static short sub(short l, short r) { 203 return (short) (l - r); 204 } 205 206 public static short mul(short l, short r) { 207 return (short) (l * r); 208 } 209 210 public static short div(short l, short r) { 211 return (short) (l / r); 212 } 213 214 public static short mod(short l, short r) { 215 return (short) (l % r); 216 } 217 218 public static short or(short l, short r) { 219 return (short) (l | r); 220 } 221 222 public static short and(short l, short r) { 223 return (short) (l & r); 224 } 225 226 public static short xor(short l, short r) { 227 return (short) (l ^ r); 228 } 229 230 public static short ashr(short l, long r) { 231 return (short) (l >> r); 232 } 233 234 public static short lshr(short l, long r) { 235 return (short) (l >>> r); 236 } 237 238 public static short lshl(short l, int r) { 239 return (short) (l << r); 240 } 241 242 public static short ashr(short l, int r) { 243 return (short) (l >> r); 244 } 245 246 public static short lshr(short l, int r) { 247 return (short) (l >>> r); 248 } 249 250 // char 251 252 public static char neg(char l) { 253 return (char) -l; 254 } 255 256 public static char add(char l, char r) { 257 return (char) (l + r); 258 } 259 260 public static char sub(char l, char r) { 261 return (char) (l - r); 262 } 263 264 public static char mul(char l, char r) { 265 return (char) (l * r); 266 } 267 268 public static char div(char l, char r) { 269 return (char) (l / r); 270 } 271 272 public static char mod(char l, char r) { 273 return (char) (l % r); 274 } 275 276 public static char or(char l, char r) { 277 return (char) (l | r); 278 } 279 280 public static char and(char l, char r) { 281 return (char) (l & r); 282 } 283 284 public static char xor(char l, char r) { 285 return (char) (l ^ r); 286 } 287 288 public static char ashr(char l, long r) { 289 return (char) (l >> r); 290 } 291 292 public static char lshr(char l, long r) { 293 return (char) (l >>> r); 294 } 295 296 public static char lshl(char l, int r) { 297 return (char) (l << r); 298 } 299 300 public static char ashr(char l, int r) { 301 return (char) (l >> r); 302 } 303 304 public static char lshr(char l, int r) { 305 return (char) (l >>> r); 306 } 307 308 // long 309 310 public static long neg(long l) { 311 return -l; 312 } 313 314 public static long add(long l, long r) { 315 return l + r; 316 } 317 318 public static long sub(long l, long r) { 319 return l - r; 320 } 321 322 public static long mul(long l, long r) { 323 return l * r; 324 } 325 326 public static long div(long l, long r) { 327 return l / r; 328 } 329 330 public static long mod(long l, long r) { 331 return l % r; 332 } 333 334 public static long or(long l, long r) { 335 return l | r; 336 } 337 338 public static long and(long l, long r) { 339 return l & r; 340 } 341 342 public static long xor(long l, long r) { 343 return l ^ r; 344 } 345 346 public static long lshl(long l, long r) { 347 return l << r; 348 } 349 350 public static long ashr(long l, long r) { 351 return l >> r; 352 } 353 354 public static long lshr(long l, long r) { 355 return l >>> r; 356 } 357 358 public static long lshl(long l, int r) { 359 return l << r; 360 } 361 362 public static long ashr(long l, int r) { 363 return l >> r; 364 } 365 366 public static long lshr(long l, int r) { 367 return l >>> r; 368 } 369 370 public static boolean eq(long l, long r) { 371 return l == r; 372 } 373 374 public static boolean neq(long l, long r) { 375 return l != r; 376 } 377 378 public static boolean gt(long l, long r) { 379 return l > r; 380 } 381 382 public static boolean ge(long l, long r) { 383 return l >= r; 384 } 385 386 public static boolean lt(long l, long r) { 387 return l < r; 388 } 389 390 public static boolean le(long l, long r) { 391 return l <= r; 392 } 393 394 395 396 // float 397 398 static float neg(float l) { 399 return -l; 400 } 401 402 static float add(float l, float r) { 403 return l + r; 404 } 405 406 static float sub(float l, float r) { 407 return l - r; 408 } 409 410 static float mul(float l, float r) { 411 return l * r; 412 } 413 414 static float div(float l, float r) { 415 return l / r; 416 } 417 418 static float mod(float l, float r) { 419 return l % r; 420 } 421 422 public static boolean eq(float l, float r) { 423 return l == r; 424 } 425 426 public static boolean neq(float l, float r) { 427 return l != r; 428 } 429 430 public static boolean gt(float l, float r) { 431 return l > r; 432 } 433 434 public static boolean ge(float l, float r) { 435 return l >= r; 436 } 437 438 public static boolean lt(float l, float r) { 439 return l < r; 440 } 441 442 public static boolean le(float l, float r) { 443 return l <= r; 444 } 445 446 447 448 // double 449 450 static double neg(double l) { 451 return -l; 452 } 453 454 static double add(double l, double r) { 455 return l + r; 456 } 457 458 static double sub(double l, double r) { 459 return l - r; 460 } 461 462 static double mul(double l, double r) { 463 return l * r; 464 } 465 466 static double div(double l, double r) { 467 return l / r; 468 } 469 470 static double mod(double l, double r) { 471 return l % r; 472 } 473 474 475 476 // boolean 477 478 static boolean eq(boolean l, boolean r) { 479 return l == r; 480 } 481 482 static boolean neq(boolean l, boolean r) { 483 return l != r; 484 } 485 486 static boolean and(boolean l, boolean r) { 487 return l & r; 488 } 489 490 static boolean or(boolean l, boolean r) { 491 return l | r; 492 } 493 494 static boolean xor(boolean l, boolean r) { 495 return l ^ r; 496 } 497 498 499 // Primitive conversions 500 501 // double conversion 502 static double conv_double(double i) { 503 return i; 504 } 505 static float conv_float(double i) { 506 return (float) i; 507 } 508 static long conv_long(double i) { 509 return (long) i; 510 } 511 static int conv_int(double i) { 512 return (int) i; 513 } 514 static short conv_short(double i) { 515 return (short) i; 516 } 517 static char conv_char(double i) { 518 return (char) i; 519 } 520 static byte conv_byte(double i) { 521 return (byte) i; 522 } 523 524 // float conversion 525 static double conv_double(float i) { 526 return i; 527 } 528 static float conv_float(float i) { 529 return i; 530 } 531 static long conv_long(float i) { 532 return (long) i; 533 } 534 static int conv_int(float i) { 535 return (int) i; 536 } 537 static short conv_short(float i) { 538 return (short) i; 539 } 540 static char conv_char(float i) { 541 return (char) i; 542 } 543 static byte conv_byte(float i) { 544 return (byte) i; 545 } 546 547 // long conversion 548 static double conv_double(long i) { 549 return (double) i; 550 } 551 static float conv_float(long i) { 552 return (float) i; 553 } 554 static long conv_long(long i) { 555 return i; 556 } 557 static int conv_int(long i) { 558 return (int) i; 559 } 560 static short conv_short(long i) { 561 return (short) i; 562 } 563 static char conv_char(long i) { 564 return (char) i; 565 } 566 static byte conv_byte(long i) { 567 return (byte) i; 568 } 569 570 // int conversion 571 static double conv_double(int i) { 572 return (double) i; 573 } 574 static float conv_float(int i) { 575 return (float) i; 576 } 577 static long conv_long(int i) { 578 return i; 579 } 580 static int conv_int(int i) { 581 return i; 582 } 583 static short conv_short(int i) { 584 return (short) i; 585 } 586 static char conv_char(int i) { 587 return (char) i; 588 } 589 static byte conv_byte(int i) { 590 return (byte) i; 591 } 592 593 // short conversion 594 static double conv_double(short i) { 595 return i; 596 } 597 static float conv_float(short i) { 598 return i; 599 } 600 static long conv_long(short i) { 601 return i; 602 } 603 static int conv_int(short i) { 604 return i; 605 } 606 static short conv_short(short i) { 607 return i; 608 } 609 static char conv_char(short i) { 610 return (char) i; 611 } 612 static byte conv_byte(short i) { 613 return (byte) i; 614 } 615 616 // char conversion 617 static double conv_double(char i) { 618 return i; 619 } 620 static float conv_float(char i) { 621 return i; 622 } 623 static long conv_long(char i) { 624 return i; 625 } 626 static int conv_int(char i) { 627 return i; 628 } 629 static short conv_short(char i) { 630 return (short) i; 631 } 632 static char conv_char(char i) { 633 return i; 634 } 635 static byte conv_byte(char i) { 636 return (byte) i; 637 } 638 639 // byte conversion 640 static double conv_double(byte i) { 641 return i; 642 } 643 static float conv_float(byte i) { 644 return i; 645 } 646 static long conv_long(byte i) { 647 return i; 648 } 649 static int conv_int(byte i) { 650 return i; 651 } 652 static short conv_short(byte i) { 653 return i; 654 } 655 static char conv_char(byte i) { 656 return (char) i; 657 } 658 static byte conv_byte(byte i) { 659 return i; 660 } 661 }