| OLD | NEW |
| 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 dart.Object { | 17 class Strength extends dart.Object { |
| 18 Strength(value, name) { | 18 Strength(value, name) { |
| 19 this.value = value; | 19 this.value = value; |
| 20 this.name = name; | 20 this.name = name; |
| 21 } | 21 } |
| 22 nextWeaker() { | 22 nextWeaker() { |
| 23 return /* Unimplemented const */new List.from([STRONG_PREFERRED, PREFERRED
, STRONG_DEFAULT, NORMAL, WEAK_DEFAULT, WEAKEST]).get(this.value); | 23 return /* Unimplemented const */new List.from([STRONG_PREFERRED, PREFERRED
, STRONG_DEFAULT, NORMAL, WEAK_DEFAULT, WEAKEST]).get(this.value); |
| 24 } | 24 } |
| 25 static stronger(s1, s2) { | 25 static stronger(s1, s2) { |
| 26 return s1.value < 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 s1.value > 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 weaker(s1, s2) ? s1 : s2; | 32 return weaker(s1, s2) ? s1 : s2; |
| 33 } | 33 } |
| 34 static strongest(s1, s2) { | 34 static strongest(s1, s2) { |
| 35 return stronger(s1, s2) ? s1 : s2; | 35 return 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"); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 this.myOutput = myOutput; | 83 this.myOutput = myOutput; |
| 84 this.satisfied = false; | 84 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 = dart.notNull(this.myOutput.mark !== mark) && dart.notNull
(Strength.stronger(this.strength, this.myOutput.walkStrength)); | 93 this.satisfied = this.myOutput.mark !== mark && dart.notNull(Strength.stro
nger(this.strength, this.myOutput.walkStrength)); |
| 94 } | 94 } |
| 95 isSatisfied() { | 95 isSatisfied() { |
| 96 return this.satisfied; | 96 return this.satisfied; |
| 97 } | 97 } |
| 98 markInputs(mark) {} | 98 markInputs(mark) {} |
| 99 output() { | 99 output() { |
| 100 return this.myOutput; | 100 return this.myOutput; |
| 101 } | 101 } |
| 102 recalculate() { | 102 recalculate() { |
| 103 this.myOutput.walkStrength = this.strength; | 103 this.myOutput.walkStrength = this.strength; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 this.v1 = v1; |
| 141 this.v2 = v2; | 141 this.v2 = v2; |
| 142 this.direction = NONE; | 142 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 = dart.notNull(this.v2.mark !== mark) && dart.notNull(Str
ength.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 = dart.notNull(this.v1.mark !== mark) && dart.notNull(Str
ength.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 } |
| 153 if (Strength.weaker(this.v1.walkStrength, this.v2.walkStrength)) { | 153 if (Strength.weaker(this.v1.walkStrength, this.v2.walkStrength)) { |
| 154 this.direction = Strength.stronger(this.strength, this.v1.walkStrength)
? BACKWARD : NONE; | 154 this.direction = Strength.stronger(this.strength, this.v1.walkStrength)
? BACKWARD : NONE; |
| 155 } else { | 155 } else { |
| 156 this.direction = Strength.stronger(this.strength, this.v2.walkStrength)
? FORWARD : BACKWARD; | 156 this.direction = Strength.stronger(this.strength, this.v2.walkStrength)
? FORWARD : BACKWARD; |
| 157 } | 157 } |
| 158 } | 158 } |
| 159 addToGraph() { | 159 addToGraph() { |
| 160 this.v1.addConstraint(this); | 160 this.v1.addConstraint(this); |
| 161 this.v2.addConstraint(this); | 161 this.v2.addConstraint(this); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 178 out.walkStrength = Strength.weakest(this.strength, ihn.walkStrength); | 178 out.walkStrength = Strength.weakest(this.strength, ihn.walkStrength); |
| 179 out.stay = ihn.stay; | 179 out.stay = ihn.stay; |
| 180 if (out.stay) | 180 if (out.stay) |
| 181 this.execute(); | 181 this.execute(); |
| 182 } | 182 } |
| 183 markUnsatisfied() { | 183 markUnsatisfied() { |
| 184 this.direction = NONE; | 184 this.direction = NONE; |
| 185 } | 185 } |
| 186 inputsKnown(mark) { | 186 inputsKnown(mark) { |
| 187 let i = this.input(); | 187 let i = this.input(); |
| 188 return dart.notNull(dart.notNull(i.mark === mark) || dart.notNull(i.stay))
|| dart.notNull(i.determinedBy === null); | 188 return i.mark === mark || dart.notNull(i.stay) || dart.notNull(i.determine
dBy === null); |
| 189 } | 189 } |
| 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 { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 212 this.scale.removeConstraint(this); | 212 this.scale.removeConstraint(this); |
| 213 if (this.offset !== null) | 213 if (this.offset !== null) |
| 214 this.offset.removeConstraint(this); | 214 this.offset.removeConstraint(this); |
| 215 } | 215 } |
| 216 markInputs(mark) { | 216 markInputs(mark) { |
| 217 super.markInputs(mark); | 217 super.markInputs(mark); |
| 218 this.scale.mark = this.offset.mark = mark; | 218 this.scale.mark = this.offset.mark = mark; |
| 219 } | 219 } |
| 220 execute() { | 220 execute() { |
| 221 if (this.direction === FORWARD) { | 221 if (this.direction === FORWARD) { |
| 222 this.v2.value = this.v1.value * this.scale.value + this.offset.value; | 222 this.v2.value = dart.notNull(this.v1.value) * dart.notNull(this.scale.va
lue) + dart.notNull(this.offset.value); |
| 223 } else { | 223 } else { |
| 224 this.v1.value = ((this.v2.value - this.offset.value) / this.scale.value)
.truncate(); | 224 this.v1.value = ((dart.notNull(this.v2.value) - dart.notNull(this.offset
.value)) / dart.notNull(this.scale.value)).truncate(); |
| 225 } | 225 } |
| 226 } | 226 } |
| 227 recalculate() { | 227 recalculate() { |
| 228 let ihn = this.input(), out = this.output(); | 228 let ihn = this.input(), out = this.output(); |
| 229 out.walkStrength = Strength.weakest(this.strength, ihn.walkStrength); | 229 out.walkStrength = Strength.weakest(this.strength, ihn.walkStrength); |
| 230 out.stay = dart.notNull(dart.notNull(ihn.stay) && dart.notNull(this.scale.
stay)) && dart.notNull(this.offset.stay); | 230 out.stay = dart.notNull(ihn.stay) && dart.notNull(this.scale.stay) && dart
.notNull(this.offset.stay); |
| 231 if (out.stay) | 231 if (out.stay) |
| 232 this.execute(); | 232 this.execute(); |
| 233 } | 233 } |
| 234 } | 234 } |
| 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; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 268 for (let overridden = c.satisfy(mark); overridden !== null; overridden = o
verridden.satisfy(mark)) | 268 for (let overridden = c.satisfy(mark); overridden !== null; overridden = o
verridden.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(); |
| 275 let unsatisfied = this.removePropagateFrom(out); | 275 let unsatisfied = this.removePropagateFrom(out); |
| 276 let strength = REQUIRED; | 276 let strength = REQUIRED; |
| 277 do { | 277 do { |
| 278 for (let i = 0; i < unsatisfied.length; i++) { | 278 for (let i = 0; dart.notNull(i) < dart.notNull(unsatisfied.length); dart
.notNull(i)++) { |
| 279 let u = unsatisfied.get(i); | 279 let u = unsatisfied.get(i); |
| 280 if (dart.equals(u.strength, strength)) | 280 if (dart.equals(u.strength, strength)) |
| 281 this.incrementalAdd(u); | 281 this.incrementalAdd(u); |
| 282 } | 282 } |
| 283 strength = strength.nextWeaker(); | 283 strength = strength.nextWeaker(); |
| 284 } while (!dart.equals(strength, WEAKEST)); | 284 } while (!dart.equals(strength, WEAKEST)); |
| 285 } | 285 } |
| 286 newMark() { | 286 newMark() { |
| 287 return ++this.currentMark; | 287 return ++dart.notNull(this.currentMark); |
| 288 } | 288 } |
| 289 makePlan(sources) { | 289 makePlan(sources) { |
| 290 let mark = this.newMark(); | 290 let mark = this.newMark(); |
| 291 let plan = new Plan(); | 291 let plan = new Plan(); |
| 292 let todo = sources; | 292 let todo = sources; |
| 293 while (todo.length > 0) { | 293 while (dart.notNull(todo.length) > 0) { |
| 294 let c = todo.removeLast(); | 294 let c = todo.removeLast(); |
| 295 if (dart.notNull(c.output().mark !== mark) && dart.notNull(c.inputsKnown
(mark))) { | 295 if (c.output().mark !== mark && dart.notNull(c.inputsKnown(mark))) { |
| 296 plan.addConstraint(c); | 296 plan.addConstraint(c); |
| 297 c.output().mark = mark; | 297 c.output().mark = mark; |
| 298 this.addConstraintsConsumingTo(c.output(), todo); | 298 this.addConstraintsConsumingTo(c.output(), todo); |
| 299 } | 299 } |
| 300 } | 300 } |
| 301 return plan; | 301 return plan; |
| 302 } | 302 } |
| 303 extractPlanFromConstraints(constraints) { | 303 extractPlanFromConstraints(constraints) { |
| 304 let sources = new List.from([]); | 304 let sources = new List.from([]); |
| 305 for (let i = 0; i < constraints.length; i++) { | 305 for (let i = 0; dart.notNull(i) < dart.notNull(constraints.length); dart.n
otNull(i)++) { |
| 306 let c = constraints.get(i); | 306 let c = constraints.get(i); |
| 307 if (dart.notNull(c.isInput()) && dart.notNull(c.isSatisfied())) | 307 if (dart.notNull(c.isInput()) && dart.notNull(c.isSatisfied())) |
| 308 sources.add(c); | 308 sources.add(c); |
| 309 } | 309 } |
| 310 return this.makePlan(sources); | 310 return this.makePlan(sources); |
| 311 } | 311 } |
| 312 addPropagate(c, mark) { | 312 addPropagate(c, mark) { |
| 313 let todo = new List.from([c]); | 313 let todo = new List.from([c]); |
| 314 while (todo.length > 0) { | 314 while (dart.notNull(todo.length) > 0) { |
| 315 let d = todo.removeLast(); | 315 let d = todo.removeLast(); |
| 316 if (d.output().mark === mark) { | 316 if (d.output().mark === mark) { |
| 317 this.incrementalRemove(c); | 317 this.incrementalRemove(c); |
| 318 return false; | 318 return false; |
| 319 } | 319 } |
| 320 d.recalculate(); | 320 d.recalculate(); |
| 321 this.addConstraintsConsumingTo(d.output(), todo); | 321 this.addConstraintsConsumingTo(d.output(), todo); |
| 322 } | 322 } |
| 323 return true; | 323 return true; |
| 324 } | 324 } |
| 325 removePropagateFrom(out) { | 325 removePropagateFrom(out) { |
| 326 out.determinedBy = null; | 326 out.determinedBy = null; |
| 327 out.walkStrength = WEAKEST; | 327 out.walkStrength = WEAKEST; |
| 328 out.stay = true; | 328 out.stay = true; |
| 329 let unsatisfied = new List.from([]); | 329 let unsatisfied = new List.from([]); |
| 330 let todo = new List.from([out]); | 330 let todo = new List.from([out]); |
| 331 while (todo.length > 0) { | 331 while (dart.notNull(todo.length) > 0) { |
| 332 let v = todo.removeLast(); | 332 let v = todo.removeLast(); |
| 333 for (let i = 0; i < v.constraints.length; i++) { | 333 for (let i = 0; dart.notNull(i) < dart.notNull(v.constraints.length); da
rt.notNull(i)++) { |
| 334 let c = v.constraints.get(i); | 334 let c = v.constraints.get(i); |
| 335 if (!dart.notNull(c.isSatisfied())) | 335 if (!dart.notNull(c.isSatisfied())) |
| 336 unsatisfied.add(c); | 336 unsatisfied.add(c); |
| 337 } | 337 } |
| 338 let determining = v.determinedBy; | 338 let determining = v.determinedBy; |
| 339 for (let i = 0; i < v.constraints.length; i++) { | 339 for (let i = 0; dart.notNull(i) < dart.notNull(v.constraints.length); da
rt.notNull(i)++) { |
| 340 let next = v.constraints.get(i); | 340 let next = v.constraints.get(i); |
| 341 if (dart.notNull(!dart.equals(next, determining)) && dart.notNull(next
.isSatisfied())) { | 341 if (dart.notNull(!dart.equals(next, determining)) && dart.notNull(next
.isSatisfied())) { |
| 342 next.recalculate(); | 342 next.recalculate(); |
| 343 todo.add(next.output()); | 343 todo.add(next.output()); |
| 344 } | 344 } |
| 345 } | 345 } |
| 346 } | 346 } |
| 347 return unsatisfied; | 347 return unsatisfied; |
| 348 } | 348 } |
| 349 addConstraintsConsumingTo(v, coll) { | 349 addConstraintsConsumingTo(v, coll) { |
| 350 let determining = v.determinedBy; | 350 let determining = v.determinedBy; |
| 351 for (let i = 0; i < v.constraints.length; i++) { | 351 for (let i = 0; dart.notNull(i) < dart.notNull(v.constraints.length); dart
.notNull(i)++) { |
| 352 let c = v.constraints.get(i); | 352 let c = v.constraints.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.add(c); | 354 coll.add(c); |
| 355 } | 355 } |
| 356 } | 356 } |
| 357 } | 357 } |
| 358 class Plan extends dart.Object { | 358 class Plan extends dart.Object { |
| 359 Plan() { | 359 Plan() { |
| 360 this.list = new List.from([]); | 360 this.list = new List.from([]); |
| 361 } | 361 } |
| 362 addConstraint(c) { | 362 addConstraint(c) { |
| 363 this.list.add(c); | 363 this.list.add(c); |
| 364 } | 364 } |
| 365 size() { | 365 size() { |
| 366 return this.list.length; | 366 return this.list.length; |
| 367 } | 367 } |
| 368 execute() { | 368 execute() { |
| 369 for (let i = 0; i < this.list.length; i++) { | 369 for (let i = 0; dart.notNull(i) < dart.notNull(this.list.length); dart.not
Null(i)++) { |
| 370 this.list.get(i).execute(); | 370 this.list.get(i).execute(); |
| 371 } | 371 } |
| 372 } | 372 } |
| 373 } | 373 } |
| 374 // Function chainTest: (int) → void | 374 // Function chainTest: (int) → void |
| 375 function chainTest(n) { | 375 function chainTest(n) { |
| 376 exports.planner = new Planner(); | 376 exports.planner = new Planner(); |
| 377 let prev = null, first = null, last = null; | 377 let prev = null, first = null, last = null; |
| 378 for (let i = 0; i <= n; i++) { | 378 for (let i = 0; dart.notNull(i) <= dart.notNull(n); dart.notNull(i)++) { |
| 379 let v = new Variable("v", 0); | 379 let v = new Variable("v", 0); |
| 380 if (prev !== null) | 380 if (prev !== null) |
| 381 new EqualityConstraint(prev, v, REQUIRED); | 381 new EqualityConstraint(prev, v, REQUIRED); |
| 382 if (i === 0) | 382 if (i === 0) |
| 383 first = v; | 383 first = v; |
| 384 if (i === n) | 384 if (i === n) |
| 385 last = v; | 385 last = v; |
| 386 prev = v; | 386 prev = v; |
| 387 } | 387 } |
| 388 new StayConstraint(last, STRONG_DEFAULT); | 388 new StayConstraint(last, STRONG_DEFAULT); |
| 389 let edit = new EditConstraint(first, PREFERRED); | 389 let edit = new EditConstraint(first, PREFERRED); |
| 390 let plan = exports.planner.extractPlanFromConstraints(new List.from([edit]))
; | 390 let plan = exports.planner.extractPlanFromConstraints(new List.from([edit]))
; |
| 391 for (let i = 0; i < 100; i++) { | 391 for (let i = 0; dart.notNull(i) < 100; dart.notNull(i)++) { |
| 392 first.value = i; | 392 first.value = i; |
| 393 plan.execute(); | 393 plan.execute(); |
| 394 if (last.value !== i) { | 394 if (last.value !== i) { |
| 395 core.print("Chain test failed:"); | 395 core.print("Chain test failed:"); |
| 396 core.print(`Expected last value to be ${i} but it was ${last.value}.`); | 396 core.print(`Expected last value to be ${i} but it was ${last.value}.`); |
| 397 } | 397 } |
| 398 } | 398 } |
| 399 } | 399 } |
| 400 // Function projectionTest: (int) → void | 400 // Function projectionTest: (int) → void |
| 401 function projectionTest(n) { | 401 function projectionTest(n) { |
| 402 exports.planner = new Planner(); | 402 exports.planner = new Planner(); |
| 403 let scale = new Variable("scale", 10); | 403 let scale = new Variable("scale", 10); |
| 404 let offset = new Variable("offset", 1000); | 404 let offset = new Variable("offset", 1000); |
| 405 let src = null, dst = null; | 405 let src = null, dst = null; |
| 406 let dests = new List.from([]); | 406 let dests = new List.from([]); |
| 407 for (let i = 0; i < n; i++) { | 407 for (let i = 0; dart.notNull(i) < dart.notNull(n); dart.notNull(i)++) { |
| 408 src = new Variable("src", i); | 408 src = new Variable("src", i); |
| 409 dst = new Variable("dst", i); | 409 dst = new Variable("dst", i); |
| 410 dests.add(dst); | 410 dests.add(dst); |
| 411 new StayConstraint(src, NORMAL); | 411 new StayConstraint(src, NORMAL); |
| 412 new ScaleConstraint(src, scale, offset, dst, REQUIRED); | 412 new ScaleConstraint(src, scale, offset, dst, REQUIRED); |
| 413 } | 413 } |
| 414 change(src, 17); | 414 change(src, 17); |
| 415 if (dst.value !== 1170) | 415 if (dst.value !== 1170) |
| 416 core.print("Projection 1 failed"); | 416 core.print("Projection 1 failed"); |
| 417 change(dst, 1050); | 417 change(dst, 1050); |
| 418 if (src.value !== 5) | 418 if (src.value !== 5) |
| 419 core.print("Projection 2 failed"); | 419 core.print("Projection 2 failed"); |
| 420 change(scale, 5); | 420 change(scale, 5); |
| 421 for (let i = 0; i < n - 1; i++) { | 421 for (let i = 0; dart.notNull(i) < dart.notNull(n) - 1; dart.notNull(i)++) { |
| 422 if (dests.get(i).value !== i * 5 + 1000) | 422 if (dests.get(i).value !== dart.notNull(i) * 5 + 1000) |
| 423 core.print("Projection 3 failed"); | 423 core.print("Projection 3 failed"); |
| 424 } | 424 } |
| 425 change(offset, 2000); | 425 change(offset, 2000); |
| 426 for (let i = 0; i < n - 1; i++) { | 426 for (let i = 0; dart.notNull(i) < dart.notNull(n) - 1; dart.notNull(i)++) { |
| 427 if (dests.get(i).value !== i * 5 + 2000) | 427 if (dests.get(i).value !== dart.notNull(i) * 5 + 2000) |
| 428 core.print("Projection 4 failed"); | 428 core.print("Projection 4 failed"); |
| 429 } | 429 } |
| 430 } | 430 } |
| 431 // Function change: (Variable, int) → void | 431 // Function change: (Variable, int) → void |
| 432 function change(v, newValue) { | 432 function change(v, newValue) { |
| 433 let edit = new EditConstraint(v, PREFERRED); | 433 let edit = new EditConstraint(v, PREFERRED); |
| 434 let plan = exports.planner.extractPlanFromConstraints(new List.from([edit]))
; | 434 let plan = exports.planner.extractPlanFromConstraints(new List.from([edit]))
; |
| 435 for (let i = 0; i < 10; i++) { | 435 for (let i = 0; dart.notNull(i) < 10; dart.notNull(i)++) { |
| 436 v.value = newValue; | 436 v.value = newValue; |
| 437 plan.execute(); | 437 plan.execute(); |
| 438 } | 438 } |
| 439 edit.destroyConstraint(); | 439 edit.destroyConstraint(); |
| 440 } | 440 } |
| 441 exports.planner = null; | 441 exports.planner = null; |
| 442 // Exports: | 442 // Exports: |
| 443 exports.main = main; | 443 exports.main = main; |
| 444 exports.DeltaBlue = DeltaBlue; | 444 exports.DeltaBlue = DeltaBlue; |
| 445 exports.Strength = Strength; | 445 exports.Strength = Strength; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 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 = {})); |
| OLD | NEW |