blob: 9077b141a7438766fa9e81c31a4a72501631b73c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
using System;
class Stress {
static string [] types = {
"int", "uint",
"short", "ushort",
"long", "ulong",
"sbyte", "byte", "char"
};
static void w (string s)
{
Console.Write (s);
}
static void wl (string s)
{
Console.WriteLine (s);
}
static void generate_receptors ()
{
foreach (string t in types){
w ("\tstatic void receive_" + t + " (" + t + " a)\n\t{\n");
w ("\t\tConsole.Write (\" \");\n");
w ("\t\tConsole.WriteLine (a);\n");
w ("\t}\n\n");
}
}
static void call (string type, string name)
{
w ("\t\treceive_" + type + " (checked ((" + type + ") var ));\n");
}
static void generate_emision ()
{
foreach (string type in types){
w ("\tstatic void probe_" + type + "()\n\t{\n");
if (type == "char")
w ("\t\t" + type + " var = (char) 0;");
else
w ("\t\t" + type + " var = 0;");
wl ("");
foreach (string t in types)
call (t, "var");
w ("\t}\n\n");
}
}
static void generate_main ()
{
wl ("\tstatic void Main ()\n\t{");
foreach (string t in types){
w ("\t\tprobe_" + t + " ();\n");
}
wl ("\t}");
}
static void Main (string [] args)
{
wl ("using System;\nclass Test {\n");
generate_receptors ();
generate_emision ();
generate_main ();
wl ("}\n");
}
}
|