| 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"); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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!"); |
| 58 } | 58 } |
| 59 return null; | 59 return null; |
| 60 } | 60 } |
| 61 this.markInputs(dart.as(mark, core.int)); | 61 this.markInputs(dart.as(mark, core.int)); |
| 62 let out = this.output(); | 62 let out = this.output(); |
| 63 let overridden = out.determinedBy; | 63 let overridden = out.determinedBy; |
| 64 if (overridden !== null) | 64 if (overridden != null) |
| 65 overridden.markUnsatisfied(); | 65 overridden.markUnsatisfied(); |
| 66 out.determinedBy = this; | 66 out.determinedBy = this; |
| 67 if (!dart.notNull(exports.planner.addPropagate(this, dart.as(mark, core.in
t)))) | 67 if (!dart.notNull(exports.planner.addPropagate(this, dart.as(mark, core.in
t)))) |
| 68 core.print("Cycle encountered"); | 68 core.print("Cycle encountered"); |
| 69 out.mark = dart.as(mark, core.int); | 69 out.mark = dart.as(mark, core.int); |
| 70 return overridden; | 70 return overridden; |
| 71 } | 71 } |
| 72 destroyConstraint() { | 72 destroyConstraint() { |
| 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 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 = this.myOutput.mark !== mark && dart.notNull(Strength.stro
nger(this.strength, this.myOutput.walkStrength)); | 93 this.satisfied = this.myOutput.mark != mark && dart.notNull(Strength.stron
ger(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; |
| 104 this.myOutput.stay = !dart.notNull(this.isInput()); | 104 this.myOutput.stay = !dart.notNull(this.isInput()); |
| 105 if (this.myOutput.stay) | 105 if (this.myOutput.stay) |
| 106 this.execute(); | 106 this.execute(); |
| 107 } | 107 } |
| 108 markUnsatisfied() { | 108 markUnsatisfied() { |
| 109 this.satisfied = false; | 109 this.satisfied = false; |
| 110 } | 110 } |
| 111 inputsKnown(mark) { | 111 inputsKnown(mark) { |
| 112 return true; | 112 return true; |
| 113 } | 113 } |
| 114 removeFromGraph() { | 114 removeFromGraph() { |
| 115 if (this.myOutput !== null) | 115 if (this.myOutput != null) |
| 116 this.myOutput.removeConstraint(this); | 116 this.myOutput.removeConstraint(this); |
| 117 this.satisfied = false; | 117 this.satisfied = false; |
| 118 } | 118 } |
| 119 } | 119 } |
| 120 class StayConstraint extends UnaryConstraint { | 120 class StayConstraint extends UnaryConstraint { |
| 121 StayConstraint(v, str) { | 121 StayConstraint(v, str) { |
| 122 super.UnaryConstraint(v, str); | 122 super.UnaryConstraint(v, str); |
| 123 } | 123 } |
| 124 execute() {} | 124 execute() {} |
| 125 } | 125 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 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 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 = 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 } |
| 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); |
| 162 this.direction = NONE; | 162 this.direction = NONE; |
| 163 } | 163 } |
| 164 isSatisfied() { | 164 isSatisfied() { |
| 165 return this.direction !== NONE; | 165 return this.direction != NONE; |
| 166 } | 166 } |
| 167 markInputs(mark) { | 167 markInputs(mark) { |
| 168 this.input().mark = mark; | 168 this.input().mark = mark; |
| 169 } | 169 } |
| 170 input() { | 170 input() { |
| 171 return this.direction === FORWARD ? this.v1 : this.v2; | 171 return this.direction == FORWARD ? this.v1 : this.v2; |
| 172 } | 172 } |
| 173 output() { | 173 output() { |
| 174 return this.direction === FORWARD ? this.v2 : this.v1; | 174 return this.direction == FORWARD ? this.v2 : this.v1; |
| 175 } | 175 } |
| 176 recalculate() { | 176 recalculate() { |
| 177 let ihn = this.input(), out = this.output(); | 177 let ihn = this.input(), out = this.output(); |
| 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 i.mark === mark || dart.notNull(i.stay) || dart.notNull(i.determine
dBy === null); | 188 return i.mark == mark || dart.notNull(i.stay) || dart.notNull(i.determined
By == 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 { |
| 199 ScaleConstraint(src, scale, offset, dest, strength) { | 199 ScaleConstraint(src, scale, offset, dest, strength) { |
| 200 this.scale = scale; | 200 this.scale = scale; |
| 201 this.offset = offset; | 201 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) |
| 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 = dart.notNull(this.v1.value) * dart.notNull(this.scale.va
lue) + dart.notNull(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 = ((dart.notNull(this.v2.value) - dart.notNull(this.offset
.value)) / dart.notNull(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(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) |
| (...skipping 26 matching lines...) Expand all Loading... |
| 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 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 = o
verridden.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(); |
| 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; dart.notNull(i) < dart.notNull(unsatisfied.length); i =
dart.notNull(i) + 1) { | 278 for (let i = 0; dart.notNull(i) < dart.notNull(unsatisfied.length); i =
dart.notNull(i) + 1) { |
| 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 = dart.notNull(this.currentMark) + 1; | 287 return this.currentMark = dart.notNull(this.currentMark) + 1; |
| 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 (dart.notNull(todo.length) > 0) { | 293 while (dart.notNull(todo.length) > 0) { |
| 294 let c = todo.removeLast(); | 294 let c = todo.removeLast(); |
| 295 if (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 core.List$(Constraint).from([]); | 304 let sources = new core.List$(Constraint).from([]); |
| 305 for (let i = 0; dart.notNull(i) < dart.notNull(constraints.length); i = da
rt.notNull(i) + 1) { | 305 for (let i = 0; dart.notNull(i) < dart.notNull(constraints.length); i = da
rt.notNull(i) + 1) { |
| 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 core.List$(Constraint).from([c]); | 313 let todo = new core.List$(Constraint).from([c]); |
| 314 while (dart.notNull(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; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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; dart.notNull(i) <= dart.notNull(n); i = dart.notNull(i) + 1)
{ | 378 for (let i = 0; dart.notNull(i) <= dart.notNull(n); i = dart.notNull(i) + 1)
{ |
| 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 core.List$(Constra
int).from([edit])); | 390 let plan = exports.planner.extractPlanFromConstraints(new core.List$(Constra
int).from([edit])); |
| 391 for (let i = 0; dart.notNull(i) < 100; i = dart.notNull(i) + 1) { | 391 for (let i = 0; dart.notNull(i) < 100; i = dart.notNull(i) + 1) { |
| 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 core.List$(Variable).from([]); | 406 let dests = new core.List$(Variable).from([]); |
| 407 for (let i = 0; dart.notNull(i) < dart.notNull(n); i = dart.notNull(i) + 1)
{ | 407 for (let i = 0; dart.notNull(i) < dart.notNull(n); i = dart.notNull(i) + 1)
{ |
| 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; dart.notNull(i) < dart.notNull(n) - 1; i = dart.notNull(i) +
1) { | 421 for (let i = 0; dart.notNull(i) < dart.notNull(n) - 1; i = dart.notNull(i) +
1) { |
| 422 if (dests.get(i).value !== dart.notNull(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; dart.notNull(i) < dart.notNull(n) - 1; i = dart.notNull(i) +
1) { | 426 for (let i = 0; dart.notNull(i) < dart.notNull(n) - 1; i = dart.notNull(i) +
1) { |
| 427 if (dests.get(i).value !== dart.notNull(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 core.List$(EditCon
straint).from([edit])); | 434 let plan = exports.planner.extractPlanFromConstraints(new core.List$(EditCon
straint).from([edit])); |
| 435 for (let i = 0; dart.notNull(i) < 10; i = dart.notNull(i) + 1) { | 435 for (let i = 0; dart.notNull(i) < 10; i = dart.notNull(i) + 1) { |
| 436 v.value = newValue; | 436 v.value = newValue; |
| 437 plan.execute(); | 437 plan.execute(); |
| (...skipping 22 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 |