Beispiel #1
0
        public void PushVector3(ref Vector3 vec, ILIntepreter intp, StackObject *ptr, IList <object> mStack)
        {
            intp.AllocValueType(ptr, CLRType);
            var dst = *((StackObject **)&ptr->Value);

            CopyValueTypeToStack(ref vec, dst, mStack);
        }
Beispiel #2
0
        void PushQuaternion(ref Quaternion vec, ILIntepreter intp, StackObject *ptr, IList <object> mStack)
        {
            intp.AllocValueType(ptr, CLRType);
            var dst = *((StackObject **)&ptr->Value);

            CopyValueTypeToStack(ref vec, dst, mStack);
        }
Beispiel #3
0
 unsafe void PushToStackSub(ref StackObject field, int fieldIdx, StackObject *esp, IList <object> managedStack, ILIntepreter intp)
 {
     if (field.ObjectType >= ObjectTypes.Object)
     {
         var obj = managedObjs[fieldIdx];
         if (obj != null)
         {
             var             ot = obj.GetType();
             ValueTypeBinder binder;
             if (ot.IsValueType && type.AppDomain.ValueTypeBinders.TryGetValue(ot, out binder))
             {
                 intp.AllocValueType(esp, binder.CLRType);
                 var dst = ILIntepreter.ResolveReference(esp);
                 binder.CopyValueTypeToStack(obj, dst, managedStack);
                 return;
             }
         }
         *esp = field;
         esp->Value = managedStack.Count;
         managedStack.Add(managedObjs[fieldIdx]);
     }
     else
     {
         *esp = field;
     }
 }
Beispiel #4
0
    private unsafe void PushRect(ref Rect vec, ILIntepreter intp, StackObject *ptr, IList <object> mStack)
    {
        intp.AllocValueType(ptr, CLRType);
        var dst = *((StackObject **)&ptr->Value);

        CopyValueTypeToStack(ref vec, dst, mStack);
    }
Beispiel #5
0
        public void PushVector3(ref TestVector3 vec, ILIntepreter intp, StackObject *ptr, IList <object> mStack)
        {
            intp.AllocValueType(ptr, CLRType);
            var dst = ILIntepreter.ResolveReference(ptr);

            CopyValueTypeToStack(ref vec, dst, mStack);
        }
        public StackObject *Vector3_Add(ILIntepreter intp, StackObject *esp, IList <object> mStack, CLRMethod method, bool isNewObj)
        {
            var ret  = ILIntepreter.Minus(esp, 2);
            var ptrB = ILIntepreter.Minus(esp, 1);
            var b    = ILIntepreter.GetObjectAndResolveReference(ptrB);

            float x, y, z, x2, y2, z2;

            if (b->ObjectType == ObjectTypes.ValueTypeObjectReference)
            {
                var src = *(StackObject **)&b->Value;
                x2 = *(float *)&ILIntepreter.Minus(src, 1)->Value;
                y2 = *(float *)&ILIntepreter.Minus(src, 2)->Value;
                z2 = *(float *)&ILIntepreter.Minus(src, 3)->Value;
                intp.FreeStackValueType(ptrB);
            }
            else
            {
                var src = (TestVector3)mStack[b->Value];
                x2 = src.X;
                y2 = src.Y;
                z2 = src.Z;
                intp.Free(ptrB);
            }

            var ptrA = ILIntepreter.Minus(esp, 2);
            var a    = ILIntepreter.GetObjectAndResolveReference(ptrA);

            if (a->ObjectType == ObjectTypes.ValueTypeObjectReference)
            {
                var src = *(StackObject **)&a->Value;
                x = *(float *)&ILIntepreter.Minus(src, 1)->Value;
                y = *(float *)&ILIntepreter.Minus(src, 2)->Value;
                z = *(float *)&ILIntepreter.Minus(src, 3)->Value;

                intp.FreeStackValueType(ptrA);
            }
            else
            {
                var src = (TestVector3)mStack[a->Value];
                x = src.X;
                y = src.Y;
                z = src.Z;
                intp.Free(ptrA);
            }

            intp.AllocValueType(ret, CLRType);
            var dst = *((StackObject **)&ret->Value);

            *(float *)&ILIntepreter.Minus(dst, 1)->Value = x + x2;
            *(float *)&ILIntepreter.Minus(dst, 2)->Value = y + y2;
            *(float *)&ILIntepreter.Minus(dst, 3)->Value = z + z2;

            return(ret + 1);
        }
Beispiel #7
0
 unsafe void PushToStackSub(ref StackObject field, int fieldIdx, StackObject *esp, IList <object> managedStack, ILIntepreter intp)
 {
     if (field.ObjectType >= ObjectTypes.Object)
     {
         var obj = managedObjs[fieldIdx];
         if (obj != null && (fieldIdx >= 64 || ((valueTypeMask & ((ulong)1 << fieldIdx)) != 0)))
         {
             if (obj is ILTypeInstance)
             {
                 ILTypeInstance ili = (ILTypeInstance)obj;
                 if (ili.type != null && ili.type.IsValueType)
                 {
                     intp.AllocValueType(esp, ili.type);
                     var dst = ILIntepreter.ResolveReference(esp);
                     ili.CopyValueTypeToStack(dst, managedStack);
                     return;
                 }
             }
             else
             {
                 var             ot = obj.GetType();
                 ValueTypeBinder binder;
                 if (ot.IsValueType && type.AppDomain.ValueTypeBinders.TryGetValue(ot, out binder))
                 {
                     intp.AllocValueType(esp, binder.CLRType);
                     var dst = ILIntepreter.ResolveReference(esp);
                     binder.CopyValueTypeToStack(obj, dst, managedStack);
                     return;
                 }
             }
         }
         *esp = field;
         esp->Value = managedStack.Count;
         managedStack.Add(managedObjs[fieldIdx]);
     }
     else
     {
         *esp = field;
     }
 }
        public StackObject *Vector3_Multiply(ILIntepreter intp, StackObject *esp, IList <object> mStack, CLRMethod method, bool isNewObj)
        {
            var ret = ILIntepreter.Minus(esp, 2);

            var ptr = ILIntepreter.Minus(esp, 1);
            var b   = ILIntepreter.GetObjectAndResolveReference(ptr);

            float val = *(float *)&b->Value;

            float x, y, z;

            ptr = ILIntepreter.Minus(esp, 2);
            var a = ILIntepreter.GetObjectAndResolveReference(ptr);

            if (a->ObjectType == ObjectTypes.ValueTypeObjectReference)
            {
                var src = *(StackObject **)&a->Value;
                x = *(float *)&ILIntepreter.Minus(src, 1)->Value;
                y = *(float *)&ILIntepreter.Minus(src, 2)->Value;
                z = *(float *)&ILIntepreter.Minus(src, 3)->Value;
                intp.FreeStackValueType(ptr);
            }
            else
            {
                var src = (TestVector3)mStack[a->Value];
                x = src.X;
                y = src.Y;
                z = src.Z;
                intp.Free(ptr);
            }

            intp.AllocValueType(ret, CLRType);
            var dst = *((StackObject **)&ret->Value);

            *(float *)&ILIntepreter.Minus(dst, 1)->Value = x * val;
            *(float *)&ILIntepreter.Minus(dst, 2)->Value = y * val;
            *(float *)&ILIntepreter.Minus(dst, 3)->Value = z * val;

            return(ret + 1);
        }