예제 #1
0
 static public void UseLocalValueImmediate(this ILCanvas item, Type type, Process <ILLocal> process)
 {
     item.UseLocal(type, delegate(ILLocal local) {
         local.RenderIL_StoreImmediate(item);
         process(local);
     });
 }
예제 #2
0
        public override void RenderIL_LoadAddress(ILCanvas canvas, ILValue target, ILValue index)
        {
            target.RenderIL_Load(canvas);
            index.RenderIL_Load(canvas);

            canvas.Emit_Ldelema(GetElementType());
        }
예제 #3
0
 static public void UseLocalValue(this ILCanvas item, ILValue value, Process <ILLocal> process)
 {
     item.UseLocal(value.GetValueType(), delegate(ILLocal local) {
         local.RenderIL_Store(item, value);
         process(local);
     });
 }
예제 #4
0
        public override void RenderIL_Load(ILCanvas canvas)
        {
            if (method.IsEffectivelyInstanceMethod() && caller != null)
            {
                caller.GetILImplicitCast(method.GetILMethodInvokationType())
                .RenderIL_Load(canvas);

                arguments.GetILImplicitCasts(method.GetEffectiveParameterTypes())
                .RenderIL_Load(canvas);

                if (method.IsTechnicallyInstanceMethod() && method.DeclaringType.IsReferenceType())
                {
                    canvas.Emit_Callvirt(method);
                }
                else
                {
                    canvas.Emit_Call(method);
                }
            }
            else
            {
                arguments.GetILImplicitCasts(method.GetTechnicalParameterTypes())
                .RenderIL_Load(canvas);

                canvas.Emit_Call(method);
            }
        }
예제 #5
0
        public override void RenderIL_Load(ILCanvas canvas)
        {
            if (constructor != null)
            {
                constructor.GetEffectiveParameterTypes().ProcessTandemStrict(arguments,
                                                                             (t, a) => a.GetILImplicitCast(t).RenderIL_Load(canvas)
                                                                             );

                canvas.Emit_Newobj(constructor);
            }
            else
            {
                if (type.IsStruct())
                {
                    canvas.UseLocal(type, delegate(ILLocal local) {
                        local.RenderIL_LoadAddress(canvas);
                        canvas.Emit_Initobj(type);
                        local.RenderIL_Load(canvas);
                    });
                }
                else
                {
                    canvas.Emit_Newobj(type.GetDefaultConstructor());
                }
            }
        }
예제 #6
0
        public override void RenderIL_Execute(ILCanvas canvas)
        {
            ILCanvasLabel exit_label = canvas.CreateLabel();

            condition.GetILImplicitCast(typeof(bool))
            .RenderIL_Load(canvas);

            if (HasElse())
            {
                ILCanvasLabel false_label = canvas.CreateLabel();

                false_label.Emit_Brfalse();
                if_true_statement.RenderIL_Execute(canvas);
                exit_label.Emit_Br();

                false_label.Emit_Label();
                if_false_statement.RenderIL_Execute(canvas);
            }
            else
            {
                exit_label.Emit_Brfalse();
                if_true_statement.RenderIL_Execute(canvas);
            }

            exit_label.Emit_Label();
        }
예제 #7
0
        public override void RenderIL_Store(ILCanvas canvas, ILValue value)
        {
            value.GetILImplicitCast(GetValueType())
            .RenderIL_Load(canvas);

            canvas.Emit_Starg(GetArgIndex(canvas));
        }
예제 #8
0
        public override void RenderIL_Load(ILCanvas canvas, ILValue target, ILValue index)
        {
            target.RenderIL_Load(canvas);
            index.RenderIL_Load(canvas);

            canvas.Emit_Ldelem_I4();
        }
예제 #9
0
        public override void EmitCast(ILCanvas canvas, ILValue value)
        {
            value.RenderIL_Load(canvas);

            canvas.Emit_Unbox_Any(GetDestinationType().GetElementType());
            canvas.MakeAddressImmediate(GetDestinationType().GetElementType());
        }
예제 #10
0
        public override void RenderIL_Execute(ILCanvas canvas)
        {
            GetLocals().Process(l => l.Allocate(canvas));

            statements.Process(s => s.RenderIL_Execute(canvas));

            GetLocals().Process(l => l.Release(canvas));
        }
예제 #11
0
        static public void UseLocal(this ILCanvas item, Type type, Process <ILLocal> process)
        {
            ILLocal local = new ILLocal(type, null, null, false);

            local.Allocate(item);
            process(local);
            local.Release(item);
        }
예제 #12
0
 public override void RenderIL_Load(ILCanvas canvas)
 {
     new ILIf(
         condition,
         new ILLoad(true_value),
         new ILLoad(false_value)
         ).RenderIL_Execute(canvas);
 }
예제 #13
0
 public override void RenderIL_Execute(ILCanvas canvas)
 {
     canvas.UseValue(array, delegate(ILValue local) {
         values.ProcessWithIndex(
             (i, v) => local.GetILIndexed(i).RenderIL_Store(canvas, v)
             );
     });
 }
