annotate dmd/NegExp.d @ 187:b0d41ff5e0df

Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
author Abscissa
date Tue, 07 Jun 2011 23:37:34 -0400
parents e3afd1303184
children
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: 63
diff changeset
1 module dmd.NegExp;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
2
114
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 109
diff changeset
3 import dmd.common;
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
4 import dmd.Expression;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
5 import dmd.Identifier;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
6 import dmd.backend.elem;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
7 import dmd.UnaExp;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
8 import dmd.InterState;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
9 import dmd.OutBuffer;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
10 import dmd.Loc;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
11 import dmd.Scope;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
12 import dmd.IRState;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
13 import dmd.ArrayTypes;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
14 import dmd.TOK;
63
cab4c37afb89 A bunch of implementations
korDen
parents: 0
diff changeset
15 import dmd.Id;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17 import dmd.expression.Neg;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19 import dmd.backend.Util;
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
20 import dmd.backend.OPER;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
21
187
b0d41ff5e0df Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents: 178
diff changeset
22 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
23
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24 class NegExp : UnaExp
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25 {
187
b0d41ff5e0df Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents: 178
diff changeset
26 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
27
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 this(Loc loc, Expression e)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29 {
178
e3afd1303184 Many small bugs fixed
korDen
parents: 130
diff changeset
30 register();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31 super(loc, TOKneg, NegExp.sizeof, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
34 override Expression semantic(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36 Expression e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38 version (LOGSEMANTIC) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 printf("NegExp::semantic('%s')\n", toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41 if (!type)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 UnaExp.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44 e1 = resolveProperties(sc, e1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 e = op_overload(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46 if (e)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49 e1.checkNoBool();
109
ceda59b4d255 expression.c changes, now only ddoc should be left
Trass3r
parents: 72
diff changeset
50 if (!e1.isArrayOperand())
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51 e1.checkArithmetic();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53 type = e1.type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
58 override Expression optimize(int result)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60 Expression e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62 e1 = e1.optimize(result);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63 if (e1.isConst() == 1)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65 e = Neg(type, e1);
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 = this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
69
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
73 override Expression interpret(InterState istate)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
78 override void buildArrayIdent(OutBuffer buf, Expressions arguments)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79 {
123
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
80 e1.buildArrayIdent(buf, arguments);
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
81 buf.writestring("Neg");
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 123
diff changeset
84 override Expression buildArrayLoop(Parameters fparams)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85 {
123
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
86 Expression ex1 = e1.buildArrayLoop(fparams);
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
87 Expression e = new NegExp(Loc(0), ex1);
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
88 return e;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
91 override Identifier opId()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
92 {
63
cab4c37afb89 A bunch of implementations
korDen
parents: 0
diff changeset
93 return Id.neg;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
96 override elem* toElem(IRState* irs)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98 elem *e = el_una(OPneg, type.totym(), e1.toElem(irs));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99 el_setLoc(e,loc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
101 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
102 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
103