Changeset 12062
- Timestamp:
- 07/26/09 19:37:47 (14 years ago)
- Location:
- trunk/abcl/src/org/armedbear/lisp
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/src/org/armedbear/lisp/Lisp.java
r12061 r12062 141 141 throws ConditionThrowable 142 142 { 143 LispObject stack = thread.getStack(); 143 144 thread.pushStackFrame(fun, args); 144 145 thread._values = null; … … 189 190 finally 190 191 { 191 thread. popStackFrame();192 thread.setStack(stack); 192 193 } 193 194 return result; -
trunk/abcl/src/org/armedbear/lisp/LispThread.java
r12061 r12062 35 35 36 36 import java.util.Iterator; 37 import java.util.LinkedList;38 37 import java.util.concurrent.ConcurrentHashMap; 39 38 … … 449 448 } 450 449 451 private static class StackFrame 450 private static class StackFrame extends LispObject 452 451 { 453 452 public final LispObject operator; … … 536 535 } 537 536 538 private LinkedList<StackFrame> stack = new LinkedList<StackFrame>(); 539 540 @Deprecated 537 private LispObject stack = NIL; 538 541 539 public LispObject getStack() 542 540 { 543 return NIL; 544 } 545 546 @Deprecated 541 return stack; 542 } 543 547 544 public void setStack(LispObject stack) 548 545 { 546 this.stack = stack; 549 547 } 550 548 … … 561 559 throws ConditionThrowable 562 560 { 563 stack .addLast(new StackFrame(operator));561 stack = new Cons((new StackFrame(operator)), stack); 564 562 doProfiling(); 565 563 } … … 568 566 throws ConditionThrowable 569 567 { 570 stack .addLast(new StackFrame(operator, arg));568 stack = new Cons((new StackFrame(operator, arg)), stack); 571 569 doProfiling(); 572 570 } … … 576 574 throws ConditionThrowable 577 575 { 578 stack .addLast(new StackFrame(operator, first, second));576 stack = new Cons((new StackFrame(operator, first, second)), stack); 579 577 doProfiling(); 580 578 } … … 584 582 throws ConditionThrowable 585 583 { 586 stack.addLast(new StackFrame(operator, first, second, third)); 584 stack = new Cons((new StackFrame(operator, first, second, third)), 585 stack); 587 586 doProfiling(); 588 587 } … … 591 590 throws ConditionThrowable 592 591 { 593 stack .addLast(new StackFrame(operator, args));592 stack = new Cons((new StackFrame(operator, args)), stack); 594 593 doProfiling(); 595 594 } 596 595 597 public final void popStackFrame()598 {599 stack.removeLast();600 }601 602 596 public void resetStack() 603 597 { 604 stack .clear();598 stack = NIL; 605 599 } 606 600 … … 611 605 return function.execute(); 612 606 607 LispObject oldStack = stack; 613 608 pushStackFrame(function); 614 609 try { … … 617 612 finally { 618 613 doProfiling(); 619 popStackFrame();614 stack = oldStack; 620 615 } 621 616 } … … 628 623 return function.execute(arg); 629 624 625 LispObject oldStack = stack; 630 626 pushStackFrame(function, arg); 631 627 try { … … 634 630 finally { 635 631 doProfiling(); 636 popStackFrame();632 stack = oldStack; 637 633 } 638 634 } … … 646 642 return function.execute(first, second); 647 643 644 LispObject oldStack = stack; 648 645 pushStackFrame(function, first, second); 649 646 try { … … 652 649 finally { 653 650 doProfiling(); 654 popStackFrame();651 stack = oldStack; 655 652 } 656 653 } … … 664 661 return function.execute(first, second, third); 665 662 663 LispObject oldStack = stack; 666 664 pushStackFrame(function, first, second, third); 667 665 try { … … 670 668 finally { 671 669 doProfiling(); 672 popStackFrame();670 stack = oldStack; 673 671 } 674 672 } … … 683 681 return function.execute(first, second, third, fourth); 684 682 683 LispObject oldStack = stack; 685 684 pushStackFrame(function, first, second, third, fourth); 686 685 try { … … 689 688 finally { 690 689 doProfiling(); 691 popStackFrame();690 stack = oldStack; 692 691 } 693 692 } … … 702 701 return function.execute(first, second, third, fourth, fifth); 703 702 703 LispObject oldStack = stack; 704 704 pushStackFrame(function, first, second, third, fourth, fifth); 705 705 try { … … 708 708 finally { 709 709 doProfiling(); 710 popStackFrame();710 stack = oldStack; 711 711 } 712 712 } … … 722 722 return function.execute(first, second, third, fourth, fifth, sixth); 723 723 724 LispObject oldStack = stack; 724 725 pushStackFrame(function, first, second, third, fourth, fifth, sixth); 725 726 try { … … 728 729 finally { 729 730 doProfiling(); 730 popStackFrame();731 stack = oldStack; 731 732 } 732 733 } … … 743 744 seventh); 744 745 746 LispObject oldStack = stack; 745 747 pushStackFrame(function, first, second, third, fourth, fifth, sixth, 746 748 seventh); … … 751 753 finally { 752 754 doProfiling(); 753 popStackFrame();755 stack = oldStack; 754 756 } 755 757 } … … 766 768 seventh, eighth); 767 769 770 LispObject oldStack = stack; 768 771 pushStackFrame(function, first, second, third, fourth, fifth, sixth, 769 772 seventh, eighth); … … 774 777 finally { 775 778 doProfiling(); 776 popStackFrame();779 stack = oldStack; 777 780 } 778 781 } … … 784 787 return function.execute(args); 785 788 789 LispObject oldStack = stack; 786 790 pushStackFrame(function, args); 787 791 try { … … 790 794 finally { 791 795 doProfiling(); 792 popStackFrame();796 stack = oldStack; 793 797 } 794 798 } … … 801 805 public void backtrace(int limit) 802 806 { 803 if ( ! stack.isEmpty()) {807 if (stack != NIL) { 804 808 try { 805 809 int count = 0; … … 808 812 out._writeLine("Evaluation stack:"); 809 813 out._finishOutput(); 810 Iterator<StackFrame> i = stack.iterator(); 811 while (i.hasNext()) { 814 while (stack != NIL) { 812 815 out._writeString(" "); 813 816 out._writeString(String.valueOf(count)); 814 817 out._writeString(": "); 815 StackFrame frame = i.next();818 StackFrame frame = (StackFrame) stack.car(); 816 819 pprint(frame.toList(), out.getCharPos(), out); 817 820 out.terpri(); … … 819 822 if (limit > 0 && ++count == limit) 820 823 break; 824 stack = stack.cdr(); 821 825 } 822 826 } … … 830 834 { 831 835 LispObject result = NIL; 832 if ( ! stack.isEmpty()) {836 if (stack != NIL) { 833 837 int count = 0; 834 838 try { 835 Iterator<StackFrame> i = stack.iterator();836 while ( i.hasNext()) {837 StackFrame frame = i.next();839 LispObject s = stack; 840 while (s != NIL) { 841 StackFrame frame = (StackFrame) s.car(); 838 842 if (frame != null) { 839 843 result = result.push(frame.toList()); … … 841 845 break; 842 846 } 847 s = s.cdr(); 843 848 } 844 849 } … … 852 857 public void incrementCallCounts() throws ConditionThrowable 853 858 { 854 Iterator<StackFrame> i = stack.iterator();855 while ( i.hasNext()) {856 StackFrame frame = i.next();859 LispObject s = stack; 860 while (s != NIL) { 861 StackFrame frame = (StackFrame) s.car(); 857 862 if (frame != null) { 858 863 LispObject operator = frame.operator; … … 860 865 operator.incrementCallCount(); 861 866 } 867 s = s.cdr(); 862 868 } 863 869 }
Note: See TracChangeset
for help on using the changeset viewer.