annotate dmd/ScopeExp.d @ 114:e28b18c23469

added a module dmd.common for commonly used stuff it currently holds code for consistency checking of predefined versions also added a VisualD project file
author Trass3r
date Wed, 01 Sep 2010 18:21:58 +0200
parents 2e2a5c3f943a
children e3afd1303184
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
1 module dmd.ScopeExp;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
2
114
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 72
diff changeset
3 import dmd.common;
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
4 import dmd.Expression;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
5 import dmd.backend.elem;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
6 import dmd.ScopeDsymbol;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 import dmd.OutBuffer;
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
8 import dmd.TemplateInstance;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
9 import dmd.Loc;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
10 import dmd.TOK;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
11 import dmd.Scope;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
12 import dmd.IRState;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 import dmd.HdrGenState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 import dmd.Global;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15 import dmd.Dsymbol;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 import dmd.VarExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17 import dmd.DotVarExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 import dmd.DsymbolExp;
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
19 import dmd.Type;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
20
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21 class ScopeExp : Expression
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
23 ScopeDsymbol sds;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25 this(Loc loc, ScopeDsymbol pkg)
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
26 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27 super(loc, TOK.TOKimport, ScopeExp.sizeof);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 //printf("ScopeExp.ScopeExp(pkg = '%s')\n", pkg.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29 //static int count; if (++count == 38) *(char*)0=0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
30 this.sds = pkg;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
33 override Expression syntaxCopy()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 ScopeExp se = new ScopeExp(loc, cast(ScopeDsymbol)sds.syntaxCopy(null));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36 return se;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
39 override Expression semantic(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41 TemplateInstance ti;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 ScopeDsymbol sds2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44 version (LOGSEMANTIC) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 printf("+ScopeExp.semantic('%s')\n", toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 Lagain:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48 ti = sds.isTemplateInstance();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49 if (ti && !global.errors)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51 Dsymbol s;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52 if (!ti.semanticRun)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53 ti.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 s = ti.inst.toAlias();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 sds2 = s.isScopeDsymbol();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56 if (!sds2)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
58 Expression e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60 //printf("s = %s, '%s'\n", s.kind(), s.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61 if (ti.withsym)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63 // Same as wthis.s
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64 e = new VarExp(loc, ti.withsym.withstate.wthis);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65 e = new DotVarExp(loc, e, s.isDeclaration());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
67 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
68 e = new DsymbolExp(loc, s);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
69
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70 e = e.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71 //printf("-1ScopeExp.semantic()\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74 if (sds2 != sds)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 sds = sds2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79 //printf("sds = %s, '%s'\n", sds.kind(), sds.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 //printf("sds = %s, '%s'\n", sds.kind(), sds.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84 //printf("\tparent = '%s'\n", sds.parent.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85 sds.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
87 type = Type.tvoid;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88 //printf("-2ScopeExp.semantic() %s\n", toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
91
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
92 override elem* toElem(IRState* irs)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
93 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
97 override void toCBuffer(OutBuffer buf, HdrGenState* hgs)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99 if (sds.isTemplateInstance())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
101 sds.toCBuffer(buf, hgs);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
102 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
103 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
104 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
105 buf.writestring(sds.kind());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
106 buf.writestring(" ");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
107 buf.writestring(sds.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
108 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
109 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
110 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
111