annotate basic/Attribute.d @ 140:927ae00bd9d2

Added support for extern keyword. Being ignored atm though. Also changed ast/Module, so that you can get a list of only vars, functions or structs.
author Anders Johnsen <skabet@gmail.com>
date Sun, 20 Jul 2008 23:23:56 +0200
parents 2be29b296081
children d76cc5cad4fc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
126
c3b24e7e8cf8 Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
1 module basic.Attribute;
c3b24e7e8cf8 Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
2
136
2be29b296081 Lots of changes:
johnsen@johnsen-laptop
parents: 126
diff changeset
3 import tango.core.BitManip;
2be29b296081 Lots of changes:
johnsen@johnsen-laptop
parents: 126
diff changeset
4 import Integer = tango.text.convert.Integer;
2be29b296081 Lots of changes:
johnsen@johnsen-laptop
parents: 126
diff changeset
5
2be29b296081 Lots of changes:
johnsen@johnsen-laptop
parents: 126
diff changeset
6 import tango.io.Stdout;
2be29b296081 Lots of changes:
johnsen@johnsen-laptop
parents: 126
diff changeset
7
126
c3b24e7e8cf8 Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
8 enum Protection : uint
c3b24e7e8cf8 Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
9 {
c3b24e7e8cf8 Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
10 Private = 1<<0,
c3b24e7e8cf8 Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
11 Public = 1<<1,
c3b24e7e8cf8 Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
12 Package = 1<<2,
c3b24e7e8cf8 Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
13 Protected = 1<<3,
c3b24e7e8cf8 Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
14 Export = 1<<4,
c3b24e7e8cf8 Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
15 }
c3b24e7e8cf8 Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
16
140
927ae00bd9d2 Added support for extern keyword. Being ignored atm though. Also changed ast/Module, so that you can get a list of only vars, functions or structs.
Anders Johnsen <skabet@gmail.com>
parents: 136
diff changeset
17 enum Extern : uint
927ae00bd9d2 Added support for extern keyword. Being ignored atm though. Also changed ast/Module, so that you can get a list of only vars, functions or structs.
Anders Johnsen <skabet@gmail.com>
parents: 136
diff changeset
18 {
927ae00bd9d2 Added support for extern keyword. Being ignored atm though. Also changed ast/Module, so that you can get a list of only vars, functions or structs.
Anders Johnsen <skabet@gmail.com>
parents: 136
diff changeset
19 C = 1<<12,
927ae00bd9d2 Added support for extern keyword. Being ignored atm though. Also changed ast/Module, so that you can get a list of only vars, functions or structs.
Anders Johnsen <skabet@gmail.com>
parents: 136
diff changeset
20 CPlusPlus = 1<<13,
927ae00bd9d2 Added support for extern keyword. Being ignored atm though. Also changed ast/Module, so that you can get a list of only vars, functions or structs.
Anders Johnsen <skabet@gmail.com>
parents: 136
diff changeset
21 D = 1<<14,
927ae00bd9d2 Added support for extern keyword. Being ignored atm though. Also changed ast/Module, so that you can get a list of only vars, functions or structs.
Anders Johnsen <skabet@gmail.com>
parents: 136
diff changeset
22 Windows = 1<<15,
927ae00bd9d2 Added support for extern keyword. Being ignored atm though. Also changed ast/Module, so that you can get a list of only vars, functions or structs.
Anders Johnsen <skabet@gmail.com>
parents: 136
diff changeset
23 Pascal = 1<<16,
927ae00bd9d2 Added support for extern keyword. Being ignored atm though. Also changed ast/Module, so that you can get a list of only vars, functions or structs.
Anders Johnsen <skabet@gmail.com>
parents: 136
diff changeset
24 System = 1<<17,
927ae00bd9d2 Added support for extern keyword. Being ignored atm though. Also changed ast/Module, so that you can get a list of only vars, functions or structs.
Anders Johnsen <skabet@gmail.com>
parents: 136
diff changeset
25 }
927ae00bd9d2 Added support for extern keyword. Being ignored atm though. Also changed ast/Module, so that you can get a list of only vars, functions or structs.
Anders Johnsen <skabet@gmail.com>
parents: 136
diff changeset
26
126
c3b24e7e8cf8 Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
27 struct Attribute
c3b24e7e8cf8 Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
28 {
c3b24e7e8cf8 Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
29
c3b24e7e8cf8 Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
30 void setProtection(Protection p)
c3b24e7e8cf8 Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
31 {
c3b24e7e8cf8 Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
32 att &= 0xFFFFFFE0;
136
2be29b296081 Lots of changes:
johnsen@johnsen-laptop
parents: 126
diff changeset
33 att |= p;
2be29b296081 Lots of changes:
johnsen@johnsen-laptop
parents: 126
diff changeset
34 }
2be29b296081 Lots of changes:
johnsen@johnsen-laptop
parents: 126
diff changeset
35
2be29b296081 Lots of changes:
johnsen@johnsen-laptop
parents: 126
diff changeset
36 Protection getProtection()
2be29b296081 Lots of changes:
johnsen@johnsen-laptop
parents: 126
diff changeset
37 {
2be29b296081 Lots of changes:
johnsen@johnsen-laptop
parents: 126
diff changeset
38 Protection p = Protection.Public;
2be29b296081 Lots of changes:
johnsen@johnsen-laptop
parents: 126
diff changeset
39 switch(bsf(0xF0000000 | att))
2be29b296081 Lots of changes:
johnsen@johnsen-laptop
parents: 126
diff changeset
40 {
2be29b296081 Lots of changes:
johnsen@johnsen-laptop
parents: 126
diff changeset
41 case 0:
2be29b296081 Lots of changes:
johnsen@johnsen-laptop
parents: 126
diff changeset
42 p = Protection.Private;
2be29b296081 Lots of changes:
johnsen@johnsen-laptop
parents: 126
diff changeset
43 break;
2be29b296081 Lots of changes:
johnsen@johnsen-laptop
parents: 126
diff changeset
44 case 1:
2be29b296081 Lots of changes:
johnsen@johnsen-laptop
parents: 126
diff changeset
45 p = Protection.Public;
2be29b296081 Lots of changes:
johnsen@johnsen-laptop
parents: 126
diff changeset
46 break;
2be29b296081 Lots of changes:
johnsen@johnsen-laptop
parents: 126
diff changeset
47 case 2:
2be29b296081 Lots of changes:
johnsen@johnsen-laptop
parents: 126
diff changeset
48 p = Protection.Package;
2be29b296081 Lots of changes:
johnsen@johnsen-laptop
parents: 126
diff changeset
49 break;
2be29b296081 Lots of changes:
johnsen@johnsen-laptop
parents: 126
diff changeset
50 case 3:
2be29b296081 Lots of changes:
johnsen@johnsen-laptop
parents: 126
diff changeset
51 p = Protection.Protected;
2be29b296081 Lots of changes:
johnsen@johnsen-laptop
parents: 126
diff changeset
52 break;
2be29b296081 Lots of changes:
johnsen@johnsen-laptop
parents: 126
diff changeset
53 case 4:
2be29b296081 Lots of changes:
johnsen@johnsen-laptop
parents: 126
diff changeset
54 p = Protection.Export;
2be29b296081 Lots of changes:
johnsen@johnsen-laptop
parents: 126
diff changeset
55 break;
2be29b296081 Lots of changes:
johnsen@johnsen-laptop
parents: 126
diff changeset
56 default:
2be29b296081 Lots of changes:
johnsen@johnsen-laptop
parents: 126
diff changeset
57 break;
2be29b296081 Lots of changes:
johnsen@johnsen-laptop
parents: 126
diff changeset
58 }
2be29b296081 Lots of changes:
johnsen@johnsen-laptop
parents: 126
diff changeset
59 return p;
126
c3b24e7e8cf8 Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
60 }
c3b24e7e8cf8 Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
61
140
927ae00bd9d2 Added support for extern keyword. Being ignored atm though. Also changed ast/Module, so that you can get a list of only vars, functions or structs.
Anders Johnsen <skabet@gmail.com>
parents: 136
diff changeset
62 void setExtern(Extern e)
927ae00bd9d2 Added support for extern keyword. Being ignored atm though. Also changed ast/Module, so that you can get a list of only vars, functions or structs.
Anders Johnsen <skabet@gmail.com>
parents: 136
diff changeset
63 {
927ae00bd9d2 Added support for extern keyword. Being ignored atm though. Also changed ast/Module, so that you can get a list of only vars, functions or structs.
Anders Johnsen <skabet@gmail.com>
parents: 136
diff changeset
64 att &= ~e;
927ae00bd9d2 Added support for extern keyword. Being ignored atm though. Also changed ast/Module, so that you can get a list of only vars, functions or structs.
Anders Johnsen <skabet@gmail.com>
parents: 136
diff changeset
65 }
927ae00bd9d2 Added support for extern keyword. Being ignored atm though. Also changed ast/Module, so that you can get a list of only vars, functions or structs.
Anders Johnsen <skabet@gmail.com>
parents: 136
diff changeset
66
126
c3b24e7e8cf8 Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
67 void setStatic() { att &= ~Static; }
c3b24e7e8cf8 Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
68 void setFinal() { att &= ~Final; }
c3b24e7e8cf8 Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
69 void setConst() { att &= ~Const; }
c3b24e7e8cf8 Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
70 void setAbstract() { att &= ~Abstract; }
c3b24e7e8cf8 Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
71 void setOverride() { att &= ~Override; }
c3b24e7e8cf8 Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
72 void setDepracted() { att &= ~Depracted; }
c3b24e7e8cf8 Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
73 void setAuto() { att &= ~Auto; }
c3b24e7e8cf8 Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
74
136
2be29b296081 Lots of changes:
johnsen@johnsen-laptop
parents: 126
diff changeset
75 char[] toString()
2be29b296081 Lots of changes:
johnsen@johnsen-laptop
parents: 126
diff changeset
76 {
2be29b296081 Lots of changes:
johnsen@johnsen-laptop
parents: 126
diff changeset
77 return Integer.toString(att);
2be29b296081 Lots of changes:
johnsen@johnsen-laptop
parents: 126
diff changeset
78 }
2be29b296081 Lots of changes:
johnsen@johnsen-laptop
parents: 126
diff changeset
79
126
c3b24e7e8cf8 Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
80 private:
c3b24e7e8cf8 Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
81 uint att;
c3b24e7e8cf8 Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
82
c3b24e7e8cf8 Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
83
c3b24e7e8cf8 Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
84 static const uint Static = 1<<5;
c3b24e7e8cf8 Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
85 static const uint Final = 1<<6;
c3b24e7e8cf8 Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
86 static const uint Const = 1<<7;
c3b24e7e8cf8 Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
87 static const uint Abstract = 1<<8;
c3b24e7e8cf8 Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
88 static const uint Override = 1<<9;
c3b24e7e8cf8 Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
89 static const uint Depracted = 1<<10;
c3b24e7e8cf8 Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
90 static const uint Auto = 1<<11;
c3b24e7e8cf8 Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
diff changeset
91 }