-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgram.cs
More file actions
2128 lines (2066 loc) · 80.2 KB
/
Program.cs
File metadata and controls
2128 lines (2066 loc) · 80.2 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
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.Collections.Generic;
using System.Text;
using System.IO;
namespace DeMangleVC
{
class Program
{
static void Main(string[] args)
{
if (args.Length > 0)
{
StreamReader sr = new StreamReader(args[0]);
String line;
line = sr.ReadLine();
char[] sep = { ' ', '\t' };
while (line != null)
{
int idx = line.IndexOfAny(sep);
if (idx > 0)
{
line = line.Substring(0, idx);
}
DeMangle dm = new DeMangle(line);
dm.Work();
//try
//{
// dm.Work();
//}
//catch (Exception e)
//{
// Console.Error.WriteLine(line);
// Console.Error.WriteLine(dm.processPos);
// Console.Error.WriteLine(e.Data);
// Console.Error.WriteLine(e.Message);
// Console.Error.WriteLine(e.Source);
// Console.Error.WriteLine(e.StackTrace);
//}
String res = dm.GetResult();
Console.WriteLine(res);
line = sr.ReadLine();
}
}
}
}
class StringHelper
{
public static string glue(string l, string r)
{
if (l == "" || r == "")
{
return l + r;
}
else
{
return l + " " + r;
}
}
}
/// <summary>
/// base class for all class that correspond to some symbols segment, like identifier, name, etc
/// </summary>
class ParseBase
{
/// <summary>
/// Start position of the underlying string
/// </summary>
private int _start;
/// <summary>
/// End postion of the underlying string
/// </summary>
private int _end;
/// <summary>
/// The underlying string
/// </summary>
private string _str;
/// <summary>
/// Pase the input start at pos, and return the pos of the next char to be parsed
/// </summary>
/// <param name="intput"></param>
/// <param name="pos"></param>
/// <returns></returns>
virtual public ParseBase parse(string src, ref int pos, ref List<Type> vType, ref List<UnqualifiedID> vUiD) { throw new NotImplementedException(); }
/// <summary>
/// dump the underlying string and pased result
/// </summary>
protected void dump() { Console.Error.WriteLine("{0} {1} {2} . {3} . {4}", _start, _end, GetType().Name, _str, getDemangledString()); }
/// <summary>
/// Get the demangled result of this piece
/// </summary>
/// <returns></returns>
virtual public string getDemangledString() { throw new NotImplementedException(); }
public Type toType() { return (Type)this; }
protected void saveParseStatus(string src, int start, int end)
{
_start = start;
_end = end;
_str = src.Substring(start, end - start);
#if TRACE
dump();
#endif
}
}
class StringComponent : ParseBase
{
protected string _strRes = "";
public override string getDemangledString() { return _strRes; }
public static string getString(string src, ref int pos)
{
// specials, meaning unknown
String[] specials = { "__abi_Windows_Foundation_" };
foreach (String special in specials) {
if ((pos + special.Length) <= src.Length && src.Substring(pos, special.Length) == special) {
pos += special.Length;
return "`" + special + "'";
}
}
int startPos = pos;
int i = 0;
while (src[pos + i] != '@')
{
i++;
}
if (i != 0)
{
pos += i + 1;
}
return src.Substring(startPos, i);
}
public static long getInteger(string src, ref int pos)
{
long val;
int iProcessPos = pos;
bool minus = false;
if (src[iProcessPos] == '?')
{
minus = true;
iProcessPos++;
}
if (Char.IsDigit(src[iProcessPos]))
{
val = src[iProcessPos] - '0' + 1;
iProcessPos++;
}
else
{
val = 0;
while (src[iProcessPos] >= 'A' && src[iProcessPos] <= 'P')
{
val = val * 16 + src[iProcessPos] - 'A';
iProcessPos++;
}
if (src[iProcessPos] != '@')
{
throw new Exception("Error in Integer constant");
}
iProcessPos++;
}
if (minus)
{
val = -val;
}
pos = iProcessPos;
return val;
}
public static string GetTemplateArgumentList(string src, ref int pos, ref List<Type> vType, ref List<UnqualifiedID> vUiD)
{
return new TemplateArguamentList().parse(src, ref pos, ref vType, ref vUiD).getDemangledString();
}
}
class FunctionModifier : StringComponent
{
protected static String[] strAControl = {
"private:", "protected:", "public:"
};
protected static String[] strModifier = {
"static", "virtual"
};
protected enum enumModifier { enmMstatic, enmMvirtual };
public override ParseBase parse(string src, ref int pos, ref List<Type> vType, ref List<UnqualifiedID> vUiD)
{
String sModifier;
_bHasThis = true;
//String tAccess = new TypeID();
String tAccess = "";
String sThunkPrefix = "";
sModifier = "";
_sThunkAdjustor = "";
int iProcessPos = pos;
if (src[iProcessPos] < 'Y')
{
tAccess = strAControl[(src[iProcessPos] - 'A') / 8];
}
switch (src[iProcessPos])
{
case 'A':
case 'I':
case 'Q':
break;
case 'C':
case 'S':
case 'K':
_bHasThis = false;
sModifier = strModifier[(int)enumModifier.enmMstatic];
break;
case 'E':
case 'M':
case 'U':
sModifier = strModifier[(int)enumModifier.enmMvirtual];
break;
case 'G':
case 'O':
case 'W':
iProcessPos++;
long lAdjustor = StringComponent.getInteger(src, ref iProcessPos);
sThunkPrefix = "[thunk]:";
_sThunkAdjustor = "`adjustor{" + lAdjustor.ToString() + "}\' ";
sModifier = strModifier[(int)enumModifier.enmMvirtual];
iProcessPos--;
break;
case 'Y':
_bHasThis = false;
sModifier = "";
break;
default:
throw new Exception();
}
iProcessPos++;
if (tAccess != "" && sModifier != "")
{
tAccess += " ";
}
_strRes = sThunkPrefix + tAccess + sModifier;
saveParseStatus(src, pos, iProcessPos);
pos = iProcessPos;
return this;
}
private bool _bHasThis;
private string _sThunkAdjustor;
public string sThunkAdjustor { get { return _sThunkAdjustor; } }
public bool bHasThis { get { return _bHasThis; } }
}
class ParameterClause : StringComponent
{
public override ParseBase parse(string src, ref int pos, ref List<Type> vType, ref List<UnqualifiedID> vUiD)
{
int iProcessPos = pos;
StringBuilder PList = new StringBuilder();
Type strParamType;
if (src[iProcessPos] == '@')
{
PList.Append("");
iProcessPos++;
}
else if (src[iProcessPos] == 'Z')
{
PList.Append("...");
iProcessPos++;
}
else
{
strParamType = Type.GetTypeLikeID(src, ref iProcessPos, ref vType, ref vUiD, true);
PList.Append(strParamType.getDeclaration(""));
if (strParamType.getDeclaration("") != "void")
{
while (src[iProcessPos] != '@' && src[iProcessPos] != 'Z')
{
strParamType = Type.GetTypeLikeID(src, ref iProcessPos, ref vType, ref vUiD, true);
PList.Append(",");
PList.Append(strParamType.getDeclaration(""));
}
if (src[iProcessPos] == 'Z')
{
PList.Append(",...");
}
iProcessPos++;
}
}
_strRes = PList.ToString();
saveParseStatus(src, pos, iProcessPos);
pos = iProcessPos;
return this;
}
}
class Type : ParseBase
{
#region enumeration constants
protected static String[] strType = {
"&", // reference
"& volatile",
"signed char",
"char",
"unsigned char",
"short",
"unsigned short",
"int",
"unsigned int",
"long",
"unsigned long",
"L",
"float",
"double",
"long double",
"*",
"* const",
"* volatile",
"* const volatile",
"union",
"struct",
"class",
"enum",
"void",
"[.]",
"Z"
};
protected static String[] strTypeE = {
"& __ptr64", // reference
"& __ptr64 volatile",
"C",
"D",
"E",
"F",
"G",
"H",
"I",
"J",
"K",
"L",
"M",
"N",
"O",
"* __ptr64",
"* __ptr64 const",
"* __ptr64 volatile",
"* __ptr64 const volatile",
"T",
"U",
"V",
"W",
"X",
"Y",
"Z"
};
protected static String[] strType_ = {
"_A",
"_B",
"_C",
"__int8",
"unsigned __int8",
"__int16",
"unsigned __int16",
"__int32",
"unsigned __int32",
"__int64",
"unsigned __int64",
"__int128",
"unsigned __int128",
"bool",
"_O",
"auto",
"_Q",
"_R",
"char16_t",
"decltype(auto)",
"char32_t",
"_V",
"wchar_t",
"_X",
"_Y",
"_Z"
};
#endregion
protected String _strCVQualifier = "";
public String StrCVQualifier
{
get { return _strCVQualifier; }
}
virtual public String getTypeString() { throw new NotImplementedException(); }
virtual public String getDeclaration(String qID, bool bEnclose = false)
{
return StringHelper.glue(getTypeString(), qID);
}
virtual public void ajdustCVQ() { _strCVQualifier = ""; }
public override string getDemangledString() { return getDeclaration("###"); }
public static Type GetTypeLikeID(string src, ref int pos, ref List<Type> vType, ref List<UnqualifiedID> vUiD, bool topLevelType = false)
{
Type retType = null;
int iProcessPos = pos;
String[] specials = { "___abi_IDelegate____abi_Invoke" };
switch (src[iProcessPos])
{
case 'C':
case 'D':
case 'E':
case 'F':
case 'G':
case 'H':
case 'I':
case 'J':
case 'K':
case 'M':
case 'N':
case 'O':
case 'X':
retType = new TypeSimple(strType[src[iProcessPos] - 'A']);
iProcessPos++;
break;
case '?':
case 'A':
case 'B':
case 'P':
case 'Q':
case 'R':
case 'S':
retType = new TypeReference().parse(src, ref iProcessPos, ref vType, ref vUiD).toType();
break;
case 'T':
case 'U':
case 'V':
case 'W':
retType = new TypeClass().parse(src, ref iProcessPos, ref vType, ref vUiD).toType();
break;
case 'Y':
retType = new TypeArray().parse(src, ref iProcessPos, ref vType, ref vUiD).toType();
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
retType = vType[src[iProcessPos] - '0'];
#if TRACE
Console.Error.WriteLine("dump vType");
for (int i = 0; i < vType.Count; i++)
{
Console.Error.WriteLine("{0} , {1}", i, vType[i].getDemangledString());
}
#endif
iProcessPos++;
break;
case '_':
iProcessPos++;
switch (src[iProcessPos])
{
case 'D':
case 'E':
case 'F':
case 'G':
case 'H':
case 'I':
case 'J':
case 'K':
case 'L':
case 'M':
case 'N':
case 'P':
case 'S':
case 'T':
case 'U':
case 'W':
retType = new TypeSimple(strType_[src[iProcessPos] - 'A']);
iProcessPos++;
break;
default:
foreach (String special in specials)
{
if (special.Length + iProcessPos - 1 <= src.Length && src.Substring(iProcessPos - 1, special.Length) == special)
{
retType = new TypeSimple("`" + special + "'");
iProcessPos += special.Length - 1;
break;
}
}
if (retType == null) {
throw new Exception("Type specific letter _" + new String(src[iProcessPos], 1) + " not found");
}
break;
}
break;
case '$': // special type or type like identifier
iProcessPos++;
switch (src[iProcessPos])
{
case '0': // integer
iProcessPos++;
retType = new TypeNonType(StringComponent.getInteger(src, ref iProcessPos).ToString());
break;
case '1': // pointer or l-value reference non-type template argument
// a full Declaration follows;
iProcessPos++;
Declaration Decl = new Declaration();
Decl.parse(src, ref iProcessPos, ref vType, ref vUiD);
retType = new TypeNonType("&" + Decl.QualifiedID.getDemangledString() + " /* " + Decl.getDemangledString() + " */");
break;
case 'S':
retType = new TypeNonType(""); // Empty expansion list for integral types/size_t
iProcessPos++;
break;
case '$':
iProcessPos++;
if (src[iProcessPos] == '$' && src[iProcessPos + 1] == 'V')
{ // "$$V" for empty template parameter list
retType = new TypeNonType("");
iProcessPos += 2;
}
else if (src[iProcessPos] == 'V')
{ // empty template parameter expanstion pack
retType = new TypeNonType("");
iProcessPos++;
}
else if (src[iProcessPos] == 'T')
{
retType = new TypeSimple("std::nullptr_t");
iProcessPos++;
}
else if (src[iProcessPos] == 'Z')
{ // separator between two empty template parameter expanstion packs
retType = new TypeNonType("");
iProcessPos++;
}
else
{
iProcessPos = pos;
retType = new TypeReference().parse(src, ref iProcessPos, ref vType, ref vUiD).toType();
}
break;
default:
throw new Exception();
}
break;
case '@':
retType = new TypeNonType("");
break;
default:
throw new Exception("Type specific letter " + new String(src[iProcessPos], 1) + " not found");
}
if (topLevelType && iProcessPos > pos + 1 && !(retType is TypeNonType))
{
vType.Add(retType);
}
pos = iProcessPos;
return retType;
}
}
class TypeSimple : Type
{
private String _strType;
public TypeSimple(String type)
{
_strType = type;
}
public override String getTypeString()
{
return _strType;
}
public override string getDeclaration(string qID, bool hasBrackt = false)
{
return StringHelper.glue(_strType, qID);
}
}
class TypeNonType : TypeSimple
{
public TypeNonType(string type) : base(type) { }
}
class TypeSuffix : Type
{
private String _strSuffix;
public TypeSuffix(string suffix)
{
_strSuffix = suffix;
}
public override string getDeclaration(string qID, bool bEnclose = false)
{
return qID + _strSuffix;
}
}
class CVQ : StringComponent
{
private static readonly String[] str_cv =
{
"",
"const",
"volatile",
"const volatile"
};
private bool _bMemThis = false;
private bool _bIgnoreNormalCV = false;
public bool bMemThis
{
get { return _bMemThis; }
}
public CVQ IgnoreNormalCV(bool ignore)
{
_bIgnoreNormalCV = ignore;
return this;
}
public override ParseBase parse(string src, ref int pos, ref List<Type> vType, ref List<UnqualifiedID> vUiD)
{
int iProcessPos = pos;
_bMemThis = false;
string suffix = "";
if (src[iProcessPos] == '$' && src[iProcessPos + 1] == 'A')
{
// shows that this cv is used for handle
// The generation of the handle symbol is usually in other parts of the mangled name
iProcessPos += 2;
}
switch (src[iProcessPos])
{
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'G':
case 'H':
if (src[iProcessPos] == 'E')
{
suffix = "__ptr64";
iProcessPos++;
}
else if (src[iProcessPos] == 'G')
{
suffix = "&";
iProcessPos++;
}
else if (src[iProcessPos] == 'H')
{
suffix = "&&";
iProcessPos++;
}
switch (src[iProcessPos])
{
case 'A':
case 'B':
case 'C':
case 'D':
_strRes = str_cv[src[iProcessPos] - 'A'];
break;
default:
throw new Exception("Unrecognized CV-Qualifier " + src[iProcessPos]);
}
if (_bIgnoreNormalCV && suffix == "")
{
_strRes = "";
}
else
{
_strRes += suffix;
}
break;
case 'Q':
case 'R':
case 'S':
case 'T':
_strRes = str_cv[src[iProcessPos] - 'Q'];
iProcessPos++;
_strRes = StringHelper.glue(_strRes, new NestNameSpecifier().parse(src, ref iProcessPos, ref vType, ref vUiD).getDemangledString());
iProcessPos--;
if (_bIgnoreNormalCV)
{
_strRes = "";
}
break;
case '6':
_strRes = "";
break;
case '8':
iProcessPos++;
_strRes = new NestNameSpecifier().parse(src, ref iProcessPos, ref vType, ref vUiD).getDemangledString();
_bMemThis = true;
iProcessPos--;
break;
default:
throw new Exception("Unrecognized CV-Qualifier " + src[iProcessPos]);
}
iProcessPos++;
saveParseStatus(src, pos, iProcessPos);
pos = iProcessPos;
return this;
}
}
class TypeReference : Type
{
private String _strReferenceType = "";
private Type _typeReferenced;
public override String getTypeString()
{
return getDeclaration("");
}
public override string getDeclaration(string qID, bool bEnclose = false)
{
String strDecl = "";
char[] seperator ={ ' ' };
String[] refTypes = _strReferenceType.Split(seperator);
for (int i = 1; i < refTypes.Length; i++)
{
String tail = String.Join(" ", refTypes, refTypes.Length - i, i) + " ";
if (qID.StartsWith(tail))
{
qID = qID.Substring(tail.Length);
}
}
if (StrCVQualifier.EndsWith("::"))
{
#if REFINE__
strDecl = StrCVQualifier + StringHelper.glue(_strReferenceType, qID);
#else
strDecl = StrCVQualifier + StringHelper.glue(_strReferenceType == "* const" ? "*" : _strReferenceType, qID);
#endif
}
else
{
#if REFINE__
strDecl = StringHelper.glue(StrCVQualifier, StringHelper.glue(_strReferenceType, qID));
#else
if (StrCVQualifier != "" && _strReferenceType == "" && qID == "")
{ // Extra blank generated by UnDecorateSymbolName
strDecl = StrCVQualifier + " ";
}
else
{
strDecl = StringHelper.glue(StrCVQualifier, StringHelper.glue(_strReferenceType == "* const" && qID.StartsWith("(") ? "*" : _strReferenceType, qID));
}
#endif
}
return _typeReferenced.getDeclaration(strDecl, (_typeReferenced is TypeFunctionBase && _strReferenceType == "") ? false : true);
}
public override void ajdustCVQ()
{
_strReferenceType = _strReferenceType.Replace("* const", "*");
}
public override ParseBase parse(string src, ref int pos, ref List<Type> vType, ref List<UnqualifiedID> vUiD)
{
int iProcessPos = pos;
bool noCV = false;
switch (src[iProcessPos])
{
case 'A':
case 'B':
case 'P':
case 'Q':
case 'R':
case 'S':
if (src[iProcessPos + 1] == 'E')
{
_strReferenceType = strTypeE[src[iProcessPos] - 'A'];
iProcessPos++;
}
else
{
_strReferenceType = strType[src[iProcessPos] - 'A'];
}
if (src[iProcessPos + 1] == '$' && src[iProcessPos + 2] == 'A')
{
_strReferenceType = "^" + _strReferenceType.Substring(1);
iProcessPos += 2;
}
else if (iProcessPos + 7 <= src.Length && src.Substring(iProcessPos + 1, 6) == "$01E$A")
{ // meaning unknown
_strReferenceType = "^" + _strReferenceType.Substring(1);
iProcessPos += 6;
}
break;
case '?': // type transfered by value
break;
case '$':
iProcessPos++;
if (src[iProcessPos] != '$')
{
throw new Exception("Illegal special type identifier");
}
iProcessPos++;
switch (src[iProcessPos])
{
case 'A': // function. (not pointer or reference to function, but a function)
// can appear in template argument
break;
case 'B': // array, no CV qualifier (can appear in template argument)
noCV = true;
break;
case 'C': // used when a simple type need a cvq, like array element, template parameter, etc. only complicate type has a place to encode a cvq.
break;
case 'Q':
_strReferenceType = "&&";
break;
default:
throw new Exception("illegal Special Ref : " + src[iProcessPos]);
}
break;
default:
throw new Exception("Illegal leading char in Ref and Pointer Type : " + src[iProcessPos]);
}
iProcessPos++;
CVQ cvq = new CVQ();
if (Char.IsDigit(src[iProcessPos]))
{
_strCVQualifier = cvq.parse(src, ref iProcessPos, ref vType, ref vUiD).getDemangledString();
_typeReferenced = new TypeFunctionBase(cvq.bMemThis).parse(src, ref iProcessPos, ref vType, ref vUiD).toType();
}
else
{
if (!noCV)
{
_strCVQualifier = cvq.parse(src, ref iProcessPos, ref vType, ref vUiD).getDemangledString();
}
_typeReferenced = Type.GetTypeLikeID(src, ref iProcessPos, ref vType, ref vUiD);
}
saveParseStatus(src, pos, iProcessPos);
pos = iProcessPos;
return this;
}
}
class TypeClass : Type
{
private String _strClassQualifiedName;
private String _classKey;
public override string getTypeString()
{
return _classKey + " " + _strClassQualifiedName;
}
public override ParseBase parse(string src, ref int pos, ref List<Type> vType, ref List<UnqualifiedID> vUiD)
{
int iProcessPos = pos;
char cType = src[iProcessPos];
String infixEnum = "";
if (cType == 'W')
{
iProcessPos++;
if (src[iProcessPos] >= '0' && src[iProcessPos] <= '7')
{
infixEnum = strType[src[iProcessPos] - '0' + 3] + " ";
if (infixEnum == "int ")
{
infixEnum = "";
}
}
else
{
throw new Exception("illegal Enumeration : " + src[iProcessPos]);
}
}
switch (cType)
{
case 'T':
case 'U':
case 'V':
case 'W':
iProcessPos++;
_classKey = StringHelper.glue(strType[cType - 'A'], infixEnum);
_strClassQualifiedName = new QualifiedID().parse(src, ref iProcessPos, ref vType, ref vUiD).getDemangledString();
break;
default:
throw new Exception("illegal compound : " + cType);
}
saveParseStatus(src, pos, iProcessPos);
pos = iProcessPos;
return this;
}
}
class TypeArray : Type
{
private String _strSubcript;
private Type _baseType;
public override string getDeclaration(string qID, bool hasBrackt = false)
{
//String Decl = "";
if (qID.IndexOf('*') >= 0 || qID.IndexOf('&') >= 0)
{
#if REFINE__
#else
// This should be a bug of UnDecorateSymbolName
if (qID.StartsWith("* const "))
{
qID = "*" + qID.Substring("* const".Length);
}
#endif
qID = "(" + qID + ")";
}
return _baseType.getDeclaration(qID + _strSubcript);
}
public override ParseBase parse(string src, ref int pos, ref List<Type> vType, ref List<UnqualifiedID> vUiD)
{
int iProcessPos = pos;
if (src[iProcessPos] != 'Y')
{
throw new Exception("Error Array Identifier");
}
iProcessPos++;
_strSubcript = "";
long Dimension = StringComponent.getInteger(src, ref iProcessPos);
for (long i = 0; i < Dimension; i++)
{
// a dimension of 0 is used of array of unknown bound
// may appear in template argument
long dim = StringComponent.getInteger(src, ref iProcessPos);
string s_dim = "";
if (dim > 0)
{
s_dim = dim.ToString();
}
_strSubcript = _strSubcript + "[" + s_dim + "]";
}
_baseType = Type.GetTypeLikeID(src, ref iProcessPos, ref vType, ref vUiD);
saveParseStatus(src, pos, iProcessPos);
pos = iProcessPos;
return this;
}
}
class TypeVarType : Type
{
private String _strAccess;
private Type _baseType;
public override string getTypeString()
{
return getDeclaration("");
}
public override string getDeclaration(string qID, bool hasBrackt = false)
{
return _strAccess + _baseType.getDeclaration(StringHelper.glue(StrCVQualifier.EndsWith("::") ? "" : StrCVQualifier, qID));
}
public override ParseBase parse(string src, ref int pos, ref List<Type> vType, ref List<UnqualifiedID> vUiD)
{
int iProcessPos = pos;
_baseType = new TypeSimple("");
int iSpecialVariable = 0;
switch (src[iProcessPos])
{
case '0':
_strAccess = "private: static ";
break;
case '1':
_strAccess = "protected: static ";
break;
case '2':
_strAccess = "public: static ";
break;
case '3':
_strAccess = "";
break;
case '4': // function scope static variable
_strAccess = "";
break;
case '5':
_strAccess = "";
iSpecialVariable = 5;
break;
case '6': // `vftable'
_strAccess = "";
iSpecialVariable = 6;
break;
case '7': // `vbtable'
_strAccess = "";
iSpecialVariable = 7;
break;
case '8':
_strAccess = "";
iSpecialVariable = 8;
break;
case '9':
_strAccess = "";
iSpecialVariable = 9;
break;
default:
throw new Exception("Illegal Variable Acess modifier: " + src[iProcessPos]);
//break;
}