comparison src/cjr_print.sml @ 1073:b2311dfb3158

Initializers and setval
author Adam Chlipala <adamc@hcoop.net>
date Sun, 13 Dec 2009 14:20:41 -0500
parents 217eb87dde31
children 0657e5adc938
comparison
equal deleted inserted replaced
1072:9001966ae1c8 1073:b2311dfb3158
1847 1847
1848 string "n;", 1848 string "n;",
1849 newline, 1849 newline,
1850 string "})"] 1850 string "})"]
1851 1851
1852 | ESetval {seq, count} =>
1853 box [string "({",
1854 newline,
1855
1856 #setval (Settings.currentDbms ()) {loc = loc,
1857 seqE = p_exp env seq,
1858 count = p_exp env count},
1859 newline,
1860 newline,
1861
1862 string "uw_unit_v;",
1863 newline,
1864 string "})"]
1865
1852 | EUnurlify (e, t) => 1866 | EUnurlify (e, t) =>
1853 let 1867 let
1854 fun getIt () = 1868 fun getIt () =
1855 if isUnboxable t then 1869 if isUnboxable t then
1856 unurlify false env t 1870 unurlify false env t
2082 string "style", 2096 string "style",
2083 space, 2097 space,
2084 string s, 2098 string s,
2085 space, 2099 space,
2086 string "*/"] 2100 string "*/"]
2101
2102 | DInitializer _ => box []
2087 2103
2088 datatype 'a search = 2104 datatype 'a search =
2089 Found of 'a 2105 Found of 'a
2090 | NotFound 2106 | NotFound
2091 | Error 2107 | Error
2714 newline]) rules, 2730 newline]) rules,
2715 string "return 0;", 2731 string "return 0;",
2716 newline], 2732 newline],
2717 string "}", 2733 string "}",
2718 newline] 2734 newline]
2735
2736 val initializers = List.mapPartial (fn (DInitializer e, _) => SOME e | _ => NONE) ds
2719 in 2737 in
2720 box [string "#include <stdio.h>", 2738 box [string "#include <stdio.h>",
2721 newline, 2739 newline,
2722 string "#include <stdlib.h>", 2740 string "#include <stdlib.h>",
2723 newline, 2741 newline,
2847 newline, 2865 newline,
2848 newline, 2866 newline,
2849 2867
2850 string "void uw_initializer(uw_context ctx) {", 2868 string "void uw_initializer(uw_context ctx) {",
2851 newline, 2869 newline,
2852 box [p_enamed env (!initialize), 2870 box [p_list_sep (box []) (fn e => box [p_exp env e,
2871 string ";",
2872 newline]) initializers,
2873 p_enamed env (!initialize),
2853 string "(ctx, uw_unit_v);", 2874 string "(ctx, uw_unit_v);",
2854 newline], 2875 newline],
2855 string "}", 2876 string "}",
2856 newline] 2877 newline]
2857 else 2878 else