public override object Execute(ProtoCore.Runtime.Context c, Interpreter dsi) { List <StackValue> s = dsi.runtime.rmem.Stack; FFIObjectMarshler marshaller = Module.GetMarshaller(dsi.runtime.RuntimeCore); Object retVal = null; if (ReflectionInfo.IsWrapperOf(CLRModuleType.DisposeMethod)) { // For those FFI objects that are disposable but don't provide // Dispose() method in their classes, they will share a same // Dispose() method from CLRModuleType.DisposeMethod. We need // to manually dispose them. var thisObject = marshaller.UnMarshal(s.Last(), c, dsi, typeof(IDisposable)); if (thisObject != null && thisObject is IDisposable) { var disposable = thisObject as IDisposable; disposable.Dispose(); } } else { retVal = base.Execute(c, dsi); } marshaller.OnDispose(s.Last(), c, dsi); //Notify marshler for dispose. return(retVal); }
public override object Execute(ProtoCore.Runtime.Context c, Interpreter dsi) { Object retVal = base.Execute(c, dsi); List <ProtoCore.DSASM.StackValue> s = dsi.runtime.rmem.Stack; FFIObjectMarshler marshaller = Module.GetMarshaller(dsi.runtime.Core); marshaller.OnDispose(s.Last(), c, dsi); //Notify marshler for dispose. return(retVal); }