1 /* 2 * Copyright (c) 2025, 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. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 final class InvokableLeafOps { 25 26 public static String add(String a, String b) { 27 return a.concat(b); 28 } 29 30 31 public static boolean eq(Object a, Object b) { 32 return a == b; 33 } 34 35 public static boolean neq(Object a, Object b) { 36 return a != b; 37 } 38 39 40 public static boolean not(boolean l) { 41 return !l; 42 } 43 44 // int 45 46 public static int neg(int l) { 47 return -l; 48 } 49 50 public static int compl(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 compl(byte l) { 141 return (byte) ~l; 142 } 143 144 public static byte add(byte l, byte r) { 145 return (byte) (l + r); 146 } 147 148 public static byte sub(byte l, byte r) { 149 return (byte) (l - r); 150 } 151 152 public static byte mul(byte l, byte r) { 153 return (byte) (l * r); 154 } 155 156 public static byte div(byte l, byte r) { 157 return (byte) (l / r); 158 } 159 160 public static byte mod(byte l, byte r) { 161 return (byte) (l % r); 162 } 163 164 public static byte or(byte l, byte r) { 165 return (byte) (l | r); 166 } 167 168 public static byte and(byte l, byte r) { 169 return (byte) (l & r); 170 } 171 172 public static byte xor(byte l, byte r) { 173 return (byte) (l ^ r); 174 } 175 176 public static byte ashr(byte l, long r) { 177 return (byte) (l >> r); 178 } 179 180 public static byte lshr(byte l, long r) { 181 return (byte) (l >>> r); 182 } 183 184 public static byte lshl(byte l, int r) { 185 return (byte) (l << r); 186 } 187 188 public static byte ashr(byte l, int r) { 189 return (byte) (l >> r); 190 } 191 192 public static byte lshr(byte l, int r) { 193 return (byte) (l >>> r); 194 } 195 196 public static boolean eq(byte l, byte r) { 197 return l == r; 198 } 199 200 public static boolean neq(byte l, byte r) { 201 return l != r; 202 } 203 204 public static boolean gt(byte l, byte r) { 205 return l > r; 206 } 207 208 public static boolean ge(byte l, byte r) { 209 return l >= r; 210 } 211 212 public static boolean lt(byte l, byte r) { 213 return l < r; 214 } 215 216 public static boolean le(byte l, byte r) { 217 return l <= r; 218 } 219 220 // short 221 222 public static short neg(short l) { 223 return (short) -l; 224 } 225 226 public static short compl(short l) { 227 return (short) ~l; 228 } 229 230 public static short add(short l, short r) { 231 return (short) (l + r); 232 } 233 234 public static short sub(short l, short r) { 235 return (short) (l - r); 236 } 237 238 public static short mul(short l, short r) { 239 return (short) (l * r); 240 } 241 242 public static short div(short l, short r) { 243 return (short) (l / r); 244 } 245 246 public static short mod(short l, short r) { 247 return (short) (l % r); 248 } 249 250 public static short or(short l, short r) { 251 return (short) (l | r); 252 } 253 254 public static short and(short l, short r) { 255 return (short) (l & r); 256 } 257 258 public static short xor(short l, short r) { 259 return (short) (l ^ r); 260 } 261 262 public static short ashr(short l, long r) { 263 return (short) (l >> r); 264 } 265 266 public static short lshr(short l, long r) { 267 return (short) (l >>> r); 268 } 269 270 public static short lshl(short l, int r) { 271 return (short) (l << r); 272 } 273 274 public static short ashr(short l, int r) { 275 return (short) (l >> r); 276 } 277 278 public static short lshr(short l, int r) { 279 return (short) (l >>> r); 280 } 281 282 public static boolean eq(short l, short r) { 283 return l == r; 284 } 285 286 public static boolean neq(short l, short r) { 287 return l != r; 288 } 289 290 public static boolean gt(short l, short r) { 291 return l > r; 292 } 293 294 public static boolean ge(short l, short r) { 295 return l >= r; 296 } 297 298 public static boolean lt(short l, short r) { 299 return l < r; 300 } 301 302 public static boolean le(short l, short r) { 303 return l <= r; 304 } 305 306 // char 307 308 public static char neg(char l) { 309 return (char) -l; 310 } 311 312 public static char compl(char l) { 313 return (char) ~l; 314 } 315 316 public static char add(char l, char r) { 317 return (char) (l + r); 318 } 319 320 public static char sub(char l, char r) { 321 return (char) (l - r); 322 } 323 324 public static char mul(char l, char r) { 325 return (char) (l * r); 326 } 327 328 public static char div(char l, char r) { 329 return (char) (l / r); 330 } 331 332 public static char mod(char l, char r) { 333 return (char) (l % r); 334 } 335 336 public static char or(char l, char r) { 337 return (char) (l | r); 338 } 339 340 public static char and(char l, char r) { 341 return (char) (l & r); 342 } 343 344 public static char xor(char l, char r) { 345 return (char) (l ^ r); 346 } 347 348 public static char ashr(char l, long r) { 349 return (char) (l >> r); 350 } 351 352 public static char lshr(char l, long r) { 353 return (char) (l >>> r); 354 } 355 356 public static char lshl(char l, int r) { 357 return (char) (l << r); 358 } 359 360 public static char ashr(char l, int r) { 361 return (char) (l >> r); 362 } 363 364 public static char lshr(char l, int r) { 365 return (char) (l >>> r); 366 } 367 368 public static boolean eq(char l, char r) { 369 return l == r; 370 } 371 372 public static boolean neq(char l, char r) { 373 return l != r; 374 } 375 376 public static boolean gt(char l, char r) { 377 return l > r; 378 } 379 380 public static boolean ge(char l, char r) { 381 return l >= r; 382 } 383 384 public static boolean lt(char l, char r) { 385 return l < r; 386 } 387 388 public static boolean le(char l, char r) { 389 return l <= r; 390 } 391 // long 392 393 public static long neg(long l) { 394 return -l; 395 } 396 397 public static long compl(long l) { 398 return ~l; 399 } 400 401 public static long add(long l, long r) { 402 return l + r; 403 } 404 405 public static long sub(long l, long r) { 406 return l - r; 407 } 408 409 public static long mul(long l, long r) { 410 return l * r; 411 } 412 413 public static long div(long l, long r) { 414 return l / r; 415 } 416 417 public static long mod(long l, long r) { 418 return l % r; 419 } 420 421 public static long or(long l, long r) { 422 return l | r; 423 } 424 425 public static long and(long l, long r) { 426 return l & r; 427 } 428 429 public static long xor(long l, long r) { 430 return l ^ r; 431 } 432 433 public static long lshl(long l, long r) { 434 return l << r; 435 } 436 437 public static long ashr(long l, long r) { 438 return l >> r; 439 } 440 441 public static long lshr(long l, long r) { 442 return l >>> r; 443 } 444 445 public static long lshl(long l, int r) { 446 return l << r; 447 } 448 449 public static long ashr(long l, int r) { 450 return l >> r; 451 } 452 453 public static long lshr(long l, int r) { 454 return l >>> r; 455 } 456 457 public static boolean eq(long l, long r) { 458 return l == r; 459 } 460 461 public static boolean neq(long l, long r) { 462 return l != r; 463 } 464 465 public static boolean gt(long l, long r) { 466 return l > r; 467 } 468 469 public static boolean ge(long l, long r) { 470 return l >= r; 471 } 472 473 public static boolean lt(long l, long r) { 474 return l < r; 475 } 476 477 public static boolean le(long l, long r) { 478 return l <= r; 479 } 480 481 482 // float 483 484 static float neg(float l) { 485 return -l; 486 } 487 488 static float add(float l, float r) { 489 return l + r; 490 } 491 492 static float sub(float l, float r) { 493 return l - r; 494 } 495 496 static float mul(float l, float r) { 497 return l * r; 498 } 499 500 static float div(float l, float r) { 501 return l / r; 502 } 503 504 static float mod(float l, float r) { 505 return l % r; 506 } 507 508 public static boolean eq(float l, float r) { 509 return l == r; 510 } 511 512 public static boolean neq(float l, float r) { 513 return l != r; 514 } 515 516 public static boolean gt(float l, float r) { 517 return l > r; 518 } 519 520 public static boolean ge(float l, float r) { 521 return l >= r; 522 } 523 524 public static boolean lt(float l, float r) { 525 return l < r; 526 } 527 528 public static boolean le(float l, float r) { 529 return l <= r; 530 } 531 532 533 // double 534 535 static double neg(double l) { 536 return -l; 537 } 538 539 static double add(double l, double r) { 540 return l + r; 541 } 542 543 static double sub(double l, double r) { 544 return l - r; 545 } 546 547 static double mul(double l, double r) { 548 return l * r; 549 } 550 551 static double div(double l, double r) { 552 return l / r; 553 } 554 555 static double mod(double l, double r) { 556 return l % r; 557 } 558 559 public static boolean eq(double l, double r) { 560 return l == r; 561 } 562 563 public static boolean neq(double l, double r) { 564 return l != r; 565 } 566 567 public static boolean gt(double l, double r) { 568 return l > r; 569 } 570 571 public static boolean ge(double l, double r) { 572 return l >= r; 573 } 574 575 public static boolean lt(double l, double r) { 576 return l < r; 577 } 578 579 public static boolean le(double l, double r) { 580 return l <= r; 581 } 582 583 584 // boolean 585 586 static boolean eq(boolean l, boolean r) { 587 return l == r; 588 } 589 590 static boolean neq(boolean l, boolean r) { 591 return l != r; 592 } 593 594 static boolean and(boolean l, boolean r) { 595 return l & r; 596 } 597 598 static boolean or(boolean l, boolean r) { 599 return l | r; 600 } 601 602 static boolean xor(boolean l, boolean r) { 603 return l ^ r; 604 } 605 606 607 // Primitive conversions 608 609 // double conversion 610 static double conv_double(double i) { 611 return i; 612 } 613 614 static float conv_float(double i) { 615 return (float) i; 616 } 617 618 static long conv_long(double i) { 619 return (long) i; 620 } 621 622 static int conv_int(double i) { 623 return (int) i; 624 } 625 626 static short conv_short(double i) { 627 return (short) i; 628 } 629 630 static char conv_char(double i) { 631 return (char) i; 632 } 633 634 static byte conv_byte(double i) { 635 return (byte) i; 636 } 637 638 static boolean conv_boolean(double i) { 639 return ((int) i & 1) == 1; 640 } 641 642 // float conversion 643 static double conv_double(float i) { 644 return i; 645 } 646 647 static float conv_float(float i) { 648 return i; 649 } 650 651 static long conv_long(float i) { 652 return (long) i; 653 } 654 655 static int conv_int(float i) { 656 return (int) i; 657 } 658 659 static short conv_short(float i) { 660 return (short) i; 661 } 662 663 static char conv_char(float i) { 664 return (char) i; 665 } 666 667 static byte conv_byte(float i) { 668 return (byte) i; 669 } 670 671 static boolean conv_boolean(float i) { 672 return ((int) i & 1) == 1; 673 } 674 675 // long conversion 676 static double conv_double(long i) { 677 return (double) i; 678 } 679 680 static float conv_float(long i) { 681 return (float) i; 682 } 683 684 static long conv_long(long i) { 685 return i; 686 } 687 688 static int conv_int(long i) { 689 return (int) i; 690 } 691 692 static short conv_short(long i) { 693 return (short) i; 694 } 695 696 static char conv_char(long i) { 697 return (char) i; 698 } 699 700 static byte conv_byte(long i) { 701 return (byte) i; 702 } 703 704 static boolean conv_boolean(long i) { 705 return (i & 1) == 1; 706 } 707 708 // int conversion 709 static double conv_double(int i) { 710 return (double) i; 711 } 712 713 static float conv_float(int i) { 714 return (float) i; 715 } 716 717 static long conv_long(int i) { 718 return i; 719 } 720 721 static int conv_int(int i) { 722 return i; 723 } 724 725 static short conv_short(int i) { 726 return (short) i; 727 } 728 729 static char conv_char(int i) { 730 return (char) i; 731 } 732 733 static byte conv_byte(int i) { 734 return (byte) i; 735 } 736 737 static boolean conv_boolean(int i) { 738 return (i & 1) == 1; 739 } 740 741 // short conversion 742 static double conv_double(short i) { 743 return i; 744 } 745 746 static float conv_float(short i) { 747 return i; 748 } 749 750 static long conv_long(short i) { 751 return i; 752 } 753 754 static int conv_int(short i) { 755 return i; 756 } 757 758 static short conv_short(short i) { 759 return i; 760 } 761 762 static char conv_char(short i) { 763 return (char) i; 764 } 765 766 static byte conv_byte(short i) { 767 return (byte) i; 768 } 769 770 static boolean conv_boolean(short i) { 771 return (i & 1) == 1; 772 } 773 774 // char conversion 775 static double conv_double(char i) { 776 return i; 777 } 778 779 static float conv_float(char i) { 780 return i; 781 } 782 783 static long conv_long(char i) { 784 return i; 785 } 786 787 static int conv_int(char i) { 788 return i; 789 } 790 791 static short conv_short(char i) { 792 return (short) i; 793 } 794 795 static char conv_char(char i) { 796 return i; 797 } 798 799 static byte conv_byte(char i) { 800 return (byte) i; 801 } 802 803 static boolean conv_boolean(char i) { 804 return (i & 1) == 1; 805 } 806 807 // byte conversion 808 static double conv_double(byte i) { 809 return i; 810 } 811 812 static float conv_float(byte i) { 813 return i; 814 } 815 816 static long conv_long(byte i) { 817 return i; 818 } 819 820 static int conv_int(byte i) { 821 return i; 822 } 823 824 static short conv_short(byte i) { 825 return i; 826 } 827 828 static char conv_char(byte i) { 829 return (char) i; 830 } 831 832 static byte conv_byte(byte i) { 833 return i; 834 } 835 836 static boolean conv_boolean(byte i) { 837 return (i & 1) == 1; 838 } 839 840 // boolean conversion 841 static double conv_double(boolean i) { 842 return i ? 1d : 0d; 843 } 844 845 static float conv_float(boolean i) { 846 return i ? 1f : 0f; 847 } 848 849 static long conv_long(boolean i) { 850 return i ? 1l : 0l; 851 } 852 853 static int conv_int(boolean i) { 854 return i ? 1 : 0; 855 } 856 857 static short conv_short(boolean i) { 858 return i ? (short) 1 : 0; 859 } 860 861 static char conv_char(boolean i) { 862 return i ? (char) 1 : 0; 863 } 864 865 static byte conv_byte(boolean i) { 866 return i ? (byte) 1 : 0; 867 } 868 869 static boolean conv_boolean(boolean i) { 870 return i; 871 } 872 }