Example #1
0
        private void GCDisposeObject(StackValue svPtr, Executive exe)
        {
            int classIndex = svPtr.metaData.type;

            if (this.disposeProcedureNode == null || classIndex != previousClassIndex)
            {
                previousClassIndex = classIndex;
                ClassNode cn = exe.exe.classTable.ClassNodes[classIndex];

                isDSObject = !string.IsNullOrEmpty(cn.ExternLib) && cn.ExternLib.Contains(".ds");

                disposeProcedureNode = cn.GetDisposeMethod();
                while (disposeProcedureNode == null)
                {
                    if (cn.Base != Constants.kInvalidIndex)
                    {
                        classIndex           = cn.Base;
                        cn                   = exe.exe.classTable.ClassNodes[classIndex];
                        disposeProcedureNode = cn.GetDisposeMethod();
                    }
                    else
                    {
                        break;
                    }
                }
            }

            //legacy dispose for design script objects.  This may be very rare
            if (disposeProcedureNode != null && isDSObject)
            {
                // TODO Jun/Jiong: Use build pointer utilities
                exe.rmem.Push(StackValue.BuildArrayDimension(0));
                exe.rmem.Push(StackValue.BuildPointer(svPtr.Pointer, svPtr.metaData));
                exe.rmem.Push(StackValue.BuildInt(1));

                ++exe.RuntimeCore.FunctionCallDepth;

                // TODO: Need to move IsExplicitCall to DebugProps and come up with a more elegant solution for this
                // fix for IDE-963 - pratapa
                bool explicitCall = exe.IsExplicitCall;
                bool tempFlag     = explicitCall;
                exe.Callr(disposeProcedureNode.RuntimeIndex, disposeProcedureNode.ID, classIndex, ref explicitCall);

                exe.IsExplicitCall = tempFlag;

                --exe.RuntimeCore.FunctionCallDepth;
            }
            else if (disposeProcedureNode != null)
            {
                exe.CallDispose(disposeProcedureNode, svPtr, classIndex);
            }
        }
Example #2
0
        private void GCDisposeObject(ref StackValue svPtr, Executive exe)
        {
            int           classIndex = svPtr.metaData.type;
            ClassNode     cn         = exe.exe.classTable.ClassNodes[classIndex];
            ProcedureNode pn         = null;

            while (pn == null)
            {
                pn = cn.GetDisposeMethod();
                if (pn == null && cn.baseList != null && cn.baseList.Count != 0) // search the base class
                {
                    // assume multiple inheritance is not allowed
                    // it will only has a single base class
                    classIndex = cn.baseList[0];
                    cn         = exe.exe.classTable.ClassNodes[cn.baseList[0]];
                }
                else
                {
                    break;
                }
            }

            if (pn != null)
            {
                // TODO Jun/Jiong: Use build pointer utilities
                exe.rmem.Push(StackValue.BuildArrayDimension(0));
                exe.rmem.Push(StackValue.BuildPointer(svPtr.opdata, svPtr.metaData));
                exe.rmem.Push(StackValue.BuildBlockIndex(pn.runtimeIndex));
                exe.rmem.Push(StackValue.BuildArrayDimension(0));
                exe.rmem.Push(StackValue.BuildStaticType((int)ProtoCore.PrimitiveType.kTypeVar));

                ++exe.Core.FunctionCallDepth;

                // TODO: Need to move isExplicitCall to DebugProps and come up with a more elegant solution for this
                // fix for IDE-963 - pratapa
                bool explicitCall = exe.isExplicitCall;
                bool tempFlag     = explicitCall;
                exe.Callr(pn.procId, classIndex, 1, ref explicitCall);

                exe.isExplicitCall = tempFlag;

                --exe.Core.FunctionCallDepth;
            }
        }
Example #3
0
        private void GCDisposeObject(StackValue svPtr, Executive exe)
        {
            int       classIndex = svPtr.metaData.type;
            ClassNode cn         = exe.exe.classTable.ClassNodes[classIndex];

            ProcedureNode pn = cn.GetDisposeMethod();

            while (pn == null)
            {
                if (cn.baseList != null && cn.baseList.Count != 0)
                {
                    classIndex = cn.baseList[0];
                    cn         = exe.exe.classTable.ClassNodes[classIndex];
                    pn         = cn.GetDisposeMethod();
                }
                else
                {
                    break;
                }
            }

            if (pn != null)
            {
                // TODO Jun/Jiong: Use build pointer utilities
                exe.rmem.Push(StackValue.BuildArrayDimension(0));
                exe.rmem.Push(StackValue.BuildPointer(svPtr.opdata, svPtr.metaData));
                exe.rmem.Push(StackValue.BuildArrayDimension(0));
                exe.rmem.Push(StackValue.BuildStaticType((int)PrimitiveType.kTypeVar));
                exe.rmem.Push(StackValue.BuildInt(1));

                ++exe.RuntimeCore.FunctionCallDepth;

                // TODO: Need to move IsExplicitCall to DebugProps and come up with a more elegant solution for this
                // fix for IDE-963 - pratapa
                bool explicitCall = exe.IsExplicitCall;
                bool tempFlag     = explicitCall;
                exe.Callr(pn.runtimeIndex, pn.procId, classIndex, ref explicitCall);

                exe.IsExplicitCall = tempFlag;

                --exe.RuntimeCore.FunctionCallDepth;
            }
        }