mantis 6199 and 6872: Yengine will now error at compile tme if state name not found. Was doing it at runtime only. Xengine stays as it was

This commit is contained in:
UbitUmarov
2021-10-23 23:27:31 +01:00
parent 1bfd2ae1d8
commit 3f3a5da3a9

View File

@@ -2485,17 +2485,18 @@ namespace OpenSim.Region.ScriptEngine.Yengine
int index = 0; // 'default' state
// Set new state value by throwing an exception.
// These exceptions aren't catchable by script-level try { } catch { }.
if((stateStmt.state != null) && !stateIndices.TryGetValue(stateStmt.state.val, out index))
// Set new state value by throwing an exception.
// These exceptions aren't catchable by script-level try { } catch { }.
if ((stateStmt.state != null) && !stateIndices.TryGetValue(stateStmt.state.val, out index))
{
// The moron XEngine compiles scripts that reference undefined states.
// So rather than produce a compile-time error, we'll throw an exception at runtime.
// ErrorMsg (stateStmt, "undefined state " + stateStmt.state.val);
mightGetHere = false;
// do compile time error
ErrorMsg (stateStmt, "undefined state " + stateStmt.state.val);
throw new Exception("undefined state " + stateStmt.state.val);
// throw new UndefinedStateException (stateStmt.state.val);
ilGen.Emit(stateStmt, OpCodes.Ldstr, stateStmt.state.val);
ilGen.Emit(stateStmt, OpCodes.Newobj, scriptUndefinedStateExceptionConstructorInfo);
// before we did throw an exception only at runtime.
//ilGen.Emit(stateStmt, OpCodes.Ldstr, stateStmt.state.val);
//ilGen.Emit(stateStmt, OpCodes.Newobj, scriptUndefinedStateExceptionConstructorInfo);
}
else
{