1 ! Copyright (C) 2009 Slava Pestov.
2 ! See https://factorcode.org/license.txt for BSD license.
3 USING: accessors arrays byte-arrays kernel make math
4 math.parser prettyprint sequences smalltalk.ast strings
8 GENERIC: smalltalk>string ( object -- string )
10 M: real smalltalk>string number>string ;
12 M: string smalltalk>string
15 [ dup CHAR: ' = [ dup , , ] [ , ] if ] each
19 GENERIC: array-element>string ( object -- string )
21 M: object array-element>string smalltalk>string ;
23 M: array array-element>string
24 [ array-element>string ] map join-words "(" ")" surround ;
26 M: array smalltalk>string
27 array-element>string "#" prepend ;
29 M: byte-array smalltalk>string
30 [ number>string ] { } map-as join-words "#[" "]" surround ;
32 M: symbol smalltalk>string
33 name>> smalltalk>string "#" prepend ;
35 M: object smalltalk>string unparse-short ;