Code cleanup.

This commit is contained in:
2023-05-19 00:46:45 +08:00
parent 5bed3cf05b
commit 0d0902735a
2 changed files with 6 additions and 5 deletions

View File

@@ -263,9 +263,9 @@ namespace Cryville.Crtr {
Monitor.Enter(_etor, ref locked); Monitor.Enter(_etor, ref locked);
InputProxyEntry proxy; InputProxyEntry proxy;
if (_sproxies.TryGetValue(id.Source, out proxy)) { if (_sproxies.TryGetValue(id.Source, out proxy)) {
_etor.ContextCascadeInsert();
float ft, tt = (float)GetSyncedTime(frame.Time, id.Source.Handler); float ft, tt = (float)GetSyncedTime(frame.Time, id.Source.Handler);
if (!_vect.TryGetValue(id, out ft)) ft = tt; if (!_vect.TryGetValue(id, out ft)) ft = tt;
_etor.ContextCascadeInsert();
if (frame.IsNull) { if (frame.IsNull) {
_etor.ContextCascadeUpdate(_var_input_vec, PropSrc.Null); _etor.ContextCascadeUpdate(_var_input_vec, PropSrc.Null);
OnInput(id, proxy.Target, ft, tt, true); OnInput(id, proxy.Target, ft, tt, true);
@@ -275,8 +275,8 @@ namespace Cryville.Crtr {
_etor.ContextCascadeUpdate(_var_input_vec, _vecsrcs[0]); _etor.ContextCascadeUpdate(_var_input_vec, _vecsrcs[0]);
OnInput(id, proxy.Target, ft, tt, false); OnInput(id, proxy.Target, ft, tt, false);
} }
_vect[id] = tt;
_etor.ContextCascadeDiscard(); _etor.ContextCascadeDiscard();
_vect[id] = tt;
} }
} }
finally { finally {
@@ -287,12 +287,13 @@ namespace Cryville.Crtr {
static readonly int _var_fv = IdentifierManager.Shared.Request("input_vec_from"); static readonly int _var_fv = IdentifierManager.Shared.Request("input_vec_from");
static readonly int _var_tv = IdentifierManager.Shared.Request("input_vec_to"); static readonly int _var_tv = IdentifierManager.Shared.Request("input_vec_to");
readonly InputVectorSrc _vecsrc = new InputVectorSrc(); readonly InputVectorSrc _vecsrc = new InputVectorSrc();
unsafe void OnInput(InputIdentifier id, Identifier target, float ft, float tt, bool nullFlag, int depth = 0) {
if (depth >= MAX_DEPTH) throw new InputProxyException("Input propagation limit reached\nThe ruleset has invalid input definitions"); if (depth >= MAX_DEPTH) throw new InputProxyException("Input propagation limit reached\nThe ruleset has invalid input definitions");
var def = _ruleset.inputs[target]; var def = _ruleset.inputs[target];
if (def.pass != null) { if (def.pass != null) {
foreach (var p in def.pass) { foreach (var p in def.pass) {
_etor.ContextCascadeInsert(); _etor.ContextCascadeInsert();
bool newNullFlag = nullflag; bool newNullFlag = nullFlag;
if (!newNullFlag) { if (!newNullFlag) {
_etor.Evaluate(_vecops[depth + 1], p.Value); _etor.Evaluate(_vecops[depth + 1], p.Value);
newNullFlag = _vecsrcs[depth + 1].IsNull; newNullFlag = _vecsrcs[depth + 1].IsNull;

View File

@@ -8,7 +8,7 @@ namespace Cryville.Crtr {
public RulesetInterpreter(string src, Binder binder) : base(src, binder) { } public RulesetInterpreter(string src, Binder binder) : base(src, binder) { }
readonly List<RulesetSelector> s = new List<RulesetSelector>(); readonly List<RulesetSelector> s = new List<RulesetSelector>();
readonly List<string> a = new List<string>(); readonly HashSet<string> a = new HashSet<string>();
protected override object InterpretKey(Type type) { protected override object InterpretKey(Type type) {
if (type == typeof(Constraint)) if (type == typeof(Constraint))
return InterpretConstraintKey(); return InterpretConstraintKey();
@@ -52,7 +52,7 @@ namespace Cryville.Crtr {
break; break;
} }
ws(); ws();
if (Position == pp) throw new FormatException("Invalid selector or key format"); if (Position == pp) throw new FormatException("Invalid selector or key format.");
} }
} }
} }