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