source: doc/generic_types/evaluation/cfa-print.c @ d9dd3d1

aaron-thesisarm-ehcleanup-dtorsdeferred_resndemanglerjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerresolv-newwith_gc
Last change on this file since d9dd3d1 was 0d10090, checked in by Aaron Moss <a3moss@…>, 5 years ago

Add printing code to benchmark

  • Property mode set to 100644
File size: 781 bytes
Line 
1#include <stdio.h>
2#include "pair"
3#include "cfa-print.h"
4
5forall(otype T, ttype Params | { void print(FILE*, T); void print(FILE*, Params); })
6void print(FILE* out, T arg, Params rest) {
7        print(out, arg);
8        print(out, rest);
9}
10
11void print(FILE* out, const char* x) { fprintf(out, "%s", x); }
12
13void print(FILE* out, _Bool x) { fprintf(out, "%s", x ? "true" : "false"); }
14
15void print(FILE* out, char x) {
16        if ( 0x20 <= x && x <= 0x7E ) { fprintf(out, "'%c'", x); }
17        else { fprintf(out, "'\\%x'", x); }
18}
19
20void print(FILE* out, int x) { fprintf(out, "%d", x); }
21
22forall(otype R, otype S | { void print(FILE*, R); void print(FILE*, S); })
23void print(FILE* out, pair(R, S) x) {
24        fprintf(out, "[");
25        print(out, x.first);
26        fprintf(out, ", ");
27        print(out, x.second);
28        fprintf(out, "]");
29}
Note: See TracBrowser for help on using the repository browser.