Fix error handling in PDT evaluator.
This commit is contained in:
@@ -64,8 +64,10 @@ namespace Cryville.Common.Pdt {
|
||||
}
|
||||
else {
|
||||
var frame = _stack[_framecount - 1];
|
||||
ReplaceIP(il, new PdtInstruction.PushConstant(frame.Type, _mem, frame.Offset, frame.Length), cols);
|
||||
for (var j = 0; j < fc1; j++) il.Remove(_ip.Previous);
|
||||
if (frame.Type != PdtInternalType.Error) {
|
||||
ReplaceIP(il, new PdtInstruction.PushConstant(frame.Type, _mem, frame.Offset, frame.Length), cols);
|
||||
for (var j = 0; j < fc1; j++) il.Remove(_ip.Previous);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (i is PdtInstruction.Collapse) {
|
||||
@@ -197,7 +199,7 @@ namespace Cryville.Common.Pdt {
|
||||
for (int i = 0; i < pc; i++) {
|
||||
var frame = _stack[--_framecount];
|
||||
if (frame.Type == PdtInternalType.Error) {
|
||||
_framecount -= pc - i;
|
||||
_framecount -= pc - i - 1;
|
||||
_stack[_framecount++] = new StackFrame { Type = PdtInternalType.Error, Offset = _goffset, Length = 0 };
|
||||
return false;
|
||||
}
|
||||
|
@@ -189,13 +189,15 @@ namespace Cryville.Crtr {
|
||||
SkinVariable v;
|
||||
if (!vars.TryGetValue(Name, out v))
|
||||
vars.Add(Name, v = new SkinVariable());
|
||||
ChartPlayer.etor.Evaluate(v.Op, exp);
|
||||
if (!ChartPlayer.etor.Evaluate(v.Op, exp))
|
||||
throw new EvaluationFailureException();
|
||||
}
|
||||
public override void ExecuteDynamic(ISkinnableGroup group, RuntimeSkinContext ctx, PdtExpression exp, IntKeyedDictionary<SkinVariable> vars, int dl) {
|
||||
SkinVariable v;
|
||||
if (!vars.TryGetValue(Name, out v))
|
||||
throw new InvalidOperationException(string.Format("Variable \"{0}\" not defined", IdentifierManager.SharedInstance.Retrieve(Name)));
|
||||
ChartPlayer.etor.Evaluate(v.Op, exp);
|
||||
if (!ChartPlayer.etor.Evaluate(v.Op, exp))
|
||||
throw new EvaluationFailureException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -131,7 +131,8 @@ namespace Cryville.Crtr {
|
||||
public SkinContext Match(SkinContext a) {
|
||||
ChartPlayer.etor.ContextTransform = a.Transform;
|
||||
try {
|
||||
ChartPlayer.etor.Evaluate(_op, _exp);
|
||||
if (!ChartPlayer.etor.Evaluate(_op, _exp))
|
||||
throw new EvaluationFailureException();
|
||||
return _flag ? a : null;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
|
Reference in New Issue
Block a user