Skip to content

Commit 2432cdf

Browse files
committed
Updated Cilbox to latest branch
1 parent ff461f9 commit 2432cdf

2 files changed

Lines changed: 27 additions & 9 deletions

File tree

Basis/Packages/com.cnlohr.cilbox/Cilbox.cs

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,20 @@ public object Interpret( CilboxProxy ths, object [] parametersIn )
197197
try
198198
{
199199
ret = InterpretInner( stackBuffer, parameters ).AsObject();
200-
} catch( Exception e )
200+
}
201+
catch( Exception e )
201202
{
202203
parentClass.box.InterpreterExit();
204+
205+
if (e is CilboxUnhandledInterpretedException uhe)
206+
{
207+
// strip the throwee just in case, and re-throw a normal runtime exception
208+
string exceptionTypeName = uhe.Throwee?.GetType().FullName ?? "null";
209+
string reason = $"Exception of type {exceptionTypeName} was unhandled in interpreted code";
210+
parentClass.box.DisableWithReason(reason); // CilboxUnhandledInterpretedException bypasses the box disable
211+
throw new CilboxInterpreterRuntimeException(reason, uhe.ClassName, uhe.MethodName, uhe.PC);
212+
}
213+
203214
Debug.Log( e.ToString() );
204215
throw;
205216
}
@@ -1541,10 +1552,7 @@ private StackElement InterpretInner( ArraySegment<StackElement> stackBufferIn, A
15411552
catch( Exception e )
15421553
{
15431554
string fullError = $"Breakwarn: {e.ToString()} Class: {parentClass.className}, Function: {methodName}, Bytecode: {pc}";
1544-
Debug.LogError( fullError );
1545-
box.disabledReason = fullError;
1546-
box.disabled = true;
1547-
//box.InterpreterExit();
1555+
box.DisableWithReason(fullError);
15481556

15491557
if (e is CilboxInterpreterRuntimeException)
15501558
{
@@ -2328,6 +2336,14 @@ void Update()
23282336
{
23292337
usSpentLastFrame = Interlocked.Exchange( ref interpreterAccountingCumulitiveTicks, 0 ) / interpreterTicksInUs;
23302338
}
2339+
2340+
internal void DisableWithReason(string reason)
2341+
{
2342+
Debug.LogError( reason );
2343+
this.disabledReason = reason;
2344+
this.disabled = true;
2345+
//this.InterpreterExit();
2346+
}
23312347
}
23322348

23332349

@@ -3025,10 +3041,11 @@ public enum ImportFunctionID
30253041
Update,
30263042
Start,
30273043
Awake,
3028-
OnTriggerEnter,
3029-
OnTriggerExit,
30303044
OnEnable,
30313045
OnDisable,
3046+
OnDestroy,
3047+
OnTriggerEnter,
3048+
OnTriggerExit,
30323049
OnCollisionEnter,
30333050
OnCollisionExit
30343051
}

Basis/Packages/com.cnlohr.cilbox/CilboxProxy.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,10 +472,11 @@ void Start() {
472472
box.InterpretIID( cls, this, ImportFunctionID.Awake, null );
473473
box.InterpretIID( cls, this, ImportFunctionID.Start, null );
474474
}
475+
void FixedUpdate() { if( proxyWasSetup ) box.InterpretIID( cls, this, ImportFunctionID.FixedUpdate, null ); }
476+
void Update() { if( proxyWasSetup ) box.InterpretIID( cls, this, ImportFunctionID.Update, null ); }
475477
void OnEnable() { if( proxyWasSetup ) box.InterpretIID( cls, this, ImportFunctionID.OnEnable, null ); }
476478
void OnDisable() { if( proxyWasSetup ) box.InterpretIID( cls, this, ImportFunctionID.OnDisable, null ); }
477-
void Update() { if( proxyWasSetup ) box.InterpretIID( cls, this, ImportFunctionID.Update, null ); }
478-
void FixedUpdate() { if( proxyWasSetup ) box.InterpretIID( cls, this, ImportFunctionID.FixedUpdate, null ); }
479+
void OnDestroy() { if( proxyWasSetup ) box.InterpretIID( cls, this, ImportFunctionID.OnDestroy, null ); }
479480
void OnTriggerEnter(Collider c) { if (proxyWasSetup) box.InterpretIID(cls, this, ImportFunctionID.OnTriggerEnter, new object[] { c }); }
480481
void OnTriggerExit(Collider c) { if (proxyWasSetup) box.InterpretIID(cls, this, ImportFunctionID.OnTriggerExit, new object[] { c }); }
481482
void OnCollisionEnter(Collision c) { if (proxyWasSetup) box.InterpretIID(cls, this, ImportFunctionID.OnCollisionEnter, new object[] { c }); }

0 commit comments

Comments
 (0)