Make the output type of a property source read-only.

This commit is contained in:
2023-01-16 20:53:45 +08:00
parent 9d6bdd968f
commit 5b9149cb34
8 changed files with 76 additions and 56 deletions

View File

@@ -32,7 +32,7 @@ namespace Cryville.Crtr {
}
else if (ContextState != null && ChartPlayer.motionRegistry.ContainsKey(id)) {
var vec = ContextState.GetRawValue(id);
new VectorSrc(() => vec).Get(out type, out value);
VectorSrc.Construct(() => vec).Get(out type, out value);
}
else if (ContextJudge != null && ContextJudge.TryGetScoreSrc(name, out prop)) {
prop.Get(out type, out value);
@@ -43,7 +43,7 @@ namespace Cryville.Crtr {
RevokePotentialConstant();
}
else {
PropSrc.Arbitrary result = ContextCascadeLookup(name);
PropSrc result = ContextCascadeLookup(name);
if (result != null) {
result.Get(out type, out value);
}
@@ -103,22 +103,22 @@ namespace Cryville.Crtr {
public Judge ContextJudge { private get; set; }
public PropSrc ContextSelfValue { private get; set; }
readonly Dictionary<int, PropSrc.Arbitrary>[] ContextCascade = new Dictionary<int, PropSrc.Arbitrary>[256];
readonly Dictionary<int, PropSrc>[] ContextCascade = new Dictionary<int, PropSrc>[256];
int _cascadeHeight;
public void ContextCascadeInsert() {
ContextCascade[_cascadeHeight++].Clear();
}
public void ContextCascadeInsert(Dictionary<int, PropSrc.Arbitrary> srcs) {
public void ContextCascadeInsert(Dictionary<int, PropSrc> srcs) {
ContextCascadeInsert();
foreach (var src in srcs) ContextCascadeUpdate(src.Key, src.Value);
}
public void ContextCascadeUpdate(int key, PropSrc.Arbitrary value) {
public void ContextCascadeUpdate(int key, PropSrc value) {
ContextCascade[_cascadeHeight - 1][key] = value;
}
public PropSrc.Arbitrary ContextCascadeLookup(int name) {
PropSrc.Arbitrary result;
public PropSrc ContextCascadeLookup(int name) {
PropSrc result;
for (int i = _cascadeHeight - 1; i >= 0; i--) {
Dictionary<int, PropSrc.Arbitrary> cas = ContextCascade[i];
Dictionary<int, PropSrc> cas = ContextCascade[i];
if (cas.TryGetValue(name, out result)) {
return result;
}
@@ -130,7 +130,7 @@ namespace Cryville.Crtr {
}
public PdtEvaluator() {
for (int i = 0; i < ContextCascade.Length; i++) ContextCascade[i] = new Dictionary<int, PropSrc.Arbitrary>();
for (int i = 0; i < ContextCascade.Length; i++) ContextCascade[i] = new Dictionary<int, PropSrc>();
_ctxops.Add(IdentifierManager.SharedInstance.Request("screen_edge"), new func_screen_edge(() => ContextTransform));
_ctxops.Add(IdentifierManager.SharedInstance.Request("int"), new func_int(() => ContextSelfValue));