示例#1
0
        public void Restore(XMRInstAbstract inst, XMRInstArrays.Recver recvValue)
        {
            int classindex = (int)recvValue();

            Construct(inst, classindex);
            this.instVars.RecvArrays(recvValue);
        }
示例#2
0
        protected XMRInstAbstract instance;     // what script it is in

        public HeapTrackerBase(XMRInstAbstract inst)
        {
            if (inst == null)
            {
                throw new ArgumentNullException("inst");
            }
            instance = inst;
        }
示例#3
0
 public HeapTrackerList(XMRInstAbstract inst) : base(inst)
 {
 }
示例#4
0
 public HeapTrackerString(XMRInstAbstract inst) : base(inst)
 {
 }
示例#5
0
 public HeapTrackerObject(XMRInstAbstract inst) : base(inst)
 {
 }
示例#6
0
 public static string ExceptionToString(Exception x, XMRInstAbstract inst)
 {
     return(XMRInstAbstract.xmrExceptionTypeName(x) + ": " + XMRInstAbstract.xmrExceptionMessage(x) +
            "\n" + inst.xmrExceptionStackTrace(x));
 }
示例#7
0
 public XMR_Array(XMRInstAbstract inst)
 {
     this.inst = inst;
     dnary     = new SortedDictionary <object, object>(XMRArrayKeyComparer.singleton);
     heapUse   = inst.UpdateHeapUse(0, EMPTYHEAP);
 }
示例#8
0
        /**
         * @brief Set up everything except the instVars arrays.
         * @param inst = script instance this object is part of
         * @param classindex = which script-defined type class this object is an onstance of
         * @returns with the vtables filled in
         */
        private void Construct(XMRInstAbstract inst, int classindex)
        {
            Delegate[]           thisMid = null;
            TokenDeclSDTypeClass clas    = (TokenDeclSDTypeClass)inst.m_ObjCode.sdObjTypesIndx[classindex];

            xmrInst   = inst;
            sdtcClass = clas;
            instVars  = new XMRInstArrays(inst);

            /*
             * VTable consists of delegates built from DynamicMethods and the 'this' pointer.
             * Yes, yes, lots of shitty little mallocs.
             */
            DynamicMethod[] vDynMeths = clas.vDynMeths;
            if (vDynMeths != null)
            {
                int    n          = vDynMeths.Length;
                Type[] vMethTypes = clas.vMethTypes;
                sdtcVTable = new Delegate[n];
                for (int i = 0; i < n; i++)
                {
                    sdtcVTable[i] = vDynMeths[i].CreateDelegate(vMethTypes[i], this);
                }
            }

            /*
             * Fill in interface vtables.
             * There is one array of delegates for each implemented interface.
             * The array of delegates IS the interface's object, ie, the 'this' value of the interface.
             * To cast from the class type to the interface type, just get the correct array from the table.
             * To cast from the interface type to the class type, just get Target of entry 0.
             *
             * So we end up with this:
             *    sdtcITable[interfacenumber][methodofintfnumber] = delegate of this.ourimplementationofinterfacesmethod
             */
            if (clas.iDynMeths != null)
            {
                int nIFaces = clas.iDynMeths.Length;
                sdtcITable = new Delegate[nIFaces][];
                for (int i = 0; i < nIFaces; i++)
                {
                    // get vector of entrypoints of our instance methods that implement that interface
                    DynamicMethod[] iDynMeths  = clas.iDynMeths[i];
                    Type[]          iMethTypes = clas.iMethTypes[i];

                    // allocate an array with a slot for each method the interface defines
                    int        nMeths = iDynMeths.Length;
                    Delegate[] ivec;
                    if (nMeths > 0)
                    {
                        // fill in the array with delegates that reference back to this class instance
                        ivec = new Delegate[nMeths];
                        for (int j = 0; j < nMeths; j++)
                        {
                            ivec[j] = iDynMeths[j].CreateDelegate(iMethTypes[j], this);
                        }
                    }
                    else
                    {
                        // just a marker interface with no methods,
                        // allocate a one-element array and fill
                        // with a dummy entry.  this will allow casting
                        // back to the original class instance (this)
                        // by reading Target of entry 0.
                        if (thisMid == null)
                        {
                            thisMid    = new Delegate[1];
                            thisMid[0] = markerInterfaceDummy.CreateDelegate(typeof(MarkerInterfaceDummy), this);
                        }
                        ivec = thisMid;
                    }

                    // save whatever we ended up allocating
                    sdtcITable[i] = ivec;
                }
            }
        }
示例#9
0
 /**
  * @brief Called by script's $new() to initialize a new object.
  */
 public XMRSDTypeClObj(XMRInstAbstract inst, int classindex)
 {
     Construct(inst, classindex);
     instVars.AllocVarArrays(sdtcClass.instSizes);
 }