示例#1
0
        public static char ToDotnetChar(IshtarObject *obj, CallFrame frame)
        {
            FFI.StaticTypeOf(frame, &obj, TYPE_CHAR);
            var clazz = obj->decodeClass();

            return((char)(int)(int *)obj->vtable[clazz.Field["!!value"].vtable_offset]);
        }
示例#2
0
        public static float ToDotnetFloat(IshtarObject *obj, CallFrame frame)
        {
            FFI.StaticTypeOf(frame, &obj, TYPE_R4);
            var clazz = obj->decodeClass();

            return(BitConverter.Int32BitsToSingle((int)(int *)obj->vtable[clazz.Field["!!value"].vtable_offset]));
        }
示例#3
0
        public static ulong ToDotnetUInt64(IshtarObject *obj, CallFrame frame)
        {
            FFI.StaticTypeOf(frame, &obj, TYPE_U8);
            var clazz = obj->decodeClass();

            return((ulong)(ulong *)obj->vtable[clazz.Field["!!value"].vtable_offset]);
        }
示例#4
0
        public static bool ToDotnetBoolean(IshtarObject *obj, CallFrame frame)
        {
            FFI.StaticTypeOf(frame, &obj, TYPE_BOOLEAN);
            var clazz = obj->decodeClass();

            return((int)(int *)obj->vtable[clazz.Field["!!value"].vtable_offset] == 1);
        }
示例#5
0
        public static short ToDotnetInt16(IshtarObject *obj, CallFrame frame)
        {
            FFI.StaticTypeOf(frame, &obj, TYPE_I2);
            var clazz = obj->decodeClass();

            return((short)(short *)obj->vtable[clazz.Field["!!value"].vtable_offset]);
        }
示例#6
0
        public static byte ToDotnetUInt8(IshtarObject *obj, CallFrame frame)
        {
            FFI.StaticTypeOf(frame, &obj, TYPE_U1);
            var clazz = obj->decodeClass();

            return((byte)(byte *)obj->vtable[clazz.Field["!!value"].vtable_offset]);
        }
示例#7
0
 protected RuntimeLayerObject(IshtarObject *obj, CallFrame frame)
 {
     _obj   = obj;
     _frame = frame;
     VM.Assert(obj->decodeClass().runtime_token == Class.runtime_token, WNE.TYPE_MISMATCH,
               "Mismatch type when trying create layered object.", frame);
 }
示例#8
0
        public static string ToDotnetString(IshtarObject *obj, CallFrame frame)
        {
            FFI.StaticTypeOf(frame, &obj, TYPE_STRING);
            var clazz = obj->decodeClass();
            var p     = (StrRef *)obj->vtable[clazz.Field["!!value"].vtable_offset];

            return(StringStorage.GetString(p, frame));
        }
示例#9
0
 public void SetMemory(IshtarObject *obj)
 {
     memory      = obj;
     clazz       = obj->clazz;
     flags       = obj->flags;
     vtable_size = obj->vtable_size;
     owner       = obj->owner;
 }
示例#10
0
 public static IshtarObject *IsInstanceOf(CallFrame frame, IshtarObject * @this, RuntimeIshtarClass @class)
 {
     if ([email protected]_inited)
     {
         @class.init_vtable();
     }
     if (@this == null)
     {
         return(null);
     }
     if (@class.IsInterface)
     {
         return(IsInstanceOfByRef(frame, @this, @class));
     }
     return(IsAssignableFrom(frame, @class, @this->decodeClass()) ? @this : null);
 }
示例#11
0
        public static X ToDotnet <X>(IshtarObject *obj, CallFrame frame)
        {
            switch (typeof(X))
            {
            case { } when typeof(X) == typeof(nint):
                return((X)(object)ToDotnetPointer(obj, frame));

            case { } when typeof(X) == typeof(sbyte):
                return((X)(object)ToDotnetInt8(obj, frame));

            case { } when typeof(X) == typeof(byte):
                return((X)(object)ToDotnetUInt8(obj, frame));

            case { } when typeof(X) == typeof(short):
                return((X)(object)ToDotnetInt16(obj, frame));

            case { } when typeof(X) == typeof(ushort):
                return((X)(object)ToDotnetUInt16(obj, frame));

            case { } when typeof(X) == typeof(int):
                return((X)(object)ToDotnetInt32(obj, frame));

            case { } when typeof(X) == typeof(uint):
                return((X)(object)ToDotnetUInt32(obj, frame));

            case { } when typeof(X) == typeof(long):
                return((X)(object)ToDotnetInt64(obj, frame));

            case { } when typeof(X) == typeof(ulong):
                return((X)(object)ToDotnetUInt64(obj, frame));

            case { } when typeof(X) == typeof(bool):
                return((X)(object)ToDotnetBoolean(obj, frame));

            case { } when typeof(X) == typeof(char):
                return((X)(object)ToDotnetChar(obj, frame));

            case { } when typeof(X) == typeof(string):
                return((X)(object)ToDotnetString(obj, frame));

            default:
                VM.FastFail(WNE.TYPE_MISMATCH,
                            $"[marshal::ToDotnet] converter for '{typeof(X).Name}' not support.", frame);
                return(default);
            }
        }
示例#12
0
 public static IshtarObject *ToIshtarString(IshtarObject *obj, CallFrame frame) => obj->decodeClass().TypeCode switch
 {
示例#13
0
 public static nint ToDotnetPointer(IshtarObject *obj, CallFrame frame)
 {
     FFI.StaticTypeOf(frame, &obj, TYPE_RAW);
     return((nint)obj->vtable);
 }
示例#14
0
 public static IshtarObject *IsInstanceOfByRef(CallFrame frame, IshtarObject *c, RuntimeIshtarClass @class)
 {
     // temporary cast to\from interface is not support
     frame.ThrowException(KnowTypes.IncorrectCastFault(frame));
     return(c);
 }