-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
84 lines (73 loc) · 2.24 KB
/
Program.cs
File metadata and controls
84 lines (73 loc) · 2.24 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
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
79
80
81
82
83
84
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Principal;
using System.Text;
using System.Threading.Tasks;
using QsScript.Engine;
namespace QsScript {
internal class Program : Editor {
public void Test() {
Bloc global = new Bloc();
global.Add(@class("enum", null).SetScop(
Field("A", "int"), Field("B", "real"),
Bloc(
get("a").setTo("A"), get("b").setTo("B"), get("this").AsReturn()
).AsFunction("save", "a", "b")
));
global
.Add(New("enum").setTo("inst"))
.Add(get("inst").Call("save", Const(3.0), Const(6)))
.Add(get("inst", "A").setTo("x"))
.Add(Bloc(get("x").CalcWith(Operation.plus, get("x")).setTo("x")).AsWhile(get("x").CalcWith(Operation.Lth, Const(100))))
.Add(get("x").CalcWith(Operation.mult, get("x")).AsReturn());
try {
var file = File.Open(@"a:\h\test2.xml", FileMode.OpenOrCreate);
file.Seek(0, SeekOrigin.Begin);
file.Flush();
//VM.Serializer.Serialize(file, global);
//file.Dispose();
} catch(System.Exception ee) {
}
var x = 3;
while (x<100)
{
x += x;
}
x = x * x;
Console.WriteLine(x);
VM.Reset();
var xx = global.Calc();
Console.WriteLine(xx);
xx.ToString();
Console.ReadKey();
}
//private void CurrentDomain_FirstChanceException(object sender, System.Runtime.ExceptionServices.FirstChanceExceptionEventArgs e) {
// this.get("");
//}
private void ee() {
}
static int Main(string[] args) {
new Program().Test();
return 0;
}
public static Stream Execute(Stream s) {
Expression fr = Void.Value;
try {
var o = VM.Serializer.Deserialize(s) as Expression;
if(o != null) {
var m = o.Calc();
if(m == null) {
fr = new Text("UnrecognizeError").AsThrow();
} else; } else
fr = new Text("Code en Error Format").AsThrow();
} catch(System.Exception e) {
fr = new Text(e.Message).AsThrow();
}
Stream l = new MemoryStream(2048);
VM.Serializer.Serialize(l, fr);
return l;
}
}
}