diff --git a/Basis/Packages/com.basis.shim/Shims/CilboxPropBasis.cs b/Basis/Packages/com.basis.shim/Shims/CilboxPropBasis.cs index fd860eeb4..789843206 100644 --- a/Basis/Packages/com.basis.shim/Shims/CilboxPropBasis.cs +++ b/Basis/Packages/com.basis.shim/Shims/CilboxPropBasis.cs @@ -68,6 +68,7 @@ public class CilboxPropBasis : Cilbox // Unity types "UnityEngine.Animator", + "UnityEngine.AnimatorStateInfo", "UnityEngine.AudioClip", "UnityEngine.AudioSource", "UnityEngine.Color", diff --git a/Basis/Packages/com.cnlohr.cilbox/Cilbox.cs b/Basis/Packages/com.cnlohr.cilbox/Cilbox.cs index b2d58a81e..d8a171ae0 100644 --- a/Basis/Packages/com.cnlohr.cilbox/Cilbox.cs +++ b/Basis/Packages/com.cnlohr.cilbox/Cilbox.cs @@ -197,9 +197,20 @@ public object Interpret( CilboxProxy ths, object [] parametersIn ) try { ret = InterpretInner( stackBuffer, parameters ).AsObject(); - } catch( Exception e ) + } + catch( Exception e ) { parentClass.box.InterpreterExit(); + + if (e is CilboxUnhandledInterpretedException uhe) + { + // strip the throwee just in case, and re-throw a normal runtime exception + string exceptionTypeName = uhe.Throwee?.GetType().FullName ?? "null"; + string reason = $"Exception of type {exceptionTypeName} was unhandled in interpreted code"; + parentClass.box.DisableWithReason(reason); // CilboxUnhandledInterpretedException bypasses the box disable + throw new CilboxInterpreterRuntimeException(reason, uhe.ClassName, uhe.MethodName, uhe.PC); + } + Debug.Log( e.ToString() ); throw; } @@ -1541,10 +1552,7 @@ private StackElement InterpretInner( ArraySegment stackBufferIn, A catch( Exception e ) { string fullError = $"Breakwarn: {e.ToString()} Class: {parentClass.className}, Function: {methodName}, Bytecode: {pc}"; - Debug.LogError( fullError ); - box.disabledReason = fullError; - box.disabled = true; - //box.InterpreterExit(); + box.DisableWithReason(fullError); if (e is CilboxInterpreterRuntimeException) { @@ -2328,6 +2336,14 @@ void Update() { usSpentLastFrame = Interlocked.Exchange( ref interpreterAccountingCumulitiveTicks, 0 ) / interpreterTicksInUs; } + + internal void DisableWithReason(string reason) + { + Debug.LogError( reason ); + this.disabledReason = reason; + this.disabled = true; + //this.InterpreterExit(); + } } @@ -3025,10 +3041,11 @@ public enum ImportFunctionID Update, Start, Awake, - OnTriggerEnter, - OnTriggerExit, OnEnable, OnDisable, + OnDestroy, + OnTriggerEnter, + OnTriggerExit, OnCollisionEnter, OnCollisionExit } diff --git a/Basis/Packages/com.cnlohr.cilbox/CilboxProxy.cs b/Basis/Packages/com.cnlohr.cilbox/CilboxProxy.cs index 5f356c133..609a65f54 100644 --- a/Basis/Packages/com.cnlohr.cilbox/CilboxProxy.cs +++ b/Basis/Packages/com.cnlohr.cilbox/CilboxProxy.cs @@ -472,10 +472,11 @@ void Start() { box.InterpretIID( cls, this, ImportFunctionID.Awake, null ); box.InterpretIID( cls, this, ImportFunctionID.Start, null ); } + void FixedUpdate() { if( proxyWasSetup ) box.InterpretIID( cls, this, ImportFunctionID.FixedUpdate, null ); } + void Update() { if( proxyWasSetup ) box.InterpretIID( cls, this, ImportFunctionID.Update, null ); } void OnEnable() { if( proxyWasSetup ) box.InterpretIID( cls, this, ImportFunctionID.OnEnable, null ); } void OnDisable() { if( proxyWasSetup ) box.InterpretIID( cls, this, ImportFunctionID.OnDisable, null ); } - void Update() { if( proxyWasSetup ) box.InterpretIID( cls, this, ImportFunctionID.Update, null ); } - void FixedUpdate() { if( proxyWasSetup ) box.InterpretIID( cls, this, ImportFunctionID.FixedUpdate, null ); } + void OnDestroy() { if( proxyWasSetup ) box.InterpretIID( cls, this, ImportFunctionID.OnDestroy, null ); } void OnTriggerEnter(Collider c) { if (proxyWasSetup) box.InterpretIID(cls, this, ImportFunctionID.OnTriggerEnter, new object[] { c }); } void OnTriggerExit(Collider c) { if (proxyWasSetup) box.InterpretIID(cls, this, ImportFunctionID.OnTriggerExit, new object[] { c }); } void OnCollisionEnter(Collision c) { if (proxyWasSetup) box.InterpretIID(cls, this, ImportFunctionID.OnCollisionEnter, new object[] { c }); }