Ejemplo n.º 1
0
        public EmitSyntax EmitInitialization(EmitSyntax emit)
        {
            var types = emit.Types;

            var labels = emit.Labels;

            END   = labels.Generate();
            START = labels.Generate();

            var locals = emit.Locals;

            count = locals.Generate();
            if (Index == null)
            {
                Index = locals.Generate();
                emit.Local(Index, types.Int32);
            }

            if (Value == null)
            {
                Value = locals.Generate();
                emit
                .Local(Value, valueType)
                .Ldc_I4(int.MinValue)
                .Stloc(Value.GetRef());
            }

            emit
            // int count;
            .Local(count, types.Int32);

            // count = array.Length
            ldarray(emit);
            return(emit
                   .Ldlen()
                   .Stloc(count.GetRef())

                   // Index = 0
                   .Ldc_I4(-1)
                   .Stloc(Index.GetRef())
                   // Value = -1
                   .Ldc_I4(-1)
                   .Stloc(Value.GetRef()));

            ;
        }
Ejemplo n.º 2
0
        public EmitSyntax EmitInitialization(EmitSyntax emit)
        {
            var types = emit.Types;

            var labels = emit.Labels;
            END = labels.Generate();
            START = labels.Generate();

            var locals = emit.Locals;
            count = locals.Generate();
            if (Index == null)
            {
                Index = locals.Generate();
                emit.Local(Index, types.Int32);
            }

            if (Value == null)
            {
                Value = locals.Generate();
                emit
                    .Local(Value, valueType)
                    .Ldc_I4(int.MinValue)
                    .Stloc(Value.GetRef());
            }

            emit
                // int count;
                .Local(count, types.Int32);

            // count = array.Length
            ldarray(emit);
            return emit
                .Ldlen()
                .Stloc(count.GetRef())

                // Index = 0
                .Ldc_I4(-1)
                .Stloc(Index.GetRef())
                // Value = -1
                .Ldc_I4(-1)
                .Stloc(Value.GetRef());
                ;
        }