/
BuildFile.cs
1109 lines (883 loc) · 65.6 KB
/
BuildFile.cs
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading;
using Microsoft.CSharp;
using PostParse;
namespace ConsoleApplication1
{
public class BuildFile
{
private SpokeMethod[] Methods;
private Func<SpokeObject[], SpokeObject>[] InternalMethods;
private string TOP;
public BuildFile(Func<SpokeObject[], SpokeObject>[] internalMethods, Tuple<SpokeMethod[], SpokeConstruct> mets)
{
Methods = mets.Item1;
Construct = mets.Item2;
InternalMethods = internalMethods;
}
private class MethodItem
{
public SpokeMethod Method;
public string Name;
public List<PostParseExpression> Expressions;
public int SpecVariables;
}
public Command buildIt()
{
List<Tuple<SpokeMethod, Tuple<string, List<PostParseExpression>>, int>> itemz = new List<Tuple<SpokeMethod, Tuple<string, List<PostParseExpression>>, int>>();
foreach (var spokeMethod in Methods.Where(a => a.Instructions != null && a.Instructions.Length > 0))
{
Tuple<string, List<PostParseExpression>> der = buildMethod(spokeMethod);
var gotos = der.Item2.Where(a => a.ExpressionType == PPExpressionType.String && ((PostParseString)a).GotoString != null);
var labels = der.Item2.Where(a => a.ExpressionType == PPExpressionType.String && ((PostParseString)a).LabelString != null).ToArray();
foreach (var postParseExpression in labels) {
if (!gotos.Any(a=>((PostParseString)a).GotoString==((PostParseString)postParseExpression).LabelString)) {
for (int index = der.Item2.Count-1; index >= 0; index--)
{
var parseExpression = der.Item2[index];
if (parseExpression.Equals(postParseExpression)) {
der.Item2.RemoveAt(index);
}
}
}
}
for (int index = der.Item2.Count - 1; index >= 1; index--)
{
var postParseExpression = der.Item2[index];
if (postParseExpression.ExpressionType == PPExpressionType.String && der.Item2[index - 1].ExpressionType == PPExpressionType.String)
{
if (((PostParseString)postParseExpression).LabelString != null && ((PostParseString)der.Item2[index - 1]).GotoString != null)
{
if (((PostParseString)postParseExpression).LabelString.Equals(((PostParseString)der.Item2[index - 1]).GotoString))
{
if (!der.Item2.Any(a => a.ExpressionType == PPExpressionType.String && ((PostParseString)a).GotoString == ((PostParseString)postParseExpression).LabelString))
{
der.Item2.RemoveAt(index - 1);
der.Item2.RemoveAt(index - 1);
index -= 1;
}
}
}
}
}
File.WriteAllText("C:\\aabc.txt", der.Item2.Where(a => !a.MarkForRemoval).Aggregate("", (a, b) => a + "\t\t" + b.ToString() + "\r\n"));
AssureSplitStacks d;
fixThings(der.Item2, d = new AssureSplitStacks(der.Item2));
File.WriteAllText("C:\\aabc3.txt", der.Item2.Where(a => !a.MarkForRemoval).Aggregate("", (a, b) => a + "\t\t" + b.ToString() + "\r\n"));
doThings(der.Item2);
if (spokeMethod.Class.Name == "Main" && spokeMethod.MethodName == ".ctor")
Construct.NumOfVars = spokeMethod.NumOfVars = AssureSplitStacks.getAllVariables(der.Item2).OrderBy(a => a.Index).Last().Index + 1;
else spokeMethod.NumOfVars = AssureSplitStacks.getAllVariables(der.Item2).OrderBy(a => a.Index).Last().Index + 1;
itemz.Add(new Tuple<SpokeMethod, Tuple<string, List<PostParseExpression>>, int>(spokeMethod, der, d.NumberOfSpecVariables));
}
foreach (var tuple in itemz)
{
foreach (var postParseMethod in AssureSplitStacks.getAllMethods(tuple.Item2.Item2).Where(a => !a.TotalMethodName.Contains("[")))
{
var g = itemz.FirstOrDefault(a => a.Item1.Class.Name + a.Item1.CleanMethodName == postParseMethod.TotalMethodName);
if (g != null)
{
postParseMethod.NumOfVariables = g.Item1.NumOfVars;
}
else
{
throw new AbandonedMutexException();
}
}
}
TOP = @"
private SpokeMethod[] Methods;
private Func<SpokeObject[], SpokeObject>[] InternalMethods;
private SpokeObject FALSE = new SpokeObject(false);
private SpokeObject TRUE = new SpokeObject(true) ;
private SpokeObject[] ints;
private SpokeObject NULL = new SpokeObject(ObjectType.Null);
private SpokeObject intCache(int index)
{
// if (index > 0 && index < 100)
{
// return ints[index];
}
return new SpokeObject(index);
}
public RunClass()
{
}
public void loadUp(Func<SpokeObject[], SpokeObject>[] internalMethods, SpokeMethod[] mets){
Methods = mets;
InternalMethods = internalMethods;
ints = new SpokeObject[100];
for (int i = 0; i < 100; i++)
{
ints[i] = new SpokeObject(i);
}
}
public SpokeObject Run()
{
SpokeObject dm = new SpokeObject(new SpokeObject[" + Construct.NumOfVars + @"]);
var gm = new SpokeObject[" + Construct.NumOfVars + @"];
gm[0] = dm;
return Mainctor(gm);
}";
StringBuilder file2 = new StringBuilder();
StringBuilder file = new StringBuilder();
file.AppendLine(@"using System;using System.Collections.Generic;using System.Linq;using System.Text;
namespace ConsoleApplication1{public partial class RunClass:Command{");
file.AppendLine(TOP);
file2.Append(@"using System;using System.Collections.Generic;using System.Linq;using System.Text;
namespace ConsoleApplication1{public partial class RunClass:Command{");
file2.AppendLine(TOP);
foreach (var tuple in itemz)
{
var spokeMethod = tuple.Item1;
var der = tuple.Item2;
file.AppendLine(string.Format("private SpokeObject {0}(SpokeObject[] variables) {{", spokeMethod.Class.Name + spokeMethod.CleanMethodName));
file.AppendLine(string.Format("SpokeObject[] specVariables =new SpokeObject[" + tuple.Item3 + "]; SpokeObject[] sps;"));
file.AppendLine(string.Format("SpokeObject bm2;"));
file.AppendLine(string.Format("SpokeObject bm;"));
file.AppendLine(string.Format("SpokeObject lastStack;"));
file2.AppendLine(string.Format("private SpokeObject {0}(SpokeObject[] variables) {{", spokeMethod.Class.Name + spokeMethod.CleanMethodName));
file2.AppendLine(string.Format("SpokeObject[] stack =new SpokeObject[100]; SpokeObject[] sps;"));
file2.AppendLine(string.Format("SpokeObject[] specVariables =new SpokeObject[" + tuple.Item3 + "];"));
file2.AppendLine(string.Format("SpokeObject bm2;"));
file2.AppendLine(string.Format("SpokeObject bm;"));
file2.AppendLine(string.Format("SpokeObject lastStack;"));
file2.AppendLine(der.Item1);
string dm = der.Item2.Where(a => !a.MarkForRemoval).Aggregate("", (a, b) => a + "\t\t" + b.ToString() + "\r\n");
file.AppendLine(dm);
file.AppendLine(string.Format("return null;}}"));
file2.AppendLine(string.Format("return null;}}"));
}
file.AppendLine(string.Format("}}}}"));
file2.AppendLine(string.Format("}}}}"));
File.WriteAllText(@"c:\abc.cs", file.ToString());
File.WriteAllText(@"c:\abc2.cs", file2.ToString());
return compile(file .ToString());
}
private string n = "a";
private SpokeConstruct Construct;
private string GetNext()
{
if (n.Last() == 'z')
{
n = n + 'a';
}
return n = n.Substring(0, n.Length - 1) + (char)(n.Last() + 1);
}
private void fixThings(List<PostParseExpression> item2, AssureSplitStacks assurer, int index = -1)
{
for (index = index == -1 ? item2.Count - 1 : index; index >= 0; index--)
{
PostParseExpression postParseExpression = item2[index];
switch (postParseExpression.ExpressionType)
{
case PPExpressionType.Statement:
var st = ((PostParseStatement)postParseExpression);
foreach (var a in st.Items)
tryToNeeds(a, false, assurer);
break;
case PPExpressionType.Set:
if (((PostParseSet)postParseExpression).Left is PostParseVariable)
{
var pps = (PostParseVariable)((PostParseSet)postParseExpression).Left;
if (pps.Type == VariableType.Stack)
{
tryToNeeds(((PostParseSet)postParseExpression).Left, true, assurer);
}
}
tryToNeeds(((PostParseSet)postParseExpression).Right, false, assurer);
break;
case PPExpressionType.String:
if (((PostParseString)postParseExpression).GotoString != null)
{
return;
}
else if (((PostParseString)postParseExpression).LabelString != null)
{
var split = assurer.GetSplit();
var k = new Dictionary<int, Tuple<int, List<PostParseVariable>>>(split.Needs);
foreach (var i in findGoto(item2, ((PostParseString)postParseExpression).LabelString))
{
fixThings(item2, split, i - 1);
split.Needs = new Dictionary<int, Tuple<int, List<PostParseVariable>>>(k);
}
fixThings(item2, split, index - 1);
return;
}
else
{
}
break;
case PPExpressionType.Method:
var wst = ((PostParseMethod)postParseExpression);
foreach (var a in wst.Params)
tryToNeeds(a, false, assurer);
break;
default:
throw new ArgumentOutOfRangeException();
}
}
}
private void tryToNeeds(PostParseItem item, bool isLeft, AssureSplitStacks assurer)
{
switch (item.ItemType)
{
case PPItemType.Variable:
if (((PostParseVariable)item).Type == VariableType.Stack)
{
if (isLeft)
assurer.Resolve(((PostParseVariable)item).Index, ((PostParseVariable)item));
else
assurer.Need(((PostParseVariable)item).Index, ((PostParseVariable)item));
}
break;
case PPItemType.String:
return;
case PPItemType.Operation:
var op = ((PostParseOperation)item);
tryToNeeds(op.Left, false, assurer);
tryToNeeds(op.Right, false, assurer);
break;
case PPItemType.Statement:
var st = ((PostParseStatement)item);
foreach (var postParseItem in st.Items)
{
tryToNeeds(postParseItem, false, assurer);
}
break;
case PPItemType.Method:
var wst = ((PostParseMethod)item);
foreach (var a in wst.Params)
tryToNeeds(a, false, assurer);
break;
default:
throw new ArgumentOutOfRangeException();
}
return;
;
}
private IEnumerable<int> findGoto(List<PostParseExpression> items, string labelString)
{
for (int index = items.Count - 1; index >= 0; index--)
{
var postParseExpression = items[index];
if (postParseExpression is PostParseString && ((PostParseString)postParseExpression).GotoString == labelString)
{
yield return index;
}
}
}
private void doThings(List<PostParseExpression> item2)
{
Dictionary<int, PostParseItem> stacks = new Dictionary<int, PostParseItem>();
for (int index = 0; index < item2.Count; index++)
{
PostParseExpression postParseExpression = item2[index];
switch (postParseExpression.ExpressionType)
{
case PPExpressionType.Statement:
var st = ((PostParseStatement)postParseExpression);
item2[index] = new PostParseString(string.Format(st.Wrap, st.Items.Select(a => tryToFix(a, stacks)).ToArray()));
break;
case PPExpressionType.Set:
if (((PostParseSet)postParseExpression).Left is PostParseVariable)
{
var pps = (PostParseVariable)((PostParseSet)postParseExpression).Left;
switch (pps.Type)
{
case VariableType.Stack:
if (!((PostParseSet)postParseExpression).OkayToRemove)
{
((PostParseSet)postParseExpression).Right =
tryToFix(((PostParseSet)postParseExpression).Right, stacks);
((PostParseSet)postParseExpression).MarkForRemoval = false;
if (stacks.ContainsKey(pps.Index))
stacks.Remove(pps.Index);
string gc;
stacks.Add(pps.Index, new PostParseString(gc = GetNext()));
((PostParseSet)postParseExpression).Left = new PostParseString("var " + gc);
}
else
{
var fm = tryToFix(((PostParseSet)postParseExpression).Right, stacks);
if (stacks.ContainsKey(pps.Index))
stacks.Remove(pps.Index);
stacks.Add(pps.Index, fm);
((PostParseSet)postParseExpression).Right = fm;
postParseExpression.MarkForRemoval = true;
if (((PostParseSet)postParseExpression).RemoveLeft)
{
((PostParseExpression)fm).endOfLine = true;
item2[index] = (PostParseExpression)fm;
}
}
break;
case VariableType.Special:
((PostParseSet)postParseExpression).Right = tryToFix(((PostParseSet)postParseExpression).Right, stacks);
break;
case VariableType.Variable: ((PostParseSet)postParseExpression).Right = tryToFix(((PostParseSet)postParseExpression).Right, stacks);
break;
default:
throw new ArgumentOutOfRangeException();
}
}
break;
case PPExpressionType.String:
break;
case PPExpressionType.Method:
var wst = ((PostParseMethod)postParseExpression);
PostParseItem[] itm = new PostParseItem[wst.Params.Length];
for (int i = 0; i < wst.Params.Length; i++)
{
itm[i] = tryToFix(wst.Params[i], stacks);
}
wst.Params = itm;
// item2[index] = new PostParseString(wst.ToString());
break;
default:
throw new ArgumentOutOfRangeException();
}
}
}
private PostParseItem tryToFix(PostParseItem right, Dictionary<int, PostParseItem> stacks)
{
switch (right.ItemType)
{
case PPItemType.Variable:
if (((PostParseVariable)right).Type == VariableType.Stack)
{
return stacks[((PostParseVariable)right).Index];
}
return right;
break;
case PPItemType.String:
return right;
break;
case PPItemType.Operation:
var op = ((PostParseOperation)right);
return new PostParseString(string.Format(op.Wrap, tryToFix(op.Left, stacks), tryToFix(op.Right, stacks)));
break;
case PPItemType.Statement:
var st = ((PostParseStatement)right);
return new PostParseString(string.Format(st.Wrap, st.Items.Select(a => tryToFix(a, stacks)).ToArray()));
break;
case PPItemType.Method:
var wst = ((PostParseMethod)right);
PostParseItem[] itm = new PostParseItem[wst.Params.Length];
for (int index = 0; index < wst.Params.Length; index++)
{
itm[index] = tryToFix(wst.Params[index], stacks);
}
wst.Params = itm;
return wst;
// return new PostParseString(right.ToString());
break;
default:
throw new ArgumentOutOfRangeException();
}
}
private Command compile(string source)
{
CSharpCodeProvider csp = new CSharpCodeProvider();
ICodeCompiler cc = csp.CreateCompiler();
CompilerParameters cp = new CompilerParameters();
cp.OutputAssembly = "C:\\fffs\\" + "TestClass.dll";
cp.ReferencedAssemblies.Add("System.dll");
cp.ReferencedAssemblies.Add("System.Core.dll");
cp.ReferencedAssemblies.Add("System.Data.dll");
cp.ReferencedAssemblies.Add("System.Xml.Linq.dll");
cp.ReferencedAssemblies.Add("System.Xml.dll");
cp.ReferencedAssemblies.Add("mscorlib.dll");
cp.ReferencedAssemblies.Add(@"C:\spoke\lista3\lista_2\ConsoleApplication1\bin\Release\ConsoleApplication1.exe");
cp.WarningLevel = 0;
cp.CompilerOptions = "/target:library /optimize";
cp.GenerateExecutable = false;
cp.GenerateInMemory = true;
//cp.IncludeDebugInformation = true;
System.CodeDom.Compiler.TempFileCollection tfc = new TempFileCollection("C:\\fffs\\", false);
CompilerResults cr = new CompilerResults(tfc);
cr = cc.CompileAssemblyFromSource(cp, source);
if (cr.Errors.Count > 0)
{
foreach (CompilerError ce in cr.Errors)
{
Console.WriteLine(ce.ErrorNumber + ": " + ce.ErrorText);
}
Console.ReadLine();
return null;
}
return (Command)cr.CompiledAssembly.CreateInstance("ConsoleApplication1.RunClass");
}
private Tuple<string, List<PostParseExpression>> buildMethod(SpokeMethod fm)
{
StringBuilder sb = new StringBuilder();
#if stacktrace
dfss.AppendLine( fm.Class.Name +" : : "+fm.MethodName+" Start");
#endif
List<PostParseExpression> exps = new List<PostParseExpression>();
for (int index = 0; index < fm.Instructions.Length; index++)
{
var ins = fm.Instructions[index];
#if stacktrace
dfss.AppendLine(stackIndex + " :: " + ins.ToString());
#endif
int gj;
PostParseVariable[] pps;
switch (ins.Type)
{
case SpokeInstructionType.CreateReference:
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Stack, ins.StackBefore_), new PostParseString(string.Format("new SpokeObject(new SpokeObject[{0}])", ins.Index)), false));
sb.AppendLine(string.Format("stack[{0}]=new SpokeObject(new SpokeObject[{1}]);", ins.StackBefore_, ins.Index));
break;
case SpokeInstructionType.Comment:
exps.Add(new PostParseString(string.Format("/*{0}*/", ins.StringVal)));
sb.AppendLine(string.Format("/*{0}*/", ins.StringVal));
break;
case SpokeInstructionType.CreateArray:
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Stack, ins.StackBefore_), new PostParseString(string.Format("new SpokeObject(new List<SpokeObject>(20))")), false));
sb.AppendLine(string.Format("stack[{0}]=new SpokeObject(new List<SpokeObject>(20) );", ins.StackBefore_));
break;
case SpokeInstructionType.CreateMethod:
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Stack, ins.StackBefore_), new PostParseString(string.Format("NULL")), false));
sb.AppendLine(string.Format("stack[{0}]=NULL;", ins.StackBefore_));
break;
case SpokeInstructionType.Label:
exps.Add(new PostParseString(ins.labelGuy + ":"));
sb.AppendLine(string.Format("{0}:", ins.labelGuy));
break;
case SpokeInstructionType.Goto:
exps.Add(new PostParseString("goto " + ins.gotoGuy + ";"));
sb.AppendLine(string.Format("goto {0};", ins.gotoGuy));
break;
case SpokeInstructionType.CallMethod:
pps = new PostParseVariable[ins.Index3];
for (int i = ins.Index3 - 1; i >= 0; i--)
pps[i] = new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1 - i);
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Stack, ins.StackAfter_ - 1), new PostParseMethod(Methods[ins.Index].Class.Name + Methods[ins.Index].CleanMethodName, pps.Reverse().ToArray(), ins.Index3), true));
sb.AppendLine(string.Format("sps = new SpokeObject[{0}];", Methods[ins.Index].NumOfVars));
gj = ins.StackBefore_ - 1;
for (int i = ins.Index3 - 1; i >= 0; i--)
{
sb.AppendLine(string.Format("sps[{1}] = stack[{0}];", gj--, i));
}
sb.AppendLine(string.Format("stack[{0}] = {1}(sps);", ins.StackAfter_ - 1, Methods[ins.Index].Class.Name + Methods[ins.Index].CleanMethodName));
break;
case SpokeInstructionType.CallMethodFunc:
pps = new PostParseVariable[ins.Index3];
for (int i = ins.Index3 - 1; i >= 0; i--)
{
pps[i] = new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1 - i);
}
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Stack, ins.StackAfter_ - 1), new PostParseMethod(string.Format("Methods[{0}].MethodFunc", ins.Index), pps.Reverse().ToArray(), ins.Index3), true));
sb.AppendLine(string.Format("sps = new SpokeObject[{0}];", ins.Index3));
gj = ins.StackBefore_ - 1;
for (int i = ins.Index3 - 1; i >= 0; i--)
{
sb.AppendLine(string.Format("sps[{1}] = stack[{0}];", gj--, i));
}
sb.AppendLine(string.Format("stack[{0}] = Methods[{1}].MethodFunc(sps);", ins.StackAfter_ - 1, ins.Index));
break;
case SpokeInstructionType.CallInternal:
pps = new PostParseVariable[ins.Index3];
for (int i = ins.Index3 - 1; i >= 0; i--)
{
pps[i] = new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1 - i);
}
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Stack, ins.StackAfter_ - 1), new PostParseMethod(string.Format("InternalMethods[{0}]", ins.Index), pps.Reverse().ToArray(), ins.Index3), true));
sb.AppendLine(string.Format("sps = new SpokeObject[{0}];", ins.Index3));
gj = ins.StackBefore_ - 1;
for (int i = ins.Index3 - 1; i >= 0; i--)
{
sb.AppendLine(string.Format("sps[{1}] = stack[{0}];", gj--, i));
}
sb.AppendLine(string.Format("stack[{0}] = InternalMethods[{1}](sps);", ins.StackAfter_ - 1, ins.Index));
break;
case SpokeInstructionType.BreakpointInstruction:
Console.WriteLine("BreakPoint");
break;
case SpokeInstructionType.Return:
exps.Add(new PostParseStatement("return {0};", new PostParseVariable(VariableType.Stack, ins.StackBefore_)));
sb.AppendLine(string.Format("return stack[{0}];", ins.StackBefore_));
break;
case SpokeInstructionType.IfTrueContinueElse:
exps.Add(new PostParseStatement("if(!({0}).BoolVal) ", new PostParseVariable(VariableType.Stack, ins.StackBefore_)));
exps.Add(new PostParseString("goto " + ins.elseGuy + ";"));
sb.AppendLine(string.Format("if(!stack[{0}].BoolVal) goto {1};", ins.StackBefore_, ins.elseGuy));
break;
case SpokeInstructionType.Or:
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1),
new PostParseOperation(new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1),
new PostParseVariable(VariableType.Stack, ins.StackBefore_),
"(({0}.BoolVal || {1}.BoolVal)?TRUE:FALSE)"), true));
sb.AppendLine(string.Format("stack[{0}] = (stack[{0}].BoolVal || stack[{1}].BoolVal)?TRUE:FALSE;", ins.StackBefore_ - 1, ins.StackBefore_));
break;
case SpokeInstructionType.And:
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1),
new PostParseOperation(new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1),
new PostParseVariable(VariableType.Stack, ins.StackBefore_),
"(({0}.BoolVal && {1}.BoolVal)?TRUE:FALSE)"), true));
sb.AppendLine(string.Format("stack[{0}] = (stack[{0}].BoolVal && stack[{1}].BoolVal)?TRUE:FALSE;", ins.StackBefore_ - 1, ins.StackBefore_));
break;
case SpokeInstructionType.StoreLocalInt:
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Variable, ins.Index), new PostParseStatement("intCache({0}.IntVal)", new PostParseVariable(VariableType.Stack, ins.StackBefore_)), true));
sb.AppendLine(string.Format("variables[{0}] = intCache(stack[{1}].IntVal);", ins.Index, ins.StackBefore_));
break;
case SpokeInstructionType.StoreLocalFloat:
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Variable, ins.Index),
new PostParseStatement("new SpokeObject({0}.FloatVal)", new PostParseVariable(VariableType.Stack, ins.StackBefore_)), true));
sb.AppendLine(string.Format("variables[{0}] = new SpokeObject(stack[{1}].FloatVal);", ins.Index, ins.StackBefore_));
break;
case SpokeInstructionType.StoreLocalBool:
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Variable, ins.Index),
new PostParseStatement("new SpokeObject({0}.BoolVal)", new PostParseVariable(VariableType.Stack, ins.StackBefore_)), true));
sb.AppendLine(string.Format("variables[{0}] = stack[{1}].BoolVal ? TRUE : FALSE;", ins.Index, ins.StackBefore_));
// variables[ins.Index] = lastStack.BoolVal ? TRUE : FALSE;
break;
case SpokeInstructionType.StoreLocalString:
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Variable, ins.Index), new PostParseStatement("new SpokeObject({0}.StringVal)", new PostParseVariable(VariableType.Stack, ins.StackBefore_)), true));
sb.AppendLine(string.Format("variables[{0}] = new SpokeObject(stack[{1}].StringVal);", ins.Index, ins.StackBefore_));
break;
case SpokeInstructionType.StoreLocalMethod:
case SpokeInstructionType.StoreLocalObject:
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Variable, ins.Index), new PostParseVariable(VariableType.Stack, ins.StackBefore_), true));
sb.AppendLine(string.Format("variables[{0}] = stack[{1}];", ins.Index, ins.StackBefore_));
break;
case SpokeInstructionType.StoreLocalRef:
exps.Add(
new PostParseStatement(
@"
//{1}={0};
lastStack = {0};
bm2 = {1};
bm2.Variables = lastStack.Variables;
bm2.ArrayItems = lastStack.ArrayItems;
bm2.StringVal = lastStack.StringVal;
bm2.IntVal = lastStack.IntVal;
bm2.BoolVal = lastStack.BoolVal;
bm2.FloatVal = lastStack.FloatVal;
",
new PostParseVariable(VariableType.Stack, ins.StackBefore_), new PostParseVariable(VariableType.Variable, ins.Index)));
sb.AppendLine(string.Format("lastStack = stack[{0}];", ins.StackBefore_));
sb.AppendLine(string.Format("bm = variables[{0}];", ins.Index));
sb.AppendLine(@"
bm.Variables = lastStack.Variables;
bm.ArrayItems = lastStack.ArrayItems;
bm.StringVal = lastStack.StringVal;
bm.IntVal = lastStack.IntVal;
bm.BoolVal = lastStack.BoolVal;
bm.FloatVal = lastStack.FloatVal;
");
break;
case SpokeInstructionType.StoreFieldBool:
exps.Add(new PostParseStatement("{0}.Variables[" + ins.Index + "]={1}.BoolVal?TRUE:FALSE;", new PostParseVariable(VariableType.Stack, ins.StackBefore_), new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1)));
sb.AppendLine(string.Format("stack[{0}].Variables[{2}]=stack[{1}].BoolVal?TRUE:FALSE;", ins.StackBefore_, ins.StackAfter_, ins.Index));
break;
case SpokeInstructionType.StoreFieldInt:
exps.Add(new PostParseStatement("{0}.Variables[" + ins.Index + "]=intCache({1}.IntVal);", new PostParseVariable(VariableType.Stack, ins.StackBefore_), new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1)));
sb.AppendLine(string.Format("stack[{0}].Variables[{2}]=intCache(stack[{1}].IntVal );", ins.StackBefore_, ins.StackAfter_, ins.Index));
break;
case SpokeInstructionType.StoreFieldFloat:
exps.Add(new PostParseStatement("{0}.Variables[" + ins.Index + "]=new SpokeObject({1}.FloatVal);", new PostParseVariable(VariableType.Stack, ins.StackBefore_), new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1)));
sb.AppendLine(string.Format("stack[{0}].Variables[{2}]=new SpokeObject( stack[{1}].FloatVal );", ins.StackBefore_, ins.StackAfter_, ins.Index));
break;
case SpokeInstructionType.StoreFieldString:
exps.Add(new PostParseStatement("{0}.Variables[" + ins.Index + "]=new SpokeObject({1}.StringVal);", new PostParseVariable(VariableType.Stack, ins.StackBefore_), new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1)));
sb.AppendLine(string.Format("stack[{0}].Variables[{2}]=new SpokeObject(stack[{1}].StringVal );", ins.StackBefore_, ins.StackAfter_, ins.Index));
break;
case SpokeInstructionType.StoreFieldMethod:
case SpokeInstructionType.StoreFieldObject:
exps.Add(new PostParseStatement("{0}.Variables[" + ins.Index + "]={1};", new PostParseVariable(VariableType.Stack, ins.StackBefore_), new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1)));
sb.AppendLine(string.Format("stack[{0}].Variables[{2}]=stack[{1}];", ins.StackBefore_, ins.StackAfter_, ins.Index));
break;
case SpokeInstructionType.StoreToReference:
exps.Add(new PostParseStatement("{0}.Variables[" + ins.Index + "] = {1};", new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1), new PostParseVariable(VariableType.Stack, ins.StackBefore_)));
sb.AppendLine(string.Format("stack[{1}].Variables[{2}] = stack[{0}];", ins.StackBefore_, ins.StackBefore_ - 1, ins.Index));
break;
case SpokeInstructionType.GetField:
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1), new PostParseStatement("{0}.Variables[" + ins.Index + "]", new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1)), true));
sb.AppendLine(string.Format("stack[{0}] = stack[{0}].Variables[{1}];", ins.StackBefore_ - 1, ins.Index));
break;
case SpokeInstructionType.GetLocal:
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Stack, ins.StackBefore_), new PostParseVariable(VariableType.Variable, ins.Index), true));
sb.AppendLine(string.Format("stack[{0}] = variables[{1}];", ins.StackBefore_, ins.Index));
break;
case SpokeInstructionType.PopStack:
var d = (PostParseSet)exps.Last(a => a.ExpressionType == PPExpressionType.Set);
if (d.Right.ItemType == PPItemType.Variable)
{
d.MarkForRemoval = true;
}
else d.RemoveLeft = true;
break;
case SpokeInstructionType.Not:
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1), new PostParseStatement("{0}.BoolVal?FALSE:TRUE", new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1)), true));
sb.AppendLine(string.Format("stack[{0}] = stack[{0}].BoolVal?FALSE:TRUE;", ins.StackBefore_ - 1));
break;
case SpokeInstructionType.IntConstant:
if (ins.Index >= 0 && ins.Index < 100)
{
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Stack, ins.StackBefore_), new PostParseString(string.Format("ints[{0}]", ins.Index)), true));
sb.AppendLine(string.Format("stack[{0}] = ints[{1}];", ins.StackBefore_, ins.Index));
}
else
{
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Stack, ins.StackBefore_), new PostParseString(string.Format("new SpokeObject( {0} )", ins.Index)), true));
sb.AppendLine(string.Format("stack[{0}] = new SpokeObject( {1} );", ins.StackBefore_, ins.Index));
}
break;
case SpokeInstructionType.BoolConstant:
sb.AppendLine(string.Format("stack[{0}] = {1};", ins.StackBefore_, ins.BoolVal ? "TRUE" : "FALSE"));
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Stack, ins.StackBefore_), new PostParseString(ins.BoolVal ? "TRUE" : "FALSE"), true));
break;
case SpokeInstructionType.FloatConstant:
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Stack, ins.StackBefore_), new PostParseString(string.Format("new SpokeObject( {0}f )", ins.FloatVal)), true));
sb.AppendLine(string.Format("stack[{0}] = new SpokeObject({1}f );", ins.StackBefore_, ins.FloatVal));
break;
case SpokeInstructionType.StringConstant:
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Stack, ins.StackBefore_), new PostParseString(string.Format("new SpokeObject( \"{0}\" )", ins.StringVal)), true));
sb.AppendLine(string.Format("stack[{0}] = new SpokeObject( \"{1}\" );", ins.StackBefore_, ins.StringVal));
break;
case SpokeInstructionType.Null:
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Stack, ins.StackBefore_), new PostParseString("NULL"), true));
sb.AppendLine(string.Format("stack[{0}] = NULL;", ins.StackBefore_));
break;
case SpokeInstructionType.AddIntInt:
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1), new PostParseOperation(new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1), new PostParseVariable(VariableType.Stack, ins.StackAfter_), "intCache({0}.IntVal + {1}.IntVal)"), true));
sb.AppendLine(string.Format("stack[{0}]=intCache(stack[{0}].IntVal + stack[{1}].IntVal);", ins.StackBefore_ - 1, ins.StackAfter_));
break;
case SpokeInstructionType.AddStringInt:
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1), new PostParseOperation(new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1), new PostParseVariable(VariableType.Stack, ins.StackAfter_), "new SpokeObject({0}.StringVal + {1}.IntVal)"), true));
sb.AppendLine(string.Format("stack[{0}]=new SpokeObject( stack[{0}].StringVal + stack[{1}].IntVal );", ins.StackBefore_ - 1, ins.StackAfter_));
break;
case SpokeInstructionType.AddIntString:
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1), new PostParseOperation(new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1), new PostParseVariable(VariableType.Stack, ins.StackAfter_), "new SpokeObject({0}.IntVal + {1}.StringVal)"), true));
sb.AppendLine(string.Format("stack[{0}]=new SpokeObject(stack[{0}].IntVal + stack[{1}].StringVal );", ins.StackBefore_ - 1, ins.StackAfter_));
break;
case SpokeInstructionType.AddFloatString:
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1), new PostParseOperation(new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1), new PostParseVariable(VariableType.Stack, ins.StackAfter_), "new SpokeObject({0}.FloatVal + {1}.StringVal)"), true));
sb.AppendLine(string.Format("stack[{0}]=new SpokeObject( stack[{0}].FloatString + stack[{1}].StringVal );", ins.StackBefore_ - 1, ins.StackAfter_));
break;
case SpokeInstructionType.AddStringFloat:
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1), new PostParseOperation(new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1), new PostParseVariable(VariableType.Stack, ins.StackAfter_), "new SpokeObject({0}.StringVal + {1}.FloatVal)"), true));
sb.AppendLine(string.Format("stack[{0}]=new SpokeObject(stack[{0}].StringVal + stack[{1}].FloatVal );", ins.StackBefore_ - 1, ins.StackAfter_));
break;
case SpokeInstructionType.AddStringString:
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1), new PostParseOperation(new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1), new PostParseVariable(VariableType.Stack, ins.StackAfter_), "new SpokeObject({0}.StringVal + {1}.StringVal)"), true));
sb.AppendLine(string.Format("stack[{0}]=new SpokeObject(stack[{0}].StringVal + stack[{1}].StringVal );", ins.StackBefore_ - 1, ins.StackAfter_));
break;
case SpokeInstructionType.SubtractIntInt:
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1), new PostParseOperation(new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1), new PostParseVariable(VariableType.Stack, ins.StackAfter_), "intCache({0}.IntVal - {1}.IntVal)"), true));
sb.AppendLine(string.Format("stack[{0}]=intCache (stack[{0}].IntVal - stack[{1}].IntVal);", ins.StackBefore_ - 1, ins.StackAfter_));
break;
case SpokeInstructionType.MultiplyIntInt:
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1), new PostParseOperation(new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1), new PostParseVariable(VariableType.Stack, ins.StackAfter_), "intCache({0}.IntVal * {1}.IntVal)"), true));
sb.AppendLine(string.Format("stack[{0}]=intCache (stack[{0}].IntVal * stack[{1}].IntVal);", ins.StackBefore_ - 1, ins.StackAfter_));
break;
case SpokeInstructionType.DivideIntInt:
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1), new PostParseOperation(new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1), new PostParseVariable(VariableType.Stack, ins.StackAfter_), "intCache({0}.IntVal / {1}.IntVal)"), true));
sb.AppendLine(string.Format("stack[{0}]=intCache (stack[{0}].IntVal / stack[{1}].IntVal);", ins.StackBefore_ - 1, ins.StackAfter_));
break;
case SpokeInstructionType.GreaterIntInt:
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1), new PostParseOperation(new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1), new PostParseVariable(VariableType.Stack, ins.StackBefore_), "(({0}.IntVal > {1}.IntVal)?TRUE:FALSE)"), true));
sb.AppendLine(string.Format("stack[{0}]=(stack[{0}].IntVal > stack[{1}].IntVal)?TRUE:FALSE;", ins.StackBefore_ - 1, ins.StackAfter_));
break;
case SpokeInstructionType.GreaterIntFloat:
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1), new PostParseOperation(new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1), new PostParseVariable(VariableType.Stack, ins.StackBefore_), "(({0}.IntVal > {1}.FloatVal)?TRUE:FALSE)"), true));
sb.AppendLine(string.Format("stack[{0}]=(stack[{0}].IntVal > stack[{1}].FloatVal)?TRUE:FALSE;", ins.StackBefore_ - 1, ins.StackAfter_));
break;
case SpokeInstructionType.GreaterFloatInt:
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1), new PostParseOperation(new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1), new PostParseVariable(VariableType.Stack, ins.StackBefore_), "(({0}.FloatVal > {1}.IntVal)?TRUE:FALSE)"), true));
sb.AppendLine(string.Format("stack[{0}]=(stack[{0}].FloatVal > stack[{1}].IntVal)?TRUE:FALSE;", ins.StackBefore_ - 1, ins.StackAfter_));
break;
case SpokeInstructionType.GreaterFloatFloat:
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1), new PostParseOperation(new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1), new PostParseVariable(VariableType.Stack, ins.StackBefore_), "(({0}.FloatVal > {1}.FloatVal)?TRUE:FALSE)"), true));
sb.AppendLine(string.Format("stack[{0}]=(stack[{0}].FloatVal > stack[{1}].FloatVal)?TRUE:FALSE;", ins.StackBefore_ - 1, ins.StackAfter_));
break;
case SpokeInstructionType.LessIntInt:
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1),
new PostParseOperation(
new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1),
new PostParseVariable(VariableType.Stack, ins.StackBefore_),
"(({0}.IntVal < {1}.IntVal)?TRUE:FALSE)"), true));
sb.AppendLine(string.Format("stack[{0}]=(stack[{0}].IntVal < stack[{1}].IntVal)?TRUE:FALSE;", ins.StackBefore_ - 1, ins.StackAfter_));
break;
case SpokeInstructionType.LessIntFloat:
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1),
new PostParseOperation(
new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1),
new PostParseVariable(VariableType.Stack, ins.StackBefore_),
"(({0}.IntVal < {1}.FloatVal)?TRUE:FALSE)"), true));
sb.AppendLine(string.Format("stack[{0}]=(stack[{0}].IntVal < stack[{1}].FloatVal)?TRUE:FALSE;", ins.StackBefore_ - 1, ins.StackAfter_));
break;
case SpokeInstructionType.LessFloatInt:
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1),
new PostParseOperation(
new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1),
new PostParseVariable(VariableType.Stack, ins.StackBefore_),
"(({0}.FloatVal < {1}.IntVal)?TRUE:FALSE)"), true));
sb.AppendLine(string.Format("stack[{0}]=(stack[{0}].FloatVal < stack[{1}].IntVal)?TRUE:FALSE;", ins.StackBefore_ - 1, ins.StackAfter_));
break;
case SpokeInstructionType.LessFloatFloat:
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1),
new PostParseOperation(
new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1),
new PostParseVariable(VariableType.Stack, ins.StackBefore_),
"(({0}.FloatVal < {1}.FloatVal)?TRUE:FALSE)"), true));
sb.AppendLine(string.Format("stack[{0}]=(stack[{0}].FloatVal < stack[{1}].FloatVal)?TRUE:FALSE;", ins.StackBefore_ - 1, ins.StackAfter_));
break;
case SpokeInstructionType.GreaterEqualIntInt:
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1),
new PostParseOperation(
new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1),
new PostParseVariable(VariableType.Stack, ins.StackBefore_),
"(({0}.IntVal >= {1}.IntVal)?TRUE:FALSE)"), true));
sb.AppendLine(string.Format("stack[{0}]=(stack[{0}].IntVal >= stack[{1}].IntVal)?TRUE:FALSE;", ins.StackBefore_ - 1, ins.StackAfter_));
break;
case SpokeInstructionType.GreaterEqualIntFloat:
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1),
new PostParseOperation(
new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1),
new PostParseVariable(VariableType.Stack, ins.StackBefore_),
"(({0}.IntVal >= {1}.FloatVal)?TRUE:FALSE)"), true));
sb.AppendLine(string.Format("stack[{0}]=(stack[{0}].IntVal >= stack[{1}].FloatVal)?TRUE:FALSE;", ins.StackBefore_ - 1, ins.StackAfter_));
break;
case SpokeInstructionType.GreaterEqualFloatInt:
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1),
new PostParseOperation(
new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1),
new PostParseVariable(VariableType.Stack, ins.StackBefore_),
"(({0}.FloatVal >= {1}.IntVal)?TRUE:FALSE)"), true));
sb.AppendLine(string.Format("stack[{0}]=(stack[{0}].FloatVal >= stack[{1}].IntVal)?TRUE:FALSE;", ins.StackBefore_ - 1, ins.StackAfter_));
break;
case SpokeInstructionType.GreaterEqualFloatFloat:
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1),
new PostParseOperation(
new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1),
new PostParseVariable(VariableType.Stack, ins.StackBefore_),
"(({0}.FloatVal >= {1}.FloatVal)?TRUE:FALSE)"), true));
sb.AppendLine(string.Format("stack[{0}]=(stack[{0}].FloatVal >= stack[{1}].FloatVal)?TRUE:FALSE;", ins.StackBefore_ - 1, ins.StackAfter_));
break;
case SpokeInstructionType.LessEqualIntInt:
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1),
new PostParseOperation(
new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1),
new PostParseVariable(VariableType.Stack, ins.StackBefore_),
"(({0}.IntVal <= {1}.IntVal)?TRUE:FALSE)"), true));
sb.AppendLine(string.Format("stack[{0}]=(stack[{0}].IntVal <= stack[{1}].IntVal)?TRUE:FALSE;", ins.StackBefore_ - 1, ins.StackAfter_));
break;
case SpokeInstructionType.LessEqualIntFloat:
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1),
new PostParseOperation(
new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1),
new PostParseVariable(VariableType.Stack, ins.StackBefore_),
"(({0}.IntVal <= {1}.FloatVal)?TRUE:FALSE)"), true));
sb.AppendLine(string.Format("stack[{0}]=(stack[{0}].IntVal <= stack[{1}].FloatVal)?TRUE:FALSE;", ins.StackBefore_ - 1, ins.StackAfter_));
break;
case SpokeInstructionType.LessEqualFloatInt:
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1),
new PostParseOperation(
new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1),
new PostParseVariable(VariableType.Stack, ins.StackBefore_),
"(({0}.FloatVal <= {1}.IntVal)?TRUE:FALSE)"), true));
sb.AppendLine(string.Format("stack[{0}]=(stack[{0}].FloatVal <= stack[{1}].IntVal)?TRUE:FALSE;", ins.StackBefore_ - 1, ins.StackAfter_));
break;
case SpokeInstructionType.LessEqualFloatFloat:
exps.Add(new PostParseSet(new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1),
new PostParseOperation(
new PostParseVariable(VariableType.Stack, ins.StackBefore_ - 1),
new PostParseVariable(VariableType.Stack, ins.StackBefore_),
"({0}.FloatVal <= {1}.FloatVal)?TRUE:FALSE"), true));
sb.AppendLine(string.Format("stack[{0}]=(stack[{0}].FloatVal <= stack[{1}].FloatVal)?TRUE:FALSE;", ins.StackBefore_ - 1, ins.StackAfter_));
break;
case SpokeInstructionType.Equal: