Implement optimization for collapse instruction.

This commit is contained in:
2022-10-30 01:39:22 +08:00
parent 0a0be73ea7
commit 13131b0f31
4 changed files with 84 additions and 5 deletions

View File

@@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;
using System.Xml.Linq;
namespace Cryville.Crtr {
public class Ruleset {
@@ -35,6 +36,24 @@ namespace Cryville.Crtr {
public Dictionary<string, JudgeDefinition> judges;
public Dictionary<string, 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 j in judges.Values) {
if (j.clip != null) etor.Optimize(j.clip);
if (j.hit != null) etor.Optimize(j.hit);
if (j.scores != null) foreach (var e in j.scores.Values) {
etor.Optimize(e);
}
}
foreach (var s in scores.Values) {
if (s.value != null) etor.Optimize(s.value);
}
constraints.Optimize(etor);
}
public void PrePatch(Chart chart) {
constraints.PrePatch(chart);
}
@@ -54,6 +73,15 @@ namespace Cryville.Crtr {
public Dictionary<RulesetSelectors, Constraint> Elements = new Dictionary<RulesetSelectors, Constraint>();
[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 Elements) {
e.Key.Optimize(etor);
e.Value.Optimize(etor);
}
}
public void PrePatch(ChartEvent ev) {
var etor = ChartPlayer.etor;
PropSrc src;