]> gitweb.factorcode.org Git - factor.git/blob - basis/alien/prettyprint/prettyprint.factor
convert compiler cpu backends to use c-type words
[factor.git] / basis / alien / prettyprint / prettyprint.factor
1 ! Copyright (C) 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: kernel combinators alien alien.strings alien.c-types
4 alien.syntax arrays math.parser prettyprint.backend
5 prettyprint.custom prettyprint.sections definitions see see.private
6 strings words ;
7 IN: alien.prettyprint
8
9 M: alien pprint*
10     {
11         { [ dup expired? ] [ drop \ BAD-ALIEN pprint-word ] }
12         { [ dup pinned-c-ptr? not ] [ drop "( displaced alien )" text ] }
13         [ \ ALIEN: [ alien-address >hex text ] pprint-prefix ]
14     } cond ;
15
16 M: dll pprint* dll-path dup "DLL\" " "\"" pprint-string ;
17
18 M: c-type-word definer drop \ C-TYPE: f ;
19 M: c-type-word definition drop f ;
20
21 GENERIC: pprint-c-type ( c-type -- )
22 M: word pprint-c-type pprint-word ;
23 M: string pprint-c-type text ;
24 M: array pprint-c-type pprint* ;
25
26 M: typedef-word see-class*
27     <colon
28     \ TYPEDEF: pprint-word
29     dup "c-type" word-prop pprint-c-type
30     pprint-word
31     block> ;