]> gitweb.factorcode.org Git - factor.git/commitdiff
cuda: adding prettyprint for cuda functions.
authorJohn Benediktsson <mrjbq7@gmail.com>
Thu, 7 Apr 2016 14:21:41 +0000 (07:21 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Thu, 7 Apr 2016 14:26:23 +0000 (07:26 -0700)
extra/cuda/libraries/libraries.factor
extra/cuda/prettyprint/prettyprint.factor [new file with mode: 0644]
extra/cuda/syntax/syntax.factor

index 21eef3d46e7724b962b08d32b9758070288e5c41..41afac8602f54a689609e074afb6520be155bc32 100644 (file)
@@ -4,7 +4,7 @@ USING: accessors alien.data alien.parser arrays assocs
 byte-arrays classes.struct classes.struct.private combinators
 combinators.short-circuit cuda cuda.ffi fry generalizations
 io.backend kernel locals macros math namespaces sequences
-variants words ;
+variants vocabs.loader words ;
 QUALIFIED-WITH: alien.c-types c
 IN: cuda.libraries
 
@@ -201,3 +201,5 @@ ERROR: bad-cuda-abi abi ;
 : add-cuda-library ( name abi path -- )
     normalize-path <cuda-library>
     dup name>> cuda-libraries get-global set-at ;
+
+{ "cuda.libraries" "prettyprint" } "cuda.prettyprint" require-when
diff --git a/extra/cuda/prettyprint/prettyprint.factor b/extra/cuda/prettyprint/prettyprint.factor
new file mode 100644 (file)
index 0000000..a802c21
--- /dev/null
@@ -0,0 +1,29 @@
+USING: accessors alien.prettyprint combinators
+combinators.short-circuit cuda.libraries cuda.syntax definitions
+effects kernel prettyprint.backend prettyprint.sections see
+see.private sequences words ;
+IN: cuda.prettyprint
+
+PREDICATE: cuda-function-word < word
+    def>> { [ length 14 = ] [ last \ cuda-invoke eq? ] } 1&& ;
+
+: pprint-cuda-library ( library -- )
+    [ \ CUDA-LIBRARY: [ text ] pprint-prefix ] when* ;
+
+: pprint-cuda-function ( word quot -- )
+    [
+        <block "(" text
+        [ def>> third ] [ stack-effect in>> ] bi
+        pprint-function-args
+        ")" text block>
+    ] bi ; inline
+
+M: cuda-function-word definer drop \ CUDA-FUNCTION: \ ; ;
+M: cuda-function-word definition drop f ;
+M: cuda-function-word synopsis*
+   {
+       [ seeing-word ]
+       [ definer. ]
+       [ [ pprint-word ] pprint-cuda-function ]
+   } cleave ;
+
index baf7b18ec80a94ad47395daa1844d96c1109a6e2..6c886b751e42ef05ffb2cc3488321b1c14924229 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2010 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien.parser cuda cuda.libraries io.backend
-fry kernel lexer namespaces parser ;
+USING: alien.parser cuda.libraries fry kernel lexer namespaces
+parser ;
 IN: cuda.syntax
 
 SYNTAX: CUDA-LIBRARY: