Changeset 12064
- Timestamp:
- 07/26/09 21:48:15 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/src/org/armedbear/lisp/LispThread.java
r12062 r12064 448 448 } 449 449 450 private static class StackFrame extends LispObject450 private static class StackFrame 451 451 { 452 452 public final LispObject operator; … … 455 455 private final LispObject third; 456 456 private final LispObject[] args; 457 458 public StackFrame(LispObject operator) 457 final StackFrame next; 458 459 public StackFrame(LispObject operator, StackFrame next) 459 460 { 460 461 this.operator = operator; … … 463 464 third = null; 464 465 args = null; 465 } 466 467 public StackFrame(LispObject operator, LispObject arg) 466 this.next = next; 467 } 468 469 public StackFrame(LispObject operator, LispObject arg, StackFrame next) 468 470 { 469 471 this.operator = operator; … … 472 474 third = null; 473 475 args = null; 476 this.next = next; 474 477 } 475 478 476 479 public StackFrame(LispObject operator, LispObject first, 477 LispObject second )480 LispObject second, StackFrame next) 478 481 { 479 482 this.operator = operator; … … 482 485 third = null; 483 486 args = null; 487 this.next = next; 484 488 } 485 489 486 490 public StackFrame(LispObject operator, LispObject first, 487 LispObject second, LispObject third )491 LispObject second, LispObject third, StackFrame next) 488 492 { 489 493 this.operator = operator; … … 492 496 this.third = third; 493 497 args = null; 494 } 495 496 public StackFrame(LispObject operator, LispObject[] args) 498 this.next = next; 499 } 500 501 public StackFrame(LispObject operator, LispObject[] args, StackFrame next) 497 502 { 498 503 this.operator = operator; … … 501 506 third = null; 502 507 this.args = args; 508 this.next = next; 503 509 } 504 510 … … 535 541 } 536 542 537 private LispObject stack = NIL; 538 543 private StackFrame stack = null; 544 545 @Deprecated 539 546 public LispObject getStack() 540 547 { 541 return stack; 542 } 543 548 return NIL; 549 } 550 551 @Deprecated 544 552 public void setStack(LispObject stack) 545 553 { 546 this.stack = stack;547 554 } 548 555 … … 559 566 throws ConditionThrowable 560 567 { 561 stack = new Cons((new StackFrame(operator)), stack);568 stack = new StackFrame(operator, stack); 562 569 doProfiling(); 563 570 } … … 566 573 throws ConditionThrowable 567 574 { 568 stack = new Cons((new StackFrame(operator, arg)), stack);575 stack = new StackFrame(operator, arg, stack); 569 576 doProfiling(); 570 577 } … … 574 581 throws ConditionThrowable 575 582 { 576 stack = new Cons((new StackFrame(operator, first, second)), stack);583 stack = new StackFrame(operator, first, second, stack); 577 584 doProfiling(); 578 585 } … … 582 589 throws ConditionThrowable 583 590 { 584 stack = new Cons((new StackFrame(operator, first, second, third)), 585 stack); 591 stack = new StackFrame(operator, first, second, third, stack); 586 592 doProfiling(); 587 593 } … … 590 596 throws ConditionThrowable 591 597 { 592 stack = new Cons((new StackFrame(operator, args)), stack);598 stack = new StackFrame(operator, args, stack); 593 599 doProfiling(); 594 600 } 595 601 602 public final void popStackFrame() 603 { 604 if (stack != null) 605 stack = stack.next; 606 } 607 596 608 public void resetStack() 597 609 { 598 stack = NIL;610 stack = null; 599 611 } 600 612 … … 605 617 return function.execute(); 606 618 607 LispObject oldStack = stack;608 619 pushStackFrame(function); 609 620 try { … … 612 623 finally { 613 624 doProfiling(); 614 stack = oldStack;625 popStackFrame(); 615 626 } 616 627 } … … 623 634 return function.execute(arg); 624 635 625 LispObject oldStack = stack;626 636 pushStackFrame(function, arg); 627 637 try { … … 630 640 finally { 631 641 doProfiling(); 632 stack = oldStack;642 popStackFrame(); 633 643 } 634 644 } … … 642 652 return function.execute(first, second); 643 653 644 LispObject oldStack = stack;645 654 pushStackFrame(function, first, second); 646 655 try { … … 649 658 finally { 650 659 doProfiling(); 651 stack = oldStack;660 popStackFrame(); 652 661 } 653 662 } … … 661 670 return function.execute(first, second, third); 662 671 663 LispObject oldStack = stack;664 672 pushStackFrame(function, first, second, third); 665 673 try { … … 668 676 finally { 669 677 doProfiling(); 670 stack = oldStack;678 popStackFrame(); 671 679 } 672 680 } … … 681 689 return function.execute(first, second, third, fourth); 682 690 683 LispObject oldStack = stack;684 691 pushStackFrame(function, first, second, third, fourth); 685 692 try { … … 688 695 finally { 689 696 doProfiling(); 690 stack = oldStack;697 popStackFrame(); 691 698 } 692 699 } … … 701 708 return function.execute(first, second, third, fourth, fifth); 702 709 703 LispObject oldStack = stack;704 710 pushStackFrame(function, first, second, third, fourth, fifth); 705 711 try { … … 708 714 finally { 709 715 doProfiling(); 710 stack = oldStack;716 popStackFrame(); 711 717 } 712 718 } … … 722 728 return function.execute(first, second, third, fourth, fifth, sixth); 723 729 724 LispObject oldStack = stack;725 730 pushStackFrame(function, first, second, third, fourth, fifth, sixth); 726 731 try { … … 729 734 finally { 730 735 doProfiling(); 731 stack = oldStack;736 popStackFrame(); 732 737 } 733 738 } … … 744 749 seventh); 745 750 746 LispObject oldStack = stack;747 751 pushStackFrame(function, first, second, third, fourth, fifth, sixth, 748 752 seventh); … … 753 757 finally { 754 758 doProfiling(); 755 stack = oldStack;759 popStackFrame(); 756 760 } 757 761 } … … 768 772 seventh, eighth); 769 773 770 LispObject oldStack = stack;771 774 pushStackFrame(function, first, second, third, fourth, fifth, sixth, 772 775 seventh, eighth); … … 777 780 finally { 778 781 doProfiling(); 779 stack = oldStack;782 popStackFrame(); 780 783 } 781 784 } … … 787 790 return function.execute(args); 788 791 789 LispObject oldStack = stack;790 792 pushStackFrame(function, args); 791 793 try { … … 794 796 finally { 795 797 doProfiling(); 796 stack = oldStack;798 popStackFrame(); 797 799 } 798 800 } … … 805 807 public void backtrace(int limit) 806 808 { 807 if (stack != NIL) {809 if (stack != null) { 808 810 try { 809 811 int count = 0; … … 812 814 out._writeLine("Evaluation stack:"); 813 815 out._finishOutput(); 814 while (stack != NIL) { 816 817 StackFrame s = stack; 818 while (s != null) { 815 819 out._writeString(" "); 816 820 out._writeString(String.valueOf(count)); 817 821 out._writeString(": "); 818 StackFrame frame = (StackFrame) stack.car();819 pprint( frame.toList(), out.getCharPos(), out);822 823 pprint(s.toList(), out.getCharPos(), out); 820 824 out.terpri(); 821 825 out._finishOutput(); 822 826 if (limit > 0 && ++count == limit) 823 827 break; 824 s tack = stack.cdr();828 s = s.next; 825 829 } 826 830 } … … 834 838 { 835 839 LispObject result = NIL; 836 if (stack != NIL) {840 if (stack != null) { 837 841 int count = 0; 838 842 try { 839 LispObject s = stack; 840 while (s != NIL) { 841 StackFrame frame = (StackFrame) s.car(); 842 if (frame != null) { 843 result = result.push(frame.toList()); 844 if (limit > 0 && ++count == limit) 845 break; 846 } 847 s = s.cdr(); 843 StackFrame s = stack; 844 while (s != null) { 845 result = result.push(s.toList()); 846 if (limit > 0 && ++count == limit) 847 break; 848 s = s.next; 848 849 } 849 850 } … … 857 858 public void incrementCallCounts() throws ConditionThrowable 858 859 { 859 LispObject s = stack; 860 while (s != NIL) { 861 StackFrame frame = (StackFrame) s.car(); 862 if (frame != null) { 863 LispObject operator = frame.operator; 864 if (operator != null) 865 operator.incrementCallCount(); 866 } 867 s = s.cdr(); 860 StackFrame s = stack; 861 while (s != null) { 862 LispObject operator = s.operator; 863 if (operator != null) 864 operator.incrementCallCount(); 865 s = s.next; 868 866 } 869 867 }
Note: See TracChangeset
for help on using the changeset viewer.