1740 |
1741 |
1741 printOn:aStream |
1742 printOn:aStream |
1742 "append a printed representation of the receiver to aStream" |
1743 "append a printed representation of the receiver to aStream" |
1743 |
1744 |
1744 self isLiteral ifTrue:[ |
1745 self isLiteral ifTrue:[ |
1745 |limit firstOne s| |
1746 |limit firstOne s| |
1746 |
1747 |
1747 thisContext isRecursive ifTrue:[ |
1748 thisContext isRecursive ifTrue:[ |
1748 'Array [error]: printOn: of self referencing collection.' errorPrintCR. |
1749 'Array [error]: printOn: of self referencing collection.' errorPrintCR. |
1749 aStream nextPutAll:'#("recursive")'. |
1750 aStream nextPutAll:'#("recursive")'. |
1750 ^ self |
1751 ^ self |
1751 ]. |
1752 ]. |
1752 |
1753 |
1753 aStream nextPutAll:'#('. |
1754 aStream nextPutAll:'#('. |
1754 firstOne := true. |
1755 firstOne := true. |
1755 |
1756 |
1756 " |
1757 " |
1757 if aStream is not positionable, create an temporary positionable stream |
1758 if aStream is not positionable, create an temporary positionable stream |
1758 (needed for limit calculation) |
1759 (needed for limit calculation) |
1759 " |
1760 " |
1760 aStream isPositionable ifTrue:[ |
1761 aStream isPositionable ifTrue:[ |
1761 s := aStream. |
1762 s := aStream. |
1762 ] ifFalse:[ |
1763 ] ifFalse:[ |
1763 s := WriteStream on:(String uninitializedNew:50). |
1764 s := CharacterWriteStream new:50. |
1764 ]. |
1765 ]. |
1765 limit := s position + self maxPrint. |
1766 limit := s position + self maxPrint. |
1766 |
1767 |
1767 self printElementsDo:[:element | |
1768 self printElementsDo:[:element | |
1768 firstOne ifFalse:[ |
1769 firstOne ifFalse:[ |
1769 s space |
1770 s space |
1770 ] ifTrue:[ |
1771 ] ifTrue:[ |
1771 firstOne := false |
1772 firstOne := false |
1772 ]. |
1773 ]. |
1773 (s position >= limit) ifTrue:[ |
1774 (s position >= limit) ifTrue:[ |
1774 s ~~ aStream ifTrue:[ |
1775 s ~~ aStream ifTrue:[ |
1775 aStream nextPutAll:(s contents). |
1776 aStream nextPutAll:(s contents). |
1776 ]. |
1777 ]. |
1777 aStream nextPutAll:'...etc...)'. |
1778 aStream nextPutAll:'...etc...)'. |
1778 ^ self |
1779 ^ self |
1779 ] ifFalse:[ |
1780 ] ifFalse:[ |
1780 element printOn:s. |
1781 element printOn:s. |
1781 ]. |
1782 ]. |
1782 ]. |
1783 ]. |
1783 s ~~ aStream ifTrue:[ |
1784 s ~~ aStream ifTrue:[ |
1784 aStream nextPutAll:(s contents). |
1785 aStream nextPutAll:(s contents). |
1785 ]. |
1786 ]. |
1786 aStream nextPut:$) |
1787 aStream nextPut:$) |
1787 ] ifFalse:[ |
1788 ] ifFalse:[ |
1788 super printOn:aStream |
1789 super printOn:aStream |
1789 ] |
1790 ] |
1790 |
1791 |
1791 " |
1792 " |
1792 #(1 2 $a 'hello' sym kewordSymbol:with: #'funny symbol') printString |
1793 #(1 2 $a $Š 'hello' sym kewordSymbol:with: #'funny symbol') printString |
1793 #(1 2 $a [1 2 3] true false nil #true #false #nil) printString |
1794 #(1 2 $a [1 2 3] true false nil #true #false #nil) printString |
1794 " |
1795 " |
1795 |
1796 |
1796 "Created: 20.11.1995 / 11:16:58 / cg" |
1797 "Created: 20.11.1995 / 11:16:58 / cg" |
1797 ! |
1798 ! |