Esempio n. 1
0
        public override object Execute(ProtoCore.Runtime.Context c, Interpreter dsi, List <StackValue> s)
        {
            Object retVal = base.Execute(c, dsi, s);

            if (retVal == null)
            {
                return(null);
            }

            StackValue propValue  = (StackValue)retVal;
            var        thisObject = s?.Last() ?? dsi.runtime.rmem.Stack.Last();

            bool isValidPointer = thisObject.IsPointer && thisObject.Pointer != Constants.kInvalidIndex;

            if (isValidPointer && propValue.IsReferenceType)
            {
                int classIndex = thisObject.metaData.type;
                if (classIndex != ProtoCore.DSASM.Constants.kInvalidIndex)
                {
                    var runtimeCore = dsi.runtime.RuntimeCore;
                    int idx         = runtimeCore.DSExecutable.classTable.ClassNodes[classIndex].Symbols.IndexOf(PropertyName);

                    var        obj      = runtimeCore.Heap.ToHeapObject <DSObject>(thisObject);
                    StackValue oldValue = obj.GetValueFromIndex(idx, runtimeCore);
                    if (!StackUtils.Equals(oldValue, propValue))
                    {
                        obj.SetValueAtIndex(idx, propValue, runtimeCore);
                    }
                }
            }

            return(retVal);
        }
        public override object Execute(ProtoCore.Runtime.Context c, Interpreter dsi)
        {
            Object retVal = base.Execute(c, dsi);

            if (retVal == null)
            {
                return(null);
            }

            StackValue propValue  = (StackValue)retVal;
            StackValue thisObject = dsi.runtime.rmem.Stack.Last();

            if (StackUtils.IsValidPointer(thisObject) && StackUtils.IsReferenceType(propValue))
            {
                int classIndex = (int)thisObject.metaData.type;
                if (classIndex != ProtoCore.DSASM.Constants.kInvalidIndex)
                {
                    var core    = dsi.runtime.Core;
                    int thisptr = (int)thisObject.opdata;

                    int        idx      = core.ClassTable.ClassNodes[classIndex].symbols.IndexOf(PropertyName);
                    StackValue oldValue = core.Heap.Heaplist[(int)thisObject.opdata].GetValue(idx, core);
                    if (!StackUtils.Equals(oldValue, propValue))
                    {
                        GCUtils.GCRetain(propValue, core);
                        core.Heap.Heaplist[thisptr].SetValue(idx, propValue);
                    }
                }
            }

            return(retVal);
        }
        public override object Execute(ProtoCore.Runtime.Context c, Interpreter dsi)
        {
            Object retVal = base.Execute(c, dsi);

            if (retVal == null)
            {
                return(null);
            }

            StackValue propValue  = (StackValue)retVal;
            StackValue thisObject = dsi.runtime.rmem.Stack.Last();

            bool isValidPointer = thisObject.IsPointer && thisObject.opdata != Constants.kInvalidIndex;

            if (isValidPointer && propValue.IsReferenceType)
            {
                int classIndex = thisObject.metaData.type;
                if (classIndex != ProtoCore.DSASM.Constants.kInvalidIndex)
                {
                    var        runtimeCore = dsi.runtime.RuntimeCore;
                    int        idx         = runtimeCore.DSExecutable.classTable.ClassNodes[classIndex].symbols.IndexOf(PropertyName);
                    StackValue oldValue    = dsi.runtime.rmem.Heap.GetHeapElement(thisObject).GetValue(idx, runtimeCore);
                    if (!StackUtils.Equals(oldValue, propValue))
                    {
                        dsi.runtime.rmem.Heap.GetHeapElement(thisObject).SetValue(idx, propValue);
                    }
                }
            }

            return(retVal);
        }