OLD | NEW |
1 dart_library.library('DeltaBlue', null, /* Imports */[ | 1 dart_library.library('DeltaBlue', null, /* Imports */[ |
2 'dart/_runtime', | 2 'dart_sdk' |
3 'BenchmarkBase', | 3 ], function(exports, dart_sdk) { |
4 'dart/core' | |
5 ], /* Lazy imports */[ | |
6 ], function(exports, dart, BenchmarkBase, core) { | |
7 'use strict'; | 4 'use strict'; |
8 let dartx = dart.dartx; | 5 const core = dart_sdk.core; |
9 function main() { | 6 const dart = dart_sdk.dart; |
10 new DeltaBlue().report(); | 7 const dartx = dart_sdk.dartx; |
11 } | 8 const DeltaBlue$ = Object.create(null); |
12 dart.fn(main); | 9 const BenchmarkBase$ = Object.create(null); |
13 class DeltaBlue extends BenchmarkBase.BenchmarkBase { | 10 DeltaBlue$.main = function() { |
| 11 new DeltaBlue$.DeltaBlue().report(); |
| 12 }; |
| 13 dart.fn(DeltaBlue$.main); |
| 14 BenchmarkBase$.BenchmarkBase = class BenchmarkBase extends core.Object { |
| 15 BenchmarkBase(name) { |
| 16 this.name = name; |
| 17 } |
| 18 run() {} |
| 19 warmup() { |
| 20 this.run(); |
| 21 } |
| 22 exercise() { |
| 23 for (let i = 0; i < 10; i++) { |
| 24 this.run(); |
| 25 } |
| 26 } |
| 27 setup() {} |
| 28 teardown() {} |
| 29 static measureFor(f, timeMinimum) { |
| 30 let time = 0; |
| 31 let iter = 0; |
| 32 let watch = new core.Stopwatch(); |
| 33 watch.start(); |
| 34 let elapsed = 0; |
| 35 while (dart.notNull(elapsed) < dart.notNull(timeMinimum)) { |
| 36 dart.dcall(f); |
| 37 elapsed = watch.elapsedMilliseconds; |
| 38 iter++; |
| 39 } |
| 40 return 1000.0 * dart.notNull(elapsed) / iter; |
| 41 } |
| 42 measure() { |
| 43 this.setup(); |
| 44 BenchmarkBase$.BenchmarkBase.measureFor(dart.fn(() => { |
| 45 this.warmup(); |
| 46 }), 100); |
| 47 let result = BenchmarkBase$.BenchmarkBase.measureFor(dart.fn(() => { |
| 48 this.exercise(); |
| 49 }), 2000); |
| 50 this.teardown(); |
| 51 return result; |
| 52 } |
| 53 report() { |
| 54 let score = this.measure(); |
| 55 core.print(`${this.name}(RunTime): ${score} us.`); |
| 56 } |
| 57 }; |
| 58 dart.setSignature(BenchmarkBase$.BenchmarkBase, { |
| 59 constructors: () => ({BenchmarkBase: [BenchmarkBase$.BenchmarkBase, [core.St
ring]]}), |
| 60 methods: () => ({ |
| 61 run: [dart.void, []], |
| 62 warmup: [dart.void, []], |
| 63 exercise: [dart.void, []], |
| 64 setup: [dart.void, []], |
| 65 teardown: [dart.void, []], |
| 66 measure: [core.double, []], |
| 67 report: [dart.void, []] |
| 68 }), |
| 69 statics: () => ({measureFor: [core.double, [core.Function, core.int]]}), |
| 70 names: ['measureFor'] |
| 71 }); |
| 72 DeltaBlue$.DeltaBlue = class DeltaBlue extends BenchmarkBase$.BenchmarkBase { |
14 DeltaBlue() { | 73 DeltaBlue() { |
15 super.BenchmarkBase("DeltaBlue"); | 74 super.BenchmarkBase("DeltaBlue"); |
16 } | 75 } |
17 run() { | 76 run() { |
18 chainTest(100); | 77 DeltaBlue$.chainTest(100); |
19 projectionTest(100); | 78 DeltaBlue$.projectionTest(100); |
20 } | 79 } |
21 } | 80 }; |
22 dart.setSignature(DeltaBlue, { | 81 dart.setSignature(DeltaBlue$.DeltaBlue, { |
23 constructors: () => ({DeltaBlue: [DeltaBlue, []]}) | 82 constructors: () => ({DeltaBlue: [DeltaBlue$.DeltaBlue, []]}) |
24 }); | 83 }); |
25 class Strength extends core.Object { | 84 DeltaBlue$.Strength = class Strength extends core.Object { |
26 Strength(value, name) { | 85 Strength(value, name) { |
27 this.value = value; | 86 this.value = value; |
28 this.name = name; | 87 this.name = name; |
29 } | 88 } |
30 nextWeaker() { | 89 nextWeaker() { |
31 return dart.const(dart.list([STRONG_PREFERRED, PREFERRED, STRONG_DEFAULT,
NORMAL, WEAK_DEFAULT, WEAKEST], Strength))[dartx.get](this.value); | 90 return dart.const(dart.list([DeltaBlue$.STRONG_PREFERRED, DeltaBlue$.PREFE
RRED, DeltaBlue$.STRONG_DEFAULT, DeltaBlue$.NORMAL, DeltaBlue$.WEAK_DEFAULT, Del
taBlue$.WEAKEST], DeltaBlue$.Strength))[dartx.get](this.value); |
32 } | 91 } |
33 static stronger(s1, s2) { | 92 static stronger(s1, s2) { |
34 return dart.notNull(s1.value) < dart.notNull(s2.value); | 93 return dart.notNull(s1.value) < dart.notNull(s2.value); |
35 } | 94 } |
36 static weaker(s1, s2) { | 95 static weaker(s1, s2) { |
37 return dart.notNull(s1.value) > dart.notNull(s2.value); | 96 return dart.notNull(s1.value) > dart.notNull(s2.value); |
38 } | 97 } |
39 static weakest(s1, s2) { | 98 static weakest(s1, s2) { |
40 return dart.notNull(Strength.weaker(s1, s2)) ? s1 : s2; | 99 return dart.notNull(DeltaBlue$.Strength.weaker(s1, s2)) ? s1 : s2; |
41 } | 100 } |
42 static strongest(s1, s2) { | 101 static strongest(s1, s2) { |
43 return dart.notNull(Strength.stronger(s1, s2)) ? s1 : s2; | 102 return dart.notNull(DeltaBlue$.Strength.stronger(s1, s2)) ? s1 : s2; |
44 } | 103 } |
45 } | 104 }; |
46 dart.setSignature(Strength, { | 105 dart.setSignature(DeltaBlue$.Strength, { |
47 constructors: () => ({Strength: [Strength, [core.int, core.String]]}), | 106 constructors: () => ({Strength: [DeltaBlue$.Strength, [core.int, core.String
]]}), |
48 methods: () => ({nextWeaker: [Strength, []]}), | 107 methods: () => ({nextWeaker: [DeltaBlue$.Strength, []]}), |
49 statics: () => ({ | 108 statics: () => ({ |
50 stronger: [core.bool, [Strength, Strength]], | 109 stronger: [core.bool, [DeltaBlue$.Strength, DeltaBlue$.Strength]], |
51 weaker: [core.bool, [Strength, Strength]], | 110 weaker: [core.bool, [DeltaBlue$.Strength, DeltaBlue$.Strength]], |
52 weakest: [Strength, [Strength, Strength]], | 111 weakest: [DeltaBlue$.Strength, [DeltaBlue$.Strength, DeltaBlue$.Strength]]
, |
53 strongest: [Strength, [Strength, Strength]] | 112 strongest: [DeltaBlue$.Strength, [DeltaBlue$.Strength, DeltaBlue$.Strength
]] |
54 }), | 113 }), |
55 names: ['stronger', 'weaker', 'weakest', 'strongest'] | 114 names: ['stronger', 'weaker', 'weakest', 'strongest'] |
56 }); | 115 }); |
57 const REQUIRED = dart.const(new Strength(0, "required")); | 116 DeltaBlue$.REQUIRED = dart.const(new DeltaBlue$.Strength(0, "required")); |
58 const STRONG_PREFERRED = dart.const(new Strength(1, "strongPreferred")); | 117 DeltaBlue$.STRONG_PREFERRED = dart.const(new DeltaBlue$.Strength(1, "strongPre
ferred")); |
59 const PREFERRED = dart.const(new Strength(2, "preferred")); | 118 DeltaBlue$.PREFERRED = dart.const(new DeltaBlue$.Strength(2, "preferred")); |
60 const STRONG_DEFAULT = dart.const(new Strength(3, "strongDefault")); | 119 DeltaBlue$.STRONG_DEFAULT = dart.const(new DeltaBlue$.Strength(3, "strongDefau
lt")); |
61 const NORMAL = dart.const(new Strength(4, "normal")); | 120 DeltaBlue$.NORMAL = dart.const(new DeltaBlue$.Strength(4, "normal")); |
62 const WEAK_DEFAULT = dart.const(new Strength(5, "weakDefault")); | 121 DeltaBlue$.WEAK_DEFAULT = dart.const(new DeltaBlue$.Strength(5, "weakDefault")
); |
63 const WEAKEST = dart.const(new Strength(6, "weakest")); | 122 DeltaBlue$.WEAKEST = dart.const(new DeltaBlue$.Strength(6, "weakest")); |
64 class Constraint extends core.Object { | 123 DeltaBlue$.Constraint = class Constraint extends core.Object { |
65 Constraint(strength) { | 124 Constraint(strength) { |
66 this.strength = strength; | 125 this.strength = strength; |
67 } | 126 } |
68 addConstraint() { | 127 addConstraint() { |
69 this.addToGraph(); | 128 this.addToGraph(); |
70 exports.planner.incrementalAdd(this); | 129 DeltaBlue$.planner.incrementalAdd(this); |
71 } | 130 } |
72 satisfy(mark) { | 131 satisfy(mark) { |
73 this.chooseMethod(dart.as(mark, core.int)); | 132 this.chooseMethod(dart.as(mark, core.int)); |
74 if (!dart.notNull(this.isSatisfied())) { | 133 if (!dart.notNull(this.isSatisfied())) { |
75 if (dart.equals(this.strength, REQUIRED)) { | 134 if (dart.equals(this.strength, DeltaBlue$.REQUIRED)) { |
76 core.print("Could not satisfy a required constraint!"); | 135 core.print("Could not satisfy a required constraint!"); |
77 } | 136 } |
78 return null; | 137 return null; |
79 } | 138 } |
80 this.markInputs(dart.as(mark, core.int)); | 139 this.markInputs(dart.as(mark, core.int)); |
81 let out = this.output(); | 140 let out = this.output(); |
82 let overridden = out.determinedBy; | 141 let overridden = out.determinedBy; |
83 if (overridden != null) overridden.markUnsatisfied(); | 142 if (overridden != null) overridden.markUnsatisfied(); |
84 out.determinedBy = this; | 143 out.determinedBy = this; |
85 if (!dart.notNull(exports.planner.addPropagate(this, dart.as(mark, core.in
t)))) core.print("Cycle encountered"); | 144 if (!dart.notNull(DeltaBlue$.planner.addPropagate(this, dart.as(mark, core
.int)))) core.print("Cycle encountered"); |
86 out.mark = dart.as(mark, core.int); | 145 out.mark = dart.as(mark, core.int); |
87 return overridden; | 146 return overridden; |
88 } | 147 } |
89 destroyConstraint() { | 148 destroyConstraint() { |
90 if (dart.notNull(this.isSatisfied())) exports.planner.incrementalRemove(th
is); | 149 if (dart.notNull(this.isSatisfied())) DeltaBlue$.planner.incrementalRemove
(this); |
91 this.removeFromGraph(); | 150 this.removeFromGraph(); |
92 } | 151 } |
93 isInput() { | 152 isInput() { |
94 return false; | 153 return false; |
95 } | 154 } |
96 } | 155 }; |
97 dart.setSignature(Constraint, { | 156 dart.setSignature(DeltaBlue$.Constraint, { |
98 constructors: () => ({Constraint: [Constraint, [Strength]]}), | 157 constructors: () => ({Constraint: [DeltaBlue$.Constraint, [DeltaBlue$.Streng
th]]}), |
99 methods: () => ({ | 158 methods: () => ({ |
100 addConstraint: [dart.void, []], | 159 addConstraint: [dart.void, []], |
101 satisfy: [Constraint, [dart.dynamic]], | 160 satisfy: [DeltaBlue$.Constraint, [dart.dynamic]], |
102 destroyConstraint: [dart.void, []], | 161 destroyConstraint: [dart.void, []], |
103 isInput: [core.bool, []] | 162 isInput: [core.bool, []] |
104 }) | 163 }) |
105 }); | 164 }); |
106 class UnaryConstraint extends Constraint { | 165 DeltaBlue$.UnaryConstraint = class UnaryConstraint extends DeltaBlue$.Constrai
nt { |
107 UnaryConstraint(myOutput, strength) { | 166 UnaryConstraint(myOutput, strength) { |
108 this.myOutput = myOutput; | 167 this.myOutput = myOutput; |
109 this.satisfied = false; | 168 this.satisfied = false; |
110 super.Constraint(strength); | 169 super.Constraint(strength); |
111 this.addConstraint(); | 170 this.addConstraint(); |
112 } | 171 } |
113 addToGraph() { | 172 addToGraph() { |
114 this.myOutput.addConstraint(this); | 173 this.myOutput.addConstraint(this); |
115 this.satisfied = false; | 174 this.satisfied = false; |
116 } | 175 } |
117 chooseMethod(mark) { | 176 chooseMethod(mark) { |
118 this.satisfied = this.myOutput.mark != mark && dart.notNull(Strength.stron
ger(this.strength, this.myOutput.walkStrength)); | 177 this.satisfied = this.myOutput.mark != mark && dart.notNull(DeltaBlue$.Str
ength.stronger(this.strength, this.myOutput.walkStrength)); |
119 } | 178 } |
120 isSatisfied() { | 179 isSatisfied() { |
121 return this.satisfied; | 180 return this.satisfied; |
122 } | 181 } |
123 markInputs(mark) {} | 182 markInputs(mark) {} |
124 output() { | 183 output() { |
125 return this.myOutput; | 184 return this.myOutput; |
126 } | 185 } |
127 recalculate() { | 186 recalculate() { |
128 this.myOutput.walkStrength = this.strength; | 187 this.myOutput.walkStrength = this.strength; |
129 this.myOutput.stay = !dart.notNull(this.isInput()); | 188 this.myOutput.stay = !dart.notNull(this.isInput()); |
130 if (dart.notNull(this.myOutput.stay)) this.execute(); | 189 if (dart.notNull(this.myOutput.stay)) this.execute(); |
131 } | 190 } |
132 markUnsatisfied() { | 191 markUnsatisfied() { |
133 this.satisfied = false; | 192 this.satisfied = false; |
134 } | 193 } |
135 inputsKnown(mark) { | 194 inputsKnown(mark) { |
136 return true; | 195 return true; |
137 } | 196 } |
138 removeFromGraph() { | 197 removeFromGraph() { |
139 if (this.myOutput != null) this.myOutput.removeConstraint(this); | 198 if (this.myOutput != null) this.myOutput.removeConstraint(this); |
140 this.satisfied = false; | 199 this.satisfied = false; |
141 } | 200 } |
142 } | 201 }; |
143 dart.setSignature(UnaryConstraint, { | 202 dart.setSignature(DeltaBlue$.UnaryConstraint, { |
144 constructors: () => ({UnaryConstraint: [UnaryConstraint, [Variable, Strength
]]}), | 203 constructors: () => ({UnaryConstraint: [DeltaBlue$.UnaryConstraint, [DeltaBl
ue$.Variable, DeltaBlue$.Strength]]}), |
145 methods: () => ({ | 204 methods: () => ({ |
146 addToGraph: [dart.void, []], | 205 addToGraph: [dart.void, []], |
147 chooseMethod: [dart.void, [core.int]], | 206 chooseMethod: [dart.void, [core.int]], |
148 isSatisfied: [core.bool, []], | 207 isSatisfied: [core.bool, []], |
149 markInputs: [dart.void, [core.int]], | 208 markInputs: [dart.void, [core.int]], |
150 output: [Variable, []], | 209 output: [DeltaBlue$.Variable, []], |
151 recalculate: [dart.void, []], | 210 recalculate: [dart.void, []], |
152 markUnsatisfied: [dart.void, []], | 211 markUnsatisfied: [dart.void, []], |
153 inputsKnown: [core.bool, [core.int]], | 212 inputsKnown: [core.bool, [core.int]], |
154 removeFromGraph: [dart.void, []] | 213 removeFromGraph: [dart.void, []] |
155 }) | 214 }) |
156 }); | 215 }); |
157 class StayConstraint extends UnaryConstraint { | 216 DeltaBlue$.StayConstraint = class StayConstraint extends DeltaBlue$.UnaryConst
raint { |
158 StayConstraint(v, str) { | 217 StayConstraint(v, str) { |
159 super.UnaryConstraint(v, str); | 218 super.UnaryConstraint(v, str); |
160 } | 219 } |
161 execute() {} | 220 execute() {} |
162 } | 221 }; |
163 dart.setSignature(StayConstraint, { | 222 dart.setSignature(DeltaBlue$.StayConstraint, { |
164 constructors: () => ({StayConstraint: [StayConstraint, [Variable, Strength]]
}), | 223 constructors: () => ({StayConstraint: [DeltaBlue$.StayConstraint, [DeltaBlue
$.Variable, DeltaBlue$.Strength]]}), |
165 methods: () => ({execute: [dart.void, []]}) | 224 methods: () => ({execute: [dart.void, []]}) |
166 }); | 225 }); |
167 class EditConstraint extends UnaryConstraint { | 226 DeltaBlue$.EditConstraint = class EditConstraint extends DeltaBlue$.UnaryConst
raint { |
168 EditConstraint(v, str) { | 227 EditConstraint(v, str) { |
169 super.UnaryConstraint(v, str); | 228 super.UnaryConstraint(v, str); |
170 } | 229 } |
171 isInput() { | 230 isInput() { |
172 return true; | 231 return true; |
173 } | 232 } |
174 execute() {} | 233 execute() {} |
175 } | 234 }; |
176 dart.setSignature(EditConstraint, { | 235 dart.setSignature(DeltaBlue$.EditConstraint, { |
177 constructors: () => ({EditConstraint: [EditConstraint, [Variable, Strength]]
}), | 236 constructors: () => ({EditConstraint: [DeltaBlue$.EditConstraint, [DeltaBlue
$.Variable, DeltaBlue$.Strength]]}), |
178 methods: () => ({execute: [dart.void, []]}) | 237 methods: () => ({execute: [dart.void, []]}) |
179 }); | 238 }); |
180 const NONE = 1; | 239 DeltaBlue$.NONE = 1; |
181 const FORWARD = 2; | 240 DeltaBlue$.FORWARD = 2; |
182 const BACKWARD = 0; | 241 DeltaBlue$.BACKWARD = 0; |
183 class BinaryConstraint extends Constraint { | 242 DeltaBlue$.BinaryConstraint = class BinaryConstraint extends DeltaBlue$.Constr
aint { |
184 BinaryConstraint(v1, v2, strength) { | 243 BinaryConstraint(v1, v2, strength) { |
185 this.v1 = v1; | 244 this.v1 = v1; |
186 this.v2 = v2; | 245 this.v2 = v2; |
187 this.direction = NONE; | 246 this.direction = DeltaBlue$.NONE; |
188 super.Constraint(strength); | 247 super.Constraint(strength); |
189 this.addConstraint(); | 248 this.addConstraint(); |
190 } | 249 } |
191 chooseMethod(mark) { | 250 chooseMethod(mark) { |
192 if (this.v1.mark == mark) { | 251 if (this.v1.mark == mark) { |
193 this.direction = this.v2.mark != mark && dart.notNull(Strength.stronger(
this.strength, this.v2.walkStrength)) ? FORWARD : NONE; | 252 this.direction = this.v2.mark != mark && dart.notNull(DeltaBlue$.Strengt
h.stronger(this.strength, this.v2.walkStrength)) ? DeltaBlue$.FORWARD : DeltaBlu
e$.NONE; |
194 } | 253 } |
195 if (this.v2.mark == mark) { | 254 if (this.v2.mark == mark) { |
196 this.direction = this.v1.mark != mark && dart.notNull(Strength.stronger(
this.strength, this.v1.walkStrength)) ? BACKWARD : NONE; | 255 this.direction = this.v1.mark != mark && dart.notNull(DeltaBlue$.Strengt
h.stronger(this.strength, this.v1.walkStrength)) ? DeltaBlue$.BACKWARD : DeltaBl
ue$.NONE; |
197 } | 256 } |
198 if (dart.notNull(Strength.weaker(this.v1.walkStrength, this.v2.walkStrengt
h))) { | 257 if (dart.notNull(DeltaBlue$.Strength.weaker(this.v1.walkStrength, this.v2.
walkStrength))) { |
199 this.direction = dart.notNull(Strength.stronger(this.strength, this.v1.w
alkStrength)) ? BACKWARD : NONE; | 258 this.direction = dart.notNull(DeltaBlue$.Strength.stronger(this.strength
, this.v1.walkStrength)) ? DeltaBlue$.BACKWARD : DeltaBlue$.NONE; |
200 } else { | 259 } else { |
201 this.direction = dart.notNull(Strength.stronger(this.strength, this.v2.w
alkStrength)) ? FORWARD : BACKWARD; | 260 this.direction = dart.notNull(DeltaBlue$.Strength.stronger(this.strength
, this.v2.walkStrength)) ? DeltaBlue$.FORWARD : DeltaBlue$.BACKWARD; |
202 } | 261 } |
203 } | 262 } |
204 addToGraph() { | 263 addToGraph() { |
205 this.v1.addConstraint(this); | 264 this.v1.addConstraint(this); |
206 this.v2.addConstraint(this); | 265 this.v2.addConstraint(this); |
207 this.direction = NONE; | 266 this.direction = DeltaBlue$.NONE; |
208 } | 267 } |
209 isSatisfied() { | 268 isSatisfied() { |
210 return this.direction != NONE; | 269 return this.direction != DeltaBlue$.NONE; |
211 } | 270 } |
212 markInputs(mark) { | 271 markInputs(mark) { |
213 this.input().mark = mark; | 272 this.input().mark = mark; |
214 } | 273 } |
215 input() { | 274 input() { |
216 return this.direction == FORWARD ? this.v1 : this.v2; | 275 return this.direction == DeltaBlue$.FORWARD ? this.v1 : this.v2; |
217 } | 276 } |
218 output() { | 277 output() { |
219 return this.direction == FORWARD ? this.v2 : this.v1; | 278 return this.direction == DeltaBlue$.FORWARD ? this.v2 : this.v1; |
220 } | 279 } |
221 recalculate() { | 280 recalculate() { |
222 let ihn = this.input(), out = this.output(); | 281 let ihn = this.input(), out = this.output(); |
223 out.walkStrength = Strength.weakest(this.strength, ihn.walkStrength); | 282 out.walkStrength = DeltaBlue$.Strength.weakest(this.strength, ihn.walkStre
ngth); |
224 out.stay = ihn.stay; | 283 out.stay = ihn.stay; |
225 if (dart.notNull(out.stay)) this.execute(); | 284 if (dart.notNull(out.stay)) this.execute(); |
226 } | 285 } |
227 markUnsatisfied() { | 286 markUnsatisfied() { |
228 this.direction = NONE; | 287 this.direction = DeltaBlue$.NONE; |
229 } | 288 } |
230 inputsKnown(mark) { | 289 inputsKnown(mark) { |
231 let i = this.input(); | 290 let i = this.input(); |
232 return i.mark == mark || dart.notNull(i.stay) || i.determinedBy == null; | 291 return i.mark == mark || dart.notNull(i.stay) || i.determinedBy == null; |
233 } | 292 } |
234 removeFromGraph() { | 293 removeFromGraph() { |
235 if (this.v1 != null) this.v1.removeConstraint(this); | 294 if (this.v1 != null) this.v1.removeConstraint(this); |
236 if (this.v2 != null) this.v2.removeConstraint(this); | 295 if (this.v2 != null) this.v2.removeConstraint(this); |
237 this.direction = NONE; | 296 this.direction = DeltaBlue$.NONE; |
238 } | 297 } |
239 } | 298 }; |
240 dart.setSignature(BinaryConstraint, { | 299 dart.setSignature(DeltaBlue$.BinaryConstraint, { |
241 constructors: () => ({BinaryConstraint: [BinaryConstraint, [Variable, Variab
le, Strength]]}), | 300 constructors: () => ({BinaryConstraint: [DeltaBlue$.BinaryConstraint, [Delta
Blue$.Variable, DeltaBlue$.Variable, DeltaBlue$.Strength]]}), |
242 methods: () => ({ | 301 methods: () => ({ |
243 chooseMethod: [dart.void, [core.int]], | 302 chooseMethod: [dart.void, [core.int]], |
244 addToGraph: [dart.void, []], | 303 addToGraph: [dart.void, []], |
245 isSatisfied: [core.bool, []], | 304 isSatisfied: [core.bool, []], |
246 markInputs: [dart.void, [core.int]], | 305 markInputs: [dart.void, [core.int]], |
247 input: [Variable, []], | 306 input: [DeltaBlue$.Variable, []], |
248 output: [Variable, []], | 307 output: [DeltaBlue$.Variable, []], |
249 recalculate: [dart.void, []], | 308 recalculate: [dart.void, []], |
250 markUnsatisfied: [dart.void, []], | 309 markUnsatisfied: [dart.void, []], |
251 inputsKnown: [core.bool, [core.int]], | 310 inputsKnown: [core.bool, [core.int]], |
252 removeFromGraph: [dart.void, []] | 311 removeFromGraph: [dart.void, []] |
253 }) | 312 }) |
254 }); | 313 }); |
255 class ScaleConstraint extends BinaryConstraint { | 314 DeltaBlue$.ScaleConstraint = class ScaleConstraint extends DeltaBlue$.BinaryCo
nstraint { |
256 ScaleConstraint(src, scale, offset, dest, strength) { | 315 ScaleConstraint(src, scale, offset, dest, strength) { |
257 this.scale = scale; | 316 this.scale = scale; |
258 this.offset = offset; | 317 this.offset = offset; |
259 super.BinaryConstraint(src, dest, strength); | 318 super.BinaryConstraint(src, dest, strength); |
260 } | 319 } |
261 addToGraph() { | 320 addToGraph() { |
262 super.addToGraph(); | 321 super.addToGraph(); |
263 this.scale.addConstraint(this); | 322 this.scale.addConstraint(this); |
264 this.offset.addConstraint(this); | 323 this.offset.addConstraint(this); |
265 } | 324 } |
266 removeFromGraph() { | 325 removeFromGraph() { |
267 super.removeFromGraph(); | 326 super.removeFromGraph(); |
268 if (this.scale != null) this.scale.removeConstraint(this); | 327 if (this.scale != null) this.scale.removeConstraint(this); |
269 if (this.offset != null) this.offset.removeConstraint(this); | 328 if (this.offset != null) this.offset.removeConstraint(this); |
270 } | 329 } |
271 markInputs(mark) { | 330 markInputs(mark) { |
272 super.markInputs(mark); | 331 super.markInputs(mark); |
273 this.scale.mark = this.offset.mark = mark; | 332 this.scale.mark = this.offset.mark = mark; |
274 } | 333 } |
275 execute() { | 334 execute() { |
276 if (this.direction == FORWARD) { | 335 if (this.direction == DeltaBlue$.FORWARD) { |
277 this.v2.value = dart.notNull(this.v1.value) * dart.notNull(this.scale.va
lue) + dart.notNull(this.offset.value); | 336 this.v2.value = dart.notNull(this.v1.value) * dart.notNull(this.scale.va
lue) + dart.notNull(this.offset.value); |
278 } else { | 337 } else { |
279 this.v1.value = ((dart.notNull(this.v2.value) - dart.notNull(this.offset
.value)) / dart.notNull(this.scale.value))[dartx.truncate](); | 338 this.v1.value = ((dart.notNull(this.v2.value) - dart.notNull(this.offset
.value)) / dart.notNull(this.scale.value))[dartx.truncate](); |
280 } | 339 } |
281 } | 340 } |
282 recalculate() { | 341 recalculate() { |
283 let ihn = this.input(), out = this.output(); | 342 let ihn = this.input(), out = this.output(); |
284 out.walkStrength = Strength.weakest(this.strength, ihn.walkStrength); | 343 out.walkStrength = DeltaBlue$.Strength.weakest(this.strength, ihn.walkStre
ngth); |
285 out.stay = dart.notNull(ihn.stay) && dart.notNull(this.scale.stay) && dart
.notNull(this.offset.stay); | 344 out.stay = dart.notNull(ihn.stay) && dart.notNull(this.scale.stay) && dart
.notNull(this.offset.stay); |
286 if (dart.notNull(out.stay)) this.execute(); | 345 if (dart.notNull(out.stay)) this.execute(); |
287 } | 346 } |
288 } | 347 }; |
289 dart.setSignature(ScaleConstraint, { | 348 dart.setSignature(DeltaBlue$.ScaleConstraint, { |
290 constructors: () => ({ScaleConstraint: [ScaleConstraint, [Variable, Variable
, Variable, Variable, Strength]]}), | 349 constructors: () => ({ScaleConstraint: [DeltaBlue$.ScaleConstraint, [DeltaBl
ue$.Variable, DeltaBlue$.Variable, DeltaBlue$.Variable, DeltaBlue$.Variable, Del
taBlue$.Strength]]}), |
291 methods: () => ({execute: [dart.void, []]}) | 350 methods: () => ({execute: [dart.void, []]}) |
292 }); | 351 }); |
293 class EqualityConstraint extends BinaryConstraint { | 352 DeltaBlue$.EqualityConstraint = class EqualityConstraint extends DeltaBlue$.Bi
naryConstraint { |
294 EqualityConstraint(v1, v2, strength) { | 353 EqualityConstraint(v1, v2, strength) { |
295 super.BinaryConstraint(v1, v2, strength); | 354 super.BinaryConstraint(v1, v2, strength); |
296 } | 355 } |
297 execute() { | 356 execute() { |
298 this.output().value = this.input().value; | 357 this.output().value = this.input().value; |
299 } | 358 } |
300 } | 359 }; |
301 dart.setSignature(EqualityConstraint, { | 360 dart.setSignature(DeltaBlue$.EqualityConstraint, { |
302 constructors: () => ({EqualityConstraint: [EqualityConstraint, [Variable, Va
riable, Strength]]}), | 361 constructors: () => ({EqualityConstraint: [DeltaBlue$.EqualityConstraint, [D
eltaBlue$.Variable, DeltaBlue$.Variable, DeltaBlue$.Strength]]}), |
303 methods: () => ({execute: [dart.void, []]}) | 362 methods: () => ({execute: [dart.void, []]}) |
304 }); | 363 }); |
305 class Variable extends core.Object { | 364 DeltaBlue$.Variable = class Variable extends core.Object { |
306 Variable(name, value) { | 365 Variable(name, value) { |
307 this.constraints = dart.list([], Constraint); | 366 this.constraints = dart.list([], DeltaBlue$.Constraint); |
308 this.name = name; | 367 this.name = name; |
309 this.value = value; | 368 this.value = value; |
310 this.determinedBy = null; | 369 this.determinedBy = null; |
311 this.mark = 0; | 370 this.mark = 0; |
312 this.walkStrength = WEAKEST; | 371 this.walkStrength = DeltaBlue$.WEAKEST; |
313 this.stay = true; | 372 this.stay = true; |
314 } | 373 } |
315 addConstraint(c) { | 374 addConstraint(c) { |
316 this.constraints[dartx.add](c); | 375 this.constraints[dartx.add](c); |
317 } | 376 } |
318 removeConstraint(c) { | 377 removeConstraint(c) { |
319 this.constraints[dartx.remove](c); | 378 this.constraints[dartx.remove](c); |
320 if (dart.equals(this.determinedBy, c)) this.determinedBy = null; | 379 if (dart.equals(this.determinedBy, c)) this.determinedBy = null; |
321 } | 380 } |
322 } | 381 }; |
323 dart.setSignature(Variable, { | 382 dart.setSignature(DeltaBlue$.Variable, { |
324 constructors: () => ({Variable: [Variable, [core.String, core.int]]}), | 383 constructors: () => ({Variable: [DeltaBlue$.Variable, [core.String, core.int
]]}), |
325 methods: () => ({ | 384 methods: () => ({ |
326 addConstraint: [dart.void, [Constraint]], | 385 addConstraint: [dart.void, [DeltaBlue$.Constraint]], |
327 removeConstraint: [dart.void, [Constraint]] | 386 removeConstraint: [dart.void, [DeltaBlue$.Constraint]] |
328 }) | 387 }) |
329 }); | 388 }); |
330 class Planner extends core.Object { | 389 DeltaBlue$.Planner = class Planner extends core.Object { |
331 Planner() { | 390 Planner() { |
332 this.currentMark = 0; | 391 this.currentMark = 0; |
333 } | 392 } |
334 incrementalAdd(c) { | 393 incrementalAdd(c) { |
335 let mark = this.newMark(); | 394 let mark = this.newMark(); |
336 for (let overridden = c.satisfy(mark); overridden != null; overridden = ov
erridden.satisfy(mark)) | 395 for (let overridden = c.satisfy(mark); overridden != null; overridden = ov
erridden.satisfy(mark)) |
337 ; | 396 ; |
338 } | 397 } |
339 incrementalRemove(c) { | 398 incrementalRemove(c) { |
340 let out = c.output(); | 399 let out = c.output(); |
341 c.markUnsatisfied(); | 400 c.markUnsatisfied(); |
342 c.removeFromGraph(); | 401 c.removeFromGraph(); |
343 let unsatisfied = this.removePropagateFrom(out); | 402 let unsatisfied = this.removePropagateFrom(out); |
344 let strength = REQUIRED; | 403 let strength = DeltaBlue$.REQUIRED; |
345 do { | 404 do { |
346 for (let i = 0; i < dart.notNull(unsatisfied[dartx.length]); i++) { | 405 for (let i = 0; i < dart.notNull(unsatisfied[dartx.length]); i++) { |
347 let u = unsatisfied[dartx.get](i); | 406 let u = unsatisfied[dartx.get](i); |
348 if (dart.equals(u.strength, strength)) this.incrementalAdd(u); | 407 if (dart.equals(u.strength, strength)) this.incrementalAdd(u); |
349 } | 408 } |
350 strength = strength.nextWeaker(); | 409 strength = strength.nextWeaker(); |
351 } while (!dart.equals(strength, WEAKEST)); | 410 } while (!dart.equals(strength, DeltaBlue$.WEAKEST)); |
352 } | 411 } |
353 newMark() { | 412 newMark() { |
354 return this.currentMark = dart.notNull(this.currentMark) + 1; | 413 return this.currentMark = dart.notNull(this.currentMark) + 1; |
355 } | 414 } |
356 makePlan(sources) { | 415 makePlan(sources) { |
357 let mark = this.newMark(); | 416 let mark = this.newMark(); |
358 let plan = new Plan(); | 417 let plan = new DeltaBlue$.Plan(); |
359 let todo = sources; | 418 let todo = sources; |
360 while (dart.notNull(todo[dartx.length]) > 0) { | 419 while (dart.notNull(todo[dartx.length]) > 0) { |
361 let c = todo[dartx.removeLast](); | 420 let c = todo[dartx.removeLast](); |
362 if (c.output().mark != mark && dart.notNull(c.inputsKnown(mark))) { | 421 if (c.output().mark != mark && dart.notNull(c.inputsKnown(mark))) { |
363 plan.addConstraint(c); | 422 plan.addConstraint(c); |
364 c.output().mark = mark; | 423 c.output().mark = mark; |
365 this.addConstraintsConsumingTo(c.output(), todo); | 424 this.addConstraintsConsumingTo(c.output(), todo); |
366 } | 425 } |
367 } | 426 } |
368 return plan; | 427 return plan; |
369 } | 428 } |
370 extractPlanFromConstraints(constraints) { | 429 extractPlanFromConstraints(constraints) { |
371 let sources = dart.list([], Constraint); | 430 let sources = dart.list([], DeltaBlue$.Constraint); |
372 for (let i = 0; i < dart.notNull(constraints[dartx.length]); i++) { | 431 for (let i = 0; i < dart.notNull(constraints[dartx.length]); i++) { |
373 let c = constraints[dartx.get](i); | 432 let c = constraints[dartx.get](i); |
374 if (dart.notNull(c.isInput()) && dart.notNull(c.isSatisfied())) sources[
dartx.add](c); | 433 if (dart.notNull(c.isInput()) && dart.notNull(c.isSatisfied())) sources[
dartx.add](c); |
375 } | 434 } |
376 return this.makePlan(sources); | 435 return this.makePlan(sources); |
377 } | 436 } |
378 addPropagate(c, mark) { | 437 addPropagate(c, mark) { |
379 let todo = dart.list([c], Constraint); | 438 let todo = dart.list([c], DeltaBlue$.Constraint); |
380 while (dart.notNull(todo[dartx.length]) > 0) { | 439 while (dart.notNull(todo[dartx.length]) > 0) { |
381 let d = todo[dartx.removeLast](); | 440 let d = todo[dartx.removeLast](); |
382 if (d.output().mark == mark) { | 441 if (d.output().mark == mark) { |
383 this.incrementalRemove(c); | 442 this.incrementalRemove(c); |
384 return false; | 443 return false; |
385 } | 444 } |
386 d.recalculate(); | 445 d.recalculate(); |
387 this.addConstraintsConsumingTo(d.output(), todo); | 446 this.addConstraintsConsumingTo(d.output(), todo); |
388 } | 447 } |
389 return true; | 448 return true; |
390 } | 449 } |
391 removePropagateFrom(out) { | 450 removePropagateFrom(out) { |
392 out.determinedBy = null; | 451 out.determinedBy = null; |
393 out.walkStrength = WEAKEST; | 452 out.walkStrength = DeltaBlue$.WEAKEST; |
394 out.stay = true; | 453 out.stay = true; |
395 let unsatisfied = dart.list([], Constraint); | 454 let unsatisfied = dart.list([], DeltaBlue$.Constraint); |
396 let todo = dart.list([out], Variable); | 455 let todo = dart.list([out], DeltaBlue$.Variable); |
397 while (dart.notNull(todo[dartx.length]) > 0) { | 456 while (dart.notNull(todo[dartx.length]) > 0) { |
398 let v = todo[dartx.removeLast](); | 457 let v = todo[dartx.removeLast](); |
399 for (let i = 0; i < dart.notNull(v.constraints[dartx.length]); i++) { | 458 for (let i = 0; i < dart.notNull(v.constraints[dartx.length]); i++) { |
400 let c = v.constraints[dartx.get](i); | 459 let c = v.constraints[dartx.get](i); |
401 if (!dart.notNull(c.isSatisfied())) unsatisfied[dartx.add](c); | 460 if (!dart.notNull(c.isSatisfied())) unsatisfied[dartx.add](c); |
402 } | 461 } |
403 let determining = v.determinedBy; | 462 let determining = v.determinedBy; |
404 for (let i = 0; i < dart.notNull(v.constraints[dartx.length]); i++) { | 463 for (let i = 0; i < dart.notNull(v.constraints[dartx.length]); i++) { |
405 let next = v.constraints[dartx.get](i); | 464 let next = v.constraints[dartx.get](i); |
406 if (!dart.equals(next, determining) && dart.notNull(next.isSatisfied()
)) { | 465 if (!dart.equals(next, determining) && dart.notNull(next.isSatisfied()
)) { |
407 next.recalculate(); | 466 next.recalculate(); |
408 todo[dartx.add](next.output()); | 467 todo[dartx.add](next.output()); |
409 } | 468 } |
410 } | 469 } |
411 } | 470 } |
412 return unsatisfied; | 471 return unsatisfied; |
413 } | 472 } |
414 addConstraintsConsumingTo(v, coll) { | 473 addConstraintsConsumingTo(v, coll) { |
415 let determining = v.determinedBy; | 474 let determining = v.determinedBy; |
416 for (let i = 0; i < dart.notNull(v.constraints[dartx.length]); i++) { | 475 for (let i = 0; i < dart.notNull(v.constraints[dartx.length]); i++) { |
417 let c = v.constraints[dartx.get](i); | 476 let c = v.constraints[dartx.get](i); |
418 if (!dart.equals(c, determining) && dart.notNull(c.isSatisfied())) coll[
dartx.add](c); | 477 if (!dart.equals(c, determining) && dart.notNull(c.isSatisfied())) coll[
dartx.add](c); |
419 } | 478 } |
420 } | 479 } |
421 } | 480 }; |
422 dart.setSignature(Planner, { | 481 dart.setSignature(DeltaBlue$.Planner, { |
423 methods: () => ({ | 482 methods: () => ({ |
424 incrementalAdd: [dart.void, [Constraint]], | 483 incrementalAdd: [dart.void, [DeltaBlue$.Constraint]], |
425 incrementalRemove: [dart.void, [Constraint]], | 484 incrementalRemove: [dart.void, [DeltaBlue$.Constraint]], |
426 newMark: [core.int, []], | 485 newMark: [core.int, []], |
427 makePlan: [Plan, [core.List$(Constraint)]], | 486 makePlan: [DeltaBlue$.Plan, [core.List$(DeltaBlue$.Constraint)]], |
428 extractPlanFromConstraints: [Plan, [core.List$(Constraint)]], | 487 extractPlanFromConstraints: [DeltaBlue$.Plan, [core.List$(DeltaBlue$.Const
raint)]], |
429 addPropagate: [core.bool, [Constraint, core.int]], | 488 addPropagate: [core.bool, [DeltaBlue$.Constraint, core.int]], |
430 removePropagateFrom: [core.List$(Constraint), [Variable]], | 489 removePropagateFrom: [core.List$(DeltaBlue$.Constraint), [DeltaBlue$.Varia
ble]], |
431 addConstraintsConsumingTo: [dart.void, [Variable, core.List$(Constraint)]] | 490 addConstraintsConsumingTo: [dart.void, [DeltaBlue$.Variable, core.List$(De
ltaBlue$.Constraint)]] |
432 }) | 491 }) |
433 }); | 492 }); |
434 class Plan extends core.Object { | 493 DeltaBlue$.Plan = class Plan extends core.Object { |
435 Plan() { | 494 Plan() { |
436 this.list = dart.list([], Constraint); | 495 this.list = dart.list([], DeltaBlue$.Constraint); |
437 } | 496 } |
438 addConstraint(c) { | 497 addConstraint(c) { |
439 this.list[dartx.add](c); | 498 this.list[dartx.add](c); |
440 } | 499 } |
441 size() { | 500 size() { |
442 return this.list[dartx.length]; | 501 return this.list[dartx.length]; |
443 } | 502 } |
444 execute() { | 503 execute() { |
445 for (let i = 0; i < dart.notNull(this.list[dartx.length]); i++) { | 504 for (let i = 0; i < dart.notNull(this.list[dartx.length]); i++) { |
446 this.list[dartx.get](i).execute(); | 505 this.list[dartx.get](i).execute(); |
447 } | 506 } |
448 } | 507 } |
449 } | 508 }; |
450 dart.setSignature(Plan, { | 509 dart.setSignature(DeltaBlue$.Plan, { |
451 methods: () => ({ | 510 methods: () => ({ |
452 addConstraint: [dart.void, [Constraint]], | 511 addConstraint: [dart.void, [DeltaBlue$.Constraint]], |
453 size: [core.int, []], | 512 size: [core.int, []], |
454 execute: [dart.void, []] | 513 execute: [dart.void, []] |
455 }) | 514 }) |
456 }); | 515 }); |
457 function chainTest(n) { | 516 DeltaBlue$.chainTest = function(n) { |
458 exports.planner = new Planner(); | 517 DeltaBlue$.planner = new DeltaBlue$.Planner(); |
459 let prev = null, first = null, last = null; | 518 let prev = null, first = null, last = null; |
460 for (let i = 0; i <= dart.notNull(n); i++) { | 519 for (let i = 0; i <= dart.notNull(n); i++) { |
461 let v = new Variable("v", 0); | 520 let v = new DeltaBlue$.Variable("v", 0); |
462 if (prev != null) new EqualityConstraint(prev, v, REQUIRED); | 521 if (prev != null) new DeltaBlue$.EqualityConstraint(prev, v, DeltaBlue$.RE
QUIRED); |
463 if (i == 0) first = v; | 522 if (i == 0) first = v; |
464 if (i == n) last = v; | 523 if (i == n) last = v; |
465 prev = v; | 524 prev = v; |
466 } | 525 } |
467 new StayConstraint(last, STRONG_DEFAULT); | 526 new DeltaBlue$.StayConstraint(last, DeltaBlue$.STRONG_DEFAULT); |
468 let edit = new EditConstraint(first, PREFERRED); | 527 let edit = new DeltaBlue$.EditConstraint(first, DeltaBlue$.PREFERRED); |
469 let plan = exports.planner.extractPlanFromConstraints(dart.list([edit], Cons
traint)); | 528 let plan = DeltaBlue$.planner.extractPlanFromConstraints(dart.list([edit], D
eltaBlue$.Constraint)); |
470 for (let i = 0; i < 100; i++) { | 529 for (let i = 0; i < 100; i++) { |
471 first.value = i; | 530 first.value = i; |
472 plan.execute(); | 531 plan.execute(); |
473 if (last.value != i) { | 532 if (last.value != i) { |
474 core.print("Chain test failed:"); | 533 core.print("Chain test failed:"); |
475 core.print(`Expected last value to be ${i} but it was ${last.value}.`); | 534 core.print(`Expected last value to be ${i} but it was ${last.value}.`); |
476 } | 535 } |
477 } | 536 } |
478 } | 537 }; |
479 dart.fn(chainTest, dart.void, [core.int]); | 538 dart.fn(DeltaBlue$.chainTest, dart.void, [core.int]); |
480 function projectionTest(n) { | 539 DeltaBlue$.projectionTest = function(n) { |
481 exports.planner = new Planner(); | 540 DeltaBlue$.planner = new DeltaBlue$.Planner(); |
482 let scale = new Variable("scale", 10); | 541 let scale = new DeltaBlue$.Variable("scale", 10); |
483 let offset = new Variable("offset", 1000); | 542 let offset = new DeltaBlue$.Variable("offset", 1000); |
484 let src = null, dst = null; | 543 let src = null, dst = null; |
485 let dests = dart.list([], Variable); | 544 let dests = dart.list([], DeltaBlue$.Variable); |
486 for (let i = 0; i < dart.notNull(n); i++) { | 545 for (let i = 0; i < dart.notNull(n); i++) { |
487 src = new Variable("src", i); | 546 src = new DeltaBlue$.Variable("src", i); |
488 dst = new Variable("dst", i); | 547 dst = new DeltaBlue$.Variable("dst", i); |
489 dests[dartx.add](dst); | 548 dests[dartx.add](dst); |
490 new StayConstraint(src, NORMAL); | 549 new DeltaBlue$.StayConstraint(src, DeltaBlue$.NORMAL); |
491 new ScaleConstraint(src, scale, offset, dst, REQUIRED); | 550 new DeltaBlue$.ScaleConstraint(src, scale, offset, dst, DeltaBlue$.REQUIRE
D); |
492 } | 551 } |
493 change(src, 17); | 552 DeltaBlue$.change(src, 17); |
494 if (dst.value != 1170) core.print("Projection 1 failed"); | 553 if (dst.value != 1170) core.print("Projection 1 failed"); |
495 change(dst, 1050); | 554 DeltaBlue$.change(dst, 1050); |
496 if (src.value != 5) core.print("Projection 2 failed"); | 555 if (src.value != 5) core.print("Projection 2 failed"); |
497 change(scale, 5); | 556 DeltaBlue$.change(scale, 5); |
498 for (let i = 0; i < dart.notNull(n) - 1; i++) { | 557 for (let i = 0; i < dart.notNull(n) - 1; i++) { |
499 if (dests[dartx.get](i).value != i * 5 + 1000) core.print("Projection 3 fa
iled"); | 558 if (dests[dartx.get](i).value != i * 5 + 1000) core.print("Projection 3 fa
iled"); |
500 } | 559 } |
501 change(offset, 2000); | 560 DeltaBlue$.change(offset, 2000); |
502 for (let i = 0; i < dart.notNull(n) - 1; i++) { | 561 for (let i = 0; i < dart.notNull(n) - 1; i++) { |
503 if (dests[dartx.get](i).value != i * 5 + 2000) core.print("Projection 4 fa
iled"); | 562 if (dests[dartx.get](i).value != i * 5 + 2000) core.print("Projection 4 fa
iled"); |
504 } | 563 } |
505 } | 564 }; |
506 dart.fn(projectionTest, dart.void, [core.int]); | 565 dart.fn(DeltaBlue$.projectionTest, dart.void, [core.int]); |
507 function change(v, newValue) { | 566 DeltaBlue$.change = function(v, newValue) { |
508 let edit = new EditConstraint(v, PREFERRED); | 567 let edit = new DeltaBlue$.EditConstraint(v, DeltaBlue$.PREFERRED); |
509 let plan = exports.planner.extractPlanFromConstraints(dart.list([edit], Edit
Constraint)); | 568 let plan = DeltaBlue$.planner.extractPlanFromConstraints(dart.list([edit], D
eltaBlue$.EditConstraint)); |
510 for (let i = 0; i < 10; i++) { | 569 for (let i = 0; i < 10; i++) { |
511 v.value = newValue; | 570 v.value = newValue; |
512 plan.execute(); | 571 plan.execute(); |
513 } | 572 } |
514 edit.destroyConstraint(); | 573 edit.destroyConstraint(); |
515 } | 574 }; |
516 dart.fn(change, dart.void, [Variable, core.int]); | 575 dart.fn(DeltaBlue$.change, dart.void, [DeltaBlue$.Variable, core.int]); |
517 exports.planner = null; | 576 DeltaBlue$.planner = null; |
| 577 BenchmarkBase$.Expect = class Expect extends core.Object { |
| 578 static equals(expected, actual) { |
| 579 if (!dart.equals(expected, actual)) { |
| 580 dart.throw(`Values not equal: ${expected} vs ${actual}`); |
| 581 } |
| 582 } |
| 583 static listEquals(expected, actual) { |
| 584 if (expected[dartx.length] != actual[dartx.length]) { |
| 585 dart.throw(`Lists have different lengths: ${expected[dartx.length]} vs $
{actual[dartx.length]}`); |
| 586 } |
| 587 for (let i = 0; i < dart.notNull(actual[dartx.length]); i++) { |
| 588 BenchmarkBase$.Expect.equals(expected[dartx.get](i), actual[dartx.get](i
)); |
| 589 } |
| 590 } |
| 591 fail(message) { |
| 592 dart.throw(message); |
| 593 } |
| 594 }; |
| 595 dart.setSignature(BenchmarkBase$.Expect, { |
| 596 methods: () => ({fail: [dart.dynamic, [dart.dynamic]]}), |
| 597 statics: () => ({ |
| 598 equals: [dart.void, [dart.dynamic, dart.dynamic]], |
| 599 listEquals: [dart.void, [core.List, core.List]] |
| 600 }), |
| 601 names: ['equals', 'listEquals'] |
| 602 }); |
518 // Exports: | 603 // Exports: |
519 exports.main = main; | 604 exports.DeltaBlue = DeltaBlue$; |
520 exports.DeltaBlue = DeltaBlue; | 605 exports.BenchmarkBase = BenchmarkBase$; |
521 exports.Strength = Strength; | |
522 exports.REQUIRED = REQUIRED; | |
523 exports.STRONG_PREFERRED = STRONG_PREFERRED; | |
524 exports.PREFERRED = PREFERRED; | |
525 exports.STRONG_DEFAULT = STRONG_DEFAULT; | |
526 exports.NORMAL = NORMAL; | |
527 exports.WEAK_DEFAULT = WEAK_DEFAULT; | |
528 exports.WEAKEST = WEAKEST; | |
529 exports.Constraint = Constraint; | |
530 exports.UnaryConstraint = UnaryConstraint; | |
531 exports.StayConstraint = StayConstraint; | |
532 exports.EditConstraint = EditConstraint; | |
533 exports.NONE = NONE; | |
534 exports.FORWARD = FORWARD; | |
535 exports.BACKWARD = BACKWARD; | |
536 exports.BinaryConstraint = BinaryConstraint; | |
537 exports.ScaleConstraint = ScaleConstraint; | |
538 exports.EqualityConstraint = EqualityConstraint; | |
539 exports.Variable = Variable; | |
540 exports.Planner = Planner; | |
541 exports.Plan = Plan; | |
542 exports.chainTest = chainTest; | |
543 exports.projectionTest = projectionTest; | |
544 exports.change = change; | |
545 }); | 606 }); |
OLD | NEW |