Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: test/codegen/expect/DeltaBlue.js

Issue 1090313002: fixes #52, fields shadowing getters/setters or other fields (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/codegen/expect/BenchmarkBase.js ('k') | test/codegen/expect/cascade.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 var DeltaBlue; 1 var DeltaBlue;
2 (function(exports) { 2 (function(exports) {
3 'use strict'; 3 'use strict';
4 // Function main: () → dynamic 4 // Function main: () → dynamic
5 function main() { 5 function main() {
6 new DeltaBlue().report(); 6 new DeltaBlue().report();
7 } 7 }
8 class DeltaBlue extends BenchmarkBase.BenchmarkBase { 8 class DeltaBlue extends BenchmarkBase.BenchmarkBase {
9 DeltaBlue() { 9 DeltaBlue() {
10 super.BenchmarkBase("DeltaBlue"); 10 super.BenchmarkBase("DeltaBlue");
11 } 11 }
12 run() { 12 run() {
13 chainTest(100); 13 chainTest(100);
14 projectionTest(100); 14 projectionTest(100);
15 } 15 }
16 } 16 }
17 let value$ = Symbol('value');
18 let name$ = Symbol('name');
17 class Strength extends core.Object { 19 class Strength extends core.Object {
20 get value() {
21 return this[value$];
22 }
23 get name() {
24 return this[name$];
25 }
18 Strength(value, name) { 26 Strength(value, name) {
19 this.value = value; 27 this[value$] = value;
20 this.name = name; 28 this[name$] = name;
21 } 29 }
22 nextWeaker() { 30 nextWeaker() {
23 return /* Unimplemented const */new core.List$(Strength).from([STRONG_PREF ERRED, PREFERRED, STRONG_DEFAULT, NORMAL, WEAK_DEFAULT, WEAKEST])[core.$get](thi s.value); 31 return /* Unimplemented const */new core.List$(Strength).from([STRONG_PREF ERRED, PREFERRED, STRONG_DEFAULT, NORMAL, WEAK_DEFAULT, WEAKEST])[core.$get](thi s.value);
24 } 32 }
25 static stronger(s1, s2) { 33 static stronger(s1, s2) {
26 return dart.notNull(s1.value) < dart.notNull(s2.value); 34 return dart.notNull(s1.value) < dart.notNull(s2.value);
27 } 35 }
28 static weaker(s1, s2) { 36 static weaker(s1, s2) {
29 return dart.notNull(s1.value) > dart.notNull(s2.value); 37 return dart.notNull(s1.value) > dart.notNull(s2.value);
30 } 38 }
31 static weakest(s1, s2) { 39 static weakest(s1, s2) {
32 return Strength.weaker(s1, s2) ? s1 : s2; 40 return Strength.weaker(s1, s2) ? s1 : s2;
33 } 41 }
34 static strongest(s1, s2) { 42 static strongest(s1, s2) {
35 return Strength.stronger(s1, s2) ? s1 : s2; 43 return Strength.stronger(s1, s2) ? s1 : s2;
36 } 44 }
37 } 45 }
38 let REQUIRED = new Strength(0, "required"); 46 let REQUIRED = new Strength(0, "required");
39 let STRONG_PREFERRED = new Strength(1, "strongPreferred"); 47 let STRONG_PREFERRED = new Strength(1, "strongPreferred");
40 let PREFERRED = new Strength(2, "preferred"); 48 let PREFERRED = new Strength(2, "preferred");
41 let STRONG_DEFAULT = new Strength(3, "strongDefault"); 49 let STRONG_DEFAULT = new Strength(3, "strongDefault");
42 let NORMAL = new Strength(4, "normal"); 50 let NORMAL = new Strength(4, "normal");
43 let WEAK_DEFAULT = new Strength(5, "weakDefault"); 51 let WEAK_DEFAULT = new Strength(5, "weakDefault");
44 let WEAKEST = new Strength(6, "weakest"); 52 let WEAKEST = new Strength(6, "weakest");
53 let strength$ = Symbol('strength');
45 class Constraint extends core.Object { 54 class Constraint extends core.Object {
55 get strength() {
56 return this[strength$];
57 }
46 Constraint(strength) { 58 Constraint(strength) {
47 this.strength = strength; 59 this[strength$] = strength;
48 } 60 }
49 addConstraint() { 61 addConstraint() {
50 this.addToGraph(); 62 this.addToGraph();
51 exports.planner.incrementalAdd(this); 63 exports.planner.incrementalAdd(this);
52 } 64 }
53 satisfy(mark) { 65 satisfy(mark) {
54 this.chooseMethod(dart.as(mark, core.int)); 66 this.chooseMethod(dart.as(mark, core.int));
55 if (!dart.notNull(this.isSatisfied())) { 67 if (!dart.notNull(this.isSatisfied())) {
56 if (dart.equals(this.strength, REQUIRED)) { 68 if (dart.equals(this.strength, REQUIRED)) {
57 core.print("Could not satisfy a required constraint!"); 69 core.print("Could not satisfy a required constraint!");
(...skipping 13 matching lines...) Expand all
71 } 83 }
72 destroyConstraint() { 84 destroyConstraint() {
73 if (this.isSatisfied()) 85 if (this.isSatisfied())
74 exports.planner.incrementalRemove(this); 86 exports.planner.incrementalRemove(this);
75 this.removeFromGraph(); 87 this.removeFromGraph();
76 } 88 }
77 isInput() { 89 isInput() {
78 return false; 90 return false;
79 } 91 }
80 } 92 }
93 let myOutput$ = Symbol('myOutput');
94 let satisfied = Symbol('satisfied');
81 class UnaryConstraint extends Constraint { 95 class UnaryConstraint extends Constraint {
96 get myOutput() {
97 return this[myOutput$];
98 }
99 get satisfied() {
100 return this[satisfied];
101 }
102 set satisfied(value) {
103 this[satisfied] = value;
104 }
82 UnaryConstraint(myOutput, strength) { 105 UnaryConstraint(myOutput, strength) {
83 this.myOutput = myOutput; 106 this[myOutput$] = myOutput;
84 this.satisfied = false; 107 this[satisfied] = false;
85 super.Constraint(strength); 108 super.Constraint(strength);
86 this.addConstraint(); 109 this.addConstraint();
87 } 110 }
88 addToGraph() { 111 addToGraph() {
89 this.myOutput.addConstraint(this); 112 this.myOutput.addConstraint(this);
90 this.satisfied = false; 113 this.satisfied = false;
91 } 114 }
92 chooseMethod(mark) { 115 chooseMethod(mark) {
93 this.satisfied = this.myOutput.mark != mark && dart.notNull(Strength.stron ger(this.strength, this.myOutput.walkStrength)); 116 this.satisfied = this.myOutput.mark != mark && dart.notNull(Strength.stron ger(this.strength, this.myOutput.walkStrength));
94 } 117 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 super.UnaryConstraint(v, str); 151 super.UnaryConstraint(v, str);
129 } 152 }
130 isInput() { 153 isInput() {
131 return true; 154 return true;
132 } 155 }
133 execute() {} 156 execute() {}
134 } 157 }
135 let NONE = 1; 158 let NONE = 1;
136 let FORWARD = 2; 159 let FORWARD = 2;
137 let BACKWARD = 0; 160 let BACKWARD = 0;
161 let v1$ = Symbol('v1');
162 let v2$ = Symbol('v2');
163 let direction = Symbol('direction');
138 class BinaryConstraint extends Constraint { 164 class BinaryConstraint extends Constraint {
165 get v1() {
166 return this[v1$];
167 }
168 set v1(value) {
169 this[v1$] = value;
170 }
171 get v2() {
172 return this[v2$];
173 }
174 set v2(value) {
175 this[v2$] = value;
176 }
177 get direction() {
178 return this[direction];
179 }
180 set direction(value) {
181 this[direction] = value;
182 }
139 BinaryConstraint(v1, v2, strength) { 183 BinaryConstraint(v1, v2, strength) {
140 this.v1 = v1; 184 this[v1$] = v1;
141 this.v2 = v2; 185 this[v2$] = v2;
142 this.direction = NONE; 186 this[direction] = NONE;
143 super.Constraint(strength); 187 super.Constraint(strength);
144 this.addConstraint(); 188 this.addConstraint();
145 } 189 }
146 chooseMethod(mark) { 190 chooseMethod(mark) {
147 if (this.v1.mark == mark) { 191 if (this.v1.mark == mark) {
148 this.direction = this.v2.mark != mark && dart.notNull(Strength.stronger( this.strength, this.v2.walkStrength)) ? FORWARD : NONE; 192 this.direction = this.v2.mark != mark && dart.notNull(Strength.stronger( this.strength, this.v2.walkStrength)) ? FORWARD : NONE;
149 } 193 }
150 if (this.v2.mark == mark) { 194 if (this.v2.mark == mark) {
151 this.direction = this.v1.mark != mark && dart.notNull(Strength.stronger( this.strength, this.v1.walkStrength)) ? BACKWARD : NONE; 195 this.direction = this.v1.mark != mark && dart.notNull(Strength.stronger( this.strength, this.v1.walkStrength)) ? BACKWARD : NONE;
152 } 196 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 return i.mark == mark || dart.notNull(i.stay) || dart.notNull(i.determined By == null); 232 return i.mark == mark || dart.notNull(i.stay) || dart.notNull(i.determined By == null);
189 } 233 }
190 removeFromGraph() { 234 removeFromGraph() {
191 if (this.v1 != null) 235 if (this.v1 != null)
192 this.v1.removeConstraint(this); 236 this.v1.removeConstraint(this);
193 if (this.v2 != null) 237 if (this.v2 != null)
194 this.v2.removeConstraint(this); 238 this.v2.removeConstraint(this);
195 this.direction = NONE; 239 this.direction = NONE;
196 } 240 }
197 } 241 }
242 let scale$ = Symbol('scale');
243 let offset$ = Symbol('offset');
198 class ScaleConstraint extends BinaryConstraint { 244 class ScaleConstraint extends BinaryConstraint {
245 get scale() {
246 return this[scale$];
247 }
248 get offset() {
249 return this[offset$];
250 }
199 ScaleConstraint(src, scale, offset, dest, strength) { 251 ScaleConstraint(src, scale, offset, dest, strength) {
200 this.scale = scale; 252 this[scale$] = scale;
201 this.offset = offset; 253 this[offset$] = offset;
202 super.BinaryConstraint(src, dest, strength); 254 super.BinaryConstraint(src, dest, strength);
203 } 255 }
204 addToGraph() { 256 addToGraph() {
205 super.addToGraph(); 257 super.addToGraph();
206 this.scale.addConstraint(this); 258 this.scale.addConstraint(this);
207 this.offset.addConstraint(this); 259 this.offset.addConstraint(this);
208 } 260 }
209 removeFromGraph() { 261 removeFromGraph() {
210 super.removeFromGraph(); 262 super.removeFromGraph();
211 if (this.scale != null) 263 if (this.scale != null)
(...skipping 21 matching lines...) Expand all
233 } 285 }
234 } 286 }
235 class EqualityConstraint extends BinaryConstraint { 287 class EqualityConstraint extends BinaryConstraint {
236 EqualityConstraint(v1, v2, strength) { 288 EqualityConstraint(v1, v2, strength) {
237 super.BinaryConstraint(v1, v2, strength); 289 super.BinaryConstraint(v1, v2, strength);
238 } 290 }
239 execute() { 291 execute() {
240 this.output().value = this.input().value; 292 this.output().value = this.input().value;
241 } 293 }
242 } 294 }
295 let constraints = Symbol('constraints');
296 let determinedBy = Symbol('determinedBy');
297 let mark = Symbol('mark');
298 let walkStrength = Symbol('walkStrength');
299 let stay = Symbol('stay');
300 let value$0 = Symbol('value');
301 let name$0 = Symbol('name');
243 class Variable extends core.Object { 302 class Variable extends core.Object {
303 get constraints() {
304 return this[constraints];
305 }
306 set constraints(value) {
307 this[constraints] = value;
308 }
309 get determinedBy() {
310 return this[determinedBy];
311 }
312 set determinedBy(value) {
313 this[determinedBy] = value;
314 }
315 get mark() {
316 return this[mark];
317 }
318 set mark(value) {
319 this[mark] = value;
320 }
321 get walkStrength() {
322 return this[walkStrength];
323 }
324 set walkStrength(value) {
325 this[walkStrength] = value;
326 }
327 get stay() {
328 return this[stay];
329 }
330 set stay(value) {
331 this[stay] = value;
332 }
333 get value() {
334 return this[value$0];
335 }
336 set value(value) {
337 this[value$0] = value;
338 }
339 get name() {
340 return this[name$0];
341 }
244 Variable(name, value) { 342 Variable(name, value) {
245 this.constraints = new core.List$(Constraint).from([]); 343 this[constraints] = new core.List$(Constraint).from([]);
246 this.name = name; 344 this[name$0] = name;
247 this.value = value; 345 this[value$0] = value;
248 this.determinedBy = null; 346 this[determinedBy] = null;
249 this.mark = 0; 347 this[mark] = 0;
250 this.walkStrength = WEAKEST; 348 this[walkStrength] = WEAKEST;
251 this.stay = true; 349 this[stay] = true;
252 } 350 }
253 addConstraint(c) { 351 addConstraint(c) {
254 this.constraints[core.$add](c); 352 this.constraints[core.$add](c);
255 } 353 }
256 removeConstraint(c) { 354 removeConstraint(c) {
257 this.constraints[core.$remove](c); 355 this.constraints[core.$remove](c);
258 if (dart.equals(this.determinedBy, c)) 356 if (dart.equals(this.determinedBy, c))
259 this.determinedBy = null; 357 this.determinedBy = null;
260 } 358 }
261 } 359 }
360 let currentMark = Symbol('currentMark');
262 class Planner extends core.Object { 361 class Planner extends core.Object {
263 Planner() { 362 Planner() {
264 this.currentMark = 0; 363 this[currentMark] = 0;
364 }
365 get currentMark() {
366 return this[currentMark];
367 }
368 set currentMark(value) {
369 this[currentMark] = value;
265 } 370 }
266 incrementalAdd(c) { 371 incrementalAdd(c) {
267 let mark = this.newMark(); 372 let mark = this.newMark();
268 for (let overridden = c.satisfy(mark); overridden != null; overridden = ov erridden.satisfy(mark)) 373 for (let overridden = c.satisfy(mark); overridden != null; overridden = ov erridden.satisfy(mark))
269 ; 374 ;
270 } 375 }
271 incrementalRemove(c) { 376 incrementalRemove(c) {
272 let out = c.output(); 377 let out = c.output();
273 c.markUnsatisfied(); 378 c.markUnsatisfied();
274 c.removeFromGraph(); 379 c.removeFromGraph();
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 } 453 }
349 addConstraintsConsumingTo(v, coll) { 454 addConstraintsConsumingTo(v, coll) {
350 let determining = v.determinedBy; 455 let determining = v.determinedBy;
351 for (let i = 0; dart.notNull(i) < dart.notNull(v.constraints[core.$length] ); i = dart.notNull(i) + 1) { 456 for (let i = 0; dart.notNull(i) < dart.notNull(v.constraints[core.$length] ); i = dart.notNull(i) + 1) {
352 let c = v.constraints[core.$get](i); 457 let c = v.constraints[core.$get](i);
353 if (dart.notNull(!dart.equals(c, determining)) && dart.notNull(c.isSatis fied())) 458 if (dart.notNull(!dart.equals(c, determining)) && dart.notNull(c.isSatis fied()))
354 coll[core.$add](c); 459 coll[core.$add](c);
355 } 460 }
356 } 461 }
357 } 462 }
463 let list = Symbol('list');
358 class Plan extends core.Object { 464 class Plan extends core.Object {
359 Plan() { 465 Plan() {
360 this.list = new core.List$(Constraint).from([]); 466 this[list] = new core.List$(Constraint).from([]);
467 }
468 get list() {
469 return this[list];
470 }
471 set list(value) {
472 this[list] = value;
361 } 473 }
362 addConstraint(c) { 474 addConstraint(c) {
363 this.list[core.$add](c); 475 this.list[core.$add](c);
364 } 476 }
365 size() { 477 size() {
366 return this.list[core.$length]; 478 return this.list[core.$length];
367 } 479 }
368 execute() { 480 execute() {
369 for (let i = 0; dart.notNull(i) < dart.notNull(this.list[core.$length]); i = dart.notNull(i) + 1) { 481 for (let i = 0; dart.notNull(i) < dart.notNull(this.list[core.$length]); i = dart.notNull(i) + 1) {
370 this.list[core.$get](i).execute(); 482 this.list[core.$get](i).execute();
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 exports.BinaryConstraint = BinaryConstraint; 572 exports.BinaryConstraint = BinaryConstraint;
461 exports.ScaleConstraint = ScaleConstraint; 573 exports.ScaleConstraint = ScaleConstraint;
462 exports.EqualityConstraint = EqualityConstraint; 574 exports.EqualityConstraint = EqualityConstraint;
463 exports.Variable = Variable; 575 exports.Variable = Variable;
464 exports.Planner = Planner; 576 exports.Planner = Planner;
465 exports.Plan = Plan; 577 exports.Plan = Plan;
466 exports.chainTest = chainTest; 578 exports.chainTest = chainTest;
467 exports.projectionTest = projectionTest; 579 exports.projectionTest = projectionTest;
468 exports.change = change; 580 exports.change = change;
469 })(DeltaBlue || (DeltaBlue = {})); 581 })(DeltaBlue || (DeltaBlue = {}));
OLDNEW
« no previous file with comments | « test/codegen/expect/BenchmarkBase.js ('k') | test/codegen/expect/cascade.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698