Esempio n. 1
0
        public override bool Call(bool isCallvirt, DmdMethodBase method, ILValue[] arguments, out ILValue?returnValue)
        {
            switch (method.SpecialMethodKind)
            {
            case DmdSpecialMethodKind.Array_Get:
                returnValue = LoadArrayElement(GetZeroBasedIndex(arguments, arguments.Length));
                return(returnValue is not null);

            case DmdSpecialMethodKind.Array_Set:
                StoreArrayElement(GetZeroBasedIndex(arguments, arguments.Length - 1), arguments[arguments.Length - 1]);
                returnValue = null;
                return(true);

            case DmdSpecialMethodKind.Array_Address:
                uint index     = GetZeroBasedIndex(arguments, arguments.Length);
                var  addrValue = ObjValue.GetArrayElementAddressAt(index);
                if (addrValue is not null)
                {
                    runtime.RecordValue(addrValue.Value);
                    Debug.Assert(addrValue.Value.Value !.Type.IsByRef);
                    returnValue = new ByRefILValueImpl(runtime, addrValue.Value.Value);
                }
                else
                {
                    returnValue = new ArrayElementAddress(runtime, this, index);
                }
                return(true);
            }

            return(base.Call(isCallvirt, method, arguments, out returnValue));
        }
Esempio n. 2
0
        public override bool Call(bool isCallvirt, DmdMethodBase method, ILValue[] arguments, out ILValue returnValue)
        {
            switch (method.SpecialMethodKind)
            {
            case DmdSpecialMethodKind.Array_Get:
                returnValue = LoadArrayElement(GetZeroBasedIndex(arguments, arguments.Length));
                return(returnValue != null);

            case DmdSpecialMethodKind.Array_Set:
                StoreArrayElement(GetZeroBasedIndex(arguments, arguments.Length - 1), arguments[arguments.Length - 1]);
                returnValue = null;
                return(true);

            case DmdSpecialMethodKind.Array_Address:
                returnValue = new ArrayElementAddress(runtime, this, GetZeroBasedIndex(arguments, arguments.Length));
                return(true);
            }

            return(base.Call(isCallvirt, method, arguments, out returnValue));
        }