예제 #14
0
        public void RenderIL_StoreImmediate(ILCanvas canvas)
        {
            if (is_cemented)
            {
                throw new InvalidOperationException("Cannot store to cemented locals.");
            }

            RenderIL_StoreImmediateInternal(canvas);
        }
예제 #15
0
        private ILCanvasLabel FetchLabel(ILCanvas canvas)
        {
            if (label == null)
            {
                label = canvas.CreateLabel();
            }

            return(label);
        }
예제 #16
0
        public override void RenderIL_Load(ILCanvas canvas)
        {
            caller.RenderIL_Load(canvas);

            arguments.GetILImplicitCasts(constructor.GetEffectiveParameterTypes())
            .RenderIL_Load(canvas);

            canvas.Emit_Call(constructor);
        }
예제 #17
0
        public override void RenderIL_Load(ILCanvas canvas)
        {
            value.RenderIL_Load(canvas);

            canvas.Emit_Isinst(check_type);

            canvas.Emit_Ldnull();
            canvas.Emit_Cneq();
        }
예제 #18
0
        private int GetArgIndex(ILCanvas canvas)
        {
            if (canvas.GetMethod().IsTechnicallyInstanceMethod())
            {
                return(parameter.Position + 1);
            }

            return(parameter.Position);
        }
예제 #19
0
        public override void RenderIL_Execute(ILCanvas canvas)
        {
            value.RenderIL_Load(canvas);

            if (value.GetValueType().IsVoidType() == false)
            {
                canvas.Emit_Pop();
            }
        }
예제 #20
0
        private void RenderIL_ExecuteInternal(ILCanvas canvas, ILValue value, ILStatement else_statement)
        {
            int index = cases.Count / 2;

            canvas.UseValue(value, delegate(ILValue local) {
                cases[index].GenerateStatement(local, cases, else_statement, 0, cases.Count, index)
                .RenderIL_Execute(canvas);
            });
        }
예제 #21
0
 public override void RenderIL_Load(ILCanvas canvas)
 {
     canvas.UseValue(
         new ILNewArray(element_type, values.Count),
         delegate(ILValue local) {
         new ILAssignArray(local, values).RenderIL_Execute(canvas);
         local.RenderIL_Load(canvas);
     }
         );
 }
예제 #22
0
        public override void RenderIL_Store(ILCanvas canvas, ILValue target, ILValue index, ILValue value)
        {
            target.RenderIL_Load(canvas);
            index.RenderIL_Load(canvas);

            value.GetILImplicitCast(GetElementType())
            .RenderIL_Load(canvas);

            canvas.Emit_Stelem_I4();
        }
예제 #23
0
        public override void RenderIL_Execute(ILCanvas canvas)
        {
            if (value != null)
            {
                value.GetILImplicitCast(canvas.GetMethod().GetReturnType())
                .RenderIL_Load(canvas);
            }

            canvas.Emit_Ret();
        }
예제 #24
0
        public override void RenderIL_Execute(ILCanvas canvas)
        {
            ILCanvasLabel after_label = canvas.CreateLabel();

            after_label.Emit_Br();

            entry_label.RenderIL_Execute(canvas);
            statement.RenderIL_Execute(canvas);

            after_label.Emit_Label();
        }
예제 #25
0
 static public void UseValue(this ILCanvas item, ILValue value, Process <ILValue> process)
 {
     if (value.IsILCostTrivial())
     {
         process(value);
     }
     else
     {
         item.UseLocalValue(value, l => process(l));
     }
 }
예제 #26
0
 public override void EmitStore(ILCanvas canvas, ILValue target, ILValue to_store)
 {
     if (method_pair.CanSet())
     {
         method_pair.EmitStore(canvas, target, to_store);
     }
     else if (backing_field != null)
     {
         backing_field.EmitStore(canvas, target, to_store);
     }
 }
예제 #27
0
 public override void EmitLoad(ILCanvas canvas, ILValue target)
 {
     if (method_pair.CanGet())
     {
         method_pair.EmitLoad(canvas, target);
     }
     else if (backing_field != null)
     {
         backing_field.EmitLoad(canvas, target);
     }
 }
예제 #28
0
        public override void RenderIL_Load(ILCanvas canvas)
        {
            if (field.IsInstanceField())
            {
                RenderIL_LoadTarget(canvas);

                canvas.Emit_Ldfld(field);
            }
            else
            {
                canvas.Emit_Ldsfld(field);
            }
        }
예제 #29
0
        static public void RenderIL_LoadAddress(this ILValue item, ILCanvas canvas)
        {
            ILAddressable cast;

            if (item.Convert <ILAddressable>(out cast))
            {
                cast.RenderIL_LoadAddress(canvas);
            }
            else
            {
                item.RenderIL_LoadAddressInternal(canvas);
            }
        }
예제 #30
0
        public void RenderIL_LoadAddress(ILCanvas canvas)
        {
            if (field.IsInstanceField())
            {
                RenderIL_LoadTarget(canvas);

                canvas.Emit_Ldflda(field);
            }
            else
            {
                canvas.Emit_Ldsflda(field);
            }
        }