| 592 | |
| 593 | public String toString() |
| 594 | { |
| 595 | switch (name) |
| 596 | { |
| 597 | case OC_TEXT: |
| 598 | return "print " + location.getCode(); |
| 599 | case OC_LOADNONE: |
| 600 | return "r" + r1 + " = None"; |
| 601 | case OC_LOADFALSE: |
| 602 | return "r" + r1 + " = False"; |
| 603 | case OC_LOADTRUE: |
| 604 | return "r" + r1 + " = True"; |
| 605 | case OC_LOADINT: |
| 606 | return "r" + r1 + " = " + arg; |
| 607 | case OC_LOADFLOAT: |
| 608 | return "r" + r1 + " = " + arg; |
| 609 | case OC_LOADSTR: |
| 610 | return "r" + r1 + " = " + Utils.repr(arg); |
| 611 | case OC_LOADDATE: |
| 612 | return "r" + r1 + " = " + Utils.repr(arg); |
| 613 | case OC_BUILDLIST: |
| 614 | return "r" + r1 + " = []"; |
| 615 | case OC_BUILDDICT: |
| 616 | return "r" + r1 + " = {}"; |
| 617 | case OC_ADDLIST: |
| 618 | return "r" + r1 + ".append(r" + r2 + ")"; |
| 619 | case OC_ADDDICT: |
| 620 | return "r" + r1 + "[r" + r2 + "] = r" + r3; |
| 621 | case OC_LOADVAR: |
| 622 | return "r" + r1 + " = vars[" + Utils.repr(arg) + "]"; |
| 623 | case OC_STOREVAR: |
| 624 | return "vars[" + Utils.repr(arg) + "] = r" + r1; |
| 625 | case OC_ADDVAR: |
| 626 | return "vars[" + Utils.repr(arg) + "] += r" + r1; |
| 627 | case OC_SUBVAR: |
| 628 | return "vars[" + Utils.repr(arg) + "] -= r" + r1; |
| 629 | case OC_MULVAR: |
| 630 | return "vars[" + Utils.repr(arg) + "] *= r" + r1; |
| 631 | case OC_TRUEDIVVAR: |
| 632 | return "vars[" + Utils.repr(arg) + "] /= r" + r1; |
| 633 | case OC_FLOORDIVVAR: |
| 634 | return "vars[" + Utils.repr(arg) + "] //= r" + r1; |
| 635 | case OC_MODVAR: |
| 636 | return "vars[" + Utils.repr(arg) + "] %= r" + r1; |
| 637 | case OC_DELVAR: |
| 638 | return "del vars[" + Utils.repr(arg) + "]"; |
| 639 | case OC_GETATTR: |
| 640 | return "r" + r1 + " = getattr(r" + r2 + ", " + Utils.repr(arg) + ")"; |
| 641 | case OC_GETITEM: |
| 642 | return "r" + r1 + " = r" + r2 + "[r" + r3 + "]"; |
| 643 | case OC_GETSLICE12: |
| 644 | return "r" + r1 + " = r" + r2 + "[r" + r3 + ":r" + r4 + "]"; |
| 645 | case OC_GETSLICE1: |
| 646 | return "r" + r1 + " = r" + r2 + "[r" + r3 + ":]"; |
| 647 | case OC_GETSLICE2: |
| 648 | return "r" + r1 + " = r" + r2 + "[:r" + r4 + "]"; |
| 649 | case OC_PRINT: |
| 650 | return "print r" + r1; |
| 651 | case OC_PRINTX: |
| 652 | return "print xmlescape(r" + r1 + ")"; |
| 653 | case OC_NOT: |
| 654 | return "r" + r1 + " = not r" + r2; |
| 655 | case OC_NEG: |
| 656 | return "r" + r1 + " = -r" + r2; |
| 657 | case OC_EQ: |
| 658 | return "r" + r1 + " = r" + r2 + " == r" + r3; |
| 659 | case OC_NE: |
| 660 | return "r" + r1 + " = r" + r2 + " != r" + r3; |
| 661 | case OC_LT: |
| 662 | return "r" + r1 + " = r" + r2 + " < r" + r3; |
| 663 | case OC_LE: |
| 664 | return "r" + r1 + " = r" + r2 + " <= r" + r3; |
| 665 | case OC_GT: |
| 666 | return "r" + r1 + " = r" + r2 + " > r" + r3; |
| 667 | case OC_GE: |
| 668 | return "r" + r1 + " = r" + r2 + " >= r" + r3; |
| 669 | case OC_CONTAINS: |
| 670 | return "r" + r1 + " = r" + r2 + " in r" + r3; |
| 671 | case OC_NOTCONTAINS: |
| 672 | return "r" + r1 + " = r" + r2 + " not in r" + r3; |
| 673 | case OC_ADD: |
| 674 | return "r" + r1 + " = r" + r2 + " + r" + r3; |
| 675 | case OC_SUB: |
| 676 | return "r" + r1 + " = r" + r2 + " - r" + r3; |
| 677 | case OC_MUL: |
| 678 | return "r" + r1 + " = r" + r2 + " == r" + r3; |
| 679 | case OC_FLOORDIV: |
| 680 | return "r" + r1 + " = r" + r2 + " // r" + r3; |
| 681 | case OC_TRUEDIV: |
| 682 | return "r" + r1 + " = r" + r2 + " / r" + r3; |
| 683 | case OC_AND: |
| 684 | return "r" + r1 + " = r" + r2 + " and r" + r3; |
| 685 | case OC_OR: |
| 686 | return "r" + r1 + " = r" + r2 + " or r" + r3; |
| 687 | case OC_MOD: |
| 688 | return "r" + r1 + " = r" + r2 + " % r" + r3; |
| 689 | case OC_CALLFUNC0: |
| 690 | return "r" + r1 + " = " + arg + "()"; |
| 691 | case OC_CALLFUNC1: |
| 692 | return "r" + r1 + " = " + arg + "(r" + r2 + ")"; |
| 693 | case OC_CALLFUNC2: |
| 694 | return "r" + r1 + " = " + arg + "(r" + r2 + ", " + r3 + ")"; |
| 695 | case OC_CALLFUNC3: |
| 696 | return "r" + r1 + " = " + arg + "(r" + r2 + ", " + r3 + ", " + r4 + ")"; |
| 697 | case OC_CALLMETH0: |
| 698 | return "r" + r1 + " = r" + r2 + "." + arg + "()"; |
| 699 | case OC_CALLMETH1: |
| 700 | return "r" + r1 + " = r" + r2 + "." + arg + "(r" + r3 + ")"; |
| 701 | case OC_CALLMETH2: |
| 702 | return "r" + r1 + " = r" + r2 + "." + arg + "(r" + r3 + ", " + r4 + ")"; |
| 703 | case OC_CALLMETH3: |
| 704 | return "r" + r1 + " = r" + r2 + "." + arg + "(r" + r3 + ", " + r4 + ", " + r5 + ")"; |
| 705 | case OC_IF: |
| 706 | return "if r" + r1; |
| 707 | case OC_ELSE: |
| 708 | return "else"; |
| 709 | case OC_ENDIF: |
| 710 | return "endif"; |
| 711 | case OC_FOR: |
| 712 | return "for r" + r1 + " in r" + r2; |
| 713 | case OC_ENDFOR: |
| 714 | return "endfor"; |
| 715 | case OC_BREAK: |
| 716 | return "break"; |
| 717 | case OC_CONTINUE: |
| 718 | return "continue"; |
| 719 | case OC_RENDER: |
| 720 | return "render " + arg + "(r" + r1 + ")"; |
| 721 | default: |
| 722 | throw new IllegalArgumentException("Opcode code " + name + " unknown!"); |
| 723 | } |
| 724 | } |