Add context cascade blocking.

This commit is contained in:
2023-02-18 14:48:43 +08:00
parent 13893b2853
commit 6bd32c9aef

View File

@@ -104,6 +104,13 @@ namespace Cryville.Crtr {
public Judge ContextJudge { private get; set; }
public PropSrc ContextSelfValue { private get; set; }
readonly Stack<int> ContextCascadeBlocks = new Stack<int>();
public void ContextCascadeInsertBlock() {
ContextCascadeBlocks.Push(_cascadeHeight);
}
public void ContextCascadeDiscardBlock() {
ContextCascadeBlocks.Pop();
}
readonly Dictionary<int, PropSrc>[] ContextCascade = new Dictionary<int, PropSrc>[256];
int _cascadeHeight;
public void ContextCascadeInsert() {
@@ -118,7 +125,7 @@ namespace Cryville.Crtr {
}
public PropSrc ContextCascadeLookup(int name) {
PropSrc result;
for (int i = _cascadeHeight - 1; i >= 0; i--) {
for (int i = _cascadeHeight - 1; i >= ContextCascadeBlocks.Peek(); i--) {
Dictionary<int, PropSrc> cas = ContextCascade[i];
if (cas.TryGetValue(name, out result)) {
return result;
@@ -131,6 +138,7 @@ namespace Cryville.Crtr {
}
public PdtEvaluator() {
ContextCascadeBlocks.Push(0);
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));