Code cleanup.

This commit is contained in:
2023-02-18 14:46:08 +08:00
parent 274a823d02
commit a1f7418d32
10 changed files with 78 additions and 66 deletions

View File

@@ -34,23 +34,26 @@ namespace Cryville.Crtr {
public Dictionary<Identifier, ScoreDefinition> scores;
public Constraint constraints;
public void Optimize(PdtEvaluatorBase etor) {
foreach (var i in inputs.Values) {
if (i.pass != null) foreach (var e in i.pass.Values) {
etor.Optimize(e);
foreach (var i in inputs) {
var input = i.Value;
if (input.pass != null) foreach (var e in input.pass) {
etor.Optimize(e.Value);
}
}
foreach (var j in judges.Values) {
if (j.hit != null) etor.Optimize(j.hit);
if (j.scores != null) {
foreach (var s in j.scores) {
foreach (var j in judges) {
var judge = j.Value;
if (judge.hit != null) etor.Optimize(judge.hit);
if (judge.scores != null) {
foreach (var s in judge.scores) {
if (s.Key.op != default(Identifier))
etor.PatchCompound(s.Key.name.Key, s.Key.op.Key, s.Value);
etor.Optimize(s.Value);
}
}
}
foreach (var s in scores.Values) {
if (s.value != null) etor.Optimize(s.value);
foreach (var s in scores) {
var score = s.Value;
if (score.value != null) etor.Optimize(score.value);
}
constraints.Optimize(etor);
}
@@ -65,8 +68,8 @@ namespace Cryville.Crtr {
[PropertyList]
public Dictionary<PropertyKey, PdtExpression> Properties = new Dictionary<PropertyKey, PdtExpression>();
public void Optimize(PdtEvaluatorBase etor) {
foreach (var e in Properties.Values) {
etor.Optimize(e);
foreach (var e in Properties) {
etor.Optimize(e.Value);
}
foreach (var e in Elements) {
e.Key.Optimize(etor);