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

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

Issue 1093143004: 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 class Strength extends core.Object { 17 class Strength extends core.Object {
18 Strength(value, name) { 18 Strength(value, name) {
19 this.value = value; 19 dart.initField(Strength, this, 'value', value);
20 this.name = name; 20 dart.initField(Strength, this, 'name', name);
21 } 21 }
22 nextWeaker() { 22 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); 23 return /* Unimplemented const */new core.List$(Strength).from([STRONG_PREF ERRED, PREFERRED, STRONG_DEFAULT, NORMAL, WEAK_DEFAULT, WEAKEST])[core.$get](thi s.value);
24 } 24 }
25 static stronger(s1, s2) { 25 static stronger(s1, s2) {
26 return dart.notNull(s1.value) < dart.notNull(s2.value); 26 return dart.notNull(s1.value) < dart.notNull(s2.value);
27 } 27 }
28 static weaker(s1, s2) { 28 static weaker(s1, s2) {
29 return dart.notNull(s1.value) > dart.notNull(s2.value); 29 return dart.notNull(s1.value) > dart.notNull(s2.value);
30 } 30 }
31 static weakest(s1, s2) { 31 static weakest(s1, s2) {
32 return Strength.weaker(s1, s2) ? s1 : s2; 32 return Strength.weaker(s1, s2) ? s1 : s2;
33 } 33 }
34 static strongest(s1, s2) { 34 static strongest(s1, s2) {
35 return Strength.stronger(s1, s2) ? s1 : s2; 35 return Strength.stronger(s1, s2) ? s1 : s2;
36 } 36 }
37 } 37 }
38 let REQUIRED = new Strength(0, "required"); 38 let REQUIRED = new Strength(0, "required");
39 let STRONG_PREFERRED = new Strength(1, "strongPreferred"); 39 let STRONG_PREFERRED = new Strength(1, "strongPreferred");
40 let PREFERRED = new Strength(2, "preferred"); 40 let PREFERRED = new Strength(2, "preferred");
41 let STRONG_DEFAULT = new Strength(3, "strongDefault"); 41 let STRONG_DEFAULT = new Strength(3, "strongDefault");
42 let NORMAL = new Strength(4, "normal"); 42 let NORMAL = new Strength(4, "normal");
43 let WEAK_DEFAULT = new Strength(5, "weakDefault"); 43 let WEAK_DEFAULT = new Strength(5, "weakDefault");
44 let WEAKEST = new Strength(6, "weakest"); 44 let WEAKEST = new Strength(6, "weakest");
45 class Constraint extends core.Object { 45 class Constraint extends core.Object {
46 Constraint(strength) { 46 Constraint(strength) {
47 this.strength = strength; 47 dart.initField(Constraint, this, 'strength', strength);
48 } 48 }
49 addConstraint() { 49 addConstraint() {
50 this.addToGraph(); 50 this.addToGraph();
51 exports.planner.incrementalAdd(this); 51 exports.planner.incrementalAdd(this);
52 } 52 }
53 satisfy(mark) { 53 satisfy(mark) {
54 this.chooseMethod(dart.as(mark, core.int)); 54 this.chooseMethod(dart.as(mark, core.int));
55 if (!dart.notNull(this.isSatisfied())) { 55 if (!dart.notNull(this.isSatisfied())) {
56 if (dart.equals(this.strength, REQUIRED)) { 56 if (dart.equals(this.strength, REQUIRED)) {
57 core.print("Could not satisfy a required constraint!"); 57 core.print("Could not satisfy a required constraint!");
(...skipping 15 matching lines...) Expand all
73 if (this.isSatisfied()) 73 if (this.isSatisfied())
74 exports.planner.incrementalRemove(this); 74 exports.planner.incrementalRemove(this);
75 this.removeFromGraph(); 75 this.removeFromGraph();
76 } 76 }
77 isInput() { 77 isInput() {
78 return false; 78 return false;
79 } 79 }
80 } 80 }
81 class UnaryConstraint extends Constraint { 81 class UnaryConstraint extends Constraint {
82 UnaryConstraint(myOutput, strength) { 82 UnaryConstraint(myOutput, strength) {
83 this.myOutput = myOutput; 83 dart.initField(UnaryConstraint, this, 'myOutput', myOutput);
84 this.satisfied = false; 84 dart.initField(UnaryConstraint, this, 'satisfied', false);
85 super.Constraint(strength); 85 super.Constraint(strength);
86 this.addConstraint(); 86 this.addConstraint();
87 } 87 }
88 addToGraph() { 88 addToGraph() {
89 this.myOutput.addConstraint(this); 89 this.myOutput.addConstraint(this);
90 this.satisfied = false; 90 this.satisfied = false;
91 } 91 }
92 chooseMethod(mark) { 92 chooseMethod(mark) {
93 this.satisfied = this.myOutput.mark != mark && dart.notNull(Strength.stron ger(this.strength, this.myOutput.walkStrength)); 93 this.satisfied = this.myOutput.mark != mark && dart.notNull(Strength.stron ger(this.strength, this.myOutput.walkStrength));
94 } 94 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 isInput() { 130 isInput() {
131 return true; 131 return true;
132 } 132 }
133 execute() {} 133 execute() {}
134 } 134 }
135 let NONE = 1; 135 let NONE = 1;
136 let FORWARD = 2; 136 let FORWARD = 2;
137 let BACKWARD = 0; 137 let BACKWARD = 0;
138 class BinaryConstraint extends Constraint { 138 class BinaryConstraint extends Constraint {
139 BinaryConstraint(v1, v2, strength) { 139 BinaryConstraint(v1, v2, strength) {
140 this.v1 = v1; 140 dart.initField(BinaryConstraint, this, 'v1', v1);
141 this.v2 = v2; 141 dart.initField(BinaryConstraint, this, 'v2', v2);
142 this.direction = NONE; 142 dart.initField(BinaryConstraint, this, 'direction', NONE);
143 super.Constraint(strength); 143 super.Constraint(strength);
144 this.addConstraint(); 144 this.addConstraint();
145 } 145 }
146 chooseMethod(mark) { 146 chooseMethod(mark) {
147 if (this.v1.mark == mark) { 147 if (this.v1.mark == mark) {
148 this.direction = this.v2.mark != mark && dart.notNull(Strength.stronger( this.strength, this.v2.walkStrength)) ? FORWARD : NONE; 148 this.direction = this.v2.mark != mark && dart.notNull(Strength.stronger( this.strength, this.v2.walkStrength)) ? FORWARD : NONE;
149 } 149 }
150 if (this.v2.mark == mark) { 150 if (this.v2.mark == mark) {
151 this.direction = this.v1.mark != mark && dart.notNull(Strength.stronger( this.strength, this.v1.walkStrength)) ? BACKWARD : NONE; 151 this.direction = this.v1.mark != mark && dart.notNull(Strength.stronger( this.strength, this.v1.walkStrength)) ? BACKWARD : NONE;
152 } 152 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 removeFromGraph() { 190 removeFromGraph() {
191 if (this.v1 != null) 191 if (this.v1 != null)
192 this.v1.removeConstraint(this); 192 this.v1.removeConstraint(this);
193 if (this.v2 != null) 193 if (this.v2 != null)
194 this.v2.removeConstraint(this); 194 this.v2.removeConstraint(this);
195 this.direction = NONE; 195 this.direction = NONE;
196 } 196 }
197 } 197 }
198 class ScaleConstraint extends BinaryConstraint { 198 class ScaleConstraint extends BinaryConstraint {
199 ScaleConstraint(src, scale, offset, dest, strength) { 199 ScaleConstraint(src, scale, offset, dest, strength) {
200 this.scale = scale; 200 dart.initField(ScaleConstraint, this, 'scale', scale);
201 this.offset = offset; 201 dart.initField(ScaleConstraint, this, 'offset', offset);
202 super.BinaryConstraint(src, dest, strength); 202 super.BinaryConstraint(src, dest, strength);
203 } 203 }
204 addToGraph() { 204 addToGraph() {
205 super.addToGraph(); 205 super.addToGraph();
206 this.scale.addConstraint(this); 206 this.scale.addConstraint(this);
207 this.offset.addConstraint(this); 207 this.offset.addConstraint(this);
208 } 208 }
209 removeFromGraph() { 209 removeFromGraph() {
210 super.removeFromGraph(); 210 super.removeFromGraph();
211 if (this.scale != null) 211 if (this.scale != null)
(...skipping 23 matching lines...) Expand all
235 class EqualityConstraint extends BinaryConstraint { 235 class EqualityConstraint extends BinaryConstraint {
236 EqualityConstraint(v1, v2, strength) { 236 EqualityConstraint(v1, v2, strength) {
237 super.BinaryConstraint(v1, v2, strength); 237 super.BinaryConstraint(v1, v2, strength);
238 } 238 }
239 execute() { 239 execute() {
240 this.output().value = this.input().value; 240 this.output().value = this.input().value;
241 } 241 }
242 } 242 }
243 class Variable extends core.Object { 243 class Variable extends core.Object {
244 Variable(name, value) { 244 Variable(name, value) {
245 this.constraints = new core.List$(Constraint).from([]); 245 dart.initField(Variable, this, 'constraints', new core.List$(Constraint).f rom([]));
246 this.name = name; 246 dart.initField(Variable, this, 'name', name);
247 this.value = value; 247 dart.initField(Variable, this, 'value', value);
248 this.determinedBy = null; 248 dart.initField(Variable, this, 'determinedBy', null);
249 this.mark = 0; 249 dart.initField(Variable, this, 'mark', 0);
250 this.walkStrength = WEAKEST; 250 dart.initField(Variable, this, 'walkStrength', WEAKEST);
251 this.stay = true; 251 dart.initField(Variable, this, 'stay', true);
252 } 252 }
253 addConstraint(c) { 253 addConstraint(c) {
254 this.constraints[core.$add](c); 254 this.constraints[core.$add](c);
255 } 255 }
256 removeConstraint(c) { 256 removeConstraint(c) {
257 this.constraints[core.$remove](c); 257 this.constraints[core.$remove](c);
258 if (dart.equals(this.determinedBy, c)) 258 if (dart.equals(this.determinedBy, c))
259 this.determinedBy = null; 259 this.determinedBy = null;
260 } 260 }
261 } 261 }
262 class Planner extends core.Object { 262 class Planner extends core.Object {
263 Planner() { 263 Planner() {
264 this.currentMark = 0; 264 dart.initField(Planner, this, 'currentMark', 0);
265 } 265 }
266 incrementalAdd(c) { 266 incrementalAdd(c) {
267 let mark = this.newMark(); 267 let mark = this.newMark();
268 for (let overridden = c.satisfy(mark); overridden != null; overridden = ov erridden.satisfy(mark)) 268 for (let overridden = c.satisfy(mark); overridden != null; overridden = ov erridden.satisfy(mark))
269 ; 269 ;
270 } 270 }
271 incrementalRemove(c) { 271 incrementalRemove(c) {
272 let out = c.output(); 272 let out = c.output();
273 c.markUnsatisfied(); 273 c.markUnsatisfied();
274 c.removeFromGraph(); 274 c.removeFromGraph();
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 let determining = v.determinedBy; 350 let determining = v.determinedBy;
351 for (let i = 0; dart.notNull(i) < dart.notNull(v.constraints[core.$length] ); i = dart.notNull(i) + 1) { 351 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); 352 let c = v.constraints[core.$get](i);
353 if (dart.notNull(!dart.equals(c, determining)) && dart.notNull(c.isSatis fied())) 353 if (dart.notNull(!dart.equals(c, determining)) && dart.notNull(c.isSatis fied()))
354 coll[core.$add](c); 354 coll[core.$add](c);
355 } 355 }
356 } 356 }
357 } 357 }
358 class Plan extends core.Object { 358 class Plan extends core.Object {
359 Plan() { 359 Plan() {
360 this.list = new core.List$(Constraint).from([]); 360 dart.initField(Plan, this, 'list', new core.List$(Constraint).from([]));
361 } 361 }
362 addConstraint(c) { 362 addConstraint(c) {
363 this.list[core.$add](c); 363 this.list[core.$add](c);
364 } 364 }
365 size() { 365 size() {
366 return this.list[core.$length]; 366 return this.list[core.$length];
367 } 367 }
368 execute() { 368 execute() {
369 for (let i = 0; dart.notNull(i) < dart.notNull(this.list[core.$length]); i = dart.notNull(i) + 1) { 369 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(); 370 this.list[core.$get](i).execute();
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 exports.BinaryConstraint = BinaryConstraint; 460 exports.BinaryConstraint = BinaryConstraint;
461 exports.ScaleConstraint = ScaleConstraint; 461 exports.ScaleConstraint = ScaleConstraint;
462 exports.EqualityConstraint = EqualityConstraint; 462 exports.EqualityConstraint = EqualityConstraint;
463 exports.Variable = Variable; 463 exports.Variable = Variable;
464 exports.Planner = Planner; 464 exports.Planner = Planner;
465 exports.Plan = Plan; 465 exports.Plan = Plan;
466 exports.chainTest = chainTest; 466 exports.chainTest = chainTest;
467 exports.projectionTest = projectionTest; 467 exports.projectionTest = projectionTest;
468 exports.change = change; 468 exports.change = change;
469 })(DeltaBlue || (DeltaBlue = {})); 469 })(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