| OLD | NEW |
| 1 var DeltaBlue = dart.defineLibrary(DeltaBlue, {}); | 1 var DeltaBlue = dart.defineLibrary(DeltaBlue, {}); |
| 2 var BenchmarkBase = dart.import(BenchmarkBase); | 2 var BenchmarkBase = dart.import(BenchmarkBase); |
| 3 var core = dart.import(core); | 3 var core = dart.import(core); |
| 4 (function(exports, BenchmarkBase, core) { | 4 (function(exports, BenchmarkBase, core) { |
| 5 'use strict'; | 5 'use strict'; |
| 6 function main() { | 6 function main() { |
| 7 new DeltaBlue().report(); | 7 new DeltaBlue().report(); |
| 8 } | 8 } |
| 9 dart.fn(main); | 9 dart.fn(main); |
| 10 class DeltaBlue extends BenchmarkBase.BenchmarkBase { | 10 class DeltaBlue extends BenchmarkBase.BenchmarkBase { |
| 11 DeltaBlue() { | 11 DeltaBlue() { |
| 12 super.BenchmarkBase("DeltaBlue"); | 12 super.BenchmarkBase("DeltaBlue"); |
| 13 } | 13 } |
| 14 run() { | 14 run() { |
| 15 chainTest(100); | 15 chainTest(100); |
| 16 projectionTest(100); | 16 projectionTest(100); |
| 17 } | 17 } |
| 18 } | 18 } |
| 19 dart.setSignature(DeltaBlue, { |
| 20 constructors: () => ({DeltaBlue: [DeltaBlue, []]}) |
| 21 }); |
| 19 class Strength extends core.Object { | 22 class Strength extends core.Object { |
| 20 Strength(value, name) { | 23 Strength(value, name) { |
| 21 this.value = value; | 24 this.value = value; |
| 22 this.name = name; | 25 this.name = name; |
| 23 } | 26 } |
| 24 nextWeaker() { | 27 nextWeaker() { |
| 25 return dart.const(dart.setType([STRONG_PREFERRED, PREFERRED, STRONG_DEFAUL
T, NORMAL, WEAK_DEFAULT, WEAKEST], core.List$(Strength)))[core.$get](this.value)
; | 28 return dart.const(dart.setType([STRONG_PREFERRED, PREFERRED, STRONG_DEFAUL
T, NORMAL, WEAK_DEFAULT, WEAKEST], core.List$(Strength)))[core.$get](this.value)
; |
| 26 } | 29 } |
| 27 static stronger(s1, s2) { | 30 static stronger(s1, s2) { |
| 28 return dart.notNull(s1.value) < dart.notNull(s2.value); | 31 return dart.notNull(s1.value) < dart.notNull(s2.value); |
| 29 } | 32 } |
| 30 static weaker(s1, s2) { | 33 static weaker(s1, s2) { |
| 31 return dart.notNull(s1.value) > dart.notNull(s2.value); | 34 return dart.notNull(s1.value) > dart.notNull(s2.value); |
| 32 } | 35 } |
| 33 static weakest(s1, s2) { | 36 static weakest(s1, s2) { |
| 34 return Strength.weaker(s1, s2) ? s1 : s2; | 37 return Strength.weaker(s1, s2) ? s1 : s2; |
| 35 } | 38 } |
| 36 static strongest(s1, s2) { | 39 static strongest(s1, s2) { |
| 37 return Strength.stronger(s1, s2) ? s1 : s2; | 40 return Strength.stronger(s1, s2) ? s1 : s2; |
| 38 } | 41 } |
| 39 } | 42 } |
| 40 dart.setSignature(Strength, { | 43 dart.setSignature(Strength, { |
| 44 constructors: () => ({Strength: [Strength, [core.int, core.String]]}), |
| 41 methods: () => ({nextWeaker: [Strength, []]}), | 45 methods: () => ({nextWeaker: [Strength, []]}), |
| 42 statics: () => ({ | 46 statics: () => ({ |
| 43 stronger: [core.bool, [Strength, Strength]], | 47 stronger: [core.bool, [Strength, Strength]], |
| 44 weaker: [core.bool, [Strength, Strength]], | 48 weaker: [core.bool, [Strength, Strength]], |
| 45 weakest: [Strength, [Strength, Strength]], | 49 weakest: [Strength, [Strength, Strength]], |
| 46 strongest: [Strength, [Strength, Strength]] | 50 strongest: [Strength, [Strength, Strength]] |
| 47 }), | 51 }), |
| 48 names: ['stronger', 'weaker', 'weakest', 'strongest'] | 52 names: ['stronger', 'weaker', 'weakest', 'strongest'] |
| 49 }); | 53 }); |
| 50 let REQUIRED = dart.const(new Strength(0, "required")); | 54 let REQUIRED = dart.const(new Strength(0, "required")); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 destroyConstraint() { | 88 destroyConstraint() { |
| 85 if (this.isSatisfied()) | 89 if (this.isSatisfied()) |
| 86 exports.planner.incrementalRemove(this); | 90 exports.planner.incrementalRemove(this); |
| 87 this.removeFromGraph(); | 91 this.removeFromGraph(); |
| 88 } | 92 } |
| 89 isInput() { | 93 isInput() { |
| 90 return false; | 94 return false; |
| 91 } | 95 } |
| 92 } | 96 } |
| 93 dart.setSignature(Constraint, { | 97 dart.setSignature(Constraint, { |
| 98 constructors: () => ({Constraint: [Constraint, [Strength]]}), |
| 94 methods: () => ({ | 99 methods: () => ({ |
| 95 addConstraint: [dart.void, []], | 100 addConstraint: [dart.void, []], |
| 96 satisfy: [Constraint, [core.Object]], | 101 satisfy: [Constraint, [core.Object]], |
| 97 destroyConstraint: [dart.void, []], | 102 destroyConstraint: [dart.void, []], |
| 98 isInput: [core.bool, []] | 103 isInput: [core.bool, []] |
| 99 }) | 104 }) |
| 100 }); | 105 }); |
| 101 class UnaryConstraint extends Constraint { | 106 class UnaryConstraint extends Constraint { |
| 102 UnaryConstraint(myOutput, strength) { | 107 UnaryConstraint(myOutput, strength) { |
| 103 this.myOutput = myOutput; | 108 this.myOutput = myOutput; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 131 inputsKnown(mark) { | 136 inputsKnown(mark) { |
| 132 return true; | 137 return true; |
| 133 } | 138 } |
| 134 removeFromGraph() { | 139 removeFromGraph() { |
| 135 if (this.myOutput != null) | 140 if (this.myOutput != null) |
| 136 this.myOutput.removeConstraint(this); | 141 this.myOutput.removeConstraint(this); |
| 137 this.satisfied = false; | 142 this.satisfied = false; |
| 138 } | 143 } |
| 139 } | 144 } |
| 140 dart.setSignature(UnaryConstraint, { | 145 dart.setSignature(UnaryConstraint, { |
| 146 constructors: () => ({UnaryConstraint: [UnaryConstraint, [Variable, Strength
]]}), |
| 141 methods: () => ({ | 147 methods: () => ({ |
| 142 addToGraph: [dart.void, []], | 148 addToGraph: [dart.void, []], |
| 143 chooseMethod: [dart.void, [core.int]], | 149 chooseMethod: [dart.void, [core.int]], |
| 144 isSatisfied: [core.bool, []], | 150 isSatisfied: [core.bool, []], |
| 145 markInputs: [dart.void, [core.int]], | 151 markInputs: [dart.void, [core.int]], |
| 146 output: [Variable, []], | 152 output: [Variable, []], |
| 147 recalculate: [dart.void, []], | 153 recalculate: [dart.void, []], |
| 148 markUnsatisfied: [dart.void, []], | 154 markUnsatisfied: [dart.void, []], |
| 149 inputsKnown: [core.bool, [core.int]], | 155 inputsKnown: [core.bool, [core.int]], |
| 150 removeFromGraph: [dart.void, []] | 156 removeFromGraph: [dart.void, []] |
| 151 }) | 157 }) |
| 152 }); | 158 }); |
| 153 class StayConstraint extends UnaryConstraint { | 159 class StayConstraint extends UnaryConstraint { |
| 154 StayConstraint(v, str) { | 160 StayConstraint(v, str) { |
| 155 super.UnaryConstraint(v, str); | 161 super.UnaryConstraint(v, str); |
| 156 } | 162 } |
| 157 execute() {} | 163 execute() {} |
| 158 } | 164 } |
| 159 dart.setSignature(StayConstraint, { | 165 dart.setSignature(StayConstraint, { |
| 166 constructors: () => ({StayConstraint: [StayConstraint, [Variable, Strength]]
}), |
| 160 methods: () => ({execute: [dart.void, []]}) | 167 methods: () => ({execute: [dart.void, []]}) |
| 161 }); | 168 }); |
| 162 class EditConstraint extends UnaryConstraint { | 169 class EditConstraint extends UnaryConstraint { |
| 163 EditConstraint(v, str) { | 170 EditConstraint(v, str) { |
| 164 super.UnaryConstraint(v, str); | 171 super.UnaryConstraint(v, str); |
| 165 } | 172 } |
| 166 isInput() { | 173 isInput() { |
| 167 return true; | 174 return true; |
| 168 } | 175 } |
| 169 execute() {} | 176 execute() {} |
| 170 } | 177 } |
| 171 dart.setSignature(EditConstraint, { | 178 dart.setSignature(EditConstraint, { |
| 179 constructors: () => ({EditConstraint: [EditConstraint, [Variable, Strength]]
}), |
| 172 methods: () => ({execute: [dart.void, []]}) | 180 methods: () => ({execute: [dart.void, []]}) |
| 173 }); | 181 }); |
| 174 let NONE = 1; | 182 let NONE = 1; |
| 175 let FORWARD = 2; | 183 let FORWARD = 2; |
| 176 let BACKWARD = 0; | 184 let BACKWARD = 0; |
| 177 class BinaryConstraint extends Constraint { | 185 class BinaryConstraint extends Constraint { |
| 178 BinaryConstraint(v1, v2, strength) { | 186 BinaryConstraint(v1, v2, strength) { |
| 179 this.v1 = v1; | 187 this.v1 = v1; |
| 180 this.v2 = v2; | 188 this.v2 = v2; |
| 181 this.direction = NONE; | 189 this.direction = NONE; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 } | 236 } |
| 229 removeFromGraph() { | 237 removeFromGraph() { |
| 230 if (this.v1 != null) | 238 if (this.v1 != null) |
| 231 this.v1.removeConstraint(this); | 239 this.v1.removeConstraint(this); |
| 232 if (this.v2 != null) | 240 if (this.v2 != null) |
| 233 this.v2.removeConstraint(this); | 241 this.v2.removeConstraint(this); |
| 234 this.direction = NONE; | 242 this.direction = NONE; |
| 235 } | 243 } |
| 236 } | 244 } |
| 237 dart.setSignature(BinaryConstraint, { | 245 dart.setSignature(BinaryConstraint, { |
| 246 constructors: () => ({BinaryConstraint: [BinaryConstraint, [Variable, Variab
le, Strength]]}), |
| 238 methods: () => ({ | 247 methods: () => ({ |
| 239 chooseMethod: [dart.void, [core.int]], | 248 chooseMethod: [dart.void, [core.int]], |
| 240 addToGraph: [dart.void, []], | 249 addToGraph: [dart.void, []], |
| 241 isSatisfied: [core.bool, []], | 250 isSatisfied: [core.bool, []], |
| 242 markInputs: [dart.void, [core.int]], | 251 markInputs: [dart.void, [core.int]], |
| 243 input: [Variable, []], | 252 input: [Variable, []], |
| 244 output: [Variable, []], | 253 output: [Variable, []], |
| 245 recalculate: [dart.void, []], | 254 recalculate: [dart.void, []], |
| 246 markUnsatisfied: [dart.void, []], | 255 markUnsatisfied: [dart.void, []], |
| 247 inputsKnown: [core.bool, [core.int]], | 256 inputsKnown: [core.bool, [core.int]], |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 } | 288 } |
| 280 recalculate() { | 289 recalculate() { |
| 281 let ihn = this.input(), out = this.output(); | 290 let ihn = this.input(), out = this.output(); |
| 282 out.walkStrength = Strength.weakest(this.strength, ihn.walkStrength); | 291 out.walkStrength = Strength.weakest(this.strength, ihn.walkStrength); |
| 283 out.stay = dart.notNull(ihn.stay) && dart.notNull(this.scale.stay) && dart
.notNull(this.offset.stay); | 292 out.stay = dart.notNull(ihn.stay) && dart.notNull(this.scale.stay) && dart
.notNull(this.offset.stay); |
| 284 if (out.stay) | 293 if (out.stay) |
| 285 this.execute(); | 294 this.execute(); |
| 286 } | 295 } |
| 287 } | 296 } |
| 288 dart.setSignature(ScaleConstraint, { | 297 dart.setSignature(ScaleConstraint, { |
| 298 constructors: () => ({ScaleConstraint: [ScaleConstraint, [Variable, Variable
, Variable, Variable, Strength]]}), |
| 289 methods: () => ({execute: [dart.void, []]}) | 299 methods: () => ({execute: [dart.void, []]}) |
| 290 }); | 300 }); |
| 291 class EqualityConstraint extends BinaryConstraint { | 301 class EqualityConstraint extends BinaryConstraint { |
| 292 EqualityConstraint(v1, v2, strength) { | 302 EqualityConstraint(v1, v2, strength) { |
| 293 super.BinaryConstraint(v1, v2, strength); | 303 super.BinaryConstraint(v1, v2, strength); |
| 294 } | 304 } |
| 295 execute() { | 305 execute() { |
| 296 this.output().value = this.input().value; | 306 this.output().value = this.input().value; |
| 297 } | 307 } |
| 298 } | 308 } |
| 299 dart.setSignature(EqualityConstraint, { | 309 dart.setSignature(EqualityConstraint, { |
| 310 constructors: () => ({EqualityConstraint: [EqualityConstraint, [Variable, Va
riable, Strength]]}), |
| 300 methods: () => ({execute: [dart.void, []]}) | 311 methods: () => ({execute: [dart.void, []]}) |
| 301 }); | 312 }); |
| 302 class Variable extends core.Object { | 313 class Variable extends core.Object { |
| 303 Variable(name, value) { | 314 Variable(name, value) { |
| 304 this.constraints = dart.setType([], core.List$(Constraint)); | 315 this.constraints = dart.setType([], core.List$(Constraint)); |
| 305 this.name = name; | 316 this.name = name; |
| 306 this.value = value; | 317 this.value = value; |
| 307 this.determinedBy = null; | 318 this.determinedBy = null; |
| 308 this.mark = 0; | 319 this.mark = 0; |
| 309 this.walkStrength = WEAKEST; | 320 this.walkStrength = WEAKEST; |
| 310 this.stay = true; | 321 this.stay = true; |
| 311 } | 322 } |
| 312 addConstraint(c) { | 323 addConstraint(c) { |
| 313 this.constraints[core.$add](c); | 324 this.constraints[core.$add](c); |
| 314 } | 325 } |
| 315 removeConstraint(c) { | 326 removeConstraint(c) { |
| 316 this.constraints[core.$remove](c); | 327 this.constraints[core.$remove](c); |
| 317 if (dart.equals(this.determinedBy, c)) | 328 if (dart.equals(this.determinedBy, c)) |
| 318 this.determinedBy = null; | 329 this.determinedBy = null; |
| 319 } | 330 } |
| 320 } | 331 } |
| 321 dart.setSignature(Variable, { | 332 dart.setSignature(Variable, { |
| 333 constructors: () => ({Variable: [Variable, [core.String, core.int]]}), |
| 322 methods: () => ({ | 334 methods: () => ({ |
| 323 addConstraint: [dart.void, [Constraint]], | 335 addConstraint: [dart.void, [Constraint]], |
| 324 removeConstraint: [dart.void, [Constraint]] | 336 removeConstraint: [dart.void, [Constraint]] |
| 325 }) | 337 }) |
| 326 }); | 338 }); |
| 327 class Planner extends core.Object { | 339 class Planner extends core.Object { |
| 328 Planner() { | 340 Planner() { |
| 329 this.currentMark = 0; | 341 this.currentMark = 0; |
| 330 } | 342 } |
| 331 incrementalAdd(c) { | 343 incrementalAdd(c) { |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 exports.BinaryConstraint = BinaryConstraint; | 556 exports.BinaryConstraint = BinaryConstraint; |
| 545 exports.ScaleConstraint = ScaleConstraint; | 557 exports.ScaleConstraint = ScaleConstraint; |
| 546 exports.EqualityConstraint = EqualityConstraint; | 558 exports.EqualityConstraint = EqualityConstraint; |
| 547 exports.Variable = Variable; | 559 exports.Variable = Variable; |
| 548 exports.Planner = Planner; | 560 exports.Planner = Planner; |
| 549 exports.Plan = Plan; | 561 exports.Plan = Plan; |
| 550 exports.chainTest = chainTest; | 562 exports.chainTest = chainTest; |
| 551 exports.projectionTest = projectionTest; | 563 exports.projectionTest = projectionTest; |
| 552 exports.change = change; | 564 exports.change = change; |
| 553 })(DeltaBlue, BenchmarkBase, core); | 565 })(DeltaBlue, BenchmarkBase, core); |
| OLD | NEW |