1687 |
1686 |
1688 printOn:aStream |
1687 printOn:aStream |
1689 "append a printed representation of the receiver to aStream" |
1688 "append a printed representation of the receiver to aStream" |
1690 |
1689 |
1691 self isLiteral ifTrue:[ |
1690 self isLiteral ifTrue:[ |
1692 |limit firstOne s| |
1691 |limit firstOne s| |
1693 |
1692 |
1694 thisContext isRecursive ifTrue:[ |
1693 thisContext isRecursive ifTrue:[ |
1695 'Array [error]: printOn: of self referencing collection.' errorPrintCR. |
1694 'Array [error]: printOn: of self referencing collection.' errorPrintCR. |
1696 aStream nextPutAll:'#("recursive")'. |
1695 aStream nextPutAll:'#("recursive")'. |
1697 ^ self |
1696 ^ self |
1698 ]. |
1697 ]. |
1699 |
1698 |
1700 aStream nextPutAll:'#('. |
1699 aStream nextPutAll:'#('. |
1701 firstOne := true. |
1700 firstOne := true. |
1702 |
1701 |
1703 " |
1702 " |
1704 if aStream is not positionable, create an temporary positionable stream |
1703 if aStream is not positionable, create an temporary positionable stream |
1705 (needed for limit calculation) |
1704 (needed for limit calculation) |
1706 " |
1705 " |
1707 aStream isPositionable ifTrue:[ |
1706 aStream isPositionable ifTrue:[ |
1708 s := aStream. |
1707 s := aStream. |
1709 ] ifFalse:[ |
1708 ] ifFalse:[ |
1710 s := WriteStream on:(String uninitializedNew:50). |
1709 s := WriteStream on:(String uninitializedNew:50). |
1711 ]. |
1710 ]. |
1712 limit := s position1Based + self maxPrint. |
1711 limit := s position0Based + self maxPrint. |
1713 |
1712 |
1714 self printElementsDo:[:element | |
1713 self printElementsDo:[:element | |
1715 firstOne ifFalse:[ |
1714 firstOne ifFalse:[ |
1716 s space |
1715 s space |
1717 ] ifTrue:[ |
1716 ] ifTrue:[ |
1718 firstOne := false |
1717 firstOne := false |
1719 ]. |
1718 ]. |
1720 (s position1Based >= limit) ifTrue:[ |
1719 (s position0Based >= limit) ifTrue:[ |
1721 s ~~ aStream ifTrue:[ |
1720 s ~~ aStream ifTrue:[ |
1722 aStream nextPutAll:(s contents). |
1721 aStream nextPutAll:(s contents). |
1723 ]. |
1722 ]. |
1724 aStream nextPutAll:'...etc...)'. |
1723 aStream nextPutAll:'...etc...)'. |
1725 ^ self |
1724 ^ self |
1726 ] ifFalse:[ |
1725 ] ifFalse:[ |
1727 element printOn:s. |
1726 element printOn:s. |
1728 ]. |
1727 ]. |
1729 ]. |
1728 ]. |
1730 s ~~ aStream ifTrue:[ |
1729 s ~~ aStream ifTrue:[ |
1731 aStream nextPutAll:(s contents). |
1730 aStream nextPutAll:(s contents). |
1732 ]. |
1731 ]. |
1733 aStream nextPut:$) |
1732 aStream nextPut:$) |
1734 ] ifFalse:[ |
1733 ] ifFalse:[ |
1735 super printOn:aStream |
1734 super printOn:aStream |
1736 ] |
1735 ] |
1737 |
1736 |
1738 " |
1737 " |
1739 #(1 2 $a 'hello' sym kewordSymbol:with: #'funny symbol') printString |
1738 #(1 2 $a 'hello' sym kewordSymbol:with: #'funny symbol') printString |
1740 #(1 2 $a [1 2 3] true false nil #true #false #nil) printString |
1739 #(1 2 $a [1 2 3] true false nil #true #false #nil) printString |