5 static string mode
= "unchecked";
7 static string [] types
= {
11 "sbyte", "byte", "char"
15 static void w (string s
)
20 static void wl (string s
)
22 Console
.WriteLine (s
);
25 static void generate_receptors ()
27 foreach (string t
in types
){
28 w ("\tstatic void receive_" + t
+ " (" + t
+ " a)\n\t{\n");
29 w ("\t\tConsole.Write (\" \");\n");
30 w ("\t\tConsole.WriteLine (a);\n");
36 static void var (string type
, string name
, string init
)
38 w ("\t\t" + type
+ " " + name
+ " = (" + type
+ ") " + init
+ ";\n");
41 static void call (string type
, string name
)
43 w ("\t\treceive_" + type
+ " (" + mode
+ "((" + type
+ ") " + name
+ "));\n");
46 static void generate_emision ()
48 foreach (string type
in types
){
49 w ("\tstatic void probe_" + type
+ "()\n\t{\n");
50 var (type
, "zero", "0");
51 var (type
, "min", type
+ ".MinValue");
52 var (type
, "max", type
+ ".MaxValue");
55 wl ("\t\tConsole.WriteLine (\"Testing: " + type
+ "\");\n");
56 foreach (string t
in types
){
57 wl ("\t\tConsole.WriteLine (\" arg: " + t
+ " (" + type
+ ")\");\n");
67 static void generate_main ()
69 wl ("\tstatic void Main ()\n\t{");
71 foreach (string t
in types
){
72 w ("\t\tprobe_" + t
+ " ();\n");
77 static void Main (string [] args
)
79 foreach (string arg
in args
){
80 if (arg
== "-h" || arg
== "--help"){
81 Console
.WriteLine ("-h, --help Shows help");
82 Console
.WriteLine ("-c, --checked Generate checked contexts");
85 if (arg
== "--checked" || arg
== "-c"){
90 wl ("using System;\nclass Test {\n");
92 generate_receptors ();