annotate dmd/TemplateAliasParameter.d @ 13:427f8aa74d28

On the road to make Phobos compilable
author korDen
date Mon, 12 Apr 2010 16:29:33 +0400
parents 89cc05dbdae1
children 460959608115
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1 module dmd.TemplateAliasParameter;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
3 import dmd.TemplateParameter;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.Loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5 import dmd.Identifier;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
6 import dmd.Type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 import dmd.ArrayTypes;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8 import dmd.Scope;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
9 import dmd.Declaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
10 import dmd.MATCH;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
11 import dmd.OutBuffer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12 import dmd.HdrGenState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 import dmd.Dsymbol;
13
427f8aa74d28 On the road to make Phobos compilable
korDen
parents: 7
diff changeset
14 import dmd.TypeIdentifier;
427f8aa74d28 On the road to make Phobos compilable
korDen
parents: 7
diff changeset
15 import dmd.AliasDeclaration;
427f8aa74d28 On the road to make Phobos compilable
korDen
parents: 7
diff changeset
16 import dmd.Util;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17
7
89cc05dbdae1 Implementing TemplateAliasParameter and TemplateValueParameter
dkoroskin <>
parents: 0
diff changeset
18 import dmd.templates.Util;
89cc05dbdae1 Implementing TemplateAliasParameter and TemplateValueParameter
dkoroskin <>
parents: 0
diff changeset
19
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20 class TemplateAliasParameter : TemplateParameter
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22 /* Syntax:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
23 * specType ident : specAlias = defaultAlias
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26 Type specType;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27 Object specAlias;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 Object defaultAlias;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
30 static Dsymbol sdummy;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32 this(Loc loc, Identifier ident, Type specType, Object specAlias, Object defaultAlias)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34 super(loc, ident);
7
89cc05dbdae1 Implementing TemplateAliasParameter and TemplateValueParameter
dkoroskin <>
parents: 0
diff changeset
35
89cc05dbdae1 Implementing TemplateAliasParameter and TemplateValueParameter
dkoroskin <>
parents: 0
diff changeset
36 this.specType = specType;
89cc05dbdae1 Implementing TemplateAliasParameter and TemplateValueParameter
dkoroskin <>
parents: 0
diff changeset
37 this.specAlias = specAlias;
89cc05dbdae1 Implementing TemplateAliasParameter and TemplateValueParameter
dkoroskin <>
parents: 0
diff changeset
38 this.defaultAlias = defaultAlias;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41 TemplateAliasParameter isTemplateAliasParameter()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 {
7
89cc05dbdae1 Implementing TemplateAliasParameter and TemplateValueParameter
dkoroskin <>
parents: 0
diff changeset
43 return this;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46 TemplateParameter syntaxCopy()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 {
7
89cc05dbdae1 Implementing TemplateAliasParameter and TemplateValueParameter
dkoroskin <>
parents: 0
diff changeset
48 TemplateAliasParameter tp = new TemplateAliasParameter(loc, ident, specType, specAlias, defaultAlias);
89cc05dbdae1 Implementing TemplateAliasParameter and TemplateValueParameter
dkoroskin <>
parents: 0
diff changeset
49 if (tp.specType)
89cc05dbdae1 Implementing TemplateAliasParameter and TemplateValueParameter
dkoroskin <>
parents: 0
diff changeset
50 tp.specType = specType.syntaxCopy();
89cc05dbdae1 Implementing TemplateAliasParameter and TemplateValueParameter
dkoroskin <>
parents: 0
diff changeset
51 tp.specAlias = objectSyntaxCopy(specAlias);
89cc05dbdae1 Implementing TemplateAliasParameter and TemplateValueParameter
dkoroskin <>
parents: 0
diff changeset
52 tp.defaultAlias = objectSyntaxCopy(defaultAlias);
89cc05dbdae1 Implementing TemplateAliasParameter and TemplateValueParameter
dkoroskin <>
parents: 0
diff changeset
53 return tp;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56 void declareParameter(Scope sc)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57 {
13
427f8aa74d28 On the road to make Phobos compilable
korDen
parents: 7
diff changeset
58 TypeIdentifier ti = new TypeIdentifier(loc, ident);
427f8aa74d28 On the road to make Phobos compilable
korDen
parents: 7
diff changeset
59 sparam = new AliasDeclaration(loc, ident, ti);
427f8aa74d28 On the road to make Phobos compilable
korDen
parents: 7
diff changeset
60 if (!sc.insert(sparam))
427f8aa74d28 On the road to make Phobos compilable
korDen
parents: 7
diff changeset
61 error(loc, "parameter '%s' multiply defined", ident.toChars());
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63
13
427f8aa74d28 On the road to make Phobos compilable
korDen
parents: 7
diff changeset
64 void semantic(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65 {
13
427f8aa74d28 On the road to make Phobos compilable
korDen
parents: 7
diff changeset
66 if (specType)
427f8aa74d28 On the road to make Phobos compilable
korDen
parents: 7
diff changeset
67 {
427f8aa74d28 On the road to make Phobos compilable
korDen
parents: 7
diff changeset
68 specType = specType.semantic(loc, sc);
427f8aa74d28 On the road to make Phobos compilable
korDen
parents: 7
diff changeset
69 }
427f8aa74d28 On the road to make Phobos compilable
korDen
parents: 7
diff changeset
70 specAlias = aliasParameterSemantic(loc, sc, specAlias);
427f8aa74d28 On the road to make Phobos compilable
korDen
parents: 7
diff changeset
71 static if (false) { // Don't do semantic() until instantiation
427f8aa74d28 On the road to make Phobos compilable
korDen
parents: 7
diff changeset
72 if (defaultAlias)
427f8aa74d28 On the road to make Phobos compilable
korDen
parents: 7
diff changeset
73 defaultAlias = defaultAlias.semantic(loc, sc);
427f8aa74d28 On the road to make Phobos compilable
korDen
parents: 7
diff changeset
74 }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77 void print(Object oarg, Object oded)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82 void toCBuffer(OutBuffer buf, HdrGenState* hgs)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
87 Object specialization()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
91
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
92 Object defaultArg(Loc loc, Scope sc)
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
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97 bool overloadMatch(TemplateParameter)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
101
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
102 MATCH matchArg(Scope sc, Objects tiargs, int i, TemplateParameters parameters, Objects dedtypes, Declaration* psparam, int flags)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
103 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
104 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
105 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
106
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
107 void* dummyArg()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
108 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
109 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
110 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
111 }