예제 #1
0
        public override StringMangleStackTop?Emit(IStringMangleContext context)
        {
            var emitter = context.Emitter;
            var fr      = new FeatureRequest(Context, emitter);

            using (var r = fr.Enter(context.SourceMethod))
                if (r != null)
                {
                    ValueDemangler cdm;
                    do
                    {
                        cdm = _demanglers.RandomElementOrDefault(Mangler.Rng);
                    } while (fr.IsOnStack(cdm.Method.Method));

                    var part = context.Pieces.Dequeue();
                    using (emitter.UseTempLocal(cdm.Method.Type.TypeMapping.Target.ToTypeSig(), out var instance))
                    {
                        cdm.EmitNew(emitter, Mangler.Rng, instance);
                        var mangledPart = cdm.Codec.Mangle(part.Value);
                        Debug.Assert(Equals(cdm.Codec.Demangle(mangledPart), part.Value));
                        cdm.EmitCall(emitter, Mangler.Rng, instance, mangledPart);
                    }

                    return(StringMangleStackTop.String);
                }

            return(null);
        }
예제 #2
0
        public void Emit(FeatureRequest request, int value)
        {
            ValueDemangler cdm;

            do
            {
                cdm = _demanglers.RandomElementOrDefault(Rng);
            } while (request.IsOnStack(cdm.Method.Method));

            using (request.Emitter.UseTempLocal(cdm.Method.Type.TypeMapping.Target.ToTypeSig(), out var instance))
            {
                cdm.EmitNew(request.Emitter, Rng, instance);
                var mangled = cdm.Codec.Mangle(value);
                Debug.Assert(Equals(cdm.Codec.Demangle(mangled), value));
                cdm.EmitCall(request.Emitter, Rng, instance, mangled);
            }
        }