Mercurial > projects > ddmd
annotate dmd/CompileExp.d @ 192:eb38fdcb3e62 default tip
updated to compile with dmd2.062
author | korDen |
---|---|
date | Sat, 02 Mar 2013 01:25:52 -0800 |
parents | b0d41ff5e0df |
children |
rev | line source |
---|---|
72 | 1 module dmd.CompileExp; |
2 | |
114 | 3 import dmd.common; |
72 | 4 import dmd.Expression; |
5 import dmd.UnaExp; | |
6 import dmd.OutBuffer; | |
7 import dmd.Loc; | |
8 import dmd.Scope; | |
9 import dmd.HdrGenState; | |
10 import dmd.TOK; | |
11 import dmd.PREC; | |
12 import dmd.WANT; | |
13 import dmd.StringExp; | |
14 import dmd.Type; | |
15 import dmd.Parser; | |
16 | |
17 import dmd.expression.Util; | |
18 | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
19 import dmd.DDMDExtensions; |
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
20 |
72 | 21 class CompileExp : UnaExp |
22 { | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
23 mixin insertMemberExtension!(typeof(this)); |
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
24 |
72 | 25 this(Loc loc, Expression e) |
26 { | |
178 | 27 register(); |
72 | 28 super(loc, TOK.TOKmixin, this.sizeof, e); |
29 } | |
30 | |
31 override Expression semantic(Scope sc) | |
32 { | |
33 version (LOGSEMANTIC) { | |
34 printf("CompileExp.semantic('%s')\n", toChars()); | |
35 } | |
36 UnaExp.semantic(sc); | |
37 e1 = resolveProperties(sc, e1); | |
38 e1 = e1.optimize(WANT.WANTvalue | WANT.WANTinterpret); | |
39 if (e1.op != TOK.TOKstring) | |
40 { error("argument to mixin must be a string, not (%s)", e1.toChars()); | |
41 type = Type.terror; | |
42 return this; | |
43 } | |
44 StringExp se = cast(StringExp)e1; | |
45 se = se.toUTF8(sc); | |
46 Parser p = new Parser(sc.module_, cast(ubyte*)se.string_, se.len, 0); | |
47 p.loc = loc; | |
48 p.nextToken(); | |
49 //printf("p.loc.linnum = %d\n", p.loc.linnum); | |
50 Expression e = p.parseExpression(); | |
51 if (p.token.value != TOK.TOKeof) | |
52 error("incomplete mixin expression (%s)", se.toChars()); | |
53 return e.semantic(sc); | |
54 } | |
55 | |
56 override void toCBuffer(OutBuffer buf, HdrGenState* hgs) | |
57 { | |
58 buf.writestring("mixin("); | |
59 expToCBuffer(buf, hgs, e1, PREC.PREC_assign); | |
60 buf.writeByte(')'); | |
61 } | |
62 } |