From cad11641e59b1c5b5ff97e1c103c281be39c27c7 Mon Sep 17 00:00:00 2001 From: Craig Long Date: Fri, 30 Sep 2022 16:35:08 -0400 Subject: [PATCH 1/2] RevertCode --- .../Reflection/GraphicDataProvider.cs | 27 +++++-------------- src/Engine/ProtoCore/RuntimeCore.cs | 2 -- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/src/Engine/ProtoCore/Reflection/GraphicDataProvider.cs b/src/Engine/ProtoCore/Reflection/GraphicDataProvider.cs index 80602067e8f..7726479a298 100644 --- a/src/Engine/ProtoCore/Reflection/GraphicDataProvider.cs +++ b/src/Engine/ProtoCore/Reflection/GraphicDataProvider.cs @@ -141,41 +141,28 @@ internal List GetGraphicItems(DSASM.StackValue svData, RuntimeCore return null; } - //Store marshaller for repeated calls to GetCLRObject. Used for short-circuit of re-allocation of marshaller / interpreter object. - private static Interpreter interpreter; - private static ProtoFFI.FFIObjectMarshaler marshaler; - internal object GetCLRObject(StackValue svData, RuntimeCore runtimeCore) { if (null == runtimeCore.DSExecutable.classTable) return null; - //The GetCLRObject function is typically utilized to retrieve a ClrObject from a StackValue of type pointer. - //There is an edge cases for pointers where the pointer references a non CLR object. This code - //checks for this edge case by verifying that the requested StackValue pointer is associated with an - //imported library. An example is the "Function" pointer which does not have an associated CLRObject. - //In that case, the return value should be null. - var classNode = runtimeCore.DSExecutable.classTable.GetClassNodeAtIndex(svData.metaData.type); - if (classNode != null && !classNode.IsImportedClass) - { + IList classNodes = runtimeCore.DSExecutable.classTable.ClassNodes; + if (null == classNodes || (classNodes.Count <= 0)) return null; - } - if (marshaler != null) - { - return marshaler.UnMarshal(svData, null, interpreter, typeof(object)); - } + ClassNode classnode = runtimeCore.DSExecutable.classTable.ClassNodes[svData.metaData.type]; + if (!classnode.IsImportedClass) //TODO: look at properties to see if it contains any FFI objects. + return null; try { - interpreter = new ProtoCore.DSASM.Interpreter(runtimeCore, false); + ProtoCore.DSASM.Interpreter interpreter = new ProtoCore.DSASM.Interpreter(runtimeCore, false); var helper = ProtoFFI.DLLFFIHandler.GetModuleHelper(ProtoFFI.FFILanguage.CSharp); - marshaler = helper.GetMarshaler(runtimeCore); + var marshaler = helper.GetMarshaler(runtimeCore); return marshaler.UnMarshal(svData, null, interpreter, typeof(object)); } catch (System.Exception) { - marshaler = null; return null; } } diff --git a/src/Engine/ProtoCore/RuntimeCore.cs b/src/Engine/ProtoCore/RuntimeCore.cs index 9caef966b2e..d5c88188c96 100644 --- a/src/Engine/ProtoCore/RuntimeCore.cs +++ b/src/Engine/ProtoCore/RuntimeCore.cs @@ -6,7 +6,6 @@ using ProtoCore.DSASM; using ProtoCore.Lang; using ProtoCore.Lang.Replication; -using ProtoCore.Mirror; using ProtoCore.Runtime; using ProtoCore.Utils; using ProtoFFI; @@ -272,7 +271,6 @@ public void Cleanup() { OnDispose(); CLRModuleType.ClearTypes(); - GraphicDataProvider.ClearMarshaller(); } public void NotifyExecutionEvent(ExecutionStateEventArgs.State state) From 1bd2af2253cbd7e7d352151f7964591d09f15de1 Mon Sep 17 00:00:00 2001 From: Craig Long Date: Fri, 30 Sep 2022 16:41:34 -0400 Subject: [PATCH 2/2] Remove clear function --- src/Engine/ProtoCore/Reflection/GraphicDataProvider.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/Engine/ProtoCore/Reflection/GraphicDataProvider.cs b/src/Engine/ProtoCore/Reflection/GraphicDataProvider.cs index 7726479a298..2910720456b 100644 --- a/src/Engine/ProtoCore/Reflection/GraphicDataProvider.cs +++ b/src/Engine/ProtoCore/Reflection/GraphicDataProvider.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections; using System.Collections.Generic; using System.Reflection; @@ -166,12 +166,6 @@ internal object GetCLRObject(StackValue svData, RuntimeCore runtimeCore) return null; } } - - internal static void ClearMarshaller() - { - interpreter = null; - marshaler = null; - } } ///