Beispiel #1
0
        protected static void EmitValueTypeLoadAddress(FleeILGenerator ilg, Type targetType)
        {
            int index = ilg.GetTempLocalIndex(targetType);

            Utility.EmitStoreLocal(ilg, index);
            ilg.Emit(OpCodes.Ldloca_S, (byte)index);
        }
        public override void Emit(FleeILGenerator ilg, System.IServiceProvider services)
        {
            int index = ilg.GetTempLocalIndex(typeof(TimeSpan));

            Utility.EmitLoadLocalAddress(ilg, index);

            LiteralElement.EmitInt64Load(MyValue.Ticks, ilg);

            ConstructorInfo ci = typeof(TimeSpan).GetConstructor(new Type[] { typeof(long) });

            ilg.Emit(OpCodes.Call, ci);

            Utility.EmitLoadLocal(ilg, index);
        }
        // Load a PropertyDescriptor based property
        private void EmitVirtualPropertyLoad(FleeILGenerator ilg)
        {
            // The previous value is already on the top of the stack but we need it at the bottom

            // Get a temporary local index
            int index = ilg.GetTempLocalIndex(MyPrevious.ResultType);

            // Store the previous value there
            Utility.EmitStoreLocal(ilg, index);

            // Load the variable collection
            EmitLoadVariables(ilg);
            // Load the property name
            ilg.Emit(OpCodes.Ldstr, MyName);

            // Load the previous value and convert it to object
            Utility.EmitLoadLocal(ilg, index);
            ImplicitConverter.EmitImplicitConvert(MyPrevious.ResultType, typeof(object), ilg);

            // Call the method to get the actual value
            MethodInfo mi = VariableCollection.GetVirtualPropertyLoadMethod(this.ResultType);

            this.EmitMethodCall(mi, ilg);
        }