root/trunk/dtypes.d

Revision 21, 11.2 kB (checked in by Jaymz031602, 3 years ago)

Added dtypes.d for dparse.d dependency - sorry, forgot about it when I checked in the originals.

Line 
1 module  dtypes;
2
3 private import dlexer;
4
5 enum {
6     STCundefined    = 0,
7     STCstatic       = 1,
8     STCextern       = 2,
9     STCconst        = 4,
10     STCfinal        = 8,
11     STCabstract     = 0x10,
12     STCparameter    = 0x20,
13     STCfield        = 0x40,
14     STCoverride     = 0x80,
15     STCauto         = 0x100,
16     STCsynchronized = 0x200,
17     STCdeprecated   = 0x400,
18     STCin           = 0x800,        // in parameter
19     STCout          = 0x1000,       // out parameter
20     STCforeach      = 0x2000,       // variable for foreach loop
21     STCcomdat       = 0x4000,       // should go into COMDAT record
22 };
23
24 enum {
25     PROTundefined,
26     PROTnone,       // no access
27     PROTprivate,
28     PROTpackage,
29     PROTprotected,
30     PROTpublic,
31     PROTexport,
32 };
33
34 enum {
35     LINKdefault,
36     LINKwindows,
37     LINKpascal,
38     LINKd,
39     LINKc,
40     LINKcpp
41 };
42
43 enum {
44     Tarray,         // dynamic array
45     Tsarray,        // static array
46     Taarray,        // associative array
47     Tpointer,
48     Treference,
49     Tfunction,
50     Tident,
51     Tclass,
52     Tstruct,
53     Tenum,
54     Ttypedef,
55     Tdelegate,
56
57     Tnone,
58     Tvoid,
59     Tint8,
60     Tuns8,
61     Tint16,
62     Tuns16,
63     Tint32,
64     Tuns32,
65     Tint64,
66     Tuns64,
67     Tfloat32,
68     Tfloat64,
69     Tfloat80,
70
71     Timaginary32,
72     Timaginary64,
73     Timaginary80,
74
75     Tcomplex32,
76     Tcomplex64,
77     Tcomplex80,
78
79     Tbit,
80     Tchar,
81     Twchar,
82     Tdchar,
83
84     Terror,
85     Tinstance,
86     Ttypeof,
87     TMAX
88 };
89
90 enum {
91     PSsemi = 1,     // empty ';' statements are allowed
92     PSscope = 2,    // start a new scope
93     PScurly = 4,    // { } statement is required
94     PScurlyscope = 8,   // { } starts a new scope
95 };
96
97 enum {
98     In,
99     Out,
100     InOut
101 };
102
103 // A dynamically growing array with some stack properties:
104 class ArrayT(mytype) {
105     mytype[]    data;
106     int         count;
107
108     this() {
109         count = 0;
110         data.length = 0;
111     }
112
113     int dim() {
114         return data.length;
115     }
116
117     void dim(int i) {
118         data.length = i;
119     }
120
121     void reserve(int i) {
122         if (data.length - count < i)
123             data.length = count + i;
124     }
125
126     mytype pop() {
127         return data[--count];
128     }
129
130     void push(mytype s) {
131         reserve(1);
132         data[count++] = s;
133     }
134
135     void append(ArrayT a) {
136         data.length = count;
137         data ~= a.data;
138         count = data.length;
139     }
140 }
141
142 class Id {
143     static Identifier   Windows;
144     static Identifier   Pascal;
145     static Identifier   D;
146     static Identifier   C;
147     static Identifier   empty;
148     static this() {
149         Windows = new Identifier("Windows", 0);
150         Pascal = new Identifier("Pascal", 0);
151         D = new Identifier("D", 0);
152         C = new Identifier("C", 0);
153         empty = new Identifier("", 0);
154     }
155 }
156
157 class Dsymbol {
158     public:
159         Identifier      id;
160         Loc             loc;
161        
162         this(Loc loc, Identifier id) {
163             this.loc = loc;
164             this.id = id;
165         }
166 }
167
168 alias ArrayT!(Dsymbol) Array;
169
170 class Type {
171     static Type tvoid;
172     static Type tint8;
173     static Type tuns8;
174     static Type tint16;
175     static Type tuns16;
176     static Type tint32;
177     static Type tuns32;
178     static Type tint64;
179     static Type tuns64;
180     static Type tfloat32;
181     static Type tfloat64;
182     static Type tfloat80;
183     static Type timaginary32;
184     static Type timaginary64;
185     static Type timaginary80;
186     static Type tcomplex32;
187     static Type tcomplex64;
188     static Type tcomplex80;
189     static Type tbit;
190     static Type tchar;
191     static Type twchar;
192     static Type tdchar;
193
194     Type    next;
195     uint    ty;
196 }
197
198 class TypeQualified : Type {
199    
200 }
201
202 class TypeTypeof : TypeQualified {
203     public:
204         this(Loc loc, Expression e) {
205             super(loc, null);
206         }
207 }
208
209 class TypePointer : TypeQualified {
210     public:
211         this(Type y) {
212            
213         }
214 }
215
216 class TypeInstance : TypeQualified {
217     public:
218         this(Loc loc, TemplateInstance ti) {
219         }
220 }
221
222 class TypeIdentifier : TypeQualified {
223     public:
224         this(Loc loc, Identifier id) {
225            
226         }
227 }
228
229 class TypeDArray : TypeQualified {
230     public:
231         this(Type t) {
232            
233         }
234 }
235
236 class TypeAArray : TypeQualified {
237     public:
238         this(Type t, Type it) {
239            
240         }
241 }
242
243 class TypeSArray : TypeQualified {
244     public:
245         this(Type t, Expression e) {
246            
247         }
248 }
249
250 class TypeFunction : TypeQualified {
251     public:
252         this(Array a, Type t, int b, uint c) {
253        
254         }
255 }
256
257 class TypeDelegate : TypeQualified {
258     public:
259         this(Type t) {
260        
261         }
262 }
263
264 class Declaration : Dsymbol {
265     public:
266         uint    storage_class;
267
268         this(Loc loc, Identifier id) {
269             super(loc, id);
270         }
271 }
272
273 class TypedefDeclaration : Declaration {
274     public:
275         this(Identifier id, Type t, Initializer iz) {
276
277         }
278 }
279
280 class AggregateDeclaration : Declaration {
281     public:
282         Array   members;
283
284         this(Loc loc, Identifier id) {
285             super(loc, id);
286             this.members = new Array();
287         }
288 }
289
290 class StructDeclaration : AggregateDeclaration {
291     public:
292         this(Loc loc, Identifier id) {
293             super(loc, id);
294         }
295 }
296
297 class UnionDeclaration : AggregateDeclaration {
298     public:
299         this(Loc loc, Identifier id) {
300             super(loc, id);
301         }
302 }
303
304 class InterfaceDeclaration : AggregateDeclaration {
305     public:
306         this(Loc loc, Identifier id) {
307             super(loc, id);
308         }
309
310         this(Loc loc, Identifier id, Array a) {
311             super(loc, id);
312         }
313 }
314
315 class ClassDeclaration : AggregateDeclaration {
316     public:
317         this(Loc loc, Identifier id) {
318             super(loc, id);
319         }
320
321         this(Loc loc, Identifier id, Array a) {
322             super(loc, id);
323         }
324 }
325
326 class AnonDeclaration : AggregateDeclaration {
327     public:
328         this(Loc loc, Identifier id) {
329             super(loc, id);
330         }
331
332         this(int i, Array a) {
333            
334         }
335 }
336
337 class FuncDeclaration : Declaration {
338     public:
339         Statement   fbody, frequire, fensure;
340         Loc         endloc;
341         Identifier  outId;
342
343         this(Loc loc, int a, Identifier id, uint b, Type t) {
344             super(loc, id);
345         }
346 }
347
348 class CtorDeclaration : FuncDeclaration {
349     public:
350         this(Loc loc, int a, Array b, int c) {
351             super(loc, null);
352         }
353 }
354
355 class StaticCtorDeclaration : FuncDeclaration {
356     public:
357         this(Loc loc, int a, Array b, int c) {
358             super(loc, null);
359         }
360
361         this(Loc loc, int level) {
362        
363         }
364 }
365
366 class DtorDeclaration : FuncDeclaration {
367     public:
368         this(Loc loc, Identifier id) {
369             super(loc, id);
370         }
371
372         this(Loc loc, int level) {
373        
374         }
375 }
376
377 class StaticDtorDeclaration : FuncDeclaration {
378     public:
379         this(Loc loc, Identifier id) {
380             super(loc, id);
381         }
382        
383         this(Loc loc, int level) {
384        
385         }
386 }
387
388 class NewDeclaration : FuncDeclaration {
389     public:
390         this(Loc loc, Identifier id) {
391             super(loc, id);
392         }
393
394         this(Loc loc, int a, Array b, int c) {
395             super(loc, null);
396         }
397 }
398
399 class DeleteDeclaration : FuncDeclaration {
400     public:
401         this(Loc loc, Identifier id) {
402             super(loc, id);
403         }
404
405         this(Loc loc, int a, Array b) {
406             super(loc, null);
407         }
408 }
409
410 class BaseClass : Dsymbol {
411     public:
412         this(Type t, uint v) {
413
414         }
415 }
416
417 class EnumMember : Dsymbol {
418     public:
419         this(Loc loc, Identifier id, Expression e) {
420             super(loc, id);
421         }
422 }
423
424 class EnumDeclaration : Declaration {
425     public:
426         ArrayT!(EnumMember) members;
427
428         this(Identifier id, Type t) {
429             super(null, id);
430         }
431 }
432
433 class TemplateParameter : Dsymbol {
434     public:
435         this(Loc loc, Identifier id, Type t) {
436             super(loc, id);
437         }
438 }
439
440 class TemplateAliasParameter : TemplateParameter {
441     public:
442         this(Loc loc, Identifier id, Type t) {
443             super(loc, id, t);
444         }
445 }
446
447 class TemplateTypeParameter : TemplateParameter {
448     public:
449         this(Loc loc, Identifier id, Type t, Type t2) {
450             super(loc, id, t);
451         }
452 }
453
454 class TemplateValueParameter : TemplateParameter {
455     public:
456         this(Loc loc, Identifier id, Type t, Expression e, Expression e2) {
457             super(loc, id, t);
458         }
459 }
460
461 class TemplateDeclaration : Declaration {
462     public:
463         this(Loc loc, Identifier id, Array a, Array b) {
464             super(loc, id);
465         }
466 }
467
468 class DebugSymbol : Dsymbol {
469     public:
470         uint    level;
471
472         this(Identifier id) {
473             super(null, id);
474         }
475
476         this(uint level) {
477             this.level = level;
478         }
479 }
480
481 class VersionSymbol : Dsymbol {
482     public:
483         uint    level;
484
485         this(Identifier id) {
486             super(null, id);
487         }
488
489         this(uint level) {
490             this.level = level;
491         }
492 }
493
494 class Import : Dsymbol {
495     public:
496         ArrayT!(Identifier) imp;
497
498         this(Loc loc, ArrayT!(Identifier) a, Identifier id) {
499             super(loc, id);
500             imp = a;
501         }
502 }
503
504 class Initializer {
505     public:
506         this(Loc loc, Loc endloc) {
507            
508         }
509 }
510
511 class StructInitializer : Initializer {
512     public:
513         ArrayT!(Identifier)     field;
514         ArrayT!(Initializer)    value;
515         AggregateDeclaration    ad;
516        
517         this(Loc loc) {
518             super(loc, null);
519         }
520
521         void addInit(Identifier field, Initializer value) {
522             this.field.push(field);
523             this.value.push(value);
524         }
525 }
526
527 class ArrayInitializer : Initializer {
528     public:
529         ArrayT!(Expression)     index;
530         ArrayT!(Initializer)    value;
531         uint                    dim;
532         Type                    type;
533        
534         this(Loc loc) {
535             super(loc, null);
536         }
537
538         void addInit(Expression e, Initializer iz) {
539             index.push(e);
540             value.push(iz);
541         }
542 }
543
544 class ExpInitializer : Initializer {
545     public:
546         Expression      exp;
547
548         this(Loc loc, Expression e) {
549             super(loc, null);
550             exp = e;
551         }
552 }
553
554
555 class VarDeclaration : Declaration {
556     public:
557         this(Loc loc, Type t, Identifier id, Initializer iz) {
558             super(loc, id);
559         }
560 }
561
562 class Statement {
563     public:
564         Loc     loc;
565
566         this(Loc loc) {
567             this.loc = loc;
568         }
569 }
570
571 class ExpStatement : Statement {
572     public:
573         Expression  exp;
574
575         this(Loc loc, Expression e) {
576             super(loc);
577             exp = e;
578         }
579 }
580
581 class DeclarationStatement : ExpStatement {
582     public:
583         this(Loc loc, Dsymbol id) {
584             super(loc);
585         }
586         this(Loc loc, Expression e) {
587             super(loc, e);
588         }
589 }
590
591 class CompoundStatement : Statement {
592     public:
593         ArrayT!(Statement)  statements;
594
595         this(Loc loc, ArrayT!(Statement) s) {
596             super(loc);
597             statements = s;
598         }
599         this(Loc loc, Statement s1, Statement s2) {
600             super(loc);
601             statements = new ArrayT!(Statement);
602             statements.push(s1);
603             statements.push(s2);
604         }
605 }
606
607 class Expression : Dsymbol {
608     public:
609         this(Loc loc, Identifier id) {
610             super(loc, id);
611         }
612 }
613
614 class StaticAssert : Dsymbol {
615     public:
616         this(Loc loc, Expression e) {
617             super(loc, null);
618         }
619 }
620
621 class UnitTestDeclaration : FuncDeclaration {
622     public:
623         this(Loc loc, Loc endloc) {
624             super(loc, null);
625         }
626 }
627
628 class TemplateMixin : Dsymbol {
629     public:
630         this(Loc loc, Identifier id, TypeTypeof t, ArrayT!(Identifier) a, Array b) {
631             super(loc, id);
632         }
633 }
634
635 class TemplateInstance : Dsymbol {
636     public:
637         Array   tiargs;
638
639         this(Loc loc, Identifier id) {
640             super(loc, id);
641         }
642
643         void addIdent(Identifier id) {
644        
645         }
646 }
647
648 class AliasDeclaration : Declaration {
649     public:
650         TemplateInstance    ti;
651
652         this(Loc loc, Identifier id, TemplateInstance ti) {
653             super(loc, id);
654             this.ti = ti;
655         }
656
657         this(Loc loc, Identifier id, Type t) {
658             super(loc, id);
659         }
660 }
661
662 class InvariantDeclaration : FuncDeclaration {
663     public:
664         this(Loc loc, Identifier id) {
665             super(loc, id);
666         }
667        
668         this(Loc loc, int level) {
669        
670         }
671 }
672
673 class StorageClassDeclaration : Declaration {
674     public:
675         this(uint stc, Array a) {
676            
677         }
678 }
679
680 class ProtDeclaration : Declaration {
681     public:
682         this(uint prot, Array a) {
683            
684         }
685 }
686
687 class AlignDeclaration : Declaration {
688     public:
689         this(uint prot, Array a) {
690            
691         }
692 }
693
694 class PragmaDeclaration : Declaration {
695     public:
696         this(Identifier id, Array a, Array b) {
697            
698         }
699 }
700
701 class LinkDeclaration : Declaration {
702     public:
703         this(uint link, Array a) {
704            
705         }
706 }
707
708 // Conditions:
709
710 class DebugCondition : Dsymbol {
711     public:
712         uint    level;
713
714         this(uint level, Identifier id) {
715             super(null, id);
716             this.level = level;
717         }
718 }
719
720 class VersionCondition : Dsymbol {
721     public:
722         uint    level;
723
724         this(uint level, Identifier id) {
725             super(null, id);
726             this.level = level;
727         }
728 }
729
730 class DebugDeclaration : Declaration {
731     public:
732         this(DebugCondition dc, Array a, Array b) {
733            
734         }
735 }
736
737 class VersionDeclaration : Declaration {
738     public:
739         this(VersionCondition dc, Array a, Array b) {
740            
741         }
742 }
743
744 class Argument : Dsymbol {
745     public:
746         this(uint inoutt, Type a, Identifier id, Expression e) {
747         }
748 }
749
750 class ScopeExp : Expression