@@ -18,7 +18,7 @@ class Strength extends core::Object {
1818 : self::Strength::value = value, self::Strength::name = name, super core::Object::•()
1919 ;
2020 method nextWeaker() → self::Strength
21- return const <self::Strength>[self::STRONG_PREFERRED, self::PREFERRED, self::STRONG_DEFAULT, self::NORMAL, self::WEAK_DEFAULT, self::WEAKEST] .{core::List::[]}(this.{self::Strength::value});
21+ return (#C19) .{core::List::[]}(this.{self::Strength::value});
2222 static method stronger(self::Strength s1, self::Strength s2) → core::bool {
2323 return s1.{self::Strength::value}.{core::num::<}(s2.{self::Strength::value});
2424 }
@@ -54,7 +54,7 @@ abstract class Constraint extends core::Object {
5454 method satisfy(dynamic mark) → self::Constraint {
5555 this.{self::Constraint::chooseMethod}(mark as{TypeError} core::int);
5656 if(!this.{self::Constraint::isSatisfied}()) {
57- if(this.{self::Constraint::strength}.{core::Object::==}(self::REQUIRED )) {
57+ if(this.{self::Constraint::strength}.{core::Object::==}(#C22 )) {
5858 core::print("Could not satisfy a required constraint!");
5959 }
6060 return null;
@@ -131,39 +131,39 @@ class EditConstraint extends self::UnaryConstraint {
131131abstract class BinaryConstraint extends self::Constraint {
132132 field self::Variable v1;
133133 field self::Variable v2;
134- field core::int direction = self::NONE ;
134+ field core::int direction = #C1 ;
135135 constructor •(self::Variable v1, self::Variable v2, self::Strength strength) → self::BinaryConstraint
136136 : self::BinaryConstraint::v1 = v1, self::BinaryConstraint::v2 = v2, super self::Constraint::•(strength) {
137137 this.{self::Constraint::addConstraint}();
138138 }
139139 method chooseMethod(core::int mark) → void {
140140 if(this.{self::BinaryConstraint::v1}.{self::Variable::mark}.{core::num::==}(mark)) {
141- this.{self::BinaryConstraint::direction} = !this.{self::BinaryConstraint::v2}.{self::Variable::mark}.{core::num::==}(mark) && self::Strength::stronger(this.{self::Constraint::strength}, this.{self::BinaryConstraint::v2}.{self::Variable::walkStrength}) ?{core::int} self::FORWARD : self::NONE ;
141+ this.{self::BinaryConstraint::direction} = !this.{self::BinaryConstraint::v2}.{self::Variable::mark}.{core::num::==}(mark) && self::Strength::stronger(this.{self::Constraint::strength}, this.{self::BinaryConstraint::v2}.{self::Variable::walkStrength}) ?{core::int} #C4 : #C1 ;
142142 }
143143 if(this.{self::BinaryConstraint::v2}.{self::Variable::mark}.{core::num::==}(mark)) {
144- this.{self::BinaryConstraint::direction} = !this.{self::BinaryConstraint::v1}.{self::Variable::mark}.{core::num::==}(mark) && self::Strength::stronger(this.{self::Constraint::strength}, this.{self::BinaryConstraint::v1}.{self::Variable::walkStrength}) ?{core::int} self::BACKWARD : self::NONE ;
144+ this.{self::BinaryConstraint::direction} = !this.{self::BinaryConstraint::v1}.{self::Variable::mark}.{core::num::==}(mark) && self::Strength::stronger(this.{self::Constraint::strength}, this.{self::BinaryConstraint::v1}.{self::Variable::walkStrength}) ?{core::int} #C20 : #C1 ;
145145 }
146146 if(self::Strength::weaker(this.{self::BinaryConstraint::v1}.{self::Variable::walkStrength}, this.{self::BinaryConstraint::v2}.{self::Variable::walkStrength})) {
147- this.{self::BinaryConstraint::direction} = self::Strength::stronger(this.{self::Constraint::strength}, this.{self::BinaryConstraint::v1}.{self::Variable::walkStrength}) ?{core::int} self::BACKWARD : self::NONE ;
147+ this.{self::BinaryConstraint::direction} = self::Strength::stronger(this.{self::Constraint::strength}, this.{self::BinaryConstraint::v1}.{self::Variable::walkStrength}) ?{core::int} #C20 : #C1 ;
148148 }
149149 else {
150- this.{self::BinaryConstraint::direction} = self::Strength::stronger(this.{self::Constraint::strength}, this.{self::BinaryConstraint::v2}.{self::Variable::walkStrength}) ?{core::int} self::FORWARD : self::BACKWARD ;
150+ this.{self::BinaryConstraint::direction} = self::Strength::stronger(this.{self::Constraint::strength}, this.{self::BinaryConstraint::v2}.{self::Variable::walkStrength}) ?{core::int} #C4 : #C20 ;
151151 }
152152 }
153153 method addToGraph() → void {
154154 this.{self::BinaryConstraint::v1}.{self::Variable::addConstraint}(this);
155155 this.{self::BinaryConstraint::v2}.{self::Variable::addConstraint}(this);
156- this.{self::BinaryConstraint::direction} = self::NONE ;
156+ this.{self::BinaryConstraint::direction} = #C1 ;
157157 }
158158 method isSatisfied() → core::bool
159- return !this.{self::BinaryConstraint::direction}.{core::num::==}(self::NONE );
159+ return !this.{self::BinaryConstraint::direction}.{core::num::==}(#C1 );
160160 method markInputs(core::int mark) → void {
161161 this.{self::BinaryConstraint::input}().{self::Variable::mark} = mark;
162162 }
163163 method input() → self::Variable
164- return this.{self::BinaryConstraint::direction}.{core::num::==}(self::FORWARD ) ?{self::Variable} this.{self::BinaryConstraint::v1} : this.{self::BinaryConstraint::v2};
164+ return this.{self::BinaryConstraint::direction}.{core::num::==}(#C4 ) ?{self::Variable} this.{self::BinaryConstraint::v1} : this.{self::BinaryConstraint::v2};
165165 method output() → self::Variable
166- return this.{self::BinaryConstraint::direction}.{core::num::==}(self::FORWARD ) ?{self::Variable} this.{self::BinaryConstraint::v2} : this.{self::BinaryConstraint::v1};
166+ return this.{self::BinaryConstraint::direction}.{core::num::==}(#C4 ) ?{self::Variable} this.{self::BinaryConstraint::v2} : this.{self::BinaryConstraint::v1};
167167 method recalculate() → void {
168168 self::Variable ihn = this.{self::BinaryConstraint::input}();
169169 self::Variable out = this.{self::BinaryConstraint::output}();
@@ -173,7 +173,7 @@ abstract class BinaryConstraint extends self::Constraint {
173173 this.{self::Constraint::execute}();
174174 }
175175 method markUnsatisfied() → void {
176- this.{self::BinaryConstraint::direction} = self::NONE ;
176+ this.{self::BinaryConstraint::direction} = #C1 ;
177177 }
178178 method inputsKnown(core::int mark) → core::bool {
179179 self::Variable i = this.{self::BinaryConstraint::input}();
@@ -184,7 +184,7 @@ abstract class BinaryConstraint extends self::Constraint {
184184 this.{self::BinaryConstraint::v1}.{self::Variable::removeConstraint}(this);
185185 if(!this.{self::BinaryConstraint::v2}.{core::Object::==}(null))
186186 this.{self::BinaryConstraint::v2}.{self::Variable::removeConstraint}(this);
187- this.{self::BinaryConstraint::direction} = self::NONE ;
187+ this.{self::BinaryConstraint::direction} = #C1 ;
188188 }
189189}
190190class ScaleConstraint extends self::BinaryConstraint {
@@ -210,7 +210,7 @@ class ScaleConstraint extends self::BinaryConstraint {
210210 this.{self::ScaleConstraint::scale}.{self::Variable::mark} = this.{self::ScaleConstraint::offset}.{self::Variable::mark} = mark;
211211 }
212212 method execute() → void {
213- if(this.{self::BinaryConstraint::direction}.{core::num::==}(self::FORWARD )) {
213+ if(this.{self::BinaryConstraint::direction}.{core::num::==}(#C4 )) {
214214 this.{self::BinaryConstraint::v2}.{self::Variable::value} = this.{self::BinaryConstraint::v1}.{self::Variable::value}.{core::num::*}(this.{self::ScaleConstraint::scale}.{self::Variable::value}).{core::num::+}(this.{self::ScaleConstraint::offset}.{self::Variable::value});
215215 }
216216 else {
@@ -238,7 +238,7 @@ class Variable extends core::Object {
238238 field core::List<self::Constraint> constraints = <self::Constraint>[];
239239 field self::Constraint determinedBy = null;
240240 field core::int mark = 0;
241- field self::Strength walkStrength = self::WEAKEST ;
241+ field self::Strength walkStrength = #C18 ;
242242 field core::bool stay = true;
243243 field core::int value;
244244 final field core::String name;
@@ -269,7 +269,7 @@ class Planner extends core::Object {
269269 c.{self::Constraint::markUnsatisfied}();
270270 c.{self::Constraint::removeFromGraph}();
271271 core::List<self::Constraint> unsatisfied = this.{self::Planner::removePropagateFrom}(out);
272- self::Strength strength = self::REQUIRED ;
272+ self::Strength strength = #C22 ;
273273 do {
274274 for (core::int i = 0; i.{core::num::<}(unsatisfied.{core::List::length}); i = i.{core::num::+}(1)) {
275275 self::Constraint u = unsatisfied.{core::List::[]}(i);
@@ -278,7 +278,7 @@ class Planner extends core::Object {
278278 }
279279 strength = strength.{self::Strength::nextWeaker}();
280280 }
281- while (!strength.{core::Object::==}(self::WEAKEST ))
281+ while (!strength.{core::Object::==}(#C18 ))
282282 }
283283 method newMark() → core::int
284284 return this.{self::Planner::currentMark} = this.{self::Planner::currentMark}.{core::num::+}(1);
@@ -320,7 +320,7 @@ class Planner extends core::Object {
320320 }
321321 method removePropagateFrom(self::Variable out) → core::List<self::Constraint> {
322322 out.{self::Variable::determinedBy} = null;
323- out.{self::Variable::walkStrength} = self::WEAKEST ;
323+ out.{self::Variable::walkStrength} = #C18 ;
324324 out.{self::Variable::stay} = true;
325325 core::List<self::Constraint> unsatisfied = <self::Constraint>[];
326326 core::List<self::Variable> todo = <self::Variable>[out];
@@ -367,16 +367,16 @@ class Plan extends core::Object {
367367 }
368368 }
369369}
370- static const field self::Strength REQUIRED = const self::Strength::•(0, "required") ;
371- static const field self::Strength STRONG_PREFERRED = const self::Strength::•(1, "strongPreferred") ;
372- static const field self::Strength PREFERRED = const self::Strength::•(2, "preferred") ;
373- static const field self::Strength STRONG_DEFAULT = const self::Strength::•(3, "strongDefault") ;
374- static const field self::Strength NORMAL = const self::Strength::•(4, "normal") ;
375- static const field self::Strength WEAK_DEFAULT = const self::Strength::•(5, "weakDefault") ;
376- static const field self::Strength WEAKEST = const self::Strength::•(6, "weakest") ;
377- static const field core::int NONE = 1 ;
378- static const field core::int FORWARD = 2 ;
379- static const field core::int BACKWARD = 0 ;
370+ static const field self::Strength REQUIRED = #C22 ;
371+ static const field self::Strength STRONG_PREFERRED = #C3 ;
372+ static const field self::Strength PREFERRED = #C6 ;
373+ static const field self::Strength STRONG_DEFAULT = #C9 ;
374+ static const field self::Strength NORMAL = #C12 ;
375+ static const field self::Strength WEAK_DEFAULT = #C15 ;
376+ static const field self::Strength WEAKEST = #C18 ;
377+ static const field core::int NONE = #C1 ;
378+ static const field core::int FORWARD = #C4 ;
379+ static const field core::int BACKWARD = #C20 ;
380380static field self::Planner planner;
381381static method main() → dynamic {
382382 new self::DeltaBlue::•().{self::DeltaBlue::run}();
@@ -389,15 +389,15 @@ static method chainTest(core::int n) → void {
389389 for (core::int i = 0; i.{core::num::<=}(n); i = i.{core::num::+}(1)) {
390390 self::Variable v = new self::Variable::•("v${i}", 0);
391391 if(!prev.{core::Object::==}(null))
392- new self::EqualityConstraint::•(prev, v, self::REQUIRED );
392+ new self::EqualityConstraint::•(prev, v, #C22 );
393393 if(i.{core::num::==}(0))
394394 first = v;
395395 if(i.{core::num::==}(n))
396396 last = v;
397397 prev = v;
398398 }
399- new self::StayConstraint::•(last, self::STRONG_DEFAULT );
400- self::EditConstraint edit = new self::EditConstraint::•(first, self::PREFERRED );
399+ new self::StayConstraint::•(last, #C9 );
400+ self::EditConstraint edit = new self::EditConstraint::•(first, #C6 );
401401 self::Plan plan = self::planner.{self::Planner::extractPlanFromConstraints}(<self::Constraint>[edit]);
402402 for (core::int i = 0; i.{core::num::<}(100); i = i.{core::num::+}(1)) {
403403 first.{self::Variable::value} = i;
@@ -419,8 +419,8 @@ static method projectionTest(core::int n) → void {
419419 src = new self::Variable::•("src", i);
420420 dst = new self::Variable::•("dst", i);
421421 dests.{core::List::add}(dst);
422- new self::StayConstraint::•(src, self::NORMAL );
423- new self::ScaleConstraint::•(src, scale, offset, dst, self::REQUIRED );
422+ new self::StayConstraint::•(src, #C12 );
423+ new self::ScaleConstraint::•(src, scale, offset, dst, #C22 );
424424 }
425425 self::change(src, 17);
426426 if(!dst.{self::Variable::value}.{core::num::==}(1170))
@@ -440,11 +440,36 @@ static method projectionTest(core::int n) → void {
440440 }
441441}
442442static method change(self::Variable v, core::int newValue) → void {
443- self::EditConstraint edit = new self::EditConstraint::•(v, self::PREFERRED );
443+ self::EditConstraint edit = new self::EditConstraint::•(v, #C6 );
444444 self::Plan plan = self::planner.{self::Planner::extractPlanFromConstraints}(<self::EditConstraint>[edit]);
445445 for (core::int i = 0; i.{core::num::<}(10); i = i.{core::num::+}(1)) {
446446 v.{self::Variable::value} = newValue;
447447 plan.{self::Plan::execute}();
448448 }
449449 edit.{self::Constraint::destroyConstraint}();
450450}
451+
452+ constants {
453+ #C1 = 1
454+ #C2 = "strongPreferred"
455+ #C3 = self::Strength {value:#C1, name:#C2}
456+ #C4 = 2
457+ #C5 = "preferred"
458+ #C6 = self::Strength {value:#C4, name:#C5}
459+ #C7 = 3
460+ #C8 = "strongDefault"
461+ #C9 = self::Strength {value:#C7, name:#C8}
462+ #C10 = 4
463+ #C11 = "normal"
464+ #C12 = self::Strength {value:#C10, name:#C11}
465+ #C13 = 5
466+ #C14 = "weakDefault"
467+ #C15 = self::Strength {value:#C13, name:#C14}
468+ #C16 = 6
469+ #C17 = "weakest"
470+ #C18 = self::Strength {value:#C16, name:#C17}
471+ #C19 = <self::Strength>[#C3, #C6, #C9, #C12, #C15, #C18]
472+ #C20 = 0
473+ #C21 = "required"
474+ #C22 = self::Strength {value:#C20, name:#C21}
475+ }
0 commit comments