-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
34 lines (30 loc) · 1.21 KB
/
Program.cs
File metadata and controls
34 lines (30 loc) · 1.21 KB
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
using System.Reflection.Emit;
namespace TheLeftExit.Brainfuck {
static class Program {
static void Main(string[] args) {
HelloWorldTest();
Console.Write("Press any key...");
Console.ReadKey();
}
static void HelloWorldTest() {
DynamicMethod myMethod = new DynamicMethod("MyMethod", null, Type.EmptyTypes);
BrainfuckEmit emit = new BrainfuckEmit(myMethod.GetILGenerator());
emit.Init();
foreach(char c in "++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.") {
switch (c) {
case '>': emit.IncPtr(); break;
case '<': emit.DecPtr(); break;
case '+': emit.Inc(); break;
case '-': emit.Dec(); break;
case '.': emit.Write(); break;
case ',': emit.Read(); break;
case '[': emit.BeginWhile(); break;
case ']': emit.EndWhile(); break;
}
}
emit.End();
Action myAction = myMethod.CreateDelegate<Action>();
myAction();
}
}
}