annotate dmd/NegExp.d @ 178:e3afd1303184

Many small bugs fixed Made all classes derive from TObject to detect memory leaks (functionality is disabled for now) Began work on overriding backend memory allocations (to avoid memory leaks)
author korDen
date Sun, 17 Oct 2010 07:42:00 +0400
parents 60bb0fe4563e
children b0d41ff5e0df
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
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22 class NegExp : UnaExp
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
23 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24 this(Loc loc, Expression e)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25 {
178
e3afd1303184 Many small bugs fixed
korDen
parents: 130
diff changeset
26 register();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27 super(loc, TOKneg, NegExp.sizeof, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
30 override Expression semantic(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32 Expression e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34 version (LOGSEMANTIC) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 printf("NegExp::semantic('%s')\n", toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37 if (!type)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 UnaExp.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 e1 = resolveProperties(sc, e1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41 e = op_overload(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 if (e)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 e1.checkNoBool();
109
ceda59b4d255 expression.c changes, now only ddoc should be left
Trass3r
parents: 72
diff changeset
46 if (!e1.isArrayOperand())
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 e1.checkArithmetic();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49 type = e1.type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
54 override Expression optimize(int result)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56 Expression e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
58 e1 = e1.optimize(result);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 if (e1.isConst() == 1)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61 e = Neg(type, e1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64 e = this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
67 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
68
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
69 override Expression interpret(InterState istate)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
74 override void buildArrayIdent(OutBuffer buf, Expressions arguments)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75 {
123
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
76 e1.buildArrayIdent(buf, arguments);
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
77 buf.writestring("Neg");
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 123
diff changeset
80 override Expression buildArrayLoop(Parameters fparams)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81 {
123
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
82 Expression ex1 = e1.buildArrayLoop(fparams);
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
83 Expression e = new NegExp(Loc(0), ex1);
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
84 return e;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 63
diff changeset
87 override Identifier opId()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88 {
63
cab4c37afb89 A bunch of implementations
korDen
parents: 0
diff changeset
89 return Id.neg;
0
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: 63
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 elem *e = el_una(OPneg, type.totym(), e1.toElem(irs));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95 el_setLoc(e,loc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99